[lazarus] Programmatically showing the listbox of combobox

hernan.et at pg.com hernan.et at pg.com
Thu Jun 5 18:44:55 EDT 2003




What is this patch for?

This patch will enable to programmatically show the list box of the combobox control.

How to use?

Set DroppedDown to true, e.g., combobox1.DroppedDown := True;
this cause the list box to show up.
Set DroppedDown to false to hide the list box, e.g, combobox1.DroppedDown := False;



changes to  stdctrls.pp

213d212
<     procedure CreateWnd; override;
260a259
>     property Style: TComboBoxStyle read FStyle write SetStyle;
281d279
<     property Style: TComboBoxStyle read FStyle write SetStyle;


changes to customcombobox.inc

77,81c77,79
< procedure TCustomComboBox.CreateWnd;
< begin
<   inherited CreateWnd;
<   CNSendMessage(LM_SETPROPERTIES, Self, nil);
< end;
---
> {------------------------------------------------------------------------------
>   procedure TCustomComboBox.DrawItem(Index: Integer; Rect: TRect;
>     State: TOwnerDrawState);
83,87d81
< {------------------------------------------------------------------------------
<   procedure TCustomComboBox.DrawItem(Index: Integer; Rect: TRect;
<     State: TOwnerDrawState);
<
<
367,368c361
<     if HandleAllocated then
<       CNSendMessage(LM_SETPROPERTIES, Self, nil);
---
>     // ToDo


changes to gtkobject.inc

6030,6031c6030,6031
<     csCombobox :
<       with TCustomComboBox(Sender) do
---
>     csEdit :
>       with TCustomEdit(Sender) do
6033,6045c6033,6040
<           case TCustomComboBox(Sender).Style of
<             csDropDownList :
<               begin
<                 gtk_combo_set_value_in_list(PgtkCombo(Handle),-1, 0);
<                 gtk_combo_set_use_arrows_always(PgtkCombo(Handle),-1);
<                 gtk_combo_set_case_sensitive(PGtkCombo(Handle),0);
<               end;
<             else
<               begin
<                 gtk_combo_set_value_in_list(PgtkCombo(Handle),0,0);
<                 gtk_combo_set_use_arrows_always(PgtkCombo(Handle),0);
<               end;
<           end;
---
>           // XXX TODO: GTK 1.x does not support EchoMode emNone.
>           // This will have to be coded around, but not a priority
>
>           gtk_entry_set_editable(PgtkEntry(Handle), not (TCustomEdit(Sender).ReadOnly));
>           gtk_entry_set_max_length(PgtkEntry(Handle), TCustomEdit(Sender).MaxLength);
>           gtk_entry_set_visibility(PGtkEntry(Handle),
>             (TCustomEdit(Sender).EchoMode = emNormal)
>             and (TCustomEdit(Sender).PassWordChar=#0));
6047,6059d6042
<     csEdit :
<       with TCustomEdit(Sender) do
<         begin
<           // XXX TODO: GTK 1.x does not support EchoMode emNone.
<           // This will have to be coded around, but not a priority
<
<           gtk_entry_set_editable(PgtkEntry(Handle), not (TCustomEdit(Sender).ReadOnly));
<           gtk_entry_set_max_length(PgtkEntry(Handle), TCustomEdit(Sender).MaxLength);
<           gtk_entry_set_visibility(PGtkEntry(Handle),
<             (TCustomEdit(Sender).EchoMode = emNormal)
<             and (TCustomEdit(Sender).PassWordChar=#0));
<         end;
<


changes to gtkwinapi.inc

1941,1942c1941,1954
<   procedure gtk_combo_get_pos(combo : PGtkCombo; var x : gint; var  y : gint; var height : gint; var width : gint);
<   var
---
> var
>   ComboWidget: PGtkCombo;
> begin
>   Result:=false;
>   if Handle=0 then exit;
>   ComboWidget:=PGtkCombo(Handle);
>   if DropDown<>GTK_WIDGET_VISIBLE(ComboWidget^.popwin) then begin
>     if DropDown then begin
>       writeln('TgtkObject.ComboBoxDropDown ToDo: Find the trick to popup the combobox');
>     end else
>       gtk_widget_hide (ComboWidget^.popwin);
>   end;
>   Result:=true;
> end;
1944,1962c1956,1959
<     popwin : PGtkbin;
<     widget : PGtkWidget;
<     popup : PGtkScrolledwindow;
<     real_height : gint;
<     list_requisition : PGtkRequisition;
<     show_hscroll : gboolean;
<     show_vscroll : gboolean;
<     avail_height : gint;
<     min_height : gint;
<     alloc_width : gint;
<     work_height : gint;
<     old_height : gint;
<     old_width : gint;
<     okay_to_exit : boolean;
<   const
<     EMPTY_LIST_HEIGHT = 15;
<   begin
<     show_hscroll := False;
<     show_vscroll := False;
---
> {------------------------------------------------------------------------------
>   Function: ExtSelectClipRGN
>   Params:  dc, RGN, Mode
>   Returns: integer
1964,1976c1961,1962
<     widget := GTK_WIDGET(combo);
<     popup  := GTK_SCROLLED_WINDOW (combo^.popup);
<     popwin := GTK_BIN (combo^.popwin);
<     gdk_window_get_origin (combo^.entry^.window, @x, @y);
<     real_height := MIN (combo^.entry^.requisition.height,
<              combo^.entry^.allocation.height);
<     y := y + real_height;
<     avail_height := gdk_screen_height () - y;
<     New(list_requisition);
<     gtk_widget_size_request (combo^.list, list_requisition);
<     min_height := list_requisition^.height;
< //    if min_height < popup^.vscrollbar^.requisition.height then
< //      min_height := popup^.vscrollbar^.requisition.height;
---
>   Combines the passed Region with the current clipping region in the device
>   context (dc), using the specified mode.
1978,1980c1964,1965
<     min_height := MIN (list_requisition^.height,popup^.vscrollbar^.requisition.height);
<     if  GTK_LIST (combo^.list)^.children = nil then
<       list_requisition^.height := list_requisition^.height + EMPTY_LIST_HEIGHT;
---
>   The Combine Mode can be one of the following:
>       RGN_AND  : all points which are in both regions
1982,1987c1967
<     alloc_width := (widget^.allocation.width -
<       2 * PGtkStyle(popwin^.child^.thestyle)^.klass^.xthickness -
<       2 * border_width(GTK_CONTAINER (popwin^.child)^) -
<       2 * border_width(GTK_CONTAINER (combo^.popup)^) -
<       2 * border_width(GTK_CONTAINER (GTK_BIN (popup)^.child)^) -
<       2 * PGtkStyle(GTK_BIN (popup)^.child^.thestyle)^.klass^.xthickness);
---
>       RGN_COPY : an exact copy of the source region, same as SelectClipRGN
1989,1993c1969,1970
<     work_height := (2 * (PGtkStyle(popwin^.child^.thestyle)^.klass^.ythickness) +
<           2 * border_width(GTK_CONTAINER (popwin^.child)^) +
<           2 * border_width(GTK_CONTAINER (combo^.popup)^) +
<           2 * border_width(GTK_CONTAINER (GTK_BIN (popup)^.child)^) +
<           2 * PGtkStyle(GTK_BIN (popup)^.child^.thestyle)^.klass^.xthickness);
---
>       RGN_DIFF : all points which are in the Clipping Region but
>                  but not in the Source.(Clip - RGN)
1995,1998c1972,1973
<     repeat
<       okay_to_exit := True;
<       old_width := alloc_width;
<       old_height := work_height;
---
>       RGN_OR   : all points which are in either the Clip Region or
>                  in the Source.(Clip + RGN)
2000,2020c1975,1976
<       if ((not show_hscroll) and (alloc_width < list_requisition^.width)) then
<       begin
<             work_height := work_height +  popup^.hscrollbar^.requisition.height +
<           GTK_SCROLLED_WINDOW_CLASS(GTK_OBJECT (combo^.popup)^.klass)^.scrollbar_spacing;
<         show_hscroll := TRUE;
<         okay_to_exit := False;
<       end;
<       if ((not show_vscroll) and (work

I have tried to use diff -ur --exclude=CVS /orig_lazarus/ /changed_laz/ | gzip > laz.diff.gz but I am generated a large file, maybe my working copy is quite
old.
If it is better to send the generated file, please let me know.

Yoyong






More information about the Lazarus mailing list