]> git.saurik.com Git - wxWidgets.git/commitdiff
wxWindow::GetBestSize() added
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 19 Nov 1999 21:01:20 +0000 (21:01 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 19 Nov 1999 21:01:20 +0000 (21:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4633 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

61 files changed:
docs/latex/wx/function.tex
docs/latex/wx/window.tex
include/wx/gtk/checkbox.h
include/wx/gtk/choice.h
include/wx/gtk/combobox.h
include/wx/gtk/control.h
include/wx/gtk/listbox.h
include/wx/gtk/statbmp.h
include/wx/gtk/stattext.h
include/wx/gtk/textctrl.h
include/wx/gtk1/checkbox.h
include/wx/gtk1/choice.h
include/wx/gtk1/combobox.h
include/wx/gtk1/control.h
include/wx/gtk1/listbox.h
include/wx/gtk1/statbmp.h
include/wx/gtk1/stattext.h
include/wx/gtk1/textctrl.h
include/wx/msw/button.h
include/wx/msw/checkbox.h
include/wx/msw/control.h
include/wx/msw/listbox.h
include/wx/msw/private.h
include/wx/msw/spinbutt.h
include/wx/msw/spinctrl.h
include/wx/msw/statbmp.h
include/wx/msw/statbox.h
include/wx/msw/stattext.h
include/wx/msw/textctrl.h
include/wx/msw/window.h
include/wx/window.h
src/common/wincmn.cpp
src/gtk/checkbox.cpp
src/gtk/choice.cpp
src/gtk/combobox.cpp
src/gtk/control.cpp
src/gtk/listbox.cpp
src/gtk/statbmp.cpp
src/gtk/stattext.cpp
src/gtk/textctrl.cpp
src/gtk/window.cpp
src/gtk1/checkbox.cpp
src/gtk1/choice.cpp
src/gtk1/combobox.cpp
src/gtk1/control.cpp
src/gtk1/listbox.cpp
src/gtk1/statbmp.cpp
src/gtk1/stattext.cpp
src/gtk1/textctrl.cpp
src/gtk1/window.cpp
src/msw/button.cpp
src/msw/checkbox.cpp
src/msw/control.cpp
src/msw/listbox.cpp
src/msw/spinbutt.cpp
src/msw/spinctrl.cpp
src/msw/statbmp.cpp
src/msw/statbox.cpp
src/msw/stattext.cpp
src/msw/textctrl.cpp
src/msw/window.cpp

index 783bf35bdaa114c3cc0c13b613ba33c6bf496808..d2bcd33f54ea131bd4d3be62dbc38e61083526eb 100644 (file)
@@ -1051,7 +1051,7 @@ See also \helpref{wxDDEServer}{wxddeserver}, \helpref{wxDDEClient}{wxddeclient},
 
 \func{void}{wxDebugMsg}{\param{const wxString\& }{fmt}, \param{...}{}}
 
-{\bf This function is deprecated, use \helpref{wxLogDebug}{wxlogoverview} instead!}
+{\bf This function is deprecated, use \helpref{wxLogDebug}{wxlogdebug} instead!}
 
 Display a debugging message; under Windows, this will appear on the
 debugger command window, and under Unix, it will be written to standard
@@ -2285,7 +2285,9 @@ Another name for \helpref{wxResourceRegisterBitmapData}{registerbitmapdata}.
 \section{Log functions}\label{logfunctions}
 
 These functions provide a variety of logging functions: see \helpref{Log classes overview}{wxlogoverview} for
-further information.
+further information. The functions use (implicitly) the currently active log
+target, so their descriptions here may not apply if the log target is not the
+standard one (installed by wxWindows in the beginning of the program).
 
 \wxheading{Include files}
 
@@ -2295,9 +2297,9 @@ further information.
 
 \func{void}{wxLogError}{\param{const char*}{ formatString}, \param{...}{}}
 
-The function to use for error messages, i.e. the
-messages that must be shown to the user. The default processing is to pop up a
-message box to inform the user about it.
+The function to use for error messages, i.e. the messages that must be shown
+to the user. The default processing is to pop up a message box to inform the
+user about it.
 
 \membersection{::wxLogFatalError}\label{wxlogfatalerror}
 
@@ -2311,18 +2313,18 @@ function also terminates the program with this exit code.
 
 \func{void}{wxLogWarning}{\param{const char*}{ formatString}, \param{...}{}}
 
-For warnings - they are also normally shown to the
-user, but don't interrupt the program work.
+For warnings - they are also normally shown to the user, but don't interrupt
+the program work.
 
 \membersection{::wxLogMessage}\label{wxlogmessage}
 
 \func{void}{wxLogMessage}{\param{const char*}{ formatString}, \param{...}{}}
 
-for all normal, informational messages. They also
-appear in a message box by default (but it can be changed). Notice
-that the standard behaviour is to not show informational messages if there are
-any errors later - the logic being that the later error messages make the
-informational messages preceding them meaningless.
+for all normal, informational messages. They also appear in a message box by
+default (but it can be changed). Notice that the standard behaviour is to not
+show informational messages if there are any errors later - the logic being
+that the later error messages make the informational messages preceding them
+meaningless.
 
 \membersection{::wxLogVerbose}\label{wxlogverbose}
 
@@ -2334,48 +2336,79 @@ progress (another, but possibly confusing name for the same function is {\bf wxL
 
 \membersection{::wxLogStatus}\label{wxlogstatus}
 
+\func{void}{wxLogStatus}{\param{wxFrame *}{frame}, \param{const char*}{ formatString}, \param{...}{}}
+
 \func{void}{wxLogStatus}{\param{const char*}{ formatString}, \param{...}{}}
 
-For status messages - they will go into the status
-bar of the active or specified (as the first argument) \helpref{wxFrame}{wxframe} if it has one.
+Messages logged by this function will appear in the statusbar of the {\it
+frame} or of the top level application window by default (i.e. when using
+the second version of the function).
+
+If the target frame doesn't have a statusbar, the message will be lost.
 
 \membersection{::wxLogSysError}\label{wxlogsyserror}
 
 \func{void}{wxLogSysError}{\param{const char*}{ formatString}, \param{...}{}}
 
-Mostly used by wxWindows itself, but might be
-handy for logging errors after system call (API function) failure. It logs the
-specified message text as well as the last system error code ({\it errno} or {\it ::GetLastError()} depending
-on the platform) and the corresponding error
-message. The second form of this function takes the error code explitly as the
-first argument.
+Mostly used by wxWindows itself, but might be handy for logging errors after
+system call (API function) failure. It logs the specified message text as well
+as the last system error code ({\it errno} or {\it ::GetLastError()} depending
+on the platform) and the corresponding error message. The second form
+of this function takes the error code explitly as the first argument.
 
 \membersection{::wxLogDebug}\label{wxlogdebug}
 
 \func{void}{wxLogDebug}{\param{const char*}{ formatString}, \param{...}{}}
 
-The right function for debug output. It only
-does anything at all in the debug mode (when the preprocessor symbol \_\_WXDEBUG\_\_ is defined)
-and expands to nothing in release mode (otherwise).
+The right function for debug output. It only does anything at all in the debug
+mode (when the preprocessor symbol \_\_WXDEBUG\_\_ is defined) and expands to
+nothing in release mode (otherwise).
 
 \membersection{::wxLogTrace}\label{wxlogtrace}
 
 \func{void}{wxLogTrace}{\param{const char*}{ formatString}, \param{...}{}}
 
-\func{void}{wxLogTrace}{\param{wxTraceMask}{ mask}, \param{const char*}{ formatString}, \param{...}{}}
+\func{void}{wxLogTrace}{\param{const char *}{mask}, \param{const char *}{formatString}, \param{...}{}}
+
+\func{void}{wxLogTrace}{\param{wxTraceMask}{ mask}, \param{const char *}{formatString}, \param{...}{}}
+
+As {\bf wxLogDebug}, trace functions only do something in debug build and
+expand to nothing in the release one. The reason for making
+it a separate function from it is that usually there are a lot of trace
+messages, so it might make sense to separate them from other debug messages.
+
+The trace messages also usually can be separated into different categories and
+the second and third versions of this function only log the message if the 
+{\it mask} which it has is currently enabled in \helpref{wxLog}{wxlog}. This
+allows to selectively trace only some operations and not others by changing
+the value of the trace mask (possible during the run-time).
+
+For the second function (taking a string mask), the message is logged only if
+the mask has been previously enabled by the call to 
+\helpref{AddTraceMask}{wxlogaddtracemask}. The predefined string trace masks
+used by wxWindows are:
+
+\begin{itemize}\itemsep=0pt
+\item wxTRACE\_MemAlloc: trace memory allocation (new/delete)
+\item wxTRACE\_Messages: trace window messages/X callbacks
+\item wxTRACE\_ResAlloc: trace GDI resource allocation
+\item wxTRACE\_RefCount: trace various ref counting operations
+\item wxTRACE\_OleCalls: trace OLE method calls (Win32 only)
+\end{itemize}
 
-As {\bf wxLogDebug}, only does something in debug
-build. The reason for making it a separate function from it is that usually
-there are a lot of trace messages, so it might make sense to separate them
-from other debug messages which would be flooded in them. Moreover, the second
-version of this function takes a trace mask as the first argument which allows
-to further restrict the amount of messages generated. The value of {\it mask} can be:
+The third version of the function only logs the message if all the bit
+corresponding to the {\it mask} are set in the wxLog trace mask which can be
+set by \helpref{SetTraceMask}{wxlogsettracemask}. This version is less
+flexible than the previous one because it doesn't allow defining the user
+trace masks easily - this is why it is deprecated in favour of using string
+trace masks.
 
 \begin{itemize}\itemsep=0pt
 \item wxTraceMemAlloc: trace memory allocation (new/delete)
 \item wxTraceMessages: trace window messages/X callbacks
 \item wxTraceResAlloc: trace GDI resource allocation
 \item wxTraceRefCount: trace various ref counting operations
+\item wxTraceOleCalls: trace OLE method calls (Win32 only)
 \end{itemize}
 
 \section{Debugging macros and functions}\label{debugmacros}
index 9e3be209fa3f0c7a3079ccc4b9633be64962e912..9a24dac8ab2ffc6a6e9d2f984e96e210d5bf86f4 100644 (file)
@@ -430,7 +430,8 @@ implements the following methods:\par
 
 \func{virtual void}{Fit}{\void}
 
-Sizes the window so that it fits around its subwindows.
+Sizes the window so that it fits around its subwindows. This function won't do
+anything if there are no subwindows.
 
 \membersection{wxWindow::GetBackgroundColour}\label{wxwindowgetbackgroundcolour}
 
@@ -445,6 +446,17 @@ Returns the background colour of the window.
 \helpref{wxWindow::GetForegroundColour}{wxwindowgetforegroundcolour},\rtfsp
 \helpref{wxWindow::OnEraseBackground}{wxwindowonerasebackground}
 
+\membersection{wxWindow::GetBestSize}{wxwindowgetbestsize}
+
+\constfunc{virtual wxSize}{GetBestSize}{\void}
+
+This functions returns the best acceptable minimal size for the window. For
+example, for a static control, it will be the minimal size such that the
+control label is not truncated. For windows containing subwindows (typically 
+\helpref{wxPanel}wxpanel}), the size returned by this function will be the
+same as the size the window would have had after calling 
+\helpref{Fit}{wxwindowfit}.
+
 \membersection{wxWindow::GetCharHeight}
 
 \constfunc{virtual int}{GetCharHeight}{\void}
index 412b3663b2e0626137086c96f95ad885b9d608b4..40afabfd83b1c7e5bb6cefb9365e3e1d410d466f 100644 (file)
@@ -73,6 +73,9 @@ public:
     GtkWidget *m_widgetCheckbox;
     GtkWidget *m_widgetLabel;
     
+protected:
+    virtual wxSize DoGetBestSize() const;
+
 private:
     DECLARE_DYNAMIC_CLASS(wxCheckBox)
 };
index a58c6bb5830345a6cec554072243727a7e2bfc1f..448c81b98831cc74bb64b61d760c81ba5aa294e3 100644 (file)
@@ -71,6 +71,8 @@ protected:
     virtual void DoSetItemClientObject( int n, wxClientData* clientData );
     virtual wxClientData* DoGetItemClientObject( int n ) const;
 
+    virtual wxSize DoGetBestSize() const;
+
 private:
     // common part of Create() and DoAppend()
     size_t AppendHelper(GtkWidget *menu, const wxString& item);
index 129321d3a4901c0443ea3dbd5dbf621058aa39b3..f48a786405c4e3b4c3c28507386270c04f05ae47 100644 (file)
@@ -121,6 +121,9 @@ public:
     bool IsOwnGtkWindow( GdkWindow *window );
     void ApplyWidgetStyle();
  
+protected:
+    virtual wxSize DoGetBestSize() const;
+
 private: 
     DECLARE_DYNAMIC_CLASS(wxComboBox)
     DECLARE_EVENT_TABLE()
index 5ae7c44043a9344245116db3befa4c6bba48dee0..e7869e4f0e7de21cf8a730f7ff83690edd49c521 100644 (file)
@@ -46,6 +46,8 @@ public:
     virtual wxString GetLabel() const;
 
 protected:
+    virtual wxSize DoGetBestSize() const;
+
     wxString   m_label;
     char       m_chAccel;  // enabled to avoid breaking binary compatibility later on
     
index 8038c9c0abc6a154539704c6041547f92448808e..20eb87cac5f91b668146eebe4695d17273dbfb66 100644 (file)
@@ -96,6 +96,9 @@ public:
     bool       m_hasCheckBoxes;
 #endif // wxUSE_CHECKLISTBOX
 
+protected:
+    virtual wxSize DoGetBestSize() const;
+
 private:
     // this array is only used for controls with wxCB_SORT style, so only
     // allocate it if it's needed (hence using pointer)
index 0d9bcddfb33f290b0590bc96bd780fc43eb1ecff..f56a5d4d569fd60864b5dfa1a486a246298e34fa 100644 (file)
@@ -80,6 +80,9 @@ public:
         SetBitmap( icon );
     }
 
+protected:
+    virtual wxSize DoGetBestSize() const;
+
 private:
     // creates the new pixmap widget
     void CreatePixmapWidget();
index 0e58cb15ec908b75ca719c190f290a885f50e6ec..809568191e500544135a654d35497a202eab0b2a 100644 (file)
@@ -36,25 +36,35 @@ extern const wxChar *wxStaticTextNameStr;
 // wxStaticText
 //-----------------------------------------------------------------------------
 
-class wxStaticText: public wxControl
+class wxStaticText : public wxControl
 {
-  DECLARE_DYNAMIC_CLASS(wxStaticText)
-
-  public:
-
-    wxStaticText(void);
-    wxStaticText( wxWindow *parent, wxWindowID id, const wxString &label,
-      const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, 
-      long style = 0, const wxString &name = wxStaticTextNameStr );
-    bool Create(  wxWindow *parent, wxWindowID id, const wxString &label,
-      const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, 
-      long style = 0, const wxString &name = wxStaticTextNameStr );
-    wxString GetLabel(void) const;
+public:
+
+    wxStaticText();
+    wxStaticText(wxWindow *parent,
+                 wxWindowID id,
+                 const wxString &label,
+                 const wxPoint &pos = wxDefaultPosition,
+                 const wxSize &size = wxDefaultSize, 
+                 long style = 0,
+                 const wxString &name = wxStaticTextNameStr );
+
+    bool Create(wxWindow *parent,
+                wxWindowID id,
+                const wxString &label,
+                const wxPoint &pos = wxDefaultPosition,
+                const wxSize &size = wxDefaultSize, 
+                long style = 0,
+                const wxString &name = wxStaticTextNameStr );
+
+    wxString GetLabel() const;
     void SetLabel( const wxString &label );
-    
-  // implementation
-    
+
+    // implementation
     void ApplyWidgetStyle();
+
+protected:
+    DECLARE_DYNAMIC_CLASS(wxStaticText)
 };
 
 #endif // __GTKSTATICTEXTH__
index c437884c3cfc12d4ac456bbee1e194539e8bb881..7c18d927dc6d615a7a4dd8f605657ce88a80657c 100644 (file)
@@ -131,6 +131,9 @@ public:
 
     void SetModified() { m_modified = TRUE; }
 
+protected:
+    virtual wxSize DoGetBestSize() const;
+
 private:
     bool        m_modified;
     GtkWidget  *m_text;
index 412b3663b2e0626137086c96f95ad885b9d608b4..40afabfd83b1c7e5bb6cefb9365e3e1d410d466f 100644 (file)
@@ -73,6 +73,9 @@ public:
     GtkWidget *m_widgetCheckbox;
     GtkWidget *m_widgetLabel;
     
+protected:
+    virtual wxSize DoGetBestSize() const;
+
 private:
     DECLARE_DYNAMIC_CLASS(wxCheckBox)
 };
index a58c6bb5830345a6cec554072243727a7e2bfc1f..448c81b98831cc74bb64b61d760c81ba5aa294e3 100644 (file)
@@ -71,6 +71,8 @@ protected:
     virtual void DoSetItemClientObject( int n, wxClientData* clientData );
     virtual wxClientData* DoGetItemClientObject( int n ) const;
 
+    virtual wxSize DoGetBestSize() const;
+
 private:
     // common part of Create() and DoAppend()
     size_t AppendHelper(GtkWidget *menu, const wxString& item);
index 129321d3a4901c0443ea3dbd5dbf621058aa39b3..f48a786405c4e3b4c3c28507386270c04f05ae47 100644 (file)
@@ -121,6 +121,9 @@ public:
     bool IsOwnGtkWindow( GdkWindow *window );
     void ApplyWidgetStyle();
  
+protected:
+    virtual wxSize DoGetBestSize() const;
+
 private: 
     DECLARE_DYNAMIC_CLASS(wxComboBox)
     DECLARE_EVENT_TABLE()
index 5ae7c44043a9344245116db3befa4c6bba48dee0..e7869e4f0e7de21cf8a730f7ff83690edd49c521 100644 (file)
@@ -46,6 +46,8 @@ public:
     virtual wxString GetLabel() const;
 
 protected:
+    virtual wxSize DoGetBestSize() const;
+
     wxString   m_label;
     char       m_chAccel;  // enabled to avoid breaking binary compatibility later on
     
index 8038c9c0abc6a154539704c6041547f92448808e..20eb87cac5f91b668146eebe4695d17273dbfb66 100644 (file)
@@ -96,6 +96,9 @@ public:
     bool       m_hasCheckBoxes;
 #endif // wxUSE_CHECKLISTBOX
 
+protected:
+    virtual wxSize DoGetBestSize() const;
+
 private:
     // this array is only used for controls with wxCB_SORT style, so only
     // allocate it if it's needed (hence using pointer)
index 0d9bcddfb33f290b0590bc96bd780fc43eb1ecff..f56a5d4d569fd60864b5dfa1a486a246298e34fa 100644 (file)
@@ -80,6 +80,9 @@ public:
         SetBitmap( icon );
     }
 
+protected:
+    virtual wxSize DoGetBestSize() const;
+
 private:
     // creates the new pixmap widget
     void CreatePixmapWidget();
index 0e58cb15ec908b75ca719c190f290a885f50e6ec..809568191e500544135a654d35497a202eab0b2a 100644 (file)
@@ -36,25 +36,35 @@ extern const wxChar *wxStaticTextNameStr;
 // wxStaticText
 //-----------------------------------------------------------------------------
 
-class wxStaticText: public wxControl
+class wxStaticText : public wxControl
 {
-  DECLARE_DYNAMIC_CLASS(wxStaticText)
-
-  public:
-
-    wxStaticText(void);
-    wxStaticText( wxWindow *parent, wxWindowID id, const wxString &label,
-      const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, 
-      long style = 0, const wxString &name = wxStaticTextNameStr );
-    bool Create(  wxWindow *parent, wxWindowID id, const wxString &label,
-      const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, 
-      long style = 0, const wxString &name = wxStaticTextNameStr );
-    wxString GetLabel(void) const;
+public:
+
+    wxStaticText();
+    wxStaticText(wxWindow *parent,
+                 wxWindowID id,
+                 const wxString &label,
+                 const wxPoint &pos = wxDefaultPosition,
+                 const wxSize &size = wxDefaultSize, 
+                 long style = 0,
+                 const wxString &name = wxStaticTextNameStr );
+
+    bool Create(wxWindow *parent,
+                wxWindowID id,
+                const wxString &label,
+                const wxPoint &pos = wxDefaultPosition,
+                const wxSize &size = wxDefaultSize, 
+                long style = 0,
+                const wxString &name = wxStaticTextNameStr );
+
+    wxString GetLabel() const;
     void SetLabel( const wxString &label );
-    
-  // implementation
-    
+
+    // implementation
     void ApplyWidgetStyle();
+
+protected:
+    DECLARE_DYNAMIC_CLASS(wxStaticText)
 };
 
 #endif // __GTKSTATICTEXTH__
index c437884c3cfc12d4ac456bbee1e194539e8bb881..7c18d927dc6d615a7a4dd8f605657ce88a80657c 100644 (file)
@@ -131,6 +131,9 @@ public:
 
     void SetModified() { m_modified = TRUE; }
 
+protected:
+    virtual wxSize DoGetBestSize() const;
+
 private:
     bool        m_modified;
     GtkWidget  *m_text;
index 794d9f933733034dd9703c0d11995a81d5b23460..fa828361edce6246fc59f72561461b9ebbaeb990 100644 (file)
@@ -66,7 +66,7 @@ protected:
     // send a notification event, return TRUE if processed
     bool SendClickEvent();
 
-    virtual wxSize DoGetBestSize();
+    virtual wxSize DoGetBestSize() const;
 };
 
 #endif
index 7bcd8ef308b9338dbd5dc75cfa970342297a9934..eb7f87b0a273c37e38f4e953c98a79a0ab2b9ba2 100644 (file)
@@ -53,7 +53,7 @@ public:
             WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
 
 protected:
-    virtual wxSize DoGetBestSize();
+    virtual wxSize DoGetBestSize() const;
 };
 
 class WXDLLEXPORT wxBitmapCheckBox: public wxCheckBox
index 9f3b15938bee6b031f6a1ece035579d4611b29ff..430aa7cfdb657bd080c3f1bac2f3707d062eff4d 100644 (file)
@@ -69,7 +69,7 @@ protected:
    // For controls like radiobuttons which are really composite
    wxList m_subControls;
 
-   virtual wxSize DoGetBestSize();
+   virtual wxSize DoGetBestSize() const;
 
    // create the control of the given class with the given style, returns FALSE
    // if creation failed
index edebfe9907819db68b99b3227771a97b7d58bb1f..1dbd35f32bd047e4c464cf0d8aba4e267746c08e 100644 (file)
@@ -126,7 +126,7 @@ protected:
     int m_noItems;
     int m_selected;
 
-    virtual wxSize DoGetBestSize();
+    virtual wxSize DoGetBestSize() const;
 
 #if wxUSE_OWNER_DRAWN
     // control items
index 4c7c5628d983f8b6af720abe63ec5e25511c7357..1017104e5a505c9100194fcf6d98e74b03ce2cb2 100644 (file)
@@ -269,7 +269,7 @@ WXDLLEXPORT void wxSetInstance(HINSTANCE hInst);
 
 WXDLLEXPORT wxWindow* wxFindWinFromHandle(WXHWND hWnd);
 
-WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font);
+WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y, const wxFont *the_font);
 WXDLLEXPORT void wxFillLogFont(LOGFONT *logFont, const wxFont *font);
 WXDLLEXPORT wxFont wxCreateFontFromLogFont(const LOGFONT *logFont);
 
index f4e119db99700fa2724d0021f49b0d850f5fde64..2828753d570a92c53f410c7c96ec2b8b066d0e32 100644 (file)
@@ -59,7 +59,7 @@ public:
                              WXWORD pos, WXHWND control);
 
 protected:
-   virtual wxSize DoGetBestSize();
+   virtual wxSize DoGetBestSize() const;
 
 private:
     DECLARE_DYNAMIC_CLASS(wxSpinButton)
index 7babcf4e74765276f73b1cc349ee084594dd0856..dbf42d7e7a39f9b1d519ede34f1a4217b8641cb5 100644 (file)
@@ -61,7 +61,7 @@ public:
 
 protected:
     virtual void DoMoveWindow(int x, int y, int width, int height);
-    virtual wxSize DoGetBestSize();
+    virtual wxSize DoGetBestSize() const;
 
     WXHWND m_hwndBuddy;
 
index e412b276ad7a64c9a520523e70186a5f449cf40d..115abfb2066e57ed7800d51d1d3f28ba20bc6834 100644 (file)
@@ -84,7 +84,7 @@ protected:
         wxBitmap *bitmap;
     } m_image;
 
-    virtual wxSize DoGetBestSize();
+    virtual wxSize DoGetBestSize() const;
 };
 
 #endif
index e1d5f2e85aafdb24e7a02e60070e450525f3865c..734392f53b0e3c722babe70ccc4ba8bf483445be 100644 (file)
@@ -57,7 +57,7 @@ public:
     virtual bool AcceptsFocus() const { return FALSE; }
 
 protected:
-    virtual wxSize DoGetBestSize();
+    virtual wxSize DoGetBestSize() const;
 };
 
 #endif
index f21a4bd3b0873ac5300cb331e7013625ab2126ee..f2ab5e5f7408cf9de9df074ffe4fb17a8dfe6383 100644 (file)
@@ -56,7 +56,7 @@ public:
     virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
 
 protected:
-    virtual wxSize DoGetBestSize();
+    virtual wxSize DoGetBestSize() const;
 };
 
 #endif
index 00675d4c95e08ac141d67300ed7a654bb0888f5f..4290b207c95ae299a97f8899f5ac0740f3cedced 100644 (file)
@@ -162,7 +162,7 @@ protected:
     // limit is big enough)
     void AdjustSpaceLimit();
 
-    virtual wxSize DoGetBestSize();
+    virtual wxSize DoGetBestSize() const;
 
 private:
     DECLARE_EVENT_TABLE()
index 1ae0efd35c37552e0cb0f62d4daf3dad859f0de2..e0181bd29b22d4e85e5e7e7d8643845633d7327f 100644 (file)
@@ -401,10 +401,6 @@ protected:
                            int sizeFlags = wxSIZE_AUTO);
     virtual void DoSetClientSize(int width, int height);
 
-    // get the size which best suits the window: e.g., for a static text it
-    // will be the width and height of the text
-    virtual wxSize DoGetBestSize();
-
     // move the window to the specified location and resize it: this is called
     // from both DoSetSize() and DoSetClientSize() and would usually just call
     // ::MoveWindow() except for composite controls which will want to arrange
index 7d11de1b10ab5e3c28c17a3f610e32ce64be7691..afc521e18f019ba0f85976c9214096df71a2b77f 100644 (file)
@@ -267,6 +267,18 @@ public:
         return wxSize(w, h);
     }
 
+        // get the size best suited for the window (in fact, minimal
+        // acceptable size using which it will still look "nice")
+    wxSize GetBestSize() const { return DoGetBestSize(); }
+    void GetBestSize(int *w, int *h) const
+    {
+        wxSize s = DoGetBestSize();
+        if ( w )
+            *w = s.x;
+        if ( h )
+            *h = s.y;
+    }
+
         // centre with respect to the the parent window
     void Centre( int direction = wxBOTH );
     void Center( int direction = wxBOTH ) { Centre(direction); }
@@ -752,6 +764,26 @@ protected:
     static int WidthDefault(int w) { return w == -1 ? 20 : w; }
     static int HeightDefault(int h) { return h == -1 ? 20 : h; }
 
+    // sets the size to be size but take width and/or height from
+    // DoGetBestSize() if width/height of size is -1
+    //
+    // NB: when calling this function from the ctor, the DoGetBestSize() of
+    //     the class with the same name as the ctor, not the real (most
+    //     derived) one - but this is what we usually want
+    void SetSizeOrDefault(const wxSize& size = wxDefaultSize)
+    {
+        if ( size.x == -1 || size.y == -1 )
+        {
+            wxSize sizeDef = GetBestSize();
+            SetSize( size.x == -1 ? sizeDef.x : size.x,
+                     size.y == -1 ? sizeDef.y : size.y);
+        }
+        else
+        {
+            SetSize(size);
+        }
+    }
+
     // more pure virtual functions
     // ---------------------------
 
@@ -773,6 +805,11 @@ protected:
     virtual void DoGetSize( int *width, int *height ) const = 0;
     virtual void DoGetClientSize( int *width, int *height ) const = 0;
 
+    // get the size which best suits the window: for a control, it would be
+    // the minimal size which doesn't truncate the control, for a panel - the
+    // same size as it would have after a call to Fit()
+    virtual wxSize DoGetBestSize() const;
+
     // this is the virtual function to be overriden in any derived class which
     // wants to change how SetSize() or Move() works - it is called by all
     // versions of these functions in the base class
@@ -845,6 +882,8 @@ inline wxWindow *wxWindowBase::GetGrandParent() const
 // ----------------------------------------------------------------------------
 
 WXDLLEXPORT extern wxWindow* wxGetActiveWindow();
+
+// deprecated (doesn't start with 'wx' prefix), use wxWindow::NewControlId()
 inline WXDLLEXPORT int NewControlId() { return wxWindowBase::NewControlId(); }
 
 #endif
index 18e1821bfc1ae89d2c64a2f2a48d245c432d5cda..782d3bf7d17e2f035834e947e04c37ea4ae0d6d1 100644 (file)
@@ -302,7 +302,7 @@ bool wxWindowBase::DestroyChildren()
 }
 
 // ----------------------------------------------------------------------------
-// centre/fit the window
+// size/position related methods
 // ----------------------------------------------------------------------------
 
 // centre the window with respect to its parent in either (or both) directions
@@ -361,36 +361,55 @@ void wxWindowBase::Centre(int direction)
 // fits the window around the children
 void wxWindowBase::Fit()
 {
-    int maxX = 0,
-        maxY = 0;
+    if ( GetChildren().GetCount() > 0 )
+    {
+        SetClientSize(DoGetBestSize());
+    }
+    //else: do nothing if we have no children
+}
 
-    for ( wxWindowList::Node *node = GetChildren().GetFirst();
-          node;
-          node = node->GetNext() )
+// return the size best suited for the current window
+wxSize wxWindowBase::DoGetBestSize() const
+{
+    if ( GetChildren().GetCount() > 0 )
     {
-        wxWindow *win = node->GetData();
-        if ( win->IsTopLevel() )
+        // our minimal acceptable size is such that all our windows fit inside
+        int maxX = 0,
+            maxY = 0;
+
+        for ( wxWindowList::Node *node = GetChildren().GetFirst();
+              node;
+              node = node->GetNext() )
         {
-            // dialogs and frames lie in different top level windows - don't
-            // deal with them here
-            continue;
+            wxWindow *win = node->GetData();
+            if ( win->IsTopLevel() )
+            {
+                // dialogs and frames lie in different top level windows -
+                // don't deal with them here
+                continue;
+            }
+
+            int wx, wy, ww, wh;
+            win->GetPosition(&wx, &wy);
+            win->GetSize(&ww, &wh);
+            if ( wx + ww > maxX )
+                maxX = wx + ww;
+            if ( wy + wh > maxY )
+                maxY = wy + wh;
         }
 
-        int wx, wy, ww, wh;
-        win->GetPosition(&wx, &wy);
-        win->GetSize(&ww, &wh);
-        if ( wx + ww > maxX )
-            maxX = wx + ww;
-        if ( wy + wh > maxY )
-            maxY = wy + wh;
+        // leave a margin
+        return wxSize(maxX + 7, maxY + 14);
+    }
+    else
+    {
+        // for a generic window there is no natural best size - just use the
+        // current one
+        return GetSize();
     }
-
-    // leave a margin
-    SetClientSize(maxX + 7, maxY + 14);
 }
 
 // set the min/max size of the window
-
 void wxWindowBase::SetSizeHints(int minW, int minH,
                                 int maxW, int maxH,
                                 int WXUNUSED(incW), int WXUNUSED(incH))
index 2729438afb6606c88ba1b404194bf098738c5e72..c6cf5f5d7f6bd9c91f2745a6dd43052dd5beecc4 100644 (file)
@@ -106,16 +106,7 @@ bool wxCheckBox::Create(wxWindow *parent,
         m_widget = m_widgetCheckbox;
     }
 
-    wxSize newSize(size);
-    if (newSize.x == -1)
-    {
-        newSize.x = 25 + gdk_string_measure( m_widgetCheckbox->style->font,
-                                             m_label.mbc_str() );
-    }
-    if (newSize.y == -1)
-        newSize.y = 26;
-
-    SetSize( newSize.x, newSize.y );
+    SetSizeOrDefault( size );
 
     gtk_signal_connect( GTK_OBJECT(m_widgetCheckbox),
                         "clicked",
@@ -210,4 +201,10 @@ void wxCheckBox::OnInternalIdle()
     UpdateWindowUI();
 }
 
+wxSize wxCheckBox::DoGetBestSize() const
+{
+    return wxSize( 25 + gdk_string_measure( m_widgetCheckbox->style->font,
+                                            m_label.mbc_str() ), 26 );
+}
+
 #endif
index b772e750a81ade70652d3fdf650423f1fc4325e8..7e2499fe4569627efdab19832e0326803e398224 100644 (file)
@@ -90,12 +90,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
 
     m_widget = gtk_option_menu_new();
 
-    wxSize newSize(size);
-    if (newSize.x == -1)
-        newSize.x = 80;
-    if (newSize.y == -1)
-        newSize.y = 26;
-    SetSize( newSize.x, newSize.y );
+    SetSizeOrDefault( size );
 
     if ( style & wxCB_SORT )
     {
@@ -429,4 +424,9 @@ size_t wxChoice::AppendHelper(GtkWidget *menu, const wxString& item)
     return index;
 }
 
+wxSize wxChoice::DoGetBestSize() const
+{
+    return wxSize(80, 26);
+}
+
 #endif
index 3210098c67b1a69c5cbfcf32e68979a5607f5f5f..d8a36d5ef3f224ad1f8fe2d17a75f9a39b840985 100644 (file)
@@ -113,12 +113,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
     // make it more useable
     gtk_combo_set_use_arrows_always(GTK_COMBO(m_widget), TRUE);
 
-    wxSize newSize = size;
-    if (newSize.x == -1)
-        newSize.x = 100;
-    if (newSize.y == -1)
-        newSize.y = 26;
-    SetSize( newSize.x, newSize.y );
+    SetSizeOrDefault( size );
 
     GtkWidget *list = GTK_COMBO(m_widget)->list;
 
@@ -660,4 +655,9 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window )
              (window == GTK_COMBO(m_widget)->button->window ) );
 }
 
+wxSize wxComboBox::DoGetBestSize() const
+{
+    return wxSize(100, 26);
+}
+
 #endif
index bbd5ac2fd8e5bd86b269943f5faea7df1eb7deb4..a0b88f5944d1e0b7ba7c1a4139d5d38c0c8dc40a 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "wx/control.h"
 
-#include "gtk/gtkfeatures.h"
+#include "gtk/gtk.h"
 
 //-----------------------------------------------------------------------------
 // wxControl
@@ -58,3 +58,12 @@ wxString wxControl::GetLabel() const
 }
 
 
+wxSize wxControl::DoGetBestSize() const
+{
+    GtkRequisition req;
+    (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request )
+        (m_widget, &req );
+
+    return wxSize(req.width, req.height);
+}
+
index 1452563f5032fce32ef51300a33e3ca5c66d8a44..da71a4a355233299b7f74a7f08aea9bc75b1b810 100644 (file)
@@ -327,12 +327,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
 
     gtk_widget_show( GTK_WIDGET(m_list) );
 
-    wxSize newSize = size;
-    if (newSize.x == -1)
-        newSize.x = 100;
-    if (newSize.y == -1)
-        newSize.y = 110;
-    SetSize( newSize.x, newSize.y );
+    SetSizeOrDefault( size );
 
     if ( style & wxLB_SORT )
     {
@@ -939,4 +934,9 @@ void wxListBox::OnInternalIdle()
     UpdateWindowUI();
 }
 
+wxSize wxListBox::DoGetBestSize() const
+{
+    return wxSize(100, 110);
+}
+
 #endif
index 74f494f6e9c13314376c0d5f588b80b46f611071..e86af74122a1580f3c71253da6927f55e997bfee 100644 (file)
@@ -69,16 +69,12 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
 
     if (m_bitmap.Ok())
     {
-       wxSize newSize = size;
-
         GdkBitmap *mask = (GdkBitmap *) NULL;
         if ( m_bitmap.GetMask() )
             mask = m_bitmap.GetMask()->GetBitmap();
         m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
 
-        if (newSize.x == -1) newSize.x = m_bitmap.GetWidth();
-        if (newSize.y == -1) newSize.y = m_bitmap.GetHeight();
-        SetSize( newSize.x, newSize.y );
+        SetSizeOrDefault( size );
     }
     else
     {
@@ -116,8 +112,16 @@ void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
             gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask );
         }
 
-        SetSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() );
+        SetSizeOrDefault();
     }
 }
 
+wxSize wxStaticBitmap::DoGetBestSize() const
+{
+    if ( m_bitmap.Ok() )
+        return wxSize(m_bitmap.GetWidth(), m_bitmap.GetHeight());
+    else
+        return wxSize(16, 16);  // completely arbitrary
+}
+
 #endif
index 6816895a376b901859df451e4613891be1a4c53d..b89853149c3583c4e164b02f20df2d0dbac99065 100644 (file)
@@ -79,13 +79,7 @@ bool wxStaticText::Create(wxWindow *parent,
     static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
     gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0);
 
-    GtkRequisition req;
-    (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );
-    
-    wxSize newSize = size;
-    if (newSize.x == -1) newSize.x = req.width;
-    if (newSize.y == -1) newSize.y = req.height;
-    SetSize( newSize.x, newSize.y );
+    SetSizeOrDefault( size );
 
     m_parent->DoAddChild( this );
 
@@ -115,11 +109,7 @@ void wxStaticText::SetLabel( const wxString &label )
     // adjust the label size to the new label unless disabled
     if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
     {
-        GtkRequisition req;
-        (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request )
-            (m_widget, &req );
-
-        SetSize( req.width, req.height );
+        SetSize( GetBestSize() );
     }
 }
 
@@ -128,4 +118,3 @@ void wxStaticText::ApplyWidgetStyle()
     SetWidgetStyle();
     gtk_widget_set_style( m_widget, m_widgetStyle );
 }
-
index fd5d34bc5876ed0708d4778c0556e2c221561cac..3fc3e5386ce14438534d97153cbcf765512dbc2f 100644 (file)
@@ -182,10 +182,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
           m_text = gtk_entry_new();
     }
 
-    wxSize newSize = size;
-    if (newSize.x == -1) newSize.x = 80;
-    if (newSize.y == -1) newSize.y = 26;
-    SetSize( newSize.x, newSize.y );
+    SetSizeOrDefault( size );
 
     m_parent->DoAddChild( this );
 
@@ -966,3 +963,9 @@ void wxTextCtrl::OnInternalIdle()
 
     UpdateWindowUI();
 }
+
+wxSize wxTextCtrl::DoGetBestSize() const
+{
+    // FIXME should be different for multi-line controls...
+    return wxSize(80, 26);
+}
index 57b5dfc22d86b94fed9570177f55f589a932b6f8..fb0fb302c43b7372f3f40eaa7cb1d23b100c16bc 100644 (file)
@@ -185,7 +185,8 @@ extern bool       g_blockEventsOnDrag;
 extern bool       g_blockEventsOnScroll;
 extern wxCursor   g_globalCursor;
 static wxWindow  *g_captureWindow = (wxWindow*) NULL;
-extern wxWindow  *g_focusWindow = (wxWindow*) NULL;
+
+/* extern */ wxWindow  *g_focusWindow = (wxWindow*) NULL;
 
 // if we detect that the app has got/lost the focus, we set this variable to
 // either TRUE or FALSE and an activate event will be sent during the next
index 2729438afb6606c88ba1b404194bf098738c5e72..c6cf5f5d7f6bd9c91f2745a6dd43052dd5beecc4 100644 (file)
@@ -106,16 +106,7 @@ bool wxCheckBox::Create(wxWindow *parent,
         m_widget = m_widgetCheckbox;
     }
 
-    wxSize newSize(size);
-    if (newSize.x == -1)
-    {
-        newSize.x = 25 + gdk_string_measure( m_widgetCheckbox->style->font,
-                                             m_label.mbc_str() );
-    }
-    if (newSize.y == -1)
-        newSize.y = 26;
-
-    SetSize( newSize.x, newSize.y );
+    SetSizeOrDefault( size );
 
     gtk_signal_connect( GTK_OBJECT(m_widgetCheckbox),
                         "clicked",
@@ -210,4 +201,10 @@ void wxCheckBox::OnInternalIdle()
     UpdateWindowUI();
 }
 
+wxSize wxCheckBox::DoGetBestSize() const
+{
+    return wxSize( 25 + gdk_string_measure( m_widgetCheckbox->style->font,
+                                            m_label.mbc_str() ), 26 );
+}
+
 #endif
index b772e750a81ade70652d3fdf650423f1fc4325e8..7e2499fe4569627efdab19832e0326803e398224 100644 (file)
@@ -90,12 +90,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
 
     m_widget = gtk_option_menu_new();
 
-    wxSize newSize(size);
-    if (newSize.x == -1)
-        newSize.x = 80;
-    if (newSize.y == -1)
-        newSize.y = 26;
-    SetSize( newSize.x, newSize.y );
+    SetSizeOrDefault( size );
 
     if ( style & wxCB_SORT )
     {
@@ -429,4 +424,9 @@ size_t wxChoice::AppendHelper(GtkWidget *menu, const wxString& item)
     return index;
 }
 
+wxSize wxChoice::DoGetBestSize() const
+{
+    return wxSize(80, 26);
+}
+
 #endif
index 3210098c67b1a69c5cbfcf32e68979a5607f5f5f..d8a36d5ef3f224ad1f8fe2d17a75f9a39b840985 100644 (file)
@@ -113,12 +113,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
     // make it more useable
     gtk_combo_set_use_arrows_always(GTK_COMBO(m_widget), TRUE);
 
-    wxSize newSize = size;
-    if (newSize.x == -1)
-        newSize.x = 100;
-    if (newSize.y == -1)
-        newSize.y = 26;
-    SetSize( newSize.x, newSize.y );
+    SetSizeOrDefault( size );
 
     GtkWidget *list = GTK_COMBO(m_widget)->list;
 
@@ -660,4 +655,9 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window )
              (window == GTK_COMBO(m_widget)->button->window ) );
 }
 
+wxSize wxComboBox::DoGetBestSize() const
+{
+    return wxSize(100, 26);
+}
+
 #endif
index bbd5ac2fd8e5bd86b269943f5faea7df1eb7deb4..a0b88f5944d1e0b7ba7c1a4139d5d38c0c8dc40a 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "wx/control.h"
 
-#include "gtk/gtkfeatures.h"
+#include "gtk/gtk.h"
 
 //-----------------------------------------------------------------------------
 // wxControl
@@ -58,3 +58,12 @@ wxString wxControl::GetLabel() const
 }
 
 
+wxSize wxControl::DoGetBestSize() const
+{
+    GtkRequisition req;
+    (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request )
+        (m_widget, &req );
+
+    return wxSize(req.width, req.height);
+}
+
index 1452563f5032fce32ef51300a33e3ca5c66d8a44..da71a4a355233299b7f74a7f08aea9bc75b1b810 100644 (file)
@@ -327,12 +327,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
 
     gtk_widget_show( GTK_WIDGET(m_list) );
 
-    wxSize newSize = size;
-    if (newSize.x == -1)
-        newSize.x = 100;
-    if (newSize.y == -1)
-        newSize.y = 110;
-    SetSize( newSize.x, newSize.y );
+    SetSizeOrDefault( size );
 
     if ( style & wxLB_SORT )
     {
@@ -939,4 +934,9 @@ void wxListBox::OnInternalIdle()
     UpdateWindowUI();
 }
 
+wxSize wxListBox::DoGetBestSize() const
+{
+    return wxSize(100, 110);
+}
+
 #endif
index 74f494f6e9c13314376c0d5f588b80b46f611071..e86af74122a1580f3c71253da6927f55e997bfee 100644 (file)
@@ -69,16 +69,12 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
 
     if (m_bitmap.Ok())
     {
-       wxSize newSize = size;
-
         GdkBitmap *mask = (GdkBitmap *) NULL;
         if ( m_bitmap.GetMask() )
             mask = m_bitmap.GetMask()->GetBitmap();
         m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
 
-        if (newSize.x == -1) newSize.x = m_bitmap.GetWidth();
-        if (newSize.y == -1) newSize.y = m_bitmap.GetHeight();
-        SetSize( newSize.x, newSize.y );
+        SetSizeOrDefault( size );
     }
     else
     {
@@ -116,8 +112,16 @@ void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
             gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask );
         }
 
-        SetSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() );
+        SetSizeOrDefault();
     }
 }
 
+wxSize wxStaticBitmap::DoGetBestSize() const
+{
+    if ( m_bitmap.Ok() )
+        return wxSize(m_bitmap.GetWidth(), m_bitmap.GetHeight());
+    else
+        return wxSize(16, 16);  // completely arbitrary
+}
+
 #endif
index 6816895a376b901859df451e4613891be1a4c53d..b89853149c3583c4e164b02f20df2d0dbac99065 100644 (file)
@@ -79,13 +79,7 @@ bool wxStaticText::Create(wxWindow *parent,
     static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
     gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0);
 
-    GtkRequisition req;
-    (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );
-    
-    wxSize newSize = size;
-    if (newSize.x == -1) newSize.x = req.width;
-    if (newSize.y == -1) newSize.y = req.height;
-    SetSize( newSize.x, newSize.y );
+    SetSizeOrDefault( size );
 
     m_parent->DoAddChild( this );
 
@@ -115,11 +109,7 @@ void wxStaticText::SetLabel( const wxString &label )
     // adjust the label size to the new label unless disabled
     if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
     {
-        GtkRequisition req;
-        (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request )
-            (m_widget, &req );
-
-        SetSize( req.width, req.height );
+        SetSize( GetBestSize() );
     }
 }
 
@@ -128,4 +118,3 @@ void wxStaticText::ApplyWidgetStyle()
     SetWidgetStyle();
     gtk_widget_set_style( m_widget, m_widgetStyle );
 }
-
index fd5d34bc5876ed0708d4778c0556e2c221561cac..3fc3e5386ce14438534d97153cbcf765512dbc2f 100644 (file)
@@ -182,10 +182,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
           m_text = gtk_entry_new();
     }
 
-    wxSize newSize = size;
-    if (newSize.x == -1) newSize.x = 80;
-    if (newSize.y == -1) newSize.y = 26;
-    SetSize( newSize.x, newSize.y );
+    SetSizeOrDefault( size );
 
     m_parent->DoAddChild( this );
 
@@ -966,3 +963,9 @@ void wxTextCtrl::OnInternalIdle()
 
     UpdateWindowUI();
 }
+
+wxSize wxTextCtrl::DoGetBestSize() const
+{
+    // FIXME should be different for multi-line controls...
+    return wxSize(80, 26);
+}
index 57b5dfc22d86b94fed9570177f55f589a932b6f8..fb0fb302c43b7372f3f40eaa7cb1d23b100c16bc 100644 (file)
@@ -185,7 +185,8 @@ extern bool       g_blockEventsOnDrag;
 extern bool       g_blockEventsOnScroll;
 extern wxCursor   g_globalCursor;
 static wxWindow  *g_captureWindow = (wxWindow*) NULL;
-extern wxWindow  *g_focusWindow = (wxWindow*) NULL;
+
+/* extern */ wxWindow  *g_focusWindow = (wxWindow*) NULL;
 
 // if we detect that the app has got/lost the focus, we set this variable to
 // either TRUE or FALSE and an activate event will be sent during the next
index e369bf170dfe762c98730786a978ed77e7ab182a..4e113f40a17bfce8d2eb83a38fd1048bc67d112f 100644 (file)
@@ -128,7 +128,7 @@ wxButton::~wxButton()
 // size management including autosizing
 // ----------------------------------------------------------------------------
 
-wxSize wxButton::DoGetBestSize()
+wxSize wxButton::DoGetBestSize() const
 {
     wxString label = wxGetWindowText(GetHWND());
     int wBtn;
index bffacc03447c024fe286f9bf4be2dca834f95632..8b7ba211b9daee599683972d6f9f217045999adc 100644 (file)
@@ -138,7 +138,7 @@ void wxCheckBox::SetLabel(const wxString& label)
   SetWindowText(GetHwnd(), label);
 }
 
-wxSize wxCheckBox::DoGetBestSize()
+wxSize wxCheckBox::DoGetBestSize() const
 {
     int wCheckbox, hCheckbox;
 
index 17c62f087c86172660d6a3f259126663742f7284..d45fa4d01ff06fee19789e420d0ba0bfd46aaec0 100644 (file)
@@ -119,7 +119,7 @@ bool wxControl::MSWCreateControl(const wxChar *classname,
     return TRUE;
 }
 
-wxSize wxControl::DoGetBestSize()
+wxSize wxControl::DoGetBestSize() const
 {
     return wxSize(DEFAULT_ITEM_WIDTH, DEFAULT_ITEM_HEIGHT);
 }
index 6e786a20fca96040b3a945dd3a5ca89ed62f9d20..b4a83da00ce8fa1c0ee1a482e89cfca2e19c7a4f 100644 (file)
@@ -623,7 +623,7 @@ void wxListBox::SetHorizontalExtent(const wxString& s)
     }
 }
 
-wxSize wxListBox::DoGetBestSize()
+wxSize wxListBox::DoGetBestSize() const
 {
     // find the widest string
     int wLine;
index b443d1b06243a5c5d1394da76bcfdbcf34f7dd12..6cc04c468f36ebb897f66a8db02107df6f9048cf 100644 (file)
@@ -153,7 +153,7 @@ wxSpinButton::~wxSpinButton()
 // size calculation
 // ----------------------------------------------------------------------------
 
-wxSize wxSpinButton::DoGetBestSize()
+wxSize wxSpinButton::DoGetBestSize() const
 {
     if ( (GetWindowStyle() & wxSP_VERTICAL) != 0 )
     {
index d37468bbf011b7ae05bc281fea1757672c71013d..5cbac4deda6006b2c748602bbc02ef0c44fe125a 100644 (file)
@@ -207,7 +207,7 @@ bool wxSpinCtrl::SetFont(const wxFont& font)
 // size calculations
 // ----------------------------------------------------------------------------
 
-wxSize wxSpinCtrl::DoGetBestSize()
+wxSize wxSpinCtrl::DoGetBestSize() const
 {
     wxSize sizeBtn = wxSpinButton::DoGetBestSize();
     sizeBtn.x += DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN;
index 9b809e110e5deff9923788221fda6ed91d4bcfcc..ab210117e5f0638e6b68ddb9847fbeb3c14202f7 100644 (file)
@@ -140,7 +140,7 @@ void wxStaticBitmap::Free()
     m_image.icon = NULL;
 }
 
-wxSize wxStaticBitmap::DoGetBestSize()
+wxSize wxStaticBitmap::DoGetBestSize() const
 {
     // reuse the current size (as wxWindow does) instead of using some
     // arbitrary default size (as wxControl, our immediate base class, does)
index 3607bf7d723280d4b3037c90823f700d3f2c684d..c07beec6ae80357294b405af2b5a551e6ff062f5 100644 (file)
@@ -70,7 +70,7 @@ bool wxStaticBox::Create(wxWindow *parent,
     return TRUE;
 }
 
-wxSize wxStaticBox::DoGetBestSize()
+wxSize wxStaticBox::DoGetBestSize() const
 {
     int cx, cy;
     wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
index 38d249d3cbb6fce29f2dc94581aa42dc2fb9e3a7..2a8bfaad15328b198ae4337c890f5f361ea426cb 100644 (file)
@@ -94,7 +94,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
   return TRUE;
 }
 
-wxSize wxStaticText::DoGetBestSize()
+wxSize wxStaticText::DoGetBestSize() const
 {
     wxString text(wxGetWindowText(GetHWND()));
 
index fc7e926e8c4bd7f6203dee2d747972302ef729ec..3f00865a4cf27545dc9eed77b201d8decac11f23 100644 (file)
@@ -886,7 +886,7 @@ bool wxTextCtrl::AcceptsFocus() const
     return IsEditable() && wxControl::AcceptsFocus();
 }
 
-wxSize wxTextCtrl::DoGetBestSize()
+wxSize wxTextCtrl::DoGetBestSize() const
 {
     int cx, cy;
     wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
index 34a9c55cc2b064ed1c9d4471af7b745006fd6aeb..3a49e008d6ba02ccaed4fa6057c09f01af798bb6 100644 (file)
@@ -1257,12 +1257,6 @@ void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags)
     DoMoveWindow(x, y, width, height);
 }
 
-// for a generic window there is no natural best size - just use the current one
-wxSize wxWindow::DoGetBestSize()
-{
-    return GetSize();
-}
-
 void wxWindow::DoSetClientSize(int width, int height)
 {
     wxWindow *parent = GetParent();
@@ -3353,7 +3347,7 @@ bool wxWindow::MSWOnScroll(int orientation, WXWORD wParam,
 // global functions
 // ===========================================================================
 
-void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font)
+void wxGetCharSize(WXHWND wnd, int *x, int *y, const wxFont *the_font)
 {
     TEXTMETRIC tm;
     HDC dc = ::GetDC((HWND) wnd);
@@ -3363,7 +3357,7 @@ void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font)
     {
         //    the_font->UseResource();
         //    the_font->RealizeResource();
-        fnt = (HFONT)the_font->GetResourceHandle();
+        fnt = (HFONT)((wxFont *)the_font)->GetResourceHandle(); // const_cast
         if ( fnt )
             was = (HFONT) SelectObject(dc,fnt);
     }