OOFILE  1.9
oofgui.h
Go to the documentation of this file.
1 // COPYRIGHT 1999 A.D. Software, All rights reserved
2 
3 
4 #ifndef H_OOFGUI
5 #define H_OOFGUI
6 
11 #define OOFVERS_GUI 0x01400000 // Version 1.4.0
12 
33 // NOTE inline definitions included at end of this header file
34 #ifndef H_OOF4
35  #include "oof4.h"
36 #endif
37 #ifndef H_OOFMSG
38  #include "oofmsg.h"
39 #endif
40 
42 
43 // forward decls
44 class dbFieldLink;
45 class dbRelRef;
46 class dbHelper;
49 
50 // define MessageT
51 #ifdef _Macintosh
52  #ifndef _H_PP_Types
53  #include <PP_Types.h>
54  #endif
55 // otherwise already defined in oofmsh.h
56 #elif defined _Windows
57 // here because used Boolean in some common GUI interfaces
58  typedef bool Boolean; // but define compatibly anyway
59 #endif
60 
75 public:
76  dbGUIAdapter();
77  virtual ~dbGUIAdapter() {};
78  // use default copy ctor, op=
79 
80  dbFieldLink* fieldLink() const;
81 
82  bool isValuePicker() const;
83  virtual void setValueList(dbView&);
84 
86 
87  virtual dbGUIAdapter* clone() const=0;
88  virtual oofString getString() const=0;
89  virtual void setString(const oofString&)=0;
91 
93 
94  virtual void highlightContents() {};
95  virtual void readOnly(bool) {}; // optional override - may choose to not be able to toggle this state
96  virtual void setFieldLink(dbFieldLink*);
97  virtual bool equalsString(const oofString&) const; // only override to be more efficient
98  virtual bool adaptsControl(void*) const;
100 
102 
103  virtual int getValue() const;
104  virtual void setValue(int);
105  virtual bool equalsValue(int) const;
107 
108 protected:
109  bool IsReadOnly() const;
110 
111 // data storage
114 };
115 
116 
122 public:
123 
125 
126  virtual oofString getString() const;
127  virtual void setString(const oofString&);
129 
131 
132  virtual bool equalsString(const oofString&) const;
134 };
135 
136 
137 
143 public:
144  virtual void editingOccurred();
145  virtual void setTextEntryLimit(unsigned long);
146 };
147 
148 
183 public:
184  dbFieldLink(dbField*, dbGUIAdapter* adoptedAdapter, bool becomeReadOnly=false);
185  dbFieldLink(const dbFieldLink&);
186  virtual ~dbFieldLink();
187  dbHelper* owner() const;
188  void owner(dbHelper*);
189 
191 
192  void maybeChangeTargetLink();
193  void maybeDirty();
194  virtual void tellGUIcareAboutLocking() const;
196 
198 
199  virtual void copyFieldToLink();
200  virtual void copyLinkToField();
201  virtual bool linkEqualsField() const;
202  virtual bool leaveLink();
203  virtual void updateDerivedFieldDisplay(bool isNew);
204  virtual void readOnly(bool isReadOnly=true);
205 
206  virtual bool validToLeaveLink();
207  virtual bool validToLeaveForm();
208 
209  virtual void highlightLink();
210  void markClean();
212 
214 //{@
215  bool isReadOnly() const;
216  bool alwaysReadOnly() const;
217  bool isDirty() const;
218 
219  bool linkIsEmpty() const;
220  dbGUIAdapter* adapter() const;
221 
223 
224  dbField* field() const;
225  void setField(dbField* inField);
226 
227 
228 private:
229  void PreApprovedReadOnly(bool isReadOnly);
230 
231 // data storage
232 protected:
236  bool mMaybeDirty;
237  bool mReadOnly;
239 
240 friend class dbAbstractEditHelper;
241 };
242 
264 public:
265  dbFieldPickLink(dbField*, dbGUIAdapter* adoptedAdapter,
266  bool becomeReadOnly, dbRelRef* pickVia);
268  virtual ~dbFieldPickLink();
269 
271 
272  virtual void copyFieldToLink();
273  virtual void copyLinkToField();
274  virtual bool linkEqualsField() const;
275  virtual bool leaveLink();
276  virtual bool validToLeaveForm();
278 
279  bool allowsNullRelationship() const;
280  void allowNullRelationship(bool inAllowFlag=true);
281  void setDefaultPick(int);
282 
283 protected:
284  void InitLookup();
285 
289  unsigned long mCachedRecordNumber;
291 };
292 
293 
294 
302 public:
303  dbGUI(dbTable*);
304  void gotoCurrentOrNewRec();
305  bool leaveRecord();
306 
307  void newRecord();
308  void saveRecord();
309  void deleteRecord();
310  void revertRecord();
311  void cloneRecord();
312  void goFirstRecord();
313  void goNextRecord();
314  void goPrevRecord();
315  void goLastRecord();
316 
317  dbTable* mainTable() const;
318 
319 
321 
322  bool recordAvailable() const;
323  void dontCareIfLocked();
324  void careIfLocked();
326 
327 protected:
328  bool ConfirmDelete(const char* confirmMessage=0);
329  bool ConfirmRevert();
330  dbAbstractBrowseHelper* GetDisplayTableHandler(void* ioParam);
331 
332 private:
333  bool mClosing;
334  dbTable* mTable;
335  void* mLastDisplayTable;
336  dbAbstractBrowseHelper* mLastBrowser;
337  bool mDontCareIfLocked;
338 
339 public:
341 
342  bool msgForOOFILE(const MessageT, void* ioParam);
343  void goHighlightedRecord(dbAbstractBrowseHelper* inBrowser);
344  void changedSelection(oofReceiver* dontNeedToTell=0);
345  bool isOOFILEcommandEnabled(long commandID, Boolean& outEnabled) const;
346  static bool isOOFILEmsg(const MessageT );
348 };
349 
350 
356 public:
357  dbHelper(dbTable*);
358  virtual ~dbHelper();
359 
360  virtual void maybeChangeTargetLink(dbFieldLink*);
361  virtual void maybeDirty(dbFieldLink*);
362  virtual dbTable* table() const;
363 };
364 
365 
366 
373 public:
376 public:
377  virtual bool receiveMsg(OOFmsgT msg, unsigned long senderDefined);
378  virtual unsigned long highlightedRecNo() const = 0;
379  virtual void highlightRecNo(unsigned long inRecNo, bool bSelect=true) const = 0;
380  virtual void highlightNothing() const = 0;
381  virtual dbSelection highlightedSelection() const = 0;
382  virtual void deleteSelection(const dbSelection& inSel);
383  virtual void updateBrowserSelection() const = 0;
384  virtual dbView* view() const=0; // topmost view
385  virtual dbTable* table() const;
386  virtual void refreshBrowser()=0;
387 };
388 
389 
396 public:
398  virtual ~dbAbstractEditHelper();
399 
400 // generic links used if user supplies dbGUIAdapter
401  void linkAdapter(dbField&, dbGUIAdapter* adoptedAdapter, bool becomeReadOnly=false);
402  void linkAdapter(dbField*, dbGUIAdapter* adoptedAdapter, bool becomeReadOnly=false);
403 
404  void linkPickAdapter(dbField&, dbGUIAdapter* adoptedAdapter,
405  bool becomeReadOnly=false, dbRelRef* pickVia=0);
406 
407  void linkPickAdapter(dbField*, dbGUIAdapter* adoptedAdapter,
408  bool becomeReadOnly=false, dbRelRef* pickVia=0);
409 
410 // mandatory platform-specific overrides
411  virtual void* currentGUItarget() const=0;
412 protected:
413  virtual bool SendFrameworkMessage(OOFmsgT, void* ioParam=0)=0;
414  virtual bool SendImmediateFrameworkMessage(OOFmsgT, void* ioParam=0);
415 
416 public:
417  virtual bool receiveMsg(OOFmsgT msg, unsigned long senderDefined);
418  void adoptLink(dbFieldLink* adoptedLink); // for people to setup their own link & be able to access it!
419 
420  dbFieldLink* getLink(void*); // retrieve manufactured links for given user control
421  virtual dbTable* table() const;
422 
423  bool isDirty();
424  void copyLinksToFields();
425  void copyFieldsToLinks();
426  virtual void maybeChangeTargetLink(dbFieldLink*);
427  virtual void maybeDirty(dbFieldLink*);
428  virtual void updateDerivedFieldDisplays();
429 
430  // default settings, individual fields may override
431  bool isReadOnly() const;
432  void readOnly(bool isReadOnly=true);
433 
435 
436  void msgEnteringAboutToLoad(OOFmsgT);
437  OOFmsgT msgEnteringAboutToLoad();
438 
439  void msgEnteringAfterLoad(OOFmsgT);
440  OOFmsgT msgEnteringAfterLoad();
441 
442  void msgCanSaveRecord(OOFmsgT);
443  OOFmsgT msgCanSaveRecord();
444 
445  void msgConfirmSave(OOFmsgT);
446  OOFmsgT msgConfirmSave();
448 
449 
450 
451  void msgChangedCurrentField(OOFmsgT);
452  OOFmsgT msgChangedCurrentField();
453 
454 protected:
455  virtual void LoadData();
456  void ResetDirtyLinks();
457 
458  virtual bool LeaveRecord();
459  bool ValidateLinks();
460 
462 
463  virtual void EnteringAboutToLoad();
464  virtual void EnteringAfterLoad();
465  virtual bool CanSaveRecord();
466  virtual YNCancelT ConfirmSave();
467  virtual void ChangedCurrentField();
469 
470 // data storage
471  bool mChangingPages, mAutoSaveOnMoving;
472  dbTable* mMainTable; // owned smart pointer
474 // copies of what are probably members of the subclass used to manage the output
475 // list or other database front-end. We need these so we can provide default
476 // behaviour here in the mixin, that can be overridden if absolutely needed
477 // but is useful from day one
478 
479  bool mReadOnly; // default is read-write, applies to all links created after change
481 
482 // user-hook messages
488 
489 
490 public:
491  static void warnUser(std::ostream& os);
492 };
493 
494 
501 public:
502  dbNumericFieldLink(dbField*, dbGUIAdapter*, bool becomeReadOnly);
503 
504  virtual void updateDerivedFieldDisplay(bool isNew);
505 };
506 
507 
512 public:
513  dbBoolLink(dbField*, dbGUIAdapter*, bool becomeReadOnly=false);
514 
515  virtual void copyFieldToLink();
516  virtual void copyLinkToField();
517  virtual bool linkEqualsField() const;
518 };
519 
520 
526 public:
527  dbDateLink2Editor(dbField*, dbGUIAdapter*, bool becomeReadOnly=false);
528 
529  virtual void updateDerivedFieldDisplay(bool isNew);
530  virtual bool validToLeaveLink();
531 };
532 
533 
539 public:
540  dbDateTimeLink2Editor(dbField*, dbGUIAdapter*, bool becomeReadOnly=false);
541 
542  virtual void updateDerivedFieldDisplay(bool isNew);
543  virtual bool validToLeaveLink();
544 };
545 
546 
552 public:
553  dbTableDisplay(unsigned short headingRows=0);
554  virtual ~dbTableDisplay() {};
555  virtual void loadData()=0;
556  virtual void refresh()=0;
557  virtual void changeViewTo(dbView*)=0;
558  virtual long highlightedRow() const=0;
559  virtual long nextHighlightedRow(long afterRow) const=0;
560  virtual void highlightRow(unsigned long, bool bSelect=true)=0;
561  virtual void highlightNothing()=0;
562  virtual void appendRow()=0;
563  virtual void deleteRow(unsigned long zeroBasedRowNum)=0;
564 
565  virtual bool displayUsesControl(void*) const=0;
566  virtual void setDoubleClickMessage(MessageT)=0;
567 protected:
568  unsigned short mHeadingRows;
569 };
570 
571 
572 // -------------------------------------------------------
573 // d b G U I
574 // -------------------------------------------------------
575 
576 inline dbTable*
578 {
579  return mTable;
580 }
581 
582 
588 inline bool
590 {
591  bool ret = mDontCareIfLocked || mTable->lockedCurrentRecord();
592  return ret;
593 }
594 
595 
596 inline void
598 {
599  mDontCareIfLocked = true;
600 }
601 
602 
603 inline void
605 {
606  mDontCareIfLocked = false;
607 }
608 
609 
610 
611 // -------------------------------------------------------
612 // d b A b s t r a c t E d i t H e l p e r
613 // -------------------------------------------------------
614 inline bool
616 {
617  return mReadOnly;
618 }
619 
620 
621 inline void
623 {
624  mMsgEnteringAboutToLoad = inMsg;
625 }
626 
627 
628 inline OOFmsgT
630 {
632 }
633 
634 
635 inline void
637 {
638  mMsgEnteringAfterLoad = inMsg;
639 }
640 
641 
642 inline OOFmsgT
644 {
645  return mMsgEnteringAfterLoad;
646 }
647 
648 
649 inline void
651 {
652  mMsgCanSaveRecord = inMsg;
653 }
654 
655 
656 inline OOFmsgT
658 {
659  return mMsgCanSaveRecord;
660 }
661 
662 
663 inline void
665 {
666  mMsgConfirmSave = inMsg;
667 }
668 
669 
670 inline OOFmsgT
672 {
673  return mMsgConfirmSave;
674 }
675 
676 
677 inline void
679 {
680  mMsgChangedCurrentField = inMsg;
681 }
682 
683 
684 inline OOFmsgT
686 {
688 }
689 
690 
691 inline void
692 dbAbstractEditHelper::linkAdapter(dbField& fld, dbGUIAdapter* adoptedAdapter, bool becomeReadOnly)
693 {
694  linkAdapter(&fld, adoptedAdapter, becomeReadOnly);
695 }
696 
697 
698 inline void
699 dbAbstractEditHelper::linkPickAdapter(dbField& fld, dbGUIAdapter* adoptedAdapter, bool becomeReadOnly, dbRelRef* pickVia)
700 {
701  linkPickAdapter(&fld, adoptedAdapter, becomeReadOnly, pickVia);
702 }
703 
704 
705 
706 // -------------------------------------------------------
707 // d b G U I A d a p t e r
708 // -------------------------------------------------------
710  mFieldLink(0),
711  mIsValuePicker(false)
712 {}
713 
714 
715 inline bool
717 {
718  return mFieldLink->isReadOnly();
719 }
720 
721 
722 inline dbFieldLink*
724 {
725  return mFieldLink;
726 }
727 
728 
729 inline bool
731 {
732  return mIsValuePicker;
733 }
734 
735 
736 // -------------------------------------------------------
737 // d b F i e l d L i n k
738 // -------------------------------------------------------
739 inline void
741 {
742  mMaybeDirty = true;
743  mOwner->maybeDirty(this);
744 }
745 
746 
747 inline void
749 {
750  mMaybeDirty = false;
751 }
752 
753 
754 inline void
756 {
757  assert(mOwner);
759 }
760 
761 
762 inline bool
764 {
765  return mReadOnly;
766 }
767 
768 
769 inline bool
771 {
772  return mAlwaysReadOnly;
773 }
774 
775 
776 inline bool
778 {
779  if (mField)
780  return mField->isDirty();
781  else
782  return mMaybeDirty; // if don't have field, use local status
783 }
784 
785 
786 inline void
788 {
789  mOwner = inOwner;
790 }
791 
792 
793 inline dbHelper*
795 {
796  return mOwner;
797 }
798 
799 
800 
807 inline dbField*
809 {
810  return mField;
811 }
812 
813 
814 inline dbGUIAdapter*
816 {
817  return mAdapter;
818 }
819 
820 
821 inline void
823 {
824  mField = inField;
825 }
826 
827 
828 // -------------------------------------------------------
829 // d b F i e l d L i n k
830 // -------------------------------------------------------
831 inline bool
833 {
835 }
836 
837 
838 inline void
840 {
841  mAllowsNullRelationship = inAllowFlag;
842 }
843 
844 
845 inline void
847 {
848  mDefaultPick = inPick;
849  assert(!mLookupTable || inPick<mLookupTable->countAll());
850 }
851 
852 
853 #endif
854 
messaging layer of OOFILE application development framework.
OOFmsgT msgEnteringAboutToLoad()
Definition: oofgui.h:629
Definition: oofgui.h:41
OOFmsgT mMsgConfirmSave
Definition: oofgui.h:486
Abstract base for Controls.
Definition: oofgui.h:121
void linkPickAdapter(dbField &, dbGUIAdapter *adoptedAdapter, bool becomeReadOnly=false, dbRelRef *pickVia=0)
Definition: oofgui.h:699
virtual void readOnly(bool)
Definition: oofgui.h:95
YNCancelT
Definition: oofgui.h:41
virtual void maybeChangeTargetLink(dbFieldLink *)
Definition: oofgui.cpp:278
dbFieldLink for dbDate that knows how to translate and validate.
Definition: oofgui.h:525
Abstract manager coordinating dbHelper objects that manage interaction on a window.
Definition: oofgui.h:301
virtual ~dbAbstractBrowseHelper()
Definition: oofgui.h:375
bool isReadOnly() const
Definition: oofgui.h:615
OOFmsgT mMsgCanSaveRecord
Definition: oofgui.h:485
dbFieldLink * mFieldLink
reference, maybe null
Definition: oofgui.h:112
Envelope class to contain an abstract selection apart from its dbTable.
Definition: oof1.h:316
bool recordAvailable() const
Editing-aware check if record available.
Definition: oofgui.h:589
OOFmsgT msgConfirmSave()
Definition: oofgui.h:671
dbFieldLink for dbDateTimeLink that knows how to translate and validate.
Definition: oofgui.h:538
bool mIsValuePicker
set at construction to indicate behaviour is picking from list vs entry
Definition: oofgui.h:113
Special limited oofReceiver which will only ever listen to one oofBroadcaster at a time...
Definition: oofmsg.h:133
virtual bool receiveMsg(OOFmsgT msg, unsigned long senderDefined)
The default receiveMsg behaviour is to delete yourself when the broadcaster closes.
Definition: oofmsg.cpp:275
OOFmsgT mMsgEnteringAfterLoad
Definition: oofgui.h:484
void dontCareIfLocked()
Definition: oofgui.h:597
virtual ~dbGUIAdapter()
Definition: oofgui.h:77
virtual oofString getString() const =0
Links a dbField to a known control type or I/O mechanism.
Definition: oofgui.h:74
OOFmsgT mMsgEnteringAboutToLoad
Definition: oofgui.h:483
bool lockedCurrentRecord() const
Definition: oof1.h:2470
dbHelper for managing lists of records.
Definition: oofgui.h:372
Provide an iterable set of fields.
Definition: oofview.h:26
dbTable * mainTable() const
Definition: oofgui.h:577
virtual void setString(const oofString &)=0
OOFmsgT msgEnteringAfterLoad()
Definition: oofgui.h:643
dbHelper for managing an editing form that changes a record.
Definition: oofgui.h:395
virtual dbTable * table() const
Definition: oofgui.cpp:292
bool IsReadOnly() const
Definition: oofgui.h:716
virtual ~dbTableDisplay()
Definition: oofgui.h:554
abstract base to allow us to wrap different list controls.
Definition: oofgui.h:551
OOFmsgT mMsgChangedCurrentField
Definition: oofgui.h:487
Definition: oofgui.h:41
virtual bool equalsString(const oofString &) const
Definition: oofgui.cpp:871
base for any text editing Adapters.
Definition: oofgui.h:142
Base class used to refer to main OOFILE classes and provide base reflective API.
Definition: oof1.h:49
virtual void maybeDirty(dbFieldLink *)
Definition: oofgui.cpp:285
dbFieldLink * mCurrentLink
Definition: oofgui.h:480
virtual void highlightContents()
Definition: oofgui.h:94
Base class for persistent tables.
Definition: oof1.h:452
Generic receiver for messaging.
Definition: oofmsg.h:112
Portable highly capable string class.
Definition: oofstr.h:101
Definition: oofgui.h:41
bool isDirty() const
Definition: oof3.cpp:564
void linkAdapter(dbField &, dbGUIAdapter *adoptedAdapter, bool becomeReadOnly=false)
Definition: oofgui.h:692
OOFmsgT msgCanSaveRecord()
Definition: oofgui.h:657
#define OOFGUI_EXPORT
Prefix for MFC GUI classes to enable optional DLL linking.
Definition: oof0.h:190
dbFieldLink * fieldLink() const
in case someone needs to access it
Definition: oofgui.h:723
Generic broadcaster for messaging.
Definition: oofmsg.h:76
unsigned long OOFmsgT
Definition: oofmsg.h:31
OOFmsgT msgChangedCurrentField()
Definition: oofgui.h:685
void careIfLocked()
Definition: oofgui.h:604
bool isValuePicker() const
Definition: oofgui.h:730
OOF_Dictionary mLinks
Definition: oofgui.h:473
Abstract base Controller class managing database to GUI mapping.
Definition: oofgui.h:355
dbTable * mMainTable
Definition: oofgui.h:472
dbGUIAdapter()
Definition: oofgui.h:709
unsigned short mHeadingRows
Definition: oofgui.h:568
Base class for persistent fields in dbTable's.
Definition: oof3.h:63
Relationship field to 1 or 0 instances.
Definition: oofrel.h:113
Provides searchable dictionary of common OOFILE classes like dbTable.
Definition: oof1.h:159