Qt: qtwsstdctrls cleanup and reorganisation.

git-svn-id: trunk@24244 -
This commit is contained in:
zeljko 2010-03-27 11:58:33 +00:00
parent 3a75910f27
commit 18b2bcb1d9
2 changed files with 55 additions and 27 deletions

View File

@ -429,6 +429,7 @@ type
procedure Toggle;
function isChecked: Boolean;
function isDown: Boolean;
procedure setCheckable(p1: Boolean);
procedure setChecked(p1: Boolean);
procedure setDefaultColorRoles; override;
procedure setDown(p1: Boolean);
@ -449,6 +450,7 @@ type
public
procedure preferredSize(var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;
public
procedure SetDefault(const ADefault: Boolean);
procedure AttachEvents; override;
procedure DetachEvents; override;
@ -766,6 +768,7 @@ type
procedure ClearItems;
procedure setBorder(const ABorder: Boolean);
function currentIndex: Integer;
function getDroppedDown: Boolean;
function getEditable: Boolean;
function getMaxVisibleItems: Integer;
function getText: WideString; override;
@ -774,6 +777,7 @@ type
procedure insertItem(AIndex: Integer; AText: PWideString); overload;
procedure setCurrentIndex(index: Integer);
procedure setDefaultColorRoles; override;
procedure setDroppedDown(const ADroppedDown: Boolean);
procedure setMaxVisibleItems(ACount: Integer);
procedure setEditable(const AValue: Boolean);
procedure setItemText(AIndex: Integer; AText: String);
@ -4108,6 +4112,11 @@ begin
Result := QAbstractButton_isDown(QAbstractButtonH(Widget));
end;
procedure TQtAbstractButton.setCheckable(p1: Boolean);
begin
QAbstractButton_setCheckable(QAbstractButtonH(Widget), p1);
end;
{------------------------------------------------------------------------------
Function: TQtAbstractButton.setChecked
Params: None
@ -4261,6 +4270,11 @@ begin
end;
end;
procedure TQtPushButton.SetDefault(const ADefault: Boolean);
begin
QPushButton_setDefault(QPushButtonH(Widget), ADefault);
end;
procedure TQtPushButton.AttachEvents;
begin
inherited AttachEvents;
@ -6559,6 +6573,11 @@ begin
Result := QComboBox_currentIndex(QComboBoxH(Widget));
end;
function TQtComboBox.getDroppedDown: Boolean;
begin
Result := QWidget_isVisible(QComboBox_view(QComboBoxH(Widget)));
end;
function TQtComboBox.getEditable: Boolean;
begin
Result := QComboBox_isEditable(QComboBoxH(Widget));
@ -6614,6 +6633,17 @@ begin
TextColorRole := QPaletteText;
end;
procedure TQtComboBox.setDroppedDown(const ADroppedDown: Boolean);
begin
if ADroppedDown <> QWidget_isVisible(QComboBox_view(QComboBoxH(Widget))) then
begin
if ADroppedDown then
QComboBox_showPopup(QComboBoxH(Widget))
else
QComboBox_hidePopup(QComboBoxH(Widget));
end;
end;
procedure TQtComboBox.setMaxVisibleItems(ACount: Integer);
begin
QComboBox_setMaxVisibleItems(QComboboxH(Widget), ACount);

View File

@ -503,7 +503,7 @@ var
ListItem: QListWidgetItemH;
begin
QtListWidget := TQtListWidget(ACustomListBox.Handle);
ListItem := QListWidget_item(QListWidgetH(QtListWidget.Widget), AIndex);
ListItem := QtListWidget.getItem(AIndex);
if ListItem <> nil then
QtListWidget.setItemSelected(ListItem, ASelected);
end;
@ -520,7 +520,8 @@ begin
TQtWSWinControl.SetBorderStyle(ACustomListBox, ACustomListBox.BorderStyle);
end;
class procedure TQtWSCustomListBox.SetColumnCount(const ACustomListBox: TCustomListBox; ACount: Integer);
class procedure TQtWSCustomListBox.SetColumnCount(const ACustomListBox: TCustomListBox;
ACount: Integer);
{var
QtListWidget: TQtListWidget;
AModel: QAbstractItemModelH;}
@ -539,7 +540,8 @@ end;
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSCustomListBox.SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer);
class procedure TQtWSCustomListBox.SetItemIndex(const ACustomListBox: TCustomListBox;
const AIndex: integer);
begin
TQtListWidget(ACustomListBox.Handle).setCurrentRow(AIndex);
end;
@ -595,7 +597,8 @@ end;
class procedure TQtWSCustomListBox.SetTopIndex(const ACustomListBox: TCustomListBox;
const NewTopIndex: integer);
begin
TQtListWidget(ACustomListBox.Handle).scrollToItem(NewTopIndex, QAbstractItemViewPositionAtTop);
TQtListWidget(ACustomListBox.Handle).scrollToItem(NewTopIndex,
QAbstractItemViewPositionAtTop);
end;
{ TQtWSCustomMemo }
@ -957,10 +960,11 @@ end;
class procedure TQtWSButton.SetDefault(const AButton: TCustomButton;
ADefault: Boolean);
var
APushButton: QPushButtonH;
QtPushButton: TQtPushButton;
begin
APushButton := QPushButtonH(TQtAbstractButton(AButton.Handle).Widget);
QPushButton_setDefault(APushButton, ADefault);
if not WSCheckHandleAllocated(AButton, 'SetDefault') then Exit;
QtPushButton := TQtPushButton(AButton.Handle);
QtPushButton.SetDefault(ADefault);
end;
class procedure TQtWSButton.SetShortcut(const AButton: TCustomButton;
@ -968,7 +972,7 @@ class procedure TQtWSButton.SetShortcut(const AButton: TCustomButton;
begin
if not WSCheckHandleAllocated(AButton, 'SetShortcut') then Exit;
TQtAbstractButton(AButton.Handle).setShortcut(NewShortcut);
TQtPushButton(AButton.Handle).setShortcut(NewShortcut);
end;
{ TQtWSCustomCheckBox }
@ -1160,12 +1164,13 @@ end;
class function TQtWSCustomComboBox.GetDroppedDown(
const ACustomComboBox: TCustomComboBox): Boolean;
var
ComboList: QAbstractItemViewH;
ComboBox: QComboBoxH;
QtComboBox: TQtComboBox;
begin
ComboBox := QComboBoxH(TQtComboBox(ACustomComboBox.Handle).Widget);
ComboList := QComboBox_view(ComboBox);
Result := QWidget_isVisible(ComboList);
Result := False;
if not ACustomComboBox.HandleAllocated then
exit;
QtComboBox := TQtComboBox(ACustomComboBox.Handle);
Result := QtComboBox.getDroppedDown;
end;
{------------------------------------------------------------------------------
@ -1286,18 +1291,10 @@ end;
class procedure TQtWSCustomComboBox.SetDroppedDown(
const ACustomComboBox: TCustomComboBox; ADroppedDown: Boolean);
var
ComboList: QAbstractItemViewH;
ComboBox: QComboBoxH;
QtComboBox: TQtComboBox;
begin
ComboBox := QComboBoxH(TQtComboBox(ACustomComboBox.Handle).Widget);
ComboList := QComboBox_view(ComboBox);
if ADroppedDown <> QWidget_isVisible(ComboList) then
begin
if ADroppedDown then
QComboBox_showPopup(ComboBox)
else
QComboBox_hidePopup(ComboBox);
end;
QtComboBox := TQtComboBox(ACustomComboBox.Handle);
QtComboBox.setDroppedDown(ADroppedDown);
end;
{------------------------------------------------------------------------------
@ -1336,7 +1333,9 @@ class procedure TQtWSCustomComboBox.SetStyle(
const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle);
begin
TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle = csDropDown);
TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle in [csOwnerDrawFixed, csOwnerDrawVariable];
TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle in
[csOwnerDrawFixed,
csOwnerDrawVariable];
// TODO: implement styles: csSimple
inherited SetStyle(ACustomComboBox, NewStyle);
end;
@ -1415,8 +1414,7 @@ var
QtToggleBox: TQtPushButton;
begin
QtToggleBox := TQtPushButton.Create(AWinControl, AParams);
QAbstractButton_setCheckable(QAbstractButtonH(QtToggleBox.Widget), True);
QtToggleBox.setCheckable(True);
QtToggleBox.AttachEvents;
Result := TLCLIntfHandle(QtToggleBox);