1. introduced wxUniversal::wxWindow and moved wxControl drawing to it

2. wxStaticBox is more GTK-ish


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8197 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-08-27 15:42:15 +00:00
parent c21be757d6
commit bd9218ba08
20 changed files with 717 additions and 616 deletions

View File

@@ -29,8 +29,8 @@
#endif
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/window.h"
#include "wx/dc.h"
#include "wx/dcclient.h"
#include "wx/event.h"
#endif // WX_PRECOMP
@@ -38,44 +38,202 @@
#include "wx/univ/renderer.h"
#include "wx/univ/theme.h"
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
// we don't have any objects of type wxWindowBase so this cast is always safe
#define self ((wxWindow *)this)
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// drawing
// event tables
// ----------------------------------------------------------------------------
// the event handler executed when the window must be repainted
void wxWindowBase::OnPaint(wxPaintEvent& event)
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
EVT_PAINT(wxWindow::OnPaint)
EVT_ERASE_BACKGROUND(wxWindow::OnErase)
END_EVENT_TABLE()
// ----------------------------------------------------------------------------
// creation
// ----------------------------------------------------------------------------
void wxWindow::Init()
{
// get the renderer and the DC to use
wxWindowRenderer renderer = wxTheme::Get()->GetRenderer();
wxPaintDC dc(self);
m_scrollbarVert =
m_scrollbarHorz = (wxScrollBar *)NULL;
// draw the border
DoDrawBorder(dc, renderer);
// draw the control
DoDraw(dc, renderer);
m_isCurrent = FALSE;
}
// draw the border
void wxWindowBase::DoDrawBorder(wxDC& dc, wxRenderer *renderer)
// ----------------------------------------------------------------------------
// background pixmap
// ----------------------------------------------------------------------------
void wxWindow::SetBackground(const wxBitmap& bitmap,
int alignment,
wxStretch stretch)
{
if ( !IsTopLevel() && !(m_windowStyle & wxNO_BORDER) )
m_bitmapBg = bitmap;
m_alignBgBitmap = alignment;
m_stretchBgBitmap = stretch;
}
const wxBitmap& wxWindow::GetBackgroundBitmap(int *alignment,
wxStretch *stretch) const
{
if ( m_bitmapBg.Ok() )
{
renderer->DrawBorder(dc, self);
if ( alignment )
*alignment = m_alignBgBitmap;
if ( stretch )
*stretch = m_stretchBgBitmap;
}
return m_bitmapBg;
}
// ----------------------------------------------------------------------------
// painting
// ----------------------------------------------------------------------------
wxRenderer *wxWindow::GetRenderer() const
{
return wxTheme::Get()->GetRenderer();
}
// the event handler executed when the window background must be painted
void wxWindow::OnErase(wxEraseEvent& event)
{
wxControlRenderer renderer(this, *event.GetDC(),
wxTheme::Get()->GetRenderer());
if ( !DoDrawBackground(&renderer) )
{
// not processed
event.Skip();
}
}
void wxWindowBase::DoDraw(wxDC& dc, wxRenderer *renderer)
// the event handler executed when the window must be repainted
void wxWindow::OnPaint(wxPaintEvent& event)
{
// get the DC to use and create renderer on it
wxPaintDC dc(this);
wxControlRenderer renderer(this, dc, GetRenderer());
// do draw the control!
DoDraw(&renderer);
}
bool wxWindow::DoDrawBackground(wxControlRenderer *renderer)
{
if ( !m_bitmapBg.Ok() )
return FALSE;
renderer->DrawBackgroundBitmap();
return TRUE;
}
void wxWindow::DoDraw(wxControlRenderer *renderer)
{
renderer->DrawBorder();
}
// ----------------------------------------------------------------------------
// state flags
// ----------------------------------------------------------------------------
bool wxWindow::IsFocused() const
{
wxWindow *self = wxConstCast(this, wxWindow);
return self->FindFocus() == self;
}
bool wxWindow::IsPressed() const
{
return FALSE;
}
bool wxWindow::IsDefault() const
{
return FALSE;
}
bool wxWindow::IsCurrent() const
{
return m_isCurrent;
}
void wxWindow::SetCurrent(bool doit)
{
m_isCurrent = doit;
}
int wxWindow::GetStateFlags() const
{
int flags = 0;
if ( !IsEnabled() )
flags |= wxCONTROL_DISABLED;
// the following states are only possible if our application is active - if
// it is not, even our default/focused controls shouldn't appear as such
if ( wxTheApp->IsActive() )
{
if ( IsCurrent() )
flags |= wxCONTROL_CURRENT;
if ( IsFocused() )
flags |= wxCONTROL_FOCUSED;
if ( IsPressed() )
flags |= wxCONTROL_PRESSED;
if ( IsDefault() )
flags |= wxCONTROL_ISDEFAULT;
}
return flags;
}
// ----------------------------------------------------------------------------
// size
// ----------------------------------------------------------------------------
wxSize wxWindow::AdjustSize(const wxSize& size) const
{
wxSize sz = size;
wxTheme::Get()->GetRenderer()->AdjustSize(&sz, this);
return sz;
}
// ----------------------------------------------------------------------------
// scrolling
// ----------------------------------------------------------------------------
void wxWindow::SetScrollbar(int orient,
int pos,
int thumb,
int range,
bool refresh)
{
return wxWindowNative::SetScrollbar(orient, pos, thumb, range, refresh);
}
void wxWindow::SetScrollPos(int orient, int pos, bool refresh)
{
return wxWindowNative::SetScrollPos(orient, pos, refresh);
}
int wxWindow::GetScrollPos(int orient) const
{
return wxWindowNative::GetScrollPos(orient);
}
int wxWindow::GetScrollThumb(int orient) const
{
return wxWindowNative::GetScrollThumb(orient);
}
int wxWindow::GetScrollRange(int orient) const
{
return wxWindowNative::GetScrollRange(orient);
}