diff options
author | sekelsenmat <sekelsenmat@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-12 17:10:01 +0000 |
---|---|---|
committer | sekelsenmat <sekelsenmat@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-12 17:10:01 +0000 |
commit | b30cac91fb2b8579657bffea62bfe8c344fb40f9 (patch) | |
tree | 60801861ed7bf5854f7b80b6ea3289d48d79893a | |
parent | c1add0626ace53bac8e67dbef7e95c7d346187ab (diff) | |
download | fpGUI-b30cac91fb2b8579657bffea62bfe8c344fb40f9.tar.xz |
Moved gfx event methods to protected
-rw-r--r-- | examples/gfx/subwindow/subwindow.lpi | 8 | ||||
-rw-r--r-- | gfx/gdi/fpgfxpackage.pas | 2 | ||||
-rw-r--r-- | gfx/gdi/gfx_gdi.pas | 117 | ||||
-rw-r--r-- | gfx/gfxbase.pas | 71 |
4 files changed, 145 insertions, 53 deletions
diff --git a/examples/gfx/subwindow/subwindow.lpi b/examples/gfx/subwindow/subwindow.lpi index d2f61887..3d6959f4 100644 --- a/examples/gfx/subwindow/subwindow.lpi +++ b/examples/gfx/subwindow/subwindow.lpi @@ -1,12 +1,12 @@ <?xml version="1.0"?> <CONFIG> <ProjectOptions> - <PathDelim Value="/"/> + <PathDelim Value="\"/> <Version Value="5"/> <General> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> - <IconPath Value="./"/> + <IconPath Value=".\"/> <TargetFileExt Value=".exe"/> </General> <VersionInfo> @@ -14,13 +14,14 @@ </VersionInfo> <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"> @@ -38,6 +39,7 @@ </ProjectOptions> <CompilerOptions> <Version Value="5"/> + <PathDelim Value="\"/> <CodeGeneration> <Generate Value="Faster"/> </CodeGeneration> diff --git a/gfx/gdi/fpgfxpackage.pas b/gfx/gdi/fpgfxpackage.pas index 0669f181..0c2e3f6c 100644 --- a/gfx/gdi/fpgfxpackage.pas +++ b/gfx/gdi/fpgfxpackage.pas @@ -7,7 +7,7 @@ unit fpGFXPackage; interface uses - GfxBase, GFXInterface, GFX_GDI, fpgfx, GELDirty, GELImage, fpUTF8Utils; + GfxBase, GFXInterface, gfx_gdi, fpgfx, GELDirty, GELImage, fpUTF8Utils; implementation diff --git a/gfx/gdi/gfx_gdi.pas b/gfx/gdi/gfx_gdi.pas index b04a4bb7..0bab2535 100644 --- a/gfx/gdi/gfx_gdi.pas +++ b/gfx/gdi/gfx_gdi.pas @@ -13,7 +13,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. } -unit GFX_GDI; +unit gfx_gdi; {$ifdef fpc} {$mode delphi}{$H+} @@ -190,22 +190,6 @@ type function DoMouseEnterLeaveCheck(uMsg, wParam, lParam: Cardinal): Boolean; procedure EvInternalPaint; { Event processing methods } - procedure EvPaint; override; - public - { Constructors / Destructors } - constructor Create(AParent: TFCustomWindow; AWindowOptions: TFWindowOptions); override; - destructor Destroy; override; - { Widget controling methods } - procedure SetPosition(const APosition: TPoint); override; - procedure SetSize(const ASize: TSize); override; - procedure SetMinMaxSize(const AMinSize, AMaxSize: TSize); override; - procedure SetClientSize(const ASize: TSize); override; - procedure SetMinMaxClientSize(const AMinSize, AMaxSize: TSize); override; - procedure Show; override; - procedure Invalidate; override; - procedure CaptureMouse; override; - procedure ReleaseMouse; override; - { Event processing methods } procedure EvCreate; override; procedure EvFocusIn; override; procedure EvFocusOut; override; @@ -219,10 +203,24 @@ type procedure EvMouseReleased(AButton: TMouseButton; const AMousePos: TPoint); override; procedure EvMouseMove(const AMousePos: TPoint); override; procedure EvMouseWheel(AWheelDelta: Single; const AMousePos: TPoint); override; -// procedure EvPaint; override; + procedure EvPaint; override; procedure EvMove; override; procedure EvResize; override; procedure EvShow; override; + public + { Constructors / Destructors } + constructor Create(AParent: TFCustomWindow; AWindowOptions: TFWindowOptions); override; + destructor Destroy; override; + { Widget controling methods } + procedure SetPosition(const APosition: TPoint); override; + procedure SetSize(const ASize: TSize); override; + procedure SetMinMaxSize(const AMinSize, AMaxSize: TSize); override; + procedure SetClientSize(const ASize: TSize); override; + procedure SetMinMaxClientSize(const AMinSize, AMaxSize: TSize); override; + procedure Show; override; + procedure Invalidate; override; + procedure CaptureMouse; override; + procedure ReleaseMouse; override; end; @@ -1569,64 +1567,129 @@ begin end; procedure TGDIWindow.EvKeyPressed(AKey: Word); +var + vEvent: TFEvent; begin if Assigned(OnKeyPressed) then OnKeyPressed(Self, AKey, GetKeyboardShiftState) - else if Assigned(Parent) then Parent.EvKeyPressed(AKey); + else if Assigned(Parent) then + begin + vEvent.EventType := etKeyPressed; + vEvent.Key := AKey; + Parent.ProcessEvent(vEvent); + end; end; procedure TGDIWindow.EvKeyReleased(AKey: Word); +var + vEvent: TFEvent; begin if Assigned(OnKeyReleased) then OnKeyReleased(Self, AKey, GetKeyboardShiftState) - else if Assigned(Parent) then Parent.EvKeyReleased(AKey); + else if Assigned(Parent) then + begin + vEvent.EventType := etKeyReleased; + vEvent.Key := AKey; + Parent.ProcessEvent(vEvent); + end; end; procedure TGDIWindow.EvKeyChar(AKeyChar: Char); +var + vEvent: TFEvent; begin if Assigned(OnKeyChar) then OnKeyChar(Self, AKeyChar) - else if Assigned(Parent) then Parent.EvKeyChar(AKeyChar); + else if Assigned(Parent) then + begin + vEvent.EventType := etKeyChar; + vEvent.KeyChar := AKeyChar; + Parent.ProcessEvent(vEvent); + end; end; procedure TGDIWindow.EvMouseEnter(const AMousePos: TPoint); +var + vEvent: TFEvent; begin if Assigned(OnMouseEnter) then OnMouseEnter(Self, GetKeyboardShiftState, AMousePos) - else if Assigned(Parent) then Parent.EvMouseEnter(AMousePos); + else if Assigned(Parent) then + begin + vEvent.EventType := etMouseEnter; + vEvent.MousePos := AMousePos; + Parent.ProcessEvent(vEvent); + end; end; procedure TGDIWindow.EvMouseLeave; +var + vEvent: TFEvent; begin if Assigned(OnMouseLeave) then OnMouseLeave(Self) - else if Assigned(Parent) then Parent.EvMouseLeave; + else if Assigned(Parent) then + begin + vEvent.EventType := etMouseLeave; + Parent.ProcessEvent(vEvent); + end; end; procedure TGDIWindow.EvMousePressed(AButton: TMouseButton; const AMousePos: TPoint); +var + vEvent: TFEvent; begin if Assigned(OnMousePressed) then OnMousePressed(Self, AButton, GetKeyboardShiftState, AMousePos) - else if Assigned(Parent) then Parent.EvMousePressed(AButton, AMousePos); + else if Assigned(Parent) then + begin + vEvent.EventType := etMousePressed; + vEvent.MousePos := AMousePos; + vEvent.MouseButton := AButton; + Parent.ProcessEvent(vEvent); + end; end; procedure TGDIWindow.EvMouseReleased(AButton: TMouseButton; const AMousePos: TPoint); +var + vEvent: TFEvent; begin if Assigned(OnMouseReleased) then OnMouseReleased(Self, AButton, GetKeyboardShiftState, AMousePos) - else if Assigned(Parent) then Parent.EvMouseReleased(AButton, AMousePos); + else if Assigned(Parent) then + begin + vEvent.EventType := etMouseReleased; + vEvent.MousePos := AMousePos; + vEvent.MouseButton := AButton; + Parent.ProcessEvent(vEvent); + end; end; procedure TGDIWindow.EvMouseMove(const AMousePos: TPoint); +var + vEvent: TFEvent; begin if Assigned(OnMouseMove) then OnMouseMove(Self, GetKeyboardShiftState, AMousePos) - else if Assigned(Parent) then Parent.EvMouseMove(AMousePos); + else if Assigned(Parent) then + begin + vEvent.EventType := etMouseMove; + vEvent.MousePos := AMousePos; + Parent.ProcessEvent(vEvent); + end; end; procedure TGDIWindow.EvMouseWheel(AWheelDelta: Single; const AMousePos: TPoint); +var + vEvent: TFEvent; begin if Assigned(OnMouseWheel) then OnMouseWheel(Self, GetKeyboardShiftState, AWheelDelta, AMousePos) - else if Assigned(Parent) then Parent.EvMouseWheel(AWheelDelta, AMousePos); + else if Assigned(Parent) then + begin + vEvent.EventType := etMouseMove; + vEvent.WheelDelta := AWheelDelta; + vEvent.MousePos := AMousePos; + Parent.ProcessEvent(vEvent); + end; end; { Because the painting code is executed on the middle of the processing diff --git a/gfx/gfxbase.pas b/gfx/gfxbase.pas index 9b5c2724..bf50bbfd 100644 --- a/gfx/gfxbase.pas +++ b/gfx/gfxbase.pas @@ -245,13 +245,15 @@ type etMouseEnter, etMouseLeave, etMousePressed, etMouseReleased, etMouseMove, etMouseWheel, etPaint, etMove, etResize, etShow); - TFEvent = class - public + TFEvent = record EventType: TFEventType; + { Key fields } + Key: Word; + KeyChar: Char; { Mouse fields } + MousePos: TPoint; MouseButton: TMouseButton; - X, Y: Cardinal; - Width, Height: Cardinal; + WheelDelta: Single; end; { TFCustomFont } @@ -506,24 +508,7 @@ type procedure DoSetCursor; virtual; abstract; function GetHandle: PtrUInt; virtual; abstract; - procedure EvPaint; virtual; abstract; - public - { Constructors / Destructors } - constructor Create(AParent: TFCustomWindow; AWindowOptions: TFWindowOptions); virtual; - destructor Destroy; override; - { Widget controling methods } - function CanClose: Boolean; virtual; - procedure SetPosition(const APosition: TPoint); virtual; - procedure SetSize(const ASize: TSize); virtual; - procedure SetMinMaxSize(const AMinSize, AMaxSize: TSize); virtual; - procedure SetClientSize(const ASize: TSize); virtual; - procedure SetMinMaxClientSize(const AMinSize, AMaxSize: TSize); virtual; - procedure Show; virtual; abstract; - procedure Invalidate; virtual; abstract; - procedure CaptureMouse; virtual; abstract; - procedure ReleaseMouse; virtual; abstract; { Event processing methods } -// procedure ProcessEvent(AEvent: TFEvent); virtual; abstract; procedure EvCreate; virtual; abstract; procedure EvFocusIn; virtual; abstract; procedure EvFocusOut; virtual; abstract; @@ -537,10 +522,27 @@ type procedure EvMouseReleased(AButton: TMouseButton; const AMousePos: TPoint); virtual; abstract; procedure EvMouseMove(const AMousePos: TPoint); virtual; abstract; procedure EvMouseWheel(AWheelDelta: Single; const AMousePos: TPoint); virtual; abstract; -// procedure EvPaint; virtual; abstract; + procedure EvPaint; virtual; abstract; procedure EvMove; virtual; abstract; procedure EvResize; virtual; abstract; procedure EvShow; virtual; abstract; + public + { Constructors / Destructors } + constructor Create(AParent: TFCustomWindow; AWindowOptions: TFWindowOptions); virtual; + destructor Destroy; override; + { Widget controling methods } + function CanClose: Boolean; virtual; + procedure SetPosition(const APosition: TPoint); virtual; + procedure SetSize(const ASize: TSize); virtual; + procedure SetMinMaxSize(const AMinSize, AMaxSize: TSize); virtual; + procedure SetClientSize(const ASize: TSize); virtual; + procedure SetMinMaxClientSize(const AMinSize, AMaxSize: TSize); virtual; + procedure Show; virtual; abstract; + procedure Invalidate; virtual; abstract; + procedure CaptureMouse; virtual; abstract; + procedure ReleaseMouse; virtual; abstract; + { Event processing methods } + procedure ProcessEvent(AEvent: TFEvent); { Properties } property WindowOptions: TFWindowOptions read FWindowOptions write SetWindowOptions; @@ -1037,6 +1039,31 @@ begin // Empty end; +procedure TFCustomWindow.ProcessEvent(AEvent: TFEvent); +begin + case AEvent.EventType of + etCreate: EvCreate(); + etCanClose: Exit; + etClose: Exit; + etFocusIn: EvFocusIn(); + etFocusOut: EvFocusOut(); + etHide: EvHide(); + etKeyPressed: EvKeyPressed(AEvent.Key); + etKeyReleased: EvKeyReleased(AEvent.Key); + etKeyChar: EvKeyChar(AEvent.KeyChar); + etMouseEnter: EvMouseEnter(AEvent.MousePos); + etMouseLeave: EvMouseLeave(); + etMousePressed: EvMousePressed(AEvent.MouseButton, AEvent.MousePos); + etMouseReleased: EvMouseReleased(AEvent.MouseButton, AEvent.MousePos); + etMouseMove: EvMouseMove(AEvent.MousePos); + etMouseWheel: EvMouseWheel(AEvent.WheelDelta, AEvent.MousePos); + etPaint: EvPaint(); + etMove: EvMove(); + etResize: EvResize(); + etShow: EvShow(); + end; +end; + constructor TFCustomWindow.Create(AParent: TFCustomWindow; AWindowOptions: TFWindowOptions); begin |