diff options
-rw-r--r-- | gfx/gfxbase.pas | 1 | ||||
-rw-r--r-- | gfx/x11/gfx_x11.pas | 28 | ||||
-rw-r--r-- | prototypes/multihandle/gui2Base.pas | 37 |
3 files changed, 37 insertions, 29 deletions
diff --git a/gfx/gfxbase.pas b/gfx/gfxbase.pas index dab04c59..7783fb87 100644 --- a/gfx/gfxbase.pas +++ b/gfx/gfxbase.pas @@ -254,6 +254,7 @@ type State: Cardinal; Button: Cardinal; X, Y: Cardinal; + Width, Height: Cardinal; { fpGUI fields } EventType: TFEventType; end; diff --git a/gfx/x11/gfx_x11.pas b/gfx/x11/gfx_x11.pas index f4949007..f6f1ef38 100644 --- a/gfx/x11/gfx_x11.pas +++ b/gfx/x11/gfx_x11.pas @@ -1083,7 +1083,17 @@ begin end; X.Expose: begin - WindowEntry.Dispatch(XEvent); + {$Note We can do performance tuning here by looking at Count. + For now we are just ignoring all expose messages where Count <> 0 } + if XEvent.xexpose.count = 0 then + begin + Event.EventType := etPaint; + Event.X := XEvent.xexpose.x; + Event.Y := XEvent.xexpose.y; + Event.Width := XEvent.xexpose.width; + Event.Height := Xevent.xexpose.height; + WindowEntry.ProcessEvent(Event); + end; end; X.ConfigureNotify: begin @@ -1571,18 +1581,18 @@ begin else Sum := 1; - // Check for other mouse wheel messages in the queue + // Check for other mouse wheel messages in the queue while XCheckTypedWindowEvent(GFApplication.Handle, Handle, X.ButtonPress, @NewEvent) do begin - if NewEvent.xbutton.Button = 4 then - Dec(Sum) + if NewEvent.xbutton.Button = 4 then + Dec(Sum) else if NewEvent.xbutton.Button = 5 then - Inc(Sum) + Inc(Sum) else - begin - XPutBackEvent(GFApplication.Handle, @NewEvent); + begin + XPutBackEvent(GFApplication.Handle, @NewEvent); break; - end; + end; end; if Assigned(OnMouseWheel) then @@ -1610,7 +1620,7 @@ begin end; etPaint: begin - + if Assigned(OnPaint) then OnPaint(Self, Rect(AEvent.X, AEvent.Y, AEvent.Width, AEvent.Height)); end; etMove: begin 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); |