summaryrefslogtreecommitdiff
path: root/prototypes
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-13 08:26:14 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-13 08:26:14 +0000
commit28b15796b4e5550fbe1837b4242bcadc50bfbcbd (patch)
treea1d26a1f90fcbd4359a93c7468bcd06e5a911ab6 /prototypes
parent234062f2837a5d707611ea0a54d2fcb4a5b93db1 (diff)
downloadfpGUI-28b15796b4e5550fbe1837b4242bcadc50bfbcbd.tar.xz
fpgui2: reverted the event changes made of yesterday.
Diffstat (limited to 'prototypes')
-rw-r--r--prototypes/fpgui2/examples/gui/stdimages/stdimglist.lpi1
-rw-r--r--prototypes/fpgui2/examples/gui/timertest/timertest.lpi1
-rw-r--r--prototypes/fpgui2/source/core/fpgfx.pas1
-rw-r--r--prototypes/fpgui2/source/core/gfx_widget.pas64
-rw-r--r--prototypes/fpgui2/source/core/gfxbase.pas22
-rw-r--r--prototypes/fpgui2/source/core/x11/gfx_x11.pas155
-rw-r--r--prototypes/fpgui2/source/gui/gui_combobox.pas6
-rw-r--r--prototypes/fpgui2/source/gui/gui_form.pas52
8 files changed, 69 insertions, 233 deletions
diff --git a/prototypes/fpgui2/examples/gui/stdimages/stdimglist.lpi b/prototypes/fpgui2/examples/gui/stdimages/stdimglist.lpi
index 28d0f2e9..f43952b3 100644
--- a/prototypes/fpgui2/examples/gui/stdimages/stdimglist.lpi
+++ b/prototypes/fpgui2/examples/gui/stdimages/stdimglist.lpi
@@ -17,7 +17,6 @@
</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>
diff --git a/prototypes/fpgui2/examples/gui/timertest/timertest.lpi b/prototypes/fpgui2/examples/gui/timertest/timertest.lpi
index 27a478f6..b3df5d3b 100644
--- a/prototypes/fpgui2/examples/gui/timertest/timertest.lpi
+++ b/prototypes/fpgui2/examples/gui/timertest/timertest.lpi
@@ -17,7 +17,6 @@
</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>
diff --git a/prototypes/fpgui2/source/core/fpgfx.pas b/prototypes/fpgui2/source/core/fpgfx.pas
index c53e6405..3d5320d3 100644
--- a/prototypes/fpgui2/source/core/fpgfx.pas
+++ b/prototypes/fpgui2/source/core/fpgfx.pas
@@ -31,6 +31,7 @@ type
TFButtonFlags = set of (btnIsEmbedded, btnIsDefault, btnIsPressed,
btnIsSelected, btnHasFocus, btnHasParentColor);
+ TMouseButton = (mbLeft, mbRight, mbMiddle);
const
diff --git a/prototypes/fpgui2/source/core/gfx_widget.pas b/prototypes/fpgui2/source/core/gfx_widget.pas
index de876b66..5b246681 100644
--- a/prototypes/fpgui2/source/core/gfx_widget.pas
+++ b/prototypes/fpgui2/source/core/gfx_widget.pas
@@ -25,6 +25,7 @@ type
FOnMouseUp: TMouseButtonEvent;
FOnPaint: TPaintEvent;
FOnScreen: boolean;
+ procedure MsgPaint(var msg: TfpgMessageRec); message FPGM_PAINT;
procedure MsgResize(var msg: TfpgMessageRec); message FPGM_RESIZE;
procedure MsgMove(var msg: TfpgMessageRec); message FPGM_MOVE;
procedure MsgKeyChar(var msg: TfpgMessageRec); message FPGM_KEYCHAR;
@@ -34,6 +35,8 @@ type
procedure MsgMouseUp(var msg: TfpgMessageRec); message FPGM_MOUSEUP;
procedure MsgMouseMove(var msg: TfpgMessageRec); message FPGM_MOUSEMOVE;
procedure MsgDoubleClick(var msg: TfpgMessageRec); message FPGM_DOUBLECLICK;
+ procedure MsgMouseEnter(var msg: TfpgMessageRec); message FPGM_MOUSEENTER;
+ procedure MsgMouseExit(var msg: TfpgMessageRec); message FPGM_MOUSEEXIT;
procedure SetActiveWidget(const AValue: TfpgWidget);
procedure SetEnabled(const AValue: boolean);
procedure SetVisible(const AValue: boolean);
@@ -53,6 +56,7 @@ type
procedure HandleResize(awidth, aheight: TfpgCoord); virtual;
procedure HandleMove(x, y: TfpgCoord); virtual;
procedure HandleKeyChar(var keycode: word; var shiftstate: word; var consumed: boolean); virtual;
+ procedure HandleKeyPress(var keycode: word; var shiftstate: word; var consumed: boolean); virtual;
procedure HandleKeyRelease(var keycode: word; var shiftstate: word; var consumed: boolean); virtual;
procedure HandleSetFocus; virtual;
procedure HandleKillFocus; virtual;
@@ -72,10 +76,6 @@ type
procedure MoveAndResizeBy(dx, dy, dw, dh: TfpgCoord);
procedure SetPosition(aleft, atop, awidth, aheight: TfpgCoord);
procedure RePaint;
- { Internal events }
- procedure EvPaint; override;
- procedure EvMouseEnter(const AMousePos: TPoint); override;
- procedure EvMouseLeave; override;
{ property events }
property OnPaint: TPaintEvent read FOnPaint write FOnPaint;
property OnMouseExit: TNotifyEvent read FOnMouseExit write FOnMouseExit;
@@ -223,7 +223,8 @@ end;
procedure TfpgWidget.MsgKeyPress(var msg: TfpgMessageRec);
var
- key, ss: word;
+ key: word;
+ ss: word;
consumed: boolean;
wg: TfpgWidget;
begin
@@ -331,6 +332,20 @@ begin
//
end;
+procedure TfpgWidget.MsgMouseEnter(var msg: TfpgMessageRec);
+begin
+ HandleMouseEnter;
+ if Assigned(FOnMouseEnter) then
+ FOnMouseEnter(self);
+end;
+
+procedure TfpgWidget.MsgMouseExit(var msg: TfpgMessageRec);
+begin
+ HandleMouseExit;
+ if Assigned(FOnMouseExit) then
+ FOnMouseExit(Self);
+end;
+
procedure TfpgWidget.HandleShow;
var
n: integer;
@@ -372,30 +387,6 @@ begin
HandlePaint;
end;
-procedure TfpgWidget.EvPaint;
-begin
- HandlePaint;
- if Assigned(FOnPaint) then
- FOnPaint(Self);
- inherited EvPaint;
-end;
-
-procedure TfpgWidget.EvMouseEnter(const AMousePos: TPoint);
-begin
- HandleMouseEnter;
- if Assigned(FOnMouseEnter) then
- FOnMouseEnter(self);
- inherited EvMouseEnter(AMousePos);
-end;
-
-procedure TfpgWidget.EvMouseLeave;
-begin
- HandleMouseExit;
- if Assigned(FOnMouseExit) then
- FOnMouseExit(Self);
- inherited EvMouseLeave;
-end;
-
procedure TfpgWidget.SetFocus;
begin
HandleSetFocus;
@@ -483,9 +474,15 @@ begin
end;
end;
+procedure TfpgWidget.HandleKeyPress(var keycode: word; var shiftstate: word;
+ var consumed: boolean);
+begin
+ // descendants will implement this.
+end;
+
procedure TfpgWidget.HandleKeyRelease(var keycode: word; var shiftstate: word; var consumed: boolean);
begin
- // nothing yet.
+ // descendants will implement this.
end;
procedure TfpgWidget.HandleSetFocus;
@@ -639,6 +636,13 @@ begin
end;
end;
+procedure TfpgWidget.MsgPaint(var msg: TfpgMessageRec);
+begin
+ HandlePaint;
+ if Assigned(FOnPaint) then
+ FOnPaint(Self);
+end;
+
procedure TfpgWidget.MsgResize(var msg: TfpgMessageRec);
begin
HandleResize(msg.Params.rect.Width, msg.params.rect.Height);
diff --git a/prototypes/fpgui2/source/core/gfxbase.pas b/prototypes/fpgui2/source/core/gfxbase.pas
index ff4a390b..6d11808d 100644
--- a/prototypes/fpgui2/source/core/gfxbase.pas
+++ b/prototypes/fpgui2/source/core/gfxbase.pas
@@ -144,8 +144,6 @@ type
TfpgLineStyle = (lsSolid, lsDash, lsDot);
- TMouseButton = (mbLeft, mbRight, mbMiddle);
-
TfpgImageBase = class(TObject)
protected
@@ -293,26 +291,6 @@ type
function GetCanvas: TfpgCanvasBase; virtual;
procedure AllocateWindowHandle;
procedure ReleaseWindowHandle;
- { Event processing methods }
- procedure EvCreate; virtual; abstract;
- procedure EvFocusIn; virtual; abstract;
- procedure EvFocusOut; virtual; abstract;
- procedure EvHide; virtual; abstract;
-// procedure EvKeyPressed(AKey: Word); virtual; abstract;
- procedure EvKeyPressed(const AKeyCode: word; const AShiftState: word); virtual; abstract;
- procedure EvKeyReleased(AKey: Word); virtual; abstract;
- procedure EvKeyChar(AKeyChar: Char); virtual; abstract;
- procedure EvMouseEnter(const AMousePos: TPoint); virtual; abstract;
- procedure EvMouseLeave; virtual; abstract;
- procedure EvMousePressed(AButton: TMouseButton; const AMousePos: TPoint); virtual; abstract;
- 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 EvMove; virtual; abstract;
- procedure EvResize; virtual; abstract;
- procedure EvShow; virtual; abstract;
- procedure HandleKeyPress(var keycode: word; var shiftstate: word; var consumed: boolean); virtual; abstract;
public
// make some setup before the window shows
procedure AdjustWindowStyle; virtual; // forms modify the window creation parameters
diff --git a/prototypes/fpgui2/source/core/x11/gfx_x11.pas b/prototypes/fpgui2/source/core/x11/gfx_x11.pas
index f1f0e994..fe58da64 100644
--- a/prototypes/fpgui2/source/core/x11/gfx_x11.pas
+++ b/prototypes/fpgui2/source/core/x11/gfx_x11.pas
@@ -129,27 +129,6 @@ type
function DoWindowToScreen(ASource: TfpgWindowBase; const AScreenPos: TPoint): TPoint; override;
procedure DoUpdateWindowPosition(aleft, atop, awidth, aheight: TfpgCoord); override;
property WinHandle: TfpgWinHandle read FWinHandle;
- { Event processing methods }
- procedure EvCreate; override;
- procedure EvFocusIn; override;
- procedure EvFocusOut; override;
- procedure EvHide; override;
-// procedure EvKeyPressed(AKey: Word); override;
- procedure EvKeyPressed(const AKeyCode: word; const AShiftState: word); override;
- procedure EvKeyReleased(AKey: Word); override;
- procedure EvKeyChar(AKeyChar: Char); override;
- procedure EvMouseEnter(const AMousePos: TPoint); override;
- procedure EvMouseLeave; override;
- procedure EvMousePressed(AButton: TMouseButton; const AMousePos: TPoint); override;
- 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 EvMove; override;
- procedure EvResize; override;
- procedure EvShow; override;
- { This will be removed later }
- procedure HandleKeyPress(var keycode: word; var shiftstate: word; var consumed: boolean); override;
public
constructor Create(AOwner: TComponent); override;
end;
@@ -563,9 +542,6 @@ begin
// WriteLn('Event ',GetXEventName(ev._type),': ', ev._type,' window: ', ev.xany.window);
- // The window that received the message
- w := FindWindowByHandle(ev.xany.window);
-
case ev._type of
MSG_KEYPRESS,
MSG_KEYRELEASE:
@@ -584,8 +560,7 @@ begin
if ev._type = MSG_KEYPRESS then
begin
- w.EvKeyPressed(X11keycodeToScanCode(ev.xkey.keycode), Word(ev.xkey.state));
-// fpgPostMessage(nil, w, FPGM_KEYPRESS, msgp);
+ fpgPostMessage(nil, w, FPGM_KEYPRESS, msgp);
//Writeln('scancode: ',IntToHex(X11keycodeToScanCode(ev.xkey.keycode),4)
// ,' (',X11keycodeToScanCode(ev.xkey.keycode),')');
@@ -688,8 +663,7 @@ begin
until not XCheckTypedWindowEvent(display, ev.xany.window, MSG_PAINT, @ev);
if ev.xexpose.count = 0 then
begin
- w.EvPaint;
-// fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_PAINT);
+ fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_PAINT);
end;
end;
@@ -761,27 +735,21 @@ begin
}
MSG_ACTIVATE:
- w.EvFocusIn;
-// fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_ACTIVATE);
+ fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_ACTIVATE);
MSG_DEACTIVATE:
- w.EvFocusOut;
-// fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_DEACTIVATE);
+ fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_DEACTIVATE);
MSG_MOUSEENTER:
- w.EvMouseEnter(Point(ev.xbutton.x, ev.xbutton.y));
-// fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_MOUSEENTER);
+// w.EvMouseEnter(Point(ev.xbutton.x, ev.xbutton.y));
+ fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_MOUSEENTER);
MSG_MOUSEEXIT:
- w.EvMouseLeave;
-// fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_MOUSEEXIT);
+ fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_MOUSEEXIT);
{ We handle these two event manually in the TfpgForm class }
// MapNotify:
-// w.EvShow;
-
// UnmapNotify:
-// w.EvHide;
GraphicsExpose,
NoExpose:
@@ -962,115 +930,6 @@ begin
XMoveResizeWindow(xapplication.display, FWinHandle, aleft, atop, w, h);
end;
-procedure TfpgWindowImpl.EvCreate;
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvFocusIn;
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvFocusOut;
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvHide;
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvKeyPressed(const AKeyCode: word; const AShiftState: word);
-var
- k, ss: word;
- b: boolean;
-begin
- k := AKeyCode;
- ss := AShiftState;
- b := False;
- HandleKeyPress(k, ss, b);
-end;
-
-procedure TfpgWindowImpl.EvKeyReleased(AKey: Word);
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvKeyChar(AKeyChar: Char);
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvMouseEnter(const AMousePos: TPoint);
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvMouseLeave;
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvMousePressed(AButton: TMouseButton;
- const AMousePos: TPoint);
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvMouseReleased(AButton: TMouseButton;
- const AMousePos: TPoint);
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvMouseMove(const AMousePos: TPoint);
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvMouseWheel(AWheelDelta: Single;
- const AMousePos: TPoint);
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvPaint;
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvMove;
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvResize;
-begin
-
-end;
-
-procedure TfpgWindowImpl.EvShow;
-begin
-
-end;
-
-procedure TfpgWindowImpl.HandleKeyPress(var keycode: word; var shiftstate: word; var consumed: boolean);
-var
- w: TfpgWindowImpl;
-begin
- if not consumed then
- begin
- w := TfpgWindowImpl(Parent);
- while (not consumed) and (w <> nil) do
- begin
- w.HandleKeyPress(keycode, shiftstate, consumed);
- w := TfpgWindowImpl(w.Parent);
- end;
- end;
-end;
-
procedure TfpgWindowImpl.DoSetWindowTitle(const atitle: string);
var
s: string;
diff --git a/prototypes/fpgui2/source/gui/gui_combobox.pas b/prototypes/fpgui2/source/gui/gui_combobox.pas
index 17cc0003..4e945e06 100644
--- a/prototypes/fpgui2/source/gui/gui_combobox.pas
+++ b/prototypes/fpgui2/source/gui/gui_combobox.pas
@@ -59,17 +59,17 @@ type
TDropDownWindow = class(TfpgForm)
protected
- procedure EvPaint; override;
+ procedure HandlePaint; override;
public
constructor Create(AOwner: TComponent); override;
end;
{ TDropDownWindow }
-procedure TDropDownWindow.EvPaint;
+procedure TDropDownWindow.HandlePaint;
begin
Canvas.BeginDraw;
- inherited EvPaint;
+ inherited HandlePaint;
Canvas.Clear(clWhite);
Canvas.SetColor(clYellow);
Canvas.SetLineStyle(2, lsSolid);
diff --git a/prototypes/fpgui2/source/gui/gui_form.pas b/prototypes/fpgui2/source/gui/gui_form.pas
index 21bb7537..3b7cbf65 100644
--- a/prototypes/fpgui2/source/gui/gui_form.pas
+++ b/prototypes/fpgui2/source/gui/gui_form.pas
@@ -34,6 +34,8 @@ type
procedure AdjustWindowStyle; override;
procedure SetWindowParameters; override;
procedure SetWindowTitle(const AValue: string);
+ procedure MsgActivate(var msg: TfpgMessageRec); message FPGM_ACTIVATE;
+ procedure MsgDeActivate(var msg: TfpgMessageRec); message FPGM_DEACTIVATE;
procedure MsgClose(var msg: TfpgMessageRec); message FPGM_CLOSE;
procedure HandlePaint; override;
procedure HandleClose; virtual;
@@ -41,9 +43,6 @@ type
procedure HandleShow; override;
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
- { Internal Events }
- procedure EvFocusIn; override;
- procedure EvFocusOut; override;
public
constructor Create(AOwner: TComponent); override;
procedure AfterCreate; virtual;
@@ -106,6 +105,28 @@ begin
inherited DoSetWindowTitle(FWindowTitle);
end;
+procedure TfpgForm.MsgActivate(var msg: TfpgMessageRec);
+begin
+ if (fpgTopModalForm = nil) or (fpgTopModalForm = self) then
+ begin
+ FocusRootWidget := self;
+ if ActiveWidget = nil then
+ ActiveWidget := FindFocusWidget(nil, fsdFirst)
+ else
+ ActiveWidget.SetFocus;
+ end;
+ if Assigned(FOnActivate) then
+ FOnActivate(self);
+end;
+
+procedure TfpgForm.MsgDeActivate(var msg: TfpgMessageRec);
+begin
+ if ActiveWidget <> nil then
+ ActiveWidget.KillFocus;
+ if Assigned(FOnDeactivate) then
+ FOnDeactivate(self);
+end;
+
procedure TfpgForm.HandlePaint;
begin
Canvas.BeginDraw;
@@ -225,31 +246,6 @@ begin
FOnDestroy(self);
end;
-procedure TfpgForm.EvFocusIn;
-begin
- if (fpgTopModalForm = nil) or (fpgTopModalForm = self) then
- begin
- FocusRootWidget := self;
- if ActiveWidget = nil then
- ActiveWidget := FindFocusWidget(nil, fsdFirst)
- else
- ActiveWidget.SetFocus;
- end;
- if Assigned(FOnActivate) then
- FOnActivate(self);
-
- inherited EvFocusIn;
-end;
-
-procedure TfpgForm.EvFocusOut;
-begin
- if ActiveWidget <> nil then
- ActiveWidget.KillFocus;
- if Assigned(FOnDeactivate) then
- FOnDeactivate(self);
- inherited EvFocusOut;
-end;
-
procedure TfpgForm.Hide;
begin
if (fpgTopModalForm = self) then