ComboBox: implement TComboBoxStyle.IsOwnerDrawn and .IsVariable and use them instead of the in [] syntax

git-svn-id: trunk@63228 -
This commit is contained in:
ondrej 2020-05-26 22:25:15 +00:00
parent a8d3315c24
commit ef8d6a825e
16 changed files with 80 additions and 89 deletions

View File

@ -92,8 +92,7 @@ begin
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin begin
if (Style in [csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable]) if Style.IsOwnerDrawn and (FItemHeight > 0) then
and (FItemHeight > 0) then
ItemHeight := Round(ItemHeight * AYProportion); ItemHeight := Round(ItemHeight * AYProportion);
end; end;
end; end;
@ -126,7 +125,7 @@ procedure TCustomComboBox.DoEnter;
begin begin
inherited DoEnter; inherited DoEnter;
//AutoSelect when DoEnter is fired by keyboard //AutoSelect when DoEnter is fired by keyboard
if (Style = csDropDownList) then Exit;//Non editable style if not Style.HasEditBox then Exit;//Non editable style
if (FAutoSelect and not (csLButtonDown in ControlState)) then if (FAutoSelect and not (csLButtonDown in ControlState)) then
begin begin
SelectAll; SelectAll;
@ -543,7 +542,7 @@ begin
//SelectAll when hitting return key for AutoSelect feature //SelectAll when hitting return key for AutoSelect feature
if (Key = VK_RETURN) then if (Key = VK_RETURN) then
begin begin
if ((cbactEnabled in FAutoCompleteText) and (Style <> csDropDownList)) then if ((cbactEnabled in FAutoCompleteText) and Style.HasEditBox) then
begin begin
// Only happens with alpha-numeric keys and return key and editable Style // Only happens with alpha-numeric keys and return key and editable Style
SelectAll; SelectAll;
@ -555,7 +554,7 @@ begin
end; end;
end end
else else
if ((cbactEnabled in FAutoCompleteText) and (Style <> csDropDownList)) then if ((cbactEnabled in FAutoCompleteText) and Style.HasEditBox) then
begin begin
//Only happens with alpha-numeric keys and return key and editable Style //Only happens with alpha-numeric keys and return key and editable Style
//DebugLn(['TCustomComboBox.KeyUp ',Key,' ',IsEditableTextKey(Key)]); //DebugLn(['TCustomComboBox.KeyUp ',Key,' ',IsEditableTextKey(Key)]);
@ -670,9 +669,7 @@ function TCustomComboBox.GetItemHeight: Integer;
begin begin
// FItemHeight is not initialized at class creating. we can, but with what value? // FItemHeight is not initialized at class creating. we can, but with what value?
// so, if it still uninitialized (=0), then we ask widgetset // so, if it still uninitialized (=0), then we ask widgetset
if (FStyle in [csOwnerDrawFixed, csOwnerDrawVariable, if FStyle.IsOwnerDrawn and (FItemHeight > 0) or not HandleAllocated then
csOwnerDrawEditableFixed, csOwnerDrawEditableVariable])
and (FItemHeight > 0) or not HandleAllocated then
Result := FItemHeight Result := FItemHeight
else else
begin begin
@ -708,8 +705,7 @@ begin
FItemHeight := AValue; FItemHeight := AValue;
if not HandleAllocated then if not HandleAllocated then
exit; exit;
if Style in [csOwnerDrawFixed, csOwnerDrawVariable, if Style.IsOwnerDrawn then
csOwnerDrawEditableFixed, csOwnerDrawEditableVariable] then
TWSCustomComboBoxClass(WidgetSetClass).SetItemHeight(Self, FItemHeight); TWSCustomComboBoxClass(WidgetSetClass).SetItemHeight(Self, FItemHeight);
end; end;
@ -1040,7 +1036,7 @@ begin
AHeight := FItemHeight AHeight := FItemHeight
else else
AHeight := ItemHeight; AHeight := ItemHeight;
if FStyle in [csOwnerDrawVariable, csOwnerDrawEditableVariable] then if FStyle.IsVariable then
MeasureItem(Integer(ItemId), AHeight); MeasureItem(Integer(ItemId), AHeight);
if AHeight > 0 then if AHeight > 0 then
ItemHeight := AHeight; ItemHeight := AHeight;
@ -1133,4 +1129,34 @@ begin
Result := ArrHasEditBox[Self]; Result := ArrHasEditBox[Self];
end; end;
function TComboBoxStyleHelper.IsOwnerDrawn: Boolean;
const
ArrIsOwnerDrawn: array[TComboBoxStyle] of Boolean = (
False, // csDropDown, // like an TEdit plus a button to drop down the list, default
False, // csSimple, // like an TEdit plus a TListBox
False, // csDropDownList, // like TLabel plus a button to drop down the list
True, // csOwnerDrawFixed, // like csDropDownList, but custom drawn
True, // csOwnerDrawVariable,// like csDropDownList, but custom drawn and with each item can have another height
True, // csOwnerDrawEditableFixed,// like csOwnerDrawFixed, but with TEdit
True // csOwnerDrawEditableVariable// like csOwnerDrawVariable, but with TEdit
);
begin
Result := ArrIsOwnerDrawn[Self];
end;
function TComboBoxStyleHelper.IsVariable: Boolean;
const
ArrIsVariable: array[TComboBoxStyle] of Boolean = (
False, // csDropDown, // like an TEdit plus a button to drop down the list, default
False, // csSimple, // like an TEdit plus a TListBox
False, // csDropDownList, // like TLabel plus a button to drop down the list
False, // csOwnerDrawFixed, // like csDropDownList, but custom drawn
True, // csOwnerDrawVariable,// like csDropDownList, but custom drawn and with each item can have another height
False, // csOwnerDrawEditableFixed,// like csOwnerDrawFixed, but with TEdit
True // csOwnerDrawEditableVariable// like csOwnerDrawVariable, but with TEdit
);
begin
Result := ArrIsVariable[Self];
end;
// included by stdctrls.pp // included by stdctrls.pp

View File

@ -31,7 +31,7 @@ var
i: Integer; i: Integer;
begin begin
// combo that has edit control may have unreliable itemindex like bug 20950 // combo that has edit control may have unreliable itemindex like bug 20950
if Style <> csDropDownList then if Style.HasEditBox then
ItemIndex := Items.IndexOf(Text); ItemIndex := Items.IndexOf(Text);
i := ItemIndex; i := ItemIndex;
if i <> -1 then if i <> -1 then
@ -87,7 +87,7 @@ end;
procedure TDBLookupComboBox.DoOnSelect; procedure TDBLookupComboBox.DoOnSelect;
begin begin
if Style=csDropDownList then if not Style.HasEditBox then
UpdateRecord; UpdateRecord;
inherited DoOnSelect; inherited DoOnSelect;
end; end;

View File

@ -496,13 +496,12 @@ end;
function ComboBoxIsOwnerDrawn(AStyle: TComboBoxStyle): Boolean; function ComboBoxIsOwnerDrawn(AStyle: TComboBoxStyle): Boolean;
begin begin
Result := AStyle in [csOwnerDrawFixed, csOwnerDrawVariable, Result := AStyle.IsOwnerDrawn;
csOwnerDrawEditableFixed, csOwnerDrawEditableVariable];
end; end;
function ComboBoxIsVariable(AStyle: TComboBoxStyle): Boolean; function ComboBoxIsVariable(AStyle: TComboBoxStyle): Boolean;
begin begin
Result := AStyle in [csOwnerDrawVariable, csOwnerDrawEditableVariable]; Result := AStyle.IsVariable;
end; end;
procedure ComboBoxSetBorderStyle(box: NSComboBox; astyle: TBorderStyle); procedure ComboBoxSetBorderStyle(box: NSComboBox; astyle: TBorderStyle);

View File

@ -796,10 +796,8 @@ end;
class procedure TCDWSCustomComboBox.SetStyle( class procedure TCDWSCustomComboBox.SetStyle(
const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle); const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle);
begin begin
TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle = csDropDown); TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle.HasEditBox);
TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle in TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle.IsOwnerDrawn;
[csOwnerDrawFixed,
csOwnerDrawVariable];
// TODO: implement styles: csSimple // TODO: implement styles: csSimple
inherited SetStyle(ACustomComboBox, NewStyle); inherited SetStyle(ACustomComboBox, NewStyle);
end; end;

View File

@ -69,7 +69,7 @@ begin
if TCustomListbox(LCLList.Owner).Style = lbStandard then if TCustomListbox(LCLList.Owner).Style = lbStandard then
exit; exit;
if LclList.Owner is TCustomCombobox then if LclList.Owner is TCustomCombobox then
if TCustomCombobox(LclList.Owner).Style < csOwnerDrawFixed then if not TCustomCombobox(LclList.Owner).Style.IsOwnerDrawn then
exit; exit;
// get itemindex and area // get itemindex and area

View File

@ -1168,21 +1168,19 @@ var
GtkCombo: PGtkCombo; GtkCombo: PGtkCombo;
begin begin
GtkCombo := GTK_COMBO(Pointer(ACustomComboBox.Handle)); GtkCombo := GTK_COMBO(Pointer(ACustomComboBox.Handle));
case ACustomComboBox.Style of if not ACustomComboBox.Style.HasEditBox then
csDropDownList : begin
begin // do not set ok_if_empty = true, otherwise it can hang focus
// do not set ok_if_empty = true, otherwise it can hang focus gtk_combo_set_value_in_list(GtkCombo,GdkTrue,GdkTrue);
gtk_combo_set_value_in_list(GtkCombo,GdkTrue,GdkTrue); gtk_combo_set_use_arrows_always(GtkCombo,GdkTrue);
gtk_combo_set_use_arrows_always(GtkCombo,GdkTrue); gtk_combo_set_case_sensitive(GtkCombo,GdkFalse);
gtk_combo_set_case_sensitive(GtkCombo,GdkFalse); end
end; else
else begin
begin // do not set ok_if_empty = true, otherwise it can hang focus
// do not set ok_if_empty = true, otherwise it can hang focus gtk_combo_set_value_in_list(GtkCombo,GdkFalse,GdkTrue);
gtk_combo_set_value_in_list(GtkCombo,GdkFalse,GdkTrue); gtk_combo_set_use_arrows_always(GtkCombo,GdkFalse);
gtk_combo_set_use_arrows_always(GtkCombo,GdkFalse); gtk_combo_set_case_sensitive(GtkCombo,GdkTrue);
gtk_combo_set_case_sensitive(GtkCombo,GdkTrue);
end;
end; end;
end; end;

View File

@ -120,7 +120,7 @@ begin
if TCustomListbox(AWinControl).Style < lbOwnerDrawFixed then if TCustomListbox(AWinControl).Style < lbOwnerDrawFixed then
exit; exit;
if AWinControl is TCustomCombobox then if AWinControl is TCustomCombobox then
if TCustomCombobox(AWinControl).Style < csOwnerDrawVariable then if not TCustomCombobox(AWinControl).Style.IsVariable then
exit; exit;
ItemIndex := GetItemIndex(PLCLIntfCellRenderer(cell), Widget); ItemIndex := GetItemIndex(PLCLIntfCellRenderer(cell), Widget);
@ -255,7 +255,7 @@ begin
if TCustomListbox(AWinControl).Style = lbStandard then if TCustomListbox(AWinControl).Style = lbStandard then
exit; exit;
if AWinControl is TCustomCombobox then if AWinControl is TCustomCombobox then
if TCustomCombobox(AWinControl).Style < csOwnerDrawFixed then if not TCustomCombobox(AWinControl).Style.IsOwnerDrawn then
exit; exit;
// get itemindex and area // get itemindex and area
@ -438,7 +438,7 @@ begin
if (WidgetInfo <> nil) and if (WidgetInfo <> nil) and
(WidgetInfo^.LCLObject is TCustomComboBox) and (WidgetInfo^.LCLObject is TCustomComboBox) and
(TCustomComboBox(WidgetInfo^.LCLObject).Style = csDropDownList) and not (TCustomComboBox(WidgetInfo^.LCLObject).Style.HasEditBox) and
not (TCustomComboBox(WidgetInfo^.LCLObject).DroppedDown) then not (TCustomComboBox(WidgetInfo^.LCLObject).DroppedDown) then
begin begin
Value.g_type := G_TYPE_UINT; Value.g_type := G_TYPE_UINT;

View File

@ -69,7 +69,7 @@ begin
if TCustomListbox(LCLList.Owner).Style = lbStandard then if TCustomListbox(LCLList.Owner).Style = lbStandard then
exit; exit;
if LclList.Owner is TCustomCombobox then if LclList.Owner is TCustomCombobox then
if TCustomCombobox(LclList.Owner).Style < csOwnerDrawFixed then if not TCustomCombobox(LclList.Owner).Style.IsOwnerDrawn then
exit; exit;
// get itemindex and area // get itemindex and area

View File

@ -1559,7 +1559,7 @@ begin
g_object_set_data(G_OBJECT(renderer), 'widgetinfo', AWidgetInfo); g_object_set_data(G_OBJECT(renderer), 'widgetinfo', AWidgetInfo);
gtk_cell_layout_clear(PGtkCellLayout(AWidget)); gtk_cell_layout_clear(PGtkCellLayout(AWidget));
gtk_cell_layout_pack_start(PGtkCellLayout(AWidget), renderer, True); gtk_cell_layout_pack_start(PGtkCellLayout(AWidget), renderer, True);
if not (ACustomComboBox.Style in [csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable]) then if not ACustomComboBox.Style.IsOwnerDrawn then
gtk_cell_layout_set_attributes(PGtkCellLayout(AWidget), renderer, ['text', 0, nil]); gtk_cell_layout_set_attributes(PGtkCellLayout(AWidget), renderer, ['text', 0, nil]);
gtk_cell_layout_set_cell_data_func(PGtkCellLayout(AWidget), renderer, gtk_cell_layout_set_cell_data_func(PGtkCellLayout(AWidget), renderer,
@LCLIntfCellRenderer_CellDataFunc, AWidgetInfo, nil); @LCLIntfCellRenderer_CellDataFunc, AWidgetInfo, nil);
@ -2009,17 +2009,7 @@ var
begin begin
WidgetInfo := GetWidgetInfo({%H-}Pointer(ACustomComboBox.Handle)); WidgetInfo := GetWidgetInfo({%H-}Pointer(ACustomComboBox.Handle));
p := WidgetInfo^.CoreWidget; p := WidgetInfo^.CoreWidget;
case NewStyle of NeedEntry := NewStyle.HasEditBox;
csDropDown,
csSimple,
csOwnerDrawEditableFixed,
csOwnerDrawEditableVariable:
NeedEntry := True;
csDropDownList,
csOwnerDrawFixed,
csOwnerDrawVariable:
NeedEntry := False;
end;
if gtk_is_combo_box_entry(p) = NeedEntry then Exit; if gtk_is_combo_box_entry(p) = NeedEntry then Exit;
ReCreateCombo(ACustomComboBox, NeedEntry, WidgetInfo); ReCreateCombo(ACustomComboBox, NeedEntry, WidgetInfo);
end; end;
@ -2141,7 +2131,6 @@ var
ACustomComboBox: TCustomComboBox; ACustomComboBox: TCustomComboBox;
ItemList: TGtkListStoreStringList; ItemList: TGtkListStoreStringList;
LCLIndex: PLongint; LCLIndex: PLongint;
NeedEntry: Boolean;
begin begin
ACustomComboBox := TCustomComboBox(AWinControl); ACustomComboBox := TCustomComboBox(AWinControl);
@ -2154,18 +2143,7 @@ begin
ListStore := gtk_list_store_new (2, [G_TYPE_STRING, G_TYPE_POINTER, nil]); ListStore := gtk_list_store_new (2, [G_TYPE_STRING, G_TYPE_POINTER, nil]);
case ACustomComboBox.Style of if ACustomComboBox.Style.HasEditBox then
csDropDown,
csSimple,
csOwnerDrawEditableFixed,
csOwnerDrawEditableVariable:
NeedEntry := True;
csDropDownList,
csOwnerDrawFixed,
csOwnerDrawVariable:
NeedEntry := False;
end;
if NeedEntry then
ComboWidget := gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL (ListStore), 0) ComboWidget := gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL (ListStore), 0)
else else
ComboWidget := gtk_combo_box_new_with_model(GTK_TREE_MODEL (ListStore)); ComboWidget := gtk_combo_box_new_with_model(GTK_TREE_MODEL (ListStore));

View File

@ -168,7 +168,7 @@ begin
if TCustomListbox(AWinControl).Style < lbOwnerDrawFixed then if TCustomListbox(AWinControl).Style < lbOwnerDrawFixed then
exit; exit;
if AWinControl is TCustomCombobox then if AWinControl is TCustomCombobox then
if TCustomCombobox(AWinControl).Style < csOwnerDrawVariable then if not TCustomCombobox(AWinControl).Style.IsVariable then
exit; exit;
ItemIndex := GetItemIndex(PLCLIntfCellRenderer(cell), Widget); ItemIndex := GetItemIndex(PLCLIntfCellRenderer(cell), Widget);
@ -272,7 +272,7 @@ begin
if TCustomListbox(AWinControl).Style < lbOwnerDrawFixed then if TCustomListbox(AWinControl).Style < lbOwnerDrawFixed then
exit; exit;
if AWinControl is TCustomCombobox then if AWinControl is TCustomCombobox then
if TCustomCombobox(AWinControl).Style < csOwnerDrawVariable then if not TCustomCombobox(AWinControl).Style.IsVariable then
exit; exit;
ItemIndex := GetItemIndex(PLCLIntfCellRenderer(cell), Widget); ItemIndex := GetItemIndex(PLCLIntfCellRenderer(cell), Widget);
@ -322,7 +322,7 @@ begin
if TCustomListbox(AWinControl).Style < lbOwnerDrawFixed then if TCustomListbox(AWinControl).Style < lbOwnerDrawFixed then
exit; exit;
if AWinControl is TCustomCombobox then if AWinControl is TCustomCombobox then
if TCustomCombobox(AWinControl).Style < csOwnerDrawVariable then if not TCustomCombobox(AWinControl).Style.IsVariable then
exit; exit;
ItemIndex := GetItemIndex(PLCLIntfCellRenderer(cell), Widget); ItemIndex := GetItemIndex(PLCLIntfCellRenderer(cell), Widget);
@ -487,7 +487,7 @@ begin
if TCustomListbox(AWinControl).Style = lbStandard then if TCustomListbox(AWinControl).Style = lbStandard then
exit; exit;
if AWinControl is TCustomCombobox then if AWinControl is TCustomCombobox then
if TCustomCombobox(AWinControl).Style < csOwnerDrawFixed then if not TCustomCombobox(AWinControl).Style.IsOwnerDrawn then
exit; exit;
ItemIndex := GetItemIndex(PLCLIntfCellRenderer(cell), Widget); ItemIndex := GetItemIndex(PLCLIntfCellRenderer(cell), Widget);
@ -673,7 +673,7 @@ begin
// DebugLn(['LCLIntfCellRenderer_CellDataFunc stamp=',iter^.stamp,' tree_model=',dbgs(tree_model),' cell=',dbgs(cell),' WidgetInfo=',WidgetInfo <> nil,' Time=',TimeToStr(Now)]); // DebugLn(['LCLIntfCellRenderer_CellDataFunc stamp=',iter^.stamp,' tree_model=',dbgs(tree_model),' cell=',dbgs(cell),' WidgetInfo=',WidgetInfo <> nil,' Time=',TimeToStr(Now)]);
if (wtComboBox in TGtk3Widget(Data).WidgetType) and if (wtComboBox in TGtk3Widget(Data).WidgetType) and
(TCustomComboBox(TGtk3Widget(Data).LCLObject).Style = csDropDownList) and not (TCustomComboBox(TGtk3Widget(Data).LCLObject).Style.HasEditBox) and
not (TCustomComboBox(TGtk3Widget(Data).LCLObject).DroppedDown) then not (TCustomComboBox(TGtk3Widget(Data).LCLObject).DroppedDown) then
begin begin
Value.g_type := G_TYPE_UINT; Value.g_type := G_TYPE_UINT;

View File

@ -6221,8 +6221,6 @@ begin
g_object_set_data(PGObject(Result), GtkListItemLCLListTag, ItemList); g_object_set_data(PGObject(Result), GtkListItemLCLListTag, ItemList);
PGtkComboBox(Result)^.set_entry_text_column(0); PGtkComboBox(Result)^.set_entry_text_column(0);
if ACombo.Style = csDropDownList then
PGtkEditable(PGtkComboBox(Result)^.get_child)^.set_editable(False);
// do not allow combo button to get focus, entry should take focus // do not allow combo button to get focus, entry should take focus
if PGtkComboBox(Result)^.priv3^.button <> nil then if PGtkComboBox(Result)^.priv3^.button <> nil then
PGtkComboBox(Result)^.priv3^.button^.set_can_focus(False); PGtkComboBox(Result)^.priv3^.button^.set_can_focus(False);
@ -6250,7 +6248,7 @@ begin
gtk_cell_layout_clear(PGtkCellLayout(FCentralWidget)); gtk_cell_layout_clear(PGtkCellLayout(FCentralWidget));
gtk_cell_layout_pack_start(PGtkCellLayout(FCentralWidget), renderer, True); gtk_cell_layout_pack_start(PGtkCellLayout(FCentralWidget), renderer, True);
if not (ACombo.Style in [csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable]) then if not ACombo.Style.IsOwnerDrawn then
gtk_cell_layout_set_attributes(PGtkCellLayout(FCentralWidget), renderer, ['text', 0, nil]); gtk_cell_layout_set_attributes(PGtkCellLayout(FCentralWidget), renderer, ['text', 0, nil]);
gtk_cell_layout_set_cell_data_func(PGtkCellLayout(FCentralWidget), renderer, gtk_cell_layout_set_cell_data_func(PGtkCellLayout(FCentralWidget), renderer,
@LCLIntfCellRenderer_CellDataFunc, Self, nil); @LCLIntfCellRenderer_CellDataFunc, Self, nil);

View File

@ -1639,11 +1639,7 @@ class procedure TQtWSCustomComboBox.SetStyle(
const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle); const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle);
begin begin
TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle.HasEditBox); TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle.HasEditBox);
TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle in TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle.IsOwnerDrawn;
[csOwnerDrawFixed,
csOwnerDrawVariable,
csOwnerDrawEditableFixed,
csOwnerDrawEditableVariable];
// TODO: implement styles: csSimple // TODO: implement styles: csSimple
inherited SetStyle(ACustomComboBox, NewStyle); inherited SetStyle(ACustomComboBox, NewStyle);
end; end;
@ -1718,12 +1714,12 @@ var
begin begin
if not WSCheckHandleAllocated(ACustomComboBox, 'SetItemHeight') then if not WSCheckHandleAllocated(ACustomComboBox, 'SetItemHeight') then
Exit; Exit;
{only for csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable} {only for OwnerDrawn}
ComboBox := TQtComboBox(ACustomComboBox.Handle); ComboBox := TQtComboBox(ACustomComboBox.Handle);
if ComboBox.getDroppedDown then if ComboBox.getDroppedDown then
begin begin
ComboBox.DropList.setUniformItemSizes(False); ComboBox.DropList.setUniformItemSizes(False);
ComboBox.DropList.setUniformItemSizes(ACustomComboBox.Style in [csOwnerDrawFixed, csOwnerDrawEditableFixed]); ComboBox.DropList.setUniformItemSizes(ACustomComboBox.Style.IsOwnerDrawn);
end else end else
RecreateWnd(ACustomComboBox); RecreateWnd(ACustomComboBox);
end; end;

View File

@ -1584,11 +1584,7 @@ class procedure TQtWSCustomComboBox.SetStyle(
const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle); const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle);
begin begin
TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle.HasEditBox); TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle.HasEditBox);
TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle in TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle.IsOwnerDrawn;
[csOwnerDrawFixed,
csOwnerDrawVariable,
csOwnerDrawEditableFixed,
csOwnerDrawEditableVariable];
// TODO: implement styles: csSimple // TODO: implement styles: csSimple
inherited SetStyle(ACustomComboBox, NewStyle); inherited SetStyle(ACustomComboBox, NewStyle);
end; end;
@ -1663,12 +1659,12 @@ var
begin begin
if not WSCheckHandleAllocated(ACustomComboBox, 'SetItemHeight') then if not WSCheckHandleAllocated(ACustomComboBox, 'SetItemHeight') then
Exit; Exit;
{only for csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable} {only for OwnerDrawn}
ComboBox := TQtComboBox(ACustomComboBox.Handle); ComboBox := TQtComboBox(ACustomComboBox.Handle);
if ComboBox.getDroppedDown then if ComboBox.getDroppedDown then
begin begin
ComboBox.DropList.setUniformItemSizes(False); ComboBox.DropList.setUniformItemSizes(False);
ComboBox.DropList.setUniformItemSizes(ACustomComboBox.Style in [csOwnerDrawFixed, csOwnerDrawEditableFixed]); ComboBox.DropList.setUniformItemSizes(ACustomComboBox.Style.IsOwnerDrawn);
end else end else
RecreateWnd(ACustomComboBox); RecreateWnd(ACustomComboBox);
end; end;

View File

@ -1464,7 +1464,7 @@ begin
(((lWinControl is TCustomListbox) and (((lWinControl is TCustomListbox) and
(TCustomListBox(lWinControl).Style <> lbStandard)) or (TCustomListBox(lWinControl).Style <> lbStandard)) or
((lWinControl is TCustomCombobox) and ((lWinControl is TCustomCombobox) and
(TCustomCombobox(lWinControl).Style in [csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable]))) TCustomCombobox(lWinControl).Style.IsOwnerDrawn))
then then
UpdateDrawListItem(LM_DRAWLISTITEM) UpdateDrawListItem(LM_DRAWLISTITEM)
else if Assigned(WindowInfo^.DrawItemHandler) then begin else if Assigned(WindowInfo^.DrawItemHandler) then begin

View File

@ -1372,7 +1372,7 @@ begin
if ((lWinControl is TCustomListbox) and if ((lWinControl is TCustomListbox) and
(TCustomListBox(lWinControl).Style <> lbStandard)) or (TCustomListBox(lWinControl).Style <> lbStandard)) or
((lWinControl is TCustomCombobox) and ((lWinControl is TCustomCombobox) and
(TCustomCombobox(lWinControl).Style in [csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable])) TCustomCombobox(lWinControl).Style.IsOwnerDrawn)
then then
begin begin
if PDrawItemStruct(LParam)^.itemID <> dword(-1) then if PDrawItemStruct(LParam)^.itemID <> dword(-1) then

View File

@ -261,6 +261,8 @@ type
TComboBoxStyleHelper = type helper for TComboBoxStyle TComboBoxStyleHelper = type helper for TComboBoxStyle
public public
function HasEditBox: Boolean; function HasEditBox: Boolean;
function IsOwnerDrawn: Boolean;
function IsVariable: Boolean;
end; end;
TOwnerDrawState = LCLType.TOwnerDrawState; TOwnerDrawState = LCLType.TOwnerDrawState;