5 static define ROWOFFSET = 1;
7 class Enumeration : struct
13 static void UnusedFunction()
21 a.OnEdit(null,null,0,0,0,0,0);
22 a.OnDisplay(null,0,0,0,0,0,0);
23 a.OnGetDataFromString(null);
27 extern int __ecereVMethodID_class_OnEdit;
28 extern int __ecereVMethodID_class_OnDisplay;
29 extern int __ecereVMethodID_class_OnGetString;
30 extern int __ecereVMethodID_class_OnGetDataFromString;
31 extern int __ecereVMethodID_class_OnFree;
32 extern int __ecereVMethodID_class_OnCompare;
33 extern int __ecereVMethodID_class_OnCopy;
34 extern int __ecereVMethodID_class_OnSaveEdit;
37 /*static */Window Enum_OnEdit(Class _class, int * data, Window window, Window master,
38 int x, int y, int w, int h, void * userData)
40 Enumeration enumeration = _class.data;
44 window, master = master,
45 borderStyle = 0, //position = { x, y }, size = { w, h },
46 modifyVirtualArea = false, activeStipple = false;
47 anchor = { 0, 0, 0, 0 };
49 bool DataBox::NotifySelect(DropBox control, DataRow row, Modifiers mods)
51 SetData(row.GetData(null), mods.closingDropDown);
55 bool DataBox::NotifyClose(DropBox dropBox)
57 //dropBox.Deactivate();
61 // Read only DataBoxes don't really need the edition, but it will be invoked if autoSize is on because the base class OnEdit check succeeded and chained here,
62 // and it's thinking the editor is going to be an EditBox. We return an editor so the DataBox goes on with life.
63 if(!((DataBox)window).readOnly)
65 dropBox.AddField({ dataType = _class, userData = userData });
68 for(item = enumeration.values.first; item; item = item.next)
70 DataRow row = dropBox.AddRow();
71 row.SetData(null, (uint)item.data); //name);
72 if(data && (int)item.data == *data)
73 dropBox.currentRow = row;
77 dropBox.autoCreate = false;
82 static void OnDisplay(Class _class, void * data, Surface surface, int x, int y, int width, void * fieldData, Alignment alignment, DataDisplayFlags displayFlags)
84 static char tempString[16384];
87 bool needClass = false;
91 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)_class._vTbl[__ecereVMethodID_class_OnGetString])(_class, data, tempString, fieldData, &needClass);
92 len = string ? strlen(string) : 0;
94 //surface.TextOpacity(false);
96 if(!(displayFlags.fullRow) || (displayFlags.header && displayFlags.current))
98 surface.TextExtent(string, len, &w, &h);
102 // Draw the selection background
103 if(!(displayFlags.fullRow) && (displayFlags.selected) && displayFlags.firstField)
104 surface.Area(x - 3, y, x + w + 1, y + h - 1);
107 //surface.WriteTextDots(alignment, x, y + 2, width, string, len);
108 surface.WriteTextDots(alignment, x, y + ROWOFFSET, width, string, len);
112 // Draw the current row stipple
113 if(displayFlags.current && !(displayFlags.fullRow) && displayFlags.firstField)
115 if(displayFlags.active)
117 surface.LineStipple(0x5555);
118 if(displayFlags.selected)
119 surface.SetForeground(0xFFFFFF80);
121 surface.SetForeground(black);
124 surface.SetForeground(SELECTION_COLOR);
125 surface.Rectangle(x - 3, y, x + w + 1, y + h - 1);
126 surface.LineStipple(0);
129 if((displayFlags.header) && (displayFlags.current) && (displayFlags.fullRow || displayFlags.firstField))
131 surface.LineStipple(0xAAAA);
132 surface.SetForeground(black);
133 surface.Rectangle(x-2, y+1, x+w+1, y + h - 1);
134 surface.LineStipple(0);
138 static bool class_OnSaveEdit(Class _class, void ** data, Window editControl, void * object)
140 if(_class.type == enumClass)
142 DropBox dropBox = (DropBox)editControl;
143 return dropBox.Save();
147 bool changed = false;
148 EditBox editBox = (EditBox)editControl;
149 if(editBox.modifiedDocument && (!_class.noExpansion || _class._vTbl[__ecereVMethodID_class_OnGetDataFromString] != (void *)Instance::OnGetDataFromString))
151 if(_class.type == normalClass || _class.type == noHeadClass)
153 ((void (*)(void *, void *))(void *)_class._vTbl[__ecereVMethodID_class_OnFree])(_class, *data);
154 changed = ((bool (*)(void *, void *, const char *))(void *)_class._vTbl[__ecereVMethodID_class_OnGetDataFromString])(_class, data, editBox.line.text);
158 ((void (*)(void *, void *))(void *)_class._vTbl[__ecereVMethodID_class_OnFree])(_class, data);
159 changed = ((bool (*)(void *, void *, const char *))(void *)_class._vTbl[__ecereVMethodID_class_OnGetDataFromString])(_class, data, editBox.line.text);
167 static Window OnEdit(Class _class, void * data, Window window, Window master,
168 int x, int y, int w, int h, void * fieldData)
170 if(_class.type == enumClass)
171 return Enum_OnEdit(_class, data, window, master, x, y, w, h, fieldData);
174 char tempString[MAX_F_STRING] = "";
175 // Don't show the editbox right away so that the text is highlighted by default
179 window, master = master, visible = false, //position = { x, y },
181 modifyVirtualArea = false, //sizeAnchor = { { w, h }, isClientH = true };
182 autoSize = (eClass_IsDerived(window._class, class(DataBox)) ? ((DataBox)window).autoSize : false);
184 void DataBox::NotifyUpdate(EditBox editBox)
187 modifiedDocument = true;
190 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
192 opacity = (active && !readOnly) ? 1.0f : parent.opacity;
193 return EditBox::OnActivate(active, previous, goOnWithActivation, direct);
196 if(!editBox.autoSize)
197 editBox.anchor = { 0, 0, 0, 0 };
199 editBox.anchor = { 0, 0 };
203 bool needClass = false;
204 char * result = ((char *(*)(void *, void *, char *, void *, bool *))(void *)_class._vTbl[__ecereVMethodID_class_OnGetString])(_class, data, tempString, fieldData, &needClass);
209 PrintLn(window._class.name);
211 PrintLn("typeEdit::OnEdit -- editBox.autoSize == true");
213 editBox.contents = string;
214 editBox.visible = true;
218 // editBox.contents = string;
227 public class MultiLineString : String
229 Window OnEdit(DataBox dataBox, DataBox obsolete, int x, int y, int w, int h, void * userData)
231 // Don't show the editbox right away so that the text is highlighted by default
235 dataBox, visible = false,
237 hasHorzScroll = true, hasVertScroll = true,
238 modifyVirtualArea = false,
239 autoSize = dataBox.autoSize;
240 anchor = { 0, 0, 0, 0 };
243 void DataBox::NotifyUpdate(EditBox editBox)
246 modifiedDocument = true;
249 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
251 opacity = active ? 1.0f : parent.opacity;
255 editBox.contents = this;
256 editBox.visible = true;
260 editBox.contents = this;
264 bool OnSaveEdit(Window window, void * object)
266 bool changed = false;
267 EditBox editBox = (EditBox)window;
268 if(editBox.modifiedDocument)
276 for(line = editBox.firstLine; line; line = line.next)
277 size += line.count+1;
278 this = string = new char[size+1];
280 for(line = editBox.firstLine; line; line = line.next)
282 memcpy(string + size, line.text, line.count);
298 __on_register_module()
300 Class baseClass = eSystem_FindClass(module, "class");
301 eClass_AddMethod(baseClass, "OnDisplay", null, OnDisplay, publicAccess);
302 eClass_AddMethod(baseClass, "OnEdit", null, OnEdit, publicAccess);
303 eClass_AddMethod(baseClass, "OnSaveEdit", null, class_OnSaveEdit, publicAccess);