added status bar fields styles support (patch 988292)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28480 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -47,6 +47,7 @@ wxObject *wxStatusBarXmlHandler::DoCreateResource()
|
||||
|
||||
int fields = GetLong(wxT("fields"), 1);
|
||||
wxString widths = GetParamValue(wxT("widths"));
|
||||
wxString styles = GetParamValue(wxT("styles"));
|
||||
|
||||
if (fields > 1 && !widths.IsEmpty())
|
||||
{
|
||||
@@ -64,6 +65,30 @@ wxObject *wxStatusBarXmlHandler::DoCreateResource()
|
||||
else
|
||||
statbar->SetFieldsCount(fields);
|
||||
|
||||
if (!styles.IsEmpty())
|
||||
{
|
||||
int *style = new int[fields];
|
||||
for (int i = 0; i < fields; ++i)
|
||||
{
|
||||
style[i] = wxSB_NORMAL;
|
||||
|
||||
wxString first = styles.BeforeFirst(wxT(','));
|
||||
if (first == wxT("wxSB_NORMAL"))
|
||||
style[i] = wxSB_NORMAL;
|
||||
else if (first == wxT("wxSB_FLAT"))
|
||||
style[i] = wxSB_FLAT;
|
||||
else if (first == wxT("wxSB_RAISED"))
|
||||
style[i] = wxSB_RAISED;
|
||||
|
||||
if (!first.IsEmpty())
|
||||
wxLogError(wxT("Error in resource, unknown statusbar field style: ") + first);
|
||||
if(styles.Find(wxT(',')))
|
||||
styles.Remove(0, styles.Find(wxT(',')) + 1);
|
||||
}
|
||||
statbar->SetStatusStyles(fields, style);
|
||||
delete [] style;
|
||||
}
|
||||
|
||||
if (m_parentAsWindow)
|
||||
{
|
||||
wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
|
||||
|
@@ -218,6 +218,7 @@ All (GUI):
|
||||
- added wxKeyEvent::GetUnicodeKey()
|
||||
- added wxKeyEvent::CmdDown() and wxMouseEvent::CmdDown()
|
||||
- implemented wxListCtrl::FindItem() for non-MSW (Robin Stoll)
|
||||
- added status bar fields styles support (Tim Kosse)
|
||||
|
||||
Unix:
|
||||
|
||||
|
@@ -232,3 +232,28 @@ integers.}
|
||||
|
||||
\perlnote{In wxPerl this method takes as parameters the field widths.}
|
||||
|
||||
\membersection{wxStatusBar::SetStatusStyles}\label{wxstatusbarsetstatusstyles}
|
||||
|
||||
\func{virtual void}{SetStatusStyles}{\param{int}{ n}, \param{int *}{styles}}
|
||||
|
||||
Sets the styles of the fields in the status line which can make fields appear flat
|
||||
or raised instead of the standard sunken 3D border.
|
||||
|
||||
\wxheading{Parameters}
|
||||
|
||||
\docparam{n}{The number of fields in the status bar. Must be equal to the
|
||||
number passed to \helpref{SetFieldsCount}{wxstatusbarsetfieldscount} the last
|
||||
time it was called.}
|
||||
|
||||
\docparam{styles}{Contains an array of {\it n} integers with the styles for each field. There
|
||||
are three possible styles:
|
||||
|
||||
\twocolwidtha{5cm}
|
||||
\begin{twocollist}\itemsep=0pt
|
||||
\twocolitem{\windowstyle{wxSB\_NORMAL}}{(default) The field appears sunken with a standard 3D border.}
|
||||
\twocolitem{\windowstyle{wxSB\_FLAT}}{No border is painted around the field so that it appears flat.}
|
||||
\twocolitem{\windowstyle{wxSB\_RAISED}}{A raised 3D border is painted around the field.}
|
||||
\end{twocollist}
|
||||
|
||||
|
||||
|
||||
|
@@ -48,6 +48,9 @@ public:
|
||||
// set status line fields' widths
|
||||
virtual void SetStatusWidths(int n, const int widths_field[]);
|
||||
|
||||
// set status line fields' styles
|
||||
virtual void SetStatusStyles(int n, const int styles[]);
|
||||
|
||||
// sets the minimal vertical size of the status bar
|
||||
virtual void SetMinHeight(int height);
|
||||
|
||||
|
@@ -25,6 +25,15 @@
|
||||
|
||||
WX_DECLARE_LIST(wxString, wxListString);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStatusBar constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// style flags for fields
|
||||
#define wxSB_NORMAL 0x0000
|
||||
#define wxSB_FLAT 0x0001
|
||||
#define wxSB_RAISED 0x0002
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStatusBar: a window near the bottom of the frame used for status info
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -64,6 +73,15 @@ public:
|
||||
// -2 grows twice as much as one with width -1 &c)
|
||||
virtual void SetStatusWidths(int n, const int widths[]);
|
||||
|
||||
// field styles
|
||||
// ------------
|
||||
|
||||
// Set the field style. Use either wxSB_NORMAL (default) for a standard 3D
|
||||
// border around a field, wxSB_FLAT for no border around a field, so that it
|
||||
// appears flat or wxSB_POPOUT to make the field appear raised.
|
||||
// Setting field styles only works on wxMSW
|
||||
virtual void SetStatusStyles(int n, const int styles[]);
|
||||
|
||||
// geometry
|
||||
// --------
|
||||
|
||||
@@ -90,6 +108,11 @@ protected:
|
||||
// reset the widths
|
||||
void ReinitWidths() { FreeWidths(); InitWidths(); }
|
||||
|
||||
// same, for field styles
|
||||
void InitStyles();
|
||||
void FreeStyles();
|
||||
void ReinitStyles() { FreeStyles(); InitStyles(); }
|
||||
|
||||
// same, for text stacks
|
||||
void InitStacks();
|
||||
void FreeStacks();
|
||||
@@ -109,6 +132,9 @@ protected:
|
||||
// width otherwise
|
||||
int *m_statusWidths;
|
||||
|
||||
// the styles of the fields
|
||||
int *m_statusStyles;
|
||||
|
||||
// stacks of previous values for PushStatusText/PopStatusText
|
||||
// this is created on demand, use GetStatusStack/GetOrCreateStatusStack
|
||||
wxListString **m_statusTextStacks;
|
||||
|
@@ -288,7 +288,7 @@ public:
|
||||
virtual void DrawStatusField(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
const wxString& label,
|
||||
int flags = 0) = 0;
|
||||
int flags = 0, int style = 0) = 0;
|
||||
|
||||
// draw complete frame/dialog titlebar
|
||||
virtual void DrawFrameTitleBar(wxDC& dc,
|
||||
@@ -701,8 +701,8 @@ public:
|
||||
virtual void DrawStatusField(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
const wxString& label,
|
||||
int flags = 0)
|
||||
{ m_renderer->DrawStatusField(dc, rect, label, flags); }
|
||||
int flags = 0, inst style = 0)
|
||||
{ m_renderer->DrawStatusField(dc, rect, label, flags, style); }
|
||||
|
||||
virtual void DrawFrameTitleBar(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
|
@@ -146,6 +146,9 @@ class MyFrame : public wxMDIParentFrame
|
||||
|
||||
void OnSetStatusFields(wxCommandEvent& event);
|
||||
void OnRecreateStatusBar(wxCommandEvent& event);
|
||||
void OnSetStyleNormal(wxCommandEvent& event);
|
||||
void OnSetStyleFlat(wxCommandEvent& event);
|
||||
void OnSetStyleRaised(wxCommandEvent& event);
|
||||
|
||||
private:
|
||||
enum StatBarKind
|
||||
@@ -156,12 +159,18 @@ private:
|
||||
} m_statbarKind;
|
||||
void OnUpdateSetStatusFields(wxUpdateUIEvent& event);
|
||||
void OnUpdateStatusBarToggle(wxUpdateUIEvent& event);
|
||||
void OnUpdateSetStyleNormal(wxUpdateUIEvent& event);
|
||||
void OnUpdateSetStyleFlat(wxUpdateUIEvent& event);
|
||||
void OnUpdateSetStyleRaised(wxUpdateUIEvent& event);
|
||||
void OnStatusBarToggle(wxCommandEvent& event);
|
||||
void DoCreateStatusBar(StatBarKind kind);
|
||||
void ApplyStyle();
|
||||
|
||||
wxStatusBar *m_statbarDefault;
|
||||
MyStatusBar *m_statbarCustom;
|
||||
|
||||
int m_statbarStyle;
|
||||
|
||||
// any class wishing to process wxWidgets events must use this macro
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
@@ -186,7 +195,11 @@ enum
|
||||
StatusBar_Recreate,
|
||||
StatusBar_About,
|
||||
StatusBar_Toggle,
|
||||
StatusBar_Checkbox = 1000
|
||||
StatusBar_Checkbox = 1000,
|
||||
StatusBar_SetStyle,
|
||||
StatusBar_SetStyleNormal,
|
||||
StatusBar_SetStyleFlat,
|
||||
StatusBar_SetStyleRaised
|
||||
};
|
||||
|
||||
static const int BITMAP_SIZE_X = 32;
|
||||
@@ -209,8 +222,14 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(StatusBar_Recreate, MyFrame::OnRecreateStatusBar)
|
||||
EVT_MENU(StatusBar_About, MyFrame::OnAbout)
|
||||
EVT_MENU(StatusBar_Toggle, MyFrame::OnStatusBarToggle)
|
||||
EVT_MENU(StatusBar_SetStyleNormal, MyFrame::OnSetStyleNormal)
|
||||
EVT_MENU(StatusBar_SetStyleFlat, MyFrame::OnSetStyleFlat)
|
||||
EVT_MENU(StatusBar_SetStyleRaised, MyFrame::OnSetStyleRaised)
|
||||
EVT_UPDATE_UI(StatusBar_Toggle, MyFrame::OnUpdateStatusBarToggle)
|
||||
EVT_UPDATE_UI(StatusBar_SetFields, MyFrame::OnUpdateSetStatusFields)
|
||||
EVT_UPDATE_UI(StatusBar_SetStyleNormal, MyFrame::OnUpdateSetStyleNormal)
|
||||
EVT_UPDATE_UI(StatusBar_SetStyleFlat, MyFrame::OnUpdateSetStyleFlat)
|
||||
EVT_UPDATE_UI(StatusBar_SetStyleRaised, MyFrame::OnUpdateSetStyleRaised)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
BEGIN_EVENT_TABLE(MyStatusBar, wxStatusBar)
|
||||
@@ -267,6 +286,8 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
m_statbarDefault = NULL;
|
||||
m_statbarCustom = NULL;
|
||||
|
||||
m_statbarStyle = wxSB_NORMAL;
|
||||
|
||||
#ifdef __WXMAC__
|
||||
// we need this in order to allow the about menu relocation, since ABOUT is
|
||||
// not the default id of the about menu
|
||||
@@ -285,6 +306,12 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
statbarMenu->Append(StatusBar_Recreate, _T("&Recreate\tCtrl-R"),
|
||||
_T("Toggle status bar format"));
|
||||
|
||||
wxMenu *statbarStyleMenu = new wxMenu;
|
||||
statbarStyleMenu->Append(StatusBar_SetStyleNormal, _T("&Normal"), _T("Sets the style of the first field to normal (sunken) look"), true);
|
||||
statbarStyleMenu->Append(StatusBar_SetStyleFlat, _T("&Flat"), _T("Sets the style of the first field to flat look"), true);
|
||||
statbarStyleMenu->Append(StatusBar_SetStyleRaised, _T("&Raised"), _T("Sets the style of the first field to raised look"), true);
|
||||
statbarMenu->Append(StatusBar_SetStyle, _T("Field style"), statbarStyleMenu);
|
||||
|
||||
wxMenu *helpMenu = new wxMenu;
|
||||
helpMenu->Append(StatusBar_About, _T("&About...\tCtrl-A"), _T("Show about dialog"));
|
||||
|
||||
@@ -339,6 +366,7 @@ void MyFrame::DoCreateStatusBar(MyFrame::StatBarKind kind)
|
||||
wxFAIL_MSG(wxT("unknown stat bar kind"));
|
||||
}
|
||||
|
||||
ApplyStyle();
|
||||
GetStatusBar()->Show();
|
||||
PositionStatusBar();
|
||||
|
||||
@@ -347,13 +375,12 @@ void MyFrame::DoCreateStatusBar(MyFrame::StatBarKind kind)
|
||||
|
||||
void MyFrame::OnUpdateSetStatusFields(wxUpdateUIEvent& event)
|
||||
{
|
||||
// only allow the setting of the number of status fields for the default
|
||||
// only allow the settings of the number of status fields for the default
|
||||
// status bar
|
||||
wxStatusBar *sb = GetStatusBar();
|
||||
event.Enable(sb == m_statbarDefault);
|
||||
}
|
||||
|
||||
|
||||
// event handlers
|
||||
void MyFrame::OnSetStatusFields(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
@@ -455,6 +482,55 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
dlg.ShowModal();
|
||||
}
|
||||
|
||||
void MyFrame::OnUpdateSetStyleNormal(wxUpdateUIEvent &event)
|
||||
{
|
||||
event.Check(m_statbarStyle == wxSB_NORMAL);
|
||||
}
|
||||
|
||||
void MyFrame::OnUpdateSetStyleFlat(wxUpdateUIEvent &event)
|
||||
{
|
||||
event.Check(m_statbarStyle == wxSB_FLAT);
|
||||
}
|
||||
|
||||
void MyFrame::OnUpdateSetStyleRaised(wxUpdateUIEvent &event)
|
||||
{
|
||||
event.Check(m_statbarStyle == wxSB_RAISED);
|
||||
}
|
||||
|
||||
void MyFrame::OnSetStyleNormal(wxCommandEvent &event)
|
||||
{
|
||||
m_statbarStyle = wxSB_NORMAL;
|
||||
ApplyStyle();
|
||||
}
|
||||
|
||||
void MyFrame::OnSetStyleFlat(wxCommandEvent &event)
|
||||
{
|
||||
m_statbarStyle = wxSB_FLAT;
|
||||
ApplyStyle();
|
||||
}
|
||||
|
||||
void MyFrame::OnSetStyleRaised(wxCommandEvent &event)
|
||||
{
|
||||
m_statbarStyle = wxSB_RAISED;
|
||||
ApplyStyle();
|
||||
}
|
||||
|
||||
void MyFrame::ApplyStyle()
|
||||
{
|
||||
wxStatusBar *sb = GetStatusBar();
|
||||
int fields = sb->GetFieldsCount();
|
||||
int *styles = new int[fields];
|
||||
|
||||
for (int i = 1; i < fields; i++)
|
||||
styles[i] = wxSB_NORMAL;
|
||||
|
||||
styles[0] = m_statbarStyle;
|
||||
|
||||
sb->SetStatusStyles(fields, styles);
|
||||
|
||||
delete [] styles;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MyAboutDialog
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -53,12 +53,14 @@ wxStatusBarBase::wxStatusBarBase()
|
||||
|
||||
InitWidths();
|
||||
InitStacks();
|
||||
InitStyles();
|
||||
}
|
||||
|
||||
wxStatusBarBase::~wxStatusBarBase()
|
||||
{
|
||||
FreeWidths();
|
||||
FreeStacks();
|
||||
InitStyles();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -75,6 +77,20 @@ void wxStatusBarBase::FreeWidths()
|
||||
delete [] m_statusWidths;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// styles array handling
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxStatusBarBase::InitStyles()
|
||||
{
|
||||
m_statusStyles = NULL;
|
||||
}
|
||||
|
||||
void wxStatusBarBase::FreeStyles()
|
||||
{
|
||||
delete [] m_statusStyles;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// field widths
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -112,6 +128,26 @@ void wxStatusBarBase::SetFieldsCount(int number, const int *widths)
|
||||
m_statusTextStacks = newStacks;
|
||||
}
|
||||
|
||||
// Resize styles array
|
||||
if (m_statusStyles)
|
||||
{
|
||||
int *oldStyles = m_statusStyles;
|
||||
m_statusStyles = new int[number];
|
||||
int i, max = wxMin(number, m_nFields);
|
||||
|
||||
// copy old styles
|
||||
for (i = 0; i < max; ++i)
|
||||
m_statusStyles[i] = oldStyles[i];
|
||||
|
||||
// initialize new styles to wxSB_NORMAL
|
||||
for (i = max; i < number; ++i)
|
||||
m_statusStyles[i] = wxSB_NORMAL;
|
||||
|
||||
// free old styles
|
||||
delete [] oldStyles;
|
||||
}
|
||||
|
||||
|
||||
m_nFields = number;
|
||||
|
||||
ReinitWidths();
|
||||
@@ -151,6 +187,25 @@ void wxStatusBarBase::SetStatusWidths(int WXUNUSED_UNLESS_DEBUG(n),
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void wxStatusBarBase::SetStatusStyles(int WXUNUSED_UNLESS_DEBUG(n),
|
||||
const int styles[])
|
||||
{
|
||||
wxCHECK_RET( styles, _T("NULL pointer in SetStatusStyles") );
|
||||
|
||||
wxASSERT_MSG( n == m_nFields, _T("field number mismatch") );
|
||||
|
||||
if ( !m_statusStyles )
|
||||
m_statusStyles = new int[m_nFields];
|
||||
|
||||
for ( int i = 0; i < m_nFields; i++ )
|
||||
{
|
||||
m_statusStyles[i] = styles[i];
|
||||
}
|
||||
|
||||
// update the display after the widths changed
|
||||
Refresh();
|
||||
}
|
||||
|
||||
wxArrayInt wxStatusBarBase::CalculateAbsWidths(wxCoord widthTotal) const
|
||||
{
|
||||
wxArrayInt widths;
|
||||
|
@@ -140,12 +140,10 @@ void wxStatusBarGeneric::SetFieldsCount(int number, const int *widths)
|
||||
for (i = m_nFields - 1; i >= number; --i)
|
||||
m_statusStrings.RemoveAt(i);
|
||||
|
||||
m_nFields = number;
|
||||
wxStatusBarBase::SetFieldsCount(number, widths);
|
||||
|
||||
wxASSERT_MSG( m_nFields == (int)m_statusStrings.GetCount(),
|
||||
_T("This really should never happen, can we do away with m_nFields here?") );
|
||||
|
||||
SetStatusWidths(number, widths);
|
||||
}
|
||||
|
||||
void wxStatusBarGeneric::SetStatusText(const wxString& text, int number)
|
||||
@@ -269,43 +267,52 @@ void wxStatusBarGeneric::DrawField(wxDC& dc, int i)
|
||||
wxRect rect;
|
||||
GetFieldRect(i, rect);
|
||||
|
||||
// Draw border
|
||||
// Have grey background, plus 3-d border -
|
||||
// One black rectangle.
|
||||
// Inside this, left and top sides - dark grey. Bottom and right -
|
||||
// white.
|
||||
int style = wxSB_NORMAL;
|
||||
if (m_statusStyles)
|
||||
style = m_statusStyles[i];
|
||||
|
||||
dc.SetPen(m_hilightPen);
|
||||
if (style != wxSB_FLAT)
|
||||
{
|
||||
// Draw border
|
||||
// For wxSB_NORMAL:
|
||||
// Have grey background, plus 3-d border -
|
||||
// One black rectangle.
|
||||
// Inside this, left and top sides - dark grey. Bottom and right -
|
||||
// white.
|
||||
// Reverse it for wxSB_RAISED
|
||||
|
||||
#ifndef __WXPM__
|
||||
dc.SetPen((style == wxSB_RAISED) ? m_mediumShadowPen : m_hilightPen);
|
||||
|
||||
// Right and bottom white lines
|
||||
dc.DrawLine(rect.x + rect.width, rect.y,
|
||||
rect.x + rect.width, rect.y + rect.height);
|
||||
dc.DrawLine(rect.x + rect.width, rect.y + rect.height,
|
||||
rect.x, rect.y + rect.height);
|
||||
#ifndef __WXPM__
|
||||
|
||||
dc.SetPen(m_mediumShadowPen);
|
||||
// Right and bottom lines
|
||||
dc.DrawLine(rect.x + rect.width, rect.y,
|
||||
rect.x + rect.width, rect.y + rect.height);
|
||||
dc.DrawLine(rect.x + rect.width, rect.y + rect.height,
|
||||
rect.x, rect.y + rect.height);
|
||||
|
||||
// Left and top grey lines
|
||||
dc.DrawLine(rect.x, rect.y + rect.height,
|
||||
rect.x, rect.y);
|
||||
dc.DrawLine(rect.x, rect.y,
|
||||
rect.x + rect.width, rect.y);
|
||||
#else
|
||||
dc.SetPen((style == wxSB_RAISED) ? m_hilightPen : m_mediumShadowPen);
|
||||
|
||||
dc.DrawLine(rect.x + rect.width, rect.height + 2,
|
||||
rect.x, rect.height + 2);
|
||||
dc.DrawLine(rect.x + rect.width, rect.y,
|
||||
rect.x + rect.width, rect.y + rect.height);
|
||||
// Left and top lines
|
||||
dc.DrawLine(rect.x, rect.y + rect.height,
|
||||
rect.x, rect.y);
|
||||
dc.DrawLine(rect.x, rect.y,
|
||||
rect.x + rect.width, rect.y);
|
||||
#else
|
||||
|
||||
dc.SetPen(m_mediumShadowPen);
|
||||
dc.DrawLine(rect.x, rect.y,
|
||||
rect.x + rect.width, rect.y);
|
||||
dc.DrawLine(rect.x, rect.y + rect.height,
|
||||
rect.x, rect.y);
|
||||
dc.DrawLine(rect.x + rect.width, rect.height + 2,
|
||||
rect.x, rect.height + 2);
|
||||
dc.DrawLine(rect.x + rect.width, rect.y,
|
||||
rect.x + rect.width, rect.y + rect.height);
|
||||
|
||||
dc.SetPen((style == wxSB_RAISED) ? m_hilightPen : m_mediumShadowPen);
|
||||
dc.DrawLine(rect.x, rect.y,
|
||||
rect.x + rect.width, rect.y);
|
||||
dc.DrawLine(rect.x, rect.y + rect.height,
|
||||
rect.x, rect.y);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
DrawFieldText(dc, i);
|
||||
}
|
||||
|
@@ -177,7 +177,30 @@ void wxStatusBar95::SetStatusText(const wxString& strText, int nField)
|
||||
wxCHECK_RET( (nField >= 0) && (nField < m_nFields),
|
||||
_T("invalid statusbar field index") );
|
||||
|
||||
if ( !StatusBar_SetText(GetHwnd(), nField, strText) )
|
||||
// Get field style, if any
|
||||
int style;
|
||||
if (m_statusStyles)
|
||||
{
|
||||
switch(m_statusStyles[nField])
|
||||
{
|
||||
case wxSB_RAISED:
|
||||
style = SBT_POPOUT;
|
||||
break;
|
||||
case wxSB_FLAT:
|
||||
style = SBT_NOBORDERS;
|
||||
break;
|
||||
case wxSB_NORMAL:
|
||||
default:
|
||||
style = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
style = 0;
|
||||
|
||||
// Pass both field number and style. MSDN library doesn't mention
|
||||
// that nField and style have to be 'ORed'
|
||||
if ( !StatusBar_SetText(GetHwnd(), nField | style, strText) )
|
||||
{
|
||||
wxLogLastError(wxT("StatusBar_SetText"));
|
||||
}
|
||||
@@ -267,5 +290,39 @@ void wxStatusBar95::DoMoveWindow(int x, int y, int width, int height)
|
||||
}
|
||||
}
|
||||
|
||||
void wxStatusBar95::SetStatusStyles(int n, const int styles[])
|
||||
{
|
||||
wxStatusBarBase::SetStatusStyles(n, styles);
|
||||
|
||||
if (n != m_nFields)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
int style;
|
||||
switch(styles[i])
|
||||
{
|
||||
case wxSB_RAISED:
|
||||
style = SBT_POPOUT;
|
||||
break;
|
||||
case wxSB_FLAT:
|
||||
style = SBT_NOBORDERS;
|
||||
break;
|
||||
case wxSB_NORMAL:
|
||||
default:
|
||||
style = 0;
|
||||
break;
|
||||
}
|
||||
// The SB_SETTEXT message is both used to set the field's text as well as
|
||||
// the fields' styles. MSDN library doesn't mention
|
||||
// that nField and style have to be 'ORed'
|
||||
wxString text = GetStatusText(i);
|
||||
if (!StatusBar_SetText(GetHwnd(), style | i, text))
|
||||
{
|
||||
wxLogLastError(wxT("StatusBar_SetText"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __WIN95__ && wxUSE_NATIVE_STATUSBAR
|
||||
|
||||
|
@@ -140,7 +140,12 @@ void wxStatusBarUniv::DoDraw(wxControlRenderer *renderer)
|
||||
flags |= wxCONTROL_ISDEFAULT;
|
||||
}
|
||||
|
||||
m_renderer->DrawStatusField(dc, rect, m_statusText[n], flags);
|
||||
int style;
|
||||
if (m_statusStyles)
|
||||
style = m_statusStyles[n];
|
||||
else
|
||||
style = wxSB_NORMAL;
|
||||
m_renderer->DrawStatusField(dc, rect, m_statusText[n], flags, style);
|
||||
}
|
||||
|
||||
rect.x += rect.width + borderBetweenFields;
|
||||
|
@@ -42,6 +42,7 @@
|
||||
#include "wx/slider.h"
|
||||
#include "wx/textctrl.h"
|
||||
#include "wx/toolbar.h"
|
||||
#include "wx/statusbr.h"
|
||||
|
||||
#include "wx/settings.h"
|
||||
#endif // WX_PRECOMP
|
||||
@@ -228,7 +229,7 @@ public:
|
||||
virtual void DrawStatusField(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
const wxString& label,
|
||||
int flags = 0);
|
||||
int flags = 0, int style = 0);
|
||||
|
||||
virtual void DrawFrameTitleBar(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
@@ -2236,7 +2237,7 @@ wxGTKRenderer::GetStatusBarBorders(wxCoord * WXUNUSED(borderBetweenFields)) cons
|
||||
void wxGTKRenderer::DrawStatusField(wxDC& WXUNUSED(dc),
|
||||
const wxRect& WXUNUSED(rect),
|
||||
const wxString& WXUNUSED(label),
|
||||
int WXUNUSED(flags))
|
||||
int WXUNUSED(flags), int WXUNUSED(style))
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -40,6 +40,7 @@
|
||||
#include "wx/textctrl.h"
|
||||
#include "wx/listbox.h"
|
||||
#include "wx/toolbar.h"
|
||||
#include "wx/statusbr.h"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
// for COLOR_* constants
|
||||
@@ -299,7 +300,7 @@ public:
|
||||
virtual void DrawStatusField(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
const wxString& label,
|
||||
int flags = 0);
|
||||
int flags = 0, int style = 0);
|
||||
|
||||
// titlebars
|
||||
virtual void DrawFrameTitleBar(wxDC& dc,
|
||||
@@ -3224,7 +3225,7 @@ wxSize wxWin32Renderer::GetStatusBarBorders(wxCoord *borderBetweenFields) const
|
||||
void wxWin32Renderer::DrawStatusField(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
const wxString& label,
|
||||
int flags)
|
||||
int flags, int style /*=0*/)
|
||||
{
|
||||
wxRect rectIn;
|
||||
|
||||
@@ -3240,9 +3241,15 @@ void wxWin32Renderer::DrawStatusField(wxDC& dc,
|
||||
y2 = rect.GetBottom();
|
||||
|
||||
// draw the upper left part of the rect normally
|
||||
dc.SetPen(m_penDarkGrey);
|
||||
dc.DrawLine(rect.GetLeft(), rect.GetTop(), rect.GetLeft(), y2);
|
||||
dc.DrawLine(rect.GetLeft() + 1, rect.GetTop(), x2, rect.GetTop());
|
||||
if (style != wxSB_FLAT)
|
||||
{
|
||||
if (style == wxSB_RAISED)
|
||||
dc.SetPen(m_penHighlight);
|
||||
else
|
||||
dc.SetPen(m_penDarkGrey);
|
||||
dc.DrawLine(rect.GetLeft(), rect.GetTop(), rect.GetLeft(), y2);
|
||||
dc.DrawLine(rect.GetLeft() + 1, rect.GetTop(), x2, rect.GetTop());
|
||||
}
|
||||
|
||||
// draw the grey stripes of the grip
|
||||
size_t n;
|
||||
@@ -3262,9 +3269,16 @@ void wxWin32Renderer::DrawStatusField(wxDC& dc,
|
||||
}
|
||||
|
||||
// draw the remaining rect boundaries
|
||||
ofs -= WIDTH_STATUSBAR_GRIP_BAND;
|
||||
dc.DrawLine(x2, rect.GetTop(), x2, y2 - ofs + 1);
|
||||
dc.DrawLine(rect.GetLeft(), y2, x2 - ofs + 1, y2);
|
||||
if (style != wxSB_FLAT)
|
||||
{
|
||||
if (style == wxSB_RAISED)
|
||||
dc.SetPen(m_penDarkGrey);
|
||||
else
|
||||
dc.SetPen(m_penHighlight);
|
||||
ofs -= WIDTH_STATUSBAR_GRIP_BAND;
|
||||
dc.DrawLine(x2, rect.GetTop(), x2, y2 - ofs + 1);
|
||||
dc.DrawLine(rect.GetLeft(), y2, x2 - ofs + 1, y2);
|
||||
}
|
||||
|
||||
rectIn = rect;
|
||||
rectIn.Deflate(1);
|
||||
@@ -3273,7 +3287,10 @@ void wxWin32Renderer::DrawStatusField(wxDC& dc,
|
||||
}
|
||||
else // normal pane
|
||||
{
|
||||
DrawBorder(dc, wxBORDER_STATIC, rect, flags, &rectIn);
|
||||
if (style == wxSB_RAISED)
|
||||
DrawBorder(dc, wxBORDER_RAISED, rect, flags, &rectIn);
|
||||
else if (style != wxSB_FLAT)
|
||||
DrawBorder(dc, wxBORDER_STATIC, rect, flags, &rectIn);
|
||||
}
|
||||
|
||||
rectIn.Deflate(STATBAR_BORDER_X, STATBAR_BORDER_Y);
|
||||
|
@@ -47,6 +47,7 @@ wxObject *wxStatusBarXmlHandler::DoCreateResource()
|
||||
|
||||
int fields = GetLong(wxT("fields"), 1);
|
||||
wxString widths = GetParamValue(wxT("widths"));
|
||||
wxString styles = GetParamValue(wxT("styles"));
|
||||
|
||||
if (fields > 1 && !widths.IsEmpty())
|
||||
{
|
||||
@@ -64,6 +65,30 @@ wxObject *wxStatusBarXmlHandler::DoCreateResource()
|
||||
else
|
||||
statbar->SetFieldsCount(fields);
|
||||
|
||||
if (!styles.IsEmpty())
|
||||
{
|
||||
int *style = new int[fields];
|
||||
for (int i = 0; i < fields; ++i)
|
||||
{
|
||||
style[i] = wxSB_NORMAL;
|
||||
|
||||
wxString first = styles.BeforeFirst(wxT(','));
|
||||
if (first == wxT("wxSB_NORMAL"))
|
||||
style[i] = wxSB_NORMAL;
|
||||
else if (first == wxT("wxSB_FLAT"))
|
||||
style[i] = wxSB_FLAT;
|
||||
else if (first == wxT("wxSB_RAISED"))
|
||||
style[i] = wxSB_RAISED;
|
||||
|
||||
if (!first.IsEmpty())
|
||||
wxLogError(wxT("Error in resource, unknown statusbar field style: ") + first);
|
||||
if(styles.Find(wxT(',')))
|
||||
styles.Remove(0, styles.Find(wxT(',')) + 1);
|
||||
}
|
||||
statbar->SetStatusStyles(fields, style);
|
||||
delete [] style;
|
||||
}
|
||||
|
||||
if (m_parentAsWindow)
|
||||
{
|
||||
wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
|
||||
|
Reference in New Issue
Block a user