diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2013-12-22 23:36:23 +0000 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2013-12-22 23:36:23 +0000 |
commit | b5a9e3c70f3608c53f8ed4f14845991dfb3036a0 (patch) | |
tree | 10891cd8dfe44461b6e2a4515cdb978a9a0fdc19 | |
parent | f77e641113a5a0d785e26d842766be9ab16832d8 (diff) | |
download | fpGUI-b5a9e3c70f3608c53f8ed4f14845991dfb3036a0.tar.xz |
Adds 2 new themes to the fpGUI framework.
All are 'dark' themes, but with various looks and color variations.
Thanks to Rochdi Abdelilah (aka ROCABDEL) for the fantastic contribution.
-rw-r--r-- | src/corelib/gdi/fpgui_toolkit.lpk | 10 | ||||
-rw-r--r-- | src/corelib/gdi/fpgui_toolkit.pas | 3 | ||||
-rw-r--r-- | src/corelib/x11/fpgui_toolkit.lpk | 12 | ||||
-rw-r--r-- | src/corelib/x11/fpgui_toolkit.pas | 2 | ||||
-rw-r--r-- | src/gui/fpg_style_carbon.pas | 250 | ||||
-rw-r--r-- | src/gui/fpg_style_plastic.pas | 376 |
6 files changed, 648 insertions, 5 deletions
diff --git a/src/corelib/gdi/fpgui_toolkit.lpk b/src/corelib/gdi/fpgui_toolkit.lpk index 967c273d..e71fdc29 100644 --- a/src/corelib/gdi/fpgui_toolkit.lpk +++ b/src/corelib/gdi/fpgui_toolkit.lpk @@ -31,7 +31,7 @@ <Description Value="fpGUI Toolkit"/> <License Value="LGPL 2 with static linking exception."/> <Version Major="1"/> - <Files Count="100"> + <Files Count="102"> <Item1> <Filename Value="..\stdimages.inc"/> <Type Value="Include"/> @@ -432,6 +432,14 @@ <Filename Value="..\fpg_dbugmsg.pas"/> <UnitName Value="fpg_dbugmsg"/> </Item100> + <Item101> + <Filename Value="..\..\gui\fpg_style_carbon.pas"/> + <UnitName Value="fpg_style_carbon"/> + </Item101> + <Item102> + <Filename Value="..\..\gui\fpg_style_plastic.pas"/> + <UnitName Value="fpg_style_plastic"/> + </Item102> </Files> <LazDoc Paths="..\..\..\docs\xml\corelib;..\..\..\docs\xml\corelib\x11;..\..\..\docs\xml\corelib\gdi;..\..\..\docs\xml\gui"/> <RequiredPkgs Count="1"> diff --git a/src/corelib/gdi/fpgui_toolkit.pas b/src/corelib/gdi/fpgui_toolkit.pas index 922109c3..6df1f67d 100644 --- a/src/corelib/gdi/fpgui_toolkit.pas +++ b/src/corelib/gdi/fpgui_toolkit.pas @@ -21,7 +21,8 @@ uses fpg_interface, fpg_editbtn, fpg_imgfmt_jpg, fpg_imgutils, fpg_stylemanager, fpg_style_win2k, fpg_style_motif, fpg_style_clearlooks, fpg_style_bluecurve, fpg_style_bitmap, fpg_readonly, fpg_imgfmt_png, U_Command, U_Pdf, U_Report, - U_ReportImages, U_Visu, fpg_trayicon, Agg2D, fpg_dbugintf, fpg_dbugmsg; + U_ReportImages, U_Visu, fpg_trayicon, Agg2D, fpg_dbugintf, fpg_dbugmsg, + fpg_style_carbon, fpg_style_plastic; implementation diff --git a/src/corelib/x11/fpgui_toolkit.lpk b/src/corelib/x11/fpgui_toolkit.lpk index d3d468b9..72c835c3 100644 --- a/src/corelib/x11/fpgui_toolkit.lpk +++ b/src/corelib/x11/fpgui_toolkit.lpk @@ -1,4 +1,4 @@ -<?xml version="1.0"?> +<?xml version="1.0" encoding="UTF-8"?> <CONFIG> <Package Version="4"> <Name Value="fpgui_toolkit"/> @@ -29,7 +29,7 @@ <Description Value="fpGUI Toolkit"/> <License Value="LGPL 2 with static linking exception."/> <Version Major="1"/> - <Files Count="102"> + <Files Count="104"> <Item1> <Filename Value="../stdimages.inc"/> <Type Value="Include"/> @@ -438,6 +438,14 @@ <Filename Value="../render/software/fpg_fontcache.pas"/> <UnitName Value="fpg_fontcache"/> </Item102> + <Item103> + <Filename Value="../../gui/fpg_style_carbon.pas"/> + <UnitName Value="fpg_style_carbon"/> + </Item103> + <Item104> + <Filename Value="../../gui/fpg_style_plastic.pas"/> + <UnitName Value="fpg_style_plastic"/> + </Item104> </Files> <LazDoc Paths="../../../docs/xml/corelib;../../../docs/xml/corelib/x11;../../../docs/xml/corelib/gdi;../../../docs/xml/gui"/> <RequiredPkgs Count="1"> diff --git a/src/corelib/x11/fpgui_toolkit.pas b/src/corelib/x11/fpgui_toolkit.pas index bdbe1a3f..d2c7d4f7 100644 --- a/src/corelib/x11/fpgui_toolkit.pas +++ b/src/corelib/x11/fpgui_toolkit.pas @@ -22,7 +22,7 @@ uses fpg_stylemanager, fpg_style_win2k, fpg_style_motif, fpg_style_clearlooks, fpg_style_bluecurve, fpg_style_bitmap, fpg_readonly, fpg_imgfmt_png, U_Command, U_Pdf, U_Report, U_ReportImages, U_Visu, fpg_trayicon, Agg2D, - fpg_dbugintf, fpg_dbugmsg, fpg_fontcache; + fpg_dbugintf, fpg_dbugmsg, fpg_fontcache, fpg_style_carbon, fpg_style_plastic; implementation diff --git a/src/gui/fpg_style_carbon.pas b/src/gui/fpg_style_carbon.pas new file mode 100644 index 00000000..6ad720ee --- /dev/null +++ b/src/gui/fpg_style_carbon.pas @@ -0,0 +1,250 @@ +{ + fpGUI - Free Pascal GUI Toolkit + + Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + Description: + Carbon fpGUI styles + + Author: Rochdi Abdelilah +} + +unit fpg_style_carbon; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, + fpg_main, + fpg_base; + +type + + TfpgCarbonStyle = class(TfpgStyle) + public + constructor Create; override; + { General } + procedure DrawControlFrame(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord); override; + function GetControlFrameBorders: TRect; override; + procedure DrawBevel(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; ARaised: boolean = True); override; + procedure DrawDirectionArrow(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; direction: TArrowDirection); override; + procedure DrawString(ACanvas: TfpgCanvas; x, y: TfpgCoord; AText: string; AEnabled: boolean = True); override; + procedure DrawFocusRect(ACanvas: TfpgCanvas; r: TfpgRect); override; + { Buttons } + procedure DrawButtonFace(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; AFlags: TfpgButtonFlags); override; + function GetButtonBorders: TRect; override; + function GetButtonShift: TPoint; override; + function HasButtonHoverEffect: boolean; override; + procedure DrawMenuBar(ACanvas: TfpgCanvas; r: TfpgRect; ABackgroundColor: TfpgColor); override; + procedure DrawMenuRow(ACanvas: TfpgCanvas; r: TfpgRect; AFlags: TfpgMenuItemFlags); override; + procedure DrawMenuItemSeparator(ACanvas: TfpgCanvas; r: TfpgRect); override; + end; + + +implementation + +uses + fpg_stylemanager; + +const + CarbonBaseColors: array [0..15] of TfpgColor = ( + $FF333333, $FF191919, $FF616161, + $FF202020, $FF474747, $FFC0C0C0, + $FF6E6E6E, $FF3399FF, $FFEAEAEA, + $FF2D2D2D, $FF494949, $FF24617A, + $FF353535, $FF434343, $FF313131, + $FF27546A); + +{ TfpgCarbonStyle } + +constructor TfpgCarbonStyle.Create; +begin + inherited Create; + fpgSetNamedColor(clWindowBackground, CarbonBaseColors[0]); + fpgSetNamedColor(clBoxColor, CarbonBaseColors[1]); + fpgSetNamedColor(clShadow1, CarbonBaseColors[2]); + fpgSetNamedColor(clShadow2, CarbonBaseColors[1]); + fpgSetNamedColor(clHilite1, CarbonBaseColors[3]); + fpgSetNamedColor(clHilite2, CarbonBaseColors[4]); + fpgSetNamedColor(clText1, CarbonBaseColors[5]); + fpgSetNamedColor(clText4, CarbonBaseColors[6]); + fpgSetNamedColor(clSelection, CarbonBaseColors[7]); + fpgSetNamedColor(clSelectionText, CarbonBaseColors[8]); + fpgSetNamedColor(clInactiveSel, CarbonBaseColors[7]); + fpgSetNamedColor(clInactiveSelText, CarbonBaseColors[8]); + fpgSetNamedColor(clScrollBar, CarbonBaseColors[9]); + fpgSetNamedColor(clButtonFace, CarbonBaseColors[0]); + fpgSetNamedColor(clListBox, CarbonBaseColors[1]); + fpgSetNamedColor(clGridLines, CarbonBaseColors[2]); + fpgSetNamedColor(clGridHeader, CarbonBaseColors[0]); + fpgSetNamedColor(clWidgetFrame, CarbonBaseColors[2]); + fpgSetNamedColor(clInactiveWgFrame, CarbonBaseColors[10]); + fpgSetNamedColor(clUnset, CarbonBaseColors[11]); + fpgSetNamedColor(clMenuText, CarbonBaseColors[5]); + fpgSetNamedColor(clMenuDisabled, CarbonBaseColors[0]); + fpgSetNamedColor(clHintWindow, CarbonBaseColors[0]); + fpgSetNamedColor(clGridSelection, CarbonBaseColors[7]); + fpgSetNamedColor(clGridSelectionText, CarbonBaseColors[8]); + fpgSetNamedColor(clGridInactiveSel, CarbonBaseColors[7]); + fpgSetNamedColor(clGridInactiveSelText, CarbonBaseColors[8]); + fpgSetNamedColor(clSplitterGrabBar, CarbonBaseColors[7]); +end; + +procedure TfpgCarbonStyle.DrawControlFrame(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord); +var + r: TfpgRect; +begin + r.SetRect(x, y, w, h); + ACanvas.SetColor(clShadow1); + ACanvas.SetLineStyle(1, lsSolid); + ACanvas.DrawRectangle(r); +end; + +function TfpgCarbonStyle.GetControlFrameBorders: TRect; +begin + Result := Rect(1, 1, 1, 1); +end; + +procedure TfpgCarbonStyle.DrawBevel(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; + ARaised: boolean); +begin + ACanvas.SetLineStyle(1, lsSolid); + ACanvas.GradientFill(fpgRect(x,y,w,h), clUnset, CarbonBaseColors[15], gdVertical); + ACanvas.SetColor(clHilite1); + ACanvas.DrawRectangle(x, y, w, h); +end; + +procedure TfpgCarbonStyle.DrawDirectionArrow(ACanvas: TfpgCanvas; + x, y, w, h: TfpgCoord; direction: TArrowDirection); +begin + ACanvas.SetColor(clBoxColor); + inherited DrawDirectionArrow(ACanvas, x + 1, y + 1, w, h, direction); +end; + +procedure TfpgCarbonStyle.DrawString(ACanvas: TfpgCanvas; x, y: TfpgCoord; + AText: string; AEnabled: boolean); +begin + if AText = '' then + Exit; + if not AEnabled then + ACanvas.SetTextColor(clText4) + else + ACanvas.SetTextColor(clText1); + ACanvas.DrawString(x, y, AText); +end; + +procedure TfpgCarbonStyle.DrawButtonFace(ACanvas: TfpgCanvas; + x, y, w, h: TfpgCoord; AFlags: TfpgButtonFlags); +var + r: TfpgRect; +begin + ACanvas.SetColor(clBoxColor); + ACanvas.SetLineStyle(1, lsSolid); + ACanvas.FillRectangle(x, y, w, h); + + r.SetRect(x + 1, y + 1, w - 2, h - 2); + + if (btfIsPressed in AFlags) then + begin + if (btfFlat in AFlags) or (btfHover in AFlags) then + ACanvas.SetColor(clHilite2) + else + begin + ACanvas.GradientFill(r, CarbonBaseColors[14], CarbonBaseColors[13], gdVertical); + ACanvas.SetColor(clInactiveWgFrame); + end; + end + else + begin + if btfHover in AFlags then + begin + ACanvas.GradientFill(r, clHilite2, CarbonBaseColors[12], gdVertical); + ACanvas.SetColor(clShadow1); + end + else + begin + if not ((btfFlat in AFlags) and not (btfIsPressed in AFlags)) then + begin + ACanvas.GradientFill(r, CarbonBaseColors[13], CarbonBaseColors[14], gdVertical); + ACanvas.SetColor(clInactiveWgFrame); + end + else if btfFlat in AFlags then + begin + ACanvas.SetColor(clButtonFace); + ACanvas.FillRectangle(r); + end; + end; + end; + + ACanvas.SetLineStyle(1, lsSolid); + ACanvas.DrawRectangle(r); + if btfIsDefault in AFlags then + begin + ACanvas.SetColor(clUnset); + ACanvas.DrawLine(2, 1, w - 2, 1); + ACanvas.DrawLine(2, h - 2, w - 2, h - 2); + end; +end; + +function TfpgCarbonStyle.GetButtonBorders: TRect; +begin + Result := Rect(2, 2, 2, 2); +end; + +function TfpgCarbonStyle.GetButtonShift: TPoint; +begin + Result := Point(0, 0); +end; + +function TfpgCarbonStyle.HasButtonHoverEffect: boolean; +begin + Result := True; +end; + +procedure TfpgCarbonStyle.DrawMenuRow(ACanvas: TfpgCanvas; r: TfpgRect; + AFlags: TfpgMenuItemFlags); +begin + inherited DrawMenuRow(ACanvas, r, AFlags); + if (mifSelected in AFlags) and not (mifSeparator in AFlags) then + ACanvas.GradientFill(r, clUnset, CarbonBaseColors[15], gdVertical); +end; + + +procedure TfpgCarbonStyle.DrawMenuBar(ACanvas: TfpgCanvas; r: TfpgRect; + ABackgroundColor: TfpgColor); +begin + ACanvas.Clear(clWindowBackground); + ACanvas.SetColor(clShadow1); + ACanvas.DrawLine(r.Left, r.Bottom-1, r.Right + 1, r.Bottom-1); + ACanvas.SetColor(clBoxColor); + ACanvas.DrawLine(r.Left, r.Bottom, r.Right + 1, r.Bottom); +end; + +procedure TfpgCarbonStyle.DrawMenuItemSeparator(ACanvas: TfpgCanvas; r: TfpgRect); +begin + ACanvas.SetColor(clBoxColor); + ACanvas.DrawLine(r.Left + 1, r.Top + 2, r.Right, r.Top + 2); +end; + +procedure TfpgCarbonStyle.DrawFocusRect(ACanvas: TfpgCanvas; r: TfpgRect); +begin + ACanvas.SetColor(clUnset); + ACanvas.SetLineStyle(1, lsSolid); + //InflateRect(r, 1, 1); + ACanvas.DrawRectangle(r); +end; + +initialization + fpgStyleManager.RegisterClass('Carbon', TfpgCarbonStyle); + +end. diff --git a/src/gui/fpg_style_plastic.pas b/src/gui/fpg_style_plastic.pas new file mode 100644 index 00000000..2bb43159 --- /dev/null +++ b/src/gui/fpg_style_plastic.pas @@ -0,0 +1,376 @@ +{ + fpGUI - Free Pascal GUI Toolkit + + Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + Description: + Plastic fpGUI styles + + Author: Rochdi Abdelilah +} + +{$define RegPlasticDark} +{$define RegPlasticDarkGray} +{$define RegPlasticMediumGray} +{$define RegPlasticLightGray} + +{$IF not defined(RegPlasticDark) and + not defined(RegPlasticDarkGray) and + not defined(RegPlasticMediumGray) and + not defined(RegPlasticLightGray))} + {$define RegPlasticDark} +{$ifend} + +unit fpg_style_plastic; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, + fpg_main, + fpg_base; + +type + TPlasticColors = array [0..22] of TfpgColor; + PPlasticColors = ^TPlasticColors; + + TfpgPlasticStyle = class(TfpgStyle) + protected + FPlasticColors: PPlasticColors; + procedure LoadPlasticColors; virtual; abstract; + public + constructor Create; override; + { General } + procedure DrawControlFrame(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord); override; overload; + procedure DrawBevel(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; ARaised: boolean = True); override; + procedure DrawDirectionArrow(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; direction: TArrowDirection); override; + procedure DrawString(ACanvas: TfpgCanvas; x, y: TfpgCoord; AText: string; AEnabled: boolean = True); override; + procedure DrawFocusRect(ACanvas: TfpgCanvas; r: TfpgRect); override; + { Buttons } + procedure DrawButtonFace(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; AFlags: TfpgButtonFlags); override; + function GetButtonBorders: TRect; override; + function GetButtonShift: TPoint; override; + function HasButtonHoverEffect: boolean; override; + procedure DrawMenuBar(ACanvas: TfpgCanvas; r: TfpgRect; ABackgroundColor: TfpgColor); override; + { Menus } + procedure DrawMenuItemSeparator(ACanvas: TfpgCanvas; r: TfpgRect); override; + end; + + { TfpgPlasticDarkStyle } + + {$IFDEF RegPlasticDark} + TfpgPlasticDarkStyle = class(TfpgPlasticStyle) + protected + procedure LoadPlasticColors; override; + end; + {$ENDIF} + + { TfpgPlasticDarkGrayStyle } + + {$IFDEF RegPlasticDarkGray} + TfpgPlasticDarkGrayStyle = class(TfpgPlasticStyle) + protected + procedure LoadPlasticColors; override; + end; + {$ENDIF} + + { TfpgPlasticMediumGrayStyle } + + {$IFDEF RegPlasticMediumGray} + TfpgPlasticMediumGrayStyle = class(TfpgPlasticStyle) + protected + procedure LoadPlasticColors; override; + end; + {$ENDIF} + + { TfpgPlasticLightGrayStyle } + + {$IFDEF RegPlasticLightGray} + TfpgPlasticLightGrayStyle = class(TfpgPlasticStyle) + protected + procedure LoadPlasticColors; override; + end; + {$ENDIF} + +implementation + +uses + fpg_stylemanager; + +const + {$IFDEF RegPlasticDark} + PlasticDarkColors: TPlasticColors = + ($FF343434, $FF222222, $FF141414, $FF454545, + $FFDDDDDD, $FF4B5367, $FF464646, $FF101010, + $FF4A669B, $FF373737, $FF303030, $FF1F1F1F, + $FF878787, $FF696969, $FF646464, $FF4E4E4E, + $FF262626, $FF1D1D1D, $FF3D3D3D, $FF272727, + $FF282828, $FF292929, $FF2A2A2A); + {$ENDIF} + {$IFDEF RegPlasticDarkGray} + PlasticDarkGrayColors: TPlasticColors = + ($FF535353, $FF3a3a3a, $FF282828, $FF6A6A6A, + $FFE5E5E5, $FF596678, $FF6A6A6A, $FF303030, + $FF506FAC, $FF575757, $FF4D4D4D, $FF333333, + $FFA0A0A0, $FF919191, $FF848484, $FF757575, + $FF3F3F3F, $FF373737, $FF626262, $FF444444, + $FF464646, $FF474747, $FF484848); + {$ENDIF} + {$IFDEF RegPlasticMediumGray} + PlasticMediumGrayColors: TPlasticColors = + ($FFB8B8B8, $FFFFFFFF, $FF707070, $FFCDCDCD, + $FF373737, $FFB7CDF9, $FFC8C8C8, $FF686868, + $FF74AAF3, $FFBBBBBB, $FFA9A9A9, $FF7F7F7F, + $FFFAFAFA, $FFF7F7F7, $FFFEFEFE, $FFE7E7E7, + $FF8D8D8D, $FF868686, $FFBDBDBD, $FF909090, + $FF919191, $FF929292, $FF959595); + {$ENDIF} + {$IFDEF RegPlasticLightGray} + PlasticLightGrayColors: TPlasticColors = + ($FFD6D6D6, $FFFFFFFF, $FF737373, $FFEBEBEB, + $FF373737, $FFB7CDF9, $FFE8E8E8, $FF7C7C7C, + $FF9BCAFA, $FFD9D9D9, $FFC3C3C3, $FF999999, + $FFFFFFFF, $FFF5F5F5, $FFFEFEFE, $FFE6E6E6, + $FFA9A9A9, $FFA0A0A0, $FFD7D7D7, $FFACACAC, + $FFAEAEAE, $FFB7B7B7, $FFBABABA); + {$ENDIF} + +{ TfpgPlasticLightGrayStyle } + +{$IFDEF RegPlasticLightGray} +procedure TfpgPlasticLightGrayStyle.LoadPlasticColors; +begin + FPlasticColors := @PlasticLightGrayColors; +end; +{$ENDIF} + +{ TfpgPlasticMediumGrayStyle } + +{$IFDEF RegPlasticMediumGray} +procedure TfpgPlasticMediumGrayStyle.LoadPlasticColors; +begin + FPlasticColors := @PlasticMediumGrayColors; +end; +{$ENDIF} + +{ TfpgPlasticDarkGrayStyle } + +{$IFDEF RegPlasticDarkGray} +procedure TfpgPlasticDarkGrayStyle.LoadPlasticColors; +begin + FPlasticColors := @PlasticDarkGrayColors; +end; +{$ENDIF} + +{ TfpgPlasticDarkStyle } + +{$IFDEF RegPlasticDark} +procedure TfpgPlasticDarkStyle.LoadPlasticColors; +begin + FPlasticColors := @PlasticDarkColors; +end; +{$ENDIF} + +{ TfpgPlasticStyle } + +constructor TfpgPlasticStyle.Create; +begin + inherited Create; + LoadPlasticColors; + fpgSetNamedColor(clWindowBackground, FPlasticColors^[0]); + fpgSetNamedColor(clBoxColor, FPlasticColors^[1]); + fpgSetNamedColor(clShadow1, FPlasticColors^[2]); + fpgSetNamedColor(clShadow2, FPlasticColors^[3]); + fpgSetNamedColor(clHilite1, FPlasticColors^[3]); + fpgSetNamedColor(clHilite2, FPlasticColors^[3]); + fpgSetNamedColor(clText1, FPlasticColors^[4]); + fpgSetNamedColor(clText4, FPlasticColors^[2]); + fpgSetNamedColor(clSelection, FPlasticColors^[5]); + fpgSetNamedColor(clSelectionText, FPlasticColors^[4]); + fpgSetNamedColor(clInactiveSel, FPlasticColors^[5]); + fpgSetNamedColor(clInactiveSelText, FPlasticColors^[4]); + fpgSetNamedColor(clScrollBar, FPlasticColors^[6]); + fpgSetNamedColor(clButtonFace, FPlasticColors^[0]); + fpgSetNamedColor(clListBox, FPlasticColors^[1]); + fpgSetNamedColor(clGridLines, FPlasticColors^[7]); + fpgSetNamedColor(clGridHeader, FPlasticColors^[0]); + fpgSetNamedColor(clWidgetFrame, FPlasticColors^[3]); + fpgSetNamedColor(clInactiveWgFrame, FPlasticColors^[2]); + fpgSetNamedColor(clMenuText, FPlasticColors^[4]); + fpgSetNamedColor(clHintWindow, FPlasticColors^[1]); + fpgSetNamedColor(clGridSelection, FPlasticColors^[5]); + fpgSetNamedColor(clGridSelectionText, FPlasticColors^[4]); + fpgSetNamedColor(clGridInactiveSel, FPlasticColors^[5]); + fpgSetNamedColor(clGridInactiveSelText, FPlasticColors^[4]); + fpgSetNamedColor(clSplitterGrabBar, FPlasticColors^[8]); +end; + +procedure TfpgPlasticStyle.DrawDirectionArrow(ACanvas: TfpgCanvas; + x, y, w, h: TfpgCoord; direction: TArrowDirection); +begin + ACanvas.SetColor(clText1); + inherited DrawDirectionArrow(ACanvas, x + 2, y + 1, w - 2, h - 3, direction); +end; + +procedure TfpgPlasticStyle.DrawBevel(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; + ARaised: boolean); +begin + DrawButtonFace(ACanvas, x, y, w, h, [btfIsPressed]); +end; + +procedure TfpgPlasticStyle.DrawString(ACanvas: TfpgCanvas; x, y: TfpgCoord; + AText: string; AEnabled: boolean); +var + lOldColor: TfpgColor; +begin + if AText = '' then + Exit; + lOldColor := ACanvas.TextColor; + if not AEnabled then + ACanvas.SetTextColor(clText4) + else + ACanvas.SetTextColor(clText1); + if lOldColor = clShadow1 then + ACanvas.SetTextColor(clHilite2); + ACanvas.DrawString(x, y, AText); + if lOldColor <> clBlue then + ACanvas.SetTextColor(lOldColor); +end; + +procedure TfpgPlasticStyle.DrawControlFrame(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord); +begin + ACanvas.SetLineStyle(1, lsSolid); + ACanvas.GradientFill(fpgRect(x, y, w, h), clWindowBackground, clScrollBar, gdVertical); + ACanvas.Pixels[x, y + h - 1] := FPlasticColors^[9]; + ACanvas.Pixels[x + w - 1, y + h - 1] := FPlasticColors^[9]; + ACanvas.SetColor(clGridLines); + ACanvas.DrawRectangle(fpgRect(x + 1, y + 1, w - 2, h - 2)); + ACanvas.Pixels[x + 1, y + 1] := FPlasticColors^[10]; + ACanvas.Pixels[x + w - 2, y + 1] := FPlasticColors^[10]; + ACanvas.Pixels[x + 1, y + h - 2] := FPlasticColors^[10]; + ACanvas.Pixels[x + w - 2, y + h - 2] := FPlasticColors^[10]; +end; + +procedure TfpgPlasticStyle.DrawFocusRect(ACanvas: TfpgCanvas; r: TfpgRect); +begin + ACanvas.SetLineStyle(1, lsSolid); + ACanvas.SetColor(clSplitterGrabBar); + ACanvas.DrawRectangle(r); + ACanvas.Pixels[r.Left, r.Top] := FPlasticColors^[9]; + ACanvas.Pixels[r.Left + 1, r.Top + 1] := clSplitterGrabBar; + ACanvas.Pixels[r.Width - 1, r.Top] := FPlasticColors^[9]; + ACanvas.Pixels[r.Width - 2, r.Top + 1] := clSplitterGrabBar; + ACanvas.Pixels[r.Left, r.Height - 1] := FPlasticColors^[9]; + ACanvas.Pixels[r.Left + 1, r.Height - 2] := clSplitterGrabBar; + ACanvas.Pixels[r.Width - 1, r.Height - 1] := FPlasticColors^[9]; + ACanvas.Pixels[r.Width - 2, r.Height - 2] := clSplitterGrabBar; +end; + +procedure TfpgPlasticStyle.DrawButtonFace(ACanvas: TfpgCanvas; + x, y, w, h: TfpgCoord; AFlags: TfpgButtonFlags); +var + r: TfpgRect; +begin + ACanvas.SetLineStyle(1, lsSolid); + r.SetRect(x, y, w, h); + DrawControlFrame(ACanvas, r); + r.SetRect(x + 2, y + 3, w - 4, h - 5); + + if (btfIsPressed in AFlags) then + begin + ACanvas.GradientFill(r, FPlasticColors^[16], FPlasticColors^[17], gdVertical); + ACanvas.SetColor(FPlasticColors^[11]); + end + else + begin + if btfHover in AFlags then + begin + ACanvas.GradientFill(r, FPlasticColors^[14], FPlasticColors^[15], gdVertical); + ACanvas.SetColor(FPlasticColors^[12]); + end + else + begin + if not ((btfFlat in AFlags) and not (btfIsPressed in AFlags)) then + begin + ACanvas.GradientFill(r, FPlasticColors^[15], FPlasticColors^[18], gdVertical); + ACanvas.SetColor(FPlasticColors^[13]); + end + else if btfFlat in AFlags then + begin + ACanvas.SetColor(clWindowBackground); + ACanvas.FillRectangle(r); + end; + end; + end; + if not (btfFlat in AFlags) then + begin + if (btfIsDefault in AFlags) and not (btfIsPressed in AFlags) and + not (btfHasFocus in AFlags) then + ACanvas.SetColor(clSplitterGrabBar); + ACanvas.DrawLine(x + 2, y + 2, x + w - 2, y + 2); + end; + ACanvas.Pixels[x + 2, y + 2] := FPlasticColors^[19]; + ACanvas.Pixels[x + w - 3, y + 2] := FPlasticColors^[20]; + ACanvas.Pixels[x + 2, y + h - 3] := FPlasticColors^[21]; + ACanvas.Pixels[x + w - 3, y + h - 3] := FPlasticColors^[22]; +end; + +function TfpgPlasticStyle.GetButtonBorders: TRect; +begin + Result := Rect(0, 0, 0, 0); +end; + +function TfpgPlasticStyle.GetButtonShift: TPoint; +begin + Result := Point(0, 0); +end; + +function TfpgPlasticStyle.HasButtonHoverEffect: boolean; +begin + Result := True; +end; + +procedure TfpgPlasticStyle.DrawMenuBar(ACanvas: TfpgCanvas; r: TfpgRect; + ABackgroundColor: TfpgColor); +begin + ACanvas.SetLineStyle(1, lsSolid); + ACanvas.SetColor(clWindowBackground); + ACanvas.FillRectangle(r); + ACanvas.SetColor(clShadow2); + ACanvas.DrawLine(r.Left, r.Top, r.Left + r.Right, r.Top); + DrawMenuItemSeparator(ACanvas, fpgRect(r.Left - 1, r.Height - 4, r.Width, r.Height)); +end; + +procedure TfpgPlasticStyle.DrawMenuItemSeparator(ACanvas: TfpgCanvas; r: TfpgRect); +begin + ACanvas.SetColor(clShadow1); + ACanvas.DrawLine(r.Left + 1, r.Top + 2, r.Right, r.Top + 2); + ACanvas.SetColor(clShadow2); + ACanvas.DrawLine(r.Left + 1, r.Top + 3, r.Right, r.Top + 3); +end; + + +initialization + {$IFDEF RegPlasticDark} + fpgStyleManager.RegisterClass('Plastic Dark', TfpgPlasticDarkStyle); + {$ENDIF} + {$IFDEF RegPlasticDarkGray} + fpgStyleManager.RegisterClass('Plastic Dark Gray', TfpgPlasticDarkGrayStyle); + {$ENDIF} + {$IFDEF RegPlasticMediumGray} + fpgStyleManager.RegisterClass('Plastic Medium Gray', TfpgPlasticMediumGrayStyle); + {$ENDIF} + {$IFDEF RegPlasticLightGray} + fpgStyleManager.RegisterClass('Plastic Light Gray', TfpgPlasticLightGrayStyle); + {$ENDIF} +end. |