From 912b242bea57e40ec465665b545a437e114743da Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 29 Oct 2005 15:58:40 +0000 Subject: [PATCH] implemented TBitBtn override GetDefaultBitBtnGlyph git-svn-id: trunk@7997 - --- components/synedit/synedit.pp | 1 + lcl/buttons.pp | 20 ++++++++++++++++++++ lcl/include/bitbtn.inc | 25 +++++++++++++++++++------ lcl/interfaces/gtk/gtkcallback.inc | 13 ++++++++----- 4 files changed, 48 insertions(+), 11 deletions(-) diff --git a/components/synedit/synedit.pp b/components/synedit/synedit.pp index 08f9d47304..61239505e7 100644 --- a/components/synedit/synedit.pp +++ b/components/synedit/synedit.pp @@ -5679,6 +5679,7 @@ var ScrollHint: THintWindow; {$ENDIF} begin + //debugln('TCustomSynEdit.WMVScroll A ',DbgSName(Self),' Msg.ScrollCode=',dbgs(Msg.ScrollCode),' SB_PAGEDOWN=',dbgs(SB_PAGEDOWN),' SB_PAGEUP=',dbgs(SB_PAGEUP)); case Msg.ScrollCode of // Scrolls to start / end of the text SB_TOP: TopLine := 1; diff --git a/lcl/buttons.pp b/lcl/buttons.pp index d5655856f7..6dcb57a3e6 100644 --- a/lcl/buttons.pp +++ b/lcl/buttons.pp @@ -213,6 +213,8 @@ type { TBitBtn } + { To set custom bitbtn glyphs for the whole application, see below for + GetDefaultBitBtnGlyph } TBitBtn = class(TCustomBitBtn) published @@ -372,7 +374,25 @@ type property PopupMenu; end; + { To override the default TBitBtn glyphs set GetDefaultBitBtnGlyph below. + Example: + function GetBitBtnGlyph(Kind: TBitBtnKind): TBitmap; + begin + if Kind in [bkOK, bkCancel] then begin + Result:=TBitmap.Create; + case Kind of + bkOk: Result.Assign(MyOkGlyph); + bkCancel: Result.Assign(MyCancelGlyph); + end; + end else + Result:=nil; + end; + } +type + TGetDefaultBitBtnGlyph = function(Kind: TBitBtnKind): TBitmap; +var + GetDefaultBitBtnGlyph: TGetDefaultBitBtnGlyph = nil; procedure Register; diff --git a/lcl/include/bitbtn.inc b/lcl/include/bitbtn.inc index 0279f6be07..1e72f349c6 100644 --- a/lcl/include/bitbtn.inc +++ b/lcl/include/bitbtn.inc @@ -164,15 +164,28 @@ end; procedure TCustomBitBtn.RealizeKind; var - ABitmap: TBitmap; + GlyphValid: Boolean; + CustomGlyph: TBitmap; begin if (Kind<>bkCustom) then begin - ABitmap := Glyph; - if ABitmap = nil - then ABitmap := TBitmap.Create; - ABitmap.Handle := LoadStockPixmap(BitBtnImages[FKind]); - Glyph := ABitmap; + GlyphValid:=false; + + // first let the user override + if GetDefaultBitBtnGlyph<>nil then begin + CustomGlyph:=GetDefaultBitBtnGlyph(Kind); + if CustomGlyph<>nil then begin + Glyph.Assign(CustomGlyph); + CustomGlyph.Free; + GlyphValid:=true; + end; + end; + + // then ask the widgetset + if not GlyphValid then begin + Glyph.Handle := LoadStockPixmap(BitBtnImages[FKind]); + GlyphValid:=true; + end; end; if not (csLoading in ComponentState) diff --git a/lcl/interfaces/gtk/gtkcallback.inc b/lcl/interfaces/gtk/gtkcallback.inc index c1b74ca2d6..9ad0e3ac4a 100644 --- a/lcl/interfaces/gtk/gtkcallback.inc +++ b/lcl/interfaces/gtk/gtkcallback.inc @@ -2451,7 +2451,7 @@ end; {$IFDEF gtk1} function gtk_range_get_update_policy(range: PGTKRange): TGtkUpdateType; begin - result := policy(Range^) + result := policy(Range^); end; {$ENDIF} @@ -2466,7 +2466,7 @@ type {$ENDIF} begin {$IFDEF gtk1} - Result :=Scroll_type(Range^); + Result := Scroll_type(Range^); {$ELSE} if (gtk_major_version=2) and (gtk_minor_version<6) and (Range^.Timer<>nil) then @@ -2531,7 +2531,7 @@ begin if IsVertSB then Result := SB_PAGEDOWN else - Result := SB_PAGERIGHT; + Result := SB_PAGERIGHT; {$ifdef GTK2} GTK_SCROLL_STEP_UP: Result := SB_LINEUP; @@ -2631,7 +2631,7 @@ begin ScrollBar := HWND(Scroll); ScrollType := get_gtk_scroll_type(Scroll); ScrollCode := ScrollTypeToSbCode(False, ScrollType, - gtk_range_get_update_policy(Scroll)); + gtk_range_get_update_policy(Scroll)); end; DeliverMessage(Data, Msg); end; @@ -2653,10 +2653,13 @@ begin if Pos < High(SmallPos) then SmallPos := Pos else SmallPos := High(SmallPos); + //DebugLn('GTKVScrollCB A Adjustment^.Value=',dbgs(Adjustment^.Value),' SmallPos=',dbgs(SmallPos)); ScrollBar := HWND(Scroll); ScrollType := get_gtk_scroll_type(Scroll); + // GTK1 has a bug with wheel mouse. It sometimes gives the wrong direction. ScrollCode := ScrollTypeToSbCode(True, ScrollType, - gtk_range_get_update_policy(Scroll)); + gtk_range_get_update_policy(Scroll)); + //DebugLn('GTKVScrollCB B Adjustment^.Value=',dbgs(Adjustment^.Value),' ScrollCode=',dbgs(ScrollCode),' ScrollType=',dbgs(ScrollType)); end; DeliverMessage(Data, Msg); end;