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; }
|
const wxArrayLong& GetSubcontrols() const { return m_subControls; }
|
||||||
|
|
||||||
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
virtual WXHBRUSH MSWControlColor(WXHDC pDC);
|
||||||
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// choose the default border for this window
|
// choose the default border for this window
|
||||||
|
@@ -257,7 +257,7 @@ public:
|
|||||||
void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
|
void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
|
||||||
WXWORD *code, WXWORD *pos, WXHWND *hwnd);
|
WXWORD *code, WXWORD *pos, WXHWND *hwnd);
|
||||||
void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
|
void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
|
||||||
WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd);
|
WXHDC *hdc, WXHWND *hwnd);
|
||||||
void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
|
void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
|
||||||
WXWORD *item, WXWORD *flags, WXHMENU *hmenu);
|
WXWORD *item, WXWORD *flags, WXHMENU *hmenu);
|
||||||
|
|
||||||
@@ -308,7 +308,6 @@ public:
|
|||||||
bool HandleCtlColor(WXHBRUSH *hBrush,
|
bool HandleCtlColor(WXHBRUSH *hBrush,
|
||||||
WXHDC hdc,
|
WXHDC hdc,
|
||||||
WXHWND hWnd,
|
WXHWND hWnd,
|
||||||
WXUINT nCtlColor,
|
|
||||||
WXUINT message,
|
WXUINT message,
|
||||||
WXWPARAM wParam,
|
WXWPARAM wParam,
|
||||||
WXLPARAM lParam);
|
WXLPARAM lParam);
|
||||||
@@ -368,6 +367,9 @@ public:
|
|||||||
|
|
||||||
// this function should return the brush to paint the window background
|
// this function should return the brush to paint the window background
|
||||||
// with or 0 for the default brush
|
// with or 0 for the default brush
|
||||||
|
virtual WXHBRUSH MSWControlColor(WXHDC hDC);
|
||||||
|
|
||||||
|
// deprecated, for compatibility only: override MSWControlColor instead
|
||||||
virtual WXHBRUSH OnCtlColor(WXHDC hDC,
|
virtual WXHBRUSH OnCtlColor(WXHDC hDC,
|
||||||
WXHWND hWnd,
|
WXHWND hWnd,
|
||||||
WXUINT nCtlColor,
|
WXUINT nCtlColor,
|
||||||
|
@@ -40,7 +40,12 @@
|
|||||||
|
|
||||||
#include "wx/control.h"
|
#include "wx/control.h"
|
||||||
|
|
||||||
|
#if wxUSE_NOTEBOOK
|
||||||
|
#include "wx/notebook.h"
|
||||||
|
#endif // wxUSE_NOTEBOOK
|
||||||
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
|
#include "wx/msw/uxtheme.h"
|
||||||
|
|
||||||
#if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
|
#if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
@@ -322,35 +327,49 @@ bool wxControl::MSWOnNotify(int idCtrl,
|
|||||||
}
|
}
|
||||||
#endif // Win95
|
#endif // Win95
|
||||||
|
|
||||||
WXHBRUSH wxControl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
|
WXHBRUSH wxControl::MSWControlColor(WXHDC pDC)
|
||||||
#if wxUSE_CTL3D
|
|
||||||
WXUINT message,
|
|
||||||
WXWPARAM wParam,
|
|
||||||
WXLPARAM lParam
|
|
||||||
#else
|
|
||||||
WXUINT WXUNUSED(message),
|
|
||||||
WXWPARAM WXUNUSED(wParam),
|
|
||||||
WXLPARAM WXUNUSED(lParam)
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
#if wxUSE_CTL3D
|
|
||||||
if ( m_useCtl3D )
|
|
||||||
{
|
|
||||||
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
|
|
||||||
return (WXHBRUSH) hbrush;
|
|
||||||
}
|
|
||||||
#endif // wxUSE_CTL3D
|
|
||||||
|
|
||||||
HDC hdc = (HDC)pDC;
|
HDC hdc = (HDC)pDC;
|
||||||
wxColour colBack = GetBackgroundColour();
|
if ( m_hasFgCol )
|
||||||
|
::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
|
||||||
|
|
||||||
::SetBkColor(hdc, wxColourToRGB(colBack));
|
if ( m_hasBgCol )
|
||||||
::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
|
{
|
||||||
|
wxColour colBack = GetBackgroundColour();
|
||||||
|
|
||||||
wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
|
::SetBkColor(hdc, wxColourToRGB(colBack));
|
||||||
|
|
||||||
return (WXHBRUSH)brush->GetResourceHandle();
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@@ -1814,7 +1814,6 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
|
|||||||
|
|
||||||
// here we try to do all the job which ::IsDialogMessage() usually does
|
// here we try to do all the job which ::IsDialogMessage() usually does
|
||||||
// internally
|
// internally
|
||||||
#if 1
|
|
||||||
if ( msg->message == WM_KEYDOWN )
|
if ( msg->message == WM_KEYDOWN )
|
||||||
{
|
{
|
||||||
bool bCtrlDown = wxIsCtrlDown();
|
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
|
// 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
|
// 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,
|
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;
|
*hwnd = (WXHWND)lParam;
|
||||||
*hdc = (WXHDC)wParam;
|
*hdc = (WXHDC)wParam;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowMSW::UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
|
void wxWindowMSW::UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
|
||||||
@@ -2725,7 +2692,7 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// CTLCOLOR messages are sent by children to query the parent for their
|
// CTLCOLOR messages are sent by children to query the parent for their
|
||||||
// colors#ifndef __WXMICROWIN__
|
// colors
|
||||||
#ifndef __WXMICROWIN__
|
#ifndef __WXMICROWIN__
|
||||||
case WM_CTLCOLORMSGBOX:
|
case WM_CTLCOLORMSGBOX:
|
||||||
case WM_CTLCOLOREDIT:
|
case WM_CTLCOLOREDIT:
|
||||||
@@ -2735,15 +2702,13 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
|
|||||||
case WM_CTLCOLORSCROLLBAR:
|
case WM_CTLCOLORSCROLLBAR:
|
||||||
case WM_CTLCOLORSTATIC:
|
case WM_CTLCOLORSTATIC:
|
||||||
{
|
{
|
||||||
WXWORD nCtlColor;
|
|
||||||
WXHDC hdc;
|
WXHDC hdc;
|
||||||
WXHWND hwnd;
|
WXHWND hwnd;
|
||||||
UnpackCtlColor(wParam, lParam, &nCtlColor, &hdc, &hwnd);
|
UnpackCtlColor(wParam, lParam, &hdc, &hwnd);
|
||||||
|
|
||||||
processed = HandleCtlColor(&rc.hBrush,
|
processed = HandleCtlColor(&rc.hBrush,
|
||||||
(WXHDC)hdc,
|
(WXHDC)hdc,
|
||||||
(WXHWND)hwnd,
|
(WXHWND)hwnd,
|
||||||
nCtlColor,
|
|
||||||
message,
|
message,
|
||||||
wParam,
|
wParam,
|
||||||
lParam);
|
lParam);
|
||||||
@@ -3773,50 +3738,40 @@ bool wxWindowMSW::HandleDisplayChange()
|
|||||||
return GetEventHandler()->ProcessEvent(event);
|
return GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush,
|
|
||||||
WXHDC pDC,
|
|
||||||
WXHWND pWnd,
|
|
||||||
WXUINT nCtlColor,
|
|
||||||
WXUINT message,
|
|
||||||
WXWPARAM wParam,
|
|
||||||
WXLPARAM lParam)
|
|
||||||
{
|
|
||||||
#ifndef __WXMICROWIN__
|
#ifndef __WXMICROWIN__
|
||||||
WXHBRUSH hBrush = 0;
|
|
||||||
|
|
||||||
#ifdef __WXWINCE__
|
bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush,
|
||||||
if (false)
|
WXHDC pDC,
|
||||||
#else
|
WXHWND pWnd,
|
||||||
if ( nCtlColor == CTLCOLOR_DLG )
|
WXUINT message,
|
||||||
#endif
|
WXWPARAM wParam,
|
||||||
{
|
WXLPARAM lParam)
|
||||||
hBrush = OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
|
{
|
||||||
}
|
|
||||||
#if wxUSE_CONTROLS
|
#if wxUSE_CONTROLS
|
||||||
|
wxControl *item = (wxControl *)FindItemByHWND(pWnd, true);
|
||||||
|
if ( item )
|
||||||
|
*brush = item->OnCtlColor(pDC, pWnd, 0, message, wParam, lParam);
|
||||||
else
|
else
|
||||||
{
|
|
||||||
wxControl *item = (wxControl *)FindItemByHWND(pWnd, true);
|
|
||||||
if ( item )
|
|
||||||
hBrush = item->OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
|
|
||||||
}
|
|
||||||
#endif // wxUSE_CONTROLS
|
#endif // wxUSE_CONTROLS
|
||||||
|
*brush = NULL;
|
||||||
|
|
||||||
if ( hBrush )
|
return *brush != NULL;
|
||||||
*brush = hBrush;
|
|
||||||
|
|
||||||
return hBrush != 0;
|
|
||||||
#else // __WXMICROWIN__
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // __WXMICROWIN__
|
||||||
|
|
||||||
// Define for each class of dialog and control
|
// Define for each class of dialog and control
|
||||||
WXHBRUSH wxWindowMSW::OnCtlColor(WXHDC WXUNUSED(hDC),
|
WXHBRUSH wxWindowMSW::OnCtlColor(WXHDC hDC,
|
||||||
WXHWND WXUNUSED(hWnd),
|
WXHWND WXUNUSED(hWnd),
|
||||||
WXUINT WXUNUSED(nCtlColor),
|
WXUINT WXUNUSED(nCtlColor),
|
||||||
WXUINT WXUNUSED(message),
|
WXUINT WXUNUSED(message),
|
||||||
WXWPARAM WXUNUSED(wParam),
|
WXWPARAM WXUNUSED(wParam),
|
||||||
WXLPARAM WXUNUSED(lParam))
|
WXLPARAM WXUNUSED(lParam))
|
||||||
|
{
|
||||||
|
return MSWControlColor(hDC);
|
||||||
|
}
|
||||||
|
|
||||||
|
WXHBRUSH wxWindowMSW::MSWControlColor(WXHDC WXUNUSED(hDC))
|
||||||
{
|
{
|
||||||
return (WXHBRUSH)0;
|
return (WXHBRUSH)0;
|
||||||
}
|
}
|
||||||
@@ -4070,43 +4025,52 @@ bool wxWindowMSW::HandleEraseBkgnd(WXHDC hdc)
|
|||||||
|
|
||||||
void wxWindowMSW::OnEraseBackground(wxEraseEvent& event)
|
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
|
default:
|
||||||
// drawing it itself in its OnPaint()
|
wxFAIL_MSG( _T("unexpected background style") );
|
||||||
return;
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // wxUSE_NOTEBOOK
|
||||||
|
event.Skip();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxBG_STYLE_COLOUR:
|
||||||
|
// we have a fixed solid background colour, do use it
|
||||||
|
RECT rect;
|
||||||
|
::GetClientRect(GetHwnd(), &rect);
|
||||||
|
|
||||||
|
HBRUSH hBrush = ::CreateSolidBrush(
|
||||||
|
wxColourToPalRGB(GetBackgroundColour()));
|
||||||
|
if ( !hBrush )
|
||||||
|
wxLogLastError(wxT("CreateSolidBrush"));
|
||||||
|
|
||||||
|
HDC hdc = GetHdcOf((*event.GetDC()));
|
||||||
|
|
||||||
|
::FillRect(hdc, &rect, hBrush);
|
||||||
|
::DeleteObject(hBrush);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !m_hasBgCol )
|
|
||||||
{
|
|
||||||
event.Skip();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
if ( !hBrush )
|
|
||||||
wxLogLastError(wxT("CreateSolidBrush"));
|
|
||||||
|
|
||||||
HDC hdc = (HDC)event.GetDC()->GetHDC();
|
|
||||||
|
|
||||||
#ifndef __WXWINCE__
|
|
||||||
int mode = ::SetMapMode(hdc, MM_TEXT);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
::FillRect(hdc, &rect, hBrush);
|
|
||||||
::DeleteObject(hBrush);
|
|
||||||
|
|
||||||
#ifndef __WXWINCE__
|
|
||||||
::SetMapMode(hdc, mode);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user