00001
00002
00003
00004
00005 #ifndef __DATA_DLG_TOOLS
00006 #define __DATA_DLG_TOOLS
00007
00008 #include "GProperties.h"
00009
00010 enum DataDlgType
00011 {
00012 DATA_STR = 1,
00013 DATA_BOOL,
00014 DATA_INT,
00015 DATA_FLOAT,
00016 DATA_PASSWORD,
00017 DATA_STR_SYSTEM
00018
00019
00020 };
00021
00022 class DataDlgTools;
00023
00025 class LgiClass DataDlgField
00026 {
00027 friend class DataDlgTools;
00028
00029 protected:
00030 int Type;
00031 int CtrlId;
00032 char *Option;
00033 char *Desc;
00034
00035 public:
00036 DataDlgField(int type, int ctrlid, char *opt, char *desc = 0);
00037 ~DataDlgField();
00038
00039 int GetType() { return Type; }
00040 int GetCtrl() { return CtrlId; }
00041 char *GetOption() { return Option; }
00042 char *GetDesc() { return Desc; }
00043
00044 void SetOption(char *o) { char *Opt = NewStr(o); DeleteArray(Option); Option = Opt; }
00045 };
00046
00047 typedef List<DataDlgField> DataDlgFieldList;
00048
00050 class LgiClass DataDlgTools
00051 {
00052 protected:
00053 bool DeleteEmptyStrings;
00054 GView *Dlg;
00055 ObjProperties *Options;
00056
00057 public:
00058 DataDlgTools();
00059
00060 void Set(GView *Dlg, ObjProperties *Options);
00061 ObjProperties *GetOptions();
00062
00063 bool ProcessField(DataDlgField *f, bool Write, char *OptionOverride = 0);
00064 bool ProcessFields(DataDlgFieldList &Field, bool Write);
00065 bool LoadFields(DataDlgFieldList &Field);
00066 bool SaveFields(DataDlgFieldList &Field);
00067 };
00068
00069 class LgiClass DRecordSetObj
00070 {
00071 public:
00072 virtual bool Serialize(ObjProperties &f, bool Write)
00073 {
00074 return false;
00075 }
00076 };
00077
00078 class LgiClass DRecordSetCtrls : public DataDlgTools
00079 {
00080
00081 GText *Description;
00082 GScrollBar *Scroll;
00083 int NewRecordId;
00084 int DeleteRecordId;
00085
00086 DataDlgFieldList *Fields;
00087
00088 protected:
00089 DRecordSetObj *Current;
00090 List<DRecordSetObj> *Records;
00091
00092 public:
00093 char *RecordStringTemplate;
00094
00095 DRecordSetCtrls( GView *window,
00096 DataDlgFieldList *fields,
00097 List<DRecordSetObj> *records,
00098 int DescId,
00099 int ScrollId,
00100 int NewId,
00101 int DelId,
00102 char *Template);
00103 ~DRecordSetCtrls();
00104
00105 virtual DRecordSetObj *NewObj() { return 0; }
00106 virtual void DelObj(DRecordSetObj *Obj) {}
00107
00108 int GetCurrentIndex();
00109 void Serialize(bool Write);
00110 void OnMoveRecord(DRecordSetObj *r);
00111 int OnNotify(GView *Col, int Flags);
00112 };
00113
00114 template <class Record>
00115 class LgiClass DRecordSet : public DRecordSetCtrls
00116 {
00117 typedef Record *(*Allocator)(GView *);
00118 Allocator Alloc;
00119
00120 public:
00121 DRecordSet
00122 (
00123 GView *window,
00124 DataDlgFieldList *fields,
00125 List<Record> *records,
00126 int DescId,
00127 int ScrollId,
00128 int NewId,
00129 int DelId,
00130 char *Template,
00131 Allocator a
00132 )
00133 :
00134 DRecordSetCtrls(window, fields, (List<DRecordSetObj>*) records, DescId, ScrollId, NewId, DelId, Template)
00135 {
00136 Alloc = a;
00137 }
00138
00139 DRecordSetObj *NewObj()
00140 {
00141 return Alloc ? Alloc(Dlg) : 0;
00142 }
00143
00144 void DelObj(DRecordSetObj *Obj)
00145 {
00146 Record *r = (Record*) Obj;
00147 if (r)
00148 {
00149 DeleteObj(r);
00150 }
00151 }
00152
00153 Record *ItemAt(int i=-1)
00154 {
00155 return dynamic_cast<Record*>((i<0 OR NOT Records) ? Current : Records->ItemAt(i));
00156 }
00157
00158 void OnMoveRecord(Record *r)
00159 {
00160 DRecordSetCtrls::OnMoveRecord((DRecordSetObj*)r);
00161 }
00162 };
00163
00164 #endif
00165