home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Demos / OOFILE / Buildable, limited OOFILE / OOFILE headers / oofpp.hpp < prev    next >
Encoding:
Text File  |  1995-09-30  |  5.3 KB  |  208 lines  |  [TEXT/CWIE]

  1. // COPYRIGHT 1995 A.D. Software, All rights reserved
  2.  
  3. // Public interface of PowerPlant Integration layer of OOFILE database
  4.  
  5. #ifndef H_OOFPowerPlant
  6. #define H_OOFPowerPlant
  7.  
  8. // COPYRIGHT 1995 A.D. Software, All rights reserved
  9.  
  10. // PowerPlant Integration layer of OOFILE database
  11.  
  12. // NOTE inline definitions included at end of this header file
  13. #include "oof0.hpp"
  14.  
  15. // include PowerPlant definitions
  16.  
  17. #include <PP_Types.h>
  18. const MessageT    cmd_dbFirst            = 'dFst';    // 1682338676
  19. const MessageT    cmd_dbPrev            = 'dPrv';    // 1682993782
  20. const MessageT    cmd_dbNext            = 'dNxt';    // 1682864244
  21. const MessageT    cmd_dbLast            = 'dLst';    // 1682731892
  22.  
  23. const MessageT    cmd_dbNew              = 'dNew';    // 1682859383
  24. const MessageT    cmd_dbEdit            = 'dEdt';    // 1682269300
  25. const MessageT    cmd_dbView            = 'dVuw';    // 1683387767
  26. const MessageT    cmd_dbDel             = 'dDel';    // 1682204012
  27. const MessageT    cmd_dbDoubleClick = 'd2Cl';    // 1681015660
  28.  
  29. // forward declarations of PowerPlant classes to avoid including
  30. class LEditField;
  31. class LTextEdit;
  32. class LCommander;
  33. class LWindow;
  34. class LListBox;
  35.  
  36. // family of abstract link classes
  37. // this is a somewhat messy collection and probably cries out to be
  38. // templated - hey, it's a first cut!
  39.  
  40. // head of family of abstract link classes
  41. // rest are declared in oofppx.hpp
  42.  
  43.  
  44. class dbFieldLink : public dbClass {
  45. private:
  46.     dbFieldLink() {};
  47.  
  48. public:
  49.     virtual void copyFieldToLink()=0;
  50.     virtual void copyLinkToField()=0;
  51. };
  52.  
  53.  
  54. class dbTable;
  55.  
  56. class dbWindowFactory  {
  57. public:
  58.   dbWindowFactory(LCommander* C, dbTable* T) : mCommander(C), mTable(T) {};
  59.   virtual ~dbWindowFactory() {};
  60.     virtual LWindow* makeWindow(const bool loadData=true) const=0;
  61.     dbTable* mainTable();
  62.     
  63. protected:
  64.     LCommander* mCommander;
  65.     dbTable* mTable;
  66. };
  67.  
  68.  
  69. class dbChar;
  70. class dbText;
  71. class dbLong;
  72. class dbShort;
  73. class dbDate;
  74. class dbReal;
  75. class dbDocHelper;
  76. class dbView;
  77. class dbBrowserDisplay;
  78.  
  79. class dbWindowHelper {
  80. protected:
  81.     dbWindowHelper();    
  82.     virtual ~dbWindowHelper() {};
  83.     
  84. public:
  85.     virtual void recordHasBeenChanged(dbWindowHelper* changedBy) {};
  86.     
  87. protected:
  88.     void LinkToDoc();
  89.     dbDocHelper* mBossDoc;
  90. };
  91.  
  92.  
  93. class dbBrowseHelper : public dbWindowHelper {
  94. protected:    // can't create as other than mixin    
  95.     dbBrowseHelper();
  96.     virtual ~dbBrowseHelper();
  97.  
  98. public:
  99.     virtual void recordHasBeenChanged(dbWindowHelper* changedBy);
  100.     
  101. protected:
  102.     bool OOFILEhandlesMessage(const Int32    inMessage, void        *ioParam);
  103.     void DelRecord();
  104.     void AdoptView(dbView*);
  105.     void BrowseViewWithListBox(LListBox*);
  106.     void     LoadBrowseData();
  107.  
  108. private:
  109.   dbView*  mBrowsingView;  // adopted
  110.     dbBrowserDisplay* mBrowserDisplay;  // owned
  111. };
  112.  
  113.  
  114. class dbEditHelper : public dbWindowHelper {
  115. protected:    // can't create as other than mixin    
  116.     dbEditHelper();
  117.     virtual ~dbEditHelper();
  118.  
  119. // USER-HOOKS override the following virtual methods as documented in guihooks.txt
  120.     virtual void EnteringAboutToLoad() {};
  121.     virtual void EnteringAfterLoad() {};
  122.     virtual bool CanLeaveRecord() { return true; };
  123.     virtual void LeavingAboutToSave() {};
  124.     virtual void LeavingAfterSave() {};
  125.  
  126.     void LoadData();
  127.     void SaveRecord();    
  128.     void GoFirstRecord();
  129.     void GoNextRecord();
  130.     void GoPrevRecord();
  131.     void GoLastRecord();
  132.     void LinkField(dbChar&, LEditField*);
  133.     void LinkField(dbChar*, LEditField*);
  134.     void LinkField(dbChar&, LTextEdit*);
  135.     void LinkField(dbChar*, LTextEdit*);
  136.     void LinkField(dbText&, LTextEdit*);
  137.     void LinkField(dbText*, LTextEdit*);
  138.     void LinkField(dbLong&, LEditField*);
  139.     void LinkField(dbLong*, LEditField*);
  140.     void LinkField(dbShort&, LEditField*);
  141.     void LinkField(dbShort*, LEditField*);
  142.     void LinkField(dbDate&, LEditField*);
  143.     void LinkField(dbDate*, LEditField*);
  144.     
  145.     bool OOFILEhandlesMessage(const Int32    inMessage, void        *ioParam);
  146.   bool LeaveRecord();
  147.      void    CopyLinksToFields();
  148.     void    CopyFieldsToLinks();
  149.     
  150. // data storage
  151.     bool    mChangingPages, mNew, mAutoSaveOnMoving;
  152.     dbTable*    mMainTable;  // owned smart pointer
  153.     OOF_Dictionary mLinks;
  154. // copies of what are probably members of the subclass used to manage the output
  155. // list or other database front-end. We need these so we can provide default
  156. // behaviour here in the mixin, that can be overridden if absolutely needed
  157. // but is useful from day one    
  158.  
  159.  
  160. public:
  161.    static void warnUser(ostream& os);
  162. };
  163.  
  164.  
  165. class dbDocHelper {
  166. protected:    // can't create as other than mixin    
  167.     dbDocHelper();
  168.     virtual ~dbDocHelper();
  169.  
  170. public:
  171.     void recordHasBeenChanged(dbWindowHelper* changedBy);  // the Doc will decide if it tells anyone else
  172.     void interestedInRecordChanges(dbWindowHelper*);
  173.     
  174. protected:
  175.     void AdoptAddDialogFactory(dbWindowFactory*);
  176.     void AdoptEditDialogFactory(dbWindowFactory*);
  177.     void AdoptBrowseWindowFactory(dbWindowFactory*);
  178.     bool OOFILEhandlesMessage(const Int32    inMessage, void     *ioParam);
  179.     // the next 3 methods can return NULL if no factory attached
  180.     LWindow* MakeBrowser();
  181.     LWindow* NewRecord();
  182.     LWindow* MakeEditor();
  183.     
  184. protected:
  185.     dbTable*    mMainTable;
  186.  
  187. private:
  188.     dbWindowFactory* mAddFactory;     // owned
  189.     dbWindowFactory* mEditFactory;    // owned 
  190.     dbWindowFactory* mBrowseFactory;  // owned
  191.     dbWindowHelper* mInterestedInRecordChanges;  // will later be a list
  192.     static dbDocHelper*  sCurrentDoc;
  193.     
  194.  
  195. friend bool dbBrowseHelper::OOFILEhandlesMessage(const Int32    inMessage, void        *ioParam);
  196. friend bool dbEditHelper::OOFILEhandlesMessage(const Int32    inMessage, void        *ioParam);
  197. friend void dbWindowHelper::LinkToDoc();
  198. };
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206. #include "oofpp.inl"
  207. #endif
  208.