if(form)
form.visible = true;
}
-
+
selected = control;
Update(null);
//activeDesigner.Update(null);
else
{
// instance.parent = _class;
- }
+ }
}
void ::PostCreateObject(Window instance, ObjectInfo object, bool isClass, Window _class)
void ::DroppedObject(Window instance, ObjectInfo object, bool isClass, Window _class)
{
instance.parent = _class;
- instance.text = object.name;
+ instance.caption = object.name;
instance.Create();
}
{
if(form)
{
- OnLeftButtonUp(
- selected.absPosition.x - absPosition.x - clientStart.x + selected.clientStart.x + GridSnap,
- selected.absPosition.y - absPosition.y - clientStart.y + selected.clientStart.y + GridSnap, 0);
- Activate();
+ AddControl(form, GridSnap, GridSnap);
+ if(visible)
+ Activate();
}
}
void ::ListClasses(DesignerBase designer, Class _class)
{
- OldLink link;
+ //OldLink link;
if(eClass_GetProperty(_class, "icon"))
designer.AddToolBoxClass(_class);
/*
void ::FixProperty(Property prop, Window object)
{
FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
-
+
if(!strcmp(prop.name, "parent"))
{
if(object.parent == guiApp.desktop)
object.parent = designer.form;
if(object.parent == designer.form)
- {
+ {
ObjectInfo previous = object.object;
while((previous = previous.prev) && ((Window)previous.instance).parent != designer.form);
if(previous)
object.parent.children.Move(object, (Window)previous.instance);
}
}
-
+
if(!strcmp(prop.name, "master") && !object.master)
object.master = designer.form;
}
}
- void ::CreateNew(EditBox editBox, Size clientSize, char * name, char * inherit)
+ void ::CreateNew(EditBox editBox, Size clientSize, const char * name, const char * inherit)
{
- int w = 640, h = 480;
+ int w = 632, h = 438;
if(clientSize.w - 40 -200 < w)
{
w = (clientSize.w - 40 - 200);
w -= w % GridSnap;
- h = h * w / 640;
+ h = h * w / 632;
h -= h % GridSnap;
w = Max(w, 304);
h = Max(h, 304);
editBox.Printf("import \"ecere\"\n\n");
editBox.Printf("class %s : %s\n", name, inherit);
editBox.Printf("{\n");
-
- editBox.Printf(" text = \"%s\";\n", name);
+
+ editBox.Printf(" caption = $\"%s\";\n", name);
//editBox.Printf(" background = Color { 212, 208, 200 };\n");
-
- editBox.Printf(" background = activeBorder;\n");
+
+ editBox.Printf(" background = formColor;\n");
editBox.Printf(" borderStyle = sizable;\n");
editBox.Printf(" hasMaximize = true;\n");
editBox.Printf(" hasMinimize = true;\n");
editBox.Printf(" hasClose = true;\n");
//editBox.Printf(" position = { 20, 20 };\n");
- editBox.Printf(" size = { %d, %d };\n", w, h);
-
-
+ editBox.Printf(" clientSize = { %d, %d };\n", w, h);
+
+
//editBox.Printf(" Button ok { parent = this, position = { 100, 100 }, size = { 80, 20 } };\n");
//editBox.Printf("\n Button ok\n {\n parent = this;\n\n bool NotifyClicked()\n {\n }\n };\n");
/*
editBox.Printf("class %s : %s\n", "SecondForm", inherit);
editBox.Printf("{\n");
- editBox.Printf(" text = \"%s\";\n", "SecondForm");
+ editBox.Printf(" caption = \"%s\";\n", "SecondForm");
editBox.Printf(" background = Color { 100, 90, 120 };\n");
editBox.Printf(" borderStyle = sizable;\n");
editBox.Printf(" hasMaximize = true;\n");
editBox.Printf(" hasClose = true;\n");
editBox.Printf(" position = { 20, 20 };\n");
editBox.Printf(" size = { %d, %d };\n", 320, 200);
- editBox.Printf(" Button ok { parent = this, text = \"OK\", position = { A_RIGHT|10, A_RIGHT|10 }, size = { 80, 20 } };\n");
+ editBox.Printf(" Button ok { parent = this, caption = \"OK\", position = { A_RIGHT|10, A_RIGHT|10 }, size = { 80, 20 } };\n");
editBox.Printf("}\n");
*/
}
int h = moved.size.h;
Box box;
Anchor anchor = moved.anchor;
-
+
x = xBefore + parentBefore.absPosition.x - curParent.absPosition.x + parentBefore.clientStart.x - curParent.clientStart.x;
y = yBefore + parentBefore.absPosition.y - curParent.absPosition.y + parentBefore.clientStart.y - curParent.clientStart.y;
}
else if(resizeX > 0)
{
- w += dx;
+ w += dx;
}
-
+
if(resizeY < 0)
{
y += dy;
{
h += dy;
}
- if(resizeX)
+ if(resizeX)
{
w = Max(w, GridSnap);
moved.size.w = w;
}
- if(resizeY)
+ if(resizeY)
{
h = Max(h, GridSnap);
moved.size.h = h;
moved.parent = parent;
if(parent == form)
- {
+ {
ObjectInfo previous = moved.object;
while((previous = previous.prev) && ((Window)previous.instance).parent != form);
if(previous)
x -= x % GridSnap;
y -= y % GridSnap;
}
-
+
activeDesigner.ModifyCode();
moved.Move(x, y, w, h);
{
int vpw, vph;
-
+
// Fix Anchor
x = moved.position.x;
y = moved.position.y;
//anchor.horz.type = anchor.horz.distance ? offset : 0;
}
else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
- if(!anchor.top.type && !anchor.bottom.type)
+ if(!anchor.top.type && !anchor.bottom.type)
{
anchor.vert.distance = (y + h / 2) - (vph / 2);
//anchor.vert.type = anchor.vert.distance ? offset : 0;
box.top -= 7;
box.right += 7;
box.bottom += 7;
-
+
Update(box);
//activeDesigner.Update(box);
bool OnLeftButtonDown(int x, int y, Modifiers mods)
{
- char * objectClass = activeDesigner.objectClass;
+ const char * objectClass = activeDesigner.objectClass;
if(!objectClass && selected)
{
Window control = FindWindow(form, master, null, x, y, false, null, null);
bool onBorder = false;
- Window parent = selected.parent;
+ //Window parent = selected.parent;
//if(control && (parent == control || parent == control.parent))
{
int cx = selected.absPosition.x - absPosition.x - clientStart.x;
((control == form) ? (Window)this : form).SetMouseRangeToWindow();
else
((control == form) ? (Window)this : form).SetMouseRangeToClient();
-
+
xClicked = x;
yClicked = y;
return true;
}
+ void AddControl(Window parent, int x, int y)
+ {
+ const char * objectClass = activeDesigner.objectClass;
+ ObjectInfo object;
+ Window control;
+ Class c = eSystem_FindClass(form._class.module, objectClass);
+ if(!c)
+ c = eSystem_FindClass(form._class.module.application, objectClass);
+ if(c)
+ {
+ control = (Window)eInstance_New(c);
+
+ activeDesigner.CodeAddObject(control, &object);
+
+ while(!parent.name)
+ {
+ x += parent.position.x + parent.clientStart.x;
+ y += parent.position.y + parent.clientStart.y;
+ parent = parent.parent;
+ }
+
+ control.object = object;
+
+ control.parent = parent;
+ control.master = form;
+
+ x -= x % GridSnap;
+ y -= y % GridSnap;
+
+ control.position.x = x;
+ control.position.y = y;
+ control.caption = object.name;
+
+ LockControls(control, control);
+
+ control.Create();
+ if(parent == form)
+ {
+ ObjectInfo previous = control.object;
+ while((previous = previous.prev) && ((Window)previous.instance).parent != form);
+ if(previous)
+ control.parent.children.Move(control, (Window)previous.instance);
+ }
+
+ activeDesigner.SheetAddObject(object);
+
+ //selected = control;
+ //activeDesigner.Update(null);
+ Update(null);
+ }
+ }
+
bool OnLeftButtonUp(int x, int y, Modifiers mods)
{
if(moved)
}
else
{
- char * objectClass = activeDesigner.objectClass;
+ const char * objectClass = activeDesigner.objectClass;
if(objectClass)
{
Window parent = FindWindow(form, activeDesigner, null, x, y, true, &x, &y);
if(parent)
- {
- ObjectInfo object;
- Window control = (Window)eInstance_New(eSystem_FindClass(form._class.module, objectClass));
-
- activeDesigner.CodeAddObject(control, &object);
-
- while(!parent.name)
- {
- x += parent.position.x + parent.clientStart.x;
- y += parent.position.y + parent.clientStart.y;
- parent = parent.parent;
- }
-
- control.object = object;
-
- control.parent = parent;
- control.master = form;
-
- x -= x % GridSnap;
- y -= y % GridSnap;
-
- control.position.x = x;
- control.position.y = y;
- control.text = object.name;
-
- LockControls(control, control);
-
- control.Create();
- if(parent == form)
- {
- ObjectInfo previous = control.object;
- while((previous = previous.prev) && ((Window)previous.instance).parent != form);
- if(previous)
- control.parent.children.Move(control, (Window)previous.instance);
- }
-
- activeDesigner.SheetAddObject(object);
-
- //selected = control;
- //activeDesigner.Update(null);
- Update(null);
- }
+ AddControl(parent, x, y);
}
}
return true;
window.OnSysKeyDown = ecere::gui::OnSysKey;
window.OnSysKeyHit = ecere::gui::OnSysKey;
window.OnSysKeyUp = ecere::gui::OnSysKey;
-
+
if(object != object.oClass)
{
window.OnActivate = Control_OnActivate;
void DrawSelection(Window window, Surface surface)
{
- Window result = null, control;
+ Window control;
for(control = window.lastChild; control; control = control.prev)
{
if(selected == control)
{
- Window parent = selected.parent;
+ //Window parent = selected.parent;
int x;
int y;
int w = selected.size.w;
}
return true;
}
-
+/*
static Window GetWindow(Window window, int x, int y, int * rx, int * ry)
{
Window result = null, control;
}
return result;
}
-
+*/
static Window FindWindow(Window form, Window window, Window moved, int x, int y, bool asParent, int * dx, int * dy)
{
Window result = null, control;
bool confirmation = activeDesigner.ObjectContainsCode(designer.selected.object);
if(confirmation)
- confirmation = MessageBox { type = okCancel, master = window.master, text = "Deleting control with code", contents = "Control contains code. Delete anyways?" }.Modal() != ok;
+ confirmation = MessageBox { type = okCancel, master = window.master, caption = $"Deleting control with code", contents = $"Control contains code. Delete anyways?" }.Modal() != ok;
// Confirmation if control contains other controls
if(!confirmation)
}
if(confirmation)
- confirmation = MessageBox { type = okCancel, master = window.master, text = "Deleting control with children", contents = "Control contains other controls. Delete control and children?"}.Modal() != ok;
+ confirmation = MessageBox { type = okCancel, master = window.master, caption = $"Deleting control with children", contents = $"Control contains other controls. Delete control and children?"}.Modal() != ok;
}
if(!confirmation)
{
activeDesigner.ModifyCode();
-
+
designer.selected.Destroy(0);
//activeDesigner.Update(null);
designer.Update(null);