diff --git a/components/ideintf/checklistboxeditordlg.pas b/components/ideintf/checklistboxeditordlg.pas index b80b64eafd..f9dd6cbea3 100644 --- a/components/ideintf/checklistboxeditordlg.pas +++ b/components/ideintf/checklistboxeditordlg.pas @@ -94,7 +94,7 @@ begin BtnPanel.CancelButton.Caption := oisCancel; BtnPanel.HelpButton.Caption := cActionListEditorHelpCategory; BtnPanel.CloseButton.Kind := bkCustom; - BtnPanel.CloseButton.LoadGlyphFromStock(idButtonYes); + BtnPanel.CloseButton.LoadGlyphFromResource(idButtonYes); BtnPanel.CloseButton.Caption := sccsTrEdtApply; BtnPanel.CloseButton.OnClick := @ApplyCheck; diff --git a/ide/buildlazdialog.pas b/ide/buildlazdialog.pas index 625b86e085..c074ee10ef 100644 --- a/ide/buildlazdialog.pas +++ b/ide/buildlazdialog.pas @@ -1051,9 +1051,7 @@ begin CompileAdvancedButton.Caption := lisLazBuildBuildMany; IDEImages.AssignImage(CompileAdvancedButton, 'menu_build_all'); SaveSettingsButton.Caption := lisSaveSettings; - SaveSettingsButton.LoadGlyphFromStock(idButtonSave); - if SaveSettingsButton.Glyph.Empty then - IDEImages.AssignImage(SaveSettingsButton, 'laz_save'); + IDEImages.AssignImage(SaveSettingsButton, 'laz_save'); CancelButton.Caption := lisCancel; HelpButton.Caption := lisMenuHelp; diff --git a/ide/desktopmanager.pas b/ide/desktopmanager.pas index 7419a80424..8f3750fcf1 100644 --- a/ide/desktopmanager.pas +++ b/ide/desktopmanager.pas @@ -393,9 +393,9 @@ begin ExportAction.Caption := lisExportSelected; ExportAllAction.Caption := lisExportAll; ImportAction.Hint := lisImport; - ExportBitBtn.LoadGlyphFromStock(idButtonSave); + IDEImages.AssignImage(ExportBitBtn, 'laz_save'); ExportBitBtn.Caption := lisExportSub; - ImportBitBtn.LoadGlyphFromStock(idButtonOpen); + IDEImages.AssignImage(ImportBitBtn, 'laz_open'); ImportBitBtn.Caption := lisImport; ButtonPanel1.HelpButton.TabOrder := 0; diff --git a/ide/diffdialog.pas b/ide/diffdialog.pas index 1ff74b96f9..566f8c2bc0 100644 --- a/ide/diffdialog.pas +++ b/ide/diffdialog.pas @@ -359,9 +359,7 @@ begin OpenInEditorButton.Caption:=lisDiffDlgOpenDiffInEditor; HelpButton.Caption:=lisMenuHelp; - OpenInEditorButton.LoadGlyphFromStock(idButtonOpen); - if OpenInEditorButton.Glyph.Empty then - IDEImages.AssignImage(OpenInEditorButton, 'laz_open'); + IDEImages.AssignImage(OpenInEditorButton, 'laz_open'); // dialogs dlgOpen.Title:=lisOpenExistingFile; diff --git a/ide/encloseifdef.pas b/ide/encloseifdef.pas index 8542cb625d..21bbc1b601 100644 --- a/ide/encloseifdef.pas +++ b/ide/encloseifdef.pas @@ -239,7 +239,7 @@ begin IDEImages.AssignImage(RemoveBtn, 'laz_delete'); ButtonPanel1.CloseButton.Caption := lisSave; ButtonPanel1.OKButton.Caption := lisOk; - //ButtonPanel1.CloseButton.LoadGlyphFromStock(idButtonSave); + //ButtonPanel1.CloseButton.LoadGlyphFromResource(idButtonSave); //if btnSave.Glyph.Empty then // btnSave.LoadGlyphFromResourceName(HInstance, 'laz_save'); try diff --git a/ide/frames/compiler_path_options.pas b/ide/frames/compiler_path_options.pas index ab3e961d10..88226b3eb7 100644 --- a/ide/frames/compiler_path_options.pas +++ b/ide/frames/compiler_path_options.pas @@ -642,7 +642,7 @@ begin btnCheck := CreateButton(lisCompTest); btnCheck.ModalResult := mrNone; btnCheck.OnClick := @DoCheck; - btnCheck.LoadGlyphFromStock(idButtonYes); + btnCheck.LoadGlyphFromResource(idButtonYes); ADialog.AddButtonSeparator; @@ -650,14 +650,12 @@ begin btnExport := CreateButton(lisExport); btnExport.OnClick := @DoExport; btnExport.Hint := dlgCOLoadSaveHint; - btnExport.LoadGlyphFromStock(idButtonSave); + IDEImages.AssignImage(btnExport, 'laz_save'); // Import btnLoadSave := CreateButton(lisImport); btnLoadSave.OnClick := @DoImport; btnLoadSave.Hint := dlgCOLoadSaveHint; - btnLoadSave.LoadGlyphFromStock(idButtonOpen); - if btnLoadSave.Glyph.Empty then - IDEImages.AssignImage(btnLoadSave, 'laz_save'); + IDEImages.AssignImage(btnLoadSave, 'laz_save'); ADialog.AddButtonSeparator; diff --git a/ide/frames/project_application_options.pas b/ide/frames/project_application_options.pas index 4a3de18026..d5cc386773 100644 --- a/ide/frames/project_application_options.pas +++ b/ide/frames/project_application_options.pas @@ -294,13 +294,10 @@ begin DefaultIconButton.Caption := dlgPODefaultIcon; SaveIconButton.Caption := dlgPOSaveIcon; ClearIconButton.Caption := dlgPOClearIcon; - LoadIconButton.LoadGlyphFromStock(idButtonOpen); - if LoadIconButton.Glyph.Empty then - IDEImages.AssignImage(LoadIconButton, 'laz_open'); + IDEImages.AssignImage(LoadIconButton, 'laz_open'); SaveIconButton.LoadGlyphFromStock(idButtonSave); IDEImages.AssignImage(DefaultIconButton, 'restore_default'); - if SaveIconButton.Glyph.Empty then - IDEImages.AssignImage(SaveIconButton, 'laz_save'); + IDEImages.AssignImage(SaveIconButton, 'laz_save'); IDEImages.AssignImage(ClearIconButton, 'menu_clean'); IconImage.KeepOriginXWhenClipped := True; IconImage.KeepOriginYWhenClipped := True; diff --git a/ide/imexportcompileropts.pas b/ide/imexportcompileropts.pas index 2b3ac70774..0f2704f664 100644 --- a/ide/imexportcompileropts.pas +++ b/ide/imexportcompileropts.pas @@ -291,9 +291,7 @@ begin with ButtonPanel1 do begin OKButton.Caption:=lisIECOLoadFromFile; - OKButton.LoadGlyphFromStock(idButtonOpen); - if OKButton.Glyph.Empty then - IDEImages.AssignImage(OKButton, 'laz_open'); + IDEImages.AssignImage(OKButton, 'laz_open'); OKButton.Enabled:=False; OKButton.OnClick:=@OpenButtonCLICK; end; @@ -312,9 +310,7 @@ begin ExportRadioGroup.Enabled:=False; with ButtonPanel1 do begin OKButton.Caption:=lisIECOSaveToFile; - OKButton.LoadGlyphFromStock(idButtonSave); - if OKButton.Glyph.Empty then - IDEImages.AssignImage(OKButton, 'laz_save'); + IDEImages.AssignImage(OKButton, 'laz_save'); OKButton.Enabled:=False; OKButton.OnClick:=@SaveButtonCLICK; end; diff --git a/lcl/buttons.pp b/lcl/buttons.pp index 2fdf90bfc8..8d8b1ff74d 100644 --- a/lcl/buttons.pp +++ b/lcl/buttons.pp @@ -56,6 +56,8 @@ type bsHot // button is under mouse ); + TButtonImage = idButtonOk..idButtonNoToAll; + { TNumGlyphs holds the number of glyphs in an image. If we change this the code in SetNumGlyphs for @link(TCustomSpeedButton) @@ -207,7 +209,8 @@ type procedure Click; override; procedure LoadGlyphFromResourceName(Instance: THandle; const AName: String); procedure LoadGlyphFromLazarusResource(const AName: String); - procedure LoadGlyphFromStock(idButton: Integer); + procedure LoadGlyphFromStock(idButton: Integer); // not DPI-aware, uses widgetset themed icons if available + procedure LoadGlyphFromResource(idButton: TButtonImage); // DPI-aware function CanShowGlyph(const AWithShowMode: Boolean = False): Boolean; public property Caption stored IsCaptionStored; @@ -511,7 +514,6 @@ type } type TGetDefaultBitBtnGlyph = function(Kind: TBitBtnKind; var Handled: Boolean): TBitmap; - TButtonImage = idButtonOk..idButtonNoToAll; var GetDefaultBitBtnGlyph: TGetDefaultBitBtnGlyph = nil; diff --git a/lcl/include/bitbtn.inc b/lcl/include/bitbtn.inc index a8c3aac53f..fb439fdf9c 100644 --- a/lcl/include/bitbtn.inc +++ b/lcl/include/bitbtn.inc @@ -77,6 +77,11 @@ begin Buttons.LoadGlyphFromLazarusResource(FButtonGlyph, AName); end; +procedure TCustomBitBtn.LoadGlyphFromResource(idButton: TButtonImage); +begin + Buttons.LoadGlyphFromResource(FButtonGlyph, idButton); +end; + procedure TCustomBitBtn.LoadGlyphFromStock(idButton: Integer); begin Buttons.LoadGlyphFromStock(FButtonGlyph, idButton);