virtual void InitDialog();
+#ifdef __WXUNIV__
+ virtual bool ProvidesBackground() { return TRUE; }
+#endif
+
WX_DECLARE_CONTROL_CONTAINER();
protected:
long numArg = -1,
const wxString& strArg = wxEmptyString);
virtual wxSize DoGetBestClientSize() const;
+
+ virtual bool DoDrawBackground(wxDC& dc);
virtual void DoDraw(wxControlRenderer *renderer);
virtual bool CanBeHighlighted() const { return TRUE; }
// overridden base class virtuals
virtual bool IsPressed() const { return m_isPressed; }
+ virtual bool HasTransparentBackground() { return TRUE; }
+
protected:
virtual bool PerformAction(const wxControlAction& action,
long numArg = -1,
virtual void DrawBackground(wxDC& dc,
const wxColour& col,
const wxRect& rect,
- int flags) = 0;
+ int flags,
+ wxWindow *window = NULL ) = 0;
+
+ // draw the button surface
+ virtual void DrawButtonSurface(wxDC& dc,
+ const wxColour& col,
+ const wxRect& rect,
+ int flags )
+ { DrawBackground( dc, col, rect, flags ); }
+
// draw the label inside the given rectangle with the specified alignment
// and optionally emphasize the character with the given index
virtual void DrawBackground(wxDC& dc,
const wxColour& col,
const wxRect& rect,
- int flags)
- { m_renderer->DrawBackground(dc, col, rect, flags); }
+ int flags,
+ wxWindow *window = NULL )
+ { m_renderer->DrawBackground(dc, col, rect, flags, window ); }
virtual void DrawLabel(wxDC& dc,
const wxString& label,
const wxRect& rect,
wxIcon GetIcon() const;
+ virtual bool HasTransparentBackground() { return TRUE; }
+
private:
virtual void DoDraw(wxControlRenderer *renderer);
// take account of this
virtual wxPoint GetBoxAreaOrigin() const;
+ virtual bool HasTransparentBackground() { return TRUE; }
+
protected:
// draw the control
virtual void DoDraw(wxControlRenderer *renderer);
virtual void SetLabel(const wxString& label);
+ virtual bool HasTransparentBackground() { return TRUE; }
+
protected:
// calculate the optimal size for the label
virtual wxSize DoGetBestClientSize() const;
virtual int GetMinWidth() const;
virtual int GetMinHeight() const;
+ virtual bool ProvidesBackground() { return TRUE; }
+
protected:
// handle titlebar button click event
virtual void ClickTitleBarButton(long button);
// control (e.g. a button, checkbox, ...)
virtual bool IsContainerWindow() const { return FALSE; }
+ // returns TRUE if the control has "transparent" areas such
+ // as a wxStaticText and wxCheckBox and the background should
+ // be adapted from a parent window
+ virtual bool HasTransparentBackground() { return FALSE; }
+
+ // to be used with function above: transparent windows get
+ // their background from parents that return TRUE here,
+ // so this is mostly for wxPanel, wxTopLevelWindow etc.
+ virtual bool ProvidesBackground() { return FALSE; }
+
// return TRUE if this control can be highlighted when the mouse is over
// it (the theme decides itself whether it is really highlighted or not)
virtual bool CanBeHighlighted() const { return FALSE; }
// erase part of the control
virtual void EraseBackground(wxDC& dc, const wxRect& rect);
- // see below
- bool HasDialogBackground() { return m_hasDialogBackground; }
-
// overridden base class methods
// -----------------------------
// the renderer we use
wxRenderer *m_renderer;
- // background like a dialog (e.g. wxStaticText,
- // wxRadioButton), not with a surface (wxButton)
- bool m_hasDialogBackground;
-
// background bitmap info
wxBitmap m_bitmapBg;
int m_alignBgBitmap;
{
wxEventType command = wxEVT_SCROLL_THUMBRELEASE;
int value = (int)ceil(win->m_adjust->value);
- int dir = win->HasFlag(wxSB_VERTICAL) ? wxVERTICAL : wxHORIZONTAL;
+ int orient = win->HasFlag(wxSB_VERTICAL) ? wxVERTICAL : wxHORIZONTAL;
- wxScrollEvent event( command, value, dir );
+ wxScrollEvent event( command, win->GetId(), value, orient );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
}
{
wxEventType command = wxEVT_SCROLL_THUMBRELEASE;
int value = (int)ceil(win->m_adjust->value);
- int dir = win->HasFlag(wxSB_VERTICAL) ? wxVERTICAL : wxHORIZONTAL;
+ int orient = win->HasFlag(wxSB_VERTICAL) ? wxVERTICAL : wxHORIZONTAL;
- wxScrollEvent event( command, value, dir );
+ wxScrollEvent event( command, win->GetId(), value, orient );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
}
#include "wx/univ/renderer.h"
#include "wx/univ/inphand.h"
#include "wx/univ/theme.h"
+#include "wx/univ/colschem.h"
// ----------------------------------------------------------------------------
// constants
renderer->DrawLabel(m_bitmap, m_marginBmpX, m_marginBmpY);
}
+bool wxButton::DoDrawBackground(wxDC& dc)
+{
+ wxRect rect;
+ wxSize size = GetSize();
+ rect.width = size.x;
+ rect.height = size.y;
+
+ if ( GetBackgroundBitmap().Ok() )
+ {
+ // get the bitmap and the flags
+ int alignment;
+ wxStretch stretch;
+ wxBitmap bmp = GetBackgroundBitmap(&alignment, &stretch);
+ wxControlRenderer::DrawBitmap(dc, bmp, rect, alignment, stretch);
+ }
+ else
+ {
+ m_renderer->DrawButtonSurface(dc, wxTHEME_BG_COLOUR(this),
+ rect, GetStateFlags());
+ }
+
+ return TRUE;
+}
+
// ----------------------------------------------------------------------------
// input processing
// ----------------------------------------------------------------------------
if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
return FALSE;
- m_hasDialogBackground = TRUE;
-
SetLabel(label);
SetBestSize(size);
m_renderer->DrawButtonBorder(m_dc, m_rect, flags, &m_rect);
- m_renderer->DrawBackground(m_dc, wxTHEME_BG_COLOUR(m_window), m_rect, flags);
+ // Why do this here?
+ // m_renderer->DrawButtonSurface(m_dc, wxTHEME_BG_COLOUR(m_window), m_rect, flags );
}
void wxControlRenderer::DrawBitmap(const wxBitmap& bitmap)
if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
return FALSE;
- m_hasDialogBackground = TRUE;
-
// set bitmap first
SetBitmap(label);
if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
return FALSE;
- m_hasDialogBackground = TRUE;
-
SetLabel(label);
return TRUE;
if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
return FALSE;
- m_hasDialogBackground = TRUE;
-
SetLabel(label);
SetBestSize(size);
virtual void DrawBackground(wxDC& dc,
const wxColour& col,
const wxRect& rect,
- int flags = 0);
+ int flags = 0,
+ wxWindow *window = NULL );
virtual void DrawLabel(wxDC& dc,
const wxString& label,
const wxRect& rect,
// draw the background with any colour, not only the default one(s)
void DoDrawBackground(wxDC& dc,
const wxColour& col,
- const wxRect& rect);
+ const wxRect& rect,
+ wxWindow *window = NULL);
// DrawBorder() helpers: all of them shift and clip the DC after drawing
// the border
void wxGTKRenderer::DoDrawBackground(wxDC& dc,
const wxColour& col,
- const wxRect& rect)
+ const wxRect& rect,
+ wxWindow *window )
{
wxBrush brush(col, wxSOLID);
dc.SetBrush(brush);
void wxGTKRenderer::DrawBackground(wxDC& dc,
const wxColour& col,
const wxRect& rect,
- int flags)
+ int flags,
+ wxWindow *window )
{
wxColour colBg = col.Ok() ? col : GetBackgroundColour(flags);
- DoDrawBackground(dc, colBg, rect);
+ DoDrawBackground(dc, colBg, rect, window );
}
// ----------------------------------------------------------------------------
// ctor
wxMetalRenderer(const wxColourScheme *scheme);
+
+ // Metal gradient
+ void DrawMetal(wxDC &dc, const wxRect &rect );
// implement the base class pure virtuals
virtual void DrawBackground(wxDC& dc,
const wxColour& col,
const wxRect& rect,
- int flags = 0);
+ int flags = 0,
+ wxWindow *window = NULL );
+ virtual void DrawButtonSurface(wxDC& dc,
+ const wxColour& col,
+ const wxRect& rect,
+ int flags );
virtual void DrawLabel(wxDC& dc,
const wxString& label,
const wxRect& rect,
// DrawButtonBorder() helper
void DoDrawBackground(wxDC& dc,
const wxColour& col,
- const wxRect& rect);
+ const wxRect& rect,
+ wxWindow *window = NULL );
// DrawBorder() helpers: all of them shift and clip the DC after drawing
// the border
}
else
{
- if ( win->HasDialogBackground() )
- {
- col = win->GetParent()->GetBackgroundColour();
- return col;
- }
-
int flags = win->GetStateFlags();
// the colour set by the user should be used for the normal state
}
}
+// ----------------------------------------------------------------------------
+// metal gradient
+// ----------------------------------------------------------------------------
+
+void wxMetalRenderer::DrawMetal(wxDC &dc, const wxRect &rect )
+{
+ dc.SetPen(*wxTRANSPARENT_PEN);
+ for (int y = rect.y; y < rect.height+rect.y; y++)
+ {
+ int intens = 230 + 80 * (rect.y-y) / rect.height;
+ dc.SetBrush( wxBrush( wxColour(intens,intens,intens), wxSOLID ) );
+ dc.DrawRectangle( rect.x, y, rect.width, 1 );
+ }
+}
+
// ----------------------------------------------------------------------------
// background
// ----------------------------------------------------------------------------
+void wxMetalRenderer::DrawButtonSurface(wxDC& dc,
+ const wxColour& col,
+ const wxRect& rect,
+ int flags )
+{
+ DrawMetal( dc, rect );
+}
+
void wxMetalRenderer::DoDrawBackground(wxDC& dc,
const wxColour& col,
- const wxRect& rect)
+ const wxRect& rect,
+ wxWindow *window )
{
dc.SetPen(*wxTRANSPARENT_PEN);
- if (col == wxTheme::Get()->GetColourScheme()->Get( wxColourScheme::CONTROL ))
- {
- for (int y = rect.y; y < rect.height+rect.y; y++)
- {
- int intens = 230 + 80 * (rect.y-y) / rect.height;
- dc.SetBrush( wxBrush( wxColour(intens,intens,intens), wxSOLID ) );
- dc.DrawRectangle( rect.x, y, rect.width, 1 );
- }
- }
- else
- {
- wxBrush brush(col, wxSOLID);
- dc.SetBrush(brush);
- dc.DrawRectangle(rect);
- }
+ wxBrush brush(col, wxSOLID);
+ dc.SetBrush(brush);
+ dc.DrawRectangle(rect);
}
void wxMetalRenderer::DrawBackground(wxDC& dc,
const wxColour& col,
const wxRect& rect,
- int flags)
+ int flags,
+ wxWindow *window )
{
// just fill it with the given or default bg colour
wxColour colBg = col.Ok() ? col : wxSCHEME_COLOUR(m_scheme, CONTROL);
- DoDrawBackground(dc, colBg, rect);
+ DoDrawBackground(dc, colBg, rect, window);
}
// ----------------------------------------------------------------------------
wxArrowStyle arrowStyle)
{
wxRect rect = rectAll;
- DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
+ DrawMetal( dc, rect );
DrawArrowBorder(dc, &rect, arrowStyle == Arrow_Pressed);
DrawArrow(dc, rect, arrowDir, arrowStyle);
}
// we don't use the flags, the thumb never changes appearance
wxRect rectThumb = rect;
DrawArrowBorder(dc, &rectThumb);
- DrawBackground(dc, wxNullColour, rectThumb);
+ DrawMetal( dc, rectThumb );
}
void wxMetalRenderer::DrawScrollbarShaft(wxDC& dc,
const wxRect& rectBar,
int flags)
{
- wxColourScheme::StdColour col = flags & wxCONTROL_PRESSED
- ? wxColourScheme::SCROLLBAR_PRESSED
- : wxColourScheme::SCROLLBAR;
- DoDrawBackground(dc, m_scheme->Get(col), rectBar);
+ DrawMetal( dc, rectBar );
}
void wxMetalRenderer::DrawScrollCorner(wxDC& dc, const wxRect& rect)
virtual void DrawBackground(wxDC& dc,
const wxColour& col,
const wxRect& rect,
- int flags = 0);
+ int flags = 0,
+ wxWindow *window = NULL);
virtual void DrawLabel(wxDC& dc,
const wxString& label,
const wxRect& rect,
// DrawButtonBorder() helper
void DoDrawBackground(wxDC& dc,
const wxColour& col,
- const wxRect& rect);
+ const wxRect& rect,
+ wxWindow *window = NULL );
// DrawBorder() helpers: all of them shift and clip the DC after drawing
// the border
void wxWin32Renderer::DoDrawBackground(wxDC& dc,
const wxColour& col,
- const wxRect& rect)
+ const wxRect& rect,
+ wxWindow *window )
{
wxBrush brush(col, wxSOLID);
dc.SetBrush(brush);
void wxWin32Renderer::DrawBackground(wxDC& dc,
const wxColour& col,
const wxRect& rect,
- int flags)
+ int flags,
+ wxWindow *window )
{
// just fill it with the given or default bg colour
wxColour colBg = col.Ok() ? col : wxSCHEME_COLOUR(m_scheme, CONTROL);
- DoDrawBackground(dc, colBg, rect);
+ DoDrawBackground(dc, colBg, rect, window );
}
// ----------------------------------------------------------------------------
m_oldSize.x = -1;
m_oldSize.y = -1;
-
- m_hasDialogBackground = FALSE;
}
bool wxWindow::Create(wxWindow *parent,
void wxWindow::EraseBackground(wxDC& dc, const wxRect& rect)
{
// TODO: handle bg bitmaps here!
-
+
m_renderer->DrawBackground(dc, wxTHEME_BG_COLOUR(this), rect, GetStateFlags());
}
win->GetEventHandler()->ProcessEvent(event);
- win->OnInternalIdle();
-
if (event.MoreRequested())
needMore = TRUE;
node = node->Next();
}
+ win->OnInternalIdle();
+
return needMore;
}
{
// While the GUI isn't working that well, just print out the
// message.
-#if 0
+#if 1
wxAppBase::OnAssert(file, line, msg);
#else
wxString msg2;
{
wxWindow::OnInternalIdle();
- if (m_needResizeInIdle)
+ // Do this only after the last idle event so that
+ // all windows have been updated before a new
+ // round of size events is sent
+ if (m_needResizeInIdle && !wxTheApp->Pending())
{
wxSizeEvent event( GetClientSize(), GetId() );
event.SetEventObject( this );
bool wxTopLevelWindowX11::Show(bool show)
{
- // Nano-X has to force a size event,
- // else there's no initial size.
-#if wxUSE_NANOX
if (show)
-#else
- if (show && m_needResizeInIdle)
-#endif
{
wxSizeEvent event(GetSize(), GetId());
+
event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event);
m_needResizeInIdle = FALSE;
}
- if (show)
- {
- // This does the layout _before_ the
- // window is shown, else the items are
- // drawn first at the wrong positions,
- // then at the correct positions.
- if (GetAutoLayout())
- {
- Layout();
- }
- }
bool ret = wxWindowX11::Show(show);