int widthParent, heightParent;
wxWindow *parent = GetParent();
- if ( (direction & wxCENTER_FRAME) && parent )
+ if ( !parent )
{
- parent->GetClientSize(&widthParent, &heightParent);
+ // no other choice
+ direction |= wxCENTRE_ON_SCREEN;
}
- else
+
+ if ( direction & wxCENTRE_ON_SCREEN )
{
// centre with respect to the whole screen
wxDisplaySize(&widthParent, &heightParent);
}
+ else
+ {
+ // centre inside the parents rectangle
+ parent->GetClientSize(&widthParent, &heightParent);
+ }
int width, height;
GetSize(&width, &height);
// controls are always centered on their parent because it doesn't make
// sense to centre them on the screen
- if ( (direction & wxCENTER_FRAME) || wxDynamicCast(this, wxControl) )
+ if ( !(direction & wxCENTRE_ON_SCREEN) || wxDynamicCast(this, wxControl) )
{
+ // theo nly chance to get this is to have a wxControl without parent
+ wxCHECK_RET( parent, _T("a control must have a parent") );
+
// adjust to the parents client area origin
wxPoint posParent = parent->ClientToScreen(wxPoint(0, 0));
// don't try to set invalid cursor, always fall back to the default
const wxCursor& cursorOk = cursor.Ok() ? cursor : *wxSTANDARD_CURSOR;
- if ( cursorOk == m_cursor )
+ if ( (wxCursor&)cursorOk == m_cursor )
{
// no change
return FALSE;
// don't try to set invalid font, always fall back to the default
const wxFont& fontOk = font.Ok() ? font : *wxSWISS_FONT;
- if ( fontOk == m_font )
+ if ( (wxFont&)fontOk == m_font )
{
// no change
return FALSE;