mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-06 17:18:19 +02:00
lcl: combo box: add new styles csOwnerDrawEditableFixed and csOwnerDrawEditableVariable as replacement for the old ReadOnly property
git-svn-id: trunk@55245 -
This commit is contained in:
parent
2276076e95
commit
c68b93c58e
@ -92,7 +92,7 @@ begin
|
|||||||
|
|
||||||
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
|
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
|
||||||
begin
|
begin
|
||||||
if (Style in [csOwnerDrawFixed, csOwnerDrawVariable])
|
if (Style in [csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable])
|
||||||
and (FItemHeight > 0) then
|
and (FItemHeight > 0) then
|
||||||
ItemHeight := Round(ItemHeight * AYProportion);
|
ItemHeight := Round(ItemHeight * AYProportion);
|
||||||
end;
|
end;
|
||||||
@ -251,7 +251,7 @@ end;
|
|||||||
procedure TCustomComboBox.CloseUp;
|
procedure TCustomComboBox.CloseUp;
|
||||||
begin
|
begin
|
||||||
if [csLoading,csDestroying,csDesigning]*ComponentState<>[] then exit;
|
if [csLoading,csDestroying,csDesigning]*ComponentState<>[] then exit;
|
||||||
if Style in [csSimple, csDropDown] then // To-Do: csOwnerDrawEditableFixed, csOwnerDrawEditableVariable
|
if Style in [csSimple, csDropDown, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable] then
|
||||||
EditingDone;
|
EditingDone;
|
||||||
if Assigned(FOnCloseUp) then FOnCloseUp(Self);
|
if Assigned(FOnCloseUp) then FOnCloseUp(Self);
|
||||||
if FAutoSelect then
|
if FAutoSelect then
|
||||||
@ -473,13 +473,13 @@ procedure TCustomComboBox.CreateParams(var Params: TCreateParams);
|
|||||||
const
|
const
|
||||||
ComboBoxStyles: array[TComboBoxStyle] of dword = (
|
ComboBoxStyles: array[TComboBoxStyle] of dword = (
|
||||||
CBS_DROPDOWN, CBS_SIMPLE, CBS_DROPDOWNLIST,
|
CBS_DROPDOWN, CBS_SIMPLE, CBS_DROPDOWNLIST,
|
||||||
CBS_OWNERDRAWFIXED, CBS_OWNERDRAWVARIABLE);
|
CBS_OWNERDRAWFIXED or CBS_DROPDOWNLIST, CBS_OWNERDRAWVARIABLE or CBS_DROPDOWNLIST,
|
||||||
|
CBS_OWNERDRAWFIXED or CBS_DROPDOWN, CBS_OWNERDRAWVARIABLE or CBS_DROPDOWN);
|
||||||
begin
|
begin
|
||||||
inherited CreateParams(Params);
|
inherited CreateParams(Params);
|
||||||
Params.Style := Params.Style or (WS_VSCROLL or CBS_AUTOHSCROLL or CBS_HASSTRINGS) or
|
Params.Style := Params.Style or (WS_VSCROLL or CBS_AUTOHSCROLL or CBS_HASSTRINGS) or
|
||||||
ComboBoxStyles[Style];
|
ComboBoxStyles[Style];
|
||||||
if Style in [csOwnerDrawFixed, csOwnerDrawVariable] then
|
|
||||||
Params.Style := Params.Style or CBS_DROPDOWNLIST;
|
|
||||||
if Sorted then
|
if Sorted then
|
||||||
Params.Style := Params.Style or CBS_SORT;
|
Params.Style := Params.Style or CBS_SORT;
|
||||||
end;
|
end;
|
||||||
|
@ -1540,7 +1540,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]) then
|
if not (ACustomComboBox.Style in [csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable]) 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);
|
||||||
@ -1976,7 +1976,9 @@ begin
|
|||||||
p := WidgetInfo^.CoreWidget;
|
p := WidgetInfo^.CoreWidget;
|
||||||
case NewStyle of
|
case NewStyle of
|
||||||
csDropDown,
|
csDropDown,
|
||||||
csSimple:
|
csSimple,
|
||||||
|
csOwnerDrawEditableFixed,
|
||||||
|
csOwnerDrawEditableVariable:
|
||||||
NeedEntry := True;
|
NeedEntry := True;
|
||||||
csDropDownList,
|
csDropDownList,
|
||||||
csOwnerDrawFixed,
|
csOwnerDrawFixed,
|
||||||
@ -2119,7 +2121,9 @@ begin
|
|||||||
|
|
||||||
case ACustomComboBox.Style of
|
case ACustomComboBox.Style of
|
||||||
csDropDown,
|
csDropDown,
|
||||||
csSimple:
|
csSimple,
|
||||||
|
csOwnerDrawEditableFixed,
|
||||||
|
csOwnerDrawEditableVariable:
|
||||||
NeedEntry := True;
|
NeedEntry := True;
|
||||||
csDropDownList,
|
csDropDownList,
|
||||||
csOwnerDrawFixed,
|
csOwnerDrawFixed,
|
||||||
|
@ -5880,7 +5880,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]) then
|
if not (ACombo.Style in [csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable]) 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);
|
||||||
|
@ -1592,10 +1592,12 @@ end;
|
|||||||
class procedure TQtWSCustomComboBox.SetStyle(
|
class procedure TQtWSCustomComboBox.SetStyle(
|
||||||
const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle);
|
const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle);
|
||||||
begin
|
begin
|
||||||
TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle in [csDropDown, csSimple]);
|
TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle in [csDropDown, csSimple, csOwnerDraw]);
|
||||||
TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle in
|
TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle in
|
||||||
[csOwnerDrawFixed,
|
[csOwnerDrawFixed,
|
||||||
csOwnerDrawVariable];
|
csOwnerDrawVariable,
|
||||||
|
csOwnerDrawEditableFixed,
|
||||||
|
csOwnerDrawEditableVariable];
|
||||||
// TODO: implement styles: csSimple
|
// TODO: implement styles: csSimple
|
||||||
inherited SetStyle(ACustomComboBox, NewStyle);
|
inherited SetStyle(ACustomComboBox, NewStyle);
|
||||||
end;
|
end;
|
||||||
@ -1670,12 +1672,12 @@ var
|
|||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(ACustomComboBox, 'SetItemHeight') then
|
if not WSCheckHandleAllocated(ACustomComboBox, 'SetItemHeight') then
|
||||||
Exit;
|
Exit;
|
||||||
{only for csOwnerDrawFixed, csOwnerDrawVariable}
|
{only for csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable}
|
||||||
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 = csOwnerDrawFixed);
|
ComboBox.DropList.setUniformItemSizes(ACustomComboBox.Style in [csOwnerDrawFixed, csOwnerDrawEditableFixed]);
|
||||||
end else
|
end else
|
||||||
RecreateWnd(ACustomComboBox);
|
RecreateWnd(ACustomComboBox);
|
||||||
end;
|
end;
|
||||||
|
@ -1574,7 +1574,9 @@ begin
|
|||||||
TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle in [csDropDown, csSimple]);
|
TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle in [csDropDown, csSimple]);
|
||||||
TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle in
|
TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle in
|
||||||
[csOwnerDrawFixed,
|
[csOwnerDrawFixed,
|
||||||
csOwnerDrawVariable];
|
csOwnerDrawVariable,
|
||||||
|
csOwnerDrawEditableFixed,
|
||||||
|
csOwnerDrawEditableVariable];
|
||||||
// TODO: implement styles: csSimple
|
// TODO: implement styles: csSimple
|
||||||
inherited SetStyle(ACustomComboBox, NewStyle);
|
inherited SetStyle(ACustomComboBox, NewStyle);
|
||||||
end;
|
end;
|
||||||
@ -1649,12 +1651,12 @@ var
|
|||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(ACustomComboBox, 'SetItemHeight') then
|
if not WSCheckHandleAllocated(ACustomComboBox, 'SetItemHeight') then
|
||||||
Exit;
|
Exit;
|
||||||
{only for csOwnerDrawFixed, csOwnerDrawVariable}
|
{only for csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable}
|
||||||
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 = csOwnerDrawFixed);
|
ComboBox.DropList.setUniformItemSizes(ACustomComboBox.Style in [csOwnerDrawFixed, csOwnerDrawEditableFixed]);
|
||||||
end else
|
end else
|
||||||
RecreateWnd(ACustomComboBox);
|
RecreateWnd(ACustomComboBox);
|
||||||
end;
|
end;
|
||||||
|
@ -1437,8 +1437,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 = csOwnerDrawFixed) or
|
(TCustomCombobox(lWinControl).Style in [csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable])))
|
||||||
(TCustomCombobox(lWinControl).Style = csOwnerDrawVariable))))
|
|
||||||
then
|
then
|
||||||
UpdateDrawListItem(LM_DRAWLISTITEM)
|
UpdateDrawListItem(LM_DRAWLISTITEM)
|
||||||
else if Assigned(WindowInfo^.DrawItemHandler) then begin
|
else if Assigned(WindowInfo^.DrawItemHandler) then begin
|
||||||
|
@ -391,7 +391,7 @@ var
|
|||||||
SaveText: String;
|
SaveText: String;
|
||||||
SavePos, SaveLen: Integer;
|
SavePos, SaveLen: Integer;
|
||||||
begin
|
begin
|
||||||
if TCustomComboBox(FSender).Style in [csSimple, csDropDown] then // To-Do: csOwnerDrawEditableFixed
|
if TCustomComboBox(FSender).Style in [csSimple, csDropDown, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable] then
|
||||||
begin
|
begin
|
||||||
SaveText := TCustomComboBox(FSender).Text;
|
SaveText := TCustomComboBox(FSender).Text;
|
||||||
SavePos := TCustomComboBox(FSender).SelStart;
|
SavePos := TCustomComboBox(FSender).SelStart;
|
||||||
@ -399,7 +399,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
inherited;
|
inherited;
|
||||||
UpdateComboHeight;
|
UpdateComboHeight;
|
||||||
if TCustomComboBox(FSender).Style in [csSimple, csDropDown] then // To-Do: csOwnerDrawEditableFixed
|
if TCustomComboBox(FSender).Style in [csSimple, csDropDown, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable] then
|
||||||
begin
|
begin
|
||||||
TCustomComboBox(FSender).Text := SaveText;
|
TCustomComboBox(FSender).Text := SaveText;
|
||||||
TCustomComboBox(FSender).SelStart := SavePos;
|
TCustomComboBox(FSender).SelStart := SavePos;
|
||||||
|
@ -940,11 +940,10 @@ function CalcComboBoxWinFlags(AComboBox: TCustomComboBox): dword;
|
|||||||
const
|
const
|
||||||
ComboBoxStyles: array[TComboBoxStyle] of dword = (
|
ComboBoxStyles: array[TComboBoxStyle] of dword = (
|
||||||
CBS_DROPDOWN, CBS_SIMPLE, CBS_DROPDOWNLIST,
|
CBS_DROPDOWN, CBS_SIMPLE, CBS_DROPDOWNLIST,
|
||||||
CBS_OWNERDRAWFIXED, CBS_OWNERDRAWVARIABLE);
|
CBS_OWNERDRAWFIXED or CBS_DROPDOWNLIST, CBS_OWNERDRAWVARIABLE or CBS_DROPDOWNLIST,
|
||||||
|
CBS_OWNERDRAWFIXED or CBS_DROPDOWN, CBS_OWNERDRAWVARIABLE or CBS_DROPDOWN);
|
||||||
begin
|
begin
|
||||||
Result := ComboBoxStyles[AComboBox.Style];
|
Result := ComboBoxStyles[AComboBox.Style];
|
||||||
if AComboBox.Style in [csOwnerDrawFixed, csOwnerDrawVariable] then
|
|
||||||
Result := Result or CBS_DROPDOWNLIST;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TWin32WSCustomComboBox.GetStringList(
|
class function TWin32WSCustomComboBox.GetStringList(
|
||||||
|
@ -1371,8 +1371,8 @@ 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 = csOwnerDrawFixed) or
|
(TCustomCombobox(lWinControl).Style in [csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable]))
|
||||||
(TCustomCombobox(lWinControl).Style = csOwnerDrawVariable))) then
|
then
|
||||||
begin
|
begin
|
||||||
if PDrawItemStruct(LParam)^.itemID <> dword(-1) then
|
if PDrawItemStruct(LParam)^.itemID <> dword(-1) then
|
||||||
begin
|
begin
|
||||||
|
@ -639,13 +639,13 @@ const
|
|||||||
CBS_DROPDOWN,
|
CBS_DROPDOWN,
|
||||||
0 {CBS_SIMPLE},
|
0 {CBS_SIMPLE},
|
||||||
CBS_DROPDOWNLIST,
|
CBS_DROPDOWNLIST,
|
||||||
0 {CBS_OWNERDRAWFIXED},
|
0 or CBS_DROPDOWNLIST {CBS_OWNERDRAWFIXED},
|
||||||
0 {CBS_OWNERDRAWVARIABLE}
|
0 or CBS_DROPDOWNLIST {CBS_OWNERDRAWVARIABLE},
|
||||||
|
0 or CBS_DROPDOWN {CBS_OWNERDRAWFIXED},
|
||||||
|
0 or CBS_DROPDOWN {CBS_OWNERDRAWVARIABLE}
|
||||||
);
|
);
|
||||||
begin
|
begin
|
||||||
Result := ComboBoxStyles[AComboBox.Style];
|
Result := ComboBoxStyles[AComboBox.Style];
|
||||||
if AComboBox.Style in [csOwnerDrawFixed, csOwnerDrawVariable] then
|
|
||||||
Result := Result or CBS_DROPDOWNLIST;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TWinCEWSCustomComboBox.CreateHandle(const AWinControl: TWinControl;
|
class function TWinCEWSCustomComboBox.CreateHandle(const AWinControl: TWinControl;
|
||||||
|
@ -248,7 +248,9 @@ type
|
|||||||
csSimple, // like an TEdit plus a TListBox
|
csSimple, // like an TEdit plus a TListBox
|
||||||
csDropDownList, // like TLabel plus a button to drop down the list
|
csDropDownList, // like TLabel plus a button to drop down the list
|
||||||
csOwnerDrawFixed, // like csDropDownList, but custom drawn
|
csOwnerDrawFixed, // like csDropDownList, but custom drawn
|
||||||
csOwnerDrawVariable // like csDropDownList, but custom drawn and with each item can have another height
|
csOwnerDrawVariable,// like csDropDownList, but custom drawn and with each item can have another height
|
||||||
|
csOwnerDrawEditableFixed,// like csOwnerDrawFixed, but with TEdit
|
||||||
|
csOwnerDrawEditableVariable// like csOwnerDrawVariable, but with TEdit
|
||||||
);
|
);
|
||||||
|
|
||||||
TOwnerDrawState = LCLType.TOwnerDrawState;
|
TOwnerDrawState = LCLType.TOwnerDrawState;
|
||||||
|
Loading…
Reference in New Issue
Block a user