From: <aka...@us...> - 2024-08-14 20:53:12
|
Revision: 4293 http://sourceforge.net/p/gexperts/code/4293 Author: akalwahome Date: 2024-08-14 20:53:09 +0000 (Wed, 14 Aug 2024) Log Message: ----------- Fixed more dark mode issues. NEW: TGX_CheckButton and TGXCheckButtonGroup with theme support; replaces TdzSpeedBitBtn Added Image for TGxFilterExceptionsExpert. Modified Paths: -------------- branches/dark-mode/ExternalSource/dzlib/u_dzSpeedBitBtn.pas branches/dark-mode/ExternalSource/dzlib/u_dzVclUtils.pas branches/dark-mode/Images/GXIcons.rc branches/dark-mode/Projects/DelphiXx120/GExpertsRS120.dpr branches/dark-mode/Projects/DelphiXx120/GExpertsRS120.dproj branches/dark-mode/Source/CodeProofreader/GX_ProofreaderConfig.dfm branches/dark-mode/Source/CodeProofreader/GX_ProofreaderConfig.pas branches/dark-mode/Source/Framework/GX_About.dfm branches/dark-mode/Source/Framework/GX_FeedbackWizard.pas branches/dark-mode/Source/Framework/GX_GExperts.pas branches/dark-mode/Source/Grep/GX_GrepSearch.pas branches/dark-mode/Source/ProjectDependencies/GX_ProjDepend.pas branches/dark-mode/Source/RenameComponents/GX_CompRename.dfm branches/dark-mode/Source/RenameComponents/GX_CompRename.pas branches/dark-mode/Source/UsesExpert/GX_UsesExpert.dfm branches/dark-mode/Source/UsesExpert/GX_UsesExpert.pas Added Paths: ----------- branches/dark-mode/Source/Utils/GX_CheckButton.pas Modified: branches/dark-mode/ExternalSource/dzlib/u_dzSpeedBitBtn.pas =================================================================== --- branches/dark-mode/ExternalSource/dzlib/u_dzSpeedBitBtn.pas 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/ExternalSource/dzlib/u_dzSpeedBitBtn.pas 2024-08-14 20:53:09 UTC (rev 4293) @@ -38,9 +38,6 @@ /// Note: Actions do not work.</summary> TdzSpeedBitBtn = class(TWindowProcHook) private - FColorRaised: TColor; - FColorSunken: TColor; - FColorText: TColor; FCaption: string; FUpGlyph: TBitmap; FDownGlyph: TBitmap; @@ -57,7 +54,8 @@ procedure SetDown(const Value: Boolean); procedure UpdateGlyph; function GetBitBtn: TBitBtn; - procedure PrepareBmp(_w, _h: Integer; _Color: TColor; _Edge: UINT; _Glyph: TBitmap; _bmp: TBitmap); + procedure PrepareBmp(_w, _h: Integer; _Color: TColor; _Edge: UINT; _Glyph: TBitmap; + _bmp: TBitmap); procedure PrepareBmps(_UpBmp, _DownBmp: TBitmap); protected procedure NewWindowProc(var _Msg: TMessage); override; @@ -65,7 +63,6 @@ constructor Create(_btn: TBitBtn); reintroduce; overload; constructor Create(_btn: TBitBtn; _UpGlyph, _DownGlyph: TBitmap); overload; constructor Create(_btn: TBitBtn; _ImageList: TImageList; _UpGlyphIdx, _DownGlyphIdx: Integer); overload; - constructor Create(_btn: TWinControl; AColorText: TColor = clNone; AColorRaised: TColor = clNone; AColorSunken: TColor = clNone); overload; destructor Destroy; override; property Down: Boolean read GetDown write SetDown; property BitBtn: TBitBtn read GetBitBtn; @@ -82,9 +79,6 @@ FOnClick: TNotifyEvent; FList: TList; FAllowAllUp: Boolean; - FColorRaised: TColor; - FColorSunken: TColor; - FColorText: TColor; procedure HandleClick(_Sender: TObject); procedure doOnClick; function TryGetSelectedSb(out _Idx: Integer; out _sb: TdzSpeedBitBtn): Boolean; @@ -121,26 +115,13 @@ function TryGetSelected(out _Data: Pointer): Boolean; overload; property AllowAllUp: Boolean read FAllowAllUp write FAllowAllUp; property OnClick: TNotifyEvent read FOnClick write FOnClick; - property ColorRaised: TColor read FColorRaised write FColorRaised default clNone; - property ColorSunken: TColor read FColorSunken write FColorSunken default clNone; - property ColorText: TColor read FColorText write FColorText default clNone; end; + end; implementation -{$IF CompilerVersion >= 35} // Delphi 11 and up. - {$DEFINE USE_THEMING} -{$IFEND} - uses Math, Forms, -{$IFDEF USE_THEMING} - UxTheme, - Themes, - {$IFDEF USE_IDE_THEMING} - GX_OtaUtils, - {$ENDIF} -{$ENDIF} u_dzGraphicsUtils, u_dzMiscUtils; @@ -190,20 +171,6 @@ UpdateGlyph; end; -constructor TdzSpeedBitBtn.Create(_btn: TWinControl; - AColorText, AColorRaised, AColorSunken: TColor); -begin - inherited Create(_btn); - - FColorRaised := AColorRaised; - FColorSunken := AColorSunken; - FColorText := AColorText; - - if FColorRaised = clNone then FColorRaised := RGB(240, 240, 240); // clBtnFace; - if FColorSunken = clNone then FColorSunken := RGB(245, 245, 245); // a bit lighter than clBtnFace; - if FColorText = clNone then FColorText := RGB(0, 0, 0); // Black -end; - constructor TdzSpeedBitBtn.Create(_btn: TBitBtn; _ImageList: TImageList; _UpGlyphIdx, _DownGlyphIdx: Integer); var @@ -242,14 +209,10 @@ begin w := BitBtn.ClientWidth; h := BitBtn.ClientHeight; - BitBtn.Spacing := 0; ColBack1 := RGB(240, 240, 240); // clBtnFace; ColBack2 := RGB(245, 245, 245); // a bit lighter than clBtnFace; - if FColorRaised <> clNone then ColBack1 := FColorRaised; - if FColorSunken <> clNone then ColBack2 := FColorSunken; - PrepareBmp(w, h, ColBack1, EDGE_RAISED, FUpGlyph, FUpBmp); PrepareBmp(w, h, ColBack2, EDGE_SUNKEN, FDownGlyph, FDownBmp); end; @@ -258,11 +221,6 @@ _bmp: TBitmap); var cnv: TCanvas; -{$IFDEF USE_THEMING} - LStyleService : TCustomStyleServices; - LDetails : TThemedElementDetails; - DC : HDC; -{$ENDIF} procedure HandleBmpOnly; var @@ -294,21 +252,7 @@ HorizontalAlignment := dthaLeft; r := Rect(X + 2, 0, _w - 3, _h); end; -{$IFDEF USE_THEMING} - if Assigned(LStyleService) and (LStyleService.Enabled) then - begin - LStyleService.DrawText( - DC, - LDetails, - FCaption, - R, - [tfCenter, tfVerticalCenter, tfSingleLine], - FColorText - ); - end - else -{$ENDIF} - TCanvas_DrawTextSingleLine(cnv, FCaption, r, HorizontalAlignment, dtvaCenter, []); + TCanvas_DrawTextSingleLine(cnv, FCaption, r, HorizontalAlignment, dtvaCenter, []); end; procedure HandleTextOnlyMultiLine; @@ -447,40 +391,14 @@ _bmp.Height := _h; _bmp.TransparentColor := clFuchsia; -{$IFDEF USE_THEMING} - _bmp.PixelFormat := pfDevice; cnv := _bmp.Canvas; - {$IFDEF USE_IDE_THEMING} - LStyleService := IdeStyleService; - {$ELSE} - LStyleService := Themes.StyleServices; - {$ENDIF} - if Assigned(LStyleService) and LStyleService.Enabled then - begin - R := Rect(0, 0, _w, _h); - if _Edge = EDGE_SUNKEN then // "down" - begin - LDetails := LStyleService.GetElementDetails(TThemedButton.tbPushButtonPressed); - FColorText := LStyleService.GetStyleFontColor(TStyleFont.sfButtonTextPressed); - end - else begin // "up" - LDetails := LStyleService.GetElementDetails(TThemedButton.tbPushButtonNormal); - FColorText := LStyleService.GetStyleFontColor(TStyleFont.sfButtonTextNormal); - end; - LStyleService.DrawElement(DC, LDetails, R, nil, 0); -// _bmp.Canvas.Pixels[0, 0] := clFuchsia; - end - else -{$ENDIF USE_THEMING} - begin - cnv := _bmp.Canvas; - cnv.Brush.Color := _Color; - cnv.Brush.Style := bsSolid; - cnv.FillRect(Rect(0, 0, _w, _h)); + cnv.Brush.Color := _Color; + cnv.Brush.Style := bsSolid; + cnv.FillRect(Rect(0, 0, _w, _h)); - r := Rect(0, 0, _w - 1, _h - 2); - DrawEdge(cnv.Handle, r, _Edge, BF_RECT); - end; + r := Rect(0, 0, _w - 1, _h - 2); + DrawEdge(cnv.Handle, r, _Edge, BF_RECT); + cnv.Brush.Style := bsClear; cnv.Font := BitBtn.Font; @@ -572,9 +490,6 @@ begin inherited Create; FList := TList.Create; - FColorRaised := clNone; - FColorSunken := clNone; - FColorText := clNone; end; destructor TdzSpeedBitBtnGroup.Destroy; @@ -586,10 +501,7 @@ function TdzSpeedBitBtnGroup.Add(_btn: TBitBtn; _Data: Pointer): TdzSpeedBitBtn; begin _btn.OnClick := Self.HandleClick; -{$IFDEF USE_THEMING} - _btn.StyleElements := []; -{$ENDIF} - Result := TdzSpeedBitBtn.Create(_btn, FColorText, FColorRaised, FColorSunken); + Result := TdzSpeedBitBtn.Create(_btn); Result.Data := _Data; FList.Add(Result); end; @@ -599,7 +511,7 @@ Result := Add(_btn, nil); end; -function TdzSpeedBitBtnGroup.Add(_btn: TBitBtn; _Data: NativeInt): TdzSpeedBitBtn; +function TdzSpeedBitBtnGroup.Add(_btn: TBitBtn; _Data: Integer): TdzSpeedBitBtn; begin Result := Add(_btn, Pointer(_Data)); //FI:W541 Casting from Integer to Pointer type (or vice versa) end; Modified: branches/dark-mode/ExternalSource/dzlib/u_dzVclUtils.pas =================================================================== --- branches/dark-mode/ExternalSource/dzlib/u_dzVclUtils.pas 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/ExternalSource/dzlib/u_dzVclUtils.pas 2024-08-14 20:53:09 UTC (rev 4293) @@ -32,7 +32,7 @@ Themes, MultiMon, // this unit doesn't exist in older Delphi versions, use a unit alias like Multimon=Windows in that case {$IFDEF HAS_UNIT_SYSTEM_ACTIONS} - Actions, + System.Actions, {$ENDIF} {$IFDEF HAS_UNIT_SYSTEM_UITYPES} UITypes, Modified: branches/dark-mode/Images/GXIcons.rc =================================================================== --- branches/dark-mode/Images/GXIcons.rc 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/Images/GXIcons.rc 2024-08-14 20:53:09 UTC (rev 4293) @@ -49,6 +49,7 @@ TGrepNextItemExpert BITMAP "TGrepNextItemExpert.bmp" TGrepPrevItemExpert BITMAP "TGrepPrevItemExpert.bmp" TGrepSearchExpert BITMAP "TGrepSearchExpert.bmp" +TGxFilterExceptionsExpert BITMAP "TGxFilterExceptionsExpert.bmp" THideNonVisualCompsExpert BITMAP "THideNonVisualCompsExpert.bmp" TIDEMenuShortCutsExpert BITMAP "TIDEMenuShortCutsExpert.bmp" TIfDefExpert BITMAP "TIfDefExpert.bmp" Modified: branches/dark-mode/Projects/DelphiXx120/GExpertsRS120.dpr =================================================================== --- branches/dark-mode/Projects/DelphiXx120/GExpertsRS120.dpr 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/Projects/DelphiXx120/GExpertsRS120.dpr 2024-08-14 20:53:09 UTC (rev 4293) @@ -18,6 +18,7 @@ GX_BaseForm in '..\..\source\Framework\GX_BaseForm.pas' {fmBaseForm}, GX_BookmarkList in '..\..\source\Utils\GX_BookmarkList.pas', GX_Bookmarks in '..\..\source\Bookmarks\GX_Bookmarks.pas' {fmGxBookmarksForm}, + GX_CheckButton in '..\..\Source\Utils\GX_CheckButton.pas', GX_CheckListBoxWithHints in '..\..\Source\ProjectOptionSets\GX_CheckListBoxWithHints.pas', GX_ClassBrowser in '..\..\source\ClassBrowser\GX_ClassBrowser.pas' {fmClassBrowser}, GX_ClassHacks in '..\..\source\Framework\GX_ClassHacks.pas', Modified: branches/dark-mode/Projects/DelphiXx120/GExpertsRS120.dproj =================================================================== --- branches/dark-mode/Projects/DelphiXx120/GExpertsRS120.dproj 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/Projects/DelphiXx120/GExpertsRS120.dproj 2024-08-14 20:53:09 UTC (rev 4293) @@ -88,7 +88,6 @@ <Manifest_File>None</Manifest_File> </PropertyGroup> <PropertyGroup Condition="'$(Cfg_2_Win32)'!=''"> - <DCC_DebugDCUs>true</DCC_DebugDCUs> <Debugger_HostApplication>$(BDS)\bin\bds.exe</Debugger_HostApplication> <Debugger_RunParams>-rBDSPlain -pDelphi</Debugger_RunParams> </PropertyGroup> @@ -144,6 +143,7 @@ <Form>fmGxBookmarksForm</Form> <FormType>dfm</FormType> </DCCReference> + <DCCReference Include="..\..\Source\Utils\GX_CheckButton.pas"/> <DCCReference Include="..\..\Source\ProjectOptionSets\GX_CheckListBoxWithHints.pas"/> <DCCReference Include="..\..\source\ClassBrowser\GX_ClassBrowser.pas"> <Form>fmClassBrowser</Form> Modified: branches/dark-mode/Source/CodeProofreader/GX_ProofreaderConfig.dfm =================================================================== --- branches/dark-mode/Source/CodeProofreader/GX_ProofreaderConfig.dfm 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/Source/CodeProofreader/GX_ProofreaderConfig.dfm 2024-08-14 20:53:09 UTC (rev 4293) @@ -112,7 +112,7 @@ end object eCustomBeep: TEdit Left = 22 - Top = 48 + Top = 52 Width = 395 Height = 22 Anchors = [akLeft, akTop, akRight] @@ -121,7 +121,7 @@ end object btnSelectFile: TButton Left = 423 - Top = 48 + Top = 52 Width = 75 Height = 22 Anchors = [akTop, akRight] Modified: branches/dark-mode/Source/CodeProofreader/GX_ProofreaderConfig.pas =================================================================== --- branches/dark-mode/Source/CodeProofreader/GX_ProofreaderConfig.pas 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/Source/CodeProofreader/GX_ProofreaderConfig.pas 2024-08-14 20:53:09 UTC (rev 4293) @@ -132,6 +132,7 @@ SysUtils, MMSystem, GX_ProofreaderAutoCorrectEntry, GX_KibitzComp, GX_GxUtils, GX_GenericUtils, GX_OtaUtils, u_dzVclUtils, GX_ConfigurationInfo, + GX_IdeUtils, GX_GExperts; {$R *.dfm} @@ -152,6 +153,10 @@ Assert(Assigned(ProofreaderData)); FProofreaderData := ProofreaderData; + if IsThemingEnabled + then Pages.Style := tsButtons + else Pages.Style := tsTabs; + TabIndex := FProofreaderData.ActiveTab; if (TabIndex > -1) and (TabIndex < Pages.PageCount) then Pages.ActivePageIndex := TabIndex; Modified: branches/dark-mode/Source/Framework/GX_About.dfm =================================================================== --- branches/dark-mode/Source/Framework/GX_About.dfm 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/Source/Framework/GX_About.dfm 2024-08-14 20:53:09 UTC (rev 4293) @@ -38,7 +38,7 @@ Left = 368 Top = 72 Width = 147 - Height = 20 + Height = 14 Alignment = taCenter Caption = 'http://www.gexperts.org/' end @@ -46,7 +46,7 @@ Left = 275 Top = 91 Width = 84 - Height = 20 + Height = 14 Alignment = taRightJustify Caption = 'Project Leader:' end @@ -54,7 +54,7 @@ Left = 255 Top = 112 Width = 104 - Height = 20 + Height = 14 Alignment = taRightJustify Caption = 'Major Contributors:' end @@ -62,7 +62,7 @@ Left = 368 Top = 91 Width = 85 - Height = 20 + Height = 14 Cursor = crHandPoint Caption = 'Thomas Mueller' OnClick = btnEmailClick @@ -71,7 +71,7 @@ Left = 304 Top = 72 Width = 55 - Height = 20 + Height = 14 Alignment = taRightJustify Caption = 'Web Site:' end @@ -177,7 +177,9 @@ 'Alex Petrov' 'Puthoon' 'Mahdi Safsafi' - 'Martin Waldenburg') + 'Martin Waldenburg' + 'Thomas M'#252'ller' + 'Achim Kalwa') ParentCtl3D = False ReadOnly = True ScrollBars = ssVertical Modified: branches/dark-mode/Source/Framework/GX_FeedbackWizard.pas =================================================================== --- branches/dark-mode/Source/Framework/GX_FeedbackWizard.pas 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/Source/Framework/GX_FeedbackWizard.pas 2024-08-14 20:53:09 UTC (rev 4293) @@ -166,6 +166,10 @@ procedure TfmFeedbackWizard.Init(const ABugEmail, AFeatureEmail: string); begin + if IsThemingEnabled + then pgeMain.Style := tsButtons + else pgeMain.Style := tsTabs; + FBugEmail := ABugEmail; FFeatureEmail := AFeatureEmail; TLabel_MakeUrlLabel(l_BugReportUrl, FBugEmail, True); Modified: branches/dark-mode/Source/Framework/GX_GExperts.pas =================================================================== --- branches/dark-mode/Source/Framework/GX_GExperts.pas 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/Source/Framework/GX_GExperts.pas 2024-08-14 20:53:09 UTC (rev 4293) @@ -96,6 +96,7 @@ procedure ShowGXAboutForm; begin + gblAboutFormClass.SetCustomBuildDetails('Dark mode'); gblAboutFormClass.Execute(nil); end; Modified: branches/dark-mode/Source/Grep/GX_GrepSearch.pas =================================================================== --- branches/dark-mode/Source/Grep/GX_GrepSearch.pas 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/Source/Grep/GX_GrepSearch.pas 2024-08-14 20:53:09 UTC (rev 4293) @@ -812,7 +812,7 @@ TControl_SetConstraints(Self, [ccMinWidth, ccMinHeight, ccMaxHeight]); if not IsStandAlone then - InitTheming(Self); + InitTheming; FixComboBoxSelections(Self); end; Modified: branches/dark-mode/Source/ProjectDependencies/GX_ProjDepend.pas =================================================================== --- branches/dark-mode/Source/ProjectDependencies/GX_ProjDepend.pas 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/Source/ProjectDependencies/GX_ProjDepend.pas 2024-08-14 20:53:09 UTC (rev 4293) @@ -785,6 +785,10 @@ InitDpiScaler; + if IsThemingEnabled + then pcData.Style := tsButtons + else pcData.Style := tsTabs; + LoadSettings; ProjectNotifier := TProjectNotifier.Create(Self); Modified: branches/dark-mode/Source/RenameComponents/GX_CompRename.dfm =================================================================== --- branches/dark-mode/Source/RenameComponents/GX_CompRename.dfm 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/Source/RenameComponents/GX_CompRename.dfm 2024-08-14 20:53:09 UTC (rev 4293) @@ -4,7 +4,7 @@ ActiveControl = edtNewName BorderStyle = bsDialog Caption = 'GExperts Rename Component' - ClientHeight = 330 + ClientHeight = 350 ClientWidth = 321 Color = clBtnFace Font.Charset = ANSI_CHARSET @@ -36,9 +36,9 @@ end object p_Buttons: TPanel Left = 0 - Top = 99 + Top = 100 Width = 321 - Height = 231 + Height = 250 Align = alBottom TabOrder = 2 object lblReason: TLabel @@ -80,9 +80,9 @@ end object pc_Additional: TPageControl Left = 1 - Top = 53 + Top = 55 Width = 319 - Height = 177 + Height = 194 ActivePage = ts_Align Align = alBottom TabIndex = 0 @@ -90,9 +90,6 @@ OnChange = pc_AdditionalChange object ts_Align: TTabSheet Caption = '&Align' - DesignSize = ( - 311 - 148) object grp_Margins: TGroupBox Left = 176 Top = 0 @@ -274,9 +271,6 @@ object ts_Anchors: TTabSheet Caption = 'An&chors' ImageIndex = 1 - DesignSize = ( - 311 - 148) object b_AnchorLeft: TBitBtn Left = 80 Top = 46 Modified: branches/dark-mode/Source/RenameComponents/GX_CompRename.pas =================================================================== --- branches/dark-mode/Source/RenameComponents/GX_CompRename.pas 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/Source/RenameComponents/GX_CompRename.pas 2024-08-14 20:53:09 UTC (rev 4293) @@ -12,7 +12,8 @@ uses Classes, Controls, Forms, StdCtrls, ExtCtrls, ToolsAPI, ComCtrls, Buttons, - GX_Experts, GX_ConfigurationInfo, GX_EditorChangeServices, Contnrs, Messages, + GX_Experts, GX_ConfigurationInfo, GX_EditorChangeServices, GX_CheckButton, + Contnrs, Messages, Types, GX_BaseForm, u_dzSpeedBitBtn; type @@ -75,8 +76,8 @@ private FIsValidComponentName: TIsValidComponentName; FProperties: TObjectList; - FAnchorButtons: array[TAnchorKind] of TdzSpeedBitBtn; - FAlignButtons: array[TAlign] of TdzSpeedBitBtn; + FAnchorButtons: array[TAnchorKind] of TGXCheckButton; + FAlignButtons: array[TAlign] of TGXCheckButton; FComponentClassName: WideString; procedure InitializeForm; function GetNewName: WideString; @@ -83,7 +84,7 @@ function GetOldName: WideString; procedure SetNewName(const Value: WideString); procedure SetOldName(const Value: WideString); - procedure AddComponentProperty(PropertyName: WideString; const Value: WideString); + procedure AddComponentProperty(Index: Integer; PropertyName: WideString; const Value: WideString); function GetComponentProperty(Index: Integer): WideString; procedure SetComponent(const _Component: IOTAComponent); procedure SetAlign(const _Component: IOTAComponent); @@ -93,6 +94,8 @@ procedure HandleAlignButtons(_Align: TAlign); procedure SetMargins(_Value: integer); procedure DialogKey(var Msg: TWMKey); message CM_DIALOGKEY; + protected + procedure ArrangeControls; override; public constructor Create(Owner: TComponent); override; destructor Destroy; override; @@ -99,7 +102,6 @@ property OldName: WideString read GetOldName write SetOldName; property NewName: WideString read GetNewName write SetNewName; function Execute: TModalResult; - procedure FixTabOrder; procedure SetRuleSelection(SelStart, SelEnd: Integer); property OnIsValidComponentName: TIsValidComponentName read FIsValidComponentName write FIsValidComponentName; end; @@ -111,6 +113,7 @@ uses SysUtils, Windows, Menus, StrUtils, IniFiles, Graphics, TypInfo, u_dzClassUtils, u_dzVclUtils, u_dzStringUtils, + Themes, {$IFOPT D+}GX_DbugIntf, {$ENDIF} GX_CompRenameConfig, GX_OtaUtils, GX_GenericUtils, GX_IdeUtils; @@ -201,39 +204,14 @@ begin ActiveControl := edtNewName; // lblReason.Top := btnOK.Top + Round((btnOK.Height / 2) - (lblReason.Height / 2)); - FixTabOrder; Result := ShowModal; end; -procedure TfmCompRename.FixTabOrder; -var - i : Integer; - C : TWinControl; -begin - edtOldName.TabOrder := 0; - edtNewName.TabOrder := 1; - for i := 0 to FProperties.Count-1 do - begin - if FProperties[i] is TWinControl then begin - C := TWinControl(FProperties[i]); - TWinControl(C).TabOrder := 2 + i; - end; - end; - btnOK.TabOrder := FProperties.Count + 2; - btnCancel.TabOrder := FProperties.Count + 3; - btnSettings.TabOrder := FProperties.Count + 4; - pc_Additional.TabOrder := FProperties.Count + 5; -end; - procedure TfmCompRename.FormShow(Sender: TObject); begin inherited; // Adjust some button positons and size after scaling - // DisableAlign; - b_AlignRight.Left := b_AlignTop.Left + b_AlignTop.Width - b_AlignRight.Width; - b_AlignClient.Left := b_AlignLeft.Left + b_AlignLeft.Width + 1; - b_AlignClient.Width := b_AlignRight.Left - b_AlignClient.Left - 2; - // EnableAlign; +// ArrangeControls; end; function TfmCompRename.GetNewName: WideString; @@ -250,9 +228,9 @@ begin inherited; if pc_Additional.ActivePage = ts_Align then - TWinControl_SetFocus(b_AlignClient) + TWinControl_SetFocus(FAlignButtons[alClient]) else if pc_Additional.ActivePage = ts_Anchors then - TWinControl_SetFocus(b_AnchorTop); + TWinControl_SetFocus(FAnchorButtons[akTop]); end; procedure TfmCompRename.GetAlign(const _Component: IOTAComponent); @@ -431,7 +409,7 @@ edtNewName.SelLength := SelEnd - SelStart; end; -procedure TfmCompRename.AddComponentProperty(PropertyName: WideString; const Value: WideString); +procedure TfmCompRename.AddComponentProperty(Index: Integer; PropertyName: WideString; const Value: WideString); var Lbl: TLabel; Edit: TEdit; @@ -456,7 +434,7 @@ Edit.Left := edtNewName.Left; Edit.Width := edtNewName.Width; Edit.Text := Value; - Edit.TabOrder := FProperties.Count + 1 + edtNewName.TabOrder; + Edit.TabOrder := edtNewName.TabOrder + Index; FProperties.Add(Edit); if Edit.Text = SPropertyNotFound then begin @@ -467,7 +445,7 @@ end; diff := edtNewName.Top - edtOldName.Top; - Height := Height + diff; + ClientHeight := ClientHeight + diff; end; function TfmCompRename.GetComponentProperty(Index: Integer): WideString; @@ -484,19 +462,18 @@ TControl_SetMinConstraints(Self); FProperties := TObjectList.Create(False); + FAlignButtons[alTop] := TGXCheckButton.Clone(b_AlignTop); + FAlignButtons[alLeft] := TGXCheckButton.Clone(b_AlignLeft); + FAlignButtons[alClient] := TGXCheckButton.Clone(b_AlignClient); + FAlignButtons[alRight] := TGXCheckButton.Clone(b_AlignRight); + FAlignButtons[alBottom] := TGXCheckButton.Clone(b_AlignBottom); + FAlignButtons[alNone] := TGXCheckButton.Clone(b_AlignNone); + FAlignButtons[alCustom] := TGXCheckButton.Clone(b_AlignCustom); - FAlignButtons[alTop] := TdzSpeedBitBtn.Create(b_AlignTop); - FAlignButtons[alLeft] := TdzSpeedBitBtn.Create(b_AlignLeft); - FAlignButtons[alClient] := TdzSpeedBitBtn.Create(b_AlignClient); - FAlignButtons[alRight] := TdzSpeedBitBtn.Create(b_AlignRight); - FAlignButtons[alBottom] := TdzSpeedBitBtn.Create(b_AlignBottom); - FAlignButtons[alNone] := TdzSpeedBitBtn.Create(b_AlignNone); - FAlignButtons[alCustom] := TdzSpeedBitBtn.Create(b_AlignCustom); - - FAnchorButtons[akTop] := TdzSpeedBitBtn.Create(b_AnchorTop); - FAnchorButtons[akLeft] := TdzSpeedBitBtn.Create(b_AnchorLeft); - FAnchorButtons[akRight] := TdzSpeedBitBtn.Create(b_AnchorRight); - FAnchorButtons[akBottom] := TdzSpeedBitBtn.Create(b_AnchorBottom); + FAnchorButtons[akTop] := TGXCheckButton.Clone(b_AnchorTop); + FAnchorButtons[akLeft] := TGXCheckButton.Clone(b_AnchorLeft); + FAnchorButtons[akRight] := TGXCheckButton.Clone(b_AnchorRight); + FAnchorButtons[akBottom] := TGXCheckButton.Clone(b_AnchorBottom); p_Buttons.BevelOuter := bvNone; InitializeForm; @@ -513,44 +490,63 @@ // make the selection of alignment and anchors via arrow keys more intuitive case Msg.CharCode of VK_DOWN: begin - if ActiveControl = b_AlignTop then - b_AlignClient.SetFocus - else if (ActiveControl = b_AlignClient) or (ActiveControl = b_AlignLeft) or (ActiveControl = b_AlignRight) then - b_AlignBottom.SetFocus - else if (ActiveControl = b_AnchorTop) or (ActiveControl = b_AnchorLeft) or (ActiveControl = b_AnchorRight) then - b_AnchorBottom.SetFocus + if ActiveControl = FAlignButtons[alTop] then + FAlignButtons[alClient].SetFocus + else if (ActiveControl = FAlignButtons[alClient]) + or (ActiveControl = FAlignButtons[alLeft]) + or (ActiveControl = FAlignButtons[alRight]) + then + FAlignButtons[alBottom].SetFocus + else if (ActiveControl = FAnchorButtons[akTop]) + or (ActiveControl = FAnchorButtons[akLeft]) + or (ActiveControl = FAnchorButtons[akRight]) + then + FAnchorButtons[akBottom].SetFocus else inherited; end; VK_UP: begin - if ActiveControl = b_AlignBottom then - b_AlignClient.SetFocus - else if (ActiveControl = b_AlignClient) or (ActiveControl = b_AlignLeft) or (ActiveControl = b_AlignRight) then - b_AlignTop.SetFocus - else if (ActiveControl = b_AlignNone) or (ActiveControl = b_AlignCustom)then - b_AlignBottom.SetFocus - else if (ActiveControl = b_AnchorBottom) or (ActiveControl = b_AnchorLeft) or (ActiveControl = b_AnchorRight) then - b_AnchorTop.SetFocus + if ActiveControl = FAlignButtons[alBottom] then + FAlignButtons[alClient].SetFocus + else if (ActiveControl = FAlignButtons[alClient]) + or (ActiveControl = FAlignButtons[alLeft]) + or (ActiveControl = FAlignButtons[alRight]) + then + FAlignButtons[alTop].SetFocus + else if (ActiveControl = FAlignButtons[alNone]) + or (ActiveControl = FAlignButtons[alCustom]) + then + FAlignButtons[alBottom].SetFocus + else if (ActiveControl = FAnchorButtons[akBottom]) + or (ActiveControl = FAnchorButtons[akLeft]) + or (ActiveControl = FAnchorButtons[akRight]) + then + FAnchorButtons[akTop].SetFocus else inherited; end; VK_RIGHT: begin - if ActiveControl = b_AlignLeft then - b_AlignClient.SetFocus - else if ActiveControl = b_AlignClient then - b_AlignRight.SetFocus - else if (ActiveControl = b_AnchorTop) or (ActiveControl = b_AnchorBottom) or (ActiveControl = b_AnchorLeft) then - b_AnchorRight.SetFocus + if ActiveControl = FAlignButtons[alLeft] then + FAlignButtons[alClient].SetFocus + else if ActiveControl = FAlignButtons[alClient] then + FAlignButtons[alRight].SetFocus + else if (ActiveControl = FAnchorButtons[akTop]) + or (ActiveControl = FAnchorButtons[akBottom]) + or (ActiveControl = FAnchorButtons[akLeft]) + then + FAnchorButtons[akRight].SetFocus else inherited; end; VK_LEFT: begin - if ActiveControl = b_AlignRight then - b_AlignClient.SetFocus - else if ActiveControl = b_AlignClient then - b_AlignLeft.SetFocus - else if (ActiveControl = b_AnchorTop) or (ActiveControl = b_AnchorBottom) or (ActiveControl = b_AnchorRight) then - b_AnchorLeft.SetFocus + if ActiveControl = FAlignButtons[alRight] then + FAlignButtons[alClient].SetFocus + else if ActiveControl = FAlignButtons[alClient] then + FAlignButtons[alLeft].SetFocus + else if (ActiveControl = FAnchorButtons[akTop]) + or (ActiveControl = FAnchorButtons[akBottom]) + or (ActiveControl = FAnchorButtons[akRight]) then + FAnchorButtons[akLeft].SetFocus else inherited; end; @@ -915,13 +911,13 @@ end; end; if UsePropValue then - frm.AddComponentProperty(PropName, PropValue) + frm.AddComponentProperty(i, PropName, PropValue) else - frm.AddComponentProperty(PropName, + frm.AddComponentProperty(i, PropName, GxOtaGetComponentPropertyAsString(Component, PropName, True)); end else - frm.AddComponentProperty(PropName, SPropertyNotFound); + frm.AddComponentProperty(i, PropName, SPropertyNotFound); end; end end @@ -1302,8 +1298,53 @@ begin SetModalFormPopupMode(Self); lblReason.Font.Color := clRed; + if IsThemingEnabled + then pc_Additional.Style := tsButtons + else pc_Additional.Style := tsTabs; end; +procedure TfmCompRename.ArrangeControls; +var + Spacer : Integer; + H, W : Integer; +begin + inherited; + Spacer := FScaler.Calc(2); + FAlignButtons[alTop].Anchors := [akLeft, akTop]; + + FAlignButtons[alLeft].Anchors := [akLeft, akTop]; + FAlignButtons[alLeft].Left := FAlignButtons[alTop].Left; + FAlignButtons[alLeft].Top := FAlignButtons[alTop].Height + Spacer; + + W := FAlignButtons[alTop].Width - (2 * FAlignButtons[alLeft].Width) - (2 * Spacer); + H := FAlignButtons[alLeft].Height; + + FAlignButtons[alClient].Anchors := [akLeft, akTop]; + FAlignButtons[alClient].Top := FAlignButtons[alLeft].Top; + FAlignButtons[alClient].Width := W; + FAlignButtons[alClient].Left := FAlignButtons[alLeft].Left + FAlignButtons[alLeft].Width + Spacer; + FAlignButtons[alClient].Height := H; + + FAlignButtons[alRight].Anchors := [akLeft, akTop]; + FAlignButtons[alRight].Left := FAlignButtons[alClient].Left + FAlignButtons[alClient].Width + Spacer; + FAlignButtons[alRight].Top := FAlignButtons[alLeft].Top; + FAlignButtons[alRight].Width := FAlignButtons[alLeft].Width; + + FAlignButtons[alBottom].Anchors := [akLeft, akTop]; + FAlignButtons[alBottom].Top := FAlignButtons[alClient].Top + FAlignButtons[alClient].Height + Spacer; + FAlignButtons[alBottom].Left := FAlignButtons[alTop].Left; + FAlignButtons[alBottom].Width := FAlignButtons[alTop].Width; + + FAlignButtons[alNone].Anchors := [akLeft, akTop]; + FAlignButtons[alNone].Left := FAlignButtons[alLeft].Left; + FAlignButtons[alNone].Top := FAlignButtons[alBottom].Top + FAlignButtons[alBottom].Height + (2 * Spacer); + + FAlignButtons[alCustom].Anchors := [akLeft, akTop]; + FAlignButtons[alCustom].Top := FAlignButtons[alNone].Top; + FAlignButtons[alCustom].Width := FAlignButtons[alNone].Width; + FAlignButtons[alCustom].Left := FAlignButtons[alTop].Left + FAlignButtons[alTop].Width - FAlignButtons[alCustom].Width; +end; + procedure TfmCompRename.btnSettingsClick(Sender: TObject); begin Assert(Assigned(PrivateCompRenameExpert)); Modified: branches/dark-mode/Source/UsesExpert/GX_UsesExpert.dfm =================================================================== --- branches/dark-mode/Source/UsesExpert/GX_UsesExpert.dfm 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/Source/UsesExpert/GX_UsesExpert.dfm 2024-08-14 20:53:09 UTC (rev 4293) @@ -45,7 +45,7 @@ ImageIndex = 3 object pnlSearchPathFooter: TPanel Left = 0 - Top = 296 + Top = 295 Width = 654 Height = 48 Align = alBottom @@ -88,7 +88,7 @@ Left = 0 Top = 0 Width = 654 - Height = 296 + Height = 295 Align = alClient BevelOuter = bvNone BorderWidth = 3 @@ -98,7 +98,7 @@ Left = 3 Top = 3 Width = 648 - Height = 290 + Height = 289 Align = alClient ColCount = 1 DefaultColWidth = 100 @@ -125,7 +125,7 @@ Left = 0 Top = 0 Width = 654 - Height = 296 + Height = 295 Align = alClient BevelOuter = bvNone BorderWidth = 3 @@ -135,7 +135,7 @@ Left = 3 Top = 3 Width = 648 - Height = 257 + Height = 256 Align = alClient ColCount = 1 DefaultColWidth = 100 @@ -155,7 +155,7 @@ end object p_NoMapFile: TPanel Left = 3 - Top = 260 + Top = 259 Width = 648 Height = 33 Align = alBottom @@ -178,7 +178,7 @@ WordWrap = True end object b_NoMapFileClose: TButton - Left = 619 + Left = 611 Top = 0 Width = 25 Height = 33 @@ -191,7 +191,7 @@ end object pnlProjFooter: TPanel Left = 0 - Top = 297 + Top = 295 Width = 654 Height = 48 Align = alBottom @@ -265,7 +265,7 @@ Left = 0 Top = 0 Width = 654 - Height = 296 + Height = 295 Align = alClient BevelOuter = bvNone BorderWidth = 3 @@ -275,7 +275,7 @@ Left = 3 Top = 3 Width = 648 - Height = 290 + Height = 289 Align = alClient ColCount = 1 DefaultColWidth = 100 @@ -296,7 +296,7 @@ end object pnlCommonFooter: TPanel Left = 0 - Top = 296 + Top = 295 Width = 654 Height = 48 Align = alBottom @@ -342,8 +342,8 @@ object pnlFavorite: TPanel Left = 0 Top = 0 - Width = 656 - Height = 304 + Width = 654 + Height = 295 Align = alClient BevelOuter = bvNone BorderWidth = 3 @@ -352,8 +352,8 @@ object sg_Favorite: TStringGrid Left = 3 Top = 3 - Width = 650 - Height = 298 + Width = 648 + Height = 289 Align = alClient ColCount = 1 DefaultColWidth = 100 @@ -374,8 +374,8 @@ end object pnlFavFooter: TPanel Left = 0 - Top = 304 - Width = 656 + Top = 295 + Width = 654 Height = 48 Align = alBottom BevelOuter = bvNone @@ -429,7 +429,7 @@ Left = 0 Top = 0 Width = 654 - Height = 296 + Height = 295 Align = alClient BevelOuter = bvNone BorderWidth = 3 @@ -439,7 +439,7 @@ Left = 3 Top = 3 Width = 648 - Height = 290 + Height = 289 Align = alClient ColCount = 2 DefaultColWidth = 150 @@ -457,7 +457,7 @@ end object pnlIdentifiersFooter: TPanel Left = 0 - Top = 296 + Top = 295 Width = 654 Height = 48 Align = alBottom @@ -534,29 +534,29 @@ object lblIdentifiers: TLabel Left = 16 Top = 88 - Width = 104 - Height = 13 + Width = 110 + Height = 15 Caption = 'Identifiers found: %d' end object lblUnitsParsed: TLabel Left = 16 Top = 40 - Width = 84 - Height = 13 + Width = 88 + Height = 15 Caption = 'Units parsed: %d' end object lblUnitsLoaded: TLabel Left = 16 Top = 64 - Width = 83 - Height = 13 + Width = 89 + Height = 15 Caption = 'Units loaded: %d' end object lblUnitsFound: TLabel Left = 16 Top = 16 - Width = 79 - Height = 13 + Width = 85 + Height = 15 Caption = 'Units found: %d' end end @@ -579,7 +579,7 @@ Left = 200 Top = 16 Width = 462 - Height = 22 + Height = 23 Anchors = [akLeft, akTop, akRight] TabOrder = 1 OnChange = edtUnitFilterChange @@ -600,8 +600,8 @@ object lblFilter: TLabel Left = 1 Top = 0 - Width = 24 - Height = 13 + Width = 26 + Height = 15 Caption = 'Filte&r' FocusControl = edtUnitFilter end @@ -610,7 +610,7 @@ Left = 0 Top = 16 Width = 421 - Height = 22 + Height = 23 Anchors = [akLeft, akTop, akRight] TabOrder = 2 Visible = False @@ -636,7 +636,7 @@ Left = 6 Top = 21 Width = 159 - Height = 363 + Height = 358 Align = alLeft BevelOuter = bvNone TabOrder = 2 @@ -645,7 +645,7 @@ Left = 0 Top = 0 Width = 159 - Height = 15 + Height = 18 Align = alTop BevelOuter = bvNone Caption = 'I&nterface' @@ -654,9 +654,9 @@ end object sg_Interface: TStringGrid Left = 0 - Top = 15 + Top = 18 Width = 159 - Height = 348 + Height = 340 Align = alClient ColCount = 1 DefaultColWidth = 100 @@ -678,7 +678,7 @@ Left = 165 Top = 21 Width = 158 - Height = 363 + Height = 358 Align = alClient BevelOuter = bvNone TabOrder = 3 @@ -685,9 +685,9 @@ OnResize = pcUsesResize object lblDprWarning: TLabel Left = 0 - Top = 288 + Top = 289 Width = 158 - Height = 75 + Height = 69 Align = alBottom AutoSize = False Caption = @@ -706,7 +706,7 @@ Left = 0 Top = 0 Width = 158 - Height = 15 + Height = 18 Align = alTop BevelOuter = bvNone Caption = 'I&mplementation' @@ -715,9 +715,9 @@ end object sg_Implementation: TStringGrid Left = 0 - Top = 15 + Top = 18 Width = 158 - Height = 273 + Height = 271 Align = alClient ColCount = 1 DefaultColWidth = 100 @@ -748,9 +748,9 @@ end object pnlUsesBottom: TPanel Left = 6 - Top = 384 + Top = 379 Width = 317 - Height = 44 + Height = 41 Align = alBottom BevelOuter = bvNone TabOrder = 1 @@ -757,7 +757,7 @@ OnResize = pnlUsesBottomResize object b_DeleteFromIntf: TButton Left = 0 - Top = 12 + Top = 9 Width = 73 Height = 25 Action = actIntfDelete @@ -767,7 +767,7 @@ end object b_DeleteFromImpl: TButton Left = 240 - Top = 12 + Top = 9 Width = 73 Height = 25 Action = actImplDelete @@ -777,7 +777,7 @@ end object b_MoveToImpl: TButton Left = 80 - Top = 12 + Top = 9 Width = 73 Height = 25 Action = actIntfMove @@ -787,7 +787,7 @@ end object b_MoveToIntf: TButton Left = 160 - Top = 12 + Top = 9 Width = 73 Height = 25 Action = actImplMove @@ -1185,7 +1185,7 @@ Left = 600 Top = 240 Bitmap = { - 494C010109003800080010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 494C010109003800040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 0000000000003600000028000000400000003000000001002000000000000030 000000000000000000000000000000000000D1B08E00C69E7400000000FF0000 00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000 Modified: branches/dark-mode/Source/UsesExpert/GX_UsesExpert.pas =================================================================== --- branches/dark-mode/Source/UsesExpert/GX_UsesExpert.pas 2024-08-10 16:21:38 UTC (rev 4292) +++ branches/dark-mode/Source/UsesExpert/GX_UsesExpert.pas 2024-08-14 20:53:09 UTC (rev 4293) @@ -13,11 +13,9 @@ uses Windows, SysUtils, Classes, Controls, Forms, Menus, ComCtrls, Buttons, ImgList, ImageList, - ExtCtrls, ActnList, Actions, Dialogs, StdCtrls, Grids, Types, -{$IFDEF GX_SUPPORTS_THEMING} - Themes, -{$ENDIF} - u_dzSpeedBitBtn, u_dzStopwatch, + ExtCtrls, ActnList, Actions, Dialogs, StdCtrls, Grids, Types, Themes, + GX_CheckButton, + u_dzStopwatch, u_dzDpiScaleUtils, GX_ConfigurationInfo, GX_Experts, GX_GenericUtils, GX_BaseForm, GX_UnitExportsParser, GX_UsesExpertOptions, GX_UnitExportList, @@ -315,7 +313,7 @@ FOldToNewUnitNameMap: TStringList; FCaption_lblFilter: string; FForceFocusToIdentifierFilter: Boolean; - FIdentifierMatchGrp: TdzSpeedBitBtnGroup; + FIdentifierMatchGrp: TGXCheckButtonGroup; FSelectedUnitLineNo: Integer; FSelectedUnitFn: string; FDefaultToInterfaceList: Boolean; @@ -371,6 +369,12 @@ procedure FinalizeForm; procedure SetSelectedFile(const _fn: string; _LineNo: Integer = -1); procedure UpdateDefaultButton; + + private + ckbIdentifierMatchStart : TGXCheckButton; + ckbIdentifierMatchAnywhere : TGXCheckButton; + ckbIdentifierMatchSort : TGXCheckButton; + protected FProjectUnits: TStringList; FCommonUnits: TStringList; @@ -900,34 +904,18 @@ pnlUnits.DoubleBuffered := True; pnlUses.DoubleBuffered := True; - FIdentifierMatchGrp := TdzSpeedBitBtnGroup.Create; -{$IFDEF SUPPORTS_THEMING} - // consider using a RadioGroup, or TSpeedButtons... - if IsThemingEnabled then - begin - FIdentifierMatchGrp.ColorText := ColorToRGB(GetThemedColor(clWindowText)); - // if FIdentifierMatchGrp.ColorText >= $800000 then - if IdeStyleIsDark then - begin - // dark background - FIdentifierMatchGrp.ColorRaised := GxOtaGetStyleColor(scButtonNormal, clBtnFace); - FIdentifierMatchGrp.ColorSunken := GxOtaGetStyleColor(scButtonPressed, clAppWorkSpace); - end - else begin - // light background - FIdentifierMatchGrp.ColorRaised := GetThemedColor(clBtnFace); - FIdentifierMatchGrp.ColorSunken := FIdentifierMatchGrp.ColorRaised + $00070707; // lighter - end; - end; -{$ENDIF} + FIdentifierMatchGrp := TGXCheckButtonGroup.Create(Self); FIdentifierMatchGrp.AllowAllUp := False; - FIdentifierMatchGrp.Add(b_IdentifierMatchStart, Ord(fieStartOnly)); - FIdentifierMatchGrp.Add(b_IdentifierMatchAnywhere, Ord(fieAnywhere)); - FIdentifierMatchGrp.Add(b_IdentifierMatchSort, Ord(fieStartFirst)); - // this only works if the order the buttons are added is the same as the order of the enums + ckbIdentifierMatchStart := FIdentifierMatchGrp.Add(b_IdentifierMatchStart, Ord(fieStartOnly)); + ckbIdentifierMatchAnywhere := FIdentifierMatchGrp.Add(b_IdentifierMatchAnywhere, Ord(fieAnywhere)); + ckbIdentifierMatchSort := FIdentifierMatchGrp.Add(b_IdentifierMatchSort, Ord(fieStartFirst)); FIdentifierMatchGrp.SetDown(Ord(FUsesExpert.FFilterIdentifiers)); FIdentifierMatchGrp.OnClick := sb_MatchWhereClick; + FIdentifierMatchGrp.AllowAllUp := False; + // this only works if the order the buttons are added is the same as the order of the enums + FIdentifierMatchGrp.SetDown(Ord(FUsesExpert.FFilterIdentifiers)); + chk_FastAdd.Checked := _UsesExpert.FFastAdd; FLeftRatio := pnlUses.Width / ClientWidth; @@ -1131,6 +1119,14 @@ FSearchPathUnits := TStringList.Create; sg_SearchPath.AssociatedList := FSearchPathUnits; + sg_Interface.Color := GetThemedColor(clWindow); + sg_Implementation.Color := GetThemedColor(clWindow); + sg_Project.Color := GetThemedColor(clWindow); + sg_Common.Color := GetThemedColor(clWindow); + sg_Favorite.Color := GetThemedColor(clWindow); + sg_SearchPath.Color := GetThemedColor(clWindow); + sg_Identifiers.Color := GetThemedColor(clWindow); + FIdentifiers := TUnitExportlist.Create(0); FAliases := TStringList.Create; FOldToNewUnitNameMap := TStringList.Create; @@ -1155,6 +1151,10 @@ SendDebug('Started SearchPath FindThread'); {$ENDIF D+} + if IsThemingEnabled + then pcUnits.Style := tsButtons + else pcUnits.Style := tsTabs; + pcUnits.ActivePage := tabSearchPath; GxOtaGetUnitAliases(FAliases); @@ -1675,16 +1675,18 @@ {$IFDEF GX_IDE_IS_HIDPI_AWARE} procedure TfmUsesManager.ApplyDpi(_NewDpi: Integer; _NewBounds: PRect); - procedure AdjustTop(_ctrl: TControl); + procedure AdjustTop(_Ctrl: TControl); begin // todo: Is this still necessary? - _Ctrl.Top := MulDiv(_Ctrl.Top, _NewDPI, FOldDPI); + if Assigned(_Ctrl) then + _Ctrl.Top := MulDiv(_Ctrl.Top, _NewDPI, FOldDPI); end; - procedure AdjustHeight(_ctrl: TControl); + procedure AdjustHeight(_Ctrl: TControl); begin // todo: Is this still necessary? - _Ctrl.Height := MulDiv(_Ctrl.Height, _NewDPI, FOldDPI); + if Assigned(_Ctrl) then + _Ctrl.Height := MulDiv(_Ctrl.Height, _NewDPI, FOldDPI); end; procedure ArrangeButtonsInGroup(const _Buttons: array of TWinControl; _grp: TGroupBox); @@ -1695,6 +1697,8 @@ begin Assert(Length(_Buttons) > 1); btn := _Buttons[0]; + if not Assigned(btn) then Exit; + Offset := _grp.ClientHeight - btn.Top - btn.Height; for i := 0 to Length(_Buttons) - 1 do AdjustTop(_Buttons[i]); @@ -2320,11 +2324,11 @@ TWinControl_Lock(pnlIdentifiers); Filter := Trim(edtIdentifierFilter.Text); + if not Assigned(FIdentifierMatchGrp) then Exit; if FIdentifierMatchGrp.TryGetSelected(Idx) then - FilterType := TFilterIdentifiersEnum(Idx) + FilterType := TFilterIdentifiersEnum(FIdentifierMatchGrp.GetButtonData(Idx)) else FilterType := FUsesExpert.FFilterIdentifiers; - FilterList := TList.Create; try MultiFilter := TStringList.Create; Added: branches/dark-mode/Source/Utils/GX_CheckButton.pas =================================================================== --- branches/dark-mode/Source/Utils/GX_CheckButton.pas (rev 0) +++ branches/dark-mode/Source/Utils/GX_CheckButton.pas 2024-08-14 20:53:09 UTC (rev 4293) @@ -0,0 +1,361 @@ +unit GX_CheckButton; + +interface + +uses + Classes, + Controls, + StdCtrls, + Themes; + +type + TGXCheckButton = class(TCustomCheckBox) + private + FSavedOnClick: TNotifyEvent; + FData: Pointer; + class constructor Create; + class destructor Destroy; + function GetDownState: Boolean; + procedure SetDownState(const Value: Boolean); + protected + procedure CreateParams(var Params: TCreateParams); override; + public + property Caption; + property Data: Pointer read FData write FData; + property Down: Boolean read GetDownState write SetDownState; + property SavedOnClick: TNotifyEvent read FSavedOnClick write FSavedOnClick; + constructor Clone(var AControl); + end; + + TGXCheckButtonGroup = class(TComponent) + private + FButtonList : TList; + FAllowAllUp : Boolean; + FOnClick : TNotifyEvent; + protected + procedure AnyButtonClicked(Sender: TObject); + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + public + property OnClick: TNotifyEvent read FOnClick write FOnClick; + property AllowAllUp: Boolean read FAllowAllUp write FAllowAllUp; + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function Add(var AControl): TGXCheckButton; overload; + function Add(var AControl; AData: Integer): TGXCheckButton; overload; + function Add(var AControl; AData: Pointer): TGXCheckButton; overload; + function GetButtonData(ndx: Integer): Pointer; + function IsDown(ndx: Integer): Boolean; overload; + function IsDown(ABtn: TGXCheckButton): Boolean; overload; + function TryGetSelected(var Index: Integer): Boolean; + procedure SetButtonState(ndx: Integer; ADown: Boolean); overload; + procedure SetButtonState(ABtn: TGXCheckButton; ADown: Boolean); overload; + procedure SetDown(AData: Integer); + end; + +implementation + +uses + Types, + Windows, + SysUtils, + Graphics; + +type + TGXCheckButtonStyleHook = class(TButtonStyleHook) + protected + procedure DrawButton(ACanvas: TCanvas; AMouseInControl: Boolean); override; + end; + +{ TGXCheckButtonStyleHook } + +procedure TGXCheckButtonStyleHook.DrawButton(ACanvas: TCanvas; AMouseInControl: Boolean); +var + LStyle : TCustomStyleServices; + Details : TThemedElementDetails; + LControl: TGXCheckButton; + R : TRect; +begin + LStyle := StyleServices; + if not LStyle.Available then + begin + inherited; + Exit; + end; + + if Control is TGXCheckButton then + begin + LControl := TGXCheckButton(Control); + if LControl.Checked + then Details := LStyle.GetElementDetails(tbPushButtonPressed) + else Details := LStyle.GetElementDetails(tbPushButtonNormal); + + R := LControl.ClientRect; + LStyle.DrawElement(ACanvas.Handle, Details, R, nil); + LStyle.DrawText(ACanvas.Handle, Details, LControl.Caption, R, [tfCenter, tfVerticalCenter]); + if Focused then + begin + R.Inflate(-2, -2); + DrawFocusRect(ACanvas.Handle, R); + end; + end; +end; + +{ TGXCheckButton } + +type + TWinControlAccess = class(TWinControl); + +class constructor TGXCheckButton.Create; +begin + TCustomStyleEngine.UnRegisterStyleHook(TGXCheckButton, TCheckBoxStyleHook); + TCustomStyleEngine.RegisterStyleHook(TGXCheckButton, TGXCheckButtonStyleHook); +end; + +class destructor TGXCheckButton.Destroy; +begin + TCustomStyleEngine.UnRegisterStyleHook(TGXCheckButton, TGXCheckButtonStyleHook); +end; + +constructor TGXCheckButton.Clone(var AControl); +var + ASource: TWinControl; +begin + if not (TObject(Pointer(AControl)) is TWinControl) then + raise EComponentError.Create('Invalid source control'); + + FSavedOnClick := nil; + ASource := TWinControl(AControl); + + Create(ASource.Owner); + Parent := ASource.Parent; + BoundsRect := ASource.BoundsRect; + Anchors := ASource.Anchors; + Margins := ASource.Margins; + AlignWithMargins := ASource.AlignWithMargins; + Caption := TWinControlAccess(ASource).Caption; + Enabled := ASource.Enabled; + Visible := ASource.Visible; + TabStop := ASource.TabStop; + TabOrder := ASource.TabOrder; + Name := ASource.Name + '_GX'; + OnClick := TWinControlAccess(ASource).OnClick; + + FreeAndNil(ASource); + Pointer(AControl) := nil; +end; + +function TGXCheckButton.GetDownState: Boolean; +begin + Result := Checked; +end; + +procedure TGXCheckButton.SetDownState(const Value: Boolean); +var + SavedClicksDisabled : Boolean; +begin + SavedClicksDisabled := ClicksDisabled; + ClicksDisabled := True; + + SetChecked(Value); + + ClicksDisabled := SavedClicksDisabled; +end; + +procedure TGXCheckButton.CreateParams(var Params: TCreateParams); +// Make the checkbox look like a button. +begin + inherited; + Params.Style := Params.Style + BS_PUSHLIKE; +end; + +{ TGXCheckButtonGroup } + +procedure TGXCheckButtonGroup.AnyButtonClicked(Sender: TObject); +var + AButton : TGXCheckButton; + LButton : TGXCheckButton; + i : Integer; +begin + if Sender is TGXCheckButton then + begin + AButton := TGXCheckButton(Sender); + + // set all other button to "up" + for i := 0 to FButtonList.Count-1 do + begin + LButton := TGXCheckButton(FButtonList.Items[i]); + if LButton <> AButton then + begin + LButton.Down := False; + end; + end; + if (not AButton.Down) and (not FAllowAllUp) then + begin + AButton.Down := True; + end; + + if AButton.Down then + begin + if Assigned(AButton.FSavedOnClick) then + AButton.FSavedOnClick(AButton) + else + if Assigned(FOnClick) then + FOnClick(AButton); + end; + end; // if Sender is TGXCheckButton +end; + +constructor TGXCheckButtonGroup.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FButtonList := TList.Create; + FAllowAllUp := True; +end; + +destructor TGXCheckButtonGroup.Destroy; +begin + FButtonList.Free; + inherited; +end; + +function TGXCheckButtonGroup.GetButtonData(ndx: Integer): Pointer; +begin + Result := nil; + if ndx >= 0 then + Result := TGXCheckButton(FButtonList.Items[ndx]).Data; +end; + +function TGXCheckButtonGroup.IsDown(ndx: Integer): Boolean; +var + LButton : TGXCheckButton; +begin + LButton := TGXCheckButton(FButtonList[ndx]); + Result := LButton.Down; +end; + +function TGXCheckButtonGroup.IsDown(ABtn: TGXCheckButton): Boolean; +var + ndx : Integer; +begin + Result := False; + ndx := FButtonList.IndexOf(ABtn); + if ndx >= 0 then + Result := ABtn.Down; +end; + +procedure TGXCheckButtonGroup.Notification(AComponent: TComponent; Operation: TOperation); +var + ndx : Integer; +begin + if (AComponent is TGXCheckButton) and (Operation = opRemove) then + begin + ndx := FButtonList.IndexOf(AComponent); + if ndx >= 0 then + begin + FButtonList.Items[ndx] := nil; + FButtonList.Delete(ndx); + end; + end; + inherited; +end; + +procedure TGXCheckButtonGroup.SetButtonState(ndx: Integer; ADown: Boolean); +var + LButton : TGXCheckButton; + i : Integer; +begin + LButton := TGXCheckButton(FButtonList.Items[ndx]); + if Assigned(LButton) then + begin + if ADown then + begin + for i := 0 to FButtonList.Count-1 do + TGXCheckButton(FButtonList.Items[i]).Down := False; + TGXCheckButton(FButtonList.Items[ndx]).Down := True; + end + else begin + for i := 0 to FButtonList.Count-1 do + TGXCheckButton(FButtonList.Items[i]).Down := False; + if FAllowAllUp then + TGXCheckButton(FButtonList.Items[ndx]).Down := True + else + TGXCheckButton(FButtonList.Items[ndx]).Down := True; + end; + LButton.Down := ADown; + end; +end; + +procedure TGXCheckButtonGroup.SetButtonState(ABtn: TGXCheckButton; ADown: Boolean); +var + ndx : Integer; +begin + ndx := FButtonList.IndexOf(ABtn); + if ndx >= 0 then + SetButtonState(ndx, ADown); +end; + +procedure TGXCheckButtonGroup.SetDown(AData: Integer); +var + i : Integer; + LButton : TGXCheckButton; +begin + for i := 0 to FButtonList.Count-1 do + begin + LButton := TGXCheckButton(FButtonList.Items[i]); + if LButton.Data = Pointer(AData) then + LButton.Down := True + else + LButton.Down := False; + end; +end; + +function TGXCheckButtonGroup.TryGetSelected(var Index: Integer): Boolean; +var + i : Integer; + LButton : TGXCheckButton; +begin + Result := False; + for i := 0 to FButtonList.Count-1 do + begin + LButton := TGXCheckButton(FButtonList.Items[i]); + if LButton.Down then + begin + Index := i; + Result := True; + Break; + end; + end; +end { TryGetSelected }; + +function TGXCheckButtonGroup.Add(var AControl; AData: Pointer): TGXCheckButton; +var + ASource : TWinControl; + AButton : TGXCheckButton; + LOnClick: TNotifyEvent; +begin + if not (TObject(Pointer(AControl)) is TWinControl) then + raise EComponentError.Create('Invalid source control'); + + ASource := TWinControl(AControl); + LOnClick := TWinControlAccess(ASource).OnClick; + + AButton := TGXCheckButton.Clone(ASource); + AButton.Data := AData; + AButton.SavedOnClick := LOnClick; + AButton.OnClick := Self.AnyButtonClicked; + + FButtonList.Add(AButton); + Result := AButton; +end; + +function TGXCheckButtonGroup.Add(var AControl; AData: Integer): TGXCheckButton; +begin + Result := Add(AControl, Pointer(AData)); +end; + +function TGXCheckButtonGroup.Add(var AControl): TGXCheckButton; +begin + Result := Add(AControl, nil); +end; + +end. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |