3 extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp;
5 static __attribute__((unused)) void Dummy()
8 a.OnLeftButtonUp(0,0,0);
11 class ToolBox : Window
14 background = formColor;
15 borderStyle = sizable;
17 //size = { 200, 500 };
19 anchor = { right = 0 };
20 //anchor = { right = 0, top = 0, bottom = 0 };
32 ObjectInfo selectedClass;
33 CodeEditor codeEditor;
34 char * selectedControl;
37 Menu viewMenu { menu, $"View" };
38 MenuItem { viewMenu, $"View Toolbox" };
44 property char * controlClass
48 arrowControl.checked = true;
50 ((Designer)GetActiveDesigner()).objectClass = null;
54 return (char *)className;
57 property CodeEditor codeEditor
59 set { this.codeEditor = value; }
61 property ObjectInfo selectedClass
65 if(value != selectedClass ||
66 (value && value.instance && (!selectedClass.instance || selectedClass.instance._class != value.instance._class)))
70 selectedControl = null;
72 selectedClass = value;
74 for(control = (Button)firstChild; control; control = next)
76 next = (Button)control.next;
77 if(control != arrowControl && !control.nonClient)
80 selectedControl = (char *)(intptr)control.id;
84 // TOFIX: It seems the virtual space does not get adjusted by only destroying the buttons?
85 scrollArea = { 0, 0 };
87 //className = null; // Had to drag twice on code...
88 arrowControl.checked = true;
90 if(value && value.instance)
94 ((Designer)GetActiveDesigner()).FillToolBox();
100 bool OnClose(bool parentClosing)
104 ide.RepositionWindows(false);
105 return parentClosing;
108 bool OnKeyDown(Key key, unichar ch)
112 if(ide.activeClient) ide.activeClient.Activate();
118 void AddControl(Class _class)
120 Button control = CreateControl(&controlY, (const char *)(intptr)eClass_GetProperty(_class, "icon"), _class.name, _class.name);
122 if(selectedControl && !strcmp(selectedControl, _class.name))
124 control.checked = true;
125 strcpy(className, _class.name);
126 ((Designer)GetActiveDesigner()).objectClass = className;
133 arrowControl = CreateControl(&y, ":others/mousePointer.png", $"Pointer", null);
134 arrowControl.checked = true;
138 bool OnLeftButtonUp(int x, int y, Modifiers mods)
140 Designer designer = (Designer)GetActiveDesigner();
141 if(designer && designer.isDragging)
143 ((Designer)GetActiveDesigner()).isDragging = false;
145 return rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp,
146 x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y, &mods, false, false);
151 Button CreateControl(int * y, const char * bitmapFile, const char * text, const void * id)
159 minClientSize.w = 120;
161 anchor = Anchor { left = 5, top = *y, right = 5 };
163 bitmap = { bitmapFile };
164 id = (int64)(intptr)id;
166 bool NotifyPushed(Button control, int x, int y, Modifiers mods)
168 control.checked = true;
169 strcpy(className, control.text); //id;
170 if((Designer)GetActiveDesigner())
172 ((Designer)GetActiveDesigner()).objectClass = control.id ? className : null; //(char *)control.text; //id;
173 ((Designer)GetActiveDesigner()).isDragging = true;
174 control.ReleaseCapture();
176 cursor = ((GuiApplication)__thisModule.application).GetCursor(arrow);
181 bool NotifyDoubleClick(Button control, int x, int y, Modifiers mods)
183 if(control != arrowControl)
184 codeEditor.AddControl();
188 bool NotifyReleased(Button control, int x, int y, Modifiers mods)
190 // ((Designer)GetActiveDesigner()).isDragging = false;