mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-05 22:38:03 +02:00
cocoa: Implements basic TSpeedButton look
git-svn-id: trunk@49580 -
This commit is contained in:
parent
5497dfc55a
commit
726931d294
@ -67,7 +67,7 @@ type
|
||||
// Standard Tab
|
||||
// ===================================
|
||||
// TCDButton
|
||||
procedure DrawButton(ADest: TFPCustomCanvas; ASize: TSize;
|
||||
procedure DrawButton(ADest: TFPCustomCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDButtonStateEx); override;
|
||||
// TCDEdit
|
||||
procedure DrawEditBackground(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
@ -572,7 +572,7 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCDDrawerAndroid.DrawButton(ADest: TFPCustomCanvas; ASize: TSize;
|
||||
procedure TCDDrawerAndroid.DrawButton(ADest: TFPCustomCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDButtonStateEx);
|
||||
var
|
||||
lDest: TCanvas absolute ADest;
|
||||
|
@ -55,7 +55,7 @@ type
|
||||
// Standard Tab
|
||||
// ===================================
|
||||
// TCDButton
|
||||
procedure DrawButton(ADest: TFPCustomCanvas; ASize: TSize;
|
||||
procedure DrawButton(ADest: TFPCustomCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDButtonStateEx); override;
|
||||
// TCDEdit
|
||||
procedure DrawEditBackground(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
@ -83,7 +83,7 @@ type
|
||||
procedure DrawScrollBar(ADest: TCanvas; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDPositionedCStateEx); override;
|
||||
// TCDGroupBox
|
||||
procedure DrawGroupBox(ADest: TFPCustomCanvas; ASize: TSize;
|
||||
procedure DrawGroupBox(ADest: TFPCustomCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx); override;
|
||||
// TCDPanel
|
||||
procedure DrawPanel(ADest: TCanvas; ASize: TSize;
|
||||
@ -702,7 +702,7 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCDDrawerCommon.DrawButton(ADest: TFPCustomCanvas;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDButtonStateEx);
|
||||
ADestPos: TPoint; ASize: TSize; AState: TCDControlState; AStateEx: TCDButtonStateEx);
|
||||
var
|
||||
Str: string;
|
||||
lGlyphLeftSpacing: Integer = 0;
|
||||
@ -1275,7 +1275,7 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCDDrawerCommon.DrawGroupBox(ADest: TFPCustomCanvas;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx);
|
||||
ADestPos: TPoint; ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx);
|
||||
var
|
||||
FCaptionMiddle: integer = 0;
|
||||
lTextSize: TSize;
|
||||
|
@ -21,7 +21,7 @@ type
|
||||
procedure DrawExpandTriangle(ADest: TCanvas; ASize: TSize;
|
||||
AX, AY: Integer; AFacing: TCDControlStateFlag);
|
||||
//
|
||||
procedure DrawMacSquareButton(ADest: TFPCustomCanvas; ASize: TSize;
|
||||
procedure DrawMacSquareButton(ADest: TFPCustomCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDButtonStateEx);
|
||||
public
|
||||
function GetMeasures(AMeasureID: Integer): Integer; override;
|
||||
@ -29,7 +29,7 @@ type
|
||||
// Standard Tab
|
||||
// ===================================
|
||||
// TCDButton
|
||||
procedure DrawButton(ADest: TFPCustomCanvas; ASize: TSize;
|
||||
procedure DrawButton(ADest: TFPCustomCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDButtonStateEx); override;
|
||||
// ===================================
|
||||
// Common Controls Tab
|
||||
@ -108,7 +108,7 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCDDrawerMac.DrawMacSquareButton(ADest: TFPCustomCanvas;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDButtonStateEx);
|
||||
ADestPos: TPoint; ASize: TSize; AState: TCDControlState; AStateEx: TCDButtonStateEx);
|
||||
var
|
||||
lDest: TCanvas absolute ADest;
|
||||
Str: string;
|
||||
@ -117,6 +117,7 @@ var
|
||||
lFrameDark, lFrameMedDark, lFrameMedium, lFrameLight: TColor;
|
||||
lSelTop, lSelTopGrad, lSelBottomGrad, lSelBottom: TColor;
|
||||
lGradientTop, lGradientBottom: TColor;
|
||||
lPosX, lPosY: Integer;
|
||||
begin
|
||||
// Main body with gradient
|
||||
if csfSunken in AState then
|
||||
@ -129,7 +130,7 @@ begin
|
||||
lGradientTop := MAC_SQUARE_BUTTON_FOCUS_GRADIENT_TOP;
|
||||
lGradientBottom := MAC_SQUARE_BUTTON_FOCUS_GRADIENT_BOTTOM;
|
||||
end;
|
||||
lRect := Bounds(0, 0, ASize.cx, ASize.cy);
|
||||
lRect := Bounds(ADestPos.X, ADestPos.Y, ASize.cx, ASize.cy);
|
||||
lDest.GradientFill(lRect, lGradientTop, lGradientBottom, gdVertical);
|
||||
|
||||
// outter rectangle
|
||||
@ -139,27 +140,29 @@ begin
|
||||
lDest.Pen.Color := MAC_SQUARE_BUTTON_FOCUS_FRAME_OUTTER
|
||||
else
|
||||
lDest.Pen.Color := MAC_SQUARE_BUTTON_FRAME;
|
||||
ADest.Rectangle(0, 0, ASize.cx, ASize.cy);
|
||||
ADest.Rectangle(Bounds(ADestPos.X, ADestPos.Y, ASize.cx, ASize.cy));
|
||||
//ADest.Rectangle(1, 1, ASize.cx-1, ASize.cy-1);
|
||||
|
||||
// inner rectangle (only for focused)
|
||||
if (csfHasFocus in AState) and not (csfSunken in AState) then
|
||||
begin
|
||||
lDest.Pen.Color := MAC_SQUARE_BUTTON_FOCUS_FRAME_INNER;
|
||||
ADest.Rectangle(1, 1, ASize.cx-1, ASize.cy-1);
|
||||
ADest.Rectangle(Bounds(ADestPos.X+1, ADestPos.Y+1, ASize.cx-1, ASize.cy-1));
|
||||
//ADest.Rectangle(2, 2, ASize.cx-2, ASize.cy-2);
|
||||
//ADest.Rectangle(3, 3, ASize.cx-3, ASize.cy-3);
|
||||
end;
|
||||
|
||||
// Button text
|
||||
ADest.Font.Assign(AStateEx.Font);
|
||||
if AStateEx.Font <> nil then
|
||||
ADest.Font.Assign(AStateEx.Font);
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Pen.Style := psSolid;
|
||||
if (csfSunken in AState) then
|
||||
ADest.Font.FPColor := colWhite;
|
||||
Str := AStateEx.Caption;
|
||||
lDest.TextOut((ASize.cx - lDest.TextWidth(Str)) div 2,
|
||||
(ASize.cy - lDest.TextHeight(Str)) div 2, Str);
|
||||
lPosX := ADestPos.X + (ASize.cx - lDest.TextWidth(Str)) div 2;
|
||||
lPosX := ADestPos.Y + (ASize.cy - lDest.TextHeight(Str)) div 2;
|
||||
lDest.TextOut(lPosX, lPosY, Str);
|
||||
end;
|
||||
|
||||
function TCDDrawerMac.GetMeasures(AMeasureID: Integer): Integer;
|
||||
@ -172,10 +175,10 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCDDrawerMac.DrawButton(ADest: TFPCustomCanvas; ASize: TSize;
|
||||
procedure TCDDrawerMac.DrawButton(ADest: TFPCustomCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDButtonStateEx);
|
||||
begin
|
||||
DrawMacSquareButton(ADest, ASize, AState, AStateEx);
|
||||
DrawMacSquareButton(ADest, ADestPos, ASize, AState, AStateEx);
|
||||
end;
|
||||
|
||||
procedure TCDDrawerMac.DrawToolBarItem(ADest: TCanvas; ASize: TSize;
|
||||
|
@ -37,7 +37,7 @@ type
|
||||
// Standard Tab
|
||||
// ===================================
|
||||
// TCDButton
|
||||
procedure DrawButton(ADest: TFPCustomCanvas; ASize: TSize;
|
||||
procedure DrawButton(ADest: TFPCustomCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDButtonStateEx); override;
|
||||
// TCDEdit
|
||||
procedure DrawEditFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
@ -184,7 +184,7 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCDDrawerWinXP.DrawButton(ADest: TFPCustomCanvas;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDButtonStateEx);
|
||||
ADestPos: TPoint; ASize: TSize; AState: TCDControlState; AStateEx: TCDButtonStateEx);
|
||||
var
|
||||
lDest: TCanvas absolute ADest;
|
||||
Str: string;
|
||||
|
@ -927,7 +927,7 @@ begin
|
||||
lControlId := GetControlId();
|
||||
PrepareControlState;
|
||||
PrepareControlStateEx;
|
||||
FDrawer.DrawControl(ACanvas, lSize, lControlId, FState, FStateEx);
|
||||
FDrawer.DrawControl(ACanvas, Point(0, 0), lSize, lControlId, FState, FStateEx);
|
||||
end;
|
||||
|
||||
procedure TCDControl.MouseEnter;
|
||||
|
@ -336,7 +336,7 @@ type
|
||||
function GetClientArea(ADest: TCanvas; ASize: TSize; AControlId: TCDControlID;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx): TRect; virtual; abstract;
|
||||
// To set a different position to draw the control then (0, 0) use the window org of the canvas
|
||||
procedure DrawControl(ADest: TCanvas; ASize: TSize;
|
||||
procedure DrawControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AControl: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx);
|
||||
// General drawing routines. The ones using TFPCustomCanvas are reusable in LCL-CustomDrawn
|
||||
procedure DrawFocusRect(ADest: TFPCustomCanvas; ADestPos: TPoint; ASize: TSize); virtual; abstract;
|
||||
@ -355,7 +355,7 @@ type
|
||||
procedure DrawControl(ADest: TCanvas; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx); virtual; abstract;
|
||||
// TCDButton
|
||||
procedure DrawButton(ADest: TFPCustomCanvas; ASize: TSize;
|
||||
procedure DrawButton(ADest: TFPCustomCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDButtonStateEx); virtual; abstract;
|
||||
// TCDEdit
|
||||
procedure DrawEditBackground(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
@ -383,7 +383,7 @@ type
|
||||
procedure DrawScrollBar(ADest: TCanvas; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDPositionedCStateEx); virtual; abstract;
|
||||
// TCDGroupBox
|
||||
procedure DrawGroupBox(ADest: TFPCustomCanvas; ASize: TSize;
|
||||
procedure DrawGroupBox(ADest: TFPCustomCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx); virtual; abstract;
|
||||
// TCDPanel
|
||||
procedure DrawPanel(ADest: TCanvas; ASize: TSize;
|
||||
@ -703,20 +703,20 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCDDrawer.DrawControl(ADest: TCanvas; ASize: TSize;
|
||||
procedure TCDDrawer.DrawControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AControl: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx
|
||||
);
|
||||
begin
|
||||
case AControl of
|
||||
cidControl: DrawControl(ADest, ASize, AState, AStateEx);
|
||||
//
|
||||
cidButton: DrawButton(ADest, ASize, AState, TCDButtonStateEx(AStateEx));
|
||||
cidButton: DrawButton(ADest, ADestPos, ASize, AState, TCDButtonStateEx(AStateEx));
|
||||
cidEdit: DrawEdit(ADest, ASize, AState, TCDEditStateEx(AStateEx));
|
||||
cidCheckBox: DrawCheckBox(ADest, ASize, AState, AStateEx);
|
||||
cidRadioButton:DrawRadioButton(ADest, ASize, AState, AStateEx);
|
||||
cidComboBox: DrawComboBox(ADest, ASize, AState, TCDEditStateEx(AStateEx));
|
||||
cidScrollBar: DrawScrollBar(ADest, ASize, AState, TCDPositionedCStateEx(AStateEx));
|
||||
cidGroupBox: DrawGroupBox(ADest, ASize, AState, AStateEx);
|
||||
cidGroupBox: DrawGroupBox(ADest, ADestPos, ASize, AState, AStateEx);
|
||||
cidPanel: DrawPanel(ADest, ASize, AState, TCDPanelStateEx(AStateEx));
|
||||
//
|
||||
cidStaticText: DrawStaticText(ADest, ASize, AState, AStateEx);
|
||||
|
Loading…
Reference in New Issue
Block a user