summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Menteiro de Carvalho <sekelsenmat@users.sourceforge.net>2006-11-20 18:23:23 +0000
committerFelipe Menteiro de Carvalho <sekelsenmat@users.sourceforge.net>2006-11-20 18:23:23 +0000
commit3c479a4c97c9445e7aba0bcda2fbbf325448e11a (patch)
tree9b01e4a14a56c41a904588141b5996853b264c42
parent1035e7b3b4aa37e3528495a3715888d2f8bcf4b2 (diff)
downloadfpGUI-3c479a4c97c9445e7aba0bcda2fbbf325448e11a.tar.xz
Added support for sub windows on Gfx, and also an example program for this
-rw-r--r--examples/gfx/eventtest/eventtest.lpi5
-rw-r--r--examples/gfx/eventtest/eventtest.pas10
-rw-r--r--examples/gfx/helloworld/helloworld.lpi10
-rw-r--r--examples/gfx/subwindow/subwindow.lpi49
-rw-r--r--examples/gfx/subwindow/subwindow.pas100
-rw-r--r--examples/gui/helloworld/helloworld.lpi10
-rw-r--r--examples/gui/helloworld/helloworld.pas2
-rw-r--r--gfx/gdi/gfx_gdi.pas65
8 files changed, 203 insertions, 48 deletions
diff --git a/examples/gfx/eventtest/eventtest.lpi b/examples/gfx/eventtest/eventtest.lpi
index 20cb4496..3562e167 100644
--- a/examples/gfx/eventtest/eventtest.lpi
+++ b/examples/gfx/eventtest/eventtest.lpi
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
- <PathDelim Value="/"/>
+ <PathDelim Value="\"/>
<Version Value="5"/>
<General>
<Flags>
@@ -20,7 +20,7 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
- <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
@@ -39,6 +39,7 @@
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
+ <PathDelim Value="\"/>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
diff --git a/examples/gfx/eventtest/eventtest.pas b/examples/gfx/eventtest/eventtest.pas
index 8b371478..4fb7593a 100644
--- a/examples/gfx/eventtest/eventtest.pas
+++ b/examples/gfx/eventtest/eventtest.pas
@@ -17,12 +17,10 @@
program EventTest;
uses
- SysUtils
- ,Classes
- ,GFXBase
- ,fpGFX
- ;
-
+ SysUtils,
+ Classes,
+ GFXBase,
+ fpGFX;
const
ButtonNames: array[TMouseButton] of PChar =
diff --git a/examples/gfx/helloworld/helloworld.lpi b/examples/gfx/helloworld/helloworld.lpi
index 66ec049a..f31d1721 100644
--- a/examples/gfx/helloworld/helloworld.lpi
+++ b/examples/gfx/helloworld/helloworld.lpi
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
- <PathDelim Value="/"/>
+ <PathDelim Value="\"/>
<Version Value="5"/>
<General>
<Flags>
@@ -14,13 +14,14 @@
</General>
<PublishOptions>
<Version Value="2"/>
+ <DestinationDirectory Value="$(TestDir)\publishedproject\"/>
<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)"/>
+ <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
@@ -30,14 +31,15 @@
</RequiredPackages>
<Units Count="1">
<Unit0>
- <Filename Value="helloworld.pas"/>
+ <Filename Value="..\subwindow\subwindow.pas"/>
<IsPartOfProject Value="True"/>
- <UnitName Value="HelloWorld"/>
+ <UnitName Value="subwindow"/>
</Unit0>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
+ <PathDelim Value="\"/>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
diff --git a/examples/gfx/subwindow/subwindow.lpi b/examples/gfx/subwindow/subwindow.lpi
new file mode 100644
index 00000000..14c843c7
--- /dev/null
+++ b/examples/gfx/subwindow/subwindow.lpi
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <PathDelim Value="\"/>
+ <Version Value="5"/>
+ <General>
+ <SessionStorage Value="InProjectDir"/>
+ <MainUnit Value="0"/>
+ <IconPath Value="./"/>
+ <TargetFileExt Value=".exe"/>
+ </General>
+ <VersionInfo>
+ <ProjectVersion Value=""/>
+ </VersionInfo>
+ <PublishOptions>
+ <Version Value="2"/>
+ <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="fpgfxpackage"/>
+ </Item1>
+ </RequiredPackages>
+ <Units Count="1">
+ <Unit0>
+ <Filename Value="subwindow.pas"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="subwindow"/>
+ </Unit0>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <PathDelim Value="\"/>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+</CONFIG>
diff --git a/examples/gfx/subwindow/subwindow.pas b/examples/gfx/subwindow/subwindow.pas
new file mode 100644
index 00000000..177f4989
--- /dev/null
+++ b/examples/gfx/subwindow/subwindow.pas
@@ -0,0 +1,100 @@
+{
+ fpGUI - Free Pascal GUI Library
+
+ SubWindow - Shows how to create a Sub-Window on GFX
+
+ Copyright (C) 2000 - 2006 See the file AUTHORS.txt, included in this
+ distribution, for details of the copyright.
+
+ See the file COPYING.modifiedLGPL, included in this distribution,
+ for details about redistributing fpGUI.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+}
+program subwindow;
+
+uses
+ SysUtils, Classes,
+ fpGFX, GFXBase, fpgfxpackage;
+
+type
+
+ { TBoxWindow }
+
+ TBoxWindow = class(TFWindow)
+ public
+ procedure Paint(Sender: TObject; const Rect: TRect);
+ constructor Create(AParent: TFCustomWindow);
+ procedure MouseReleased(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
+ end;
+
+ { TMainWindow }
+
+ TMainWindow = class(TFWindow)
+ public
+ ABox: TBoxWindow;
+ constructor Create;
+ procedure MouseReleased(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
+ end;
+
+constructor TBoxWindow.Create(AParent: TFCustomWindow);
+begin
+ inherited Create(AParent, []);
+
+ OnMouseReleased := @MouseReleased;
+ OnPaint := @Paint;
+
+ SetClientSize(Size(125, 125));
+ SetMinMaxClientSize(Size(125, 125), Size(125, 125));
+end;
+
+procedure TBoxWindow.MouseReleased(Sender: TObject; AButton: TMouseButton;
+ AShift: TShiftState; const AMousePos: TPoint);
+begin
+ WriteLn('Mouse released on child window');
+end;
+
+procedure TBoxWindow.Paint(Sender: TObject; const Rect: TRect);
+var
+ r: TRect;
+begin
+ Canvas.SetColor(colBlue);
+ r.Left := 0;
+ r.Top := 0;
+ r.Right := Width;
+ r.Bottom := Height;
+ Canvas.FillRect(r);
+end;
+
+constructor TMainWindow.Create;
+begin
+ inherited Create(nil, [woWindow]);
+
+ Title := 'fpGFX Sub-Window example';
+ SetClientSize(Size(256, 256));
+ SetMinMaxClientSize(Size(256, 256), Size(256, 256));
+
+ OnMouseReleased := @MouseReleased;
+
+ ABox := TBoxWindow.Create(Self);
+ ABox.Show;
+end;
+
+procedure TMainWindow.MouseReleased(Sender: TObject; AButton: TMouseButton;
+ AShift: TShiftState; const AMousePos: TPoint);
+begin
+ WriteLn('Mouse released on main window');
+end;
+
+var
+ MainWindow: TMainWindow;
+begin
+ GFApplication.Initialize;
+ MainWindow := TMainWindow.Create;
+ GFApplication.AddWindow(MainWindow);
+ MainWindow.Show;
+ GFApplication.Run;
+end.
+
diff --git a/examples/gui/helloworld/helloworld.lpi b/examples/gui/helloworld/helloworld.lpi
index f9e413e9..c180f8dc 100644
--- a/examples/gui/helloworld/helloworld.lpi
+++ b/examples/gui/helloworld/helloworld.lpi
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
- <PathDelim Value="/"/>
+ <PathDelim Value="\"/>
<Version Value="5"/>
<General>
<Flags>
@@ -14,6 +14,7 @@
</General>
<PublishOptions>
<Version Value="2"/>
+ <DestinationDirectory Value="$(TestDir)\publishedproject\"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
@@ -21,12 +22,12 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
- <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
- <PackageName Value="fpGUI_laz"/>
+ <PackageName Value="fpguipackage"/>
</Item1>
</RequiredPackages>
<Units Count="1">
@@ -39,8 +40,9 @@
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
+ <PathDelim Value="\"/>
<SearchPaths>
- <OtherUnitFiles Value="../../src/"/>
+ <OtherUnitFiles Value="..\..\src\"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
diff --git a/examples/gui/helloworld/helloworld.pas b/examples/gui/helloworld/helloworld.pas
index 8151291a..b9921756 100644
--- a/examples/gui/helloworld/helloworld.pas
+++ b/examples/gui/helloworld/helloworld.pas
@@ -3,7 +3,7 @@ program HelloWorld;
{$mode objfpc}{$h+}
uses
- fpGUI, fpGUI_laz;
+ fpGUI, fpguipackage;
type
TMainForm = class(TForm)
diff --git a/gfx/gdi/gfx_gdi.pas b/gfx/gdi/gfx_gdi.pas
index 82ce1214..219461d0 100644
--- a/gfx/gdi/gfx_gdi.pas
+++ b/gfx/gdi/gfx_gdi.pas
@@ -1075,52 +1075,55 @@ begin
FParent := AParent;
{ Initialize a window class, if necessary }
- if UnicodeEnabledOS then
+ if woWindow in WindowOptions then
begin
- if not Assigned(WindowClassW.lpfnWndProc) then
+ if UnicodeEnabledOS then
begin
- WindowClassW.style := CS_HREDRAW or CS_VREDRAW;
- WindowClassW.lpfnWndProc := WndProc(@fpGFXWindowProc);
- WindowClassW.hInstance := MainInstance;
- WindowClassW.hIcon := LoadIcon(0, IDI_APPLICATION);
- WindowClassW.hCursor := LoadCursor(0, IDC_ARROW);
- WindowClassW.hbrBackground := 0;
- WindowClassW.lpszClassName := 'fpGFX';
- end;
- Windows.RegisterClassW(@WindowClassW);
- end
- else
- begin
- if not Assigned(WindowClass.lpfnWndProc) then
+ if not Assigned(WindowClassW.lpfnWndProc) then
+ begin
+ WindowClassW.style := CS_HREDRAW or CS_VREDRAW;
+ WindowClassW.lpfnWndProc := WndProc(@fpGFXWindowProc);
+ WindowClassW.hInstance := MainInstance;
+ WindowClassW.hIcon := LoadIcon(0, IDI_APPLICATION);
+ WindowClassW.hCursor := LoadCursor(0, IDC_ARROW);
+ WindowClassW.hbrBackground := 0;
+ WindowClassW.lpszClassName := 'fpGFX';
+ end;
+ Windows.RegisterClassW(@WindowClassW);
+ end
+ else
begin
- WindowClass.style := CS_HREDRAW or CS_VREDRAW;
- WindowClass.lpfnWndProc := WndProc(@fpGFXWindowProc);
- WindowClass.hInstance := MainInstance;
- WindowClass.hIcon := LoadIcon(0, IDI_APPLICATION);
- WindowClass.hCursor := LoadCursor(0, IDC_ARROW);
- WindowClass.hbrBackground := 0;
- WindowClass.lpszClassName := 'fpGFX';
+ if not Assigned(WindowClass.lpfnWndProc) then
+ begin
+ WindowClass.style := CS_HREDRAW or CS_VREDRAW;
+ WindowClass.lpfnWndProc := WndProc(@fpGFXWindowProc);
+ WindowClass.hInstance := MainInstance;
+ WindowClass.hIcon := LoadIcon(0, IDI_APPLICATION);
+ WindowClass.hCursor := LoadCursor(0, IDC_ARROW);
+ WindowClass.hbrBackground := 0;
+ WindowClass.lpszClassName := 'fpGFX';
+ end;
+ Windows.RegisterClass(@WindowClass);
end;
- Windows.RegisterClass(@WindowClass);
end;
-
+
if Assigned(AParent) then
ParentHandle := AParent.Handle
else
ParentHandle := 0;
- if (woBorderless in FWindowOptions) and (woPopUp in FWindowOptions) then FWindowStyle := WS_POPUP
+ if not (woWindow in FWindowOptions) then FWindowStyle := WS_CHILD
+ else if (woBorderless in FWindowOptions) and (woPopUp in FWindowOptions) then FWindowStyle := WS_POPUP
else if woPopUp in FWindowOptions then FWindowStyle := WS_POPUPWINDOW
- else if woToolWindow in FWindowOptions then FWindowStyle := WS_OVERLAPPED
+ else if woToolWindow in FWindowOptions then FWindowStyle := WS_OVERLAPPEDWINDOW
else if woChildWindow in FWindowOptions then FWindowStyle := WS_CHILDWINDOW
else if woBorderless in FWindowOptions then FWindowStyle := WS_OVERLAPPED
- else if woWindow in FWindowOptions then FWindowStyle := WS_OVERLAPPEDWINDOW
- else FWindowStyle := 0;
+ else FWindowStyle := WS_OVERLAPPEDWINDOW;
- if woPopUp in FWindowOptions then FWindowStyleEx := WS_EX_TOOLWINDOW
+ if not (woWindow in FWindowOptions) then FWindowStyleEx := 0
+ else if woPopUp in FWindowOptions then FWindowStyleEx := WS_EX_TOOLWINDOW
else if woToolWindow in FWindowOptions then FWindowStyleEx := WS_EX_TOOLWINDOW
- else if woWindow in FWindowOptions then FWindowStyleEx := WS_EX_APPWINDOW
- else FWindowStyleEx := 0;
+ else FWindowStyleEx := WS_EX_APPWINDOW;
if UnicodeEnabledOS then
FHandle := Windows.CreateWindowExW(