mirror of https://github.com/BOINC/boinc.git
MGR: Fix sizes of task panes and buttons, elapsing button text if needed
svn path=/trunk/boinc/; revision=25147
This commit is contained in:
parent
94b6094a35
commit
36ebfcd176
|
@ -1003,3 +1003,13 @@ Charlie 25 Jan 2012
|
|||
|
||||
samples/vboxwrapper/
|
||||
vboxwrapper.cpp
|
||||
|
||||
Charlie 25 Jan 2012
|
||||
- MGR: Make the task pane in the advanced view and its buttons fixed sizes;
|
||||
ellipse the button contents if needed; show full button text plus
|
||||
description in button tooltips; don't set button labels if unchanged.
|
||||
|
||||
clientgui/
|
||||
BOINCBaseView.cpp, .h
|
||||
BOINCTaskCtrl.cpp, .h
|
||||
stdwx.h
|
||||
|
|
|
@ -733,22 +733,6 @@ void CBOINCBaseView::UpdateSelection(){
|
|||
void CBOINCBaseView::PostUpdateSelection(){
|
||||
wxASSERT(m_pTaskPane);
|
||||
m_pTaskPane->UpdateControls();
|
||||
|
||||
// Adjust the width of the task pane so that it can be fully displayed.
|
||||
//
|
||||
wxSize sz = m_pTaskPane->GetVirtualSize();
|
||||
if (sz.GetHeight() > m_pTaskPane->GetSize().GetHeight()) {
|
||||
// Account for vertical scrollbar
|
||||
if (m_pTaskPane->GetSize().GetWidth() != (sz.GetWidth() + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, NULL))) {
|
||||
m_pTaskPane->SetSize(
|
||||
sz.GetWidth() + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, NULL),
|
||||
m_pTaskPane->GetSize().GetHeight()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
m_pTaskPane->SetSize(sz.GetWidth(), m_pTaskPane->GetSize().GetHeight());
|
||||
}
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
~CTaskItem() {};
|
||||
|
||||
wxString m_strName;
|
||||
wxString m_strNameEllipsed;
|
||||
wxString m_strDescription;
|
||||
wxInt32 m_iEventID;
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "BOINCBaseView.h"
|
||||
#include "BOINCTaskCtrl.h"
|
||||
|
||||
#define TASKPANEWIDTH 200
|
||||
#define TASKBUTTONWIDTH (TASKPANEWIDTH - 55)
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(CBOINCTaskCtrl, wxScrolledWindow)
|
||||
|
||||
|
@ -131,13 +133,18 @@ wxInt32 CBOINCTaskCtrl::EnableTask( CTaskItem* pItem ) {
|
|||
|
||||
wxInt32 CBOINCTaskCtrl::UpdateTask( CTaskItem* pItem, wxString strName, wxString strDescription ) {
|
||||
if (pItem->m_pButton) {
|
||||
if (!pItem->m_strName.Cmp(strName) &&
|
||||
!pItem->m_strDescription.Cmp(strDescription)) {
|
||||
return 0;
|
||||
}
|
||||
pItem->m_strName = strName;
|
||||
pItem->m_strNameEllipsed = pItem->m_strName;
|
||||
EllipseStringIfNeeded(pItem->m_strNameEllipsed, pItem->m_pButton);
|
||||
pItem->m_strDescription = strDescription;
|
||||
|
||||
pItem->m_pButton->SetLabel( strName );
|
||||
pItem->m_pButton->SetLabel( pItem->m_strNameEllipsed );
|
||||
pItem->m_pButton->SetHelpText( strDescription );
|
||||
#if wxUSE_TOOLTIPS
|
||||
pItem->m_pButton->SetToolTip( strDescription );
|
||||
pItem->m_pButton->SetToolTip(pItem->m_strName + wxT(": ") + pItem->m_strDescription);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
|
@ -180,10 +187,13 @@ wxInt32 CBOINCTaskCtrl::UpdateControls() {
|
|||
pItem = pGroup->m_Tasks[j];
|
||||
if (!pItem->m_pButton) {
|
||||
pItem->m_pButton = new wxButton;
|
||||
pItem->m_pButton->Create(this, pItem->m_iEventID, pItem->m_strName, wxDefaultPosition, wxDefaultSize, 0);
|
||||
pItem->m_strNameEllipsed = pItem->m_strName;
|
||||
pItem->m_pButton->Create(this, pItem->m_iEventID, wxEmptyString, wxDefaultPosition, wxSize(TASKBUTTONWIDTH, -1), 0);
|
||||
EllipseStringIfNeeded(pItem->m_strNameEllipsed, pItem->m_pButton);
|
||||
pItem->m_pButton->SetLabel(pItem->m_strNameEllipsed);
|
||||
pItem->m_pButton->SetHelpText(pItem->m_strDescription);
|
||||
#if wxUSE_TOOLTIPS
|
||||
pItem->m_pButton->SetToolTip(pItem->m_strDescription);
|
||||
pItem->m_pButton->SetToolTip(pItem->m_strName + wxT(": ") + pItem->m_strDescription);
|
||||
#endif
|
||||
pGroup->m_pStaticBoxSizer->Add(pItem->m_pButton, 0, wxEXPAND|wxALL, 5);
|
||||
}
|
||||
|
@ -241,3 +251,27 @@ bool CBOINCTaskCtrl::OnRestoreState(wxConfigBase* pConfig) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CBOINCTaskCtrl::EllipseStringIfNeeded(wxString& s, wxWindow *win) {
|
||||
int w, h;
|
||||
wxSize sz = win->GetSize();
|
||||
int maxWidth = sz.GetWidth() - 10;
|
||||
|
||||
win->GetTextExtent(s, &w, &h);
|
||||
|
||||
// Adapted from ellipis code in wxRendererGeneric::DrawHeaderButtonContents()
|
||||
if (w > maxWidth) {
|
||||
int ellipsisWidth;
|
||||
win->GetTextExtent( wxT("..."), &ellipsisWidth, NULL);
|
||||
if (ellipsisWidth > maxWidth) {
|
||||
s.Clear();
|
||||
w = 0;
|
||||
} else {
|
||||
do {
|
||||
s.Truncate( s.length() - 1 );
|
||||
win->GetTextExtent( s, &w, &h);
|
||||
} while (((w + ellipsisWidth) > maxWidth) && s.length() );
|
||||
s.append( wxT("...") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ public:
|
|||
virtual bool OnSaveState( wxConfigBase* pConfig );
|
||||
virtual bool OnRestoreState( wxConfigBase* pConfig );
|
||||
|
||||
void EllipseStringIfNeeded( wxString& s, wxWindow *win );
|
||||
|
||||
private:
|
||||
|
||||
CBOINCBaseView* m_pParent;
|
||||
|
|
|
@ -115,7 +115,6 @@
|
|||
#include <wx/mstream.h>
|
||||
#include <wx/hash.h>
|
||||
#include <wx/selstore.h>
|
||||
#include <wx/splitter.h> // splitter control support
|
||||
|
||||
#ifdef _WIN32
|
||||
// Visual Studio 2005 has extended the C Run-Time Library by including "secure"
|
||||
|
|
Loading…
Reference in New Issue