Class TTitleBar (unit CapBar) |
Inherits from
TComponent
the titlebar-component itself
constructor Create(AOwner: TComponent);
- button and caption display } { procedures for componenthandling
***************************************************************
*** ***
*** procedures for the titlebar ***
*** ***
*****************************************************************} { constructor for the titlebar
procedure CreateButtonList;
create list of buttons
destructor Destroy;
destructor for the titlebar
procedure disable;
procedure enable;
make enable and disable possible by calling the methods.
procedure FormResize(Sender: TObject);
form is being resized
function GetCaptionRect: TRect;
get rectangle of captionarea
procedure SetFont(Value: TFont);
define font of caption
procedure SetShowBut(Value: boolean);
set display of buttons
procedure SetShowCap(Value: boolean);
set display of caption
procedure ShowButton(Cvs: TCanvas;Rec: TRect;But: TTitleButton);
draws the given button in the given rectangle on the given canvas
procedure DrawGradient(Active: boolean;Cvs: TCanvas;Rec: TRect;Lim: TLimit);
paint the grasdient in the given rectangle
function DrawTitleBar(Active: boolean):TRect;
paint the titlebar - our main work
function IsActive: boolean;
check, if form is active
procedure PaintCaption(Active: boolean;Cvs: TCanvas;Rec: TRect);
paint the caption in the given rectangle
procedure SetActCol1(Value: TColor);
define colors
procedure SetActCol2(Value: TColor);
procedure SetCapAlign(Value: TCapAlign);
define alignment of caption
procedure SetEnabled(Value: boolean);
set enabled
procedure SetInActCol1(Value: TColor);
procedure SetInActCol2(Value: TColor);
procedure SetInActTCol(Value: TColor);
procedure SetSteps(Value: integer);
set gradientsteps and check if the waves are more than 1/4 of
the steps.
procedure SetSwap(Value: boolean);
set gradientswapping
procedure SetWaves(Value: integer);
set gradientwaves and avoid setting them higher than 1/4 of
gradientsteps.
function ShowTitleButtons(Cvs: TCanvas;R: TRect): TLimit;
show buttons in captionbar
procedure WMGetMinMaxInfo(var Msg: TMessage);
***************************************************************
*** ***
*** messageprocessing for the ownerform ***
*** ***
*****************************************************************} { prevent the form from resizing over the given limits if
FLockSize is enabled
procedure WMNCActivate(var Msg: TMessage);
nca needs repainting
procedure WMNCHitTest(var Msg: TMessage);
check if a mousebutton-click hits one of our buttons
procedure WMNCLButtonDown(var Msg: TMessage);
left mousebutton pressed in nca
procedure WMNCLButtonUp(var Msg: TMessage);
left mousebutton released in nca - this tells us that the button
has pressed and the user wants to execute the defined action
procedure WMNCMouseMove(var Msg: TMessage);
mouse moved in nca
procedure WMNCPaint(var Msg: TMessage);
paint nonclientarea - this is the mainprogram that handles the
painting of the nca of the form.
procedure WndProc(var Msg: TMessage);
here are the message-handling-routines for the ownerform of
the component.
property Buttons : TList
property CaptionAlignment : TCapAlign
property CaptionInActive : TColor
property ColorActiveLeft : TColor
property ColorActiveRight : TColor
property ColorInActiveLeft : TColor
property ColorInActiveRight : TColor
property Enabled : boolean
the properties shown in the objectinspector
property Font : TFont
property FullGradient : boolean
property GradientSteps : integer
property GradientSwap : boolean
property GradientWaves : integer
property LockSize : boolean
property MaxHeight : integer
property MaxWidth : integer
property MinHeight : integer
property MinWidth : integer
property ShowButtons : boolean
property ShowCaption : boolean
event OnDisable : TNotifyEvent
event OnEnable : TNotifyEvent
FActCol1 : TColor;
FActCol2 : TColor;
FActivate : TNotifyEvent;
limits for formheight
FButtons : TList;
alignment of the caption
FCapAlign : TCapAlign;
FDeActivate : TNotifyEvent;
event to be executed when component becomes active
FEnabled : boolean;
pointer to original messagehandling of form
FFont : TFont;
color for inactive captiontext
FGradAll : boolean;
guess what? } { FGradAll defines if the gradient is drawn on the full width of
the tilebar or if it is limited to the space between the buttons.
FHOwner : hwnd;
form that contains the component
FInActCol1 : TColor;
colors of active form left/right
FInActCol2 : TColor;
FInActTCol : TColor;
colors for inactive form
FLockSize : boolean;
swap gradientcolors at each wave
FMaxHig : integer;
FMaxWid : integer;
FMinHig : integer;
limits for formwidth
FMinWid : integer;
limit size of form
FOwnerForm : TForm;
list of buttons
FPrevWndProc : TFarProc;
handle of form
FShowBut : boolean;
event to be executed when component becomes inactive
FShowCap : boolean;
FSteps : integer;
font for the caption (also
contains color for active caption
FSwap : boolean;
steps and waves of gradient,
see at beginning of file
FWaves : integer;
constructor Create(AOwner: TComponent);
button and caption display } { procedures for componenthandling
***************************************************************
*** ***
*** procedures for the titlebar ***
*** ***
*****************************************************************} { constructor for the titlebar
procedure CreateButtonList;
create list of buttons
destructor Destroy;
destructor for the titlebar
procedure disable;
procedure enable;
make enable and disable possible by calling the methods. defining
these procedures gives the programmer the possibility to type
TitleBar.Enable;
instead of
TitleBar.Enabled:=True;
it has the same effect, but i like the call of the procedure more
than setting the property. these procedures are not really
important.
procedure FormResize(Sender: TObject);
form is being resized
function GetCaptionRect: TRect;
get rectangle of captionarea
procedure SetFont(Value: TFont);
define font of caption
procedure SetShowBut(Value: boolean);
set display of buttons
procedure SetShowCap(Value: boolean);
set display of caption
procedure ShowButton(Cvs: TCanvas;Rec: TRect;But: TTitleButton);
draws the given button in the given rectangle on the given canvas
procedure DrawGradient(Active: boolean;Cvs: TCanvas;Rec: TRect;Lim: TLimit);
paint the grasdient in the given rectangle
function DrawTitleBar(Active: boolean):TRect;
paint the titlebar - our main work
function IsActive: boolean;
check, if form is active
procedure PaintCaption(Active: boolean;Cvs: TCanvas;Rec: TRect);
paint the caption in the given rectangle
procedure SetActCol1(Value: TColor);
define colors
procedure SetActCol2(Value: TColor);
procedure SetCapAlign(Value: TCapAlign);
define alignment of caption
procedure SetEnabled(Value: boolean);
set enabled
procedure SetInActCol1(Value: TColor);
procedure SetInActCol2(Value: TColor);
procedure SetInActTCol(Value: TColor);
procedure SetSteps(Value: integer);
set gradientsteps and check if the waves are more than 1/4 of
the steps. it makes no sense to make more waves than steps and
it doesn't look good if you define more waves than 1/4 of the
steps.
procedure SetSwap(Value: boolean);
set gradientswapping
procedure SetWaves(Value: integer);
set gradientwaves and avoid setting them higher than 1/4 of
gradientsteps.
function ShowTitleButtons(Cvs: TCanvas;R: TRect): TLimit;
show buttons in captionbar
procedure WMGetMinMaxInfo(var Msg: TMessage);
***************************************************************
*** ***
*** messageprocessing for the ownerform ***
*** ***
*****************************************************************} { prevent the form from resizing over the given limits if
FLockSize is enabled
procedure WMNCActivate(var Msg: TMessage);
nca needs repainting
procedure WMNCHitTest(var Msg: TMessage);
check if a mousebutton-click hits one of our buttons
procedure WMNCLButtonDown(var Msg: TMessage);
left mousebutton pressed in nca
procedure WMNCLButtonUp(var Msg: TMessage);
left mousebutton released in nca - this tells us that the button
has pressed and the user wants to execute the defined action
procedure WMNCMouseMove(var Msg: TMessage);
mouse moved in nca
procedure WMNCPaint(var Msg: TMessage);
paint nonclientarea - this is the mainprogram that handles the
painting of the nca of the form. and it is also the part where
Brad helped me a lot!
procedure WndProc(var Msg: TMessage);
here are the message-handling-routines for the ownerform of
the component. all procedures get the parameter TMessage because
this wyay it is possible to cover all messagehandling in one
main-procedure (WndProc)
messageprocessing for parent formular
property Buttons : TList
property CaptionAlignment : TCapAlign
property CaptionInActive : TColor
property ColorActiveLeft : TColor
property ColorActiveRight : TColor
property ColorInActiveLeft : TColor
property ColorInActiveRight : TColor
property Enabled : boolean
the properties shown in the objectinspector
property Font : TFont
property FullGradient : boolean
property GradientSteps : integer
property GradientSwap : boolean
property GradientWaves : integer
property LockSize : boolean
property MaxHeight : integer
property MaxWidth : integer
property MinHeight : integer
property MinWidth : integer
property ShowButtons : boolean
property ShowCaption : boolean
event OnDisable : TNotifyEvent
event OnEnable : TNotifyEvent
FActCol1 : TColor;
FActCol2 : TColor;
FActivate : TNotifyEvent;
limits for formheight
FButtons : TList;
alignment of the caption
FCapAlign : TCapAlign;
FDeActivate : TNotifyEvent;
event to be executed when component becomes active
FEnabled : boolean;
pointer to original messagehandling of form
FFont : TFont;
color for inactive captiontext
FGradAll : boolean;
guess what? } { FGradAll defines if the gradient is drawn on the full width of
the tilebar or if it is limited to the space between the buttons.
if you set it to true then the left color starts on the right
edge of the last button on the left side and the right color
is reached at the left edge of the first button on the right
side. confusing? just try it and see what changes.
FHOwner : hwnd;
form that contains the component
FInActCol1 : TColor;
colors of active form left/right
FInActCol2 : TColor;
FInActTCol : TColor;
colors for inactive form
FLockSize : boolean;
swap gradientcolors at each wave
FMaxHig : integer;
FMaxWid : integer;
FMinHig : integer;
limits for formwidth
FMinWid : integer;
limit size of form
FOwnerForm : TForm;
list of buttons
FPrevWndProc : TFarProc;
handle of form
FShowBut : boolean;
event to be executed when component becomes inactive
FShowCap : boolean;
FSteps : integer;
font for the caption (also
contains color for active caption
FSwap : boolean;
steps and waves of gradient,
see at beginning of file
FWaves : integer;