{*******************************************************************} { } { Developer Express Visual Component Library } { ExpressBars customizing form } { } { Copyright (c) 1998-2007 Developer Express Inc. } { ALL RIGHTS RESERVED } { } { The entire contents of this file is protected by U.S. and } { International Copyright Laws. Unauthorized reproduction, } { reverse-engineering, and distribution of all or any portion of } { the code contained in this file is strictly prohibited and may } { result in severe civil and criminal penalties and will be } { prosecuted to the maximum extent possible under the law. } { } { RESTRICTIONS } { } { THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES } { (DCU, OBJ, DLL, ETC.) ARE CONFIDENTIAL AND PROPRIETARY TRADE } { SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS } { LICENSED TO DISTRIBUTE THE EXPRESSBARS AND ALL ACCOMPANYING VCL } { CONTROLS AS PART OF AN EXECUTABLE PROGRAM ONLY. } { } { THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED } { FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE } { COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE } { AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT } { AND PERMISSION FROM DEVELOPER EXPRESS INC. } { } { CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON } { ADDITIONAL RESTRICTIONS. } { } {*******************************************************************} unit dxBarCustForm; {$I cxVer.inc} interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls, Menus, Buttons, cxClasses, dxBar, ActnList, ToolWin, ImgList, Contnrs; type TdxBarCustomizingFormPainter = class protected class procedure DrawCaption(ACanvas: TCanvas; var AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean); virtual; class procedure DrawEditEdge(ACanvas: TCanvas; var AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean); virtual; class procedure DrawEditContent(ACanvas: TCanvas; AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected, ADrawArrowButton: Boolean); virtual; class procedure InternalDrawCaption(ACanvas: TCanvas; var ATextRect: TRect; const AText: string; AItem: TdxCustomBarEdit; ASelected: Boolean); virtual; class procedure InternalDrawEditContent(ACanvas: TCanvas; AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean); virtual; class procedure DrawSubItemArrow(ACanvas: TCanvas; X, Y: Integer; ASelected: Boolean); virtual; public class function BrushColors(Selected: Boolean; AItem: TdxBarItem): TColor; virtual; class procedure DrawButtonOrSubItem(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem; ACaption: string; Selected: Boolean); virtual; class procedure DrawComboBoxButton(ACanvas: TCanvas; AItem: TdxBarItem; ARect: TRect; ASelected: Boolean); virtual; class procedure DrawEdit(ACanvas: TCanvas; ARect: TRect; AItem: TdxCustomBarEdit; Selected, ADrawArrowButton: Boolean); virtual; class procedure DrawFocusedRect(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem); virtual; class function FontColors(Selected: Boolean): TColor; virtual; class function GetButtonColor(AItem: TdxBarItem; ASelected: Boolean): Integer; virtual; class function GetComboBoxButtonWidth: Integer; virtual; end; TdxBarCustomizingFormPainterClass = class of TdxBarCustomizingFormPainter; TdxBarCustomizingFormStandardPainter = class(TdxBarCustomizingFormPainter) public class procedure DrawFocusedRect(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem); override; end; TdxBarCustomizingFormFlatPainter = class(TdxBarCustomizingFormPainter) protected class procedure DrawEditEdge(ACanvas: TCanvas; var AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean); override; class procedure InternalDrawCaption(ACanvas: TCanvas; var ATextRect: TRect; const AText: string; AItem: TdxCustomBarEdit; ASelected: Boolean); override; public class function BrushColors(Selected: Boolean; AItem: TdxBarItem): TColor; override; class procedure DrawButtonOrSubItem(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem; ACaption: string; Selected: Boolean); override; class procedure DrawComboBoxButton(ACanvas: TCanvas; AItem: TdxBarItem; ARect: TRect; ASelected: Boolean); override; class procedure DrawFocusedRect(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem); override; class function FontColors(Selected: Boolean): TColor; override; end; TdxBarCustomizingFormOffice11Painter = class(TdxBarCustomizingFormFlatPainter) protected class procedure DrawEditEdge(ACanvas: TCanvas; var AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean); override; class procedure InternalDrawCaption(ACanvas: TCanvas; var ATextRect: TRect; const AText: string; AItem: TdxCustomBarEdit; ASelected: Boolean); override; public class function BrushColors(Selected: Boolean; AItem: TdxBarItem): TColor; override; class procedure DrawButtonOrSubItem(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem; ACaption: string; Selected: Boolean); override; class procedure DrawComboBoxButton(ACanvas: TCanvas; AItem: TdxBarItem; ARect: TRect; ASelected: Boolean); override; class function FontColors(Selected: Boolean): TColor; override; class function GetButtonColor(AItem: TdxBarItem; ASelected: Boolean): Integer; override; end; TdxBarCustomizingFormXPPainter = class(TdxBarCustomizingFormPainter) class procedure DrawEditEdge(ACanvas: TCanvas; var AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean); override; class procedure InternalDrawEditContent(ACanvas: TCanvas; AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean); override; public class procedure DrawButtonOrSubItem(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem; ACaption: string; Selected: Boolean); override; class procedure DrawComboBoxButton(ACanvas: TCanvas; AItem: TdxBarItem; ARect: TRect; ASelected: Boolean); override; class procedure DrawFocusedRect(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem); override; class function GetComboBoxButtonWidth: Integer; override; end; TdxBarRunTimeSelectionController = class(TInterfacedObject, IdxBarDesigner) private FSelectionList: TdxComponentList; FOnSelectionChanged: TNotifyEvent; procedure AddSelection(AComponent: TComponent); procedure SelectionListNotify(Sender: TObject; AComponent: TComponent; AAction: TListNotification); procedure SelectionListChanged(Sender: TObject; AComponent: TComponent; AAction: TcxComponentCollectionNotification); public constructor Create; destructor Destroy; override; // IdxBarDesigner function CanDeleteComponent(AComponent: TComponent): Boolean; procedure GetSelection(AList: TList); function GetSelectionStatus(AComponent: TPersistent): TdxBarSelectionStatus; function IsComponentSelected(AComponent: TPersistent): Boolean; procedure SelectComponent(AComponent: TPersistent; ASelectionOperation: TdxBarSelectionOperation = soExclusive); procedure SetSelection(AList: TList); procedure ShowDefaultEventHandler(AItem: TdxBarItem); function UniqueName(const BaseName: string): string; property OnSelectionChanged: TNotifyEvent read FOnSelectionChanged write FOnSelectionChanged; end; TdxBarPermissiveProc = function (Sender: TComponent): Boolean of object; TdxBarCustomizingForm = class(TForm) Panel1: TPanel; PageControl: TPageControl; tsToolbars: TTabSheet; tsItems: TTabSheet; BBarDelete: TButton; BBarNew: TButton; BBarRename: TButton; BClose: TButton; LabelToobars: TLabel; tsOptions: TTabSheet; Panel2: TPanel; Panel3: TPanel; Panel4: TPanel; Panel6: TPanel; Panel7: TPanel; lbCategories: TListBox; lbItems: TListBox; LabelCategories: TLabel; LabelCommands: TLabel; tsCommands: TTabSheet; LAllCommands: TListBox; CBShowCommandsWithShortCut: TCheckBox; Panel5: TPanel; Panel8: TPanel; Panel9: TPanel; DescriptionLabel: TLabel; LabelDescription: TLabel; Bevel1: TBevel; BarManager1: TdxBarManager; CategoriesPopupMenu: TdxBarPopupMenu; CategoriesAdd: TdxBarButton; CategoriesInsert: TdxBarButton; CategoriesRename: TdxBarButton; CategoriesDelete: TdxBarButton; CommandsAdd: TdxBarButton; CommandsDelete: TdxBarButton; CommandsClear: TdxBarButton; CommandsPopupMenu: TdxBarPopupMenu; CommandsSubMenuEditor: TdxBarButton; CommandsMoveUp: TdxBarButton; CommandsMoveDown: TdxBarButton; CategoriesVisible: TdxBarButton; CategoriesItemsVisible: TdxBarCombo; lbBarsList: TListBox; CategoriesPopupButtonPlace: TSpeedButton; CommandsPopupButtonPlace: TSpeedButton; BBarReset: TButton; StandardOptionsPanel: TPanel; LabelMenuAnimations: TLabel; ComboBoxMenuAnimations: TComboBox; CBHint1: TCheckBox; CBHint2: TCheckBox; CBLargeIcons: TCheckBox; EnhancedOptionsPanel: TPanel; Label1: TLabel; ComboBoxMenuAnimationsEx: TComboBox; CBHint1Ex: TCheckBox; CBHint2Ex: TCheckBox; CBLargeIconsEx: TCheckBox; Bevel2: TBevel; Label2: TLabel; Label3: TLabel; Bevel3: TBevel; CBMenusShowRecentItemsFirst: TCheckBox; CBShowFullMenusAfterDelay: TCheckBox; BResetUsageData: TButton; BHelp: TBitBtn; tsGroups: TTabSheet; gbGroups: TGroupBox; gpGroupItems: TGroupBox; lbGroups: TListBox; lbGroupItems: TListBox; alCustomize: TActionList; aNewToolBar: TAction; aRenameToolBar: TAction; aDeleteToolBar: TAction; aResetToolBar: TAction; aAddGroupItem: TAction; aDeleteGroupItem: TAction; tbGroups: TToolBar; btnAddGroup: TToolButton; btnDeleteGroup: TToolButton; ToolButton3: TToolButton; btnMoveUpGroup: TToolButton; btnMoveDownGroup: TToolButton; aAddGroup: TAction; aDeleteGroup: TAction; imgGroups: TImageList; aMoveUpGroup: TAction; aMoveDownGroup: TAction; aMoveUpGroupItem: TAction; aMoveDownGroupItem: TAction; tbGroupItems: TToolBar; btnAddGroupItem: TToolButton; btnDeleteGroupItem: TToolButton; ToolButton8: TToolButton; btnMoveUpGroupItem: TToolButton; btnMoveDownGroupItem: TToolButton; Bevel4: TBevel; aDeleteItem: TAction; aAddItem: TAction; aMoveUpItem: TAction; aMoveDownItem: TAction; aSubMenuEditor: TAction; aClearItemList: TAction; TabSheet1: TTabSheet; tvKeyTips: TTreeView; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); procedure FormHide(Sender: TObject); procedure lbBarsListClick(Sender: TObject); procedure lbBarsListMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure lbBarsListDblClick(Sender: TObject); procedure lbBarsListKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure lbBarsListDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); procedure BHelpClick(Sender: TObject); procedure BCloseClick(Sender: TObject); procedure lbCategoriesClick(Sender: TObject); procedure lbCategoriesKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure lbCategoriesMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure lbCategoriesDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); procedure lbCategoriesEndDrag(Sender, Target: TObject; X, Y: Integer); procedure CategoriesPopupMenuPopup(Sender: TObject); procedure CategoriesAddClick(Sender: TObject); procedure CategoriesInsertClick(Sender: TObject); procedure CategoriesRenameClick(Sender: TObject); procedure CategoriesItemsVisibleChange(Sender: TObject); procedure CategoriesVisibleClick(Sender: TObject); procedure CategoriesDeleteClick(Sender: TObject); procedure lbItemsClick(Sender: TObject); procedure lbItemsDblClick(Sender: TObject); procedure lbItemsKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure lbItemsMeasureItem(Control: TWinControl; Index: Integer; var Height: Integer); procedure lbItemsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure lbItemsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); procedure lbItemsMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure CommandsPopupMenuPopup(Sender: TObject); procedure CommandsAddClick(Sender: TObject); procedure CommandsDeleteClick(Sender: TObject); procedure CommandsClearClick(Sender: TObject); procedure CommandsMoveUpClick(Sender: TObject); procedure CommandsMoveDownClick(Sender: TObject); procedure CommandsSubMenuEditorClick(Sender: TObject); procedure CBMenusShowRecentItemsFirstClick(Sender: TObject); procedure CBShowFullMenusAfterDelayClick(Sender: TObject); procedure BResetUsageDataClick(Sender: TObject); procedure CBLargeIconsClick(Sender: TObject); procedure CBHint1Click(Sender: TObject); procedure CBHint1ExClick(Sender: TObject); procedure CBHint2Click(Sender: TObject); procedure ComboBoxMenuAnimationsClick(Sender: TObject); procedure LAllCommandsClick(Sender: TObject); procedure LAllCommandsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); procedure CBShowCommandsWithShortCutClick(Sender: TObject); procedure lbGroupsClick(Sender: TObject); procedure lbGroupsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); procedure lbGroupsKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure lbGroupsMeasureItem(Control: TWinControl; Index: Integer; var Height: Integer); procedure lbGroupItemsClick(Sender: TObject); procedure lbGroupItemsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); procedure lbGroupItemsKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure aNewToolBarExecute(Sender: TObject); procedure aRenameToolBarExecute(Sender: TObject); procedure aDeleteToolBarExecute(Sender: TObject); procedure aResetToolBarExecute(Sender: TObject); procedure aAddGroupItemExecute(Sender: TObject); procedure aDeleteGroupItemExecute(Sender: TObject); procedure aAddGroupExecute(Sender: TObject); procedure aDeleteGroupExecute(Sender: TObject); procedure aMoveGroupExecute(Sender: TObject); procedure aMoveGroupItemExecute(Sender: TObject); procedure aMoveItemExecute(Sender: TObject); procedure aAddItemExecute(Sender: TObject); procedure aDeleteItemExecute(Sender: TObject); procedure aSubMenuEditorExecute(Sender: TObject); procedure aClearItemListExecute(Sender: TObject); private FDisabledWindows: TList; FSelectionList: TdxComponentList; FBarListBoxOldWndProc: TWndMethod; FBarsOldChangeEvent: TcxComponentCollectionChangeEvent; FCategoryListBoxOldWndProc: TWndMethod; FItemListBoxOldWndProc: TWndMethod; FItemsOldChangeEvent: TdxBarListChangeEvent; FCommandListBoxOldWndProc: TWndMethod; FGroupListBoxOldWndProc: TWndMethod; FGroupsOldChangeEvent: TdxBarListChangeEvent; FGroupItemListBoxOldWndProc: TWndMethod; FSelectedGroupItems: TdxBarComponentList; FDraggingCategoryIndex: Integer; FAllCommandsNameWidth: Integer; FAllCommandsCaptionWidth: Integer; FAllCommandsShortCutWidth: Integer; FAlreadySynchronous: TListBox; //Common Tools procedure DeleteSelectedObjects(AListBox: TListBox; ADeleteProc: TNotifyEvent = nil; ASynchronizeDesigner: Boolean = True); procedure EnableWindows(AEnable: Boolean); function GetVisibleItemsCount(AListBox: TListBox): Integer; function GetExclusiveObject(AListBox: TListBox): TObject; function GetObjectFromListBox(AListBox: TListBox; AIndex: Integer): TObject; function GetNextSelectedObject(AListBox: TListBox): TObject; function GetPainterClass: TdxBarCustomizingFormPainterClass; function GetSelCount(AListBox: TListBox): Integer; procedure GetSelection(AListBox: TListBox; AList: TList); procedure MoveItems(AListBox: TListBox; ABarComponentList: TdxBarComponentList; ADirection: Integer); procedure SelectBarManager; procedure SetNewWindowProc(AControl: TControl; ANewWindowProc: TWndMethod; out AOldWindowProc: TWndMethod); procedure SetSelection(AListBox: TListBox; AList: TList); overload; procedure SetSelection(AListBox: TListBox; AObject: TObject); overload; procedure SynchronizeDesigner(ANewSelection: IdxBarSelectableItem); overload; procedure SynchronizeDesigner(AListBox: TListBox); overload; procedure SynchronizeListBox(AListBox: TListBox; AChangedObject: TObject = nil; AAction: TcxComponentCollectionNotification = ccnChanged); procedure SynchronizeListBoxes; procedure SynchronizeListBoxSelection(AListBox: TListBox); procedure UpdateCommonEvents(AListBox: TListBox; AAddAction, ADeleteAction, AMoveUpAction, AMoveDownAction: TAction; ADeletePermissiveProc: TdxBarPermissiveProc = nil); procedure UpdateTopIndex(AListBox: TListBox); //BarList procedure BarListToggleCheck(AIndex: Integer); procedure BarListBoxWndProc(var Message: TMessage); procedure BarsChange(Sender: TObject; AItem: TcxComponentCollectionItem; AAction: TcxComponentCollectionNotification); function CanDeleteBar(ABar: TComponent): Boolean; function GetBarList(Index: Integer): TdxBar; function GetSelectedBar: TdxBar; function IsBarPredefined(ABar: TdxBar): Boolean; //CategoryList function CanDeleteSelectedCategory: Boolean; function CanDeleteSelectedCategoryCommands: Boolean; procedure CategoryListBoxWndProc(var Message: TMessage); //ItemList function GetItemList(Index: Integer): TdxBarItem; function GetSelectedItem: TdxBarItem; procedure ItemListBoxWndProc(var Message: TMessage); procedure ItemsChange(Sender: TObject; AComponent: TComponent; AAction: TcxComponentCollectionNotification); procedure MoveItem(Delta: Integer); //CommandList procedure CommandListBoxWndProc(var Message: TMessage); function GetCommandList(Index: Integer): TdxBarItem; procedure RefreshAllCommandListBox; //GroupList function GetSelectedGroup: TdxBarGroup; procedure GroupListBoxWndProc(var Message: TMessage); procedure GroupsChange(Sender: TObject; AComponent: TComponent; AAction: TcxComponentCollectionNotification); procedure MoveGroup(ADirection: Integer); procedure RememberSelectedList; //GroupItemList procedure GroupItemListBoxWndProc(var Message: TMessage); procedure GroupStuctureChange; procedure DeleteGroupItem(AGroupItem: TObject); procedure MoveGroupItem(ADirection: Integer); procedure UpdateGroupItemEvents; procedure WMActivate(var Message: TMessage); message WM_ACTIVATE; procedure WMDestroy(var Message: TWMDestroy); message WM_DESTROY; procedure WMNCHitTest(var Message: TMessage); message WM_NCHITTEST; property BarList[Index: Integer]: TdxBar read GetBarList; property CommandList[Index: Integer]: TdxBarItem read GetCommandList; property ItemList[Index: Integer]: TdxBarItem read GetItemList; property SelectedBar: TdxBar read GetSelectedBar; property SelectedGroup: TdxBarGroup read GetSelectedGroup; property SelectedItem: TdxBarItem read GetSelectedItem; protected procedure CreateParams(var Params: TCreateParams); override; {$IFDEF DELPHI9} procedure DestroyWindowHandle; override; {$ENDIF} public BarManager: TdxBarManager; constructor CreateEx(ABarManager: TdxBarManager); destructor Destroy; override; procedure MouseWheelHandler(var Message: TMessage); override; procedure BarManagerStyleChanged; procedure DesignSelectionChanged(Sender: TObject); procedure SelectPage(APageIndex: Integer); procedure UpdateHelpButton; procedure UpdateOptions; procedure UpdateVisibility(const AWindowPos: TWindowPos); property PainterClass: TdxBarCustomizingFormPainterClass read GetPainterClass; end; procedure dxBarCustomizing(ABarManager: TdxBarManager; AShow: Boolean); function dxBarCustomizingForm: TdxBarCustomizingForm; function IsCustomization: Boolean; procedure PrepareCustomizationFormFont(AForm: TCustomForm; ABarManager: TdxBarManager); procedure HostBarManagerStyleChanged; procedure UpdateHelpButton; procedure UpdateBarManagerOptions; implementation {$R *.DFM} uses {$IFDEF DELPHI8} Types, {$ENDIF} dxBarNameEd, dxBarPopupMenuEd, dxBarItemEd, dxBarStrs, dxBarAddGroupItemsEd, TypInfo, dxUxTheme, dxThemeManager, dxThemeConsts, dxOffice11, cxContainer, cxControls, cxGraphics, Math, cxLookAndFeelPainters; const AllCommandsIndent = 5; AToolBarsPage = 0; ACommandsPage = 1; AAllCommandsPage = 3; AGroupsPage = 4; LB_SYNCHRONYZE = WM_USER + 1; LB_SYNCHRONYZESELECTION = WM_USER + 2; LB_UPDATEEVENTS = WM_USER + 3; type TCustomdxBarContainerItemAccess = class(TCustomdxBarContainerItem); TdxBarAccess = class(TdxBar); TdxBarGroupAccess = class(TdxBarGroup); TdxBarControlAccess = class(TdxBarControl); TdxBarItemAccess = class(TdxBarItem); TdxBarManagerAccess = class(TdxBarManager); TdxCustomBarEditAccess = class(TdxCustomBarEdit); { TCheckListBox } { procedures } var FdxBarCustomizingForm: TdxBarCustomizingForm; FCloseCustomizingFormFlag: Boolean; procedure dxBarCustomizing(ABarManager: TdxBarManager; AShow: Boolean); procedure InvalidateUncustomizableToolbars; var ABar: TdxBar; I, J: Integer; begin for I := 0 to dxBarManagerList.Count - 1 do if dxBarManagerList[I] <> ABarManager then for J := 0 to dxBarManagerList[I].Bars.Count - 1 do begin ABar := dxBarManagerList[I].Bars[J]; if ABar.Visible and (ABar.Control <> nil) and ABar.Control.HandleAllocated then begin TdxBarControlAccess(ABar.Control).UpdateDoubleBuffered; ABar.Control.Invalidate; SendMessage(ABar.Control.Handle, WM_NCPAINT, 1, 0); end; end; end; procedure DoShowCustomizingForm; begin if Assigned(ABarManager.OnShowCustomizingForm) then ABarManager.OnShowCustomizingForm(ABarManager); end; procedure DoHideCustomizingForm; begin if Assigned(ABarManager.OnHideCustomizingForm) then ABarManager.OnHideCustomizingForm(ABarManager); end; begin if AShow then begin if FdxBarCustomizingForm <> nil then Exit; TdxBarManagerAccess(ABarManager).InternalUnmerge(nil, True); DoShowCustomizingForm; InvalidateUncustomizableToolbars; FdxBarCustomizingForm := TdxBarCustomizingForm.CreateEx(ABarManager); FdxBarCustomizingForm.Show; end else begin if not FCloseCustomizingFormFlag then FreeAndNil(FdxBarCustomizingForm); dxBarSubMenuEditor.Free; DoHideCustomizingForm; InvalidateUncustomizableToolbars; TdxBarManagerAccess(ABarManager).RestoreMergeState; end; end; function dxBarCustomizingForm: TdxBarCustomizingForm; begin Result := FdxBarCustomizingForm; end; function IsCustomization: Boolean; begin Result := FdxBarCustomizingForm <> nil; end; procedure PrepareCustomizationFormFont(AForm: TCustomForm; ABarManager: TdxBarManager); begin AForm.Font.Name := ABarManager.Font.Name; AForm.Font.Charset := ABarManager.Font.Charset; end; procedure HostBarManagerStyleChanged; begin if FdxBarCustomizingForm <> nil then FdxBarCustomizingForm.BarManagerStyleChanged; end; procedure UpdateHelpButton; begin if FdxBarCustomizingForm <> nil then FdxBarCustomizingForm.UpdateHelpButton; end; procedure UpdateBarManagerOptions; begin if FdxBarCustomizingForm <> nil then FdxBarCustomizingForm.UpdateOptions; end; { TCommandsListBox } const dxBarGlyphSize = 16; dxBarButtonWidth = 23; dxBarButtonHeight = 22; dxBarComboBoxArrowWidth = 11; { TCheckableButton } type TCheckableButton = class(TGraphicControl) private FDown: Boolean; FDropDownMenu: TdxBarPopupMenu; LButtonDown: Boolean; procedure SetDown(Value: Boolean); procedure SetDropDownMenu(Value: TdxBarPopupMenu); procedure DropDownMenuCloseup(Sender: TObject); procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER; procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE; protected procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure Paint; override; public constructor Create(AOwner: TComponent); override; procedure AdjustWithControl(AControl: TControl); property Down: Boolean read FDown write SetDown; property DropDownMenu: TdxBarPopupMenu read FDropDownMenu write SetDropDownMenu; end; constructor TCheckableButton.Create(AOwner: TComponent); begin inherited; ControlStyle := ControlStyle - [csCaptureMouse]; end; procedure TCheckableButton.AdjustWithControl(AControl: TControl); var AAdjustment: Integer; begin AAdjustment := AControl.BoundsRect.Right + 5 - Left; SetBounds(Left + AAdjustment, Top, Width - AAdjustment, Height); end; procedure TCheckableButton.SetDown(Value: Boolean); begin if FDown <> Value then begin FDown := Value; Repaint; if FDown and (FDropDownMenu <> nil) then with ClientToScreen(Point(0, Height)) do FDropDownMenu.PopupEx(X, Y, 0, Height, True, nil); end; end; procedure TCheckableButton.SetDropDownMenu(Value: TdxBarPopupMenu); begin if FDropDownMenu <> Value then begin FDropDownMenu := Value; FDropDownMenu.OnCloseup := DropDownMenuCloseup; end; end; procedure TCheckableButton.DropDownMenuCloseup(Sender: TObject); var P: TPoint; begin if FDown then begin GetCursorPos(P); P := ScreenToClient(P); LButtonDown := LeftButtonPressed and PtInRect(ClientRect, P); Down := False; end; end; procedure TCheckableButton.CMMouseEnter(var Message: TMessage); begin inherited; Repaint; end; procedure TCheckableButton.CMMouseLeave(var Message: TMessage); begin inherited; Repaint; end; procedure TCheckableButton.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin inherited; if LButtonDown then LButtonDown := False else if Button = mbLeft then Down := True; end; procedure TCheckableButton.Paint; const Borders: array[Boolean] of Integer = (BDR_RAISEDINNER, BDR_SUNKENOUTER); var R: TRect; P: TPoint; begin with Canvas do begin R := ClientRect; GetCursorPos(P); P := ScreenToClient(P); if PtInRect(R, P) and GetParentForm(Self).Active or FDown then DrawEdge(Handle, R, Borders[FDown], BF_RECT); InflateRect(R, -1, -1); if FDown then OffsetRect(R, 1, 1); Brush.Style := bsClear; Font := Self.Font; Font.Color := clBtnText; cxDrawText(Handle, Caption, R, DT_CENTER or DT_NOCLIP or DT_SINGLELINE or DT_VCENTER); Brush.Style := bsSolid; end; end; { TdxBarCustomizingFormPainter } class function TdxBarCustomizingFormPainter.BrushColors(Selected: Boolean; AItem: TdxBarItem): TColor; begin if Selected then Result := clHighlight else Result := clBtnFace; end; class procedure TdxBarCustomizingFormPainter.DrawButtonOrSubItem(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem; ACaption: string; Selected: Boolean); var R: TRect; S: string; IsGlyph: Boolean; W, H: Integer; FullImageRect: TRect; begin R := ARect; with TdxBarItemAccess(AItem) do IsGlyph := not Glyph.Empty or CurImageIndexLinked; with ACanvas, R do begin Right := Left + dxBarButtonWidth; Brush.Color := BrushColors(not IsGlyph and Selected, AItem); FillRect(R); Pen.Color := Brush.Color; MoveTo(Right, Top); LineTo(Right, Bottom); if IsGlyph then begin if Selected then DrawEdge(Handle, R, BDR_RAISEDINNER, BF_RECT); if AItem.Glyph.Empty then with AItem.GetCurImages do begin W := Width; H := Height; end else with AItem.Glyph do begin W := Width; H := Height; end; with R do R := Bounds((Left + Right - W) div 2, (Top + Bottom - H) div 2, W, H); FullImageRect := R; TransparentDraw(Handle, Brush.Handle, FullImageRect, R, AItem.Glyph, AItem.GetCurImages, AItem.ImageIndex, AItem.BarManager.ImageListBkColor, True, False, False{Flat}, Selected, False, False, False{Shadow}, False{Faded}, AItem.BarManager.ImageOptions.UseLeftBottomPixelAsTransparent); end; Font.Color := FontColors(Selected); Brush.Color := BrushColors(Selected, AItem); R := ARect; if (AItem is TdxBarButton) and (TdxBarButton(AItem).ButtonStyle = bsDropDown) then Dec(R.Right, 4 + 4 + 5); Inc(Left, dxBarButtonWidth + 1); FillRect(R); Inc(Left, 2); S := ACaption; if (AItem is TCustomdxBarContainerItem) and TCustomdxBarContainerItemAccess(AItem).HideWhenRun then S := '(' + ACaption + ')'; cxDrawText(Handle, S, R, DT_NOCLIP or DT_NOPREFIX or DT_SINGLELINE or DT_LEFT or DT_VCENTER); if (AItem is TdxBarButton) and (TdxBarButton(AItem).ButtonStyle = bsDropDown) then begin R.Left := R.Right; R.Right := ARect.Right; if Selected then begin DrawEdge(Handle, R, BDR_RAISEDINNER, BF_RECT); InflateRect(R, -1, -1); end else begin Dec(R.Left); DrawEdge(Handle, R, EDGE_ETCHED, BF_LEFT); Inc(R.Left, 2); end; Brush.Color := BrushColors(False, AItem); FillRect(R); Font.Color := FontColors(False); DrawSubItemArrow(ACanvas, ARect.Right - (4 + 5), ARect.Top + (dxBarButtonHeight - 7) div 2, False); end else if (AItem is TCustomdxBarSubItem) and not (AItem is TCustomdxBarContainerItem) or (AItem is TCustomdxBarContainerItem) and not TCustomdxBarContainerItemAccess(AItem).HideWhenRun then DrawSubItemArrow(ACanvas, ARect.Right - (4 + 5), ARect.Top + (dxBarButtonHeight - 7) div 2, False); end; end; class procedure TdxBarCustomizingFormPainter.DrawComboBoxButton( ACanvas: TCanvas; AItem: TdxBarItem; ARect: TRect; ASelected: Boolean); begin with ACanvas do begin Inc(ARect.Left); if ASelected then begin DrawEdge(Handle, ARect, BDR_RAISEDINNER, BF_RECT); Pen.Color := BrushColors(False, AItem); end else begin Brush.Color := clBtnHighlight; FrameRect(ARect); Pen.Color := Brush.Color; end; MoveTo(ARect.Left - 1, ARect.Top); LineTo(ARect.Left - 1, ARect.Bottom); InflateRect(ARect, -1, -1); Brush.Color := BrushColors(False, AItem); FillRect(ARect); Pen.Color := clBtnText; InflateRect(ARect, 2, 0); DrawItemArrow(Handle, ARect, adDown, True, False, False{Flat}); end; end; class procedure TdxBarCustomizingFormPainter.DrawEdit(ACanvas: TCanvas; ARect: TRect; AItem: TdxCustomBarEdit; Selected, ADrawArrowButton: Boolean); begin DrawCaption(ACanvas, ARect, AItem, Selected); DrawEditEdge(ACanvas, ARect, AItem, Selected); DrawEditContent(ACanvas, ARect, AItem, Selected, ADrawArrowButton); end; class procedure TdxBarCustomizingFormPainter.DrawFocusedRect(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem); begin SetTextColor(ACanvas.Handle, ColorToRGB(FontColors(True))); SetBkColor(ACanvas.Handle, ColorToRGB(BrushColors(True, AItem))); Windows.DrawFocusRect(ACanvas.Handle, ARect); end; class function TdxBarCustomizingFormPainter.FontColors(Selected: Boolean): TColor; begin if Selected then Result := clHighlightText else Result := clBtnText; end; class function TdxBarCustomizingFormPainter.GetButtonColor( AItem: TdxBarItem; ASelected: Boolean): Integer; begin Result := clBtnFace; end; class function TdxBarCustomizingFormPainter.GetComboBoxButtonWidth: Integer; begin Result := dxBarComboBoxArrowWidth + 1; end; class procedure TdxBarCustomizingFormPainter.DrawCaption(ACanvas: TCanvas; var AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean); var ATextRect: TRect; AText: string; begin AText := GetTextOf(AItem.Caption); ATextRect := AItemRect; ATextRect.Right := ACanvas.TextWidth(AText); InternalDrawCaption(ACanvas, ATextRect, AText, AItem, ASelected); AItemRect.Left := ATextRect.Right; end; class procedure TdxBarCustomizingFormPainter.DrawEditEdge(ACanvas: TCanvas; var AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean); begin if ASelected then DrawEdge(ACanvas.Handle, AItemRect, BDR_SUNKENOUTER, BF_RECT) else ACanvas.FrameRect(AItemRect); InflateRect(AItemRect, -1, -1); ACanvas.FrameRect(AItemRect); InflateRect(AItemRect, -1, -1); end; class procedure TdxBarCustomizingFormPainter.DrawEditContent(ACanvas: TCanvas; AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected, ADrawArrowButton: Boolean); begin if ADrawArrowButton then begin Dec(AItemRect.Right, GetComboBoxButtonWidth); DrawComboBoxButton(ACanvas, AItem, Rect(AItemRect.Right, AItemRect.Top, AItemRect.Right + GetComboBoxButtonWidth, AItemRect.Bottom), ASelected); end; InternalDrawEditContent(ACanvas, AItemRect, AItem, ASelected); end; class procedure TdxBarCustomizingFormPainter.DrawSubItemArrow(ACanvas: TCanvas; X, Y: Integer; ASelected: Boolean); begin with ACanvas do begin if ASelected and IsHighContrastWhite then Pen.Color := clWhite else Pen.Color := Font.Color; Brush.Color := Pen.Color; Polygon([Point(X, Y), Point(X, Y + 6), Point(X + 3, Y + 3)]); end; end; class procedure TdxBarCustomizingFormPainter.InternalDrawCaption(ACanvas: TCanvas; var ATextRect: TRect; const AText: string; AItem: TdxCustomBarEdit; ASelected: Boolean); const ATextOffset = 2; var ARect: TRect; begin ARect := ATextRect; ACanvas.Brush.Color := BrushColors(ASelected, AItem); Inc(ARect.Right, ATextOffset + 1); ACanvas.FillRect(ARect); Inc(ARect.Left, ATextOffset); ACanvas.Font.Color := FontColors(ASelected); cxDrawText(ACanvas.Handle, AText, ARect, DT_NOCLIP or DT_NOPREFIX or DT_SINGLELINE or DT_LEFT or DT_VCENTER); ACanvas.Brush.Color := BrushColors(False, AItem); ARect.Left := ARect.Right; Inc(ARect.Right, 4); ACanvas.FillRect(ARect); ATextRect.Right := ARect.Right; end; class procedure TdxBarCustomizingFormPainter.InternalDrawEditContent(ACanvas: TCanvas; AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean); begin ACanvas.Font.Color := FontColors(False); TdxCustomBarEditAccess(AItem).DrawCustomizingImageContent(ACanvas, AItemRect, ASelected); end; { TdxBarCustomizingFormStandardPainter } class procedure TdxBarCustomizingFormStandardPainter.DrawFocusedRect(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem); begin InflateRect(ARect, -2, -2); inherited DrawFocusedRect(ACanvas, ARect, AItem); end; { TdxBarCustomizingFormFlatPainter } class function TdxBarCustomizingFormFlatPainter.BrushColors(Selected: Boolean; AItem: TdxBarItem): TColor; begin if Selected then Result := TdxBarManagerAccess(AItem.BarManager).FlatToolbarsSelColor else Result := clWindow; end; class procedure TdxBarCustomizingFormFlatPainter.DrawButtonOrSubItem(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem; ACaption: string; Selected: Boolean); var R: TRect; S: string; IsGlyph: Boolean; W, H: Integer; FullImageRect: TRect; begin R := ARect; with TdxBarItemAccess(AItem) do IsGlyph := not Glyph.Empty or CurImageIndexLinked; with ACanvas, R do begin Brush.Color := BrushColors(Selected, AItem); if Selected then begin FillRect(R); Right := Left + Bottom - Top; end else begin Inc(Left, Bottom - Top); FillRect(R); Right := Left; Left := ARect.Left; Brush.Color := clBtnFace; FillRect(R); end; if IsGlyph then begin if AItem.Glyph.Empty then with AItem.GetCurImages do begin W := Width; H := Height; end else with AItem.Glyph do begin W := Width; H := Height; end; with R do R := Bounds((Left + Right - W) div 2, (Top + Bottom - H) div 2, W, H); FullImageRect := R; InflateRect(FullImageRect, 1, 1); TransparentDraw(Handle, Brush.Handle, FullImageRect, R, AItem.Glyph, AItem.GetCurImages, AItem.ImageIndex, AItem.BarManager.ImageListBkColor, True, False, True{Flat}, Selected, False, False, True{Shadow}, False{Faded}, AItem.BarManager.ImageOptions.UseLeftBottomPixelAsTransparent); end; Font.Color := FontColors(Selected); Brush.Color := BrushColors(Selected, AItem); R := ARect; if (AItem is TdxBarButton) and (TdxBarButton(AItem).ButtonStyle = bsDropDown) then Dec(R.Right, 4 + 4 + 5); Left := Bottom - Top + 10; S := ACaption; if (AItem is TCustomdxBarContainerItem) and TCustomdxBarContainerItemAccess(AItem).HideWhenRun then S := '(' + ACaption + ')'; cxDrawText(Handle, S, R, DT_NOCLIP or DT_NOPREFIX or DT_SINGLELINE or DT_LEFT or DT_VCENTER); if (AItem is TdxBarButton) and (TdxBarButton(AItem).ButtonStyle = bsDropDown) then begin R.Left := R.Right; R.Right := ARect.Right; if Selected then FrameFlatSelRect(Handle, R) else Windows.FrameRect(Handle, R, GetSysColorBrush(COLOR_BTNSHADOW)); InflateRect(R, -1, -1); Brush.Color := BrushColors(Selected, AItem); FillRect(R); Font.Color := FontColors(False); DrawSubItemArrow(ACanvas, ARect.Right - (4 + 5), ARect.Top + (dxBarButtonHeight - 7) div 2, Selected); end else if (AItem is TCustomdxBarSubItem) and not (AItem is TCustomdxBarContainerItem) or (AItem is TCustomdxBarContainerItem) and not TCustomdxBarContainerItemAccess(AItem).HideWhenRun then DrawSubItemArrow(ACanvas, ARect.Right - (4 + 5), ARect.Top + (dxBarButtonHeight - 7) div 2, Selected); if Selected then FrameFlatSelRect(Handle, ARect); end; end; class procedure TdxBarCustomizingFormFlatPainter.DrawComboBoxButton( ACanvas: TCanvas; AItem: TdxBarItem; ARect: TRect; ASelected: Boolean); begin with ACanvas do begin Inc(ARect.Left); if ASelected then begin InflateRect(ARect, 1, 1); FrameFlatSelRect(Handle, ARect); end else begin Brush.Color := clBtnHighlight; FrameRect(ARect); Pen.Color := Brush.Color; end; if not ASelected then begin MoveTo(ARect.Left - 1, ARect.Top); LineTo(ARect.Left - 1, ARect.Bottom); end; InflateRect(ARect, -1, -1); if ASelected then Brush.Color := TdxBarManagerAccess(AItem.BarManager).FlatToolbarsSelColor else Brush.Color := BrushColors(False, AItem); FillRect(ARect); Pen.Color := clBtnText; if ASelected then InflateRect(ARect, -1, -1); InflateRect(ARect, 2, 0); DrawItemArrow(Handle, ARect, adDown, True, ASelected and IsHighContrastWhite, True{Flat}); end; end; class procedure TdxBarCustomizingFormFlatPainter.DrawFocusedRect(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem); begin // do nothing end; class function TdxBarCustomizingFormFlatPainter.FontColors(Selected: Boolean): TColor; begin Result := clBtnText; if Selected and IsHighContrastWhite then Result := clBtnFace; end; class procedure TdxBarCustomizingFormFlatPainter.DrawEditEdge(ACanvas: TCanvas; var AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean); begin ACanvas.Brush.Color := BrushColors(False, AItem); if ASelected then FrameFlatSelRect(ACanvas.Handle, AItemRect) else Windows.FrameRect(ACanvas.Handle, AItemRect, GetSysColorBrush(COLOR_BTNSHADOW)); InflateRect(AItemRect, -1, -1); end; class procedure TdxBarCustomizingFormFlatPainter.InternalDrawCaption(ACanvas: TCanvas; var ATextRect: TRect; const AText: string; AItem: TdxCustomBarEdit; ASelected: Boolean); const ATextOffset = 5; var ARect: TRect; begin ARect := ATextRect; ACanvas.Brush.Color := BrushColors(ASelected, AItem); Inc(ARect.Right, 1 + ATextOffset + 5); ACanvas.FillRect(ARect); if ASelected then begin Inc(ARect.Right); FrameFlatSelRect(ACanvas.Handle, ARect); Dec(ARect.Right); end; Inc(ARect.Left, ATextOffset); ACanvas.Font.Color := FontColors(ASelected); cxDrawText(ACanvas.Handle, AText, ARect, DT_NOCLIP or DT_NOPREFIX or DT_SINGLELINE or DT_LEFT or DT_VCENTER); ATextRect.Right := ARect.Right; end; { TdxBarCustomizingFormOffice11Painter } class function TdxBarCustomizingFormOffice11Painter.BrushColors( Selected: Boolean; AItem: TdxBarItem): TColor; begin if Selected then Result := dxOffice11ToolbarSelectedColor else Result := dxOffice11MenuColor; end; class procedure TdxBarCustomizingFormOffice11Painter.DrawButtonOrSubItem(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem; ACaption: string; Selected: Boolean); var R: TRect; S: string; IsGlyph: Boolean; W, H: Integer; FullImageRect: TRect; begin R := ARect; with TdxBarItemAccess(AItem) do IsGlyph := not Glyph.Empty or CurImageIndexLinked; with ACanvas, R do begin Brush.Color := BrushColors(Selected, AItem); if Selected then begin FillRect(R); Right := Left + Bottom - Top; end else begin Inc(Left, Bottom - Top); FillRect(R); Right := Left; Left := ARect.Left; FillTubeGradientRect(Handle, R, dxOffice11MenuIndentColor1, dxOffice11MenuIndentColor2, True); end; if IsGlyph then begin if AItem.Glyph.Empty then with AItem.GetCurImages do begin W := Width; H := Height; end else with AItem.Glyph do begin W := Width; H := Height; end; with R do R := Bounds((Left + Right - W) div 2, (Top + Bottom - H) div 2, W, H); FullImageRect := R; InflateRect(FullImageRect, 1, 1); TransparentDraw(Handle, 0, FullImageRect, R, AItem.Glyph, AItem.GetCurImages, AItem.ImageIndex, AItem.BarManager.ImageListBkColor, True, False, False{Flat}, Selected, False, False, False{Shadow}, False{Faded}, AItem.BarManager.ImageOptions.UseLeftBottomPixelAsTransparent); end; Font.Color := FontColors(Selected); Brush.Color := BrushColors(Selected, AItem); R := ARect; if (AItem is TdxBarButton) and (TdxBarButton(AItem).ButtonStyle = bsDropDown) then Dec(R.Right, 4 + 4 + 5); Left := Bottom - Top + 10; S := ACaption; if (AItem is TCustomdxBarContainerItem) and TCustomdxBarContainerItemAccess(AItem).HideWhenRun then S := '(' + ACaption + ')'; cxDrawText(Handle, S, R, DT_NOCLIP or DT_NOPREFIX or DT_SINGLELINE or DT_LEFT or DT_VCENTER); if (AItem is TdxBarButton) and (TdxBarButton(AItem).ButtonStyle = bsDropDown) then begin R.Left := R.Right; R.Right := ARect.Right; if Selected then Office11FrameSelectedRect(Handle, R) else Windows.FrameRect(Handle, R, dxOffice11BarSeparatorBrush1); InflateRect(R, -1, -1); Brush.Color := BrushColors(Selected, AItem); FillRect(R); Font.Color := FontColors(False); DrawSubItemArrow(ACanvas, ARect.Right - (4 + 5), ARect.Top + (dxBarButtonHeight - 7) div 2, Selected); end else if (AItem is TCustomdxBarSubItem) and not (AItem is TCustomdxBarContainerItem) or (AItem is TCustomdxBarContainerItem) and not TCustomdxBarContainerItemAccess(AItem).HideWhenRun then DrawSubItemArrow(ACanvas, ARect.Right - (4 + 5), ARect.Top + (dxBarButtonHeight - 7) div 2, Selected); if Selected then Office11FrameSelectedRect(Handle, ARect); end; end; class procedure TdxBarCustomizingFormOffice11Painter.DrawComboBoxButton( ACanvas: TCanvas; AItem: TdxBarItem; ARect: TRect; ASelected: Boolean); begin with ACanvas do begin Inc(ARect.Left); if ASelected then begin InflateRect(ARect, 1, 1); Office11FrameSelectedRect(Handle, ARect); end else begin Brush.Color := clWindow; FrameRect(ARect); Pen.Color := Brush.Color; end; if not ASelected then begin MoveTo(ARect.Left - 1, ARect.Top); LineTo(ARect.Left - 1, ARect.Bottom); end; InflateRect(ARect, -1, -1); if ASelected then Brush.Color := dxOffice11ToolbarSelectedColor else Brush.Color := dxOffice11OwnerControlDownedColor; FillRect(ARect); Pen.Color := clBtnText; if ASelected then InflateRect(ARect, -1, -1); InflateRect(ARect, 2, 0); DrawItemArrow(Handle, ARect, adDown, True, ASelected and IsHighContrastWhite, True{Flat}); end; end; class function TdxBarCustomizingFormOffice11Painter.FontColors( Selected: Boolean): TColor; begin Result := dxOffice11TextEnabledColor; if Selected and IsHighContrastWhite then Result := clBtnFace; end; class function TdxBarCustomizingFormOffice11Painter.GetButtonColor( AItem: TdxBarItem; ASelected: Boolean): Integer; begin Result := dxOffice11OwnerControlDownedColor; end; class procedure TdxBarCustomizingFormOffice11Painter.DrawEditEdge(ACanvas: TCanvas; var AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean); begin ACanvas.Brush.Color := BrushColors(False, AItem); if ASelected then Office11FrameSelectedRect(ACanvas.Handle, AItemRect) else Windows.FrameRect(ACanvas.Handle, AItemRect, dxOffice11OwnerControlDownedBrush); InflateRect(AItemRect, -1, -1); end; class procedure TdxBarCustomizingFormOffice11Painter.InternalDrawCaption(ACanvas: TCanvas; var ATextRect: TRect; const AText: string; AItem: TdxCustomBarEdit; ASelected: Boolean); const ATextOffset = 10; var AItemHeight: Integer; ARect, AIndentRect: TRect; begin ARect := ATextRect; AItemHeight := ARect.Bottom - ARect.Top; ACanvas.Brush.Color := BrushColors(ASelected, AItem); Inc(ARect.Right, 1 + 5 + ATextOffset + AItemHeight); if ASelected then begin ACanvas.FillRect(ARect); Inc(ARect.Right); Office11FrameSelectedRect(ACanvas.Handle, ARect); Dec(ARect.Right); end else begin AIndentRect := ARect; AIndentRect.Right := AIndentRect.Left + AItemHeight; FillTubeGradientRect(ACanvas.Handle, AIndentRect, dxOffice11MenuIndentColor1, dxOffice11MenuIndentColor2, True); Inc(ARect.Left, AItemHeight); ACanvas.FillRect(ARect); Dec(ARect.Left, AItemHeight); end; Inc(ARect.Left, ATextOffset + AItemHeight); ACanvas.Font.Color := FontColors(ASelected); cxDrawText(ACanvas.Handle, AText, ARect, DT_NOCLIP or DT_NOPREFIX or DT_SINGLELINE or DT_LEFT or DT_VCENTER); ATextRect.Right := ARect.Right; end; { TdxBarCustomizingFormXPPainter } class procedure TdxBarCustomizingFormXPPainter.DrawButtonOrSubItem(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem; ACaption: string; Selected: Boolean); var R: TRect; S: string; IsGlyph: Boolean; W, H: Integer; FullImageRect: TRect; ATheme: TdxTheme; begin R := ARect; with TdxBarItemAccess(AItem) do IsGlyph := not Glyph.Empty or CurImageIndexLinked; with ACanvas, R do begin Right := Left + dxBarButtonWidth; Brush.Color := BrushColors(not IsGlyph and Selected, AItem); FillRect(R); Pen.Color := Brush.Color; MoveTo(Right, Top); LineTo(Right, Bottom); if IsGlyph then begin if Selected and (AItem is TdxBarButton) then begin // xp ATheme := OpenTheme(totToolBar); DrawThemeBackground(ATheme, Handle, TP_BUTTON, TS_HOT, {$IFNDEF CLR}@{$ENDIF}R); // xp end end; if AItem.Glyph.Empty then with AItem.GetCurImages do begin W := Width; H := Height; end else with AItem.Glyph do begin W := Width; H := Height; end; with R do R := Bounds((Left + Right - W) div 2, (Top + Bottom - H) div 2, W, H); FullImageRect := R; TransparentDraw(Handle, 0, FullImageRect, R, AItem.Glyph, AItem.GetCurImages, AItem.ImageIndex, AItem.BarManager.ImageListBkColor, True, False, False{Flat}, Selected, False, False, False{Shadow}, False{Faded}, AItem.BarManager.ImageOptions.UseLeftBottomPixelAsTransparent); end; Font.Color := FontColors(Selected); Brush.Color := BrushColors(Selected, AItem); R := ARect; if (AItem is TdxBarButton) and (TdxBarButton(AItem).ButtonStyle = bsDropDown) then Dec(R.Right, 4 + 4 + 5); Inc(Left, dxBarButtonWidth + 1); FillRect(R); Inc(Left, 2); S := ACaption; if (AItem is TCustomdxBarContainerItem) and TCustomdxBarContainerItemAccess(AItem).HideWhenRun then S := '(' + ACaption + ')'; cxDrawText(Handle, S, R, DT_NOCLIP or DT_NOPREFIX or DT_SINGLELINE or DT_LEFT or DT_VCENTER); if (AItem is TdxBarButton) and (TdxBarButton(AItem).ButtonStyle = bsDropDown) then begin R.Left := R.Right; R.Right := ARect.Right; Brush.Color := BrushColors(False, AItem); FillRect(R); // xp ATheme := OpenTheme(totToolBar); DrawThemeBackground(ATheme, Handle, TP_BUTTON, TS_HOT, {$IFNDEF CLR}@{$ENDIF}R); // xp end Font.Color := FontColors(False); DrawSubItemArrow(ACanvas, ARect.Right - (4 + 5), ARect.Top + (dxBarButtonHeight - 7) div 2, False); end else if (AItem is TCustomdxBarSubItem) and not (AItem is TCustomdxBarContainerItem) or (AItem is TCustomdxBarContainerItem) and not TCustomdxBarContainerItemAccess(AItem).HideWhenRun then DrawSubItemArrow(ACanvas, ARect.Right - (4 + 5), ARect.Top + (dxBarButtonHeight - 7) div 2, False); end; end; class procedure TdxBarCustomizingFormXPPainter.DrawComboBoxButton( ACanvas: TCanvas; AItem: TdxBarItem; ARect: TRect; ASelected: Boolean); begin DrawThemeBackground(OpenTheme(totComboBox), ACanvas.Handle, CP_DROPDOWNBUTTON, CBXS_NORMAL, {$IFNDEF CLR}@{$ENDIF}ARect); end; class procedure TdxBarCustomizingFormXPPainter.DrawFocusedRect(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem); var IsGlyph: Boolean; begin // InflateRect(ARect, -1, -1); with TdxBarItemAccess(AItem) do IsGlyph := not (AItem is TdxBarEdit) and (not Glyph.Empty or CurImageIndexLinked); if IsGlyph then Inc(ARect.Left, dxBarButtonWidth + 1); inherited DrawFocusedRect(ACanvas, ARect, AItem); end; class function TdxBarCustomizingFormXPPainter.GetComboBoxButtonWidth: Integer; begin Result := dxBarComboBoxArrowWidth + 2; end; class procedure TdxBarCustomizingFormXPPainter.DrawEditEdge(ACanvas: TCanvas; var AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean); begin ACanvas.FrameRect(AItemRect); InflateRect(AItemRect, -1, -1); end; class procedure TdxBarCustomizingFormXPPainter.InternalDrawEditContent(ACanvas: TCanvas; AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean); var AClipRgn: HRGN; AClipRgnExists: Boolean; begin InflateRect(AItemRect, -1, -1); inherited InternalDrawEditContent(ACanvas, AItemRect, AItem, ASelected); SaveClipRgn(ACanvas.Handle, AClipRgn, AClipRgnExists); with AItemRect do ExcludeClipRect(ACanvas.Handle, Left, Top, Right, Bottom); InflateRect(AItemRect, 1, 1); DrawThemeBackground(OpenTheme(totEdit), ACanvas.Handle, EP_EDITTEXT, ETS_NORMAL, AItemRect); RestoreClipRgn(ACanvas.Handle, AClipRgn, AClipRgnExists); end; { TdxBarRuntimeSelectionController } constructor TdxBarRunTimeSelectionController.Create; begin inherited Create; FSelectionList := TdxComponentList.Create(False); FSelectionList.OnNotify := SelectionListNotify; FSelectionList.OnComponentListChanged := SelectionListChanged; end; destructor TdxBarRuntimeSelectionController.Destroy; begin FreeAndNil(FSelectionList); inherited; end; function TdxBarRunTimeSelectionController.CanDeleteComponent( AComponent: TComponent): Boolean; begin Result := True; end; procedure TdxBarRunTimeSelectionController.GetSelection(AList: TList); var I: Integer; begin for I := 0 to FSelectionList.Count - 1 do AList.Add(FSelectionList[I]); end; function TdxBarRunTimeSelectionController.GetSelectionStatus(AComponent: TPersistent): TdxBarSelectionStatus; begin if IsComponentSelected(AComponent) then Result := ssActiveSelected else Result := ssUnselected; end; function TdxBarRunTimeSelectionController.IsComponentSelected(AComponent: TPersistent): Boolean; begin Result := FSelectionList.IndexOf(TComponent(AComponent)) <> -1; end; procedure TdxBarRunTimeSelectionController.SelectComponent(AComponent: TPersistent; ASelectionOperation: TdxBarSelectionOperation = soExclusive); begin case ASelectionOperation of soAdd, soExclusive: AddSelection(TComponent(AComponent)); end; end; procedure TdxBarRunTimeSelectionController.SetSelection(AList: TList); var I: Integer; begin FSelectionList.BeginUpdate; try for I := 0 to AList.Count - 1 do AddSelection(AList[I]); finally FSelectionList.EndUpdate; end; end; procedure TdxBarRunTimeSelectionController.ShowDefaultEventHandler(AItem: TdxBarItem); begin // do nothing end; function TdxBarRunTimeSelectionController.UniqueName(const BaseName: string): string; begin Result := ''; end; procedure TdxBarRunTimeSelectionController.AddSelection(AComponent: TComponent); var I: Integer; ABaseClass: TComponentClass; begin if FSelectionList.IndexOf(AComponent) = -1 then begin if AComponent is TdxBar then ABaseClass := TdxBar else ABaseClass := TdxBarItem; for I := FSelectionList.Count - 1 downto 0 do if FSelectionList[I].InheritsFrom(ABaseClass) then FSelectionList.Delete(I); if AComponent <> nil then FSelectionList.Add(AComponent); end; end; procedure TdxBarRunTimeSelectionController.SelectionListNotify(Sender: TObject; AComponent: TComponent; AAction: TListNotification); var ASelectableItem: IdxBarSelectableItem; begin if Supports(AComponent, IdxBarSelectableItem, ASelectableItem) then ASelectableItem.SelectionChanged; end; procedure TdxBarRunTimeSelectionController.SelectionListChanged(Sender: TObject; AComponent: TComponent; AAction: TcxComponentCollectionNotification); begin if Assigned(OnSelectionChanged) then OnSelectionChanged(Self); end; { TdxBarCustomizingForm } constructor TdxBarCustomizingForm.CreateEx(ABarManager: TdxBarManager); procedure PrepareMenuAnimationsLabel(ALabel: TLabel; ComboBox: TComboBox); begin with ALabel do begin Caption := cxGetResourceString(@dxSBAR_MENUANIMATIONS); if Left + Width + 10 > ComboBox.Left then ComboBox.Left := Left + Width + 10; end; end; procedure PrepareMenuAnimationsComboBox(ComboBox: TComboBox); var W, I: Integer; begin with ComboBox, Items do begin Clear; Add(cxGetResourceString(@dxSBAR_MENUANIM1)); Add(cxGetResourceString(@dxSBAR_MENUANIM2)); Add(cxGetResourceString(@dxSBAR_MENUANIM3)); Add(cxGetResourceString(@dxSBAR_MENUANIM4)); Add(cxGetResourceString(@dxSBAR_MENUANIM5)); W := 0; for I := 0 to Count - 1 do W := Max(W, cxTextWidth(Font, Items[I])); Width := W + 54; end; end; {$IFDEF DELPHI7} procedure SetupBevelSize(ALabel: TLabel; ABevel: TBevel); begin with ABevel, BoundsRect do BoundsRect := Rect(ALabel.BoundsRect.Right, Top, Right, Bottom); end; {$ENDIF} procedure PrepareToolBarsSheet; begin tsToolbars.Caption := cxGetResourceString(@dxSBAR_TABSHEET1); SetNewWindowProc(lbBarsList, BarListBoxWndProc, FBarListBoxOldWndProc); lbBarsList.ItemHeight := Canvas.TextHeight('Zg') + 2; lbBarsList.MultiSelect := BarManager.Designing; BBarReset.Visible := not BarManager.Designing and TdxBarManagerAccess(BarManager).CanReset; aNewToolBar.Caption := cxGetResourceString(@dxSBAR_TNEW); aRenameToolBar.Caption := cxGetResourceString(@dxSBAR_TRENAME); aDeleteToolBar.Caption := cxGetResourceString(@dxSBAR_TDELETE); aResetToolBar.Caption := cxGetResourceString(@dxSBAR_TRESET); LabelToobars.FocusControl := lbBarsList; LabelToobars.Caption := cxGetResourceString(@dxSBAR_TOOLBARS); FBarsOldChangeEvent := BarManager.Bars.OnChange; BarManager.Bars.OnChange := BarsChange; end; procedure PrepareItemsSheet; begin tsItems.Caption := cxGetResourceString(@dxSBAR_TABSHEET2); SetNewWindowProc(lbCategories, CategoryListBoxWndProc, FCategoryListBoxOldWndProc); SetNewWindowProc(lbItems, ItemListBoxWndProc, FItemListBoxOldWndProc); lbItems.ItemHeight := dxBarButtonHeight; lbItems.ControlStyle := lbItems.ControlStyle + [csOpaque] - [csCaptureMouse]; lbItems.MultiSelect := BarManager.Designing; LabelCommands.FocusControl := lbItems; if BarManager.Designing then begin with TCheckableButton.Create(Self) do begin Caption := cxGetResourceString(@dxSBAR_MODIFY); BoundsRect := CategoriesPopupButtonPlace.BoundsRect; AdjustWithControl(LabelCategories); DropDownMenu := CategoriesPopupMenu; Parent := CategoriesPopupButtonPlace.Parent; end; with TCheckableButton.Create(Self) do begin Caption := cxGetResourceString(@dxSBAR_MODIFY); BoundsRect := CommandsPopupButtonPlace.BoundsRect; AdjustWithControl(LabelCommands); DropDownMenu := CommandsPopupMenu; Parent := CommandsPopupButtonPlace.Parent; end; end; CategoriesPopupButtonPlace.Free; CommandsPopupButtonPlace.Free; LabelCategories.Caption := cxGetResourceString(@dxSBAR_CATEGORIES); LabelCommands.Caption := cxGetResourceString(@dxSBAR_COMMANDS); LabelDescription.Caption := cxGetResourceString(@dxSBAR_DESCRIPTION); CategoriesAdd.Caption := cxGetResourceString(@dxSBAR_ADDEX); CategoriesInsert.Caption := cxGetResourceString(@dxSBAR_INSERTEX); CategoriesRename.Caption := cxGetResourceString(@dxSBAR_RENAMEEX); CategoriesVisible.Caption := cxGetResourceString(@dxSBAR_VISIBLE); CategoriesDelete.Caption := cxGetResourceString(@dxSBAR_DELETE); CommandsAdd.Caption := cxGetResourceString(@dxSBAR_ADDEX); CommandsDelete.Caption := cxGetResourceString(@dxSBAR_DELETE); CommandsClear.Caption := cxGetResourceString(@dxSBAR_CLEAR); CommandsMoveUp.Caption := cxGetResourceString(@dxSBAR_MOVEUP); CommandsMoveDown.Caption := cxGetResourceString(@dxSBAR_MOVEDOWN); CommandsSubMenuEditor.Caption := cxGetResourceString(@dxSBAR_SUBMENUEDITOR); FItemsOldChangeEvent := TdxBarManagerAccess(BarManager).ItemList.OnComponentListChanged; TdxBarManagerAccess(BarManager).ItemList.OnComponentListChanged := ItemsChange; end; procedure PrepareOptionsSheet; begin tsOptions.Caption := cxGetResourceString(@dxSBAR_TABSHEET3); if BarManager.GetPaintStyle = bmsStandard then begin CBLargeIcons.Caption := cxGetResourceString(@dxSBAR_LARGEICONS); CBHint1.Caption := cxGetResourceString(@dxSBAR_HINTOPT1); CBHint2.Caption := cxGetResourceString(@dxSBAR_HINTOPT2); PrepareMenuAnimationsLabel(LabelMenuAnimations, ComboBoxMenuAnimations); PrepareMenuAnimationsComboBox(ComboBoxMenuAnimations); end else begin Label3.Caption := cxGetResourceString(@dxSBAR_PERSMENUSANDTOOLBARS); CBMenusShowRecentItemsFirst.Caption := cxGetResourceString(@dxSBAR_MENUSSHOWRECENTITEMS); CBShowFullMenusAfterDelay.Caption := cxGetResourceString(@dxSBAR_SHOWFULLMENUSAFTERDELAY); with BResetUsageData do begin Caption := cxGetResourceString(@dxSBAR_RESETUSAGEDATA); Width := cxTextWidth(Font, GetTextOf(Caption)) + 17; end; Label2.Caption := cxGetResourceString(@dxSBAR_OTHEROPTIONS); CBLargeIconsEx.Caption := cxGetResourceString(@dxSBAR_LARGEICONS); CBHint1Ex.Caption := cxGetResourceString(@dxSBAR_HINTOPT1); CBHint2Ex.Caption := cxGetResourceString(@dxSBAR_HINTOPT2); PrepareMenuAnimationsLabel(Label1, ComboBoxMenuAnimationsEx); PrepareMenuAnimationsComboBox(ComboBoxMenuAnimationsEx); end; end; procedure PrepareCommandsSheet; begin tsCommands.TabVisible := BarManager.Designing; SetNewWindowProc(LAllCommands, CommandListBoxWndProc, FCommandListBoxOldWndProc); end; procedure PrepareGroupsSheet; begin tsGroups.TabVisible := BarManager.Designing; SetNewWindowProc(lbGroups, GroupListBoxWndProc, FGroupListBoxOldWndProc); SetNewWindowProc(lbGroupItems, GroupItemListBoxWndProc, FGroupItemListBoxOldWndProc); FGroupsOldChangeEvent := TdxBarManagerAccess(BarManager).GroupList.OnComponentListChanged; TdxBarManagerAccess(BarManager).GroupList.OnComponentListChanged := GroupsChange; end; procedure PrepareKeyTipsSheet; procedure GetKeyTipsTree(AContainer: IdxBarAccessibilityHelper; ANodes: TTreeNodes; AParentNode: TTreeNode); var AChild, AContainerHelper: TdxBarAccessibilityHelper; I: Integer; begin AContainerHelper := AContainer.GetBarHelper; if AContainerHelper.Selectable then AParentNode := ANodes.AddChild(AParentNode, AContainerHelper.OwnerObject.ClassName); for I := 0 to AContainerHelper.ChildCount - 1 do begin AChild := AContainerHelper.Childs[I]; GetKeyTipsTree(AChild, ANodes, AParentNode); end; end; var AKeyTipWindowsManager: IdxBarKeyTipWindowsManager; ARootAccessibleObject: IdxBarAccessibilityHelper; begin ARootAccessibleObject := GetRootAccessibleObject(BarManager.Owner.Handle); if (ARootAccessibleObject <> nil) and ARootAccessibleObject.AreKeyTipsSupported(AKeyTipWindowsManager) then begin GetKeyTipsTree(ARootAccessibleObject, tvKeyTips.Items, nil); end; end; procedure PrepareButtons; begin BResetUsageData.Enabled := not BarManager.Designing; with BClose do begin Caption := cxGetResourceString(@dxSBAR_CLOSE); Width := cxTextWidth(Font, GetTextOf(Caption)) + 49; Left := Parent.Width - Panel3.Width - Width; end; UpdateHelpButton; end; var ARunTimeSelectionController: TdxBarRunTimeSelectionController; begin BarManager := ABarManager; inherited Create(nil); {$IFDEF DELPHI9} PopupMode := pmAuto; {$ENDIF} PrepareCustomizationFormFont(Self, BarManager); BarManager1.Font := BarManager.Font; // Global if not BarManager.Designing then begin ARunTimeSelectionController := TdxBarRunTimeSelectionController.Create; ARunTimeSelectionController.OnSelectionChanged := DesignSelectionChanged; TdxBarManagerAccess(BarManager).FdxBarDesignHelper := ARunTimeSelectionController; if BarManager.Bars.Count > 0 then SynchronizeDesigner(BarManager.Bars[0]); end; FSelectedGroupItems := TdxBarComponentList.Create(False); Caption := cxGetResourceString(@dxSBAR_CAPTION); PrepareButtons; PrepareToolBarsSheet; PrepareItemsSheet; PrepareOptionsSheet; PrepareCommandsSheet; PrepareGroupsSheet; PrepareKeyTipsSheet; BarManagerStyleChanged; {$IFDEF DELPHI7} SetupBevelSize(LabelDescription, Bevel1); SetupBevelSize(Label3, Bevel3); SetupBevelSize(Label2, Bevel2); {$ENDIF} end; destructor TdxBarCustomizingForm.Destroy; begin FreeAndNil(FSelectedGroupItems); if not BarManager.Designing then TdxBarManagerAccess(BarManager).FdxBarDesignHelper := nil; inherited; //#DG FdxBarCustomizingForm := nil; //#DG if not (csDestroying in ABarManager.ComponentState) and ABarManager.Designing then //#DG dxBarDesigner.SelectComponent(ABarManager, ABarManager); end; procedure TdxBarCustomizingForm.MouseWheelHandler(var Message: TMessage); var P: TPoint; R: TRect; H: HWND; AControl: TWinControl; I, AScrollCode, AScrollLines: Integer; begin P := SmallPointToPoint(TWMMouseWheel(Message).Pos); H := WindowFromPoint(P); if H <> 0 then begin GetWindowRect(H, R); AControl := FindControl(H); if (AControl is TCustomListBox) and PtInRect(R, P) and not (ActiveControl is TCustomListBox) then begin if SmallInt(HIWORD(Message.wParam)) > 0 then AScrollCode := SB_LINEUP else AScrollCode := SB_LINEDOWN; AScrollLines := {$IFDEF DELPHI4}Mouse.WheelScrollLines{$ELSE}3{$ENDIF}; for I := 0 to AScrollLines - 1 do SendMessage(AControl.Handle, WM_VSCROLL, AScrollCode, 0); Exit; end; end; inherited MouseWheelHandler(Message); end; procedure TdxBarCustomizingForm.DeleteSelectedObjects(AListBox: TListBox; ADeleteProc: TNotifyEvent = nil; ASynchronizeDesigner: Boolean = True); var I: Integer; ASelectedObjects: TObjectList; ANextObject: TObject; begin ANextObject := GetNextSelectedObject(AListBox); ASelectedObjects := TObjectList.Create(False); try GetSelection(AListBox, ASelectedObjects); //#DG - it was attempt to resolve blinking SetSelection(AListBox, ANextObject); //#DG - to resolve blinking SetSelection(AListBox, TObject(nil)); AListBox.Items.BeginUpdate; try for I := ASelectedObjects.Count - 1 downto 0 do if not Assigned(ADeleteProc) then ASelectedObjects[I].Free else ADeleteProc(ASelectedObjects[I]); finally AListBox.Items.EndUpdate; end; SetSelection(AListBox, ANextObject); // must be after deleting, because deleting causes update of ListBox if ASynchronizeDesigner then SynchronizeDesigner(AListBox); finally ASelectedObjects.Free; TdxBarManagerAccess(BarManager).DesignerModified; end; end; procedure TdxBarCustomizingForm.EnableWindows(AEnable: Boolean); var I: Integer; ADisabledParent: TWinControl; begin if AEnable then begin for I := 0 to dxBarManagerList.Count - 1 do TdxBarManagerAccess(dxBarManagerList[I]).EnableFloatToolBars; cxContainer.EnableWindows(FDisabledWindows); FreeAndNil(FDisabledWindows); end else begin FDisabledWindows := TList.Create; for I := 0 to dxBarManagerList.Count - 1 do begin {#DG - because can close master form} if dxBarManagerList[I].Designing then //#DG ADisabledParent := dxBarManagerList[I].Owner {#DG - because can close master form in D7} ADisabledParent := dxBarManagerList[I].ParentForm else ADisabledParent := dxBarManagerList[I].MasterForm; if (ADisabledParent <> Self) and ADisabledParent.HandleAllocated then begin if dxBarManagerList[I] <> BarManager then TdxBarManagerAccess(dxBarManagerList[I]).DisableFloatToolBars; DisableWindow(FDisabledWindows, ADisabledParent.Handle); end; end; end; end; function TdxBarCustomizingForm.GetVisibleItemsCount(AListBox: TListBox): Integer; begin Result := AListBox.Height div AListBox.ItemHeight; end; function TdxBarCustomizingForm.GetExclusiveObject(AListBox: TListBox): TObject; var AIndex: Integer; begin if AListBox.MultiSelect then if AListBox.SelCount = 1 then SendMessage(AListBox.Handle, LB_GETSELITEMS, 1, Integer(@AIndex)) else AIndex := -1 else AIndex := AListBox.ItemIndex; Result := GetObjectFromListBox(AListBox, AIndex); end; function TdxBarCustomizingForm.GetObjectFromListBox(AListBox: TListBox; AIndex: Integer): TObject; begin if (0 <= AIndex) and (AIndex < AListBox.Items.Count) then Result := AListBox.Items.Objects[AIndex] else Result := nil; end; function TdxBarCustomizingForm.GetNextSelectedObject(AListBox: TListBox): TObject; var I, ASelectedIndex: Integer; begin ASelectedIndex := -1; for I := AListBox.ItemIndex + 1 to AListBox.Items.Count - 1 do if not AListBox.Selected[I] then begin ASelectedIndex := I; Break; end; if ASelectedIndex = -1 then for I := AListBox.ItemIndex - 1 downto 0 do if not AListBox.Selected[I] then begin ASelectedIndex := I; Break; end; Result := GetObjectFromListBox(AListBox, ASelectedIndex); end; function TdxBarCustomizingForm.GetPainterClass: TdxBarCustomizingFormPainterClass; begin if BarManager.PainterClass = TdxBarXPPainter then Result := TdxBarCustomizingFormXPPainter else if BarManager.PainterClass = TdxBarOffice11Painter then Result := TdxBarCustomizingFormOffice11Painter else if BarManager.PainterClass = TdxBarFlatPainter then Result := TdxBarCustomizingFormFlatPainter else Result := TdxBarCustomizingFormStandardPainter; end; function TdxBarCustomizingForm.GetSelCount(AListBox: TListBox): Integer; begin if AListBox.MultiSelect then Result := AListBox.SelCount else if AListBox.ItemIndex <> -1 then Result := 1 else Result := 0; end; procedure TdxBarCustomizingForm.GetSelection(AListBox: TListBox; AList: TList); var I: Integer; begin if AListBox <> nil then for I := 0 to AListBox.Items.Count - 1 do if AListBox.Selected[I] then AList.Add(AListBox.Items.Objects[I]); end; procedure TdxBarCustomizingForm.MoveItems(AListBox: TListBox; ABarComponentList: TdxBarComponentList; ADirection: Integer); const AMoveUp = -1; AMoveDown = 1; var I, J, K: Integer; ASelectedItems: TList; begin ASelectedItems := TList.Create; try GetSelection(AListBox, ASelectedItems); ABarComponentList.BeginUpdate; try K := 0; case ADirection of AMoveUp: for I := 0 to ASelectedItems.Count - 1 do begin J := ABarComponentList.IndexOf(ASelectedItems[I]); if I = 0 then begin K := J - 1; if K < 0 then K := 0; ABarComponentList.Move(J, K); end else ABarComponentList.Move(J, K + I); end; AMoveDown: for I := ASelectedItems.Count - 1 downto 0 do begin J := ABarComponentList.IndexOf(ASelectedItems[I]); if I = ASelectedItems.Count - 1 then begin K := J + 1; if K > ABarComponentList.Count - 1 then K := ABarComponentList.Count - 1; ABarComponentList.Move(J, K); Dec(K, ASelectedItems.Count - 1); end else ABarComponentList.Move(J, K + I); end; end; finally ABarComponentList.EndUpdate; end; finally ASelectedItems.Free; end; TdxBarManagerAccess(BarManager).DesignerModified; end; procedure TdxBarCustomizingForm.SelectBarManager; begin if not TdxBarManagerAccess(BarManager).IsDestroying then (BarManager as IdxBarDesigner).SelectComponent(BarManager); end; procedure TdxBarCustomizingForm.SetNewWindowProc(AControl: TControl; ANewWindowProc: TWndMethod; out AOldWindowProc: TWndMethod); begin AOldWindowProc := AControl.WindowProc; AControl.WindowProc := ANewWindowProc; end; procedure TdxBarCustomizingForm.SetSelection(AListBox: TListBox; AList: TList); var I, AIndex: Integer; begin AListBox.Items.BeginUpdate; try if AListBox.MultiSelect then for I := 0 to AListBox.Items.Count - 1 do AListBox.Selected[I] := AList.IndexOf(AListBox.Items.Objects[I]) <> -1 else begin AIndex := -1; for I := 0 to AListBox.Items.Count - 1 do if AList.IndexOf(AListBox.Items.Objects[I]) <> -1 then AIndex := I; AListBox.ItemIndex := AIndex; end; UpdateTopIndex(AListBox); finally AListBox.Items.EndUpdate; if not AListBox.MultiSelect then SendMessage(AListBox.Handle, WM_NCPAINT, 0, 0); end; end; procedure TdxBarCustomizingForm.SetSelection(AListBox: TListBox; AObject: TObject); var ASelectedObjects: TList; begin ASelectedObjects := TList.Create; try ASelectedObjects.Add(AObject); SetSelection(AListBox, ASelectedObjects); finally ASelectedObjects.Free; end; end; procedure TdxBarCustomizingForm.SynchronizeDesigner(ANewSelection: IdxBarSelectableItem); begin if ANewSelection <> nil then ANewSelection.SelectComponent else SelectBarManager; end; procedure TdxBarCustomizingForm.SynchronizeDesigner(AListBox: TListBox); var ASelectedObjects: TObjectList; begin FAlreadySynchronous := AListBox; try //#DG AListBox.Items.BeginUpdate; try ASelectedObjects := TObjectList.Create(False); try GetSelection(AListBox, ASelectedObjects); if ASelectedObjects.Count > 0 then (BarManager as IdxBarDesigner).SetSelection(ASelectedObjects) else SelectBarManager; finally ASelectedObjects.Free; end; finally //#DG AListBox.Items.EndUpdate; end; finally FAlreadySynchronous := nil; end; end; procedure TdxBarCustomizingForm.SynchronizeListBox(AListBox: TListBox; AChangedObject: TObject = nil; AAction: TcxComponentCollectionNotification = ccnChanged); var AObjectIndex, APrevTopIndex: Integer; AIsSelected: Boolean; begin if not TdxBarManagerAccess(BarManager).IsDestroying then begin AListBox.Items.BeginUpdate; try APrevTopIndex := AListBox.TopIndex; if (AAction = ccnChanged) and (AChangedObject <> nil) then begin AObjectIndex := AListBox.Items.IndexOfObject(AChangedObject); if AObjectIndex <> -1 then begin AIsSelected := AListBox.Selected[AObjectIndex]; SendMessage(AListBox.Handle, LB_SYNCHRONYZE, Integer(AChangedObject), AObjectIndex); if AListBox.MultiSelect then AListBox.Selected[AObjectIndex] := AIsSelected; end; SendMessage(AListBox.Handle, LB_UPDATEEVENTS, 0, 0); end else begin AListBox.Items.Clear; SendMessage(AListBox.Handle, LB_SYNCHRONYZE, 0, 0); SendMessage(AListBox.Handle, LB_SYNCHRONYZESELECTION, 0, 0); end; AListBox.TopIndex := APrevTopIndex; UpdateTopIndex(AListBox); finally AListBox.Items.EndUpdate; end; end; end; procedure TdxBarCustomizingForm.SynchronizeListBoxes; begin SynchronizeListBox(lbBarsList); SynchronizeListBox(lbCategories); SynchronizeListBox(lbItems); SynchronizeListBox(LAllCommands); SynchronizeListBox(lbGroups); end; procedure TdxBarCustomizingForm.SynchronizeListBoxSelection(AListBox: TListBox); var AList: TList; begin if FAlreadySynchronous <> AListBox then begin AList := TList.Create; try (BarManager as IdxBarDesigner).GetSelection(AList); SetSelection(AListBox, AList); finally AList.Free; end; end; SendMessage(AListBox.Handle, LB_UPDATEEVENTS, 0, 0); end; procedure TdxBarCustomizingForm.UpdateCommonEvents(AListBox: TListBox; AAddAction, ADeleteAction, AMoveUpAction, AMoveDownAction: TAction; ADeletePermissiveProc: TdxBarPermissiveProc = nil); var I: Integer; ASelectedObjects: TList; AMoveEnabled: Boolean; begin ASelectedObjects := TList.Create; try GetSelection(AListBox, ASelectedObjects); if AAddAction <> nil then AAddAction.Enabled := TdxBarManagerAccess(BarManager).CanAddComponents; if ADeleteAction <> nil then begin ADeleteAction.Enabled := GetSelCount(AListBox) > 0; for I := 0 to ASelectedObjects.Count - 1 do begin ADeleteAction.Enabled := ADeleteAction.Enabled and (not Assigned(ADeletePermissiveProc) and IdxBarDesigner(BarManager).CanDeleteComponent(ASelectedObjects[I]) or Assigned(ADeletePermissiveProc) and ADeletePermissiveProc(ASelectedObjects[I])); end; end; if AMoveUpAction <> nil then begin AMoveEnabled := False; for I := 0 to ASelectedObjects.Count - 1 do if AListBox.Items.IndexOfObject(ASelectedObjects[I]) <> I then begin AMoveEnabled := True; Break; end; AMoveUpAction.Enabled := AMoveEnabled; end; if AMoveDownAction <> nil then begin AMoveEnabled := False; for I := 0 to ASelectedObjects.Count - 1 do if AListBox.Items.IndexOfObject(ASelectedObjects[I]) <> AListBox.Items.Count - ASelectedObjects.Count + I then begin AMoveEnabled := True; Break; end; AMoveDownAction.Enabled := AMoveEnabled; end; finally ASelectedObjects.Free; end; end; procedure TdxBarCustomizingForm.UpdateTopIndex(AListBox: TListBox); function GetAnchorIndex: Integer; var I: Integer; begin Result := -1; for I := 0 to AListBox.Items.Count - 1 do if AListBox.Selected[I] then begin Result := I; Break; end; end; var AAnchorIndex: Integer; begin AAnchorIndex := GetAnchorIndex; if (AAnchorIndex <> -1) then if AAnchorIndex < AListBox.TopIndex then AListBox.TopIndex := AAnchorIndex else if AAnchorIndex > (AListBox.TopIndex + GetVisibleItemsCount(AListBox) - 1) then AListBox.TopIndex := AAnchorIndex - (GetVisibleItemsCount(AListBox) - 1); end; procedure TdxBarCustomizingForm.BarListToggleCheck(AIndex: Integer); begin if BarList[AIndex] <> nil then if TdxBarAccess(BarList[AIndex]).CanClose then BarList[AIndex].Visible := not BarList[AIndex].Visible else MessageBeep(MB_OK); end; procedure TdxBarCustomizingForm.BarListBoxWndProc(var Message: TMessage); procedure SynchronizeBarListBox; var I: Integer; ABar: TdxBar; begin ABar := TdxBar(Message.WParam); if ABar = nil then begin for I := 0 to BarManager.Bars.Count - 1 do if BarManager.Designing or not BarManager.Bars[I].Hidden then lbBarsList.Items.AddObject(BarManager.Bars[I].Caption, BarManager.Bars[I]) end else lbBarsList.Items[Message.LParam] := ABar.Caption; end; procedure UpdateToolBarsEvents; var ABar: TdxBar; begin ABar := SelectedBar; aRenameToolBar.Enabled := (ABar <> nil) and not IsBarPredefined(ABar); aResetToolBar.Enabled := (ABar <> nil) and TdxBarAccess(ABar).CanReset; UpdateCommonEvents(lbBarsList, aNewToolBar, aDeleteToolBar, nil, nil, CanDeleteBar); end; var {$IFDEF CLR} ADIS: TDrawItemStruct; {$ELSE} ADIS: PDrawItemStruct; {$ENDIF} begin case Message.Msg of LB_SYNCHRONYZE: SynchronizeBarListBox; LB_SYNCHRONYZESELECTION: SynchronizeListBoxSelection(lbBarsList); LB_UPDATEEVENTS: UpdateToolBarsEvents; WM_LBUTTONDBLCLK: if (LOWORD(Message.lParam) < lbBarsList.ItemHeight) then Message.Msg := WM_LBUTTONDOWN; CN_DRAWITEM: begin ADIS := TWMDrawItem(Message).DrawItemStruct; Inc(ADIS.rcItem.Left, lbBarsList.ItemHeight); {$IFDEF CLR} Message.DrawItemStruct := ADIS; {$ENDIF} end; end; FBarListBoxOldWndProc(Message); end; procedure TdxBarCustomizingForm.BarsChange(Sender: TObject; AItem: TcxComponentCollectionItem; AAction: TcxComponentCollectionNotification); begin if Assigned(FBarsOldChangeEvent) then FBarsOldChangeEvent(Sender, AItem, AAction); SynchronizeListBox(lbBarsList, AItem, AAction); end; function TdxBarCustomizingForm.CanDeleteBar(ABar: TComponent): Boolean; var ASelectableItem: IdxBarSelectableItem; begin ASelectableItem := GetSelectableItem(ABar); Result := (ASelectableItem <> nil) and ASelectableItem.CanDelete; end; function TdxBarCustomizingForm.GetBarList(Index: Integer): TdxBar; begin Result := TdxBar(GetObjectFromListBox(lbBarsList, Index)); end; function TdxBarCustomizingForm.GetSelectedBar: TdxBar; begin Result := TdxBar(GetExclusiveObject(lbBarsList)); end; function TdxBarCustomizingForm.IsBarPredefined(ABar: TdxBar): Boolean; begin Result := not BarManager.Designing and ABar.IsPredefined; end; function TdxBarCustomizingForm.CanDeleteSelectedCategory: Boolean; begin Result := (lbCategories.Items.Count > 1) and (lbCategories.ItemIndex > -1) and CanDeleteSelectedCategoryCommands; end; function TdxBarCustomizingForm.CanDeleteSelectedCategoryCommands: Boolean; var I: Integer; begin Result := True; for I := 0 to lbItems.Items.Count - 1 do begin Result := IdxBarDesigner(BarManager).CanDeleteComponent(ItemList[I]); if not Result then Break; end; end; procedure TdxBarCustomizingForm.CategoryListBoxWndProc(var Message: TMessage); procedure SynchronizeCategoryList; var I: Integer; begin for I := 0 to BarManager.Categories.Count - 1 do if BarManager.Designing or BarManager.CategoryVisible[I] then lbCategories.Items.Add(BarManager.Categories[I]); if lbCategories.Items.Count > 0 then lbCategories.ItemIndex := 0; end; begin case Message.Msg of LB_SYNCHRONYZE: SynchronizeCategoryList; end; FCategoryListBoxOldWndProc(Message); end; function TdxBarCustomizingForm.GetItemList(Index: Integer): TdxBarItem; begin Result := TdxBarItem(GetObjectFromListBox(lbItems, Index)); end; function TdxBarCustomizingForm.GetSelectedItem: TdxBarItem; begin Result := TdxBarItem(GetExclusiveObject(lbItems)); end; procedure TdxBarCustomizingForm.ItemListBoxWndProc(var Message: TMessage); procedure SynchronizeItemList; var I: Integer; AList: TList; AItem: TdxBarItem; begin if lbCategories.ItemIndex > -1 then begin AItem := TdxBarItem(Message.WParam); if AItem = nil then begin AList := TList.Create; try with TdxBarManagerAccess(BarManager) do GetItemsByCategory(GetCategoryRealIndex(lbCategories.ItemIndex), AList); for I := 0 to AList.Count - 1 do begin AItem := TdxBarItem(AList[I]); lbItems.Items.AddObject(AItem.Caption, AItem); end; finally AList.Free; end; end else lbItems.Items[Message.LParam] := AItem.Caption; end; end; procedure UpdateItemEvents; begin aSubMenuEditor.Enabled := (SelectedItem is TdxBarSubItem) or (SelectedItem is TdxBarContainerItem); aClearItemList.Enabled := (lbItems.Items.Count > 0) and CanDeleteSelectedCategoryCommands; UpdateCommonEvents(lbItems, aAddItem, aDeleteItem, aMoveUpItem, aMoveDownItem); if SelectedItem = nil then DescriptionLabel.Caption := '' else DescriptionLabel.Caption := SelectedItem.Description; end; procedure WMEraseBkGnd; var R: TRect; begin R := lbItems.ClientRect; if lbItems.Items.Count <> 0 then R.Top := lbItems.ItemRect(lbItems.Items.Count - 1).Bottom; FillRect(TWMEraseBkGnd(Message).DC, R, lbItems.Brush.Handle); Message.Result := 1; end; procedure WMMouseActivate; var P: TPoint; AItemIndex: Integer; begin FItemListBoxOldWndProc(Message); GetCursorPos(P); Windows.ScreenToClient(lbItems.Handle, P); AItemIndex := lbItems.ItemAtPos(P, True); if AItemIndex > -1 then lbItems.ItemIndex := AItemIndex; end; procedure WMSetFocus; begin FItemListBoxOldWndProc(Message); { if (lbItems.ItemIndex = -1) and (lbItems.Items.Count > 0) then begin lbItems.ItemIndex := 0; SelectItem; end; } end; procedure CNDrawItem; var State: TOwnerDrawState; R: TRect; begin if lbItems.Items.Count > 0 then begin FItemListBoxOldWndProc(Message); with TWMDrawItem(Message).DrawItemStruct{$IFNDEF CLR}^{$ENDIF} do begin {$IFDEF CLR} State := TOwnerDrawState(itemState and $FFFF); {$ELSE} State := TOwnerDrawState(LongRec(itemState).Lo); {$ENDIF} R := rcItem; if odFocused in State then DrawFocusRect(hDC, R); // hide default draw focus rect end; end; end; begin case Message.Msg of LB_SYNCHRONYZE: SynchronizeItemList; LB_SYNCHRONYZESELECTION: SynchronizeListBoxSelection(lbItems); LB_UPDATEEVENTS: UpdateItemEvents; WM_ERASEBKGND: WMEraseBkGnd; WM_MOUSEACTIVATE: WMMouseActivate; WM_SETFOCUS: WMSetFocus; CN_DRAWITEM: CNDrawItem; else FItemListBoxOldWndProc(Message); end; end; procedure TdxBarCustomizingForm.ItemsChange(Sender: TObject; AComponent: TComponent; AAction: TcxComponentCollectionNotification); begin if Assigned(FItemsOldChangeEvent) then FItemsOldChangeEvent(Sender, AComponent, AAction); SynchronizeListBox(lbItems, AComponent, AAction); SynchronizeListBox(LAllCommands, AComponent, AAction); SynchronizeListBox(lbGroupItems, AComponent, AAction); end; procedure TdxBarCustomizingForm.MoveItem(Delta: Integer); begin MoveItems(lbItems, TdxBarManagerAccess(BarManager).ItemList, Delta); lbItems.SetFocus; end; procedure TdxBarCustomizingForm.CommandListBoxWndProc(var Message: TMessage); procedure SynchronizeCommandList; var I: Integer; AItem: TdxBarItem; begin AItem := TdxBarItem(Message.WParam); if AItem = nil then begin SendMessage(LAllCommands.Handle, WM_SETREDRAW, WPARAM(False), 0); try for I := 0 to BarManager.ItemCount - 1 do if (BarManager.Items[I].Category >= 0) and (not CBShowCommandsWithShortCut.Checked or (GetPropInfo(BarManager.Items[I].ClassInfo, 'ShortCut') <> nil)) then LAllCommands.Items.AddObject('', BarManager.Items[I]); finally SendMessage(LAllCommands.Handle, WM_SETREDRAW, WPARAM(True), 0); end; end; RefreshAllCommandListBox; end; begin case Message.Msg of LB_SYNCHRONYZE: SynchronizeCommandList; LB_SYNCHRONYZESELECTION: SynchronizeListBoxSelection(LAllCommands); end; FCommandListBoxOldWndProc(Message); end; function TdxBarCustomizingForm.GetCommandList(Index: Integer): TdxBarItem; begin Result := TdxBarItem(GetObjectFromListBox(LAllCommands, Index)); end; procedure TdxBarCustomizingForm.RefreshAllCommandListBox; var I, W: Integer; begin FAllCommandsNameWidth := 0; FAllCommandsCaptionWidth := 0; FAllCommandsShortCutWidth := 0; LAllCommands.Canvas.Font := LAllCommands.Font; for I := 0 to LAllCommands.Items.Count - 1 do with CommandList[I] do begin W := LAllCommands.Canvas.TextWidth(Name); if W > FAllCommandsNameWidth then FAllCommandsNameWidth := W; W := LAllCommands.Canvas.TextWidth(Caption); if W > FAllCommandsCaptionWidth then FAllCommandsCaptionWidth := W; W := LAllCommands.Canvas.TextWidth(ShortCutToText(ShortCut)); if W > FAllCommandsShortCutWidth then FAllCommandsShortCutWidth := W; end; LAllCommands.Invalidate; SendMessage(LAllCommands.Handle, LB_SETHORIZONTALEXTENT, AllCommandsIndent + FAllCommandsNameWidth + AllCommandsIndent + AllCommandsIndent + FAllCommandsCaptionWidth + AllCommandsIndent + AllCommandsIndent + FAllCommandsShortCutWidth + AllCommandsIndent, 0); end; function TdxBarCustomizingForm.GetSelectedGroup: TdxBarGroup; begin Result := TdxBarGroup(GetExclusiveObject(lbGroups)); end; procedure TdxBarCustomizingForm.GroupListBoxWndProc(var Message: TMessage); procedure SynchronizeGroupList; var I: Integer; AGroup: TdxBarGroup; begin AGroup := TdxBarGroup(Message.WParam); if AGroup = nil then for I := 0 to BarManager.GroupCount - 1 do begin AGroup := BarManager.Groups[I]; lbGroups.Items.AddObject(AGroup.Name, AGroup); end else lbGroups.Items[Message.LParam] := AGroup.Name; end; procedure UpdateGroupEvents; begin SynchronizeListBox(lbGroupItems); UpdateCommonEvents(lbGroups, aAddGroup, aDeleteGroup, aMoveUpGroup, aMoveDownGroup); end; begin case Message.Msg of LB_SYNCHRONYZE: SynchronizeGroupList; LB_SYNCHRONYZESELECTION: SynchronizeListBoxSelection(lbGroups); LB_UPDATEEVENTS: UpdateGroupEvents; end; FGroupListBoxOldWndProc(Message); end; procedure TdxBarCustomizingForm.GroupsChange(Sender: TObject; AComponent: TComponent; AAction: TcxComponentCollectionNotification); begin if Assigned(FGroupsOldChangeEvent) then FGroupsOldChangeEvent(Sender, AComponent, AAction); SynchronizeListBox(lbGroups, AComponent, AAction); end; procedure TdxBarCustomizingForm.MoveGroup(ADirection: Integer); begin MoveItems(lbGroups, TdxBarManagerAccess(BarManager).GroupList, ADirection); end; procedure TdxBarCustomizingForm.RememberSelectedList; begin FSelectedGroupItems.Clear; GetSelection(lbGroupItems, FSelectedGroupItems); end; procedure TdxBarCustomizingForm.GroupItemListBoxWndProc(var Message: TMessage); procedure SynchronizeGroupItemList; var I: Integer; AGroup: TdxBarGroup; AItem: TComponent; begin AItem := TComponent(Message.WParam); if AItem = nil then begin AGroup := SelectedGroup; if AGroup <> nil then for I := 0 to AGroup.Count - 1 do begin AItem := AGroup[I]; lbGroupItems.Items.AddObject(AItem.Name, AItem); end; end else lbGroupItems.Items[Message.LParam] := AItem.Name; end; procedure SynchronizeGroupListSelection; begin SetSelection(lbGroupItems, FSelectedGroupItems); UpdateGroupItemEvents; end; begin case Message.Msg of LB_SYNCHRONYZE: SynchronizeGroupItemList; LB_SYNCHRONYZESELECTION: SynchronizeGroupListSelection; LB_UPDATEEVENTS: UpdateGroupItemEvents; end; FGroupItemListBoxOldWndProc(Message); end; procedure TdxBarCustomizingForm.GroupStuctureChange; begin SynchronizeListBox(lbGroupItems); end; procedure TdxBarCustomizingForm.DeleteGroupItem(AGroupItem: TObject); begin SelectedGroup.Remove(TdxBarComponent(AGroupItem)); end; procedure TdxBarCustomizingForm.MoveGroupItem(ADirection: Integer); begin MoveItems(lbGroupItems, TdxBarGroupAccess(SelectedGroup).ItemList, ADirection); end; procedure TdxBarCustomizingForm.UpdateGroupItemEvents; begin aAddGroupItem.Enabled := SelectedGroup <> nil; UpdateCommonEvents(lbGroupItems, nil, aDeleteGroupItem, aMoveUpGroupItem, aMoveDownGroupItem); end; procedure TdxBarCustomizingForm.WMActivate(var Message: TMessage); var AParentForm: TCustomForm; begin inherited; if not (csDestroying in ComponentState) and not (bisFormActivating in TdxBarManagerAccess(BarManager).InternalState) then begin if BarManager.Designing then AParentForm := BarManager.ParentForm else AParentForm := BarManager.MasterForm; if //(Message.wParam <> WA_INACTIVE) and (HWND(Message.lParam) <> AParentForm.Handle) then SendMessage(AParentForm.Handle, Message.Msg, Message.wParam, Message.lParam); {#DG if (Message.wParam <> WA_INACTIVE) and not BarDesignController.IsCustomizedByPopup then PageControlChange(nil); } end; end; procedure TdxBarCustomizingForm.WMDestroy(var Message: TWMDestroy); begin inherited; //#DG BarManager.Customizing(False); end; procedure TdxBarCustomizingForm.WMNCHitTest(var Message: TMessage); begin inherited; case Message.Result of HTLEFT, HTRIGHT: Message.Result := HTCLIENT; HTTOPLEFT, HTTOPRIGHT: Message.Result := HTTOP; HTBOTTOMLEFT, HTBOTTOMRIGHT: Message.Result := HTBOTTOM; end; end; procedure TdxBarCustomizingForm.CreateParams(var Params: TCreateParams); begin inherited; Params.Style := WS_POPUP or WS_CLIPSIBLINGS or WS_SYSMENU or WS_CAPTION or WS_THICKFRAME; Params.ExStyle := WS_EX_DLGMODALFRAME or WS_EX_WINDOWEDGE; Params.WindowClass.Style := CS_OWNDC or CS_SAVEBITS; Params.WndParent := BarManager.Owner.Handle; end; {$IFDEF DELPHI9} procedure TdxBarCustomizingForm.DestroyWindowHandle; begin EnableWindows(True); inherited; end; {$ENDIF} procedure TdxBarCustomizingForm.BarManagerStyleChanged; begin SynchronizeListBoxes; UpdateOptions; BarManager1.Style := BarManager.Style; BarManager1.LookAndFeel := BarManager.LookAndFeel; if BarManager.GetPaintStyle = bmsFlat then lbItems.Color := clWindow else lbItems.Color := clBtnFace; end; procedure TdxBarCustomizingForm.DesignSelectionChanged(Sender: TObject); begin if not (csDestroying in (Application.ComponentState + ComponentState)) then begin SynchronizeListBoxSelection(lbBarsList); SynchronizeListBoxSelection(lbItems); SynchronizeListBoxSelection(LAllCommands); SynchronizeListBoxSelection(lbGroups); end; end; procedure TdxBarCustomizingForm.SelectPage(APageIndex: Integer); begin PageControl.ActivePageIndex := APageIndex; end; procedure TdxBarCustomizingForm.UpdateHelpButton; begin BHelp.Glyph := BarManager.HelpButtonGlyph; BHelp.Visible := BarManager.ShowHelpButton; end; procedure TdxBarCustomizingForm.UpdateOptions; begin StandardOptionsPanel.Visible := BarManager.GetPaintStyle = bmsStandard; EnhancedOptionsPanel.Visible := BarManager.GetPaintStyle <> bmsStandard; CBMenusShowRecentItemsFirst.Checked := BarManager.MenusShowRecentItemsFirst; CBShowFullMenusAfterDelay.Checked := BarManager.ShowFullMenusAfterDelay; CBShowFullMenusAfterDelay.Enabled := CBMenusShowRecentItemsFirst.Checked; CBLargeIcons.Checked := BarManager.LargeIcons; CBLargeIconsEx.Checked := BarManager.LargeIcons; CBHint1.Checked := BarManager.ShowHint; CBHint1Ex.Checked := BarManager.ShowHint; CBHint2.Checked := BarManager.ShowShortcutInHint; CBHint2Ex.Checked := BarManager.ShowShortcutInHint; CBHint2Ex.Enabled := CBHint1Ex.Checked; ComboBoxMenuAnimations.ItemIndex := Ord(BarManager.MenuAnimations); ComboBoxMenuAnimationsEx.ItemIndex := Ord(BarManager.MenuAnimations); end; procedure TdxBarCustomizingForm.UpdateVisibility(const AWindowPos: TWindowPos); begin if AWindowPos.flags and SWP_SHOWWINDOW <> 0 then ShowWindow(Handle, SW_SHOW) else if AWindowPos.flags and SWP_HIDEWINDOW <> 0 then ShowWindow(Handle, SW_HIDE); end; procedure TdxBarCustomizingForm.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := caFree; end; procedure TdxBarCustomizingForm.FormCreate(Sender: TObject); begin Constraints.MinHeight := Height; FSelectionList := TdxComponentList.Create(False); (BarManager as IdxBarDesigner).GetSelection(FSelectionList); end; procedure TdxBarCustomizingForm.FormDestroy(Sender: TObject); begin FdxBarCustomizingForm := nil; //#DG BarManager.Bars.OnChange := FBarsOldChangeEvent; TdxBarManagerAccess(BarManager).GroupList.OnComponentListChanged := FGroupsOldChangeEvent; TdxBarManagerAccess(BarManager).ItemList.OnComponentListChanged := FItemsOldChangeEvent; if not FCloseCustomizingFormFlag then begin FCloseCustomizingFormFlag := True; BarManager.Customizing(False); FCloseCustomizingFormFlag := False; end; // SelectBarManager; //#DG (BarManager as IdxBarDesigner).SetSelection(FSelectionList); FreeAndNil(FSelectionList); end; procedure TdxBarCustomizingForm.FormShow(Sender: TObject); begin EnableWindows(False); end; procedure TdxBarCustomizingForm.FormHide(Sender: TObject); begin EnableWindows(True); end; procedure TdxBarCustomizingForm.lbBarsListClick(Sender: TObject); begin SynchronizeDesigner(lbBarsList); end; procedure TdxBarCustomizingForm.lbBarsListMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var AIndex: Integer; begin AIndex := lbBarsList.ItemAtPos(Point(X, Y), True); if (AIndex > -1) and (lbBarsList.Items.Count > 0) and (X - lbBarsList.ItemRect(AIndex).Left < lbBarsList.ItemHeight) then BarListToggleCheck(AIndex); end; procedure TdxBarCustomizingForm.lbBarsListDblClick(Sender: TObject); begin BarListToggleCheck(lbBarsList.ItemIndex); end; procedure TdxBarCustomizingForm.lbBarsListKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin case Key of VK_DELETE: aDeleteToolBar.Execute; VK_INSERT: aNewToolBar.Execute; VK_SPACE: BarListToggleCheck(lbBarsList.ItemIndex); end; end; procedure TdxBarCustomizingForm.lbBarsListDrawItem( Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); const Checks: array[Boolean] of Integer = (0, DFCS_CHECKED); Inactives: array[Boolean] of Integer = (DFCS_INACTIVE, 0); procedure DrawCheckBox(ARect: TRect); begin Dec(ARect.Left, lbBarsList.ItemHeight); ARect.Right := ARect.Left + lbBarsList.ItemHeight; InflateRect(ARect, -1, -1); with TdxBarAccess(BarList[Index]) do DrawFrameControl(lbBarsList.Canvas.Handle, ARect, DFC_BUTTON, DFCS_BUTTONCHECK or Checks[Visible] or Inactives[CanClose]); end; var AFlags: Integer; begin if BarList[Index] = nil then //#DG ??? Exit; DrawCheckBox(Rect); lbBarsList.Canvas.FillRect(Rect); if Index < lbBarsList.Items.Count then begin AFlags := DrawTextBiDiModeFlags(DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX); if not lbBarsList.UseRightToLeftAlignment then Inc(Rect.Left, 2) else Dec(Rect.Right, 2); cxDrawText(lbBarsList.Canvas.Handle, lbBarsList.Items[Index], Rect, AFlags); end; end; procedure TdxBarCustomizingForm.BHelpClick(Sender: TObject); begin if not BarManager.Designing then begin TdxBarManagerAccess(BarManager).DoHelpButtonClick; if BarManager.HelpContext <> 0 then Application.HelpContext(BarManager.HelpContext); end; end; procedure TdxBarCustomizingForm.BCloseClick(Sender: TObject); begin Close; end; procedure TdxBarCustomizingForm.lbCategoriesClick(Sender: TObject); begin SynchronizeListBox(lbItems); end; procedure TdxBarCustomizingForm.lbCategoriesKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if BarManager.Designing then case Key of VK_INSERT: if Shift = [] then CategoriesInsertClick(nil); VK_DELETE: if Shift = [] then CategoriesDeleteClick(nil); end; end; procedure TdxBarCustomizingForm.lbCategoriesMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var ANewIndex: Integer; begin with lbCategories do case Button of mbLeft: if BarManager.Designing and (ItemAtPos(Point(X, Y), True) > -1) then begin FDraggingCategoryIndex := ItemIndex; DragMode := dmAutomatic; end; mbRight: begin SetFocus; ANewIndex := ItemAtPos(Point(X, Y), True); if (ANewIndex <> -1) and (ANewIndex <> ItemIndex) then begin ItemIndex := ANewIndex; SynchronizeListBox(lbItems); end; if BarManager.Designing then with ClientToScreen(Point(X, Y)) do CategoriesPopupMenu.Popup(X, Y); end; end; end; procedure TdxBarCustomizingForm.lbCategoriesDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); var AItemIndex: Integer; begin Accept := Source = Sender; if Accept then begin AItemIndex := lbCategories.ItemAtPos(Point(X, Y), True); if AItemIndex > -1 then begin BarManager.Categories.Move(FDraggingCategoryIndex, AItemIndex); lbCategories.Items.Move(FDraggingCategoryIndex, AItemIndex); lbCategories.ItemIndex := AItemIndex; FDraggingCategoryIndex := AItemIndex; end; end; end; procedure TdxBarCustomizingForm.lbCategoriesEndDrag(Sender, Target: TObject; X, Y: Integer); begin lbCategories.DragMode := dmManual; end; procedure TdxBarCustomizingForm.CategoriesPopupMenuPopup(Sender: TObject); begin CategoriesInsert.Enabled := lbCategories.ItemIndex > -1; CategoriesRename.Enabled := lbCategories.ItemIndex > -1; with CategoriesVisible do begin Enabled := lbCategories.ItemIndex > -1; Down := Enabled and Self.BarManager.CategoryVisible[lbCategories.ItemIndex]; end; with CategoriesItemsVisible do begin Enabled := CategoriesVisible.Enabled; if Enabled then ItemIndex := Ord(Self.BarManager.CategoryItemsVisible[lbCategories.ItemIndex]); end; CategoriesDelete.Enabled := CanDeleteSelectedCategory; end; procedure TdxBarCustomizingForm.CategoriesAddClick(Sender: TObject); var S: string; begin S := ''; if dxBarEditName(S, 1, 0, BarManager, nil) then begin BarManager.Categories.Add(S); lbCategories.Items.Add(S); lbCategories.ItemIndex := lbCategories.Items.Count - 1; SynchronizeListBox(lbItems); lbCategories.SetFocus; end; end; procedure TdxBarCustomizingForm.CategoriesInsertClick(Sender: TObject); var S: string; AItemIndex: Integer; begin AItemIndex := lbCategories.ItemIndex; if AItemIndex > -1 then begin S := ''; if dxBarEditName(S, 1, 1, BarManager, nil) then begin AItemIndex := lbCategories.ItemIndex; BarManager.Categories.Insert(AItemIndex, S); lbCategories.Items.Insert(AItemIndex, S); lbCategories.ItemIndex := AItemIndex; SynchronizeListBox(lbItems); lbCategories.SetFocus; end; end; end; procedure TdxBarCustomizingForm.CategoriesRenameClick(Sender: TObject); var S: string; AItemIndex: Integer; begin AItemIndex := lbCategories.ItemIndex; if AItemIndex > -1 then begin S := lbCategories.Items[AItemIndex]; if dxBarEditName(S, 1, 2, BarManager, nil) then begin BarManager.Categories[AItemIndex] := S; lbCategories.Items[AItemIndex] := S; lbCategories.ItemIndex := AItemIndex; lbCategories.SetFocus; end; end end; procedure TdxBarCustomizingForm.CategoriesVisibleClick(Sender: TObject); begin BarManager.CategoryVisible[lbCategories.ItemIndex] := TdxBarButton(Sender).Down; lbCategories.SetFocus; end; procedure TdxBarCustomizingForm.CategoriesItemsVisibleChange( Sender: TObject); begin BarManager.CategoryItemsVisible[lbCategories.ItemIndex] := TdxBarItemVisible(TdxBarCombo(Sender).ItemIndex); lbCategories.SetFocus; end; procedure TdxBarCustomizingForm.CategoriesDeleteClick(Sender: TObject); var AItemIndex: Integer; begin if CanDeleteSelectedCategory then begin AItemIndex := lbCategories.ItemIndex; if dxBarMessageBox(Format(cxGetResourceString(@dxSBAR_WANTTODELETECATEGORY), [lbCategories.Items[AItemIndex]]), MB_ICONEXCLAMATION or MB_OKCANCEL) = ID_OK then begin SelectBarManager; BarManager.Categories.Delete(AItemIndex); lbCategories.Items.Delete(AItemIndex); if AItemIndex = lbCategories.Items.Count then Dec(AItemIndex); lbCategories.ItemIndex := AItemIndex; SynchronizeListBox(lbItems); lbCategories.SetFocus; end; end; end; procedure TdxBarCustomizingForm.lbItemsClick(Sender: TObject); begin SynchronizeDesigner(lbItems); end; procedure TdxBarCustomizingForm.lbItemsDblClick(Sender: TObject); begin if SelectedItem <> nil then TdxBarItemAccess(SelectedItem).ShowDefaultEventHandler; end; procedure TdxBarCustomizingForm.lbItemsDrawItem( Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); function BrushColors(AItem: TdxBarItem; ASelected: Boolean): TColor; begin Result := PainterClass.BrushColors(ASelected, AItem); end; var AItem: TdxBarItem; R: TRect; begin AItem := ItemList[Index]; if AItem = nil then Exit; TdxBarItemAccess(AItem).DrawCustomizingImage(lbItems.Canvas, Rect, State); R := Rect; if Index = lbItems.Items.Count - 1 then begin R := Rect; R.Top := R.Bottom; R.Bottom := ClientHeight; lbItems.Canvas.Brush.Color := BrushColors(AItem, False); lbItems.Canvas.FillRect(R); end; if odFocused in State then PainterClass.DrawFocusedRect(lbItems.Canvas, Rect, AItem); end; procedure TdxBarCustomizingForm.lbItemsKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if BarManager.Designing then case Key of VK_INSERT: if Shift = [] then aAddItem.Execute; VK_DELETE: if Shift = [] then aDeleteItem.Execute; VK_UP: if Shift = [ssCtrl] then begin aMoveUpItem.Execute; Key := 0; end; VK_DOWN: if Shift = [ssCtrl] then begin aMoveDownItem.Execute; Key := 0; end; end; end; procedure TdxBarCustomizingForm.lbItemsMeasureItem( Control: TWinControl; Index: Integer; var Height: Integer); begin Height := dxBarButtonHeight; // todo delete end; procedure TdxBarCustomizingForm.lbItemsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var AIsDragging: Boolean; begin AIsDragging := (Button = mbLeft) and Windows.DragDetect(lbItems.Handle, GetMouseCursorPos); if Button = mbRight then begin lbItems.SetFocus; SetSelection(lbItems, ItemList[lbItems.ItemAtPos(Point(X, Y), True)]); end; SynchronizeDesigner(lbItems); if AIsDragging and (SelectedItem <> nil) then TdxBarManagerAccess(BarManager).DragAndDrop(SelectedItem, nil); end; procedure TdxBarCustomizingForm.lbItemsMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if (Button = mbRight) and (BarManager.Designing) then CommandsPopupMenu.PopupFromCursorPos; end; procedure TdxBarCustomizingForm.CommandsPopupMenuPopup(Sender: TObject); begin CommandsAdd.Enabled := aAddItem.Enabled; CommandsDelete.Enabled := aDeleteItem.Enabled; CommandsClear.Enabled := aClearItemList.Enabled; CommandsMoveUp.Enabled := aMoveUpItem.Enabled; CommandsMoveDown.Enabled := aMoveDownItem.Enabled; CommandsSubMenuEditor.Enabled := aSubMenuEditor.Enabled; end; procedure TdxBarCustomizingForm.CommandsAddClick(Sender: TObject); begin aAddItem.Execute; end; procedure TdxBarCustomizingForm.CommandsDeleteClick(Sender: TObject); begin aDeleteItem.Execute; end; procedure TdxBarCustomizingForm.CommandsClearClick(Sender: TObject); begin aClearItemList.Execute; end; procedure TdxBarCustomizingForm.CommandsMoveUpClick(Sender: TObject); begin aMoveUpItem.Execute; end; procedure TdxBarCustomizingForm.CommandsMoveDownClick(Sender: TObject); begin aMoveDownItem.Execute; end; procedure TdxBarCustomizingForm.CommandsSubMenuEditorClick(Sender: TObject); begin aSubMenuEditor.Execute; end; procedure TdxBarCustomizingForm.CBMenusShowRecentItemsFirstClick(Sender: TObject); begin CBShowFullMenusAfterDelay.Enabled := CBMenusShowRecentItemsFirst.Checked; BarManager.MenusShowRecentItemsFirst := CBMenusShowRecentItemsFirst.Checked; end; procedure TdxBarCustomizingForm.CBShowFullMenusAfterDelayClick(Sender: TObject); begin BarManager.ShowFullMenusAfterDelay := CBShowFullMenusAfterDelay.Checked; end; procedure TdxBarCustomizingForm.BResetUsageDataClick(Sender: TObject); begin BarManager.ResetUsageDataWithConfirmation; end; procedure TdxBarCustomizingForm.CBLargeIconsClick(Sender: TObject); begin BarManager.LargeIcons := TCheckBox(Sender).Checked; end; procedure TdxBarCustomizingForm.CBHint1Click(Sender: TObject); begin BarManager.ShowHint := TCheckBox(Sender).Checked; end; procedure TdxBarCustomizingForm.CBHint1ExClick(Sender: TObject); begin CBHint2Ex.Enabled := CBHint1Ex.Checked; CBHint1Click(Sender); end; procedure TdxBarCustomizingForm.CBHint2Click(Sender: TObject); begin BarManager.ShowShortCutInHint := TCheckBox(Sender).Checked; end; procedure TdxBarCustomizingForm.ComboBoxMenuAnimationsClick(Sender: TObject); begin BarManager.MenuAnimations := TdxBarMenuAnimations(TComboBox(Sender).ItemIndex); end; procedure TdxBarCustomizingForm.LAllCommandsClick(Sender: TObject); begin SynchronizeDesigner(LAllCommands); end; procedure TdxBarCustomizingForm.LAllCommandsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); var W: Integer; LastRow: Boolean; begin LastRow := Index = TListBox(Control).Items.Count - 1; with TListBox(Control), Canvas, TdxBarItem(Items.Objects[Index]), Rect do begin Pen.Color := Font.Color; FillRect(Rect); TextOut(Left + AllCommandsIndent, Top, Name); W := AllCommandsIndent + FAllCommandsNameWidth + AllCommandsIndent; MoveTo(W, Top); LineTo(W, Bottom); TextOut(W + AllCommandsIndent, Top, Caption); Inc(W, AllCommandsIndent + FAllcommandsCaptionWidth + AllCommandsIndent); MoveTo(W, Top); LineTo(W, Bottom); TextOut(W + AllCommandsIndent, Top, ShortCutToText(ShortCut)); if LastRow then begin Pen.Color := clWindowText; W := AllCommandsIndent + FAllCommandsNameWidth + AllCommandsIndent; MoveTo(W, Bottom); LineTo(W, ClientHeight); Inc(W, AllCommandsIndent + FAllCommandsCaptionWidth + AllCommandsIndent); MoveTo(W, Bottom); LineTo(W, ClientHeight); end; end; end; procedure TdxBarCustomizingForm.CBShowCommandsWithShortCutClick(Sender: TObject); begin SynchronizeListBox(LAllCommands); end; procedure TdxBarCustomizingForm.lbGroupsClick(Sender: TObject); begin SynchronizeDesigner(lbGroups); end; procedure TdxBarCustomizingForm.lbGroupsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); begin with TListBox(Control) do begin Canvas.Font.Style := Canvas.Font.Style + [fsBold]; cxExtTextOut(Canvas.Handle, Items[Index], Point(Rect.Left + 2, Rect.Top + 1), Rect, ETO_OPAQUE); end; end; procedure TdxBarCustomizingForm.lbGroupsKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin case Key of VK_INSERT: aAddGroup.Execute; VK_DELETE: aDeleteGroup.Execute; VK_UP: if Shift = [ssCtrl] then begin aMoveUpGroup.Execute; Key := 0; end; VK_DOWN: if Shift = [ssCtrl] then begin aMoveDownGroup.Execute; Key := 0; end; end; end; procedure TdxBarCustomizingForm.lbGroupsMeasureItem(Control: TWinControl; Index: Integer; var Height: Integer); begin with TListBox(Control) do Canvas.Font := Font; Height := TListBox(Control).Canvas.TextHeight('Qq') + 2; end; procedure TdxBarCustomizingForm.lbGroupItemsClick(Sender: TObject); begin RememberSelectedList; UpdateGroupItemEvents; end; procedure TdxBarCustomizingForm.lbGroupItemsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); begin with TListBox(Control) do begin if Items.Objects[Index] is TdxBarGroup then Canvas.Font.Style := Canvas.Font.Style + [fsBold]; cxExtTextOut(Canvas.Handle, Items[Index], Point(Rect.Left + 2, Rect.Top + 1), Rect, ETO_OPAQUE); end; end; procedure TdxBarCustomizingForm.lbGroupItemsKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin case Key of VK_INSERT: aAddGroupItem.Execute; VK_DELETE: aDeleteGroupItem.Execute; VK_UP: if Shift = [ssCtrl] then begin aMoveUpGroupItem.Execute; Key := 0; end; VK_DOWN: if Shift = [ssCtrl] then begin aMoveDownGroupItem.Execute; Key := 0; end; end; end; procedure TdxBarCustomizingForm.aNewToolBarExecute(Sender: TObject); begin //#DG lbBarsList.Items.BeginUpdate; { #DG - because modal form erased items} try BarManager.AddToolBar(False, True); finally //#DG lbBarsList.Items.EndUpdate; end; end; procedure TdxBarCustomizingForm.aRenameToolBarExecute(Sender: TObject); begin BarManager.RenameToolBar(SelectedBar); end; procedure TdxBarCustomizingForm.aDeleteToolBarExecute(Sender: TObject); var AConfirmString: string; begin //#DG BarManager.Bars.BeginUpdate; {#DG AV - when inside delete proc repaint listbox calls} try if GetSelCount(lbBarsList) > 1 then AConfirmString := cxGetResourceString(@dxSBAR_WANTTODELETETOOLBARS) else AConfirmString := Format(cxGetResourceString(@dxSBAR_WANTTODELETETOOLBAR), [SelectedBar.Caption]); if dxBarMessageBox(AConfirmString, MB_ICONEXCLAMATION or MB_OKCANCEL) = ID_OK then DeleteSelectedObjects(lbBarsList); finally //#DG BarManager.Bars.EndUpdate; end; end; procedure TdxBarCustomizingForm.aResetToolBarExecute(Sender: TObject); begin BarManager.ResetToolBar(SelectedBar); end; procedure TdxBarCustomizingForm.aAddGroupItemExecute(Sender: TObject); var Group: TdxBarGroup; AGroupItems: TdxObjectList; I: Integer; begin Group := SelectedGroup; AGroupItems := TdxObjectList.Create; try if dxBarChooseGroupItem(Group, AGroupItems) then begin TdxBarGroupAccess(Group).ItemList.BeginUpdate; try for I := 0 to AGroupItems.Count - 1 do Group.Add(TdxBarComponent(AGroupItems[I])); finally TdxBarGroupAccess(Group).ItemList.EndUpdate; end; AGroupItems.CopyTo(FSelectedGroupItems); GroupStuctureChange; end; finally AGroupItems.Free; end; TdxBarManagerAccess(BarManager).DesignerModified; end; procedure TdxBarCustomizingForm.aDeleteGroupItemExecute(Sender: TObject); //#DGvar //#DG AGroup: TdxBarGroup; begin //#DG AGroup := SelectedGroup; //#DG TdxBarGroupAccess(AGroup).ItemList.BeginUpdate; try DeleteSelectedObjects(lbGroupItems, DeleteGroupItem, False); RememberSelectedList; finally //#DG TdxBarGroupAccess(AGroup).ItemList.EndUpdate; end; GroupStuctureChange; end; procedure TdxBarCustomizingForm.aAddGroupExecute(Sender: TObject); var AGroup: TdxBarGroup; begin TdxBarManagerAccess(BarManager).GroupList.BeginUpdate; try AGroup := BarManager.CreateGroup; AGroup.Name := (BarManager as IdxBarDesigner).UniqueName('dxBarGroup'); SynchronizeDesigner(AGroup); finally TdxBarManagerAccess(BarManager).GroupList.EndUpdate; end; TdxBarManagerAccess(BarManager).DesignerModified; end; procedure TdxBarCustomizingForm.aDeleteGroupExecute(Sender: TObject); begin DeleteSelectedObjects(lbGroups); end; procedure TdxBarCustomizingForm.aMoveGroupExecute(Sender: TObject); begin MoveGroup(TAction(Sender).Tag); end; procedure TdxBarCustomizingForm.aMoveGroupItemExecute(Sender: TObject); begin MoveGroupItem(TAction(Sender).Tag); GroupStuctureChange; end; procedure TdxBarCustomizingForm.aMoveItemExecute(Sender: TObject); begin MoveItem(TAction(Sender).Tag); end; procedure TdxBarCustomizingForm.aAddItemExecute(Sender: TObject); var AItem: TdxBarItem; begin TdxBarManagerAccess(BarManager).ItemList.BeginUpdate; try AItem := dxBarItemAddEditor(BarManager, lbCategories.ItemIndex); if AItem <> nil then begin SynchronizeDesigner(AItem); lbItems.SetFocus; end; finally TdxBarManagerAccess(BarManager).ItemList.EndUpdate; end; end; procedure TdxBarCustomizingForm.aDeleteItemExecute(Sender: TObject); begin DeleteSelectedObjects(lbItems); lbItems.SetFocus; end; procedure TdxBarCustomizingForm.aSubMenuEditorExecute(Sender: TObject); var ASubItem: TCustomdxBarSubItem; begin lbItems.SetFocus; ASubItem := TCustomdxBarSubItem(lbItems.Items.Objects[lbItems.ItemIndex]); ShowdxBarSubMenuEditor(ASubItem.ItemLinks); end; procedure TdxBarCustomizingForm.aClearItemListExecute(Sender: TObject); procedure SelectAllItems(AListBox: TListBox); begin SendMessage(AListBox.Handle, LB_SETSEL, Integer(True), -1); end; begin if dxBarMessageBox(Format(cxGetResourceString(@dxSBAR_WANTTOCLEARCOMMANDS), [lbCategories.Items[lbCategories.ItemIndex]]), MB_ICONEXCLAMATION or MB_OKCANCEL) = ID_OK then begin lbItems.Items.BeginUpdate; try SelectAllItems(lbItems); DeleteSelectedObjects(lbItems); lbItems.SetFocus; finally lbItems.Items.EndUpdate; end; end; end; end.