wxWindow::GetBestSize() added
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4633 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -73,6 +73,9 @@ public:
|
||||
GtkWidget *m_widgetCheckbox;
|
||||
GtkWidget *m_widgetLabel;
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxCheckBox)
|
||||
};
|
||||
|
@@ -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);
|
||||
|
@@ -121,6 +121,9 @@ public:
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxComboBox)
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -80,6 +80,9 @@ public:
|
||||
SetBitmap( icon );
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
private:
|
||||
// creates the new pixmap widget
|
||||
void CreatePixmapWidget();
|
||||
|
@@ -36,25 +36,35 @@ extern const wxChar *wxStaticTextNameStr;
|
||||
// wxStaticText
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxStaticText: public wxControl
|
||||
class wxStaticText : public wxControl
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxStaticText)
|
||||
public:
|
||||
|
||||
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 );
|
||||
|
||||
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;
|
||||
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__
|
||||
|
@@ -131,6 +131,9 @@ public:
|
||||
|
||||
void SetModified() { m_modified = TRUE; }
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
private:
|
||||
bool m_modified;
|
||||
GtkWidget *m_text;
|
||||
|
@@ -73,6 +73,9 @@ public:
|
||||
GtkWidget *m_widgetCheckbox;
|
||||
GtkWidget *m_widgetLabel;
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxCheckBox)
|
||||
};
|
||||
|
@@ -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);
|
||||
|
@@ -121,6 +121,9 @@ public:
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxComboBox)
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -80,6 +80,9 @@ public:
|
||||
SetBitmap( icon );
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
private:
|
||||
// creates the new pixmap widget
|
||||
void CreatePixmapWidget();
|
||||
|
@@ -36,25 +36,35 @@ extern const wxChar *wxStaticTextNameStr;
|
||||
// wxStaticText
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxStaticText: public wxControl
|
||||
class wxStaticText : public wxControl
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxStaticText)
|
||||
public:
|
||||
|
||||
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 );
|
||||
|
||||
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;
|
||||
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__
|
||||
|
@@ -131,6 +131,9 @@ public:
|
||||
|
||||
void SetModified() { m_modified = TRUE; }
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
private:
|
||||
bool m_modified;
|
||||
GtkWidget *m_text;
|
||||
|
@@ -66,7 +66,7 @@ protected:
|
||||
// send a notification event, return TRUE if processed
|
||||
bool SendClickEvent();
|
||||
|
||||
virtual wxSize DoGetBestSize();
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -53,7 +53,7 @@ public:
|
||||
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize();
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxBitmapCheckBox: public wxCheckBox
|
||||
|
@@ -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
|
||||
|
@@ -126,7 +126,7 @@ protected:
|
||||
int m_noItems;
|
||||
int m_selected;
|
||||
|
||||
virtual wxSize DoGetBestSize();
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
#if wxUSE_OWNER_DRAWN
|
||||
// control items
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -59,7 +59,7 @@ public:
|
||||
WXWORD pos, WXHWND control);
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize();
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxSpinButton)
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -84,7 +84,7 @@ protected:
|
||||
wxBitmap *bitmap;
|
||||
} m_image;
|
||||
|
||||
virtual wxSize DoGetBestSize();
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -57,7 +57,7 @@ public:
|
||||
virtual bool AcceptsFocus() const { return FALSE; }
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize();
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -56,7 +56,7 @@ public:
|
||||
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize();
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -162,7 +162,7 @@ protected:
|
||||
// limit is big enough)
|
||||
void AdjustSpaceLimit();
|
||||
|
||||
virtual wxSize DoGetBestSize();
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user