simplifications and corrections to background drawing:

1. removed ApplyParentThemeBackground() not used any longer
2. removed ProvidesBackground() which is synonymous with
   !HasTransparentBackground()
3. removed a whole bunch of unused MSWXXX() methods
4. moved MSWControlColor() from wxWindow up to wxControl

results:

1. the gradient is still shown properly for static/radio boxes in notebooks
2. correct background colour is used for the static boxes
3. code is shorter and better commented


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33474 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-04-10 15:23:08 +00:00
parent 47561b0dc5
commit c3732409ac
32 changed files with 340 additions and 496 deletions

View File

@@ -61,10 +61,6 @@ public:
int GetMarginX() const { return m_marginX; }
int GetMarginY() const { return m_marginY; }
virtual void ApplyParentThemeBackground(const wxColour& bg)
{ SetBackgroundColour(bg); }
protected:
// function called when any of the bitmaps changes
virtual void OnSetBitmap() { InvalidateBestSize(); Refresh(); }

View File

@@ -179,11 +179,6 @@ public:
}
}
// override some base class virtuals
virtual void ApplyParentThemeBackground(const wxColour& bg)
{ SetBackgroundColour(bg); }
virtual bool ProvidesBackground() const { return true; }
protected:
// remove the page and return a pointer to it
virtual wxWindow *DoRemovePage(size_t page) = 0;

View File

@@ -80,12 +80,8 @@ public:
#ifdef __WXUNIVERSAL__
virtual bool IsCanvasWindow() const { return true; }
virtual bool ProvidesBackground() const { return true; }
#endif
virtual void ApplyParentThemeBackground(const wxColour& bg)
{ SetBackgroundColour(bg); }
WX_DECLARE_CONTROL_CONTAINER();

View File

@@ -54,13 +54,6 @@ public:
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
virtual bool MSWCommand(WXUINT param, WXWORD id);
virtual void ApplyParentThemeBackground(const wxColour& bg)
{
// avoide switching into owner-drawn mode
wxControl::SetBackgroundColour(bg);
}
#ifdef __WIN32__
// coloured buttons support
virtual bool SetBackgroundColour(const wxColour &colour);
virtual bool SetForegroundColour(const wxColour &colour);
@@ -69,7 +62,6 @@ public:
private:
void MakeOwnerDrawn();
#endif // __WIN32__
protected:
// send a notification event, return true if processed

View File

@@ -50,7 +50,6 @@ public:
protected:
virtual wxSize DoGetBestSize() const;
virtual WXHBRUSH MSWGetDefaultBgBrush();
virtual void DoSet3StateValue(wxCheckBoxState value);
virtual wxCheckBoxState DoGet3StateValue() const;

View File

@@ -70,6 +70,10 @@ public:
const wxArrayLong& GetSubcontrols() const { return m_subControls; }
// default handling of WM_CTLCOLORxxx: this is public so that wxWindow
// could call it
virtual WXHBRUSH MSWControlColor(WXHDC pDC);
protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const;
@@ -116,34 +120,15 @@ protected:
// default style for the control include WS_TABSTOP if it AcceptsFocus()
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
// default handling of WM_CTLCOLORxxx
virtual WXHBRUSH MSWControlColor(WXHDC pDC);
// call this from the derived class MSWControlColor() if you want to show
// the control greyed out (and opaque)
WXHBRUSH MSWControlColorDisabled(WXHDC pDC);
// call this from the derived class MSWControlColor() if you want to always
// paint the background (as all opaque controls do)
WXHBRUSH MSWControlColorSolid(WXHDC pDC)
{
return DoMSWControlColor(pDC, GetBackgroundColour());
}
// common part of the 3 functions above: pass wxNullColour to use the
// appropriate background colour (meaning ours or our parents) or a fixed
// one
virtual WXHBRUSH DoMSWControlColor(WXHDC pDC, wxColour colBg);
// another WM_CTLCOLOR-related function: override this to return the brush
// which should be used to paint the control background by default
//
// for most controls, the default behaviour of returning 0 and letting the
// system do it is correct, but for some -- e.g. checkboxes -- we actually
// have to return transparent brush from here to prevent the system from
// overwriting background with solid colour
virtual WXHBRUSH MSWGetDefaultBgBrush() { return 0; }
// this is a helper for the derived class GetClassDefaultAttributes()
// implementation: it returns the right colours for the classes which
// contain something else (e.g. wxListBox, wxTextCtrl, ...) instead of

View File

@@ -143,11 +143,6 @@ public:
protected:
WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
virtual WXHBRUSH MSWControlColor(WXHDC pDC)
{
return MSWControlColorSolid(pDC);
}
// free memory (common part of Clear() and dtor)
void Free();

View File

@@ -183,9 +183,6 @@ public:
return true;
}
virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindow *win);
virtual wxColour MSWGetBgColourForChild(wxWindow *win);
#endif // wxUSE_UXTHEME
protected:
@@ -198,6 +195,11 @@ protected:
// remove one page from the notebook, without deleting
virtual wxNotebookPage *DoRemovePage(size_t nPage);
// get the page rectangle for the current notebook size
//
// returns empty rectangle if an error occurs, do test for it
wxRect GetPageSize() const;
// set the size of the given page to fit in the notebook
void AdjustPageSize(wxNotebookPage *page);
@@ -208,8 +210,16 @@ protected:
// creates the brush to be used for drawing the tab control background
void UpdateBgBrush();
// paint themed children background here
virtual bool MSWPrintChild(wxWindow *win, WXWPARAM wParam, WXLPARAM lParam);
// return the themed brush for painting our children
virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindow *win);
// draw child background
virtual bool MSWPrintChild(WXHDC hDC, wxWindow *win);
// common part of QueryBgBitmap() and MSWPrintChild()
//
// if child == NULL, draw background for the entire notebook itself
bool DoDrawBackground(WXHDC hDC, wxWindow *child = NULL);
#endif // wxUSE_UXTHEME
// the current selection (-1 if none)

View File

@@ -722,6 +722,14 @@ extern WXDLLEXPORT wxSize wxGetHiconSize(HICON hicon);
// Lines are drawn differently for WinCE and regular WIN32
WXDLLEXPORT void wxDrawLine(HDC hdc, int x1, int y1, int x2, int y2);
// fill the client rect of the given window on the provided dc using this brush
inline void wxFillRect(HWND hwnd, HDC hdc, HBRUSH hbr)
{
RECT rc;
::GetClientRect(hwnd, &rc);
::FillRect(hdc, &rc, hbr);
}
// ----------------------------------------------------------------------------
// 32/64 bit helpers
// ----------------------------------------------------------------------------

View File

@@ -144,10 +144,9 @@ protected:
int sizeFlags = wxSIZE_AUTO);
virtual wxSize DoGetBestSize() const;
#ifndef __WXWINCE__
virtual WXHRGN MSWGetRegionWithoutChildren();
virtual WXLRESULT MSWWindowProc(WXUINT nMsg,
WXWPARAM wParam,
WXLPARAM lParam);
#endif // __WXWINCE__
// the buttons we contain

View File

@@ -52,9 +52,7 @@ public:
// implementation only from now on
virtual bool MSWCommand(WXUINT param, WXWORD id);
virtual void Command(wxCommandEvent& event);
virtual void ApplyParentThemeBackground(const wxColour& bg)
{ SetBackgroundColour(bg); }
virtual bool HasTransparentBackground() { return true; }
protected:
virtual wxSize DoGetBestSize() const;

View File

@@ -49,6 +49,8 @@ protected:
virtual wxBorder GetDefaultBorder() const;
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
#ifndef __WXWINCE__
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
// return the region with all the windows inside this static box excluded
@@ -58,12 +60,13 @@ protected:
// region which is embedded in a rectangle (0, 0)-(w, h)
virtual void MSWGetRegionWithoutSelf(WXHRGN hrgn, int w, int h);
// paint the given rectangle with our background colour
// paint the given rectangle with our background brush/colour
void PaintBackground(wxDC& dc, const struct tagRECT& rc);
void OnPaint(wxPaintEvent& event);
DECLARE_DYNAMIC_CLASS_NO_COPY(wxStaticBox)
#endif // !__WXWINCE__
};
#endif // _WX_MSW_STATBOX_H_

View File

@@ -51,7 +51,7 @@ protected:
int sizeFlags = wxSIZE_AUTO);
virtual wxSize DoGetBestSize() const;
virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
virtual WXHBRUSH DoMSWControlColor(WXHDC pDC, wxColour colBg);
DECLARE_DYNAMIC_CLASS_NO_COPY(wxStaticText)
};

View File

@@ -358,55 +358,32 @@ public:
// called when the window is about to be destroyed
virtual void MSWDestroyWindow();
// this function should return the brush to paint the window background
// with or 0 for the default brush
virtual WXHBRUSH MSWControlColor(WXHDC hDC);
// this function should return the brush to paint the children controls
// background or 0 if this window doesn't impose any particular background
// on its children
//
// the base class version uses MSWGetBgColourForChild() and returns a solid
// brush if we have a non default background colour or 0 otherwise
virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC), wxWindow *child)
// the base class version returns a solid brush if we have a non default
// background colour or 0 otherwise
virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindow *child);
// return the background brush to use for painting the given window by
// quering the parent windows via their MSWGetBgBrushForChild() recursively
//
// winToPaint is normally NULL meaning this window itself, but it can also
// be a child of this window which is used by the static box and could be
// potentially useful for other transparent controls
WXHBRUSH MSWGetBgBrush(WXHDC hDC, wxWindow *winToPaint = NULL);
// gives the parent the possibility to draw its children background, e.g.
// this is used by wxNotebook to do it using DrawThemeBackground()
//
// return true if background was drawn, false otherwise
virtual bool MSWPrintChild(WXHDC WXUNUSED(hDC), wxWindow * WXUNUSED(child))
{
return MSWGetSolidBgBrushForChild(child);
return false;
}
// return the background colour of this window under the given child
// (possible grand child)
//
// this is a hack as if the background is themed, there is no single colour
// representing it, but sometimes we can't use the pattern brush returned
// by MSWGetBgBrushForChild() anyhow and then this function is used as
// fallback
//
// the base class version returns bg colour if it had been explicitely set
// or wxNullColour otherwise
virtual wxColour MSWGetBgColourForChild(wxWindow *child);
// convenience function: returns a solid brush of the colour returned by
// MSWGetBgColourForChild() or 0
WXHBRUSH MSWGetSolidBgBrushForChild(wxWindow *child);
// normally just calls MSWGetBgBrushForChild() on the parent window but may
// be overridden if the default background brush is not suitable for some
// reason (e.g. wxStaticBox uses MSWGetSolidBgBrushForChild() instead)
virtual WXHBRUSH MSWGetBgBrushForSelf(wxWindow *parent, WXHDC hDC);
// return the background brush to use for this window by quering the parent
// windows via their MSWGetBgBrushForChild() recursively
WXHBRUSH MSWGetBgBrush(WXHDC hDC);
// overriding this method gives the parent window the opportunity to
// process WM_PRINTCLIENT for its children: this is currently used by
// wxNotebook to draw themed background for them
//
// return true if the message was processed or false to use default logic
// for it (currently this means handling it just as WM_PAINT i.e. render
// the control into the provided DC)
virtual bool MSWPrintChild(wxWindow *win, WXWPARAM wParam, WXLPARAM lParam);
// Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event);
@@ -422,7 +399,7 @@ public:
// virtual function for implementing internal idle
// behaviour
virtual void OnInternalIdle() ;
virtual void OnInternalIdle();
protected:
// the window handle
@@ -485,8 +462,8 @@ protected:
// default OnEraseBackground() implementation, return true if we did erase
// the background, false otherwise
bool DoEraseBackground(wxDC& dc);
// the background, false otherwise (i.e. the system should erase it)
bool DoEraseBackground(WXHDC hDC);
private:
// common part of all ctors

View File

@@ -55,12 +55,6 @@ public:
// send a notification event, return true if processed
bool SendClickEvent();
virtual void ApplyParentThemeBackground(const wxColour& bg)
{
// avoide switching into owner-drawn mode
wxControl::SetBackgroundColour(bg);
}
protected:
// default button handling

View File

@@ -137,9 +137,6 @@ public:
int GetNumVer() const;
int GetNumHor() const;
virtual void ApplyParentThemeBackground(const wxColour& bg)
{ SetBackgroundColour(bg); }
protected:
// we can't compute our best size before the items are added to the control
virtual void SetInitialBestSize(const wxSize& WXUNUSED(size)) { }

View File

@@ -56,10 +56,6 @@ public:
// send a notification event, return true if processed
bool SendClickEvent();
virtual void ApplyParentThemeBackground(const wxColour& bg)
{ SetBackgroundColour(bg); }
protected:
virtual wxSize DoGetBestSize() const;

View File

@@ -80,9 +80,6 @@ public:
virtual int GetSelStart() const { return GetMax(); }
virtual void SetSelection(int WXUNUSED(min), int WXUNUSED(max)) { }
virtual void ApplyParentThemeBackground(const wxColour& bg)
{ SetBackgroundColour(bg); }
protected:
// adjust value according to wxSL_INVERSE style

View File

@@ -48,8 +48,6 @@ public:
// overriden base class virtuals
virtual bool AcceptsFocus() const { return false; }
virtual void ApplyParentThemeBackground(const wxColour& bg)
{ SetBackgroundColour(bg); }
protected:
// set the right size for the right dimension

View File

@@ -191,7 +191,6 @@ public:
virtual bool Destroy();
virtual bool IsTopLevel() const { return true; }
virtual wxSize GetMaxSize() const;
virtual bool ProvidesBackground() const { return true; }
// event handlers
void OnCloseWindow(wxCloseEvent& event);

View File

@@ -189,10 +189,6 @@ public:
void SetSelectionBackground(const wxColour& col);
virtual void ApplyParentThemeBackground(const wxColour& WXUNUSED(bg))
{ /* do nothing */ }
virtual wxVisualAttributes GetDefaultAttributes() const
{
return GetClassDefaultAttributes(GetWindowVariant());

View File

@@ -482,14 +482,6 @@ public:
virtual void SetThemeEnabled(bool enableTheme) { m_themeEnabled = enableTheme; }
virtual bool GetThemeEnabled() const { return m_themeEnabled; }
// Returns true if this class should have the background colour
// changed to match the parent window's theme. For example when a
// page is added to a notebook it and its children may need to have
// the colours adjusted depending on the current theme settings, but
// not all windows/controls can do this without looking wrong.
virtual void ApplyParentThemeBackground(const wxColour& WXUNUSED(bg))
{ /* do nothing */ }
// focus and keyboard handling
// ---------------------------
@@ -768,13 +760,6 @@ public:
return m_hasBgCol;
}
// if the window shouldn't inherit its colour from the parent, override
// this function to return true
//
// this is currently only used by wxMSW and wxUniv but should be useful for
// the other ports too
virtual bool ProvidesBackground() const { return false; }
virtual bool SetForegroundColour(const wxColour& colour);
void SetOwnForegroundColour(const wxColour& colour)
{