gtk2: use another rules to choose whether combobox will have entry or no (fixes issue #0009303)

git-svn-id: trunk@19644 -
This commit is contained in:
paul 2009-04-27 05:29:20 +00:00
parent b3e275d1d9
commit 4c79bca2f3
2 changed files with 35 additions and 23 deletions

View File

@ -2589,18 +2589,18 @@ begin
end; end;
end; end;
procedure TPropertyEditor.SetOrdValue(const NewValue:Longint); procedure TPropertyEditor.SetOrdValue(const NewValue: Longint);
var var
I:Integer; I:Integer;
Changed: boolean; Changed: boolean;
begin begin
Changed:=false; Changed := False;
for I:=0 to FPropCount-1 do for I := 0 to FPropCount - 1 do
with FPropList^[I] do with FPropList^[I] do
Changed:=Changed or (GetOrdProp(Instance,PropInfo)<>NewValue); Changed := Changed or (GetOrdProp(Instance, PropInfo) <> NewValue);
if Changed then begin if Changed then begin
for I:=0 to FPropCount-1 do for I:=0 to FPropCount-1 do
with FPropList^[I] do SetOrdProp(Instance,PropInfo,NewValue); with FPropList^[I] do SetOrdProp(Instance, PropInfo, NewValue);
Modified; Modified;
end; end;
end; end;

View File

@ -1426,24 +1426,22 @@ class procedure TGtk2WSCustomComboBox.SetStyle(
var var
WidgetInfo: PWidgetInfo; WidgetInfo: PWidgetInfo;
p: PGtkWidget; p: PGtkWidget;
NeedEntry: Boolean;
begin begin
WidgetInfo := GetWidgetInfo(Pointer(ACustomComboBox.Handle)); WidgetInfo := GetWidgetInfo(Pointer(ACustomComboBox.Handle));
p := WidgetInfo^.CoreWidget; p := WidgetInfo^.CoreWidget;
case NewStyle of case NewStyle of
csDropDown, csDropDown,
csSimple: csSimple:
begin NeedEntry := True;
if gtk_is_combo_box_entry(p) then Exit; csDropDownList:
ReCreateCombo(ACustomComboBox, True, WidgetInfo); NeedEntry := False;
end;
csDropDownList,
csOwnerDrawFixed, csOwnerDrawFixed,
csOwnerDrawVariable: csOwnerDrawVariable:
begin NeedEntry := not ACustomComboBox.ReadOnly;
if not gtk_is_combo_box_entry(p) then Exit;
ReCreateCombo(ACustomComboBox, False, WidgetInfo);
end;
end; end;
if gtk_is_combo_box_entry(p) = NeedEntry then Exit;
ReCreateCombo(ACustomComboBox, NeedEntry, WidgetInfo);
end; end;
class procedure TGtk2WSCustomComboBox.SetReadOnly( class procedure TGtk2WSCustomComboBox.SetReadOnly(
@ -1454,10 +1452,17 @@ var
begin begin
WidgetInfo := GetWidgetInfo(Pointer(ACustomComboBox.Handle)); WidgetInfo := GetWidgetInfo(Pointer(ACustomComboBox.Handle));
if gtk_is_combo_box_entry(WidgetInfo^.CoreWidget) then begin if gtk_is_combo_box_entry(WidgetInfo^.CoreWidget) then
begin
Entry := GTK_BIN(WidgetInfo^.CoreWidget)^.child; Entry := GTK_BIN(WidgetInfo^.CoreWidget)^.child;
gtk_entry_set_editable(PGtkEntry(Entry), not NewReadOnly); if ACustomComboBox.Style in [csDropDown, csSimple] then
end; gtk_entry_set_editable(PGtkEntry(Entry), not NewReadOnly)
else
if (PGtkEntry(Entry)^.flag0 and $1) = Ord(NewReadOnly) then
ReCreateCombo(ACustomCombobox, not NewReadOnly, WidgetInfo);
end
else
ReCreateCombo(ACustomCombobox, not NewReadOnly, WidgetInfo);
end; end;
class function TGtk2WSCustomComboBox.GetItems( class function TGtk2WSCustomComboBox.GetItems(
@ -1563,8 +1568,9 @@ var
ACustomComboBox: TCustomComboBox; ACustomComboBox: TCustomComboBox;
ItemList: TGtkListStoreStringList; ItemList: TGtkListStoreStringList;
LCLIndex: PLongint; LCLIndex: PLongint;
NeedEntry: Boolean;
begin begin
ACustomComboBox:=TCustomComboBox(AWinControl); ACustomComboBox := TCustomComboBox(AWinControl);
Box := gtk_event_box_new; Box := gtk_event_box_new;
{$IFDEF DebugLCLComponents} {$IFDEF DebugLCLComponents}
@ -1576,13 +1582,19 @@ 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 case ACustomComboBox.Style of
csDropDown, csSimple: csDropDown,
ComboWidget := gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL (ListStore), 0); csSimple:
csDropDownList, NeedEntry := True;
csDropDownList:
NeedEntry := False;
csOwnerDrawFixed, csOwnerDrawFixed,
csOwnerDrawVariable : csOwnerDrawVariable:
ComboWidget := gtk_combo_box_new_with_model(GTK_TREE_MODEL (ListStore)); NeedEntry := not ACustomComboBox.ReadOnly;
end; end;
if NeedEntry then
ComboWidget := gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL (ListStore), 0)
else
ComboWidget := gtk_combo_box_new_with_model(GTK_TREE_MODEL (ListStore));
SetSensitivity(AWinControl, ComboWidget); SetSensitivity(AWinControl, ComboWidget);