Added SetOption,GetOption[Int] to wxSystemSettings. Made native MaskBlt optional.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10563 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -32,6 +32,16 @@ public:
|
|||||||
|
|
||||||
// Get a system metric, e.g. scrollbar size
|
// Get a system metric, e.g. scrollbar size
|
||||||
static int GetSystemMetric(int index);
|
static int GetSystemMetric(int index);
|
||||||
|
|
||||||
|
// User-customizable hints to wxWindows or associated libraries
|
||||||
|
// These could also be used to influence GetSystem... calls, indeed
|
||||||
|
// to implement SetSystemColour/Font/Metric
|
||||||
|
|
||||||
|
static void SetOption(const wxString& name, const wxString& value);
|
||||||
|
static void SetOption(const wxString& name, int value);
|
||||||
|
static wxString GetOption(const wxString& name) ;
|
||||||
|
static int GetOptionInt(const wxString& name) ;
|
||||||
|
static bool HasOption(const wxString& name) ;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -781,16 +781,23 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask
|
|||||||
if ( useMask )
|
if ( useMask )
|
||||||
{
|
{
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
HDC hdcMem = ::CreateCompatibleDC(GetHdc());
|
|
||||||
::SelectObject(hdcMem, GetHbitmapOf(bmp));
|
|
||||||
|
|
||||||
// use MaskBlt() with ROP which doesn't do anything to dst in the mask
|
// use MaskBlt() with ROP which doesn't do anything to dst in the mask
|
||||||
// points
|
// points
|
||||||
bool ok = ::MaskBlt(GetHdc(), x, y, width, height,
|
// On some systems, MaskBlt succeeds yet is much much slower
|
||||||
|
// than the wxWindows fall-back implementation. So we need
|
||||||
|
// to be able to switch this on and off at runtime.
|
||||||
|
bool ok = FALSE;
|
||||||
|
if (wxSystemSettings::GetOptionInt(wxT("no-maskblt")) == 0)
|
||||||
|
{
|
||||||
|
HDC hdcMem = ::CreateCompatibleDC(GetHdc());
|
||||||
|
::SelectObject(hdcMem, GetHbitmapOf(bmp));
|
||||||
|
|
||||||
|
ok = ::MaskBlt(GetHdc(), x, y, width, height,
|
||||||
hdcMem, 0, 0,
|
hdcMem, 0, 0,
|
||||||
hbmpMask, 0, 0,
|
hbmpMask, 0, 0,
|
||||||
MAKEROP4(SRCCOPY, DSTCOPY)) != 0;
|
MAKEROP4(SRCCOPY, DSTCOPY)) != 0;
|
||||||
::DeleteDC(hdcMem);
|
::DeleteDC(hdcMem);
|
||||||
|
}
|
||||||
|
|
||||||
if ( !ok )
|
if ( !ok )
|
||||||
#endif // Win32
|
#endif // Win32
|
||||||
@@ -1471,7 +1478,7 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool success;
|
bool success = FALSE;
|
||||||
|
|
||||||
if (useMask)
|
if (useMask)
|
||||||
{
|
{
|
||||||
@@ -1480,10 +1487,17 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
|
|||||||
// transparent, so use "DSTCOPY" ROP for the mask points (the usual
|
// transparent, so use "DSTCOPY" ROP for the mask points (the usual
|
||||||
// meaning of fg and bg is inverted which corresponds to wxWin notion
|
// meaning of fg and bg is inverted which corresponds to wxWin notion
|
||||||
// of the mask which is also contrary to the Windows one)
|
// of the mask which is also contrary to the Windows one)
|
||||||
success = ::MaskBlt(GetHdc(), xdest, ydest, width, height,
|
|
||||||
|
// On some systems, MaskBlt succeeds yet is much much slower
|
||||||
|
// than the wxWindows fall-back implementation. So we need
|
||||||
|
// to be able to switch this on and off at runtime.
|
||||||
|
if (wxSystemSettings::GetOptionInt(wxT("no-maskblt")) == 0)
|
||||||
|
{
|
||||||
|
success = ::MaskBlt(GetHdc(), xdest, ydest, width, height,
|
||||||
GetHdcOf(*source), xsrc, ysrc,
|
GetHdcOf(*source), xsrc, ysrc,
|
||||||
(HBITMAP)mask->GetMaskBitmap(), xsrc, ysrc,
|
(HBITMAP)mask->GetMaskBitmap(), xsrc, ysrc,
|
||||||
MAKEROP4(dwRop, DSTCOPY)) != 0;
|
MAKEROP4(dwRop, DSTCOPY)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !success )
|
if ( !success )
|
||||||
#endif // Win32
|
#endif // Win32
|
||||||
|
@@ -49,12 +49,16 @@
|
|||||||
// singleton class so it can't be done in the dtor)
|
// singleton class so it can't be done in the dtor)
|
||||||
class wxSystemSettingsModule : public wxModule
|
class wxSystemSettingsModule : public wxModule
|
||||||
{
|
{
|
||||||
|
friend class wxSystemSettings;
|
||||||
public:
|
public:
|
||||||
virtual bool OnInit();
|
virtual bool OnInit();
|
||||||
virtual void OnExit();
|
virtual void OnExit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxSystemSettingsModule)
|
DECLARE_DYNAMIC_CLASS(wxSystemSettingsModule)
|
||||||
|
|
||||||
|
static wxArrayString sm_optionNames;
|
||||||
|
static wxArrayString sm_optionValues;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -73,6 +77,9 @@ static wxFont *gs_fontDefault = NULL;
|
|||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxSystemSettingsModule, wxModule)
|
IMPLEMENT_DYNAMIC_CLASS(wxSystemSettingsModule, wxModule)
|
||||||
|
|
||||||
|
wxArrayString wxSystemSettingsModule::sm_optionNames;
|
||||||
|
wxArrayString wxSystemSettingsModule::sm_optionValues;
|
||||||
|
|
||||||
bool wxSystemSettingsModule::OnInit()
|
bool wxSystemSettingsModule::OnInit()
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -80,6 +87,8 @@ bool wxSystemSettingsModule::OnInit()
|
|||||||
|
|
||||||
void wxSystemSettingsModule::OnExit()
|
void wxSystemSettingsModule::OnExit()
|
||||||
{
|
{
|
||||||
|
sm_optionNames.Clear();
|
||||||
|
sm_optionValues.Clear();
|
||||||
delete gs_fontDefault;
|
delete gs_fontDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,3 +252,45 @@ int wxSystemSettings::GetSystemMetric(int index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Option functions (arbitrary name/value mapping)
|
||||||
|
void wxSystemSettings::SetOption(const wxString& name, const wxString& value)
|
||||||
|
{
|
||||||
|
int idx = wxSystemSettingsModule::sm_optionNames.Index(name, FALSE);
|
||||||
|
if (idx == wxNOT_FOUND)
|
||||||
|
{
|
||||||
|
wxSystemSettingsModule::sm_optionNames.Add(name);
|
||||||
|
wxSystemSettingsModule::sm_optionValues.Add(value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxSystemSettingsModule::sm_optionNames[idx] = name;
|
||||||
|
wxSystemSettingsModule::sm_optionValues[idx] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxSystemSettings::SetOption(const wxString& name, int value)
|
||||||
|
{
|
||||||
|
wxString valStr;
|
||||||
|
valStr.Printf(wxT("%d"), value);
|
||||||
|
SetOption(name, valStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxSystemSettings::GetOption(const wxString& name)
|
||||||
|
{
|
||||||
|
int idx = wxSystemSettingsModule::sm_optionNames.Index(name, FALSE);
|
||||||
|
if (idx == wxNOT_FOUND)
|
||||||
|
return wxEmptyString;
|
||||||
|
else
|
||||||
|
return wxSystemSettingsModule::sm_optionValues[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxSystemSettings::GetOptionInt(const wxString& name)
|
||||||
|
{
|
||||||
|
return wxAtoi(GetOption(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxSystemSettings::HasOption(const wxString& name)
|
||||||
|
{
|
||||||
|
return (wxSystemSettingsModule::sm_optionNames.Index(name, FALSE) != wxNOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user