\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
\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}
\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}
\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}
\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}
\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}
\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}
GtkWidget *m_widgetCheckbox;
GtkWidget *m_widgetLabel;
+protected:
+ virtual wxSize DoGetBestSize() const;
+
private:
DECLARE_DYNAMIC_CLASS(wxCheckBox)
};
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);
bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle();
+protected:
+ virtual wxSize DoGetBestSize() const;
+
private:
DECLARE_DYNAMIC_CLASS(wxComboBox)
DECLARE_EVENT_TABLE()
virtual wxString GetLabel() const;
protected:
+ virtual wxSize DoGetBestSize() const;
+
wxString m_label;
char m_chAccel; // enabled to avoid breaking binary compatibility later on
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)
SetBitmap( icon );
}
+protected:
+ virtual wxSize DoGetBestSize() const;
+
private:
// creates the new pixmap widget
void CreatePixmapWidget();
// 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__
void SetModified() { m_modified = TRUE; }
+protected:
+ virtual wxSize DoGetBestSize() const;
+
private:
bool m_modified;
GtkWidget *m_text;
GtkWidget *m_widgetCheckbox;
GtkWidget *m_widgetLabel;
+protected:
+ virtual wxSize DoGetBestSize() const;
+
private:
DECLARE_DYNAMIC_CLASS(wxCheckBox)
};
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);
bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle();
+protected:
+ virtual wxSize DoGetBestSize() const;
+
private:
DECLARE_DYNAMIC_CLASS(wxComboBox)
DECLARE_EVENT_TABLE()
virtual wxString GetLabel() const;
protected:
+ virtual wxSize DoGetBestSize() const;
+
wxString m_label;
char m_chAccel; // enabled to avoid breaking binary compatibility later on
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)
SetBitmap( icon );
}
+protected:
+ virtual wxSize DoGetBestSize() const;
+
private:
// creates the new pixmap widget
void CreatePixmapWidget();
// 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__
void SetModified() { m_modified = TRUE; }
+protected:
+ virtual wxSize DoGetBestSize() const;
+
private:
bool m_modified;
GtkWidget *m_text;
// send a notification event, return TRUE if processed
bool SendClickEvent();
- virtual wxSize DoGetBestSize();
+ virtual wxSize DoGetBestSize() const;
};
#endif
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
protected:
- virtual wxSize DoGetBestSize();
+ virtual wxSize DoGetBestSize() const;
};
class WXDLLEXPORT wxBitmapCheckBox: public wxCheckBox
// 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
int m_noItems;
int m_selected;
- virtual wxSize DoGetBestSize();
+ virtual wxSize DoGetBestSize() const;
#if wxUSE_OWNER_DRAWN
// control items
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);
WXWORD pos, WXHWND control);
protected:
- virtual wxSize DoGetBestSize();
+ virtual wxSize DoGetBestSize() const;
private:
DECLARE_DYNAMIC_CLASS(wxSpinButton)
protected:
virtual void DoMoveWindow(int x, int y, int width, int height);
- virtual wxSize DoGetBestSize();
+ virtual wxSize DoGetBestSize() const;
WXHWND m_hwndBuddy;
wxBitmap *bitmap;
} m_image;
- virtual wxSize DoGetBestSize();
+ virtual wxSize DoGetBestSize() const;
};
#endif
virtual bool AcceptsFocus() const { return FALSE; }
protected:
- virtual wxSize DoGetBestSize();
+ virtual wxSize DoGetBestSize() const;
};
#endif
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
protected:
- virtual wxSize DoGetBestSize();
+ virtual wxSize DoGetBestSize() const;
};
#endif
// limit is big enough)
void AdjustSpaceLimit();
- virtual wxSize DoGetBestSize();
+ virtual wxSize DoGetBestSize() const;
private:
DECLARE_EVENT_TABLE()
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
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); }
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
// ---------------------------
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
// ----------------------------------------------------------------------------
WXDLLEXPORT extern wxWindow* wxGetActiveWindow();
+
+// deprecated (doesn't start with 'wx' prefix), use wxWindow::NewControlId()
inline WXDLLEXPORT int NewControlId() { return wxWindowBase::NewControlId(); }
#endif
}
// ----------------------------------------------------------------------------
-// centre/fit the window
+// size/position related methods
// ----------------------------------------------------------------------------
// centre the window with respect to its parent in either (or both) directions
// 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))
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",
UpdateWindowUI();
}
+wxSize wxCheckBox::DoGetBestSize() const
+{
+ return wxSize( 25 + gdk_string_measure( m_widgetCheckbox->style->font,
+ m_label.mbc_str() ), 26 );
+}
+
#endif
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 )
{
return index;
}
+wxSize wxChoice::DoGetBestSize() const
+{
+ return wxSize(80, 26);
+}
+
#endif
// 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;
(window == GTK_COMBO(m_widget)->button->window ) );
}
+wxSize wxComboBox::DoGetBestSize() const
+{
+ return wxSize(100, 26);
+}
+
#endif
#include "wx/control.h"
-#include "gtk/gtkfeatures.h"
+#include "gtk/gtk.h"
//-----------------------------------------------------------------------------
// wxControl
}
+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);
+}
+
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 )
{
UpdateWindowUI();
}
+wxSize wxListBox::DoGetBestSize() const
+{
+ return wxSize(100, 110);
+}
+
#endif
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
{
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
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 );
// 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() );
}
}
SetWidgetStyle();
gtk_widget_set_style( m_widget, m_widgetStyle );
}
-
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 );
UpdateWindowUI();
}
+
+wxSize wxTextCtrl::DoGetBestSize() const
+{
+ // FIXME should be different for multi-line controls...
+ return wxSize(80, 26);
+}
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
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",
UpdateWindowUI();
}
+wxSize wxCheckBox::DoGetBestSize() const
+{
+ return wxSize( 25 + gdk_string_measure( m_widgetCheckbox->style->font,
+ m_label.mbc_str() ), 26 );
+}
+
#endif
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 )
{
return index;
}
+wxSize wxChoice::DoGetBestSize() const
+{
+ return wxSize(80, 26);
+}
+
#endif
// 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;
(window == GTK_COMBO(m_widget)->button->window ) );
}
+wxSize wxComboBox::DoGetBestSize() const
+{
+ return wxSize(100, 26);
+}
+
#endif
#include "wx/control.h"
-#include "gtk/gtkfeatures.h"
+#include "gtk/gtk.h"
//-----------------------------------------------------------------------------
// wxControl
}
+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);
+}
+
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 )
{
UpdateWindowUI();
}
+wxSize wxListBox::DoGetBestSize() const
+{
+ return wxSize(100, 110);
+}
+
#endif
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
{
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
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 );
// 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() );
}
}
SetWidgetStyle();
gtk_widget_set_style( m_widget, m_widgetStyle );
}
-
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 );
UpdateWindowUI();
}
+
+wxSize wxTextCtrl::DoGetBestSize() const
+{
+ // FIXME should be different for multi-line controls...
+ return wxSize(80, 26);
+}
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
// size management including autosizing
// ----------------------------------------------------------------------------
-wxSize wxButton::DoGetBestSize()
+wxSize wxButton::DoGetBestSize() const
{
wxString label = wxGetWindowText(GetHWND());
int wBtn;
SetWindowText(GetHwnd(), label);
}
-wxSize wxCheckBox::DoGetBestSize()
+wxSize wxCheckBox::DoGetBestSize() const
{
int wCheckbox, hCheckbox;
return TRUE;
}
-wxSize wxControl::DoGetBestSize()
+wxSize wxControl::DoGetBestSize() const
{
return wxSize(DEFAULT_ITEM_WIDTH, DEFAULT_ITEM_HEIGHT);
}
}
}
-wxSize wxListBox::DoGetBestSize()
+wxSize wxListBox::DoGetBestSize() const
{
// find the widest string
int wLine;
// size calculation
// ----------------------------------------------------------------------------
-wxSize wxSpinButton::DoGetBestSize()
+wxSize wxSpinButton::DoGetBestSize() const
{
if ( (GetWindowStyle() & wxSP_VERTICAL) != 0 )
{
// size calculations
// ----------------------------------------------------------------------------
-wxSize wxSpinCtrl::DoGetBestSize()
+wxSize wxSpinCtrl::DoGetBestSize() const
{
wxSize sizeBtn = wxSpinButton::DoGetBestSize();
sizeBtn.x += DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN;
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)
return TRUE;
}
-wxSize wxStaticBox::DoGetBestSize()
+wxSize wxStaticBox::DoGetBestSize() const
{
int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
return TRUE;
}
-wxSize wxStaticText::DoGetBestSize()
+wxSize wxStaticText::DoGetBestSize() const
{
wxString text(wxGetWindowText(GetHWND()));
return IsEditable() && wxControl::AcceptsFocus();
}
-wxSize wxTextCtrl::DoGetBestSize()
+wxSize wxTextCtrl::DoGetBestSize() const
{
int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
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();
// 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);
{
// 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);
}