- QT bindings updated to 1.43
- QT ThemeServices is working now. Can paint Buttons (w/wo Flat), CheckBox, RadioButton, Header

git-svn-id: trunk@11523 -
This commit is contained in:
paul 2007-07-16 09:26:28 +00:00
parent dcbce23a9c
commit 72d601e943
5 changed files with 9779 additions and 9445 deletions

File diff suppressed because it is too large Load Diff

View File

@ -163,8 +163,8 @@ end;
function TQtWidgetSet.CreateThemeServices: TThemeServices;
begin
// TODO: uncomment if you want to test TQtThemeServices
// Result := TQtThemeServices.Create;
Result := inherited CreateThemeServices;
Result := TQtThemeServices.Create;
//Result := inherited CreateThemeServices;
end;
function TQtWidgetSet.LCLPlatform: TLCLPlatform;

View File

@ -1336,13 +1336,18 @@ var
Mode: QtBGMode;
begin
result := 0;
if Widget<>nil then
if Widget <> nil then
begin
Mode := QPainter_BackgroundMode(Widget);
if Mode=QtOpaqueMode then result := OPAQUE
else result := TRANSPARENT;
if BkMode=OPAQUE then Mode := QtOpaqueMode
else Mode := QtTransparentMode;
if Mode = QtOpaqueMode then
result := OPAQUE
else
result := TRANSPARENT;
if BkMode = OPAQUE then
Mode := QtOpaqueMode
else
Mode := QtTransparentMode;
QPainter_SetBackgroundMode(Widget, Mode);
end;
end;

View File

@ -2,16 +2,6 @@ unit QtThemes;
{$mode objfpc}{$H+}
{
This theme services class is not ready. It waiting for some bindings. Without
them it is not useful.
Waiting for:
QStyleOption_setState
QStyleOption_setRect
... and other QStyleOption setters and getters
}
interface
uses
@ -55,7 +45,6 @@ type
function ThemedControlsEnabled: Boolean; override;
procedure InternalDrawParentBackground(Window: HWND; Target: HDC; Bounds: PRect); override;
function CreateQRect(R: TRect): QRectH;
function GetControlState(Details: TThemedElementDetails): QStyleState;
function GetDrawElement(Details: TThemedElementDetails): TQtDrawElement;
property Style: QStyleH read GetStyle;
@ -63,7 +52,7 @@ type
procedure DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect); override;
procedure DrawEdge(DC: HDC; Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal; AContentRect: PRect); override;
procedure DrawIcon(DC: HDC; Details: TThemedElementDetails; const R: TRect; himl: HIMAGELIST; Index: Integer); override;
procedure DrawText(DC: HDC; Details: TThemedElementDetails; const S: WideString; R: TRect; Flags, Flags2: Cardinal); override;
procedure DrawText(ACanvas: TPersistent; Details: TThemedElementDetails; const S: WideString; R: TRect; Flags, Flags2: Cardinal); override;
function ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect; override;
function HasTransparentParts(Details: TThemedElementDetails): Boolean; override;
@ -100,6 +89,7 @@ function TQtThemeServices.ContentRect(DC: HDC;
Details: TThemedElementDetails; BoundingRect: TRect): TRect;
begin
Result := BoundingRect;
InflateRect(Result, -1, -1);
end;
procedure TQtThemeServices.DrawEdge(DC: HDC;
@ -114,52 +104,60 @@ procedure TQtThemeServices.DrawElement(DC: HDC;
var
Context: TQtDeviceContext absolute DC;
opt: QStyleOptionH;
ARect: QRectH;
ARect: TRect;
Element: TQtDrawElement;
//QVariant: QVariantH;
Features: QStyleOptionButtonButtonFeatures;
begin
{$IFDEF USE_QT_4_3}
if (Context <> nil) then
begin
ARect := CreateQRect(R);
ARect := R;
Element := GetDrawElement(Details);
if (Element.DrawVariant = qdvControl) and (Element.ControlElement = QStyleCE_PushButton) then
begin
opt := QStyleOptionButton_create();
Features := 0;
if Details.Element = teToolBar then
Features := Features or QStyleOptionButtonFlat
else
Features := Features or QStyleOptionButtonNone;
case Element.DrawVariant of
qdvControl:
begin
if (Element.ControlElement in [QStyleCE_PushButton, QStyleCE_RadioButton, QStyleCE_CheckBox]) then
begin
opt := QStyleOptionButton_create();
Features := QStyleOptionButtonNone;
if Details.Element = teToolBar then
Features := Features or QStyleOptionButtonFlat;
QStyleOptionButton_setFeatures(QStyleOptionButtonH(opt), Features);
end
else
opt := QStyleOptionComplex_create(LongInt(QStyleOptionVersion), LongInt(QStyleOptionSO_Default));
{ // TODO: wait for bindings
QStyleOption_setState(opt, GetControlState(Details));
QStyleOption_setRect(opt, @ARect);
QStyleOptionButton_setButtonFeatures(opt, Features);
QStyleOption_setState(opt, GetControlState(Details));
QStyleOption_setRect(opt, ARect);
}
QStyle_drawControl(Style, Element.ControlElement, opt, Context.Widget);
QStyleOption_Destroy(opt);
end
else
if (Element.DrawVariant = qdvComplexControl) then
begin
if Element.ComplexElement = QStyleCC_ToolButton then
opt := QStyleOptionToolButton_create()
else
opt := QStyleOptionComplex_create(LongInt(QStyleOptionVersion), LongInt(QStyleOptionSO_Default));
{ // TODO: wait for bindings
QStyle_drawControl(Style, Element.ControlElement, opt, Context.Widget);
QStyleOption_Destroy(opt);
end;
qdvComplexControl:
begin
if Element.ComplexElement = QStyleCC_ToolButton then
opt := QStyleOptionToolButton_create()
else
opt := QStyleOptionComplex_create(LongInt(QStyleOptionVersion), LongInt(QStyleOptionSO_Default));
QStyleOption_setState(opt, GetControlState(Details));
QStyleOption_setRect(opt, ARect);
}
QStyle_drawComplexControl(Style, Element.ComplexElement, QStyleOptionComplexH(opt), Context.Widget);
QStyleOption_Destroy(opt);
QStyleOption_setState(opt, GetControlState(Details));
QStyleOption_setRect(opt, @ARect);
QStyle_drawComplexControl(Style, Element.ComplexElement, QStyleOptionComplexH(opt), Context.Widget);
QStyleOption_Destroy(opt);
end;
qdvPrimitive:
begin
opt := QStyleOption_create(Integer(QStyleOptionVersion), Integer(QStyleOptionSO_Default));
QStyleOption_setState(opt, GetControlState(Details));
QStyleOption_setRect(opt, @ARect);
QStyle_drawPrimitive(Style, Element.PrimitiveElement, opt, Context.Widget);
QStyleOption_Destroy(opt);
end;
end;
QRect_destroy(ARect);
end;
{$ELSE}
inherited;
{$ENDIF}
end;
procedure TQtThemeServices.DrawIcon(DC: HDC;
@ -169,6 +167,19 @@ begin
end;
procedure TQtThemeServices.DrawText(ACanvas: TPersistent;
Details: TThemedElementDetails; const S: WideString; R: TRect; Flags,
Flags2: Cardinal);
begin
with TCanvas(ACanvas) do
begin
WidgetSet.SetBkMode(Handle, TRANSPARENT);
WidgetSet.DrawText(Handle, PChar(String(S)), Length(S), R, Flags);
if Brush.Style = bsSolid then;
WidgetSet.SetBkMode(Handle, OPAQUE);
end;
end;
function TQtThemeServices.HasTransparentParts(Details: TThemedElementDetails): Boolean;
begin
Result := True;
@ -180,18 +191,6 @@ begin
// ?
end;
function TQtThemeServices.CreateQRect(R: TRect): QRectH;
begin
Result := QRect_create();
with R do
begin
QRect_setLeft(Result, Left);
QRect_setRight(Result, Right);
QRect_setTop(Result, Top);
QRect_setBottom(Result, Bottom);
end;
end;
function TQtThemeServices.GetControlState(Details: TThemedElementDetails): QStyleState;
begin
{
@ -222,6 +221,18 @@ begin
QStyleState_ReadOnly
}
Result := QStyleState_None;
if not IsDisabled(Details) then
Result := Result or QStyleState_Enabled;
if IsHot(Details) then
Result := Result or QStyleState_MouseOver;
if IsPushed(Details) then
Result := Result or QStyleState_Sunken;
if IsChecked(Details) then
Result := Result or QStyleState_On;
end;
function TQtThemeServices.GetDrawElement(Details: TThemedElementDetails): TQtDrawElement;
@ -250,22 +261,42 @@ begin
Result.ComplexElement := QStyleCC_GroupBox;
end;
end;
teHeader:
begin
case Details.Part of
HP_HEADERITEM:
begin
Result.DrawVariant := qdvControl;
Result.ControlElement := QStyleCE_HeaderSection;
end;
HP_HEADERITEMLEFT,
HP_HEADERITEMRIGHT:
begin
Result.DrawVariant := qdvControl;
{$IFDEF USE_QT_4_3}
Result.ControlElement := QStyleCE_HeaderEmptyArea;
{$ELSE}
Result.ControlElement := QStyleCE_HeaderSection;
{$ENDIF}
end;
HP_HEADERSORTARROW:
begin
Result.DrawVariant := qdvPrimitive;
Result.PrimitiveElement := QStylePE_IndicatorHeaderArrow;
end;
end;
end;
teToolBar:
begin
if Details.Part = TP_BUTTON then
begin
Result.DrawVariant := qdvComplexControl;
Result.ComplexElement := QStyleCC_ToolButton;
Result.DrawVariant := qdvPrimitive;
Result.PrimitiveElement := QStylePE_PanelButtonTool;
end;
end;
end;
end;
procedure TQtThemeServices.DrawText(DC: HDC; Details: TThemedElementDetails;
const S: WideString; R: TRect; Flags, Flags2: Cardinal);
begin
//
end;
end.

View File

@ -419,6 +419,7 @@ type
function IsDisabled(Details: TThemedElementDetails): Boolean;
function IsPushed(Details: TThemedElementDetails): Boolean;
function IsHot(Details: TThemedElementDetails): Boolean;
function IsChecked(Details: TThemedElementDetails): Boolean;
public
constructor Create;
destructor Destroy; override;
@ -1798,18 +1799,8 @@ begin
if Details.Element = teButton then
begin
case Details.Part of
BP_RADIOBUTTON:
begin
ADrawFlags := DFCS_BUTTONRADIO;
if Details.State >= RBS_CHECKEDNORMAL then
ADrawFlags := ADrawFlags or DFCS_CHECKED;
end;
BP_CHECKBOX:
begin
ADrawFlags := DFCS_BUTTONCHECK;
if Details.State >= CBS_CHECKEDNORMAL then
ADrawFlags := ADrawFlags or DFCS_CHECKED;
end;
BP_RADIOBUTTON: ADrawFlags := DFCS_BUTTONRADIO;
BP_CHECKBOX: ADrawFlags := DFCS_BUTTONCHECK;
end;
end;
@ -1820,6 +1811,9 @@ begin
if IsHot(Details) then
ADrawFlags := ADrawFlags or DFCS_HOT;
if IsChecked(Details) then
ADrawFlags := ADrawFlags or DFCS_CHECKED;
WidgetSet.DrawFrameControl(DC, ARect, DFC_BUTTON, ADrawFlags);
end;
teHeader:
@ -1907,6 +1901,13 @@ begin
Result := Details.State in [2, 6];
end;
function TThemeServices.IsChecked(Details: TThemedElementDetails): Boolean;
begin
Result := False;
if (Details.Element in [teButton]) then
Result := Details.State > 4;
end;
function TThemeServices.InitThemes: Boolean;
begin
Result := False;