From 041ae20237321e764412e289c5b677479d923ac4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Mon, 15 Nov 2004 06:23:57 +0000 Subject: [PATCH] wxUniv use wxBU flags [bug #1040584] git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30531 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/button.h | 2 +- src/univ/button.cpp | 31 ++++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/wx/button.h b/include/wx/button.h index a419b7df39..66c31c5a47 100644 --- a/include/wx/button.h +++ b/include/wx/button.h @@ -25,7 +25,7 @@ #define wxBU_TOP 0x0080 #define wxBU_RIGHT 0x0100 #define wxBU_BOTTOM 0x0200 - +#define wxBU_ALIGN_MASK ( wxBU_LEFT | wxBU_TOP | wxBU_RIGHT | wxBU_BOTTOM ) #endif #if wxUSE_BUTTON diff --git a/src/univ/button.cpp b/src/univ/button.cpp index 613ff0c3d7..b70394dc5c 100644 --- a/src/univ/button.cpp +++ b/src/univ/button.cpp @@ -81,13 +81,26 @@ bool wxButton::Create(wxWindow *parent, if (label.empty() && wxIsStockID(id)) label = wxGetStockLabel(id); - // center label by default - if ( !(style & wxALIGN_MASK) ) - { - style |= wxALIGN_CENTRE_HORIZONTAL | wxALIGN_CENTRE_VERTICAL; - } + long ctrl_style = style & !wxBU_ALIGN_MASK; + + wxASSERT_MSG( (ctrl_style & wxALIGN_MASK) == 0, + _T("Some style conflicts with align flags") ); + + if((style & wxBU_RIGHT) == wxBU_RIGHT) + ctrl_style |= wxALIGN_RIGHT; + else if((style & wxBU_LEFT) == wxBU_LEFT) + ctrl_style |= wxALIGN_LEFT; + else + ctrl_style |= wxALIGN_CENTRE_HORIZONTAL; - if ( !wxControl::Create(parent, id, pos, size, style, validator, name) ) + if((style & wxBU_TOP) == wxBU_TOP) + ctrl_style |= wxALIGN_TOP; + else if((style & wxBU_BOTTOM) == wxBU_BOTTOM) + ctrl_style |= wxALIGN_BOTTOM; + else + ctrl_style |= wxALIGN_CENTRE_VERTICAL; + + if ( !wxControl::Create(parent, id, pos, size, ctrl_style, validator, name) ) return false; SetLabel(label); @@ -144,7 +157,7 @@ wxSize wxButton::DoGetBestClientSize() const width += m_bitmap.GetWidth() + 2*m_marginBmpX; } - // The default size should not be adjusted, so the code is moved into the + // The default size should not be adjusted, so the code is moved into the // renderer. This is conceptual wrong but currently the only solution. // (Otto Wyss, Patch 664399) @@ -184,7 +197,7 @@ bool wxButton::DoDrawBackground(wxDC& dc) wxSize size = GetSize(); rect.width = size.x; rect.height = size.y; - + if ( GetBackgroundBitmap().Ok() ) { // get the bitmap and the flags @@ -280,7 +293,7 @@ void wxButton::SetImageMargins(wxCoord x, wxCoord y) { m_marginBmpX = x + 2; m_marginBmpY = y + 2; - + SetBestSize(wxDefaultSize); } -- 2.45.2