mirror of https://github.com/BOINC/boinc.git
MGR: Fix appearance of Simple Preferences dialog items when tabbing through the items to change focus; adjust length of static line for DPI setting on Windows.
This commit is contained in:
parent
d0acbd441e
commit
2702e2e32b
|
@ -144,42 +144,45 @@ CTransparentHyperlinkCtrl::CTransparentHyperlinkCtrl(wxWindow *parent,
|
|||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
const wxString& name,
|
||||
wxBitmap** parentsBgBmp)
|
||||
{
|
||||
(void)Create(parent, id, label, url, pos, size, style, name);
|
||||
(void)Create(parent, id, label, url, pos, size, style, name, parentsBgBmp);
|
||||
}
|
||||
|
||||
bool CTransparentHyperlinkCtrl::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& label, const wxString& url,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
wxWindowID id,
|
||||
const wxString& label, const wxString& url,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name,
|
||||
wxBitmap** parentsBgBmp)
|
||||
{
|
||||
SetBackgroundStyle(wxBG_STYLE_CUSTOM);
|
||||
bool bRetVal = wxHyperlinkCtrl::Create(parent, id, label, url, pos, size, style|wxTRANSPARENT_WINDOW, name);
|
||||
bool bRetVal = wxHyperlinkCtrl::Create(parent, id, label, url, pos, size, style, name);
|
||||
|
||||
m_pParentsBgBmp = parentsBgBmp;
|
||||
SetBackgroundColour(parent->GetBackgroundColour());
|
||||
SetForegroundColour(wxColour(0, 100, 225));
|
||||
wxFont myFont = GetFont();
|
||||
myFont.SetUnderlined(true);
|
||||
SetFont(myFont);
|
||||
|
||||
return bRetVal;
|
||||
}
|
||||
|
||||
wxSize CTransparentHyperlinkCtrl::GetBestSize() {
|
||||
return GetTextExtent(GetLabel());
|
||||
}
|
||||
|
||||
void CTransparentHyperlinkCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
|
||||
void CTransparentHyperlinkCtrl::OnEraseBackground(wxEraseEvent& event)
|
||||
{
|
||||
}
|
||||
|
||||
void CTransparentHyperlinkCtrl::OnPaint(wxPaintEvent& /*event*/) {
|
||||
wxPaintDC dc(this);
|
||||
wxFont myFont = GetFont();
|
||||
myFont.SetUnderlined(true);
|
||||
dc.SetFont(myFont);
|
||||
dc.DrawText(GetLabel(), 0, 0);
|
||||
if (m_pParentsBgBmp && *m_pParentsBgBmp) {
|
||||
wxMemoryDC memDC(**m_pParentsBgBmp);
|
||||
wxSize sz = GetClientSize();
|
||||
wxDC *dc = event.GetDC();
|
||||
wxCoord x, y;
|
||||
GetPosition(&x, &y);
|
||||
dc->Blit(0, 0, sz.GetWidth(), sz.GetHeight(), &memDC, x, y, wxCOPY);
|
||||
} else {
|
||||
event.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -331,25 +334,42 @@ CTransparentCheckBox::CTransparentCheckBox(wxWindow *parent, wxWindowID id, cons
|
|||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name
|
||||
const wxString& name,
|
||||
wxBitmap** parentsBgBmp
|
||||
) {
|
||||
Create(parent, id, label, pos, size, style, validator, name);
|
||||
Create(parent, id, label, pos, size, style, validator, name, parentsBgBmp);
|
||||
}
|
||||
|
||||
bool CTransparentCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name
|
||||
const wxString& name,
|
||||
wxBitmap** parentsBgBmp
|
||||
) {
|
||||
bool bRetVal = wxCheckBox::Create(parent, id, label, pos, size, style|wxTRANSPARENT_WINDOW, validator, name);
|
||||
bool bRetVal = wxCheckBox::Create(parent, id, label, pos, size, style, validator, name);
|
||||
|
||||
m_pParentsBgBmp = parentsBgBmp;
|
||||
SetBackgroundColour(parent->GetBackgroundColour());
|
||||
SetForegroundColour(parent->GetForegroundColour());
|
||||
|
||||
return bRetVal;
|
||||
}
|
||||
|
||||
void CTransparentCheckBox::OnEraseBackground(wxEraseEvent& event)
|
||||
{
|
||||
if (m_pParentsBgBmp && *m_pParentsBgBmp) {
|
||||
wxMemoryDC memDC(**m_pParentsBgBmp);
|
||||
wxSize sz = GetClientSize();
|
||||
wxDC *dc = event.GetDC();
|
||||
wxCoord x, y;
|
||||
GetPosition(&x, &y);
|
||||
dc->Blit(0, 0, sz.GetWidth(), sz.GetHeight(), &memDC, x, y, wxCOPY);
|
||||
} else {
|
||||
event.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -150,7 +150,9 @@ public:
|
|||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxHL_DEFAULT_STYLE,
|
||||
const wxString& name = wxHyperlinkCtrlNameStr);
|
||||
const wxString& name = wxHyperlinkCtrlNameStr,
|
||||
wxBitmap** parentsBgBmp = NULL
|
||||
);
|
||||
|
||||
// Creation function (for two-step construction).
|
||||
bool Create(wxWindow *parent,
|
||||
|
@ -159,13 +161,13 @@ public:
|
|||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxHL_DEFAULT_STYLE,
|
||||
const wxString& name = wxHyperlinkCtrlNameStr);
|
||||
|
||||
virtual bool HasTransparentBackground() { return true; };
|
||||
const wxString& name = wxHyperlinkCtrlNameStr,
|
||||
wxBitmap** parentsBgBmp = NULL
|
||||
);
|
||||
|
||||
virtual void OnEraseBackground(wxEraseEvent& event);
|
||||
virtual void OnPaint(wxPaintEvent& event);
|
||||
virtual wxSize GetBestSize();
|
||||
private:
|
||||
wxBitmap** m_pParentsBgBmp;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -265,19 +267,21 @@ public:
|
|||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxCheckBoxNameStr
|
||||
const wxString& name = wxCheckBoxNameStr,
|
||||
wxBitmap** parentsBgBmp = NULL
|
||||
);
|
||||
|
||||
bool Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxCheckBoxNameStr
|
||||
const wxString& name = wxCheckBoxNameStr,
|
||||
wxBitmap** parentsBgBmp = NULL
|
||||
);
|
||||
|
||||
virtual bool HasTransparentBackground() { return true; };
|
||||
|
||||
virtual void OnEraseBackground(wxEraseEvent& /*event*/) {};
|
||||
virtual void OnEraseBackground(wxEraseEvent& event);
|
||||
private:
|
||||
wxBitmap** m_pParentsBgBmp;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
|
|
@ -80,12 +80,23 @@ CPanelPreferences::CPanelPreferences( wxWindow* parent ) :
|
|||
}
|
||||
|
||||
|
||||
CPanelPreferences::~CPanelPreferences( )
|
||||
{
|
||||
if (m_backgroundBitmap) {
|
||||
delete m_backgroundBitmap;
|
||||
m_backgroundBitmap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* CPanelPreferences creator
|
||||
*/
|
||||
|
||||
bool CPanelPreferences::Create()
|
||||
{
|
||||
m_backgroundBitmap = NULL;
|
||||
|
||||
CreateControls();
|
||||
|
||||
defaultPrefs.enabled_defaults();
|
||||
|
@ -163,7 +174,8 @@ void CPanelPreferences::CreateControls()
|
|||
legendSizer->Add(
|
||||
new CTransparentHyperlinkCtrl(
|
||||
topSectionStaticBox, wxID_ANY, *web_prefs_url, *web_prefs_url,
|
||||
wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE
|
||||
wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE,
|
||||
wxHyperlinkCtrlNameStr, &m_backgroundBitmap
|
||||
),
|
||||
0, wxLEFT, 5
|
||||
);
|
||||
|
@ -180,7 +192,11 @@ void CPanelPreferences::CreateControls()
|
|||
#if 1
|
||||
topSectionSizer->AddSpacer( 10 );
|
||||
|
||||
CTransparentStaticLine* itemStaticLine8 = new CTransparentStaticLine( topSectionStaticBox, wxID_ANY, wxDefaultPosition, wxSize(300, 1), wxLI_HORIZONTAL|wxNO_BORDER );
|
||||
CTransparentStaticLine* itemStaticLine8 = new CTransparentStaticLine( topSectionStaticBox, wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxSize(ADJUSTFORXDPI(300), 1),
|
||||
wxLI_HORIZONTAL|wxNO_BORDER
|
||||
);
|
||||
itemStaticLine8->SetLineColor(pSkinSimple->GetStaticLineColor());
|
||||
topSectionSizer->Add(itemStaticLine8, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT, ADJUSTFORXDPI(20));
|
||||
|
||||
|
@ -222,7 +238,10 @@ void CPanelPreferences::CreateControls()
|
|||
|
||||
m_chkProcOnBatteries = new CTransparentCheckBox(
|
||||
itemDialog1, ID_CHKPROCONBATTERIES,
|
||||
_("Suspend when computer is on battery"), wxDefaultPosition, wxDefaultSize, 0
|
||||
_("Suspend when computer is on battery"),
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
wxDefaultValidator, wxCheckBoxNameStr,
|
||||
&m_backgroundBitmap
|
||||
);
|
||||
|
||||
m_chkProcOnBatteries->SetToolTip(ProcOnBatteriesTT);
|
||||
|
@ -233,7 +252,10 @@ void CPanelPreferences::CreateControls()
|
|||
|
||||
m_chkProcInUse = new CTransparentCheckBox(
|
||||
itemDialog1, ID_CHKPROCINUSE,
|
||||
_("Suspend when computer is in use"), wxDefaultPosition, wxDefaultSize, 0
|
||||
_("Suspend when computer is in use"),
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
wxDefaultValidator, wxCheckBoxNameStr,
|
||||
&m_backgroundBitmap
|
||||
);
|
||||
|
||||
m_chkProcInUse->SetToolTip(ProcInUseTT);
|
||||
|
@ -263,7 +285,11 @@ void CPanelPreferences::CreateControls()
|
|||
wxString ProcEveryDayTT(_("Compute only during a particular period each day."));
|
||||
m_chkProcEveryDay = new CTransparentCheckBox(
|
||||
itemDialog1, ID_CHKPROCEVERYDAY,
|
||||
_("Compute only between"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
_("Compute only between"),
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
wxDefaultValidator, wxCheckBoxNameStr,
|
||||
&m_backgroundBitmap
|
||||
);
|
||||
|
||||
m_txtProcEveryDayStart = new wxTextCtrl( itemDialog1, ID_TXTPROCEVERYDAYSTART, wxEmptyString, wxDefaultPosition, timeCtrlSize, wxTE_RIGHT );
|
||||
|
||||
|
@ -288,7 +314,11 @@ void CPanelPreferences::CreateControls()
|
|||
|
||||
wxString NetEveryDayTT(_("Transfer files only during a particular period each day."));
|
||||
m_chkNetEveryDay = new CTransparentCheckBox(
|
||||
itemDialog1, ID_CHKNETEVERYDAY, _("Transfer files only between"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
itemDialog1, ID_CHKNETEVERYDAY, _("Transfer files only between"),
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
wxDefaultValidator, wxCheckBoxNameStr,
|
||||
&m_backgroundBitmap
|
||||
);
|
||||
|
||||
m_txtNetEveryDayStart = new wxTextCtrl( itemDialog1, ID_TXTNETEVERYDAYSTART, wxEmptyString, wxDefaultPosition, timeCtrlSize, 0 );
|
||||
|
||||
|
@ -303,7 +333,11 @@ void CPanelPreferences::CreateControls()
|
|||
DiskMaxSpaceTT.Printf(_("Limit the total amount of disk space used by %s."), pSkinAdvanced->GetApplicationShortName().c_str());
|
||||
|
||||
m_chkDiskMaxSpace = new CTransparentCheckBox (
|
||||
itemDialog1, ID_CHKDISKMAXSPACE, _("Use no more than"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
itemDialog1, ID_CHKDISKMAXSPACE, _("Use no more than"),
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
wxDefaultValidator, wxCheckBoxNameStr,
|
||||
&m_backgroundBitmap
|
||||
);
|
||||
|
||||
m_txtDiskMaxSpace = new wxTextCtrl( itemDialog1, ID_TXTDISKMAXSPACE,wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("9999.99")), wxTE_RIGHT );
|
||||
|
||||
|
@ -380,11 +414,7 @@ void CPanelPreferences::OnButtonHelp( wxCommandEvent& event ) {
|
|||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_ERASE_BACKGROUND event handler for ID_DLGPREFERENCES
|
||||
*/
|
||||
|
||||
void CPanelPreferences::OnEraseBackground( wxEraseEvent& event ) {
|
||||
void CPanelPreferences::MakeBackgroundBitmap() {
|
||||
CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
|
||||
|
||||
wxASSERT(pSkinSimple);
|
||||
|
@ -399,24 +429,13 @@ void CPanelPreferences::OnEraseBackground( wxEraseEvent& event ) {
|
|||
// Dialog dimensions
|
||||
wxSize sz = GetClientSize();
|
||||
|
||||
// Create a buffered device context to reduce flicker
|
||||
wxBufferedDC dc(event.GetDC(), sz, wxBUFFER_CLIENT_AREA);
|
||||
m_backgroundBitmap = new wxBitmap(sz);
|
||||
wxMemoryDC dc(*m_backgroundBitmap);
|
||||
|
||||
// bitmap dimensions
|
||||
w = bmp.GetWidth();
|
||||
h = bmp.GetHeight();
|
||||
|
||||
#if TEST_BACKGROUND_WITH_MAGENTA_FILL
|
||||
// Fill the dialog with a magenta color so people can detect when something
|
||||
// is wrong
|
||||
dc.SetBrush(wxBrush(wxColour(255,0,255)));
|
||||
dc.SetPen(wxPen(wxColour(255,0,255)));
|
||||
dc.DrawRectangle(0, 0, sz.GetWidth(), sz.GetHeight());
|
||||
#else
|
||||
wxColour bgColor(*pSkinSimple->GetDialogBackgroundImage()->GetBackgroundColor());
|
||||
SetBackgroundColour(bgColor);
|
||||
#endif
|
||||
|
||||
// Is the bitmap smaller than the window?
|
||||
if ( (w < sz.x) || (h < sz.y) ) {
|
||||
// Check to see if they need to be rescaled to fit in the window
|
||||
|
@ -444,6 +463,40 @@ void CPanelPreferences::OnEraseBackground( wxEraseEvent& event ) {
|
|||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_ERASE_BACKGROUND event handler for ID_DLGPREFERENCES
|
||||
*/
|
||||
|
||||
void CPanelPreferences::OnEraseBackground( wxEraseEvent& event ) {
|
||||
if (!m_backgroundBitmap) {
|
||||
MakeBackgroundBitmap();
|
||||
}
|
||||
// Create a buffered device context to reduce flicker
|
||||
wxSize sz = GetClientSize();
|
||||
wxBufferedDC dc(event.GetDC(), sz, wxBUFFER_CLIENT_AREA);
|
||||
|
||||
#if TEST_BACKGROUND_WITH_MAGENTA_FILL
|
||||
// Fill the dialog with a magenta color so people can detect when something
|
||||
// is wrong
|
||||
dc.SetBrush(wxBrush(wxColour(255,0,255)));
|
||||
dc.SetPen(wxPen(wxColour(255,0,255)));
|
||||
dc.DrawRectangle(0, 0, sz.GetWidth(), sz.GetHeight());
|
||||
#else
|
||||
CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
|
||||
|
||||
wxASSERT(pSkinSimple);
|
||||
wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
|
||||
|
||||
wxColour bgColor(*pSkinSimple->GetDialogBackgroundImage()->GetBackgroundColor());
|
||||
SetBackgroundColour(bgColor);
|
||||
#endif
|
||||
|
||||
if (m_backgroundBitmap->IsOk()) {
|
||||
dc.DrawBitmap(*m_backgroundBitmap, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CPanelPreferences::OnButtonClear() {
|
||||
CMainDocument* pDoc = wxGetApp().GetDocument();
|
||||
|
||||
|
|
|
@ -97,12 +97,16 @@ public:
|
|||
CPanelPreferences( );
|
||||
CPanelPreferences( wxWindow* parent );
|
||||
|
||||
~CPanelPreferences( );
|
||||
|
||||
/// Creation
|
||||
bool Create();
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
void MakeBackgroundBitmap();
|
||||
|
||||
////@begin CPanelPreferences event handler declarations
|
||||
/// wxEVT_ERASE_BACKGROUND event handler for ID_DLGPREFERENCES
|
||||
void OnEraseBackground( wxEraseEvent& event );
|
||||
|
@ -144,6 +148,7 @@ public:
|
|||
wxWindow* fourth=NULL, wxWindow* fifth=NULL);
|
||||
wxSize getTextCtrlSize(wxString maxText);
|
||||
bool doesLocalPrefsFileExist();
|
||||
wxBitmap* GetBackgroundBmp() { return m_backgroundBitmap; }
|
||||
|
||||
private:
|
||||
////@begin CPanelPreferences member variables
|
||||
|
@ -163,7 +168,9 @@ private:
|
|||
wxTextValidator* m_vTimeValidator;
|
||||
wxButton* m_btnClear;
|
||||
wxString *web_prefs_url;
|
||||
|
||||
|
||||
wxBitmap* m_backgroundBitmap;
|
||||
|
||||
////@end CPanelPreferences member variables
|
||||
GLOBAL_PREFS global_preferences_working;
|
||||
GLOBAL_PREFS_MASK global_preferences_mask;
|
||||
|
|
Loading…
Reference in New Issue