summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-12 14:59:33 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-12 14:59:33 +0000
commitc1add0626ace53bac8e67dbef7e95c7d346187ab (patch)
tree092d69e05a52a464da9cd249f480e98a0c41d408
parent4be664970bd1fddec7b97c2d9165f07bbbb52bcf (diff)
downloadfpGUI-c1add0626ace53bac8e67dbef7e95c7d346187ab.tar.xz
fpgui2 prototype changes (Linux only):
* Started the conversion from use of Messages to Event Methods. So far I have converted MouseEnter, MouseExit, KeyPress, Activate, Deactivate and Paint events. * I have merged the Parent and ParentWindow properties into one Parent property. Descendants reintroduce the property and casts it's type correctly. All this has only been tested under Linux and the tests/edittest project. The Windows build is currently broken.
-rw-r--r--prototypes/fpgui2/source/core/fpgfx.pas31
-rw-r--r--prototypes/fpgui2/source/core/gfx_widget.pas80
-rw-r--r--prototypes/fpgui2/source/core/gfxbase.pas41
-rw-r--r--prototypes/fpgui2/source/core/x11/gfx_x11.pas171
-rw-r--r--prototypes/fpgui2/source/gui/gui_button.pas4
-rw-r--r--prototypes/fpgui2/source/gui/gui_form.pas53
-rw-r--r--prototypes/fpgui2/source/gui/gui_label.pas1
7 files changed, 278 insertions, 103 deletions
diff --git a/prototypes/fpgui2/source/core/fpgfx.pas b/prototypes/fpgui2/source/core/fpgfx.pas
index 857a30aa..c53e6405 100644
--- a/prototypes/fpgui2/source/core/fpgfx.pas
+++ b/prototypes/fpgui2/source/core/fpgfx.pas
@@ -31,7 +31,6 @@ type
TFButtonFlags = set of (btnIsEmbedded, btnIsDefault, btnIsPressed,
btnIsSelected, btnHasFocus, btnHasParentColor);
- TMouseButton = (mbLeft, mbRight, mbMiddle);
const
@@ -62,7 +61,7 @@ type
TMouseMoveEvent = procedure(Sender: TObject; AShift: TShiftState; const AMousePos: TPoint) of object;
TMouseWheelEvent = procedure(Sender: TObject; AShift: TShiftState; AWheelDelta: Single; const AMousePos: TPoint) of object;
{ Painting }
- TPaintEvent = procedure(Sender: TObject; const ARect: TfpgRect) of object;
+ TPaintEvent = procedure(Sender: TObject{; const ARect: TfpgRect}) of object;
type
TSizeParams = record
@@ -98,13 +97,13 @@ type
TfpgWindow = class(TfpgWindowImpl)
protected
- procedure SetParentWindow(const AValue: TfpgWindow); reintroduce;
- function GetParentWindow: TfpgWindow; reintroduce;
+ procedure SetParent(const AValue: TfpgWindow); reintroduce;
+ function GetParent: TfpgWindow; reintroduce;
function GetCanvas: TfpgCanvas; reintroduce;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
- property ParentWindow: TfpgWindow read GetParentWindow write SetParentWindow;
+ property Parent: TfpgWindow read GetParent write SetParent;
property Canvas: TfpgCanvas read GetCanvas;
property WinHandle; // surface this property from TfpgXXXImpl class in it's native format
end;
@@ -657,9 +656,9 @@ end;
{ TfpgWindow }
-constructor TfpgWindow.Create(aowner: TComponent);
+constructor TfpgWindow.Create(AOwner: TComponent);
begin
- inherited Create(aowner); // initialize the platform internals
+ inherited Create(AOwner); // initialize the platform internals
FTop := 0;
FLeft := 0;
@@ -671,16 +670,10 @@ begin
FModalForWin := nil;
- if (aowner <> nil) and (aowner is TfpgWindow) then
- begin
- FParentWindow := TfpgWindow(aowner);
- FWindowType := wtChild;
- end
+ if (AOwner <> nil) and (AOwner is TfpgWindow) then
+ FWindowType := wtChild
else
- begin
- FParentWindow := nil;
FWindowType := wtWindow;
- end;
FCanvas := TfpgCanvas.Create(self);
end;
@@ -691,14 +684,14 @@ begin
inherited Destroy;
end;
-procedure TfpgWindow.SetParentWindow(const AValue: TfpgWindow);
+procedure TfpgWindow.SetParent(const AValue: TfpgWindow);
begin
- inherited SetParentWindow(AValue);
+ inherited SetParent(AValue);
end;
-function TfpgWindow.GetParentWindow: TfpgWindow;
+function TfpgWindow.GetParent: TfpgWindow;
begin
- result := TfpgWindow(inherited GetParentWindow);
+ result := TfpgWindow(inherited GetParent);
end;
function TfpgWindow.GetCanvas: TfpgCanvas;
diff --git a/prototypes/fpgui2/source/core/gfx_widget.pas b/prototypes/fpgui2/source/core/gfx_widget.pas
index 34fa73af..de876b66 100644
--- a/prototypes/fpgui2/source/core/gfx_widget.pas
+++ b/prototypes/fpgui2/source/core/gfx_widget.pas
@@ -25,7 +25,6 @@ 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;
@@ -35,13 +34,10 @@ 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);
protected
- FParent: TfpgWidget;
FVisible: boolean;
FEnabled: boolean;
FFocusable: boolean;
@@ -50,12 +46,13 @@ type
FAnchors: TAnchors;
FActiveWidget: TfpgWidget;
FAlign: TAlign;
+ function GetParent: TfpgWidget; reintroduce;
+ procedure SetParent(const AValue: TfpgWidget); reintroduce;
procedure DoAlign(aalign: TAlign);
procedure HandlePaint; virtual;
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;
@@ -75,6 +72,10 @@ 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;
@@ -88,7 +89,7 @@ type
destructor Destroy; override;
procedure SetFocus;
procedure KillFocus;
- property Parent: TfpgWidget read FParent write FParent;
+ property Parent: TfpgWidget read GetParent write SetParent;
property ActiveWidget: TfpgWidget read FActiveWidget write SetActiveWidget;
property Visible: boolean read FVisible write SetVisible;
property Enabled: boolean read FEnabled write SetEnabled;
@@ -157,6 +158,16 @@ begin
end;
end;
+function TfpgWidget.GetParent: TfpgWidget;
+begin
+ Result := TfpgWidget(inherited GetParent);
+end;
+
+procedure TfpgWidget.SetParent(const AValue: TfpgWidget);
+begin
+ inherited SetParent(AValue);
+end;
+
constructor TfpgWidget.Create(AOwner: TComponent);
begin
FOnScreen := False;
@@ -171,11 +182,11 @@ begin
// OnKeyPress := nil;
if (AOwner <> nil) and (AOwner is TfpgWidget) then
- FParent := TfpgWidget(AOwner)
+ Parent := TfpgWidget(AOwner)
else
- FParent := nil;
+ Parent := nil;
- if FParent <> nil then
+ if Parent <> nil then
FWindowType := wtChild;
inherited;
@@ -187,13 +198,6 @@ begin
inherited;
end;
-procedure TfpgWidget.MsgPaint(var msg: TfpgMessageRec);
-begin
- HandlePaint;
- if Assigned(FOnPaint) then
- FOnPaint(Self, msg.Params.rect);
-end;
-
procedure TfpgWidget.MsgKeyChar(var msg: TfpgMessageRec);
var
key, ss: word;
@@ -327,20 +331,6 @@ 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;
@@ -349,7 +339,6 @@ begin
FOnScreen := True;
if FVisible then
begin
- FParentWindow := FParent;
AllocateWindowHandle;
for n := 0 to ComponentCount - 1 do
@@ -383,6 +372,30 @@ 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;
@@ -470,11 +483,6 @@ 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.
diff --git a/prototypes/fpgui2/source/core/gfxbase.pas b/prototypes/fpgui2/source/core/gfxbase.pas
index e5bbfc78..f1a6193d 100644
--- a/prototypes/fpgui2/source/core/gfxbase.pas
+++ b/prototypes/fpgui2/source/core/gfxbase.pas
@@ -144,6 +144,8 @@ type
TfpgLineStyle = (lsSolid, lsDash, lsDot);
+ TMouseButton = (mbLeft, mbRight, mbMiddle);
+
TfpgImageBase = class(TObject)
protected
@@ -266,6 +268,8 @@ type
TfpgWindowBase = class(TComponent)
+ private
+ FParent: TfpgWindowBase;
protected
FWindowType: TWindowType;
FWindowAttributes: TWindowAttributes;
@@ -276,16 +280,35 @@ type
FMinWidth: TfpgCoord;
FMinHeight: TfpgCoord;
FCanvas: TfpgCanvasBase;
- FParentWindow: TfpgWindowBase;
function HandleIsValid: boolean; virtual; abstract;
procedure DoUpdateWindowPosition(aleft, atop, awidth, aheight: TfpgCoord); virtual; abstract;
procedure DoAllocateWindowHandle(AParent: TfpgWindowBase); virtual; abstract;
procedure DoReleaseWindowHandle; virtual; abstract;
- procedure SetParentWindow(const AValue: TfpgWindowBase);
- function GetParentWindow: TfpgWindowBase;
+ procedure SetParent(const AValue: TfpgWindowBase); virtual;
+ function GetParent: TfpgWindowBase; virtual;
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
@@ -304,7 +327,7 @@ type
property MinWidth: TfpgCoord read FMinWidth write FMinWidth;
property MinHeight: TfpgCoord read FMinHeight write FMinHeight;
property Canvas: TfpgCanvasBase read GetCanvas;
- property ParentWindow: TfpgWindowBase read GetParentWindow write SetParentWindow;
+ property Parent: TfpgWindowBase read GetParent write SetParent;
end;
@@ -386,14 +409,14 @@ end;
{ TfpgWindowBase }
-procedure TfpgWindowBase.SetParentWindow(const AValue: TfpgWindowBase);
+procedure TfpgWindowBase.SetParent(const AValue: TfpgWindowBase);
begin
- FParentWindow := AValue;
+ FParent := AValue;
end;
-function TfpgWindowBase.GetParentWindow: TfpgWindowBase;
+function TfpgWindowBase.GetParent: TfpgWindowBase;
begin
- result := FParentWindow;
+ result := FParent;
end;
function TfpgWindowBase.GetCanvas: TfpgCanvasBase;
@@ -403,7 +426,7 @@ end;
procedure TfpgWindowBase.AllocateWindowHandle;
begin
- DoAllocateWindowHandle(FParentWindow);
+ DoAllocateWindowHandle(FParent);
end;
procedure TfpgWindowBase.ReleaseWindowHandle;
diff --git a/prototypes/fpgui2/source/core/x11/gfx_x11.pas b/prototypes/fpgui2/source/core/x11/gfx_x11.pas
index 064f26ea..650758db 100644
--- a/prototypes/fpgui2/source/core/x11/gfx_x11.pas
+++ b/prototypes/fpgui2/source/core/x11/gfx_x11.pas
@@ -126,6 +126,27 @@ type
procedure DoMoveWindow(x, y: TfpgCoord);
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;
@@ -539,7 +560,9 @@ 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:
@@ -558,7 +581,8 @@ begin
if ev._type = MSG_KEYPRESS then
begin
- fpgPostMessage(nil, w, FPGM_KEYPRESS, msgp);
+ w.EvKeyPressed(X11keycodeToScanCode(ev.xkey.keycode), Word(ev.xkey.state));
+// fpgPostMessage(nil, w, FPGM_KEYPRESS, msgp);
//Writeln('scancode: ',IntToHex(X11keycodeToScanCode(ev.xkey.keycode),4)
// ,' (',X11keycodeToScanCode(ev.xkey.keycode),')');
@@ -661,7 +685,8 @@ begin
until not XCheckTypedWindowEvent(display, ev.xany.window, MSG_PAINT, @ev);
if ev.xexpose.count = 0 then
begin
- fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_PAINT);
+ w.EvPaint;
+// fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_PAINT);
end;
end;
@@ -733,16 +758,27 @@ begin
}
MSG_ACTIVATE:
- fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_ACTIVATE);
+ w.EvFocusIn;
+// fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_ACTIVATE);
MSG_DEACTIVATE:
- fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_DEACTIVATE);
+ w.EvFocusOut;
+// fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_DEACTIVATE);
MSG_MOUSEENTER:
- 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:
- fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_MOUSEEXIT);
+ w.EvMouseLeave;
+// 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:
@@ -907,22 +943,131 @@ 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
- s8: string;
+ s: string;
p: PByte;
begin
if FWinHandle <= 0 then
Exit;
- s8 := atitle;
+ s := atitle;
- if length(s8) > 0 then
- p := @s8[1]
+ if length(s) > 0 then
+ p := @s[1]
else
p := nil;
- XChangeProperty(xapplication.display, FWinHandle, 39, 31, 8, 0, p, length(s8));
- XChangeProperty(xapplication.display, FWinHandle, 37, 31, 8, 0, p, length(s8));
+ XChangeProperty(xapplication.display, FWinHandle, 39, 31, 8, 0, p, length(s));
+ XChangeProperty(xapplication.display, FWinHandle, 37, 31, 8, 0, p, length(s));
{
var
diff --git a/prototypes/fpgui2/source/gui/gui_button.pas b/prototypes/fpgui2/source/gui/gui_button.pas
index 914aa479..15919902 100644
--- a/prototypes/fpgui2/source/gui/gui_button.pas
+++ b/prototypes/fpgui2/source/gui/gui_button.pas
@@ -281,9 +281,9 @@ begin
FClickOnPush := (not FDown) and AllowDown;
// search the other buttons in the group
- for n := 0 to FParent.ComponentCount - 1 do
+ for n := 0 to Parent.ComponentCount - 1 do
begin
- c := FParent.Components[n];
+ c := Parent.Components[n];
if (c <> self) and (c is TfpgButton) then
with TfpgButton(c) do
if GroupIndex = self.GroupIndex then
diff --git a/prototypes/fpgui2/source/gui/gui_form.pas b/prototypes/fpgui2/source/gui/gui_form.pas
index 8dff1aad..21bb7537 100644
--- a/prototypes/fpgui2/source/gui/gui_form.pas
+++ b/prototypes/fpgui2/source/gui/gui_form.pas
@@ -34,8 +34,6 @@ 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;
@@ -43,6 +41,9 @@ 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;
@@ -108,6 +109,7 @@ end;
procedure TfpgForm.HandlePaint;
begin
Canvas.BeginDraw;
+ inherited;
Canvas.Clear(FBackgroundColor);
Canvas.EndDraw(0, 0, FWidth, FHeight);
end;
@@ -183,28 +185,6 @@ begin
Result := ModalResult;
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.MsgClose(var msg: TfpgMessageRec);
begin
HandleClose;
@@ -245,6 +225,31 @@ 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
diff --git a/prototypes/fpgui2/source/gui/gui_label.pas b/prototypes/fpgui2/source/gui/gui_label.pas
index 18e8b2ed..b3d7f9b7 100644
--- a/prototypes/fpgui2/source/gui/gui_label.pas
+++ b/prototypes/fpgui2/source/gui/gui_label.pas
@@ -112,6 +112,7 @@ end;
procedure TfpgLabel.HandlePaint;
begin
Canvas.BeginDraw;
+ inherited;
Canvas.Clear(FBackgroundColor);
Canvas.SetFont(Font);
Canvas.SetTextColor(FColor);