summaryrefslogtreecommitdiff
path: root/prototypes
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@users.sourceforge.net>2006-12-05 23:14:16 +0000
committerGraeme Geldenhuys <graemeg@users.sourceforge.net>2006-12-05 23:14:16 +0000
commitef70fd0f2770f0e084400373e786050f8dca6eba (patch)
treeb217e753d984541da6834bd994012b18b9c9696f /prototypes
parent8a4707265b7c0424e1bc50b7ed40315c7800fd3b (diff)
downloadfpGUI-ef70fd0f2770f0e084400373e786050f8dca6eba.tar.xz
One-Handle-Per-Widget
* Implemented the TX11Application Expose event handling * Implemented the TX11Window etPaint message processing * Removed the EvOnPaint event handler and replaced it by overriding ProcessEvent
Diffstat (limited to 'prototypes')
-rw-r--r--prototypes/multihandle/gui2Base.pas37
1 files changed, 17 insertions, 20 deletions
diff --git a/prototypes/multihandle/gui2Base.pas b/prototypes/multihandle/gui2Base.pas
index c42076c7..6b9b6821 100644
--- a/prototypes/multihandle/gui2Base.pas
+++ b/prototypes/multihandle/gui2Base.pas
@@ -53,8 +53,6 @@ type
private
FColor: TGfxColor;
FOnClick: TNotifyEvent;
- FOnPainting: TNotifyEvent;
- procedure EvOnPaint(Sender: TObject; const Rect: TRect); virtual;
procedure EvOnMouseReleased(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint); virtual;
procedure EvOnMousePressed(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint); virtual;
procedure EvOnMouseLeave(Sender: TObject); virtual;
@@ -63,13 +61,13 @@ type
FWidgetStyle: TWidgetStyle;
FWidgetState: TWidgetState;
procedure Paint; virtual;
- property OnPainting: TNotifyEvent read FOnPainting write FOnPainting;
property OnClick: TNotifyEvent read FOnClick write FOnClick;
property Color: TGfxColor read FColor write SetColor;
public
constructor Create(AParent: TFCustomWindow; AWindowOptions: TFWindowOptions); override;
constructor Create(AParent: TFCustomWindow); overload;
destructor Destroy; override;
+ procedure ProcessEvent(AEvent: TFEvent); override;
procedure SetFocus;
end;
@@ -94,7 +92,6 @@ type
TButton = class(TWidget)
private
FCaption: string;
- procedure EvOnPaint(Sender: TObject; const Rect: TRect); override;
procedure SetCaption(const AValue: string);
protected
procedure Paint; override;
@@ -185,17 +182,10 @@ end;
{ TWidget }
-procedure TWidget.EvOnPaint(Sender: TObject; const Rect: TRect);
-begin
- {$IFDEF DEBUG} Writeln(ClassName + '.Paint'); {$ENDIF}
- if Assigned(OnPainting) then
- OnPainting(self);
- Paint;
-end;
-
procedure TWidget.EvOnMouseReleased(Sender: TObject; AButton: TMouseButton;
AShift: TShiftState; const AMousePos: TPoint);
begin
+ {$IFDEF DEBUG} Writeln(ClassName + '.EvOnMouseReleased'); {$ENDIF}
if (wsClickable in FWidgetStyle) and (wsEnabled in FWidgetState) and
(AButton = mbLeft) then
begin
@@ -213,6 +203,7 @@ end;
procedure TWidget.EvOnMousePressed(Sender: TObject; AButton: TMouseButton;
AShift: TShiftState; const AMousePos: TPoint);
begin
+ {$IFDEF DEBUG} Writeln(ClassName + '.EvOnMousePressed'); {$ENDIF}
if (wsClickable in FWidgetStyle) and (wsEnabled in FWidgetState) and
(AButton = mbLeft) then
begin
@@ -238,6 +229,7 @@ procedure TWidget.Paint;
var
r: TRect;
begin
+ {$IFDEF DEBUG} Writeln(ClassName + '.Paint'); {$ENDIF}
Canvas.SetColor(FColor);
r.Left := 0;
r.Top := 0;
@@ -256,7 +248,6 @@ begin
Title := ClassName;
// Assign some event handlers
- OnPaint := @EvOnPaint;
OnMouseReleased := @EvOnMouseReleased;
OnMousePressed := @EvOnMousePressed;
OnMouseLeave := @EvOnMouseLeave;
@@ -269,12 +260,23 @@ end;
destructor TWidget.Destroy;
begin
- OnPaint := nil;
OnMouseReleased := nil;
OnMousePressed := nil;
inherited Destroy;
end;
+procedure TWidget.ProcessEvent(AEvent: TFEvent);
+begin
+ case AEvent.EventType of
+ etPaint:
+ begin
+ Paint;
+ end;
+ end; { case }
+
+ inherited ProcessEvent(AEvent);
+end;
+
procedure TWidget.SetFocus;
begin
Include(FWidgetState, wsHasFocus);
@@ -296,12 +298,6 @@ end;
{ TButton }
-procedure TButton.EvOnPaint(Sender: TObject; const Rect: TRect);
-begin
- inherited EvOnPaint(Sender, Rect);
- {$IFDEF DEBUG} Writeln(' - Painting ' + Caption); {$ENDIF}
-end;
-
procedure TButton.SetCaption(const AValue: string);
begin
if FCaption=AValue then exit;
@@ -316,6 +312,7 @@ var
r: TRect;
begin
inherited Paint;
+ {$IFDEF DEBUG} Writeln(' - Painting ' + Caption); {$ENDIF}
lFlags := [];
r := Rect(0, 0, Width, Height);