~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to lcl/interfaces/carbon/carbonthemes.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{ $Id: $
2
 
                  -----------------------------------------
 
1
{                 -----------------------------------------
3
2
                  CarbonThemes.pas  -  Carbon Theme support
4
3
                  -----------------------------------------
5
4
 
13
12
 
14
13
uses
15
14
  // rtl
16
 
  Types, Classes, SysUtils, Math,
 
15
  Types, Classes, SysUtils,
17
16
  // carbon bindings
18
17
  MacOSAll,
19
18
  // lcl
30
29
    function InitThemes: Boolean; override;
31
30
    function UseThemes: Boolean; override;
32
31
    function ThemedControlsEnabled: Boolean; override;
33
 
    procedure InternalDrawParentBackground(Window: HWND; Target: HDC; Bounds: PRect); override;
 
32
    procedure InternalDrawParentBackground({%H-}Window: HWND; {%H-}Target: HDC; {%H-}Bounds: PRect); override;
34
33
 
35
34
    function GetDrawState(Details: TThemedElementDetails): ThemeDrawState;
36
 
    function DrawButtonElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect): TRect;
37
 
    function DrawHeaderElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect): TRect;
38
 
    function DrawRebarElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect): TRect;
39
 
    function DrawToolBarElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect): TRect;
40
 
    function DrawTreeviewElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect): TRect;
 
35
    function DrawButtonElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; {%H-}ClipRect: PRect): TRect;
 
36
    function DrawComboBoxElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; {%H-}ClipRect: PRect): TRect;
 
37
    function DrawHeaderElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; {%H-}ClipRect: PRect): TRect;
 
38
    function DrawRebarElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; {%H-}ClipRect: PRect): TRect;
 
39
    function DrawToolBarElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; {%H-}ClipRect: PRect): TRect;
 
40
    function DrawTreeviewElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; {%H-}ClipRect: PRect): TRect;
41
41
  public
42
42
    procedure DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect); override;
43
 
    procedure DrawEdge(DC: HDC; Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal; AContentRect: PRect); override;
44
 
    procedure DrawIcon(DC: HDC; Details: TThemedElementDetails; const R: TRect; himl: HIMAGELIST; Index: Integer); override;
45
 
    procedure DrawText(DC: HDC; Details: TThemedElementDetails; const S: String; R: TRect; Flags, Flags2: Cardinal); override;
 
43
    procedure DrawEdge({%H-}DC: HDC; {%H-}Details: TThemedElementDetails; const {%H-}R: TRect; {%H-}Edge, {%H-}Flags: Cardinal; {%H-}AContentRect: PRect); override;
 
44
    procedure DrawIcon({%H-}DC: HDC; {%H-}Details: TThemedElementDetails; const {%H-}R: TRect; {%H-}himl: HIMAGELIST; {%H-}Index: Integer); override;
 
45
    procedure DrawText({%H-}DC: HDC; {%H-}Details: TThemedElementDetails; const {%H-}S: String; {%H-}R: TRect; {%H-}Flags, {%H-}Flags2: Cardinal); override;
46
46
 
47
 
    function ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect; override;
48
 
    function HasTransparentParts(Details: TThemedElementDetails): Boolean; override;
 
47
    function ContentRect({%H-}DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect; override;
 
48
    function HasTransparentParts({%H-}Details: TThemedElementDetails): Boolean; override;
49
49
    function GetDetailSize(Details: TThemedElementDetails): TSize; override;
50
50
    function GetOption(AOption: TThemeOption): Integer; override;
51
51
  end;
86
86
end;
87
87
 
88
88
{------------------------------------------------------------------------------
 
89
  Method:  TCarbonThemeServices.DrawComboBoxElement
 
90
  Params:  DC       - Carbon device context
 
91
           Details  - Details for themed element
 
92
           R        - Bounding rectangle
 
93
           ClipRect - Clipping rectangle
 
94
  Returns: ClientRect
 
95
 
 
96
  Draws a ComboBox element with native Carbon look
 
97
 ------------------------------------------------------------------------------}
 
98
function TCarbonThemeServices.DrawComboBoxElement(DC: TCarbonDeviceContext;
 
99
  Details: TThemedElementDetails; R: TRect; ClipRect: PRect): TRect;
 
100
var
 
101
  ButtonDrawInfo: HIThemeButtonDrawInfo;
 
102
  BoundsRect: HIRect;
 
103
  NewHeight: Integer;
 
104
  BtnWidth: Integer;
 
105
begin
 
106
  ButtonDrawInfo.version := 0;
 
107
  ButtonDrawInfo.State := GetDrawState(Details);
 
108
  ButtonDrawInfo.value := kThemeButtonOn;
 
109
  ButtonDrawInfo.adornment := kThemeAdornmentNone;
 
110
 
 
111
  BoundsRect := RectToCGRect(R);
 
112
 
 
113
  NewHeight := GetCarbonThemeMetric(kThemeMetricPopupButtonHeight);
 
114
  BtnWidth := GetCarbonThemeMetric(kThemeMetricComboBoxLargeDisclosureWidth);
 
115
  ButtonDrawInfo.kind := kThemeComboBox;
 
116
  if BoundsRect.size.height < NewHeight then begin
 
117
    NewHeight := GetCarbonThemeMetric(kThemeMetricSmallPopupButtonHeight);
 
118
    BtnWidth := GetCarbonThemeMetric(kThemeMetricComboBoxSmallDisclosureWidth);
 
119
    ButtonDrawInfo.kind := kThemeComboBoxSmall;
 
120
    end;
 
121
  if BoundsRect.size.height < NewHeight then begin
 
122
    NewHeight := GetCarbonThemeMetric(kThemeMetricMiniPopupButtonHeight);
 
123
    BtnWidth := GetCarbonThemeMetric(kThemeMetricComboBoxMiniDisclosureWidth);
 
124
    ButtonDrawInfo.kind := kThemeComboBoxMini;
 
125
    end;
 
126
 
 
127
  OSError(
 
128
    HIThemeDrawButton(BoundsRect, ButtonDrawInfo, DC.CGContext,
 
129
      kHIThemeOrientationNormal, nil),
 
130
    Self, 'DrawComboBoxElement', 'HIThemeDrawButton');
 
131
 
 
132
  BoundsRect.size.height := NewHeight + 1;
 
133
  BoundsRect.size.width := BoundsRect.size.width - BtnWidth;
 
134
  Result := CGRectToRect(BoundsRect);
 
135
end;
 
136
 
 
137
{------------------------------------------------------------------------------
89
138
  Method:  TCarbonThemeServices.DrawButtonElement
90
139
  Params:  DC       - Carbon device context
91
140
           Details  - Details for themed element
100
149
const
101
150
  ButtonMap: array[BP_PUSHBUTTON..BP_USERBUTTON] of ThemeButtonKind =
102
151
  (
103
 
{BP_PUSHBUTTON } kThemeBevelButtonSmall,
 
152
{BP_PUSHBUTTON } kThemeRoundedBevelButton,
104
153
{BP_RADIOBUTTON} kThemeRadioButton,
105
154
{BP_CHECKBOX   } kThemeCheckBox,
106
155
{BP_GROUPBOX   } kHIThemeGroupBoxKindPrimary, // ??
107
 
{BP_USERBUTTON } kThemeBevelButtonSmall
 
156
{BP_USERBUTTON } kThemeRoundedBevelButton
108
157
  );
109
158
var
110
159
  ButtonDrawInfo: HIThemeButtonDrawInfo;
153
202
function TCarbonThemeServices.DrawHeaderElement(DC: TCarbonDeviceContext;
154
203
  Details: TThemedElementDetails; R: TRect; ClipRect: PRect): TRect;
155
204
var
156
 
  HeaderDrawInfo: HiThemeHeaderDrawInfo;
 
205
  ButtonDrawInfo: HIThemeButtonDrawInfo;
157
206
  PaintRect: HIRect;
158
207
begin
159
 
  if (R.Bottom - R.Top = 0) or (R.Right - R.Left = 0) then
160
 
  begin
161
 
    Result := R;
162
 
    Exit;
163
 
  end;
 
208
  ButtonDrawInfo.version := 0;
 
209
  ButtonDrawInfo.State := GetDrawState(Details);
 
210
  ButtonDrawInfo.kind := kThemeBevelButtonSmall;//kThemeListHeaderButton;
 
211
  ButtonDrawInfo.adornment := kThemeAdornmentNone;
164
212
 
165
 
  HeaderDrawInfo.version := 0;
166
 
  HeaderDrawInfo.State := GetDrawState(Details);
167
 
  HeaderDrawInfo.kind := kHiThemeHeaderKindList;
168
213
  PaintRect := RectToCGRect(R);
169
214
 
170
215
  OSError(
171
 
    HIThemeDrawHeader(PaintRect, HeaderDrawInfo, DC.CGContext,
172
 
      kHIThemeOrientationNormal),
173
 
    Self, 'DrawHeaderElement', 'HIThemeDrawHeader');
174
 
    
 
216
    HIThemeDrawButton(PaintRect, ButtonDrawInfo, DC.CGContext,
 
217
      kHIThemeOrientationNormal, @PaintRect),
 
218
    Self, 'DrawButtonElement', 'HIThemeDrawButton');
 
219
 
175
220
  Result := CGRectToRect(PaintRect);
176
 
  InflateRect(Result, -2, -2);
177
221
end;
178
222
 
179
223
{------------------------------------------------------------------------------
290
334
    TVP_TREEITEM:
291
335
    begin
292
336
      b:=TCarbonBrush.Create(False);
293
 
      b.SetColor( ColorToRGB(clHighlight), True);
 
337
      case Details.State of
 
338
        TREIS_NORMAL: b.SetColor( ColorToRGB(clWindow), True);
 
339
        TREIS_HOT: b.SetColor( ColorToRGB(clHotLight), True);
 
340
        TREIS_SELECTED: b.SetColor( ColorToRGB(clHighlight), True);
 
341
        TREIS_DISABLED: b.SetColor( ColorToRGB(clWindow), True);
 
342
        TREIS_SELECTEDNOTFOCUS: b.SetColor( ColorToRGB(clBtnFace), True);
 
343
        TREIS_HOTSELECTED: b.SetColor( ColorToRGB(clHighlight), True);
 
344
      end;
294
345
      DC.FillRect(R, b);
295
346
      b.Free;
296
347
    end;
355
406
  Details: TThemedElementDetails; BoundingRect: TRect): TRect;
356
407
begin
357
408
  case Details.Element of
 
409
    teComboBox: Result := DrawComboBoxElement(DefaultContext, Details, BoundingRect, nil);
358
410
    teHeader: Result := DrawHeaderElement(DefaultContext, Details, BoundingRect, nil);
359
411
    teButton: Result := DrawButtonElement(DefaultContext, Details, BoundingRect, nil);
360
412
    teRebar: Result := DrawRebarElement(DefaultContext, Details, BoundingRect, nil);
396
448
  if CheckDC(DC, 'TCarbonThemeServices.DrawElement') then
397
449
  begin
398
450
    case Details.Element of
 
451
      teComboBox: DrawComboBoxElement(Context, Details, R, ClipRect);
399
452
      teButton: DrawButtonElement(Context, Details, R, ClipRect);
400
453
      teHeader: DrawHeaderElement(Context, Details, R, ClipRect);
401
454
      teRebar: DrawRebarElement(Context, Details, R, ClipRect);