summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-09-07 14:56:47 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-09-07 14:56:47 +0000
commit1e7af73a67cff669d2b5801f5097e71b30673adc (patch)
tree1a8a9dc39e475c9e4c429f8d7ef59c729dc44f5d
parentc05c7618ddfcf94117efaae8c83dfa2738f5d0a3 (diff)
downloadfpGUI-1e7af73a67cff669d2b5801f5097e71b30673adc.tar.xz
GFX: Added support for handle component creation at runtime correct
while the parent component is already visible. * GUI: Introduced the usage of ComponentState so that the components react correctly in the GUI Designer. Not all components are tested yet. * GUI Designer almost paints the designed form correctly. When placing a component, they are invisible, but as soon as you resize them, they are painted correctly. This is still work
-rw-r--r--examples/apps/uidesigner/images/newform_16.bmpbin0 -> 822 bytes
-rw-r--r--examples/apps/uidesigner/vfddesigner.pas1
-rw-r--r--examples/apps/uidesigner/vfdwidgetclass.pas1
-rw-r--r--prototypes/fpgui2/tests/edittest.dpr4
-rw-r--r--src/corelib/gfx_widget.pas8
-rw-r--r--src/gui/gui_button.pas8
-rw-r--r--src/gui/gui_edit.pas4
-rw-r--r--src/gui/gui_memo.pas4
8 files changed, 27 insertions, 3 deletions
diff --git a/examples/apps/uidesigner/images/newform_16.bmp b/examples/apps/uidesigner/images/newform_16.bmp
new file mode 100644
index 00000000..674ccabc
--- /dev/null
+++ b/examples/apps/uidesigner/images/newform_16.bmp
Binary files differ
diff --git a/examples/apps/uidesigner/vfddesigner.pas b/examples/apps/uidesigner/vfddesigner.pas
index 52946e0d..a29a4446 100644
--- a/examples/apps/uidesigner/vfddesigner.pas
+++ b/examples/apps/uidesigner/vfddesigner.pas
@@ -1552,6 +1552,7 @@ begin
WindowPosition := wpUser;
WindowTitle := 'New Form';
SetPosition(300, 150, 300, 250);
+ Include(ComponentState, csDesigning);
end;
diff --git a/examples/apps/uidesigner/vfdwidgetclass.pas b/examples/apps/uidesigner/vfdwidgetclass.pas
index 94751810..39b5493b 100644
--- a/examples/apps/uidesigner/vfdwidgetclass.pas
+++ b/examples/apps/uidesigner/vfdwidgetclass.pas
@@ -116,6 +116,7 @@ end;
function TVFDWidgetClass.CreateWidget(AOwner: TComponent): TfpgWidget;
begin
Result := WidgetClass.Create(AOwner);
+ Include(Result.ComponentState, csDesigning);
end;
destructor TVFDWidgetClass.Destroy;
diff --git a/prototypes/fpgui2/tests/edittest.dpr b/prototypes/fpgui2/tests/edittest.dpr
index 422d9c56..35b3a4ce 100644
--- a/prototypes/fpgui2/tests/edittest.dpr
+++ b/prototypes/fpgui2/tests/edittest.dpr
@@ -59,6 +59,7 @@ type
TMainForm = class(TfpgForm)
private
+ FbtnRuntime: TfpgButton;
procedure Trackbar1Changed(Sender: TObject; APosition: integer);
procedure btnCloseClick(Sender: TObject);
procedure btnDisplayBMP(Sender: TObject);
@@ -317,6 +318,9 @@ begin
MouseCursor := mcHourGlass
else
MouseCursor := mcDefault;
+
+ if not Assigned(FbtnRuntime) then
+ FbtnRuntime := CreateButton(self, 100, 130, 75, 'At Runtime', nil);
end;
procedure TMainForm.btn3Click(Sender: TObject);
diff --git a/src/corelib/gfx_widget.pas b/src/corelib/gfx_widget.pas
index c777c496..7637deb7 100644
--- a/src/corelib/gfx_widget.pas
+++ b/src/corelib/gfx_widget.pas
@@ -190,6 +190,7 @@ end;
constructor TfpgWidget.Create(AOwner: TComponent);
begin
+ Include(ComponentState, csLoading);
FOnScreen := False;
FVisible := True;
FActiveWidget := nil;
@@ -211,6 +212,13 @@ begin
FWindowType := wtChild;
inherited;
+
+ // This is for components that are create at runtime, after it's
+ // parent has already been shown.
+ if (Parent <> nil) and (Parent.HasHandle) then
+ HandleShow;
+
+ Exclude(ComponentState, csLoading);
end;
destructor TfpgWidget.Destroy;
diff --git a/src/gui/gui_button.pas b/src/gui/gui_button.pas
index e3b94028..c4b068a5 100644
--- a/src/gui/gui_button.pas
+++ b/src/gui/gui_button.pas
@@ -87,10 +87,8 @@ function CreateButton(AOwner: TComponent; x, y, w: TfpgCoord; AText: string;
AOnClickEvent: TNotifyEvent): TfpgButton;
begin
Result := TfpgButton.Create(AOwner);
- Result.Left := x;
- Result.Top := y;
Result.Text := AText;
- Result.Width := w;
+ Result.SetPosition(x, y, w, Result.Height); // font was used to calculate height.
Result.OnClick := AOnClickEvent;
end;
@@ -374,12 +372,16 @@ end;
procedure TfpgButton.HandleLMouseDown(X, Y: integer; ShiftState: TShiftState);
begin
inherited;
+ if (csDesigning in ComponentState) then
+ Exit;
DoPush;
end;
procedure TfpgButton.HandleLMouseUp(x, y: integer; shiftstate: TShiftState);
begin
inherited;
+ if (csDesigning in ComponentState) then
+ Exit;
DoRelease;
end;
diff --git a/src/gui/gui_edit.pas b/src/gui/gui_edit.pas
index 484da030..c94e2bca 100644
--- a/src/gui/gui_edit.pas
+++ b/src/gui/gui_edit.pas
@@ -544,12 +544,16 @@ end;
procedure TfpgEdit.HandleMouseEnter;
begin
inherited HandleMouseEnter;
+ if (csDesigning in ComponentState) then
+ Exit;
MouseCursor := mcIBeam;
end;
procedure TfpgEdit.HandleMouseExit;
begin
inherited HandleMouseExit;
+ if (csDesigning in ComponentState) then
+ Exit;
MouseCursor := mcDefault;
end;
diff --git a/src/gui/gui_memo.pas b/src/gui/gui_memo.pas
index 04ce67d6..a7f1b5a7 100644
--- a/src/gui/gui_memo.pas
+++ b/src/gui/gui_memo.pas
@@ -590,6 +590,10 @@ end;
procedure TfpgMemo.HandleShow;
begin
inherited HandleShow;
+ if (csDesigning in ComponentState) then
+ Exit;
+ if (csLoading in ComponentState) then
+ Exit;
RecalcLongestLine;
UpdateScrollBars;
UpdateScrollBarCoords;