home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / A.D. Software / OOFILE / Buildable, limited OOFILE / source / GUI / Mac / PPlant / oofpp.hpp < prev    next >
Encoding:
Text File  |  1995-10-10  |  5.4 KB  |  206 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. #include <PP_Types.h>
  17.  
  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. class LStream;
  36. class LStrTableView;
  37.  
  38. // family of abstract link classes
  39. // this is a somewhat messy collection and probably cries out to be
  40. // templated - hey, it's a first cut!
  41.  
  42. // head of family of abstract link classes
  43. // rest are declared in oofppx.hpp
  44.  
  45.  
  46. class dbFieldLink : public dbClass {
  47. private:
  48.     dbFieldLink() {};
  49.  
  50. public:
  51.     virtual void copyFieldToLink()=0;
  52.     virtual void copyLinkToField()=0;
  53. };
  54.  
  55.  
  56. class dbTable;
  57.  
  58. class dbWindowFactory  {
  59. public:
  60.   dbWindowFactory(LCommander* C, dbTable* T) : mCommander(C), mTable(T) {};
  61.   virtual ~dbWindowFactory() {};
  62.     virtual LWindow* makeWindow(const bool loadData=true) const=0;
  63.     dbTable* mainTable();
  64.     
  65. protected:
  66.     LCommander* mCommander;
  67.     dbTable* mTable;
  68. };
  69.  
  70.  
  71. class dbChar;
  72. class dbText;
  73. class dbLong;
  74. class dbShort;
  75. class dbDate;
  76. class dbReal;
  77. class dbDocHelper;
  78. class dbView;
  79. class dbBrowserDisplay;
  80.  
  81. class dbWindowHelper {
  82. protected:
  83.     dbWindowHelper();    
  84.     virtual ~dbWindowHelper() {};
  85.     
  86. public:
  87.     virtual void recordHasBeenChanged(dbWindowHelper* changedBy=0) {};
  88.     
  89. protected:
  90.     void LinkToDoc();
  91.     dbDocHelper* mBossDoc;
  92. };
  93.  
  94.  
  95. class dbBrowseHelper : public dbWindowHelper {
  96. protected:    // can't create as other than mixin    
  97.     dbBrowseHelper();
  98.     virtual ~dbBrowseHelper();
  99.  
  100. public:
  101.     virtual void recordHasBeenChanged(dbWindowHelper* changedBy=0);
  102.     
  103. protected:
  104.     bool OOFILEhandlesMessage(const Int32    inMessage, void        *ioParam);
  105.     void DelRecord();
  106.     void AdoptView(dbView*);
  107.     void BrowseViewWithListBox(LListBox*);
  108.     void BrowseViewWithTable(LStrTableView*);
  109.     void     LoadBrowseData();
  110.     void     RefreshBrowser();
  111.  
  112. private:
  113.   dbView*  mBrowsingView;  // adopted
  114.     dbBrowserDisplay* mBrowserDisplay;  // owned
  115. };
  116.  
  117.  
  118. class dbEditHelper : public dbWindowHelper {
  119. protected:    // can't create as other than mixin    
  120.     dbEditHelper();
  121.     virtual ~dbEditHelper();
  122.  
  123. // USER-HOOKS override the following virtual methods as documented in guihooks.txt
  124.     virtual void EnteringAboutToLoad() {};
  125.     virtual void EnteringAfterLoad() {};
  126.     virtual bool CanLeaveRecord() { return true; };
  127.     virtual void LeavingAboutToSave() {};
  128.     virtual void LeavingAfterSave() {};
  129.  
  130.     void LoadData();
  131.     void SaveRecord();    
  132.     void GoFirstRecord();
  133.     void GoNextRecord();
  134.     void GoPrevRecord();
  135.     void GoLastRecord();
  136.     void LinkField(dbChar&, LEditField*);
  137.     void LinkField(dbChar*, LEditField*);
  138.     void LinkField(dbChar&, LTextEdit*);
  139.     void LinkField(dbChar*, LTextEdit*);
  140.     void LinkField(dbText&, LTextEdit*);
  141.     void LinkField(dbText*, LTextEdit*);
  142.     void LinkField(dbLong&, LEditField*);
  143.     void LinkField(dbLong*, LEditField*);
  144.     void LinkField(dbShort&, LEditField*);
  145.     void LinkField(dbShort*, LEditField*);
  146.     void LinkField(dbDate&, LEditField*);
  147.     void LinkField(dbDate*, LEditField*);
  148.     
  149.     bool OOFILEhandlesMessage(const Int32    inMessage, void        *ioParam);
  150.   bool LeaveRecord();
  151.      void    CopyLinksToFields();
  152.     void    CopyFieldsToLinks();
  153.     
  154. // data storage
  155.     bool    mChangingPages, mNew, mAutoSaveOnMoving;
  156.     dbTable*    mMainTable;  // owned smart pointer
  157.     OOF_Dictionary mLinks;
  158. // copies of what are probably members of the subclass used to manage the output
  159. // list or other database front-end. We need these so we can provide default
  160. // behaviour here in the mixin, that can be overridden if absolutely needed
  161. // but is useful from day one    
  162.  
  163.  
  164. public:
  165.    static void warnUser(ostream& os);
  166. };
  167.  
  168.  
  169. class dbDocHelper {
  170. protected:    // can't create as other than mixin    
  171.     dbDocHelper();
  172.     virtual ~dbDocHelper();
  173.  
  174. public:
  175.     void recordHasBeenChanged(dbWindowHelper* changedBy=0);  // the Doc will decide if it tells anyone else
  176.     void interestedInRecordChanges(dbWindowHelper*);
  177.     
  178. protected:
  179.     void AdoptAddDialogFactory(dbWindowFactory*);
  180.     void AdoptEditDialogFactory(dbWindowFactory*);
  181.     void AdoptBrowseWindowFactory(dbWindowFactory*);
  182.     bool OOFILEhandlesMessage(const Int32    inMessage, void     *ioParam);
  183.     // the next 3 methods can return NULL if no factory attached
  184.     LWindow* MakeBrowser();
  185.     LWindow* NewRecord();
  186.     LWindow* MakeEditor();
  187.     
  188. protected:
  189.     dbTable*    mMainTable;
  190.  
  191. private:
  192.     dbWindowFactory* mAddFactory;     // owned
  193.     dbWindowFactory* mEditFactory;    // owned 
  194.     dbWindowFactory* mBrowseFactory;  // owned
  195.     dbWindowHelper* mInterestedInRecordChanges;  // will later be a list
  196.     static dbDocHelper*  sCurrentDoc;
  197.     
  198.  
  199. friend bool dbBrowseHelper::OOFILEhandlesMessage(const Int32    inMessage, void        *ioParam);
  200. friend bool dbEditHelper::OOFILEhandlesMessage(const Int32    inMessage, void        *ioParam);
  201. friend void dbWindowHelper::LinkToDoc();
  202. };
  203.  
  204. #include "oofpp.inl"
  205. #endif
  206.