📄 dxbarcustform.pas
字号:
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, @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;
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 IsSelectableItem(AComponent, 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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -