5 uses Windows
, Messages
, Classes
, mckCtrls
, KOL
, Controls
, mirror
, KOLmdvPanel
, Graphics
;
9 TKOLmdvPanel
= class(TKOLPanel
)
11 FBevelOuter
: TBevelCut
;
12 FBevelInner
: TBevelCut
;
15 FBorderStyle
: TBorderStyle
;
17 procedure WMSize(var Message: TWMSize
); message WM_SIZE
;
18 procedure SetBevelInner(const Value
: TBevelCut
);
19 procedure SetBevelOuter(const Value
: TBevelCut
);
20 procedure SetBevelWidth(const Value
: Word);
21 procedure SetBorderWidth(const Value
: Word);
22 procedure SetBorderStyle(const Value
: TBorderStyle
);
24 procedure UpdateBorder
;
26 procedure Set_VA(const Value
: TVerticalAlign
); override;
27 function AdditionalUnits
: string; override;
28 procedure SetupConstruct( SL
: TStringList
; const AName
, AParent
, Prefix
: String ); override;
29 function SetupParams( const AName
, AParent
: String ): String; override;
31 procedure Paint
; override;
32 procedure CreateParams(var Params
: TCreateParams
); override;
34 constructor Create(AOwner
: TComponent
); override;
35 destructor Destroy
; override;
37 property BevelOuter
: TBevelCut read FBevelOuter write SetBevelOuter
;
38 property BevelInner
: TBevelCut read FBevelInner write SetBevelInner
;
39 property BevelWidth
: Word read FBevelWidth write SetBevelWidth
;
40 property BorderWidth
: Word read FBorderWidth write SetBorderWidth
;
41 property BorderStyle
: TBorderStyle read FBorderStyle write SetBorderStyle
;
43 property edgeStyle
: Boolean read FNone
;
44 property Border
: Boolean read FNone
;
55 RegisterComponents( 'KOL Additional', [TKOLmdvPanel
]);
60 function TKOLmdvPanel
.AdditionalUnits
: string;
62 Result
:= ', KOLmdvPanel';
65 constructor TKOLmdvPanel
.Create(AOwner
: TComponent
);
68 BevelOuter
:= bvRaised
;
73 Width
:= 105; Height
:= 105;
74 inherited edgeStyle
:= esNone
;
77 procedure TKOLmdvPanel
.CreateParams(var Params
: TCreateParams
);
78 const BorderStyles
: array[TBorderStyle
] of DWORD
= (0, WS_BORDER
);
80 inherited CreateParams(Params
);
83 Style
:= Style
and (not WS_BORDER
); ExStyle
:= ExStyle
and not WS_EX_CLIENTEDGE
;
84 Style
:= Style
or BorderStyles
[FBorderStyle
];
85 if NewStyleControls
and Ctl3D
and (FBorderStyle
= bsSingle
) then
87 Style
:= Style
and not WS_BORDER
;
88 ExStyle
:= ExStyle
or WS_EX_CLIENTEDGE
;
90 WindowClass
.style
:= WindowClass
.style
and not (CS_HREDRAW
or CS_VREDRAW
);
94 destructor TKOLmdvPanel
.Destroy
;
100 procedure Frame3D(Canvas
: TCanvas
; var Rect
: TRect
; TopColor
, BottomColor
: TColor
; Width
: Integer);
103 TopRight
, BottomLeft
: TPoint
;
109 BottomLeft
.X
:= Left
;
110 BottomLeft
.Y
:= Bottom
;
111 Pen
.Color
:= TopColor
;
112 PolyLine([BottomLeft
, TopLeft
, TopRight
]);
113 Pen
.Color
:= BottomColor
;
115 PolyLine([TopRight
, BottomRight
, BottomLeft
]);
120 Canvas
.Pen
.Width
:= 1;
121 Dec(Rect
.Bottom
); Dec(Rect
.Right
);
126 InflateRect(Rect
, -1, -1);
128 Inc(Rect
.Bottom
); Inc(Rect
.Right
);
131 procedure TKOLmdvPanel
.Paint
;
132 const Alignments
: array[TTextAlign
] of Longint = (DT_LEFT
, DT_RIGHT
, DT_CENTER
);
133 VAlignments
: array[TVerticalAlign
] of Longint = (DT_TOP
, DT_VCENTER
, DT_BOTTOM
);
136 TopColor
, BottomColor
: TColor
;
139 procedure AdjustColors(Bevel
: KOLmdvPanel
.TBevelCut
);
141 TopColor
:= clBtnHighlight
;
142 if Bevel
= KOLmdvPanel
.bvLowered
then TopColor
:= clBtnShadow
;
143 BottomColor
:= clBtnShadow
;
144 if Bevel
= KOLmdvPanel
.bvLowered
then BottomColor
:= clBtnHighlight
;
148 Rect
:= GetClientRect
;
149 if BevelOuter
<> KOLmdvPanel
.bvNone
then
151 AdjustColors(BevelOuter
);
152 Frame3D(Canvas
, Rect
, TopColor
, BottomColor
, BevelWidth
);
154 Frame3D(Canvas
, Rect
, Color
, Color
, BorderWidth
);
155 if BevelInner
<> KOLmdvPanel
.bvNone
then
157 AdjustColors(BevelInner
);
158 Frame3D(Canvas
, Rect
, TopColor
, BottomColor
, BevelWidth
);
162 Brush
.Color
:= Color
;
164 Brush
.Style
:= bsClear
;
165 PrepareCanvasFontForWYSIWIGPaint(Canvas
);
166 Flags
:= DT_EXPANDTABS
or DT_SINGLELINE
or VAlignments
[VerticalAlign
] or Alignments
[TextAlign
];
167 DrawText(Handle
, PChar(Caption
), -1, Rect
, Flags
);
171 procedure TKOLmdvPanel
.SetBevelInner(const Value
: KOLmdvPanel
.TBevelCut
);
173 FBevelInner
:= Value
;
179 procedure TKOLmdvPanel
.SetBevelOuter(const Value
: KOLmdvPanel
.TBevelCut
);
181 FBevelOuter
:= Value
;
187 procedure TKOLmdvPanel
.SetBevelWidth(const Value
: Word);
189 FBevelWidth
:= Value
;
195 procedure TKOLmdvPanel
.SetBorderStyle(const Value
: TBorderStyle
);
197 if FBorderStyle
<> Value
then
199 FBorderStyle
:= Value
;
206 procedure TKOLmdvPanel
.SetBorderWidth(const Value
: Word);
208 FBorderWidth
:= Value
;
214 procedure TKOLmdvPanel
.SetupConstruct(SL
: TStringList
; const AName
, AParent
, Prefix
: String);
216 SL
.Add( Prefix
+ AName
+ ' := PmdvPanel( New' + TypeName
+ '( ' + SetupParams( AName
, AParent
) + ' )' + GenerateTransparentInits
+ ');');
219 function TKOLmdvPanel
.SetupParams(const AName
, AParent
: String): String;
220 const EdgeStyles
: array[TEdgeStyle
] of String =('esRaised', 'esLowered', 'esNone');
221 BevelCuts
: array[TBevelCut
] of String =('bvNone', 'bvLowered', 'bvRaised', 'bvSpace');
222 BorderStyles
: array[TBorderStyle
] of String =('bsNone', 'bsSingle');
224 Result
:= AParent
+ ', ' + BevelCuts
[BevelOuter
] + ', ' +
225 BevelCuts
[BevelInner
] + ', ' + Int2Str(BevelWidth
) + ', ' +
226 BorderStyles
[BorderStyle
] + ', ' + Int2Str(BorderWidth
);
229 procedure TKOLmdvPanel
.Set_VA(const Value
: TVerticalAlign
);
231 FVerticalAlign
:= Value
;
236 procedure TKOLmdvPanel
.UpdateBorder
;
238 inherited Border
:= FBorderWidth
+ BevelWidth
*Ord(BevelOuter
<> bvNone
) + BevelWidth
*Ord(BevelInner
<> bvNone
);
242 procedure TKOLmdvPanel
.WMSize(var Message: TWMSize
);