diff options
-rw-r--r-- | src/gui/fpgui_package.lpk | 14 | ||||
-rw-r--r-- | src/gui/fpgui_package.pas | 3 | ||||
-rw-r--r-- | src/gui/gui_editcombo.pas | 32 | ||||
-rw-r--r-- | src/gui/gui_listbox.pas | 2 |
4 files changed, 33 insertions, 18 deletions
diff --git a/src/gui/fpgui_package.lpk b/src/gui/fpgui_package.lpk index 0e178984..06e68ea5 100644 --- a/src/gui/fpgui_package.lpk +++ b/src/gui/fpgui_package.lpk @@ -31,7 +31,7 @@ <License Value="Modified LGPL "/> <Version Minor="6" Release="1"/> - <Files Count="28"> + <Files Count="29"> <Item1> <Filename Value="gui_button.pas"/> <UnitName Value="gui_button"/> @@ -144,16 +144,20 @@ <Filename Value="gui_gauge.pas"/> <UnitName Value="gui_gauge"/> </Item28> + <Item29> + <Filename Value="gui_editcombo.pas"/> + <UnitName Value="gui_editcombo"/> + </Item29> </Files> <LazDoc Paths="../../docs/xml/gui/"/> <RequiredPkgs Count="2"> <Item1> - <PackageName Value="FCL"/> - <MinVersion Major="1" Valid="True"/> - </Item1> - <Item2> <PackageName Value="fpgfx_package"/> <MinVersion Minor="6" Release="1" Valid="True"/> + </Item1> + <Item2> + <PackageName Value="FCL"/> + <MinVersion Major="1" Valid="True"/> </Item2> </RequiredPkgs> <UsageOptions> diff --git a/src/gui/fpgui_package.pas b/src/gui/fpgui_package.pas index ad9e692a..964bea47 100644 --- a/src/gui/fpgui_package.pas +++ b/src/gui/fpgui_package.pas @@ -11,7 +11,8 @@ uses gui_listbox, gui_memo, gui_scrollbar, gui_bevel, gui_checkbox, gui_radiobutton, gui_trackbar, gui_tab, gui_basegrid, gui_listview, gui_customgrid, gui_progressbar, gui_menu, gui_style, gui_grid, gui_tree, - gui_iniutils, gui_mru, fpgui_db, gui_popupcalendar, gui_gauge; + gui_iniutils, gui_mru, fpgui_db, gui_popupcalendar, gui_gauge, + gui_editcombo; implementation diff --git a/src/gui/gui_editcombo.pas b/src/gui/gui_editcombo.pas index 7e8ffc85..00fd11c3 100644 --- a/src/gui/gui_editcombo.pas +++ b/src/gui/gui_editcombo.pas @@ -61,7 +61,8 @@ uses gfx_popupwindow; type - TAllowNew = (anNo,anYes,anAsk); + TAllowNew = (anNo, anYes, anAsk); + TfpgAbstractEditCombo = class(TfpgWidget) private @@ -109,6 +110,7 @@ type procedure HandlePaint; override; procedure PaintInternalButton; virtual; property DropDownCount: integer read FDropDownCount write SetDropDownCount default 8; + // property is 0-based property Items: TStringList read FItems; {$Note Make this read/write} // property is 1-based property FocusItem: integer read FFocusItem write SetFocusItem; @@ -349,11 +351,11 @@ begin begin FreeAndNil(FDropDown); OriginalFocusRoot := FocusRootWidget; - FDropDown := TDropDownWindow.Create(nil); + FDropDown := TDropDownWindow.Create(nil); ddw := TDropDownWindow(FDropDown); ddw.Width := Width; - ddw.CallerWidget := self; - ddw.ListBox.OnSelect := @InternalListBoxSelect; + ddw.CallerWidget := self; + ddw.ListBox.OnSelect := @InternalListBoxSelect; // Assign combobox text items to internal listbox if FAutoCompletion then @@ -371,7 +373,7 @@ begin rowcount := FDropDownCount; if rowcount < 1 then rowcount := 1; - ddw.Height := (ddw.ListBox.RowHeight * rowcount) + 4; + ddw.Height := (ddw.ListBox.RowHeight * rowcount) + 4; // set default focusitem ddw.ListBox.FocusItem := FFocusItem; @@ -396,9 +398,17 @@ end; procedure TfpgAbstractEditCombo.InternalListBoxSelect(Sender: TObject); var - msgp: TfpgMessageParams; + i: Integer; begin - FFocusItem := TDropDownWindow(FDropDown).ListBox.FocusItem; + for i := 0 to Items.Count-1 do + begin + // Items is 0-based and FocusItem is 1-based + if Items[i]= TDropDownWindow(FDropDown).ListBox.Items[TDropDownWindow(FDropDown).ListBox.FocusItem-1] then + begin + FFocusItem := i+1; + Break; + end; + end; FDropDown.Close; if HasHandle then @@ -442,7 +452,7 @@ begin begin for i := 0 to FItems.Count - 1 do begin - if SameText(UTF8Copy(FItems.Strings[i],1,UTF8Length(AVAlue)), AValue) then + if SameText(UTF8Copy(FItems.Strings[i], 1, UTF8Length(AVAlue)), AValue) then begin SetFocusItem(i+1); // our FocusItem is 1-based. TStringList is 0-based. Break; @@ -484,9 +494,9 @@ var s: string; prevval: string; begin - prevval := FText; - s := UTF8Encode(AText); - consumed := False; + prevval := FText; + s := UTF8Encode(AText); + consumed := False; // Handle only printable characters // Note: This is not UTF-8 compliant! diff --git a/src/gui/gui_listbox.pas b/src/gui/gui_listbox.pas index dd83bd5d..29cf50f7 100644 --- a/src/gui/gui_listbox.pas +++ b/src/gui/gui_listbox.pas @@ -273,7 +273,7 @@ begin FScrollBar.SliderSize := pn / ItemCount else FScrollBar.SliderSize := 1; - FScrollBar.Max := ItemCount-pn{+1}; // change to avoid the last blanc item + FScrollBar.Max := ItemCount-pn+1; FScrollBar.Position := FFirstItem; FScrollBar.RepaintSlider; end; |