home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip: Shareware for Win 95
/
Chip-Shareware-Win95.bin
/
ostatni
/
delphi
/
ruzne
/
rzcomps.exe
/
DEMO
/
LABELFRM.PA_
/
LABELFRM.PA
Wrap
Text File
|
1996-10-18
|
9KB
|
344 lines
unit Labelfrm;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Rzlabel, ExtCtrls, Spin, Buttons, RzTrkBar,
DsgnIntf, RzCmboBx, Tabs, RzPanel;
type
TFrmLabel = class(TForm)
GrpPreview: TGroupBox;
LblPreview: TRzLabel;
BtnOK: TButton;
PnlWorkspace: TRzPanel;
NbkFormat: TNotebook;
Label2: TLabel;
Label3: TLabel;
Label6: TLabel;
TrkPointSize: TRzTrackBar;
CbxFontColor: TRzColorComboBox;
GrpFontStyle: TGroupBox;
ChkBold: TCheckBox;
ChkItalic: TCheckBox;
ChkStrikeout: TCheckBox;
ChkUnderline: TCheckBox;
GrpTextStyle: TRadioGroup;
GrpShadow: TGroupBox;
Label4: TLabel;
Label5: TLabel;
TrkShadow: TRzTrackBar;
CbxShadowColor: TRzColorComboBox;
GrpRotation: TGroupBox;
LblAngle: TLabel;
TrkAngle: TRzTrackBar;
Chk15Degrees: TCheckBox;
PnlStyleTab: TRzPanel;
PnlFontTab: TRzPanel;
Label1: TLabel;
EdtCaption: TEdit;
CbxFonts: TRzFontComboBox;
RzLabel1: TRzLabel;
RzLabel2: TRzLabel;
RzLabel3: TRzLabel;
procedure EdtCaptionChange(Sender: TObject);
procedure GrpTextStyleClick(Sender: TObject);
procedure TrkPointSizeDrawTick( TrackBar: TRzTrackBar; Canvas: TCanvas;
Location: TPoint; Index: Integer );
procedure TrkPointSizeChange(Sender: TObject);
procedure TrkShadowChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure CbxFontsChange(Sender: TObject);
procedure ChkBoldClick(Sender: TObject);
procedure ChkItalicClick(Sender: TObject);
procedure ChkStrikeoutClick(Sender: TObject);
procedure ChkUnderlineClick(Sender: TObject);
procedure CbxFontColorChange(Sender: TObject);
procedure CbxShadowColorChange(Sender: TObject);
procedure TrkAngleDrawTick(TrackBar: TRzTrackBar; Canvas: TCanvas;
Location: TPoint; Index: Integer);
procedure Chk15DegreesClick(Sender: TObject);
procedure TrkAngleChange(Sender: TObject);
procedure PnlFontTabMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure PnlStyleTabMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
public
procedure UpdateControls;
end;
var
FrmLabel : TFrmLabel;
implementation
{$R *.DFM}
{=================================================}
{== Implementation Specific Types and Constants ==}
{=================================================}
const { Support Point Size Track Bar }
PointSizes : array[ 0..17 ] of string[ 2 ] =
( '6', '8', '9', '10', '11', '12', '14', '16', '18', '20',
'22', '24', '28', '32', '40', '48', '64', '72' );
{=============================}
{== TRzLabelEditDlg Methods ==}
{=============================}
{= NOTE: All changes made through the control on this dialog box affect only =}
{= the preview label (LblPreview). Only if the OK button is pressed =}
{= are the changes reflected in the selected component. =}
procedure TFrmLabel.FormCreate(Sender: TObject);
begin
NbkFormat.PageIndex := 0;
UpdateControls;
TrkPointSize.Hint := 'This is an RzTrackBar using'#13'owner-draw tick marks for'#13'point sizes.';
end;
procedure TFrmLabel.UpdateControls;
function PositionFromPointSize( P : Integer ) : Integer;
var
I : Integer;
begin
I := 0;
while ( I < 18 ) and ( StrToInt( PointSizes[ I ] ) <> P ) do
Inc( I );
if I = 18 then
Result := 2
else
Result := I;
end;
begin {= TRzLabelEditDlg.UpdateControls =}
EdtCaption.Text := LblPreview.Caption;
{ CbxFonts.ItemIndex := CbxFonts.Items.IndexOf( LblPreview.Font.Name );}
CbxFonts.SelectedFont := LblPreview.Font;
CbxFontColor.SelectedColor := LblPreview.Font.Color;
TrkPointSize.Position := PositionFromPointSize( LblPreview.Font.Size );
{ Font Styles }
ChkBold.Checked := fsBold in LblPreview.Font.Style;
ChkItalic.Checked := fsItalic in LblPreview.Font.Style;
ChkStrikeout.Checked := fsStrikeout in LblPreview.Font.Style;
ChkUnderline.Checked := fsUnderline in LblPreview.Font.Style;
{ Text Style }
GrpTextStyle.ItemIndex := Ord( LblPreview.TextStyle );
{ Shadow Options }
CbxShadowColor.SelectedColor := LblPreview.ShadowColor;
TrkShadow.Position := LblPreview.ShadowDepth;
{ Rotation Options }
TrkAngle.Position := LblPreview.Angle;
end; {= TRzLabelEditDlg.UpdateControls =}
procedure TFrmLabel.EdtCaptionChange(Sender: TObject);
begin
LblPreview.Caption := EdtCaption.Text;
end;
procedure TFrmLabel.CbxFontsChange(Sender: TObject);
begin
LblPreview.Font.Name := CbxFonts.FontName;
end;
{= TRzLabelEditDlg.TrkPointSizeDrawTick =}
{= Owner draw method is used to display point values at each tick mark. =}
procedure TFrmLabel.TrkPointSizeDrawTick(TrackBar: TRzTrackBar;
Canvas: TCanvas; Location: TPoint; Index: Integer);
var
W : Integer;
begin
Canvas.Brush.Color := TrackBar.Color;
Canvas.Font.Name := 'Small Fonts';
Canvas.Font.Size := 7;
Canvas.Font.Style := [];
W := Canvas.TextWidth( PointSizes[ Index ] );
Canvas.TextOut( Location.X - (W div 2), 1, PointSizes[ Index ] );
end;
procedure TFrmLabel.TrkPointSizeChange(Sender: TObject);
begin
LblPreview.Font.Size := StrToInt( PointSizes[ TrkPointSize.Position ] );
end;
procedure TFrmLabel.ChkBoldClick(Sender: TObject);
begin
if ChkBold.Checked then
LblPreview.Font.Style := LblPreview.Font.Style + [ fsBold ]
else
LblPreview.Font.Style := LblPreview.Font.Style - [ fsBold ]
end;
procedure TFrmLabel.ChkItalicClick(Sender: TObject);
begin
if ChkItalic.Checked then
LblPreview.Font.Style := LblPreview.Font.Style + [ fsItalic ]
else
LblPreview.Font.Style := LblPreview.Font.Style - [ fsItalic ]
end;
procedure TFrmLabel.ChkStrikeoutClick(Sender: TObject);
begin
if ChkStrikeout.Checked then
LblPreview.Font.Style := LblPreview.Font.Style + [ fsStrikeout ]
else
LblPreview.Font.Style := LblPreview.Font.Style - [ fsStrikeout ]
end;
procedure TFrmLabel.ChkUnderlineClick(Sender: TObject);
begin
if ChkUnderline.Checked then
LblPreview.Font.Style := LblPreview.Font.Style + [ fsUnderline ]
else
LblPreview.Font.Style := LblPreview.Font.Style - [ fsUnderline ]
end;
procedure TFrmLabel.GrpTextStyleClick(Sender: TObject);
begin
LblPreview.TextStyle := TTextStyle( GrpTextStyle.ItemIndex );
TrkShadow.Enabled := LblPreview.TextStyle = tsShadow;
CbxShadowColor.Enabled := LblPreview.TextStyle = tsShadow;
end;
procedure TFrmLabel.TrkShadowChange(Sender: TObject);
begin
LblPreview.ShadowDepth := TrkShadow.Position;
end;
procedure TFrmLabel.CbxFontColorChange(Sender: TObject);
begin
LblPreview.Font.Color := CbxFontColor.SelectedColor;
end;
procedure TFrmLabel.CbxShadowColorChange(Sender: TObject);
begin
LblPreview.ShadowColor := CbxShadowColor.SelectedColor;
end;
procedure TFrmLabel.TrkAngleDrawTick(TrackBar: TRzTrackBar;
Canvas: TCanvas; Location: TPoint; Index: Integer);
var
W, Degree : Integer;
begin
if Chk15Degrees.Checked then
Degree := Index * 15
else
Degree := Index;
if ( Degree mod 90 ) = 0 then
begin
Canvas.Brush.Color := TrackBar.Color;
Canvas.Font.Name := 'Small Fonts';
Canvas.Font.Size := 7;
Canvas.Font.Style := [];
W := Canvas.TextWidth( IntToStr( Degree ) );
Canvas.TextOut( Location.X - (W div 2), 1, IntToStr( Degree ) );
end;
end;
procedure TFrmLabel.Chk15DegreesClick(Sender: TObject);
begin
if Chk15Degrees.Checked then
begin
TrkAngle.Position := TrkAngle.Position div 15;
TrkAngle.Max := 24;
end
else
begin
TrkAngle.Max := 360;
TrkAngle.Position := TrkAngle.Position * 15;
end;
end;
procedure TFrmLabel.TrkAngleChange(Sender: TObject);
var
Angle : Integer;
begin
if Chk15Degrees.Checked then
Angle := TrkAngle.Position * 15
else
Angle := TrkAngle.Position;
LblAngle.Caption := IntToStr( Angle ) + '░';
LblPreview.Angle := Angle;
{ CbxFonts.ItemIndex := CbxFonts.Items.IndexOf( LblPreview.Font.Name );}
CbxFonts.SelectedFont := LblPreview.Font;
end;
procedure TFrmLabel.PnlFontTabMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
with PnlStyleTab do
begin
SendToBack;
Top := PnlWorkspace.Top - 19;
end;
with PnlFontTab do
begin
BringToFront;
Top := PnlWorkspace.Top - 21;
end;
NbkFormat.PageIndex := 0;
end;
procedure TFrmLabel.PnlStyleTabMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
with PnlFontTab do
begin
SendToBack;
Top := PnlWorkspace.Top - 19;
end;
with PnlStyleTab do
begin
BringToFront;
Top := PnlWorkspace.Top - 21;
end;
NbkFormat.PageIndex := 1;
if Chk15Degrees.Checked then
TrkAngle.Position := LblPreview.Angle div 15
else
TrkAngle.Position := LblPreview.Angle;
end;
end.