home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip: Shareware for Win 95
/
Chip-Shareware-Win95.bin
/
ostatni
/
delphi
/
ruzne
/
rzcomps.exe
/
DEMO
/
TLBARFRM.PA_
/
TLBARFRM.PA
Wrap
Text File
|
1996-10-18
|
6KB
|
229 lines
{===============================================================================
RzTbrEdt Unit
This unit implements a component editor for the RzToolbar component. This
unit defines the TRzToolbarEditor class and the TRzToolbarEditDlg class. The
TRzToolbarEditor displays the TRzToolbarEditDlg form when the component is
double-clicked or the first context menu item is chosen. The form provides a
fast and easy way to add speed buttons with custom glyphs to the toolbar.
Copyright ⌐ 1995-1996 by Raize Software Solutions, Inc.
===============================================================================}
unit Tlbarfrm;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, Buttons, StdCtrls, DsgnIntf, RzPanel;
type
TFrmToolbarEditor = class(TForm)
GrpFormatting: TGroupBox;
GrpMisc: TGroupBox;
BtnHelpBook: TSpeedButton;
BtnExecute: TSpeedButton;
BtnUpOneLevel: TSpeedButton;
BtnUtils: TSpeedButton;
GrpViewing: TGroupBox;
BtnView: TSpeedButton;
BtnZoomIn: TSpeedButton;
BtnZoomOut: TSpeedButton;
BtnBold: TSpeedButton;
BtnItalic: TSpeedButton;
BtnUnderline: TSpeedButton;
BtnLeftJustify: TSpeedButton;
BtnJustify: TSpeedButton;
BtnRightJustify: TSpeedButton;
BtnBullets: TSpeedButton;
BtnCenterJustify: TSpeedButton;
GrpEditing: TGroupBox;
BtnCut: TSpeedButton;
BtnCopy: TSpeedButton;
BtnPaste: TSpeedButton;
BtnUndo: TSpeedButton;
BtnRepeat: TSpeedButton;
GrpDatabase: TGroupBox;
BtnAdd: TSpeedButton;
BtnDelete: TSpeedButton;
BtnEdit: TSpeedButton;
BtnFirst: TSpeedButton;
BtnPrev: TSpeedButton;
BtnNext: TSpeedButton;
BtnLast: TSpeedButton;
GrpWindow: TGroupBox;
BtnCascade: TSpeedButton;
BtnHorzTile: TSpeedButton;
BtnVertTile: TSpeedButton;
BtnTile: TSpeedButton;
GrpFiles: TGroupBox;
BtnNew: TSpeedButton;
BtnOpen: TSpeedButton;
BtnSave: TSpeedButton;
GrpDeleting: TGroupBox;
BtnBasket: TSpeedButton;
BtnRecycle: TSpeedButton;
BtnTrashcan: TSpeedButton;
GrpSearching: TGroupBox;
BtnFind: TSpeedButton;
BtnFindNext: TSpeedButton;
BtnReplace: TSpeedButton;
GrpComm: TGroupBox;
BtnMail: TSpeedButton;
BtnFax: TSpeedButton;
BtnPrinter: TSpeedButton;
BtnDone: TButton;
BtnAccept: TSpeedButton;
BtnReject: TSpeedButton;
GrpBlank: TGroupBox;
BtnBlank: TSpeedButton;
ChkSpacer: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure SpeedButtonClick(Sender: TObject);
private
public
SelectedBtn : TSpeedButton;
ParentForm : TForm;
Toolbar : TRzToolbar;
end;
var
FrmToolbarEditor : TFrmToolbarEditor;
implementation
{$R *.DFM}
uses
RzCommon;
{===============================}
{== TRzToolbarEditDlg Methods ==}
{===============================}
procedure TFrmToolbarEditor.FormCreate(Sender: TObject);
begin
{$IFNDEF WIN32}
{ Adjust Position of SpeedButtons }
BtnOpen.Left := BtnOpen.Left - 1;
BtnSave.Left := BtnSave.Left - 2;
BtnCopy.Left := BtnCopy.Left - 1;
BtnPaste.Left := BtnPaste.Left - 2;
BtnRepeat.Left := BtnRepeat.Left - 3;
BtnItalic.Left := BtnItalic.Left - 1;
BtnUnderline.Left := BtnUnderline.Left - 2;
BtnCenterJustify.Left := BtnCenterJustify.Left - 1;
BtnRightJustify.Left := BtnRightJustify.Left - 2;
BtnJustify.Left := BtnJustify.Left - 3;
BtnReplace.Left := BtnReplace.Left - 1;
BtnFindNext.Left := BtnFindNext.Left - 2;
BtnHorzTile.Left := BtnHorzTile.Left - 1;
BtnVertTile.Left := BtnVertTile.Left - 2;
BtnTile.Left := BtnTile.Left - 3;
BtnZoomOut.Left := BtnZoomOut.Left - 1;
BtnZoomIn.Left := BtnZoomIn.Left - 2;
BtnEdit.Left := BtnEdit.Left - 1;
BtnDelete.Left := BtnDelete.Left - 2;
BtnPrev.Left := BtnPrev.Left - 1;
BtnNext.Left := BtnNext.Left - 2;
BtnLast.Left := BtnLast.Left - 3;
BtnFax.Left := BtnFax.Left - 1;
BtnPrinter.Left := BtnPrinter.Left - 2;
BtnReject.Left := BtnReject.Left - 1;
BtnRecycle.Left := BtnRecycle.Left - 1;
BtnTrashcan.Left := BtnTrashcan.Left - 2;
{$ENDIF}
end;
procedure TFrmToolbarEditor.SpeedButtonClick(Sender: TObject);
var
B : TSpeedButton;
MaxLeft, MaxTop, I, Spacer : Integer;
begin
{ A SpeedButton has been selected }
SelectedBtn := TSpeedButton( Sender );
if ParentForm <> nil then
begin
B := TSpeedButton.Create( ParentForm );
B.Parent := Toolbar;
if Toolbar.Align in [ alLeft, alRight ] then
begin
B.Left := 4;
MaxTop := 0;
for I := 0 to B.Parent.ControlCount - 1 do
begin
if B.Parent.Controls[ I ].Top > MaxTop then
MaxTop := B.Parent.Controls[ I ].Top;
end;
if MaxTop = 0 then
B.Top := 4
else
begin
if ChkSpacer.Checked then
Spacer := 1
else
Spacer := 0;
{$IFDEF WIN32}
B.Top := MaxTop + 25 + ( Spacer * 8 );
{$ELSE}
B.Top := MaxTop + 24 + ( Spacer * 8 );
{$ENDIF}
end;
end
else { alTop, alBottom, alClient, alNone }
begin
B.Top := 4;
MaxLeft := 0;
for I := 0 to B.Parent.ControlCount - 1 do
begin
if B.Parent.Controls[ I ].Left > MaxLeft then
MaxLeft := B.Parent.Controls[ I ].Left;
end;
if MaxLeft = 0 then
B.Left := 4
else
begin
if ChkSpacer.Checked then
Spacer := 1
else
Spacer := 0;
{$IFDEF WIN32}
B.Left := MaxLeft + 25 + ( Spacer * 8 );
{$ELSE}
B.Left := MaxLeft + 24 + ( Spacer * 8 );
{$ENDIF}
end;
end;
B.Name := GetNewComponentName( ParentForm, 'SpeedButton' );
{ Copy glyph from selected button }
B.Glyph.Assign( SelectedBtn.Glyph );
B.NumGlyphs := B.Glyph.Width div 18;
B.Hint := SelectedBtn.Hint;
ChkSpacer.Checked := False;
end;
end;
end.