removed (unused) nCtlColor parameter of OnCtlColor(); added MSWControlColor(); implemented it to use tab control background if applicable
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30632 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -70,8 +70,7 @@ public:
|
||||
|
||||
const wxArrayLong& GetSubcontrols() const { return m_subControls; }
|
||||
|
||||
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
||||
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual WXHBRUSH MSWControlColor(WXHDC pDC);
|
||||
|
||||
protected:
|
||||
// choose the default border for this window
|
||||
|
@@ -257,7 +257,7 @@ public:
|
||||
void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
|
||||
WXWORD *code, WXWORD *pos, WXHWND *hwnd);
|
||||
void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
|
||||
WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd);
|
||||
WXHDC *hdc, WXHWND *hwnd);
|
||||
void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
|
||||
WXWORD *item, WXWORD *flags, WXHMENU *hmenu);
|
||||
|
||||
@@ -308,7 +308,6 @@ public:
|
||||
bool HandleCtlColor(WXHBRUSH *hBrush,
|
||||
WXHDC hdc,
|
||||
WXHWND hWnd,
|
||||
WXUINT nCtlColor,
|
||||
WXUINT message,
|
||||
WXWPARAM wParam,
|
||||
WXLPARAM lParam);
|
||||
@@ -368,6 +367,9 @@ public:
|
||||
|
||||
// this function should return the brush to paint the window background
|
||||
// with or 0 for the default brush
|
||||
virtual WXHBRUSH MSWControlColor(WXHDC hDC);
|
||||
|
||||
// deprecated, for compatibility only: override MSWControlColor instead
|
||||
virtual WXHBRUSH OnCtlColor(WXHDC hDC,
|
||||
WXHWND hWnd,
|
||||
WXUINT nCtlColor,
|
||||
|
@@ -40,7 +40,12 @@
|
||||
|
||||
#include "wx/control.h"
|
||||
|
||||
#if wxUSE_NOTEBOOK
|
||||
#include "wx/notebook.h"
|
||||
#endif // wxUSE_NOTEBOOK
|
||||
|
||||
#include "wx/msw/private.h"
|
||||
#include "wx/msw/uxtheme.h"
|
||||
|
||||
#if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
|
||||
#include <commctrl.h>
|
||||
@@ -322,37 +327,51 @@ bool wxControl::MSWOnNotify(int idCtrl,
|
||||
}
|
||||
#endif // Win95
|
||||
|
||||
WXHBRUSH wxControl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
|
||||
#if wxUSE_CTL3D
|
||||
WXUINT message,
|
||||
WXWPARAM wParam,
|
||||
WXLPARAM lParam
|
||||
#else
|
||||
WXUINT WXUNUSED(message),
|
||||
WXWPARAM WXUNUSED(wParam),
|
||||
WXLPARAM WXUNUSED(lParam)
|
||||
#endif
|
||||
)
|
||||
WXHBRUSH wxControl::MSWControlColor(WXHDC pDC)
|
||||
{
|
||||
#if wxUSE_CTL3D
|
||||
if ( m_useCtl3D )
|
||||
{
|
||||
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
|
||||
return (WXHBRUSH) hbrush;
|
||||
}
|
||||
#endif // wxUSE_CTL3D
|
||||
|
||||
HDC hdc = (HDC)pDC;
|
||||
if ( m_hasFgCol )
|
||||
::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
|
||||
|
||||
if ( m_hasBgCol )
|
||||
{
|
||||
wxColour colBack = GetBackgroundColour();
|
||||
|
||||
::SetBkColor(hdc, wxColourToRGB(colBack));
|
||||
::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
|
||||
|
||||
wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
|
||||
|
||||
return (WXHBRUSH)brush->GetResourceHandle();
|
||||
}
|
||||
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
|
||||
#if wxUSE_UXTHEME && wxUSE_NOTEBOOK
|
||||
if ( wxUxThemeEngine::GetIfActive() )
|
||||
{
|
||||
for ( wxWindow *win = this; win; win = win->GetParent() )
|
||||
{
|
||||
wxNotebook *nbook = wxDynamicCast(win, wxNotebook);
|
||||
if ( nbook )
|
||||
{
|
||||
WXHBRUSH hbr = nbook->GetThemeBackgroundBrush();
|
||||
if ( hbr )
|
||||
{
|
||||
RECT rc;
|
||||
GetWindowRect(GetHwnd(), &rc);
|
||||
|
||||
MapWindowPoints(NULL, GetHwndOf(nbook), (POINT *)&rc, 1);
|
||||
SetBrushOrgEx(hdc, -rc.left, -rc.top, NULL);
|
||||
return hbr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_UXTHEME
|
||||
|
||||
return GetStockObject(NULL_BRUSH);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// global functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@@ -1814,7 +1814,6 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
|
||||
|
||||
// here we try to do all the job which ::IsDialogMessage() usually does
|
||||
// internally
|
||||
#if 1
|
||||
if ( msg->message == WM_KEYDOWN )
|
||||
{
|
||||
bool bCtrlDown = wxIsCtrlDown();
|
||||
@@ -1971,35 +1970,6 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else // 0
|
||||
// let ::IsDialogMessage() do almost everything and handle just the
|
||||
// things it doesn't here: Ctrl-TAB for switching notebook pages
|
||||
if ( msg->message == WM_KEYDOWN )
|
||||
{
|
||||
// don't process system keys here
|
||||
if ( !(HIWORD(msg->lParam) & KF_ALTDOWN) )
|
||||
{
|
||||
if ( (msg->wParam == VK_TAB) && wxIsCtrlDown() )
|
||||
{
|
||||
// find the first notebook parent and change its page
|
||||
wxWindow *win = this;
|
||||
wxNotebook *nbook = NULL;
|
||||
while ( win && !nbook )
|
||||
{
|
||||
nbook = wxDynamicCast(win, wxNotebook);
|
||||
win = win->GetParent();
|
||||
}
|
||||
|
||||
if ( nbook )
|
||||
{
|
||||
bool forward = !wxIsShiftDown();
|
||||
|
||||
nbook->AdvanceSelection(forward);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // 1/0
|
||||
|
||||
// don't let IsDialogMessage() get VK_ESCAPE as it _always_ eats the
|
||||
// message even when there is no cancel button and when the message is
|
||||
@@ -2147,13 +2117,10 @@ void wxWindowMSW::UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
|
||||
}
|
||||
|
||||
void wxWindowMSW::UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
|
||||
WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd)
|
||||
WXHDC *hdc, WXHWND *hwnd)
|
||||
{
|
||||
#ifndef __WXMICROWIN__
|
||||
*nCtlColor = CTLCOLOR_BTN;
|
||||
*hwnd = (WXHWND)lParam;
|
||||
*hdc = (WXHDC)wParam;
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxWindowMSW::UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
|
||||
@@ -2725,7 +2692,7 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
|
||||
break;
|
||||
|
||||
// CTLCOLOR messages are sent by children to query the parent for their
|
||||
// colors#ifndef __WXMICROWIN__
|
||||
// colors
|
||||
#ifndef __WXMICROWIN__
|
||||
case WM_CTLCOLORMSGBOX:
|
||||
case WM_CTLCOLOREDIT:
|
||||
@@ -2735,15 +2702,13 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
|
||||
case WM_CTLCOLORSCROLLBAR:
|
||||
case WM_CTLCOLORSTATIC:
|
||||
{
|
||||
WXWORD nCtlColor;
|
||||
WXHDC hdc;
|
||||
WXHWND hwnd;
|
||||
UnpackCtlColor(wParam, lParam, &nCtlColor, &hdc, &hwnd);
|
||||
UnpackCtlColor(wParam, lParam, &hdc, &hwnd);
|
||||
|
||||
processed = HandleCtlColor(&rc.hBrush,
|
||||
(WXHDC)hdc,
|
||||
(WXHWND)hwnd,
|
||||
nCtlColor,
|
||||
message,
|
||||
wParam,
|
||||
lParam);
|
||||
@@ -3773,50 +3738,40 @@ bool wxWindowMSW::HandleDisplayChange()
|
||||
return GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
#ifndef __WXMICROWIN__
|
||||
|
||||
bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush,
|
||||
WXHDC pDC,
|
||||
WXHWND pWnd,
|
||||
WXUINT nCtlColor,
|
||||
WXUINT message,
|
||||
WXWPARAM wParam,
|
||||
WXLPARAM lParam)
|
||||
{
|
||||
#ifndef __WXMICROWIN__
|
||||
WXHBRUSH hBrush = 0;
|
||||
|
||||
#ifdef __WXWINCE__
|
||||
if (false)
|
||||
#else
|
||||
if ( nCtlColor == CTLCOLOR_DLG )
|
||||
#endif
|
||||
{
|
||||
hBrush = OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
|
||||
}
|
||||
#if wxUSE_CONTROLS
|
||||
else
|
||||
{
|
||||
wxControl *item = (wxControl *)FindItemByHWND(pWnd, true);
|
||||
if ( item )
|
||||
hBrush = item->OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
|
||||
}
|
||||
*brush = item->OnCtlColor(pDC, pWnd, 0, message, wParam, lParam);
|
||||
else
|
||||
#endif // wxUSE_CONTROLS
|
||||
*brush = NULL;
|
||||
|
||||
if ( hBrush )
|
||||
*brush = hBrush;
|
||||
|
||||
return hBrush != 0;
|
||||
#else // __WXMICROWIN__
|
||||
return false;
|
||||
#endif
|
||||
return *brush != NULL;
|
||||
}
|
||||
|
||||
#endif // __WXMICROWIN__
|
||||
|
||||
// Define for each class of dialog and control
|
||||
WXHBRUSH wxWindowMSW::OnCtlColor(WXHDC WXUNUSED(hDC),
|
||||
WXHBRUSH wxWindowMSW::OnCtlColor(WXHDC hDC,
|
||||
WXHWND WXUNUSED(hWnd),
|
||||
WXUINT WXUNUSED(nCtlColor),
|
||||
WXUINT WXUNUSED(message),
|
||||
WXWPARAM WXUNUSED(wParam),
|
||||
WXLPARAM WXUNUSED(lParam))
|
||||
{
|
||||
return MSWControlColor(hDC);
|
||||
}
|
||||
|
||||
WXHBRUSH wxWindowMSW::MSWControlColor(WXHDC WXUNUSED(hDC))
|
||||
{
|
||||
return (WXHBRUSH)0;
|
||||
}
|
||||
@@ -4070,43 +4025,52 @@ bool wxWindowMSW::HandleEraseBkgnd(WXHDC hdc)
|
||||
|
||||
void wxWindowMSW::OnEraseBackground(wxEraseEvent& event)
|
||||
{
|
||||
if ( GetBackgroundStyle() == wxBG_STYLE_CUSTOM )
|
||||
switch ( GetBackgroundStyle() )
|
||||
{
|
||||
// don't skip the event here, custom background means that the app is
|
||||
// drawing it itself in its OnPaint()
|
||||
default:
|
||||
wxFAIL_MSG( _T("unexpected background style") );
|
||||
// fall through
|
||||
|
||||
case wxBG_STYLE_CUSTOM:
|
||||
// don't skip the event here, custom background means that the app
|
||||
// is drawing it itself in its OnPaint()
|
||||
break;
|
||||
|
||||
case wxBG_STYLE_SYSTEM:
|
||||
#if wxUSE_NOTEBOOK && wxUSE_UXTHEME
|
||||
// automatically apply the tab control theme background to any
|
||||
// child panels to have the same look as the native property sheet
|
||||
// dialogs
|
||||
{
|
||||
for ( wxWindow *win = this; win; win = win->GetParent() )
|
||||
{
|
||||
wxNotebook *nbook = wxDynamicCast(win, wxNotebook);
|
||||
if ( nbook )
|
||||
{
|
||||
nbook->DoEraseBackground(event);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !m_hasBgCol )
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_NOTEBOOK
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case wxBG_STYLE_COLOUR:
|
||||
// we have a fixed solid background colour, do use it
|
||||
RECT rect;
|
||||
::GetClientRect(GetHwnd(), &rect);
|
||||
|
||||
wxColour backgroundColour(GetBackgroundColour());
|
||||
COLORREF ref = PALETTERGB(backgroundColour.Red(),
|
||||
backgroundColour.Green(),
|
||||
backgroundColour.Blue());
|
||||
HBRUSH hBrush = ::CreateSolidBrush(ref);
|
||||
HBRUSH hBrush = ::CreateSolidBrush(
|
||||
wxColourToPalRGB(GetBackgroundColour()));
|
||||
if ( !hBrush )
|
||||
wxLogLastError(wxT("CreateSolidBrush"));
|
||||
|
||||
HDC hdc = (HDC)event.GetDC()->GetHDC();
|
||||
|
||||
#ifndef __WXWINCE__
|
||||
int mode = ::SetMapMode(hdc, MM_TEXT);
|
||||
#endif
|
||||
HDC hdc = GetHdcOf((*event.GetDC()));
|
||||
|
||||
::FillRect(hdc, &rect, hBrush);
|
||||
::DeleteObject(hBrush);
|
||||
|
||||
#ifndef __WXWINCE__
|
||||
::SetMapMode(hdc, mode);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user