Fixes component colors bug on Qt widgetset.

git-svn-id: trunk@10282 -
This commit is contained in:
sekelsenmat 2006-12-03 19:10:33 +00:00
parent 73b5502f8c
commit 47e5345d72
4 changed files with 177 additions and 17 deletions

View File

@ -59,7 +59,7 @@ type
procedure SlotResize; cdecl;
procedure SlotContextMenu; cdecl;
public
procedure SetColor(const Value: PQColor);
procedure SetColor(const Value: PQColor); virtual;
procedure Update;
procedure Repaint;
procedure setWindowTitle(Str: PWideString);
@ -83,6 +83,7 @@ type
TQtAbstractButton = class(TQtWidget)
private
public
procedure SetColor(const Value: PQColor); override;
procedure SetText(text: PWideString);
procedure Text(retval: PWideString);
function isChecked: Boolean;
@ -185,7 +186,7 @@ type
procedure setFrameShadow(p1: QFrameShadow);
end;
{ TQtAbstractSlider , inherited by TQtScrollBar, TQtTrackBar}
{ TQtAbstractSlider , inherited by TQtScrollBar, TQtTrackBar }
TQtAbstractSlider = class(TQtWidget)
private
@ -209,14 +210,16 @@ type
procedure setValue(p1: Integer); virtual;
end;
{ TQtScrollBar }
{ TQtScrollBar }
TQtScrollBar = class(TQtAbstractSlider)
private
public
constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override;
end;
{ TQtTrackBar }
{ TQtTrackBar }
TQtTrackBar = class(TQtAbstractSlider)
private
public
@ -232,6 +235,7 @@ type
public
constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override;
destructor Destroy; override;
procedure SetColor(const Value: PQColor); override;
end;
{ TQtTextEdit }
@ -241,6 +245,7 @@ type
public
constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override;
destructor Destroy; override;
procedure SetColor(const Value: PQColor); override;
end;
{ TQtTabWidget }
@ -261,6 +266,7 @@ type
public
constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override;
destructor Destroy; override;
procedure SetColor(const Value: PQColor); override;
function currentIndex: Integer;
procedure setCurrentIndex(index: Integer);
public
@ -785,7 +791,7 @@ end;
Params: QColorH
Returns: Nothing
Schedules a paint event for processing when Qt returns to the main event loop
Changes the color of a widget
------------------------------------------------------------------------------}
procedure TQtWidget.SetColor(const Value: PQColor);
var
@ -794,8 +800,6 @@ begin
Palette:=QPalette_create(QWidget_palette(Widget));
// Set the palette for all color groups (active, inactive, disabled)
QPalette_setColor(Palette,QPaletteWindow,Value);
QPalette_setColor(Palette,QPaletteButton,Value);
QPalette_setColor(Palette,QPaletteBase,Value);
// Set the Palette
QWidget_setPalette(Widget,Palette);
QPalette_destroy(Palette);
@ -1218,6 +1222,25 @@ end;
{ TQtAbstractButton }
{------------------------------------------------------------------------------
Function: TQtAbstractButton.SetColor
Params: QColorH
Returns: Nothing
Changes the color of a widget
------------------------------------------------------------------------------}
procedure TQtAbstractButton.SetColor(const Value: PQColor);
var
Palette: QPaletteH;
begin
Palette:=QPalette_create(QWidget_palette(Widget));
// Set the palette for all color groups (active, inactive, disabled)
QPalette_setColor(Palette,QPaletteButton,Value);
// Set the Palette
QWidget_setPalette(Widget,Palette);
QPalette_destroy(Palette);
end;
{------------------------------------------------------------------------------
Function: TQtAbstractButton.SetText
Params: None
@ -2131,7 +2154,7 @@ end;
{ TQtLineEdit }
{------------------------------------------------------------------------------
Function: TQtLineEdit.Destroy
Function: TQtLineEdit.Create
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
@ -2173,6 +2196,25 @@ begin
inherited Destroy;
end;
{------------------------------------------------------------------------------
Function: TQtLineEdit.SetColor
Params: QColorH
Returns: Nothing
Changes the color of a widget
------------------------------------------------------------------------------}
procedure TQtLineEdit.SetColor(const Value: PQColor);
var
Palette: QPaletteH;
begin
Palette:=QPalette_create(QWidget_palette(Widget));
// Set the palette for all color groups (active, inactive, disabled)
QPalette_setColor(Palette,QPaletteBase,Value);
// Set the Palette
QWidget_setPalette(Widget,Palette);
QPalette_destroy(Palette);
end;
{ TQtTextEdit }
{------------------------------------------------------------------------------
@ -2225,6 +2267,25 @@ begin
inherited Destroy;
end;
{------------------------------------------------------------------------------
Function: TQtTextEdit.SetColor
Params: QColorH
Returns: Nothing
Changes the color of a widget
------------------------------------------------------------------------------}
procedure TQtTextEdit.SetColor(const Value: PQColor);
var
Palette: QPaletteH;
begin
Palette:=QPalette_create(QWidget_palette(Widget));
// Set the palette for all color groups (active, inactive, disabled)
QPalette_setColor(Palette,QPaletteBase,Value);
// Set the Palette
QWidget_setPalette(Widget,Palette);
QPalette_destroy(Palette);
end;
{ TQtTabWidget }
{------------------------------------------------------------------------------
@ -2341,6 +2402,11 @@ begin
inherited Destroy;
end;
procedure TQtComboBox.SetColor(const Value: PQColor);
begin
inherited SetColor(Value);
end;
{------------------------------------------------------------------------------
Function: TQtComboBox.currentIndex
Params: None

View File

@ -1098,7 +1098,7 @@ begin
COLOR_ACTIVECAPTION : Result:=GetColor(QPaletteActive, QPaletteBase);
COLOR_INACTIVECAPTION : Result:=GetColor(QPaletteInActive, QPaletteBase);
COLOR_MENU : Result:=GetColor(QPaletteActive, QPaletteWindow);
COLOR_WINDOW : Result:=GetColor(QPaletteActive, QPaletteWindow);
COLOR_WINDOW : Result:=GetColor(QPaletteInActive, QPaletteBase);
COLOR_WINDOWFRAME : Result:=GetColor(QPaletteActive, QPaletteWindow);
COLOR_MENUTEXT : Result:=GetColor(QPaletteActive, QPaletteWindowText);
COLOR_WINDOWTEXT : Result:=GetColor(QPaletteActive, QPaletteWindowText);

View File

@ -30,7 +30,7 @@ uses
// Libs
qt4, qtwidgets,
// LCL
SysUtils, Controls, LCLType, Forms, InterfaceBase, Buttons, LMessages,
SysUtils, Controls, LCLType, Forms, InterfaceBase, Buttons, LMessages, Graphics,
// Widgetset
WSButtons, WSLCLClasses;
@ -50,6 +50,7 @@ type
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
// class procedure GetPreferredSize(const AWinControl: TWinControl;
// var PreferredWidth, PreferredHeight: integer); override;
class procedure SetColor(const AWinControl: TWinControl); override;
end;
{ TQtWSBitBtn }
@ -66,6 +67,7 @@ type
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
// class procedure GetPreferredSize(const AWinControl: TWinControl;
// var PreferredWidth, PreferredHeight: integer); override;
class procedure SetColor(const AWinControl: TWinControl); override;
end;
{ TQtWSSpeedButton }
@ -166,6 +168,35 @@ begin
TQtAbstractButton(AWinControl.Handle).SetText(@Str);
end;
{------------------------------------------------------------------------------
Method: TQtWSButton.SetColor
Params: AWinControl - the calling object
Returns: Nothing
Sets the color of the widget.
------------------------------------------------------------------------------}
class procedure TQtWSButton.SetColor(const AWinControl: TWinControl);
var
QColor: TQColor;
Color: TColor;
begin
if AWinControl = nil then exit;
if not AWinControl.HandleAllocated then exit;
if AWinControl.Color = CLR_INVALID then exit;
// Get the color numeric value (system colors are mapped to numeric colors depending on the widget style)
Color:=ColorToRGB(AWinControl.Color);
// Fill QColor
QColor_setRgb(@QColor,Red(Color),Green(Color),Blue(Color));
// Set color of the widget to QColor
TQtAbstractButton(AWinControl.Handle).SetColor(@QColor);
end;
{ TQtWSBitBtn }
{------------------------------------------------------------------------------
@ -252,6 +283,35 @@ begin
TQtAbstractButton(AWinControl.Handle).SetText(@Str);
end;
{------------------------------------------------------------------------------
Method: TQtWSBitBtn.SetColor
Params: AWinControl - the calling object
Returns: Nothing
Sets the color of the widget.
------------------------------------------------------------------------------}
class procedure TQtWSBitBtn.SetColor(const AWinControl: TWinControl);
var
QColor: TQColor;
Color: TColor;
begin
if AWinControl = nil then exit;
if not AWinControl.HandleAllocated then exit;
if AWinControl.Color = CLR_INVALID then exit;
// Get the color numeric value (system colors are mapped to numeric colors depending on the widget style)
Color:=ColorToRGB(AWinControl.Color);
// Fill QColor
QColor_setRgb(@QColor,Red(Color),Green(Color),Blue(Color));
// Set color of the widget to QColor
TQtAbstractButton(AWinControl.Handle).SetColor(@QColor);
end;
initialization
////////////////////////////////////////////////////

View File

@ -30,9 +30,9 @@ uses
// Bindings
qt4, qtprivate, qtwidgets,
// LCL
Classes, StdCtrls, Controls, Graphics, Forms, SysUtils, InterfaceBase,
Classes, StdCtrls, Controls, Graphics, Forms, SysUtils, InterfaceBase, LCLType, LCLIntf,
// Widgetset
WSStdCtrls, WSLCLClasses, LCLType;
WSStdCtrls, WSLCLClasses;
type
@ -161,6 +161,7 @@ type
class procedure GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer); override;}
class procedure SetColor(const AWinControl: TWinControl); override;
end;
{ TQtWSCustomMemo }
@ -681,6 +682,8 @@ class function TQtWSCustomEdit.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
QtLineEdit: TQtLineEdit;
QColor: TQColor;
Color: TColor;
begin
QtLineEdit := TQtLineEdit.Create(AWinControl, AParams);
@ -727,6 +730,35 @@ begin
QLineEdit_setText(QLineEditH(TQtWidget(AWinControl.Handle).Widget), @AString);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomEdit.SetColor
Params: AWinControl - the calling object
Returns: Nothing
Sets the color of the widget.
------------------------------------------------------------------------------}
class procedure TQtWSCustomEdit.SetColor(const AWinControl: TWinControl);
var
QColor: TQColor;
Color: TColor;
begin
if AWinControl = nil then exit;
if not AWinControl.HandleAllocated then exit;
if AWinControl.Color = CLR_INVALID then exit;
// Get the color numeric value (system colors are mapped to numeric colors depending on the widget style)
Color:=ColorToRGB(AWinControl.Color);
// Fill QColor
QColor_setRgb(@QColor,Red(Color),Green(Color),Blue(Color));
// Set color of the widget to QColor
TQtLineEdit(AWinControl.Handle).SetColor(@QColor);
end;
{ TQtWSStaticText }
{------------------------------------------------------------------------------
@ -803,7 +835,7 @@ end;
{ TQtWSCustomCheckBox }
{------------------------------------------------------------------------------
Method: TQtWSCustomEdit.RetrieveState
Method: TQtWSCustomCheckBox.RetrieveState
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
@ -818,7 +850,7 @@ begin
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomEdit.SetShortCut
Method: TQtWSCustomCheckBox.SetShortCut
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
@ -829,7 +861,7 @@ begin
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomEdit.SetState
Method: TQtWSCustomCheckBox.SetState
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
@ -844,7 +876,7 @@ begin
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomEdit.GetText
Method: TQtWSCustomCheckBox.GetText
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
@ -860,7 +892,7 @@ begin
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomEdit.SetText
Method: TQtWSCustomCheckBox.SetText
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
@ -1085,6 +1117,8 @@ var
QtComboBox: TQtComboBox;
Method: TMethod;
Hook : QObject_hookH;
QColor: TQColor;
Color: TColor;
begin
QtComboBox := TQtComboBox.Create(AWinControl, AParams);