Hi
new patch for tComboBox
Mattias Gaertner wrote:
On Wed, 22 Mar 2006 22:59:40 +0100
darekM <[EMAIL PROTECTED]> wrote:
Mattias Gaertner napisa?(a):
On Wed, 22 Mar 2006 22:26:32 +0100
darekm <[EMAIL PROTECTED]> wrote:
Mattias Gaertner wrote:
On Wed, 22 Mar 2006 21:40:31 +0100
darekm <[EMAIL PROTECTED]> wrote:
Hi
please throw up last patch,
this works better
It seems, you disabled using the widgetset TStrings in InitializeWnd.
Where is it assigned now?
On CreateComboBox You assign from fItems to Widgets list
for what reverse in Initialize
Ok. Then the
'NewStrings.Assign(FItems);'
is unneccessary in TCustomComboBox.InitializeWnd.
But you deleted the 'FItems:= NewStrings;' as well, didn't you?
reverse
Then I don't understand, how it should work, we have 2 tStrings (for
component and internal in widgets) or one.
I assume there are two, if one patch should be changed.
There are two types and only one at a time.
Without a Handle TComboBox uses a TStringList.
When a handle is created, the widgetset creates a special TGtkListStringList
and the TStringList is freed.
When the handle is destroyed, a TStringList is created and the
TGtkListStringList is destroyed.
I noticed, that caption is set two times
Darek
Index: interfaces/gtk/gtkproc.inc
===================================================================
--- interfaces/gtk/gtkproc.inc (wersja 8985)
+++ interfaces/gtk/gtkproc.inc (kopia robocza)
@@ -995,7 +995,8 @@
if not ComboBox.HandleAllocated then
RaiseGDBException('');
ComboWidget:=PGtkCombo(ComboBox.Handle);
-
ComboStrings:=TStrings(gtk_object_get_data(PGtkObject(ComboWidget),'LCLList'));
+ ComboStrings:=ComboBox.items;
+//
TStrings(gtk_object_get_data(PGtkObject(ComboWidget),GtkListItemLCLListTag));
CurText:=GetComboBoxText(ComboWidget);
Result:=ComboStrings.IndexOf(CurText);
end;
@@ -1014,7 +1015,7 @@
LockOnChange(PGtkObject(ComboWidget),+1);
gtk_list_select_item(PGtkList(ComboWidget^.list),Index);
if Index>=0 then begin
-
ComboStrings:=TStrings(gtk_object_get_data(PGtkObject(ComboWidget),'LCLList'));
+
ComboStrings:=TStrings(gtk_object_get_data(PGtkObject(ComboWidget),GtkListItemLCLListTag));
if Index < ComboStrings.Count
then SetComboBoxText(ComboWidget, PChar(ComboStrings[Index]))
else SetComboBoxText(ComboWidget, '#error#');
@@ -2375,7 +2376,9 @@
if (not EventStopped) {and (not BeforeEvent)} and CanSendChar
then begin
+ {$IFDEF EventTrace}
EventTrace('char', data);
+ {$ENDIF}
KeyPressesChar:=#0;
if Event^.Length = 1 then begin
@@ -3448,7 +3451,11 @@
begin
if Target=nil then DebugLn('[DeliverMessage] Target = nil');
{$IFDEF VerboseDeliverMessage}
- if TLMessage(AMessage).Msg<>LM_MOUSEMOVE then
+ if (TLMessage(AMessage).Msg <>LM_MOUSEMOVE)
+ and (TLMessage(AMessage).Msg <>LM_PAINT)
+ and (TLMessage(AMessage).Msg <>LM_KEYDOWN)
+ and (TLMessage(AMessage).Msg <>LM_KEYUP)
+ and (TLMessage(AMessage).Msg < CN_KEYDOWN ) then
DebugLn('DeliverMessage ',DbgS(Target),
' ',TComponent(Target).Name,':',TObject(Target).ClassName,
' Message=',GetMessageName(TLMessage(AMessage).Msg));
Index: interfaces/gtk/gtklistsl.inc
===================================================================
--- interfaces/gtk/gtklistsl.inc (wersja 8985)
+++ interfaces/gtk/gtklistsl.inc (kopia robocza)
@@ -19,9 +19,6 @@
*****************************************************************************
}
-const
- GtkListItemGtkListTag = 'GtkList';
- GtkListItemLCLListTag = 'LCLList';
{*************************************************************}
{ Default compare functions }
@@ -394,6 +391,9 @@
var
ChildWidget: Pointer;
begin
+ {$IFDEF EventTrace}
+ Debugln('connect itemCallback');
+ {$ENDIF}
gtk_object_set_data(PGtkObject(AItem), GtkListItemLCLListTag, nil);
gtk_object_set_data(PGtkObject(AItem), GtkListItemGtkListTag, nil);
{$ifdef GTK2}
Index: interfaces/gtk/gtkwsstdctrls.pp
===================================================================
--- interfaces/gtk/gtkwsstdctrls.pp (wersja 8985)
+++ interfaces/gtk/gtkwsstdctrls.pp (kopia robocza)
@@ -76,6 +76,7 @@
class function GetSelLength(const ACustomComboBox: TCustomComboBox):
integer; override;
class function GetItemIndex(const ACustomComboBox: TCustomComboBox):
integer; override;
class function GetMaxLength(const ACustomComboBox: TCustomComboBox):
integer; override;
+ class function GetText(const AWinControl: TWinControl; var AText:
String): Boolean; override;
class procedure SetArrowKeysTraverseList(const ACustomComboBox:
TCustomComboBox;
NewTraverseList: boolean); override;
@@ -617,10 +618,20 @@
end;
end;
+function TGtkWSCustomComboBox.GetText(const AWinControl: TWinControl; var
AText: String): Boolean;
+begin
+// DebugLn('TGtkWSCustomComboBox.Gettext ',DbgSName(ACustomComboBox),'
',GetWidgetDebugReport(PGtkWidget(ACustomComboBox.Handle)));
+
+ Atext:=GetComboBoxText(PGtkCombo(AWinControl.handle));
+ result:=true;
+end;
+
function TGtkWSCustomComboBox.GetItemIndex(
const ACustomComboBox: TCustomComboBox): integer;
+var
+ CurText : string;
begin
- //DebugLn('TGtkWSCustomComboBox.GetItemIndex ',DbgSName(ACustomComboBox),'
',DebugGtkWidgets.GetInfo(Pointer(ACustomComboBox.Handle),true));
+ //DebugLn('TGtkWSCustomComboBox.GetItemIndex ',DbgSName(ACustomComboBox),'
',GetWidgetDebugReport(PGtkWidget(ACustomComboBox.Handle)));
Result:=GetComboBoxItemIndex(ACustomComboBox);
end;
@@ -711,7 +722,7 @@
const ACustomComboBox: TCustomComboBox): TStrings;
begin
Result := TStrings(gtk_object_get_data(PGtkObject(ACustomComboBox.Handle),
- 'LCLList'));
+ GtkListItemLCLListTag));
end;
procedure TGtkWSCustomComboBox.Sort(const ACustomComboBox: TCustomComboBox;
Index: interfaces/gtk/gtkcallback.inc
===================================================================
--- interfaces/gtk/gtkcallback.inc (wersja 8985)
+++ interfaces/gtk/gtkcallback.inc (kopia robocza)
@@ -580,7 +580,9 @@
CurFocusWidget: PGtkWidget;
{$ENDIF}
begin
+ {$IFDEF EventTrace}
EventTrace('focus', data);
+ {$ENDIF}
if (Widget=nil) or (Event=nil) then ;
//DebugLn('GTKFocusCB ',DbgSName(TObject(Data)),'
',GetWidgetDebugReport(Widget));
{$IFDEF VerboseFocus}
@@ -625,7 +627,9 @@
CurFocusWidget: PGtkWidget;
{$ENDIF}
begin
+ {$IFDEF EventTrace}
EventTrace('focus', data);
+ {$ENDIF}
if (Widget=nil) or (Event=nil) then ;
//DebugLn('GTKFocusCBAfter ',DbgSName(TObject(Data)),'
',GetWidgetDebugReport(Widget));
{$IFDEF VerboseFocus}
@@ -2533,7 +2537,9 @@
begin
Result := CallBackDefaultReturn;
//DebugLn('[gtkFocusInNotifyCB]
',TControl(data).Name,':',TObject(data).ClassName);
+ {$IFDEF EventTrace}
EventTrace ('FocusInNotify (alias Enter)', data);
+ {$ENDIF}
if (Event=nil) then ;
if csDesigning in TControl(Data).ComponentState then begin
@@ -2552,7 +2558,9 @@
begin
Result := CallBackDefaultReturn;
//DebugLn('[gtkFocusOutNotifyCB]
',TControl(data).Name,':',TObject(data).ClassName);
+ {$IFDEF EventTrace}
EventTrace ('FocusOutNotify (alias Exit)', data);
+ {$ENDIF}
if (Event=nil) then ;
if csDesigning in TControl(Data).ComponentState then begin
@@ -3119,7 +3127,7 @@
begin
Result := CallBackDefaultReturn;
{$IFDEF EventTrace}
- EventTrace('gtkListBoxSelectionChangedAfter', data);
+ EventTrace('gtkListSelectionChangedAfter', data);
{$ENDIF}
FillChar(Mess,SizeOf(Mess),0);
Mess.msg := LM_SelChange;
Index: interfaces/gtk/gtkobject.inc
===================================================================
--- interfaces/gtk/gtkobject.inc (wersja 8985)
+++ interfaces/gtk/gtkobject.inc (kopia robocza)
@@ -4771,7 +4771,7 @@
// Items
ItemList:= TGtkListStringList.Create(PGtkList(Widget^.List),ComboBox,False);
- gtk_object_set_data(PGtkObject(Widget), 'LCLList', ItemList);
+ gtk_object_set_data(PGtkObject(Widget), GtkListItemLCLListTag, ItemList);
ItemList.Assign(ComboBox.Items);
ItemList.Sorted:= ComboBox.Sorted;
@@ -4782,8 +4782,6 @@
// MaxLength
gtk_entry_set_max_length(PGtkEntry(Widget^.entry),guint16(ComboBox.MaxLength));
- // Text
- SetComboBoxText(Widget, PChar(ComboBox.Text));
end;
Index: interfaces/gtk/gtkproc.pp
===================================================================
--- interfaces/gtk/gtkproc.pp (wersja 8985)
+++ interfaces/gtk/gtkproc.pp (kopia robocza)
@@ -57,6 +57,12 @@
FileUtil, ImgList, GTKGlobals, gtkDef;
+
+const
+ GtkListItemGtkListTag = 'GtkList';
+ GtkListItemLCLListTag = 'LCLList';
+
+
type
PPWaitHandleEventHandler = ^PWaitHandleEventHandler;
PWaitHandleEventHandler = ^TWaitHandleEventHandler;
Index: interfaces/gtk/gtkwscontrols.pp
===================================================================
--- interfaces/gtk/gtkwscontrols.pp (wersja 8985)
+++ interfaces/gtk/gtkwscontrols.pp (kopia robocza)
@@ -660,7 +660,7 @@
if ModalWindows=nil then ModalWindows:=TFPList.Create;
ModalWindows.Add(GtkWindow);
- gtk_window_set_modal(GtkWindow, true);
+// gtk_window_set_modal(GtkWindow, true);
gtk_widget_show(PGtkWidget(GtkWindow));
{$IFDEF Gtk1}
GDK_WINDOW_ACTIVATE(PGdkWindowPrivate(PGtkWidget(GtkWindow)^.window));
Index: include/customcombobox.inc
===================================================================
--- include/customcombobox.inc (wersja 8985)
+++ include/customcombobox.inc (kopia robocza)
@@ -154,7 +154,7 @@
Call handler for "OnChange"-event if one is assigned.
------------------------------------------------------------------------------}
-procedure TCustomComboBox.LMChange(var Msg);
+procedure TCustomComboBox.LMChanged(var Msg);
begin
Change;
end;
@@ -753,7 +753,7 @@
------------------------------------------------------------------------------}
function TCustomComboBox.GetItemIndex : integer;
begin
- if HandleAllocated then
+ if not (csDestroying in ComponentState){and not (csDestroyingHandle in
ControlState) } and HandleAllocated then
FItemIndex:= TWSCustomComboBoxClass(WidgetSetClass).GetItemIndex(Self);
Result:=FItemIndex;
end;
Index: stdctrls.pp
===================================================================
--- stdctrls.pp (wersja 8985)
+++ stdctrls.pp (kopia robocza)
@@ -276,7 +276,7 @@
procedure DestroyWnd; override;
procedure DrawItem(Index: Integer; ARect: TRect;
State: TOwnerDrawState); virtual;
- procedure LMChange(var Msg); message LM_CHANGED;
+ procedure LMChanged(var Msg); message LM_CHANGED;
procedure Change; dynamic;
procedure Select; dynamic;
procedure DropDown; dynamic;