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:
ondrej 2017-06-05 19:27:43 +00:00
parent 2276076e95
commit c68b93c58e
11 changed files with 38 additions and 30 deletions

View File

@ -92,7 +92,7 @@ begin
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin
if (Style in [csOwnerDrawFixed, csOwnerDrawVariable])
if (Style in [csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable])
and (FItemHeight > 0) then
ItemHeight := Round(ItemHeight * AYProportion);
end;
@ -251,7 +251,7 @@ end;
procedure TCustomComboBox.CloseUp;
begin
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;
if Assigned(FOnCloseUp) then FOnCloseUp(Self);
if FAutoSelect then
@ -473,13 +473,13 @@ procedure TCustomComboBox.CreateParams(var Params: TCreateParams);
const
ComboBoxStyles: array[TComboBoxStyle] of dword = (
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
inherited CreateParams(Params);
Params.Style := Params.Style or (WS_VSCROLL or CBS_AUTOHSCROLL or CBS_HASSTRINGS) or
ComboBoxStyles[Style];
if Style in [csOwnerDrawFixed, csOwnerDrawVariable] then
Params.Style := Params.Style or CBS_DROPDOWNLIST;
if Sorted then
Params.Style := Params.Style or CBS_SORT;
end;

View File

@ -1540,7 +1540,7 @@ begin
g_object_set_data(G_OBJECT(renderer), 'widgetinfo', AWidgetInfo);
gtk_cell_layout_clear(PGtkCellLayout(AWidget));
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_cell_data_func(PGtkCellLayout(AWidget), renderer,
@LCLIntfCellRenderer_CellDataFunc, AWidgetInfo, nil);
@ -1976,7 +1976,9 @@ begin
p := WidgetInfo^.CoreWidget;
case NewStyle of
csDropDown,
csSimple:
csSimple,
csOwnerDrawEditableFixed,
csOwnerDrawEditableVariable:
NeedEntry := True;
csDropDownList,
csOwnerDrawFixed,
@ -2119,7 +2121,9 @@ begin
case ACustomComboBox.Style of
csDropDown,
csSimple:
csSimple,
csOwnerDrawEditableFixed,
csOwnerDrawEditableVariable:
NeedEntry := True;
csDropDownList,
csOwnerDrawFixed,

View File

@ -5880,7 +5880,7 @@ begin
gtk_cell_layout_clear(PGtkCellLayout(FCentralWidget));
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_cell_data_func(PGtkCellLayout(FCentralWidget), renderer,
@LCLIntfCellRenderer_CellDataFunc, Self, nil);

View File

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

View File

@ -1574,7 +1574,9 @@ begin
TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle in [csDropDown, csSimple]);
TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle in
[csOwnerDrawFixed,
csOwnerDrawVariable];
csOwnerDrawVariable,
csOwnerDrawEditableFixed,
csOwnerDrawEditableVariable];
// TODO: implement styles: csSimple
inherited SetStyle(ACustomComboBox, NewStyle);
end;
@ -1649,12 +1651,12 @@ var
begin
if not WSCheckHandleAllocated(ACustomComboBox, 'SetItemHeight') then
Exit;
{only for csOwnerDrawFixed, csOwnerDrawVariable}
{only for csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable}
ComboBox := TQtComboBox(ACustomComboBox.Handle);
if ComboBox.getDroppedDown then
begin
ComboBox.DropList.setUniformItemSizes(False);
ComboBox.DropList.setUniformItemSizes(ACustomComboBox.Style = csOwnerDrawFixed);
ComboBox.DropList.setUniformItemSizes(ACustomComboBox.Style in [csOwnerDrawFixed, csOwnerDrawEditableFixed]);
end else
RecreateWnd(ACustomComboBox);
end;

View File

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

View File

@ -391,7 +391,7 @@ var
SaveText: String;
SavePos, SaveLen: Integer;
begin
if TCustomComboBox(FSender).Style in [csSimple, csDropDown] then // To-Do: csOwnerDrawEditableFixed
if TCustomComboBox(FSender).Style in [csSimple, csDropDown, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable] then
begin
SaveText := TCustomComboBox(FSender).Text;
SavePos := TCustomComboBox(FSender).SelStart;
@ -399,7 +399,7 @@ begin
end;
inherited;
UpdateComboHeight;
if TCustomComboBox(FSender).Style in [csSimple, csDropDown] then // To-Do: csOwnerDrawEditableFixed
if TCustomComboBox(FSender).Style in [csSimple, csDropDown, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable] then
begin
TCustomComboBox(FSender).Text := SaveText;
TCustomComboBox(FSender).SelStart := SavePos;

View File

@ -940,11 +940,10 @@ function CalcComboBoxWinFlags(AComboBox: TCustomComboBox): dword;
const
ComboBoxStyles: array[TComboBoxStyle] of dword = (
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
Result := ComboBoxStyles[AComboBox.Style];
if AComboBox.Style in [csOwnerDrawFixed, csOwnerDrawVariable] then
Result := Result or CBS_DROPDOWNLIST;
end;
class function TWin32WSCustomComboBox.GetStringList(

View File

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

View File

@ -639,13 +639,13 @@ const
CBS_DROPDOWN,
0 {CBS_SIMPLE},
CBS_DROPDOWNLIST,
0 {CBS_OWNERDRAWFIXED},
0 {CBS_OWNERDRAWVARIABLE}
0 or CBS_DROPDOWNLIST {CBS_OWNERDRAWFIXED},
0 or CBS_DROPDOWNLIST {CBS_OWNERDRAWVARIABLE},
0 or CBS_DROPDOWN {CBS_OWNERDRAWFIXED},
0 or CBS_DROPDOWN {CBS_OWNERDRAWVARIABLE}
);
begin
Result := ComboBoxStyles[AComboBox.Style];
if AComboBox.Style in [csOwnerDrawFixed, csOwnerDrawVariable] then
Result := Result or CBS_DROPDOWNLIST;
end;
class function TWinCEWSCustomComboBox.CreateHandle(const AWinControl: TWinControl;

View File

@ -248,7 +248,9 @@ type
csSimple, // like an TEdit plus a TListBox
csDropDownList, // like TLabel plus a button to drop down the list
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;