1 namespace gui::controls;
6 extern int __ecereVMethodID_class_OnGetString;
7 extern int __ecereVMethodID_class_OnGetDataFromString;
8 extern int __ecereVMethodID_class_OnCompare;
9 extern int __ecereVMethodID_class_OnSerialize;
10 extern int __ecereVMethodID_class_OnUnserialize;
11 extern int __ecereVMethodID_class_OnFree;
12 extern int __ecereVMethodID_class_OnEdit;
13 extern int __ecereVMethodID_class_OnCopy;
14 extern int __ecereVMethodID_class_OnDisplay;
15 extern int __ecereVMethodID_class_OnSaveEdit;
18 public class DataBox : CommonControl
37 virtual void SetData(any_object newData, bool closingDropDown)
39 //type._vTbl[__ecereVMethodID_class_OnCopy](type, data, newData);
43 if(type.type == normalClass || type.type == noHeadClass)
45 if(((void **)data)[0])
46 type._vTbl[__ecereVMethodID_class_OnFree](type, ((void **)data)[0]);
47 ((void **)data)[0] = newData;
51 // Free old data first
52 type._vTbl[__ecereVMethodID_class_OnFree](type, data);
53 type._vTbl[__ecereVMethodID_class_OnCopy](type, data, newData);
57 NotifyChanged(master, closingDropDown);
61 bool SaveData() // TODO: Clear this up, along with Saving DataBox
63 if(editor && type._vTbl[__ecereVMethodID_class_OnSaveEdit](type, data, editor, null))
66 NotifyChanged(master, false);
75 NotifyModified(master);
92 virtual bool Window::NotifyModified();
93 virtual bool Window::NotifyChanged(bool closingDropDown);
94 virtual void OnConfigure(Window editor);
100 if(type && !readOnly && (type.type == normalClass || type.type == noHeadClass || data))
102 // IMPORTANT FIX: If keepEditor is true, we were passing editor rather than the editor's current master
103 editor = (Window)type._vTbl[__ecereVMethodID_class_OnEdit](type,
104 (type.type == normalClass || type.type == noHeadClass) ? (data ? (*(void **)data) : null) : data,
105 this, (keepEditor && editor) ? editor.master : this, 0, 0, clientSize.w, clientSize.h, fieldData);// null);
108 // editor.anchor = { 0, 0, 0, 0 };
109 editor.background = background;
110 editor.foreground = foreground;
111 editor.opacity = opacity;
115 // TODO: Should returning 0 from OnPostCreate cancel creation?
123 void OnRedraw(Surface surface)
127 char tempString[1024];
131 if(type.type == noHeadClass || type.type == normalClass)
132 s = (String)type._vTbl[__ecereVMethodID_class_OnGetString](type, *(void **)this.data, tempString, fieldData, null);
134 s = (String)type._vTbl[__ecereVMethodID_class_OnGetString](type, this.data, tempString, fieldData, null);
136 stringValue = CopyString(s);
139 type._vTbl[__ecereVMethodID_class_OnDisplay](class(String), stringValue, surface, 3, 1, clientSize.w, fieldData, type.defaultAlignment, 0);
148 void OnPosition(int x, int y, int width, int height)
151 editor.OnPosition(editor.position.x, editor.position.y, editor.size.w, editor.size.h);
154 bool OnKeyHit(Key key, unichar ch)
156 return editor ? editor.OnKeyHit(key, ch) : true;
159 bool OnKeyDown(Key key, unichar ch)
161 if((SmartKey)key == enter)
166 else if((SmartKey)key == escape)
171 return editor ? editor.OnKeyDown(key, ch) : true;
175 public class SavingDataBox : DataBox
177 class_property(icon) = "<:ecere>controls/dataBox.png";
179 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
181 if(!active && editor && !editor.modalSlave)
189 bool OnKeyDown(Key key, unichar ch)
191 if((SmartKey)key == enter)
194 // Force Refresh on Enter if SaveData didn't do it
198 return DataBox::OnKeyDown(key, ch);