-
Notifications
You must be signed in to change notification settings - Fork 35
The item should be placed on a TSpTBXToolbar with Stretch set to True, and ShrinkMode setted to tbsmNone.
Just set the item's Anchored property to true, you can use the CustomWidth and CustomHeight properties to set the initial size value.
The item should be placed on a TSpTBXToolbar with Stretch set to True, and ShrinkMode setted to tbsmNone.
Just add a TSpTBXRightAlignSpacerItem above the item.
The control should be placed on a TSpTBXToolbar with Stretch set to True, and ShrinkMode setted to tbsmNone.
Drop a control on the toolbar and set the control's Align property to alClient or set the Anchors property to include akRight.
You can custom paint toolbar items and controls using the following events:
- OnDrawItem/OnDrawBackground: to custom paint the item background
- OnDrawCaption: to custom paint the item caption
- OnDrawImage: to custom paint the item image icon
- OnDrawHint: to custom paint the item hint
All these events have 2 important parameters: PaintStage and PaintDefault.
PaintStage indicates the current stage in the drawing process.
DefaultDraw indicates whether the control should continue with the default painting after the event handler exits.
Set DefaultDraw to false to prevent the drawing of the control after the event handler exits. If DefaultDraw remains set to true, the control continues with the default painting process.
Example:
procedure TForm1.SpTBXItem1DrawItem(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; ItemInfo: TSpTBXMenuItemInfo;
const PaintStage: TSpTBXPaintStage; var PaintDefault: Boolean);
begin
if PaintStage = pstPrePaint then begin
// Override the default painting, we are going to take care
// of all the painting here
PaintDefault := False;
// Paint the item in red
ACanvas.Brush.Color := clRed;
ACanvas.Rectangle(ARect);
end;
end;
Set the toolbar's FullSize to true and ShrinkMode to tbsmWrap
To disable the focus rectangle painting on button controls (TSpTBXButton, TSpTBXCheckBox, TSpTBXRadioButton) use the OnDrawCaption event, the focus rectangle is painted after the caption painting is done:
procedure TForm1.SpTBXButton1DrawCaption(Sender: TObject; ACanvas: TCanvas;
ClientAreaRect: TRect; State: TSpTBXSkinStatesType; var ACaption: string;
var CaptionRect: TRect; var CaptionFormat: Cardinal; IsTextRotated: Boolean;
const PaintStage: TSpTBXPaintStage; var PaintDefault: Boolean);
begin
if PaintStage = pstPostPaint then
PaintDefault := False;
end;
Use the SpFocusEditItem utility function located in the SpTBXEditors.pas unit. The first parameter is the editor item, the second parameter is the View where the item is located, normally a toolbar view:
procedure TForm1.Button1Click(Sender: TObject);
begin
SpFocusEditItem(SpTBXComboBoxItem1, SpTBXToolbar1.View);
end;
This is not done automatically by the control, you have to create the buttons yourself, take a look at the Overview demo.
I choose to leave it to the component user because there are many ways to handle this: scrollers, buttons, popups, chevron, different positions, etc.
You can also use the TabAutofit property to resize the tabs without the need to use scrollers, like Firefox.
In Delphi, margins are used to specify the space around the control, and padding the offseting inside the control.
The compound components such as the TSpTBXDockablePanel or the TSpTBXTabControl/TSpTBXTabSet have a Toolbar public property, access this property and use the mouse events of the internal toolbar:
procedure TForm1.FormShow(Sender: TObject);
begin
SpTBXDockablePanel1.Toolbar.OnMouseDown := MyMouseDownEvent;
end;
procedure TForm1.MyMouseDownEvent(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
IV: TTBItemViewer;
begin
IV := SpTBXDockablePanel1.View.ViewerFromPoint(Point(X, Y));
if Assigned(IV) then
Caption := IV.Item.Name;
end;