Carbon intf: implemented TMemo.Alignment

* last panel of TStatusBar fills it to right

git-svn-id: trunk@12644 -
This commit is contained in:
tombo 2007-10-30 09:50:15 +00:00
parent b80c5aa87e
commit 236ee9a8bb
6 changed files with 94 additions and 30 deletions

View File

@ -935,8 +935,7 @@ begin
if Style = bvRaised then
begin
if OSError(GetThemeMetric(kThemeMetricPrimaryGroupBoxContentInset, D),
Self, SName, SGetThemeMetric) then D := 1;
D := GetCarbonThemeMetric(kThemeMetricPrimaryGroupBoxContentInset, 1);
// draw frame as group box
DrawInfo.version := 0;

View File

@ -163,7 +163,10 @@ type
procedure DestroyWidget; override;
public
procedure TextDidChange; override;
function SetTXNControl(Tag: TXNControlTag; const Data: TXNControlData): Boolean;
public
procedure SetAlignment(AAlignment: TAlignment);
procedure SetColor(const AColor: TColor); override;
procedure SetFont(const AFont: TFont); override;
procedure SetPasswordChar(AChar: Char); override;
@ -814,8 +817,7 @@ end;
------------------------------------------------------------------------------}
function TCarbonSpinEdit.UpDownThemeWidth: Integer;
begin
OSError(GetThemeMetric(kThemeMetricLittleArrowsWidth, Result),
Self, 'UpDownThemeWidth', SGetThemeMetric);
Result := GetCarbonThemeMetric(kThemeMetricLittleArrowsWidth, 13);
end;
{------------------------------------------------------------------------------
@ -824,8 +826,7 @@ end;
------------------------------------------------------------------------------}
function TCarbonSpinEdit.FocusRectThemeOutset: Integer;
begin
OSError(GetThemeMetric(kThemeMetricFocusRectOutset, Result),
Self, 'UpDownThemeWidth', SGetThemeMetric);
Result := GetCarbonThemeMetric(kThemeMetricFocusRectOutset, 4);
end;
{------------------------------------------------------------------------------
@ -1282,6 +1283,45 @@ begin
DeliverMessage(LCLObject, Msg);
end;
{------------------------------------------------------------------------------
Method: TCarbonMemo.SetTXNControl
Params: Tag - Tag
Data - Tag data
Sets the control data of TXN object in Carbon interface
------------------------------------------------------------------------------}
function TCarbonMemo.SetTXNControl(Tag: TXNControlTag;
const Data: TXNControlData): Boolean;
begin
Result := False;
if OSError(TXNSetTXNObjectControls(HITextViewGetTXNObject(ControlRef(Widget)),
False, 1, @Tag, @Data),
Self, 'SetTXNControl', SSetTXNControls) then Exit;
Result := True;
end;
{------------------------------------------------------------------------------
Method: TCarbonMemo.SetAlignment
Params: AAlignment - New alignment
Sets the alignment of memo in Carbon interface
------------------------------------------------------------------------------}
procedure TCarbonMemo.SetAlignment(AAlignment: TAlignment);
var
Data: TXNControlData;
begin
case AAlignment of
taLeftJustify: Data.uValue := UInt32(kTXNFlushLeft);
taRightJustify: Data.uValue := UInt32(kTXNFlushRight);
taCenter: Data.uValue := UInt32(kTXNCenter);
end;
SetTXNControl(kTXNJustificationTag, Data);
Invalidate;
end;
{------------------------------------------------------------------------------
Method: TCarbonMemo.SetColor
Params: AColor - New color
@ -1368,19 +1408,14 @@ end;
------------------------------------------------------------------------------}
procedure TCarbonMemo.SetReadOnly(AReadOnly: Boolean);
var
Tag: TXNControlTag;
Data: TXNControlData;
begin
Tag := kTXNNoUserIOTag;
if AReadOnly then
Data.uValue := UInt32(kTXNReadOnly)
else
Data.uValue := UInt32(kTXNReadWrite);
OSError(
TXNSetTXNObjectControls(HITextViewGetTXNObject(ControlRef(Widget)),
False, 1, @Tag, @Data),
Self, 'SetReadOnly', SSetTXNControls);
SetTXNControl(kTXNNoUserIOTag, Data);
end;
{------------------------------------------------------------------------------
@ -1391,20 +1426,14 @@ end;
------------------------------------------------------------------------------}
procedure TCarbonMemo.SetWordWrap(AWordWrap: Boolean);
var
Tag: TXNControlTag;
Data: TXNControlData;
begin
Tag := kTXNWordWrapStateTag;
if AWordWrap then
Data.uValue := UInt32(kTXNAutoWrap)
else
Data.uValue := UInt32(kTXNNoAutoWrap);
OSError(
TXNSetTXNObjectControls(HITextViewGetTXNObject(ControlRef(Widget)),
False, 1, @Tag, @Data),
Self, 'SetWordWrap', SSetTXNControls);
SetTXNControl(kTXNWordWrapStateTag, Data);
Invalidate;
end;

View File

@ -943,7 +943,7 @@ begin
begin
Panel := TPanel.Create(LCLObject);
Panel.Visible := False;
Panel.Anchors := [akLeft, akTop, akBottom];
Panel.Height := LCLObject.Height;
Panel.Parent := LCLObject;
@ -963,6 +963,15 @@ begin
Panel.Alignment := StatusBar.Panels[I].Alignment;
Panel.BevelOuter := TPanelBevel(StatusBar.Panels[I].Bevel);
end;
// fit last panel
if I < StatusBar.Panels.Count - 1 then
Panel.Anchors := [akLeft, akTop, akBottom]
else
begin
Panel.Width := StatusBar.Width - X;
Panel.Anchors := [akLeft, akRight, akTop, akBottom];
end;
end;
Panel.Show;

View File

@ -72,6 +72,8 @@ function FontStyleToQDStyle(const AStyle: TFontStyles): FPCMacOSAll.Style;
procedure FillStandardDescription(out Desc: TRawImageDescription);
function GetCarbonThemeMetric(Metric: ThemeMetric; DefaultValue: Integer = 0): Integer;
function CreateCustomHIView(const ARect: HIRect): HIViewRef;
const
@ -471,6 +473,18 @@ begin
Desc.MaskShift := 0;
end;
{------------------------------------------------------------------------------
Name: GetCarbonThemeMetric
Params: Metric - Theme metric
DefaultValue
Returns: Theme metric value or default value if fails
------------------------------------------------------------------------------}
function GetCarbonThemeMetric(Metric: ThemeMetric; DefaultValue: Integer): Integer;
begin
if OSError(GetThemeMetric(Metric, Result),
'GetCarbonThemeMetric', 'GetThemeMetric') then Result := DefaultValue;
end;
{------------------------------------------------------------------------------
Name: CreateCustomHIView
Params: ARect - Bounds rect

View File

@ -1632,8 +1632,7 @@ begin
case NIndex of
SM_CYHSCROLL, SM_CXVSCROLL:
OSError(GetThemeMetric(kThemeMetricScrollBarWidth, Result),
Self, 'GetSystemMetrics', SGetThemeMetric);
Result := GetCarbonThemeMetric(kThemeMetricScrollBarWidth);
SM_CXSCREEN,
SM_CXVIRTUALSCREEN : Result := CGDisplayPixelsWide(CGMainDisplayID);
SM_CYSCREEN,

View File

@ -163,6 +163,7 @@ type
class function GetStrings(const ACustomMemo: TCustomMemo): TStrings; override;
class procedure AppendText(const ACustomMemo: TCustomMemo; const AText: string); override;
class procedure SetAlignment(const ACustomMemo: TCustomMemo; const AAlignment: TAlignment); override;
class procedure SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle); override;
class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); override;
end;
@ -659,12 +660,10 @@ begin
Self,SName,'GetDataBrowserHasScrollBars')
then exit;
if aVertical then
begin
if OSError(
GetThemeMetric(kThemeMetricScrollBarWidth,scrollwidth),
Self,SName,'GetThemeMetric')
then exit;
scrollwidth := GetCarbonThemeMetric(kThemeMetricScrollBarWidth, 10);
end
else scrollwidth:=0;
@ -999,15 +998,30 @@ begin
end;
end;
{------------------------------------------------------------------------------
Method: TCarbonWSCustomMemo.SetAlignment
Params: ACustomMemo - LCL custom memo
AAlignment - New alignment
Sets the alignment of memo in Carbon interface
------------------------------------------------------------------------------}
class procedure TCarbonWSCustomMemo.SetAlignment(const ACustomMemo: TCustomMemo;
const AAlignment: TAlignment);
begin
if not CheckHandle(ACustomMemo, Self, 'SetAlignment') then Exit;
TCarbonMemo(ACustomMemo.Handle).SetAlignment(AAlignment);
end;
{------------------------------------------------------------------------------
Method: TCarbonWSCustomMemo.SetScrollbars
Params: ACustomEdit - LCL custom memo
Params: ACustomMemo - LCL custom memo
NewScrollbars - New scrollbars style
Sets the new scrollbars style of memo in Carbon interface
------------------------------------------------------------------------------}
class procedure TCarbonWSCustomMemo.SetScrollbars(
const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle);
class procedure TCarbonWSCustomMemo.SetScrollbars(const ACustomMemo: TCustomMemo;
const NewScrollbars: TScrollStyle);
begin
if not CheckHandle(ACustomMemo, Self, 'SetScrollbars') then Exit;