customdrawncontrols: Adds disabled looks for button and edit and adds partial code for the spin

git-svn-id: trunk@35037 -
This commit is contained in:
sekelsenmat 2012-01-30 10:29:33 +00:00
parent 28fbd2b34c
commit 26d2cf7352
7 changed files with 135 additions and 15 deletions

View File

@ -116,6 +116,11 @@ type
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override; AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
procedure DrawTab(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; procedure DrawTab(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override; AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
// ===================================
// Misc Tab
// ===================================
procedure DrawSpinEdit(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDSpinStateEx); override;
end; end;
implementation implementation
@ -126,6 +131,10 @@ const
WIN2000_FRAME_GRAY = $0099A8AC; WIN2000_FRAME_GRAY = $0099A8AC;
WIN2000_FRAME_DARK_GRAY = $00646F71; WIN2000_FRAME_DARK_GRAY = $00646F71;
WIN2000_DISABLED_TEXT = WIN2000_FRAME_GRAY;
WIN2000_SELECTION_BACKGROUND = $00C56A31;
WIN2000_SCROLLBAR_BACKGROUND = $00ECF4F6; WIN2000_SCROLLBAR_BACKGROUND = $00ECF4F6;
WIN2000_PROGRESSBAR_BLUE = $00C56A31; WIN2000_PROGRESSBAR_BLUE = $00C56A31;
@ -680,12 +689,28 @@ begin
lTextOutPos.Y := (ASize.cy - ADest.TextHeight(Str)) div 2; lTextOutPos.Y := (ASize.cy - ADest.TextHeight(Str)) div 2;
ADest.Brush.Style := bsClear; ADest.Brush.Style := bsClear;
ADest.Pen.Style := psSolid; ADest.Pen.Style := psSolid;
if csfSunken in AState then if csfEnabled in AState then
begin begin
if csfSunken in AState then
begin
Inc(lTextOutPos.X);
Inc(lTextOutPos.Y);
end;
ADest.TextOut(lTextOutPos.X, lTextOutPos.Y, Str)
end
else
begin
// The disabled text is composed by a white shadow under it and a grey text
ADest.Font.Color := clWhite;
Inc(lTextOutPos.X); Inc(lTextOutPos.X);
Inc(lTextOutPos.Y); Inc(lTextOutPos.Y);
ADest.TextOut(lTextOutPos.X, lTextOutPos.Y, Str);
//
ADest.Font.Color := WIN2000_DISABLED_TEXT;
Dec(lTextOutPos.X);
Dec(lTextOutPos.Y);
ADest.TextOut(lTextOutPos.X, lTextOutPos.Y, Str);
end; end;
ADest.TextOut(lTextOutPos.X, lTextOutPos.Y, Str)
end; end;
procedure TCDDrawerCommon.DrawEditBackground(ADest: TCanvas; procedure TCDDrawerCommon.DrawEditBackground(ADest: TCanvas;
@ -751,7 +776,14 @@ var
lTextWidth: Integer; lTextWidth: Integer;
lControlTextLen: PtrInt; lControlTextLen: PtrInt;
lTextLeftSpacing, lTextRightSpacing, lTextTopSpacing, lTextBottomSpacing: Integer; lTextLeftSpacing, lTextRightSpacing, lTextTopSpacing, lTextBottomSpacing: Integer;
lTextColor: TColor;
begin begin
// Configure the text color
if csfEnabled in AState then
lTextColor := AStateEx.Font.Color
else
lTextColor := WIN2000_DISABLED_TEXT;
// Background // Background
DrawEditBackground(ADest, Point(0, 0), ASize, AState, AStateEx); DrawEditBackground(ADest, Point(0, 0), ASize, AState, AStateEx);
@ -759,6 +791,7 @@ begin
lControlTextLen := UTF8Length(AStateEx.Caption); lControlTextLen := UTF8Length(AStateEx.Caption);
ADest.Brush.Style := bsClear; ADest.Brush.Style := bsClear;
ADest.Font.Assign(AStateEx.Font); ADest.Font.Assign(AStateEx.Font);
ADest.Font.Color := lTextColor;
lTextLeftSpacing := GetMeasures(TCDEDIT_LEFT_TEXT_SPACING); lTextLeftSpacing := GetMeasures(TCDEDIT_LEFT_TEXT_SPACING);
lTextRightSpacing := GetMeasures(TCDEDIT_RIGHT_TEXT_SPACING); lTextRightSpacing := GetMeasures(TCDEDIT_RIGHT_TEXT_SPACING);
lTextTopSpacing := GetMeasures(TCDEDIT_TOP_TEXT_SPACING); lTextTopSpacing := GetMeasures(TCDEDIT_TOP_TEXT_SPACING);
@ -794,7 +827,7 @@ begin
// The selection background // The selection background
lVisibleText := UTF8Copy(lControlText, lSelLeftPos+1, lSelLength); lVisibleText := UTF8Copy(lControlText, lSelLeftPos+1, lSelLength);
lTextWidth := ADest.TextWidth(lVisibleText); lTextWidth := ADest.TextWidth(lVisibleText);
ADest.Brush.Color := clBlue; ADest.Brush.Color := WIN2000_SELECTION_BACKGROUND;
ADest.Brush.Style := bsSolid; ADest.Brush.Style := bsSolid;
ADest.Rectangle(lSelLeftPixelPos, lTextTopSpacing, lSelLeftPixelPos+lTextWidth, ASize.cy-lTextBottomSpacing); ADest.Rectangle(lSelLeftPixelPos, lTextTopSpacing, lSelLeftPixelPos+lTextWidth, ASize.cy-lTextBottomSpacing);
ADest.Brush.Style := bsClear; ADest.Brush.Style := bsClear;
@ -806,7 +839,7 @@ begin
// Text right of the selection // Text right of the selection
ADest.Brush.Color := clWhite; ADest.Brush.Color := clWhite;
ADest.Font.Color := AStateEx.Font.Color; ADest.Font.Color := lTextColor;
lVisibleText := UTF8Copy(lControlText, lSelLeftPos+lSelLength+1, lControlTextLen); lVisibleText := UTF8Copy(lControlText, lSelLeftPos+lSelLength+1, lControlTextLen);
ADest.TextOut(lSelLeftPixelPos, lTextTopSpacing, lVisibleText); ADest.TextOut(lSelLeftPixelPos, lTextTopSpacing, lVisibleText);
end; end;
@ -1605,6 +1638,12 @@ begin
end; end;
end; end;
procedure TCDDrawerCommon.DrawSpinEdit(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize; AState: TCDControlState; AStateEx: TCDSpinStateEx);
begin
end;
{ TCDListViewDrawerCommon } { TCDListViewDrawerCommon }
initialization initialization

View File

@ -215,6 +215,14 @@ type
CurStartLeftPos: Integer; CurStartLeftPos: Integer;
end; end;
TCDSpinStateEx = class(TCDPositionedCStateEx)
public
Min: integer;
Increment: integer;
FloatMin: Double;
FloatIncrement: Double;
end;
TCDControlID = ( TCDControlID = (
cidControl, cidControl,
// Standard // Standard
@ -363,6 +371,11 @@ type
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract; AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract;
procedure DrawTab(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; procedure DrawTab(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract; AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract;
// ===================================
// Misc Tab
// ===================================
procedure DrawSpinEdit(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDSpinStateEx); virtual; abstract;
end; end;
procedure RegisterDrawer(ADrawer: TCDDrawer; AStyle: TCDDrawStyle); procedure RegisterDrawer(ADrawer: TCDDrawer; AStyle: TCDDrawStyle);

View File

@ -6,6 +6,7 @@
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/> <MainUnit Value="0"/>
<ResourceType Value="res"/> <ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/> <Icon Value="0"/>
</General> </General>
<i18n> <i18n>

View File

@ -2,7 +2,7 @@ program cd_test_all;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
{$R *.res} //{$R *.res}
uses uses
{$IFDEF UNIX}{$IFDEF UseCThreads} {$IFDEF UNIX}{$IFDEF UseCThreads}

Binary file not shown.

View File

@ -10,10 +10,10 @@ object Form1: TForm1
LCLVersion = '0.9.31' LCLVersion = '0.9.31'
object comboControls: TComboBox object comboControls: TComboBox
Left = 80 Left = 80
Height = 27 Height = 21
Top = 12 Top = 12
Width = 136 Width = 136
ItemHeight = 0 ItemHeight = 13
ItemIndex = 0 ItemIndex = 0
Items.Strings = ( Items.Strings = (
'TCDMenu' 'TCDMenu'
@ -39,6 +39,7 @@ object Form1: TForm1
'TCDUpDown' 'TCDUpDown'
'TCDPageControl' 'TCDPageControl'
'TCDTabControl' 'TCDTabControl'
'TCDSpinEdit'
) )
OnChange = comboControlsChange OnChange = comboControlsChange
TabOrder = 0 TabOrder = 0
@ -60,7 +61,7 @@ object Form1: TForm1
Height = 240 Height = 240
Top = 40 Top = 40
Width = 463 Width = 463
PageIndex = 2 PageIndex = 23
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
TabOrder = 2 TabOrder = 2
TabStop = True TabStop = True
@ -132,6 +133,26 @@ object Form1: TForm1
TabOrder = 5 TabOrder = 5
TabStop = True TabStop = True
end end
object Button3: TButton
Left = 7
Height = 25
Top = 48
Width = 75
Caption = 'Disabled'
Enabled = False
TabOrder = 6
end
object CDButton7: TCDButton
Left = 232
Height = 25
Top = 88
Width = 75
Caption = 'Disabled'
DrawStyle = dsWin2000
Enabled = False
TabOrder = 7
TabStop = True
end
end end
object pageEdits: TPage object pageEdits: TPage
object CDEdit1: TCDEdit object CDEdit1: TCDEdit
@ -166,6 +187,24 @@ object Form1: TForm1
DrawStyle = dsWinXP DrawStyle = dsWinXP
Text = 'editWinXP' Text = 'editWinXP'
end end
object Edit2: TEdit
Left = 8
Height = 21
Top = 56
Width = 80
Enabled = False
TabOrder = 4
Text = 'disabled'
end
object CDEdit3: TCDEdit
Left = 224
Height = 25
Top = 26
Width = 80
DrawStyle = dsDefault
Enabled = False
Text = 'disabled'
end
end end
object pageEditMultiline: TPage object pageEditMultiline: TPage
object Memo1: TMemo object Memo1: TMemo
@ -331,16 +370,16 @@ object Form1: TForm1
Height = 19 Height = 19
Top = 47 Top = 47
Width = 93 Width = 93
DrawStyle = dsDefault
Caption = 'dsCommon' Caption = 'dsCommon'
DrawStyle = dsDefault
end end
object CDRadioButton1: TCDRadioButton object CDRadioButton1: TCDRadioButton
Left = 14 Left = 14
Height = 19 Height = 19
Top = 7 Top = 7
Width = 93 Width = 93
DrawStyle = dsCommon
Caption = 'dsCommon' Caption = 'dsCommon'
DrawStyle = dsCommon
TabStop = False TabStop = False
end end
object CDRadioButton3: TCDRadioButton object CDRadioButton3: TCDRadioButton
@ -348,9 +387,9 @@ object Form1: TForm1
Height = 19 Height = 19
Top = 27 Top = 27
Width = 93 Width = 93
Caption = 'dsCommon'
Checked = True Checked = True
DrawStyle = dsDefault DrawStyle = dsDefault
Caption = 'dsCommon'
end end
end end
end end
@ -471,8 +510,8 @@ object Form1: TForm1
Top = 13 Top = 13
Width = 100 Width = 100
AutoSize = True AutoSize = True
DrawStyle = dsCommon
Caption = 'dsCommon' Caption = 'dsCommon'
DrawStyle = dsCommon
end end
object CDGroupBox2: TCDGroupBox object CDGroupBox2: TCDGroupBox
Left = 279 Left = 279
@ -480,8 +519,8 @@ object Form1: TForm1
Top = 13 Top = 13
Width = 100 Width = 100
AutoSize = True AutoSize = True
DrawStyle = dsWinCE
Caption = 'dsWinCE' Caption = 'dsWinCE'
DrawStyle = dsWinCE
end end
end end
object pagePanels: TPage object pagePanels: TPage
@ -793,8 +832,8 @@ object Form1: TForm1
Height = 20 Height = 20
Top = 31 Top = 31
Width = 70 Width = 70
DrawStyle = dsCommon
Caption = 'dsCommon' Caption = 'dsCommon'
DrawStyle = dsCommon
end end
end end
object pageTrackBars: TPage object pageTrackBars: TPage
@ -1229,6 +1268,27 @@ object Form1: TForm1
TabIndex = 0 TabIndex = 0
end end
end end
object pageSpins: TPage
object SpinEdit1: TSpinEdit
Left = 13
Height = 21
Top = 24
Width = 85
TabOrder = 0
Value = 1
end
object FloatSpinEdit1: TFloatSpinEdit
Left = 13
Height = 21
Top = 104
Width = 85
Increment = 0.1
MaxValue = 100
MinValue = 0
TabOrder = 1
Value = 1.1
end
end
end end
object memoLog: TMemo object memoLog: TMemo
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner

View File

@ -6,7 +6,7 @@ interface
uses uses
Classes, SysUtils, FileUtil, customdrawncontrols, customdrawndrawers, Forms, Classes, SysUtils, FileUtil, customdrawncontrols, customdrawndrawers, Forms,
Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Buttons; Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Buttons, Spin;
type type
@ -16,12 +16,14 @@ type
BitBtn1: TBitBtn; BitBtn1: TBitBtn;
Button1: TButton; Button1: TButton;
Button2: TButton; Button2: TButton;
Button3: TButton;
CDButton1: TCDButton; CDButton1: TCDButton;
CDButton2: TCDButton; CDButton2: TCDButton;
CDButton3: TCDButton; CDButton3: TCDButton;
CDButton4: TCDButton; CDButton4: TCDButton;
CDButton5: TCDButton; CDButton5: TCDButton;
CDButton6: TCDButton; CDButton6: TCDButton;
CDButton7: TCDButton;
CDCheckBox1: TCDCheckBox; CDCheckBox1: TCDCheckBox;
CDCheckBox2: TCDCheckBox; CDCheckBox2: TCDCheckBox;
CDCheckBox3: TCDCheckBox; CDCheckBox3: TCDCheckBox;
@ -32,9 +34,14 @@ type
CDCheckBox8: TCDCheckBox; CDCheckBox8: TCDCheckBox;
CDEdit1: TCDEdit; CDEdit1: TCDEdit;
CDEdit2: TCDEdit; CDEdit2: TCDEdit;
CDEdit3: TCDEdit;
CDTabControl1: TCDTabControl; CDTabControl1: TCDTabControl;
Edit2: TEdit;
FloatSpinEdit1: TFloatSpinEdit;
pageSpins: TPage;
sbCommon1: TCDScrollBar; sbCommon1: TCDScrollBar;
sbCommon2: TCDScrollBar; sbCommon2: TCDScrollBar;
SpinEdit1: TSpinEdit;
TabControl1: TTabControl; TabControl1: TTabControl;
trackScrollBarPageSize: TCDTrackBar; trackScrollBarPageSize: TCDTrackBar;
CheckBox2: TCheckBox; CheckBox2: TCheckBox;