00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 #ifndef INC_MI32_DBEDIT_H
00089 #define INC_MI32_DBEDIT_H
00090
00091 #ifndef INC_MI32_LONGLIST_H
00092 #include <mi32/longlist.h>
00093 #endif
00094
00095 #ifndef INC_MI32_ELEMSTYL_H
00096 #include <mi32/elemstyl.h>
00097 #endif
00098
00099 #ifndef INC_MI32_MICALLBACKLIST_H
00100 #include <mi32/micallbacklist.h>
00101 #endif
00102
00103 #ifndef INC_RVC_STYLE_H
00104 #include <rvc/style.h>
00105 #endif
00106
00107 #ifndef INC_RVC_DBELEM_H
00108 #include <rvc/dbelem.h>
00109 #endif
00110
00111
00112
00113
00114 #ifndef GENERATING_DOXYGEN_OUTPUT
00115
00116 class DBEDIT;
00117 class DBEDIT_TDATA;
00118 class DBEDIT_TINSTANCE;
00119 class DBEDIT_STYLEDIALOG;
00120 struct DBEDIT_FIELDOPT;
00121
00122 struct RECSTYLESAMPLE;
00123 namespace RVC {
00124 class DBASE;
00125 class DBASE_ELEMENT;
00126 namespace UI {
00127 class DLG_DB_BASE;
00128 class FORM_DB_RECORD;
00129 }
00130 }
00131 namespace MGUI {
00132 class LAYOUT_PANE_BASE;
00133 }
00134 #endif // GENERATING_DOXYGEN_OUTPUT
00135
00136
00137
00139 struct DBEDIT_MSG : public MICALLBACKLIST::ANYCALLBACKSTRUCT {
00140
00141 enum REASON {
00142 REASON_ALL = 0x00000000,
00143 REASON_TableOpen = 0x00000001,
00144 REASON_TableClose = 0x00000002,
00145 REASON_FormOpen = 0x00000004,
00146 REASON_FormClose = 0x00000008,
00147 REASON_Destroy = 0x80000000,
00148 REASON_Modify = 0x04000000,
00149 REASON_SelectElements = 0x00000010,
00150 REASON_UnselectElements = 0x00000020,
00151 REASON_ToggleElements = 0x00000040,
00152 REASON_SelectOnly = 0x00000080,
00153 REASON_Elements = 0x000000F0,
00154 REASON_FormObjectCreate = 0x00000100,
00155 REASON_FormObjectDestroy= 0x00000200,
00156 REASON_AutoComplete = 0x00000400
00157 };
00158
00160 DBEDIT_MSG (
00161 DBEDIT* p_DBEdit,
00162 REASON r
00163 ) :
00164 ANYCALLBACKSTRUCT(r),
00165 DBEdit(p_DBEdit),
00166 TableNum(0),
00167 ElemType(ELEMTYPE_Empty),
00168 Record(0)
00169 { }
00170
00171 RVC::OBJITEM ObjItem;
00172 DBEDIT* DBEdit;
00173 ELEMTYPE ElemType;
00174 INT32 TableNum;
00175 INT32 Record;
00176 SIMPLE_ARRAY<INT32> Records;
00177 };
00178
00179 #ifndef GENERATING_DOXYGEN_OUTPUT
00180 DEFINE_ENUM_OP_BITWISE(DBEDIT_MSG::REASON)
00181 #endif
00182
00183
00184
00186 class DBEDIT {
00187 public:
00188
00189 #ifndef GENERATING_DOXYGEN_OUTPUT
00190 enum MODE {
00191 MODE_SingleRecord = 0,
00192 MODE_UserDefined,
00193 MODE_TabularView,
00194 MODE_NumModes
00195 };
00196 #endif
00197
00199 enum VIEWFLAGS {
00200 VIEWFLAG_None = 0,
00201 VIEWFLAG_ViewActive = 0x00000001,
00202 VIEWFLAG_ViewSelected = 0x00000002,
00203 VIEWFLAG_ViewAll = 0x00000004,
00204 VIEWFLAG_NoChangeViewMode = 0x00000008,
00205 VIEWFLAG_NoSwitchTableView = 0x00000010,
00206 VIEWFLAG_NoRecordSelection = 0x00000020,
00207 VIEWFLAG_NoAttachmentIndicator = 0x00000040,
00208 VIEWFLAG_NoRowControls = (VIEWFLAG_NoRecordSelection|VIEWFLAG_NoAttachmentIndicator),
00209 VIEWFLAG_NoNewRecord = 0x00000080,
00210 VIEWFLAG_NoDropTable = 0x00000100,
00211 VIEWFLAG_NoEditDefn = 0x00000200,
00212 VIEWFLAG_TabularView = 0x00000400,
00213 VIEWFLAG_NoElementSelection = 0x00000800,
00214 VIEWFLAG_NoCreateIfNotExist = 0x00001000,
00215 VIEWFLAG_SingleRecordView = 0x00002000
00216 };
00217
00218 enum LABELCOLOR {
00219 LABELCOLOR_Normal = 0,
00220 LABELCOLOR_Computed,
00221 LABELCOLOR_PK,
00222 LABELCOLOR_FK
00223 };
00224
00225 enum CREATEFLAGS {
00226 CREATEFLAG_None = 0x00,
00227 CREATEFLAG_NoEdit = 0x01,
00228 CREATEFLAG_AllowEditInTNTatlas = 0x20
00229 };
00230
00231 struct EVENT {
00232 EVENT();
00233 EVENT(const EVENT& rhs);
00234 INT32 reason;
00235 INT32 table;
00236 INT32 record;
00237 UINT32 subreason;
00238 };
00239
00240 static RVC::UI::DLG_DB_BASE* DlgConstructTabularView (
00241 DBEDIT_TINSTANCE *idata
00242 );
00243
00245 static void SML_Install (
00246 SML::CONTEXT *context
00247 );
00248
00251 static ERRVALUE TableCreateDefinition (
00252 MDLGPARENT parent,
00253 RVC::OBJTYPE DBaseObjType,
00254 RVC::DBTABLE::MAKEPARMS& MakeParms,
00255 RVC::DESCRIPTOR& Descriptor
00256 );
00257
00260 DBEDIT ();
00261
00263 ~DBEDIT();
00264
00266 ERRVALUE CallbackAdd (
00267 void (*func)(const DBEDIT_MSG *, void *),
00268 void *data,
00269 DBEDIT_MSG::REASON reason
00270 );
00271
00273 void CallbackRemove (
00274 void (*func)(const DBEDIT_MSG *, void *),
00275 void *data,
00276 DBEDIT_MSG::REASON reason
00277 );
00278
00282 void CallCallbacks (
00283 DBEDIT_MSG& cbs
00284 );
00285
00287 bool CanMakeTableImplied (
00288 ) const;
00289
00291 int Close ();
00292
00294 int Create (
00295 MDLGPARENT parent,
00296 const RVC::OBJITEM& ParentObjItem,
00297 ELEMTYPE elemtype,
00298 CREATEFLAGS flags = CREATEFLAG_None,
00299 const RVC::CREDENTIALS* Credentials = 0
00300 );
00301
00307 void DBCallbackSuspend (
00308 bool ReallyIgnore,
00309 bool Totally = false
00310 );
00311
00316 void DBCallbackResume (
00317 bool ReallyIgnore,
00318 bool Totally = false
00319 );
00320
00321 #ifndef GENERATING_DOXYGEN_OUTPUT
00325 int FindRecords (
00326 int active
00327 );
00328 #endif
00329
00331 int Flush ();
00332
00334 int FormClose (
00335 const RVC::OBJITEM& ObjItem
00336 );
00337
00339 int FormDrop (
00340 MDLGPARENT dlgparent,
00341 const RVC::OBJITEM& ObjItem
00342 );
00343
00345 int FormNew (
00346 MDLGPARENT dlgparent,
00347 VIEWFLAGS flags = VIEWFLAG_None,
00348 const RVC::CREDENTIALS* Credentials = 0
00349 );
00350
00352 int FormOpen (
00353 const RVC::OBJITEM& ObjItem,
00354 VIEWFLAGS flags = VIEWFLAG_None,
00355 const RVC::CREDENTIALS* Credentials = 0
00356 );
00357
00359 ERRVALUE GenViewCreate (
00360 MGUI::LAYOUT_PANE_BASE& ParentPane,
00361 INT32 TableNum,
00362 RVC::UI::FORM_DB_RECORD **ppFormRet = 0,
00363 DBEDIT::VIEWFLAGS flags = VIEWFLAG_None
00364 );
00365
00369 INT32 GetActiveElement (
00370 ) const {
00371 return (m_ActiveElemNum);
00372 }
00373
00374 INT32 GetBaseTableNum (
00375 ) const { return (m_BaseTable); }
00376
00377 CREATEFLAGS GetCreateFlags () const
00378 { return (m_flags); }
00379
00380 const RVC::CREDENTIALS* GetCredentials (
00381 ) const { return (m_Credentials); }
00382
00383 RVC::DBASE_ELEMENT* GetDBase (
00384 ) const {
00385 return m_DBase;
00386 }
00387
00389 RVC::DBASE::OBSERVER *GetDBRelateHandle() const {
00390 return (m_DBRelateHandle);
00391 }
00392
00395 MISTRING GetDisplayPath () const;
00396
00398 MDLGPARENT GetDlgParent (
00399 ) const { return (m_dlgparent); }
00400
00402 const LONGLIST& GetElemList (
00403 ) const { return (m_ElemList); }
00404
00406 ELEMTYPE GetElemType (
00407 ) const { return (m_ElemType); }
00408
00410 void GetLabelColorFromFlags (
00411 RVC::DBTABLE::FIELDINFO::FLAGS fieldflags,
00412 COLOR& color
00413 );
00414
00416 void GetLabelColor (
00417 LABELCOLOR colornum,
00418 COLOR& color
00419 );
00420
00422 int GetNumOpen ();
00423
00425 const RVC::OBJITEM& GetObjItem (
00426 ) const { return m_ObjItem; }
00427
00431 const RVC::OBJITEM& GetParentObjItem (
00432 ) const { return m_ParentObjItem; }
00433
00435 MDLGPARENT GetParent (
00436 ) const {
00437 return m_dlgparent;
00438 }
00439
00443 bool GetStyleObject (
00444 RVC::STYLE& StyleObj
00445 );
00446
00448 inline DBEDIT_TDATA * GetTableData (
00449 int table
00450 ) const {
00451 if (table == -2) table = -1;
00452 ++table;
00453 if (table < 0 || static_cast<UINT32>(table) >= m_TableData.GetNumItems()) return (NULL);
00454 return (m_TableData[table]);
00455 }
00456
00460 DBEDIT_TINSTANCE * GetTableInstanceHandle (
00461 INT32 TableNum,
00462 VIEWFLAGS flags
00463 );
00464
00465 bool HasCallbacks (
00466 UINT32 reason
00467 ) const { return (m_CBList.HasCallbacks(reason)); }
00468
00470 bool IsCreated (
00471 ) const {
00472 return (m_DBase != 0);
00473 }
00474
00476 bool IsFormOpen (
00477 const RVC::OBJITEM& ObjItemForm
00478 );
00479
00481 int IsMainLevel (
00482 ) const {
00483 return (m_DBase != 0 && m_DBase->GetElemType() == ELEMTYPE_Empty);
00484 }
00485
00490 int IsPinMapping (
00491 ) const {
00492 return (m_pin_mapping);
00493 }
00494
00496 int IsTableOpen (
00497 int TableNum
00498 );
00499
00500
00504 int ModalSingleRecordView (
00505 INT32 TableNum,
00506 INT32 RecordNum,
00507 RVC::DBTABLE::RECORD* InitVal,
00508 MDLGPARENT dlgparent,
00509 UINT32 flags = 0
00510 );
00511
00513 int MultiSelectAddElement (
00514 INT32 ElemNum
00515 );
00516
00518 int MultiSelectRemoveElement (
00519 INT32 ElemNum
00520 );
00521
00527 ERRVALUE MultiSelectStart (
00528 int BaseTable = 0
00529 );
00530
00532 ERRVALUE MultiSelectEnd (
00533 bool UpdateDialogs = true
00534 );
00535
00536 void OnEvent(const DBEDIT::EVENT& event, bool bDeferable = true);
00537
00538 #ifdef X_NATIVE
00541 ERRVALUE OpenTreeView (
00542 UINT32 flags = 0
00543 );
00544 #endif
00545
00551 int RefreshActiveElementAttachments (
00552 bool UpdateDialogs = true
00553 );
00554
00556 ERRVALUE SetActiveElement (
00557 ELEMNUM ElemNum,
00558 INT32 BaseTable = 0
00559 ) { return (SetActiveElementLow(ElemNum,true,BaseTable)); }
00560
00562 void SetBaseTable (
00563 int table
00564 );
00565
00567 void SetDBRelateHandle (
00568 RVC::DBASE::OBSERVER* handle
00569 ) {
00570 m_DBRelateHandle = handle;
00571 }
00572
00574 ERRVALUE SetElements (
00575 INT32 BaseTable,
00576 const UNSIGNEDSET& ElemSet,
00577 ELEMNUM ActiveElemNum
00578 );
00579
00581 void SetParent (
00582 MDLGPARENT parent
00583 ) {
00584 m_dlgparent = parent;
00585 }
00586
00591 int SetStyleNumber (
00592 int StyleNum,
00593 int RecNum
00594 );
00595
00597 int SetStyleObject (
00598 const RVC::OBJITEM& StyleObjItem,
00599 const RVC::OBJECTNAME& StyleTableName,
00600 const void *dftstyle
00601 );
00602
00604 int StyleDialogOpen (
00605 MDLGPARENT parent
00606 );
00607
00611 int StyleDialogClose (
00612 );
00613
00618 int TableCreate (
00619 MDLGPARENT parent,
00620 const RVC::DBTABLE::MAKEPARMS& MakeParms,
00621 const RVC::DESCRIPTOR* Descriptor = 0
00622 );
00623
00626 int TableCreate (
00627 MDLGPARENT parent
00628 );
00629
00631 int TableDrop (
00632 MDLGPARENT parent,
00633 int TableNum
00634 );
00635
00637 int TableEditDefinition (
00638 MDLGPARENT parent,
00639 int TableNum
00640 );
00641
00643 ERRVALUE TableEditACL (
00644 MDLGPARENT parent,
00645 int TableNum
00646 );
00647
00649 int TableOpen (
00650 INT32 TableNum,
00651 VIEWFLAGS flags = VIEWFLAG_None
00652 );
00653
00655 int TableClose (
00656 INT32 TableNum
00657 );
00658
00660 int TableDestroy (
00661 int TableNum
00662 );
00663
00665 int UpdateDialogs ();
00666
00671 int UpdateResume (
00672 );
00673
00675 void UpdateSuspend();
00676
00677 #ifndef GENERATING_DOXYGEN_OUTPUT
00678
00679
00680
00681
00682
00683
00684 #endif
00685
00686 private:
00687 #ifndef GENERATING_DOXYGEN_OUTPUT
00688
00689 class OBSERVER : public RVC::DBASE::OBSERVER {
00690 public:
00691 OBSERVER (
00692 DBEDIT* ddata
00693 ) :
00694 RVC::DBASE::OBSERVER(*ddata->GetDBase()),
00695 m_ddata(ddata) {}
00696
00697 virtual ~OBSERVER() {}
00698
00699 virtual void OnDBListAdd(ELEMTYPE ElemType, INT32 ElemNum);
00700 virtual void OnDBListChanged(ELEMTYPE ElemType, INT32 ElemNum);
00701 virtual void OnStructChanged(INT32 TableNum, STRUCTCHANGE SubReason);
00702 virtual void OnTableAdd(INT32 TableNum);
00703 virtual void OnTableDropBegin(INT32 TableNum);
00704 virtual void OnTableDropEnd(INT32 TableNum);
00705 virtual void OnBulkModifyBegin();
00706 virtual void OnBulkModifyEnd();
00707 private:
00708 DBEDIT* m_ddata;
00709 };
00710
00711 MDLGPARENT m_dlgparent;
00712 CREATEFLAGS m_flags;
00713 bool m_is_main_level;
00714 bool m_pin_mapping;
00715 bool m_multi_select;
00716 bool m_ReallyIgnoreCallback_DamnIt;
00717 bool m_NeedUpdate;
00718
00719 RVC::OBJITEM m_ObjItem;
00720 RVC::OBJITEM m_ParentObjItem;
00721 RVC::DBASE_ELEMENT* m_DBase;
00722
00723 INT32 m_ActiveElemNum;
00724 LONGLIST m_ElemList;
00725 ELEMTYPE m_ElemType;
00726 INT32 m_BaseTable;
00727 DBEDIT_TDATA **m_formtdata;
00728 DBEDIT_TDATA *m_OrphanInstances;
00729 int m_numtdatas, m_numforms;
00730 int m_CreatingTable;
00731 MICALLBACKLIST m_CBList;
00732 struct STYLE {
00733 RVC::OBJITEM m_StyleObjItem;
00734 int m_table;
00735 bool m_bDefaultKnown;
00736 DBEDIT_STYLEDIALOG *m_dlg;
00737 MULTISTYLE m_dft;
00738
00739 STYLE (
00740 ) :
00741 m_table(0),
00742 m_bDefaultKnown(false),
00743 m_dlg(0)
00744 { }
00745 } m_Style;
00746 RVC::DBASE::OBSERVER *m_DBRelateHandle;
00747 int m_IgnoreCallback;
00748 void *m_ClassPrivData[MODE_NumModes];
00749
00750 MILIST<EVENT> m_DBEventQueue;
00751 bool m_bDrainingQueue;
00752 int m_ReallyIgnoreCallbacks;
00753 SIMPLE_ARRAY<DBEDIT_TDATA*> m_TableData;
00754 OBSERVER *m_Observer;
00755 RVC::CREDENTIALS *m_Credentials;
00756
00760 DBEDIT_TINSTANCE *FindFormInstance (
00761 const RVC::OBJITEM& ObjItem
00762 );
00763
00765 ERRVALUE ForEachTableInstance (
00766 int (DBEDIT_TINSTANCE::*Func)(void*),
00767 void *hookdata
00768 );
00769
00771 ERRVALUE ForEachTableInstance (
00772 int (DBEDIT_TINSTANCE::*Func)(void)
00773 );
00774
00779 void DrainQueue ();
00780
00782 void UpdateDialogsInternal ();
00783
00785 int EnqueueDBEvent (
00786 const EVENT& event
00787 );
00788
00790 void DequeueDBEvent ();
00791
00802 void Dispatch (
00803 const EVENT& event
00804 );
00805
00809 int CreateDBEDIT_TDATA (
00810 int TableNum
00811 );
00812
00813 ERRVALUE OpenDatabaseLow (
00814 const RVC::OBJITEM& ParentObjItem,
00815 ELEMTYPE elemtype,
00816 UINT32 mode,
00817 const RVC::CREDENTIALS* Credentials
00818 );
00819
00821 ERRVALUE SetActiveElementLow (
00822 ELEMNUM ElemNum,
00823 bool UpdateDialogs,
00824 INT32 BaseTable = 0
00825 );
00826
00827 friend class DBEDIT_TDATA;
00828 friend class DBEDIT_TINSTANCE;
00829 friend class DBEDIT_STYLEDIALOG;
00830 #endif // GENERATING_DOXYGEN_OUTPUT
00831 };
00832
00833 #ifndef GENERATING_DOXYGEN_OUTPUT
00834 DEFINE_ENUM_OP_BITWISE(DBEDIT::VIEWFLAGS)
00835 DEFINE_ENUM_OP_INCREMENT(DBEDIT::LABELCOLOR)
00836 #endif
00837
00838
00839
00844 class DBEDIT_SUSPENDCALLBACKS {
00845 public:
00846
00848 DBEDIT_SUSPENDCALLBACKS (
00849 DBEDIT *ddata,
00850 bool NoQueue = false
00851 ):
00852 m_ddata(ddata),
00853 m_NoQueue(NoQueue)
00854 {
00855 if (m_ddata != 0) m_ddata->DBCallbackSuspend(m_NoQueue);
00856 }
00857
00859 ~DBEDIT_SUSPENDCALLBACKS (
00860 ) {
00861 if (m_ddata != 0) m_ddata->DBCallbackResume(m_NoQueue);
00862 }
00863
00864 private:
00865 #ifndef GENERATING_DOXYGEN_OUTPUT
00866 DBEDIT *m_ddata;
00867 bool m_NoQueue;
00868 #endif // GENERATING_DOXYGEN_OUTPUT
00869 };
00870
00871
00872
00873 #endif