summaryrefslogtreecommitdiff
path: root/prototypes
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-18 15:12:33 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-18 15:12:33 +0000
commitaf3be8d3385df13ef9b793bab10760a693423f38 (patch)
treed7acbea28e8ebf84dfdda5080c72438ba01a30b6 /prototypes
parent8b2fe96412eaa42af166f85feb67b50b83e3bad6 (diff)
downloadfpGUI-af3be8d3385df13ef9b793bab10760a693423f38.tar.xz
X11: Got some basic Modal Forms to work (still needs work though).
Diffstat (limited to 'prototypes')
-rw-r--r--prototypes/fpgui2/examples/gui/modalforms/modalforms.lpi52
-rw-r--r--prototypes/fpgui2/examples/gui/modalforms/modalforms.lpr165
-rw-r--r--prototypes/fpgui2/source/core/x11/gfx_x11.pas17
3 files changed, 230 insertions, 4 deletions
diff --git a/prototypes/fpgui2/examples/gui/modalforms/modalforms.lpi b/prototypes/fpgui2/examples/gui/modalforms/modalforms.lpi
new file mode 100644
index 00000000..2d2e9d9d
--- /dev/null
+++ b/prototypes/fpgui2/examples/gui/modalforms/modalforms.lpi
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <PathDelim Value="/"/>
+ <Version Value="5"/>
+ <General>
+ <Flags>
+ <SaveOnlyProjectUnits Value="True"/>
+ </Flags>
+ <SessionStorage Value="InProjectDir"/>
+ <MainUnit Value="0"/>
+ <TargetFileExt Value=""/>
+ </General>
+ <VersionInfo>
+ <ProjectVersion Value=""/>
+ </VersionInfo>
+ <PublishOptions>
+ <Version Value="2"/>
+ <IgnoreBinaries Value="False"/>
+ <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
+ <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
+ </PublishOptions>
+ <RunParams>
+ <local>
+ <FormatVersion Value="1"/>
+ <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ </local>
+ </RunParams>
+ <RequiredPackages Count="1">
+ <Item1>
+ <PackageName Value="fpGFX2"/>
+ </Item1>
+ </RequiredPackages>
+ <Units Count="1">
+ <Unit0>
+ <Filename Value="modalforms.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="modalforms"/>
+ </Unit0>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CustomOptions Value="-FUunits"/>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+</CONFIG>
diff --git a/prototypes/fpgui2/examples/gui/modalforms/modalforms.lpr b/prototypes/fpgui2/examples/gui/modalforms/modalforms.lpr
new file mode 100644
index 00000000..c3faeaf3
--- /dev/null
+++ b/prototypes/fpgui2/examples/gui/modalforms/modalforms.lpr
@@ -0,0 +1,165 @@
+{
+ Demo of modal forms in action.
+
+ NOTE: Model form are not 100% implemented yet!
+}
+program modalforms;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ Classes,
+ fpgfx,
+ gui_form,
+ gui_dialogs,
+ gui_button,
+ gui_label;
+
+type
+ // forward declaration
+ TForm1 = class;
+ TForm2 = class;
+
+ TMainForm = class(TfpgForm)
+ private
+ btnClose: TfpgButton;
+ btnOpenForm1: TfpgButton;
+ procedure btnCloseClick(Sender: TObject);
+ procedure btnOpenForm1Click(Sender: TObject);
+ public
+ constructor Create(AOwner: TComponent); override;
+ end;
+
+
+ TForm1 = class(TfpgForm)
+ private
+ Label1: TfpgLabel;
+ btnClose: TfpgButton;
+ btnOpenForm2: TfpgButton;
+ procedure btnCloseClick(Sender: TObject);
+ procedure btnOpenForm2Click(Sender: TObject);
+ public
+ constructor Create(AOwner: TComponent); override;
+ end;
+
+
+ TForm2 = class(TfpgForm)
+ private
+ Label1: TfpgLabel;
+ btnClose: TfpgButton;
+ procedure btnCloseClick(Sender: TObject);
+ public
+ constructor Create(AOwner: TComponent); override;
+ end;
+
+
+{ TForm2 }
+
+procedure TForm2.btnCloseClick(Sender: TObject);
+begin
+ Close;
+end;
+
+constructor TForm2.Create(AOwner: TComponent);
+begin
+ inherited Create(AOwner);
+ WindowTitle := 'Form2';
+ Sizeable := False;
+ SetPosition(200, 200, 200, 200);
+
+ Label1 := CreateLabel(self, 10, 10, 'This is Form2');
+
+ btnClose := CreateButton(self, 110, 170, 80, 'Quit', @btnCloseClick);
+ btnClose.ImageName := 'stdimg.Quit';
+ btnClose.ShowImage := True;
+end;
+
+{ TForm1 }
+
+procedure TForm1.btnCloseClick(Sender: TObject);
+begin
+ Close;
+end;
+
+procedure TForm1.btnOpenForm2Click(Sender: TObject);
+var
+ frm: TForm2;
+begin
+ try
+ frm := TForm2.Create(nil);
+ frm.ShowModal;
+ writeln('Form2: This should only appear after the form closes.');
+ finally
+ frm.Free;
+ end;
+end;
+
+constructor TForm1.Create(AOwner: TComponent);
+begin
+ inherited Create(AOwner);
+ WindowTitle := 'Form1';
+ Sizeable := False;
+ SetPosition(150, 150, 200, 200);
+
+ Label1 := CreateLabel(self, 10, 10, 'This is Form1');
+
+ btnClose := CreateButton(self, 110, 170, 80, 'Quit', @btnCloseClick);
+ btnClose.ImageName := 'stdimg.Quit';
+ btnClose.ShowImage := True;
+
+ btnOpenForm2 := CreateButton(self, 70, 100, 80, 'Open Form2', @btnOpenForm2Click);
+end;
+
+
+{ TMainForm }
+
+procedure TMainForm.btnCloseClick(Sender: TObject);
+begin
+ Close;
+end;
+
+procedure TMainForm.btnOpenForm1Click(Sender: TObject);
+var
+ frm: TForm1;
+begin
+ try
+ frm := TForm1.Create(nil);
+ frm.ShowModal;
+ writeln('Form1: This should only appear after the form closes.');
+ finally
+ frm.Free;
+ end;
+end;
+
+constructor TMainForm.Create(AOwner: TComponent);
+begin
+ inherited Create(AOwner);
+ WindowTitle := 'Modal Form Demo';
+ Sizeable := False;
+ SetPosition(100, 100, 400, 200);
+
+ btnClose := CreateButton(self, 310, 170, 80, 'Quit', @btnCloseClick);
+ btnClose.ImageName := 'stdimg.Quit';
+ btnClose.ShowImage := True;
+
+ btnOpenForm1 := CreateButton(self, 100, 100, 80, 'Open Form1', @btnOpenForm1Click);
+end;
+
+
+procedure MainProc;
+var
+ frm: TMainForm;
+begin
+ fpgApplication.Initialize;
+ frm := TMainForm.Create(nil);
+ frm.Show;
+ fpgApplication.Run;
+end;
+
+begin
+ MainProc;
+end.
+
diff --git a/prototypes/fpgui2/source/core/x11/gfx_x11.pas b/prototypes/fpgui2/source/core/x11/gfx_x11.pas
index 7f0a02eb..72103607 100644
--- a/prototypes/fpgui2/source/core/x11/gfx_x11.pas
+++ b/prototypes/fpgui2/source/core/x11/gfx_x11.pas
@@ -182,7 +182,8 @@ implementation
uses
baseunix,
fpgfx,
- gfx_widget; {$Note This dependency to gfx_widget must be removed.}
+ gfx_widget, {$Note This dependency to gfx_widget must be removed.}
+ gui_form; // remove this!!!!!
var
xapplication: TfpgApplication;
@@ -685,6 +686,15 @@ begin
msgp.mouse.shiftstate := ConvertShiftState(ev.xbutton.state);
w := FindWindowByHandle(ev.xbutton.window);
+
+ if fpgTopModalForm <> nil then
+ begin
+ // This is ugly!!!!!!!!!!!!!!!
+ ew := TfpgWindowImpl(WidgetParentForm(TfpgWidget(w)));
+ if (ew <> nil) and (fpgTopModalForm <> ew) then
+ blockmsg := true;
+ end;
+
if not blockmsg then
begin
if (ev.xbutton.button >= 4) and (ev.xbutton.button <= 7) then // mouse wheel
@@ -811,7 +821,6 @@ begin
fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_DEACTIVATE);
X.EnterNotify:
-// w.EvMouseEnter(Point(ev.xbutton.x, ev.xbutton.y));
fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_MOUSEENTER);
X.LeaveNotify:
@@ -884,7 +893,7 @@ var
hints: TXSizeHints;
begin
if FWinHandle > 0 then
- Exit;
+ Exit; //==>
if aparent <> nil then
pwh := TfpgWindowImpl(AParent).WinHandle
@@ -946,7 +955,7 @@ begin
// for modal windows, this is necessary
if (FWindowType = wtModalForm) and (AParent <> nil) then
- XSetTransientForHint(xapplication.display, self.FWinHandle, TfpgWindowImpl(AParent).WinHandle);
+ XSetTransientForHint(xapplication.display, FWinHandle, TfpgWindowImpl(AParent).WinHandle);
XSelectInput(xapplication.Display, wh, KeyPressMask or KeyReleaseMask or
ButtonPressMask or ButtonReleaseMask or