... |
... |
@@ -16,12 +16,14 @@ |
16
|
16
|
|
17
|
17
|
#ifndef WX_PRECOMP
|
18
|
18
|
#include "wx/menu.h"
|
|
19
|
+ #include "wx/utils.h"
|
19
|
20
|
#endif //WX_PRECOMP
|
20
|
21
|
|
21
|
|
-#include "wx/utils.h"
|
|
22
|
+#include "wx/gtk/private/wrapgtk.h"
|
22
|
23
|
#include "wx/gtk/private.h"
|
23
|
24
|
#include "wx/gtk/private/event.h"
|
24
|
25
|
#include "wx/gtk/private/gtk3-compat.h"
|
|
26
|
+#include "wx/gtk/private/stylecontext.h"
|
25
|
27
|
|
26
|
28
|
|
27
|
29
|
#if GTK_CHECK_VERSION(3,6,0)
|
... |
... |
@@ -198,10 +200,10 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id, |
198
|
200
|
|
199
|
201
|
m_focusWidget = GTK_WIDGET(entry);
|
200
|
202
|
|
201
|
|
- PostCreation(size);
|
202
|
|
-
|
203
|
203
|
gtk_entry_set_text(entry, wxGTK_CONV(value));
|
204
|
204
|
|
|
205
|
+ PostCreation(size);
|
|
206
|
+
|
205
|
207
|
SetHint(_("Search"));
|
206
|
208
|
|
207
|
209
|
GTKConnectChangedSignal();
|
... |
... |
@@ -384,4 +386,39 @@ void wxSearchCtrl::PopupSearchMenu() |
384
|
386
|
|
385
|
387
|
#endif // wxUSE_MENUS
|
386
|
388
|
|
|
389
|
+wxSize wxSearchCtrl::DoGetBestSize() const
|
|
390
|
+{
|
|
391
|
+ return DoGetSizeFromTextSize(GetCharWidth() * 8);
|
|
392
|
+}
|
|
393
|
+
|
|
394
|
+wxSize wxSearchCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const
|
|
395
|
+{
|
|
396
|
+ wxSize size(GTKGetPreferredSize(m_widget));
|
|
397
|
+ size.x += xlen;
|
|
398
|
+ if (size.y < ylen)
|
|
399
|
+ size.y = ylen;
|
|
400
|
+
|
|
401
|
+#ifdef wxHAS_GTK_SEARCH_ENTRY
|
|
402
|
+ if (HasGtkSearchEntry() &&
|
|
403
|
+ gtk_entry_get_icon_storage_type(m_entry, GTK_ENTRY_ICON_SECONDARY) == GTK_IMAGE_EMPTY)
|
|
404
|
+ {
|
|
405
|
+ // If text is empty, there is no "clear" icon, and GtkEntry preferred size
|
|
406
|
+ // does not account for it. So add in size of primary icon as a substitute.
|
|
407
|
+ GdkPixbuf* pixbuf = gtk_entry_get_icon_pixbuf(m_entry, GTK_ENTRY_ICON_PRIMARY);
|
|
408
|
+ if (pixbuf)
|
|
409
|
+ size.x += gdk_pixbuf_get_width(pixbuf);
|
|
410
|
+
|
|
411
|
+ // Also account for secondary icon margin
|
|
412
|
+ wxGtkStyleContext sc(GetContentScaleFactor());
|
|
413
|
+ sc.Add(GTK_TYPE_ENTRY, "entry", "entry", nullptr);
|
|
414
|
+ sc.Add(GTK_TYPE_IMAGE, "image", "right", nullptr);
|
|
415
|
+ GtkBorder margin;
|
|
416
|
+ gtk_style_context_get_margin(sc, GTK_STATE_FLAG_NORMAL, &margin);
|
|
417
|
+ size.x += margin.left + margin.right;
|
|
418
|
+ }
|
|
419
|
+#endif // wxHAS_GTK_SEARCH_ENTRY
|
|
420
|
+
|
|
421
|
+ return size;
|
|
422
|
+}
|
|
423
|
+
|
387
|
424
|
#endif // wxUSE_SEARCHCTRL |