mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-21 22:59:27 +02:00
customdrawn: Small fixes
git-svn-id: trunk@33268 -
This commit is contained in:
parent
7affaf002f
commit
4cb152f986
@ -50,6 +50,7 @@ type
|
||||
// ===================================
|
||||
// Common Controls Tab
|
||||
// ===================================
|
||||
// TCDTrackBar
|
||||
procedure DrawTrackBar(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDTrackBarStateEx); override;
|
||||
// TCDCustomTabControl
|
||||
@ -90,8 +91,8 @@ begin
|
||||
TCDCONTROL_CAPTION_HEIGHT: Result := ADest.TextHeight('ŹÇ')+3;
|
||||
TCDCTABCONTROL_TAB_HEIGHT:
|
||||
begin
|
||||
if AStateEx.Font.Size = 0 then Result := 32
|
||||
else Result := AStateEx.Font.Size + 22;
|
||||
if AStateEx.Font.Size = 0 then Result := 22
|
||||
else Result := AStateEx.Font.Size + 14;
|
||||
end;
|
||||
TCDCTABCONTROL_TAB_WIDTH:
|
||||
begin
|
||||
@ -411,27 +412,32 @@ begin
|
||||
ADest.Brush.Color := AStateEx.ParentRGBColor;
|
||||
ADest.Rectangle(ADestPos.X, ADestPos.Y, ADestPos.X+ASize.cx, ADestPos.Y+ASize.cy);
|
||||
|
||||
CaptionHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx);
|
||||
|
||||
// frame
|
||||
if AStateEx.TabCount = 0 then CaptionHeight := 0
|
||||
else CaptionHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx);
|
||||
|
||||
// white lines in the left and top
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Pen.Color := ColorToRGB($009C9B91);
|
||||
|
||||
if AStateEx.TabCount = 0 then
|
||||
ADest.Rectangle(0, 0, ASize.cx - 2, ASize.cy - 2)
|
||||
else
|
||||
ADest.Rectangle(0, CaptionHeight, ASize.cx - 2, ASize.cy - 2);
|
||||
|
||||
ADest.Pen.Color := ColorToRGB($00BFCED0);
|
||||
ADest.Line(ASize.cx - 1, CaptionHeight + 1,
|
||||
ASize.cx - 1, ASize.cy - 1);
|
||||
ADest.Line(ASize.cx - 1, ASize.cy - 1, 1,
|
||||
ASize.cy - 1);
|
||||
ADest.Pen.Color := clWhite;
|
||||
ADest.Line(0, CaptionHeight, 0, ASize.cy-1);
|
||||
ADest.Pixels[1,1] := clWhite;
|
||||
ADest.Line(2, CaptionHeight, ASize.cx-1, CaptionHeight);
|
||||
// Grey line on the inside left and top
|
||||
ADest.Pen.Color := ColorToRGB($00E2EFF1);
|
||||
ADest.Line(1, CaptionHeight, 1, ASize.cy-2);
|
||||
ADest.Line(2, CaptionHeight+1, ASize.cx-2, CaptionHeight+1);
|
||||
// Dark grey line on the right and bottom
|
||||
ADest.Pen.Color := ColorToRGB($00646F71);
|
||||
ADest.Line(0, ASize.cy, ASize.cx, ASize.cy);
|
||||
ADest.Line(ASize.cx, ASize.cy, ASize.cx, CaptionHeight);
|
||||
// Grey line on the inside right and bottom
|
||||
ADest.Pen.Color := ColorToRGB($00646F71);
|
||||
ADest.Line(1, ASize.cy-1, ASize.cx-1, ASize.cy-1);
|
||||
ADest.Line(ASize.cx-1, ASize.cy-1, ASize.cx-1, CaptionHeight);
|
||||
|
||||
// Tabs
|
||||
ADest.Font.Name := AStateEx.Font.Name;
|
||||
ADest.Font.Size := AStateEx.Font.Size;
|
||||
ADest.Font.Assign(AStateEx.Font);
|
||||
DrawTabs(ADest, ADestPos, ASize, AState, AStateEx);
|
||||
end;
|
||||
|
||||
@ -473,20 +479,14 @@ var
|
||||
lTabWidth, lTabHeight, lTabTopPos: Integer;
|
||||
Points: array of TPoint;
|
||||
lCaption: String;
|
||||
lTabHeightCorrection: Integer = 0;
|
||||
begin
|
||||
IsSelected := AStateEx.TabIndex = AStateEx.CurTabIndex;
|
||||
|
||||
if IsSelected then
|
||||
begin
|
||||
lTabTopPos := 0;
|
||||
lTabHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx);
|
||||
end
|
||||
else
|
||||
begin
|
||||
lTabTopPos := 5;
|
||||
lTabHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx)-5;
|
||||
end;
|
||||
if not IsSelected then lTabHeightCorrection := 3;
|
||||
|
||||
lTabTopPos := lTabHeightCorrection;
|
||||
lTabHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx)-lTabHeightCorrection;
|
||||
lTabWidth := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_WIDTH, AState, AStateEx);
|
||||
|
||||
// Fill the area inside the outer border
|
||||
@ -502,7 +502,6 @@ begin
|
||||
ADest.Polygon(Points);
|
||||
|
||||
// Draw the outer border only in the top and right sides,
|
||||
// and bottom if unselected
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Pen.Color := ColorToRGB($009C9B91);
|
||||
@ -511,16 +510,27 @@ begin
|
||||
ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+5);
|
||||
ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+lTabHeight);
|
||||
|
||||
// If it is selected, add a selection frame
|
||||
if IsSelected then
|
||||
begin
|
||||
ADest.Pen.Color := ColorToRGB($00D6C731);
|
||||
// If it is selected, add a selection frame
|
||||
ADest.Pen.Color := clWhite;
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Rectangle(
|
||||
AStateEx.CurStartLeftPos+3, lTabTopPos+3,
|
||||
AStateEx.CurStartLeftPos+lTabWidth-5, lTabTopPos+lTabHeight-5
|
||||
);
|
||||
AStateEx.CurStartLeftPos+lTabWidth-5, lTabTopPos+lTabHeight-3);
|
||||
ADest.Pen.Color := clBlack;
|
||||
ADest.Pen.Style := psDot;
|
||||
ADest.Rectangle(
|
||||
AStateEx.CurStartLeftPos+3, lTabTopPos+3,
|
||||
AStateEx.CurStartLeftPos+lTabWidth-5, lTabTopPos+lTabHeight-3);
|
||||
|
||||
// and Clear the bottom area if selected
|
||||
ADest.Pen.Color := AStateEx.RGBColor;
|
||||
ADest.Line(AStateEx.CurStartLeftPos, lTabTopPos+lTabHeight,
|
||||
AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+lTabHeight);
|
||||
ADest.Line(AStateEx.CurStartLeftPos, lTabTopPos+lTabHeight-1,
|
||||
AStateEx.CurStartLeftPos+lTabWidth-2, lTabTopPos+lTabHeight-1);
|
||||
end;
|
||||
|
||||
// Now the text
|
||||
|
@ -23,6 +23,15 @@ type
|
||||
// TCDButton
|
||||
procedure DrawButton(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx); override;
|
||||
// TCDCustomTabControl
|
||||
procedure DrawCTabControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
|
||||
procedure DrawTabSheet(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
|
||||
procedure DrawTabs(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
|
||||
procedure DrawTab(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -88,6 +97,129 @@ begin
|
||||
(ASize.cy - ADest.TextHeight(Str)) div 2, Str);
|
||||
end;
|
||||
|
||||
procedure TCDDrawerWinCE.DrawCTabControl(ADest: TCanvas; ADestPos: TPoint;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
|
||||
var
|
||||
CaptionHeight: Integer;
|
||||
begin
|
||||
// Background
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Pen.Color := AStateEx.ParentRGBColor;
|
||||
ADest.Brush.Style := bsSolid;
|
||||
ADest.Brush.Color := AStateEx.ParentRGBColor;
|
||||
ADest.Rectangle(ADestPos.X, ADestPos.Y, ADestPos.X+ASize.cx, ADestPos.Y+ASize.cy);
|
||||
|
||||
CaptionHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx);
|
||||
|
||||
// frame
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Pen.Color := ColorToRGB($009C9B91);
|
||||
|
||||
if AStateEx.TabCount = 0 then
|
||||
ADest.Rectangle(0, 0, ASize.cx - 2, ASize.cy - 2)
|
||||
else
|
||||
ADest.Rectangle(0, CaptionHeight, ASize.cx - 2, ASize.cy - 2);
|
||||
|
||||
ADest.Pen.Color := ColorToRGB($00BFCED0);
|
||||
ADest.Line(ASize.cx - 1, CaptionHeight + 1,
|
||||
ASize.cx - 1, ASize.cy - 1);
|
||||
ADest.Line(ASize.cx - 1, ASize.cy - 1, 1,
|
||||
ASize.cy - 1);
|
||||
|
||||
// Tabs
|
||||
ADest.Font.Name := AStateEx.Font.Name;
|
||||
ADest.Font.Size := AStateEx.Font.Size;
|
||||
DrawTabs(ADest, ADestPos, ASize, AState, AStateEx);
|
||||
end;
|
||||
|
||||
procedure TCDDrawerWinCE.DrawTabSheet(ADest: TCanvas; ADestPos: TPoint;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
|
||||
begin
|
||||
ADest.Brush.Color := AStateEx.RGBColor;
|
||||
ADest.Brush.Style := bsSolid;
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Pen.Color := AStateEx.RGBColor;
|
||||
ADest.Rectangle(0, 0, ASize.cx, ASize.cy);
|
||||
end;
|
||||
|
||||
procedure TCDDrawerWinCE.DrawTabs(ADest: TCanvas; ADestPos: TPoint;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
|
||||
var
|
||||
IsPainting: Boolean = False;
|
||||
i: Integer;
|
||||
begin
|
||||
AStateEx.CurStartLeftPos := 0;
|
||||
for i := 0 to AStateEx.Tabs.Count - 1 do
|
||||
begin
|
||||
if i = AStateEx.LeftmostTabVisibleIndex then
|
||||
IsPainting := True;
|
||||
|
||||
if IsPainting then
|
||||
begin
|
||||
AStateEx.CurTabIndex := i;
|
||||
DrawTab(ADest, ADestPos, ASize, AState, AStateEx);
|
||||
AStateEx.CurStartLeftPos := AStateEx.CurStartLeftPos + GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_WIDTH, AState, AStateEx);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCDDrawerWinCE.DrawTab(ADest: TCanvas; ADestPos: TPoint;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
|
||||
var
|
||||
IsSelected: Boolean;
|
||||
lTabWidth, lTabHeight, lTabTopPos: Integer;
|
||||
Points: array of TPoint;
|
||||
lCaption: String;
|
||||
lTabHeightCorrection: Integer = 0;
|
||||
begin
|
||||
IsSelected := AStateEx.TabIndex = AStateEx.CurTabIndex;
|
||||
|
||||
if not IsSelected then lTabHeightCorrection := 3;
|
||||
|
||||
lTabTopPos := lTabHeightCorrection;
|
||||
lTabHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx)-lTabHeightCorrection;
|
||||
lTabWidth := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_WIDTH, AState, AStateEx);
|
||||
|
||||
// Fill the area inside the outer border
|
||||
ADest.Pen.Style := psClear;
|
||||
ADest.Brush.Style := bsSolid;
|
||||
ADest.Brush.Color := clWhite;
|
||||
SetLength(Points, 5);
|
||||
Points[0] := Point(AStateEx.CurStartLeftPos, lTabTopPos);
|
||||
Points[1] := Point(AStateEx.CurStartLeftPos+lTabWidth-5, lTabTopPos);
|
||||
Points[2] := Point(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+5);
|
||||
Points[3] := Point(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+lTabHeight);
|
||||
Points[4] := Point(AStateEx.CurStartLeftPos, lTabTopPos+lTabHeight);
|
||||
ADest.Polygon(Points);
|
||||
|
||||
// Draw the outer border only in the top and right sides,
|
||||
// and bottom if unselected
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Pen.Color := ColorToRGB($009C9B91);
|
||||
ADest.MoveTo(AStateEx.CurStartLeftPos+1, lTabTopPos);
|
||||
ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth-5, lTabTopPos);
|
||||
ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+5);
|
||||
ADest.LineTo(AStateEx.CurStartLeftPos+lTabWidth, lTabTopPos+lTabHeight);
|
||||
|
||||
// If it is selected, add a selection frame
|
||||
if IsSelected then
|
||||
begin
|
||||
ADest.Pen.Color := ColorToRGB($00D6C731);
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Rectangle(
|
||||
AStateEx.CurStartLeftPos+3, lTabTopPos+3,
|
||||
AStateEx.CurStartLeftPos+lTabWidth-5, lTabTopPos+lTabHeight-3
|
||||
);
|
||||
end;
|
||||
|
||||
// Now the text
|
||||
lCaption := AStateEx.Tabs.Strings[AStateEx.CurTabIndex];
|
||||
ADest.TextOut(AStateEx.CurStartLeftPos+5, lTabTopPos+5, lCaption);
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDrawer(TCDDrawerWinCE.Create, dsWinCE);
|
||||
end.
|
||||
|
@ -325,6 +325,7 @@ type
|
||||
FTabs: TStringList;
|
||||
FOnChanging: TNotifyEvent;
|
||||
FOnChange: TNotifyEvent;
|
||||
FOptions: TNoteBookOptions;
|
||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
|
||||
X, Y: integer); override;
|
||||
//procedure MouseMove(Shift: TShiftState; X, Y: integer); override;
|
||||
@ -333,12 +334,14 @@ type
|
||||
//procedure MouseLeave; override;
|
||||
procedure SetTabIndex(AValue: Integer); virtual;
|
||||
procedure SetTabs(AValue: TStringList);
|
||||
procedure SetOptions(AValue: TNoteBookOptions);
|
||||
protected
|
||||
FTabCState: TCDCTabControlStateEx;
|
||||
function GetControlId: TCDControlID; override;
|
||||
procedure CreateControlStateEx; override;
|
||||
procedure PrepareControlStateEx; override;
|
||||
procedure CorrectTabIndex();
|
||||
property Options: TNoteBookOptions read FOptions write SetOptions;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
@ -366,12 +369,10 @@ type
|
||||
|
||||
TCDPageControl = class(TCDCustomTabControl)
|
||||
private
|
||||
FOptions: TNoteBookOptions;
|
||||
function GetActivePage: TCDTabSheet;
|
||||
function GetPageCount: integer;
|
||||
function GetPageIndex: integer;
|
||||
procedure SetActivePage(Value: TCDTabSheet);
|
||||
procedure SetOptions(AValue: TNoteBookOptions);
|
||||
procedure SetPageIndex(Value: integer);
|
||||
procedure UpdateAllDesignerFlags;
|
||||
procedure UpdateDesignerFlags(APageIndex: integer);
|
||||
@ -396,7 +397,7 @@ type
|
||||
property Color;
|
||||
property Font;
|
||||
property PageIndex: integer read GetPageIndex write SetPageIndex;
|
||||
property Options: TNoteBookOptions read FOptions write SetOptions;
|
||||
property Options;
|
||||
property ParentColor;
|
||||
property ParentFont;
|
||||
property TabStop default True;
|
||||
@ -754,6 +755,13 @@ begin
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TCDCustomTabControl.SetOptions(AValue: TNoteBookOptions);
|
||||
begin
|
||||
if FOptions=AValue then Exit;
|
||||
FOptions:=AValue;
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
function TCDCustomTabControl.GetControlId: TCDControlID;
|
||||
begin
|
||||
Result := cidCTabControl;
|
||||
@ -772,6 +780,7 @@ begin
|
||||
FTabCState.Tabs := Tabs;
|
||||
FTabCState.TabIndex := TabIndex;
|
||||
FTabCState.TabCount := GetTabCount();
|
||||
FTabCState.Options := FOptions;
|
||||
end;
|
||||
|
||||
constructor TCDCustomTabControl.Create(AOwner: TComponent);
|
||||
@ -1478,12 +1487,6 @@ begin
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TCDPageControl.SetOptions(AValue: TNoteBookOptions);
|
||||
begin
|
||||
if FOptions=AValue then Exit;
|
||||
FOptions:=AValue;
|
||||
end;
|
||||
|
||||
procedure TCDPageControl.SetPageIndex(Value: integer);
|
||||
begin
|
||||
if (Value > -1) and (Value < FTabs.Count) then
|
||||
|
@ -7,7 +7,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, Types,
|
||||
// LCL for types
|
||||
Graphics;
|
||||
Graphics, ComCtrls;
|
||||
|
||||
const
|
||||
CDDRAWSTYLE_COUNT = 19;
|
||||
@ -118,6 +118,7 @@ type
|
||||
Tabs: TStringList; // Just a reference, don't Free
|
||||
TabIndex: Integer;
|
||||
TabCount: Integer;
|
||||
Options: TNoteBookOptions;
|
||||
// Used internally by the drawers
|
||||
CurTabIndex: Integer;// For Tab routines, obtain the index
|
||||
CurStartLeftPos: Integer;
|
||||
|
Loading…
Reference in New Issue
Block a user