#define wxTC_MULTILINE 0x0200 /* == wxNB_MULTILINE */
#define wxTC_OWNERDRAW 0x0400
-/*
- * wxStatusBar95 flags
- */
-#define wxST_SIZEGRIP 0x0010
-
/*
* wxStaticBitmap flags
*/
// ----------------------------------------------------------------------------
#include "wx/toplevel.h" // the base class
+#include "wx/statusbr.h"
// the default names for various classs
extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusLineNameStr[];
#if wxUSE_STATUSBAR
// create the main status bar by calling OnCreateStatusBar()
virtual wxStatusBar* CreateStatusBar(int number = 1,
- long style = wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE,
+ long style = wxST_DEFAULT_STYLE,
wxWindowID winid = 0,
- const wxString& name =
- wxStatusLineNameStr);
+ const wxString& name = wxStatusLineNameStr);
// return a new status bar
virtual wxStatusBar *OnCreateStatusBar(int number,
long style,
wxStatusBarGeneric() { Init(); }
wxStatusBarGeneric(wxWindow *parent,
wxWindowID winid = wxID_ANY,
- long style = wxST_SIZEGRIP,
+ long style = wxST_DEFAULT_STYLE,
const wxString& name = wxStatusBarNameStr)
{
Init();
virtual ~wxStatusBarGeneric();
bool Create(wxWindow *parent, wxWindowID winid = wxID_ANY,
- long style = wxST_SIZEGRIP,
+ long style = wxST_DEFAULT_STYLE,
const wxString& name = wxStatusBarNameStr);
// Create status line
virtual int GetBorderY() const { return m_borderY; }
+ // implementation only (not part of wxStatusBar public API):
+
+ int GetFieldFromPoint(const wxPoint& point) const;
+
protected: // event handlers
void OnPaint(wxPaintEvent& event);
int m_borderX;
int m_borderY;
+
wxPen m_mediumShadowPen;
wxPen m_hilightPen;
wxStatusBar();
wxStatusBar(wxWindow *parent,
wxWindowID id = wxID_ANY,
- long style = wxST_SIZEGRIP,
+ long style = wxST_DEFAULT_STYLE,
const wxString& name = wxStatusBarNameStr)
{
m_pDC = NULL;
bool Create(wxWindow *parent,
wxWindowID id = wxID_ANY,
- long style = wxST_SIZEGRIP,
+ long style = wxST_DEFAULT_STYLE,
const wxString& name = wxStatusBarNameStr);
virtual ~wxStatusBar();
wxStatusBarMac();
wxStatusBarMac(wxWindow *parent, wxWindowID id = wxID_ANY,
- long style = wxST_SIZEGRIP,
+ long style = wxST_DEFAULT_STYLE,
const wxString& name = wxStatusBarNameStr);
virtual ~wxStatusBarMac();
bool Create(wxWindow *parent, wxWindowID id = wxID_ANY,
- long style = wxST_SIZEGRIP,
+ long style = wxST_DEFAULT_STYLE,
const wxString& name = wxStatusBarNameStr);
virtual void DrawFieldText(wxDC& dc, const wxRect& rc, int i, int textHeight);
wxStatusBarPalm();
wxStatusBarPalm(wxWindow *parent,
wxWindowID id = wxID_ANY,
- long style = wxST_SIZEGRIP,
+ long style = wxST_DEFAULT_STYLE,
const wxString& name = wxEmptyString)
{
(void)Create(parent, id, style, name);
bool Create(wxWindow *parent,
wxWindowID id = wxID_ANY,
- long style = wxST_SIZEGRIP,
+ long style = wxST_DEFAULT_STYLE,
const wxString& name = wxEmptyString);
virtual ~wxStatusBarPalm();
// wxStatusBar constants
// ----------------------------------------------------------------------------
+// wxStatusBar styles
+#define wxST_SIZEGRIP 0x0010
+#define wxST_SHOW_TIPS 0x0020
+
+#define wxST_DEFAULT_STYLE (wxST_SIZEGRIP|wxST_SHOW_TIPS|wxFULL_REPAINT_ON_RESIZE)
+
// style flags for fields
#define wxSB_NORMAL 0x0000
#define wxSB_FLAT 0x0001
public:
wxStatusBarPane(int style = wxSB_NORMAL, size_t width = 0)
- : m_nStyle(style), m_nWidth(width) { m_arrStack.Add(wxEmptyString); }
+ : m_nStyle(style), m_nWidth(width)
+ { m_arrStack.Add(wxEmptyString); m_bEllipsized=false; }
int GetWidth() const
{ return m_nWidth; }
const wxArrayString& GetStack() const
{ return m_arrStack; }
- // use wxStatusBar setter functions to modify a wxStatusBarPane
+ // implementation-only getter:
+ bool IsEllipsized() const
+ { return m_bEllipsized; }
+
+ // NOTE: there are no setters in wxStatusBarPane;
+ // use wxStatusBar functions to modify a wxStatusBarPane
protected:
int m_nStyle;
// this is the array of the stacked strings of this pane; note that this
// stack does include also the string currently displayed in this pane
// as the version stored in the native status bar control is possibly
- // ellipsized; note that arrStack.Last() is the top of the stack
+ // ellipsized; note that m_arrStack.Last() is the top of the stack
// (i.e. the string shown in the status bar)
wxArrayString m_arrStack;
+
+ // was the m_arrStack.Last() string shown in the status bar control ellipsized?
+ bool m_bEllipsized;
};
WX_DECLARE_OBJARRAY(wxStatusBarPane, wxStatusBarPaneArray);
// get the dimensions of the horizontal and vertical borders
virtual int GetBorderX() const = 0;
virtual int GetBorderY() const = 0;
+
+ wxSize GetBorders() const
+ { return wxSize(GetBorderX(), GetBorderY()); }
// miscellaneous
// -------------
// calculate the real field widths for the given total available size
wxArrayInt CalculateAbsWidths(wxCoord widthTotal) const;
+
+ // an internal utility used to keep track of which panes have labels
+ // which were last rendered as ellipsized...
+ void SetEllipsizedFlag(int n, bool ellipsized)
+ { m_panes[n].m_bEllipsized = ellipsized; }
// the array with the pane infos:
wxStatusBarPaneArray m_panes;
wxStatusBarUniv(wxWindow *parent,
wxWindowID id = wxID_ANY,
- long style = 0,
+ long style = wxST_DEFAULT_STYLE,
const wxString& name = wxPanelNameStr)
{
Init();
bool Create(wxWindow *parent,
wxWindowID id = wxID_ANY,
- long style = 0,
+ long style = wxST_DEFAULT_STYLE,
const wxString& name = wxPanelNameStr);
// set field count/widths
Constructs the pane with the given @a style and @a width.
*/
wxStatusBarPane(int style = wxSB_NORMAL, size_t width = 0);
-
+
/**
Returns the pane width; it maybe negative, indicating a variable-width field.
*/
int GetWidth() const;
-
+
/**
Returns the pane style.
*/
A status bar is a narrow window that can be placed along the bottom of a frame
to give small amounts of status information. It can contain one or more fields,
one or more of which can be variable length according to the size of the window.
+
+ Note that in wxStatusBar context, the terms @e pane and @e field are synonyms.
@beginStyleTable
@style{wxST_SIZEGRIP}
- Displays a gripper at the right-hand side of the status bar.
+ Displays a gripper at the right-hand side of the status bar which can be used
+ to resize the parent window.
+ @style{wxST_SHOW_TIPS}
+ Displays tooltips for those panes whose status text has been ellipsized because
+ the status text doesn't fit the pane width.
+ Note that this style has effect only on wxGTK (with GTK+ >= 2.12) currently.
+ @style{wxST_DEFAULT_STYLE}
+ The default style: includes @c wxST_SIZEGRIP|wxST_SHOW_TIPS|wxFULL_REPAINT_ON_RESIZE.
@endStyleTable
@remarks
@see Create()
*/
wxStatusBar(wxWindow* parent, wxWindowID id = wxID_ANY,
- long style = wxST_SIZEGRIP,
+ long style = wxST_DEFAULT_STYLE,
const wxString& name = wxStatusBarNameStr);
/**
See wxStatusBar() for details.
*/
bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
- long style = wxST_SIZEGRIP,
+ long style = wxST_DEFAULT_STYLE,
const wxString& name = wxStatusBarNameStr);
/**
*/
const wxStatusBarPane& GetField(int n) const;
+ /**
+ Returns the horizontal and vertical borders used when rendering the field
+ text inside the field area.
+
+ Note that the rect returned by GetFieldRect() already accounts for the
+ presence of horizontal and vertical border returned by this function.
+ */
+ wxSize GetBorders() const;
+
/**
Returns the string associated with a status bar field.
// Name: src/generic/statusbr.cpp
// Purpose: wxStatusBarGeneric class implementation
// Author: Julian Smart
-// Modified by:
+// Modified by: Francesco Montorsi
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
#ifdef __WXGTK20__
#include <gtk/gtk.h>
+ #include "wx/gtk/private.h"
#endif
// we only have to do it here when we use wxStatusBarGeneric in addition to the
// Margin between the field text and the field rect
#define wxFIELD_TEXT_MARGIN 2
+// ----------------------------------------------------------------------------
+// GTK+ signal handler
+// ----------------------------------------------------------------------------
+
+#if defined( __WXGTK20__ ) && GTK_CHECK_VERSION(2,12,0)
+extern "C" {
+static
+gboolean statusbar_query_tooltip(GtkWidget *widget,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip *tooltip,
+ wxStatusBar* statbar)
+{
+ int n = statbar->GetFieldFromPoint(wxPoint(x,y));
+ if (n == wxNOT_FOUND)
+ return FALSE;
+
+ // should we show the tooltip for the n-th pane of the statusbar?
+ if (!statbar->GetField(n).IsEllipsized())
+ return FALSE; // no, it's not useful
+
+ gtk_tooltip_set_text(tooltip, wxGTK_CONV_SYS(statbar->GetStatusText(n)));
+ return TRUE;
+}
+}
+#endif
// ----------------------------------------------------------------------------
// wxStatusBarGeneric
SetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, height);
SetFieldsCount(1);
+
+#if defined( __WXGTK20__ ) && GTK_CHECK_VERSION(2,12,0)
+ if (HasFlag(wxST_SHOW_TIPS) && !gtk_check_version(2,12,0))
+ {
+ g_object_set(m_widget, "has-tooltip", TRUE, NULL);
+ g_signal_connect(m_widget, "query-tooltip",
+ G_CALLBACK(statusbar_query_tooltip), this);
+ }
+#endif
return true;
}
wxELLIPSIZE_EXPAND_TAB);
// Ellipsize() will do something only if necessary
+ // update the ellipsization status for this pane; this is used to decide
+ // whether a tooltip should be shown or not for this pane
+ SetEllipsizedFlag(i, text != GetStatusText(i));
+
#if defined( __WXGTK__ ) || defined(__WXMAC__)
xpos++;
ypos++;
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.
+ // For wxSB_NORMAL: paint a 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
dc.SetPen((style == wxSB_RAISED) ? m_mediumShadowPen : m_hilightPen);
dc.DrawLine(rect.x, rect.y,
rect.x + rect.width, rect.y);
dc.DrawLine(rect.x, rect.y + rect.height,
- rect.x, rect.y);
+ rect.x, rect.y);
#endif
}
DrawFieldText(dc, rect, i, textHeight);
}
-// Get the position and size of the field's internal bounding rectangle
bool wxStatusBarGeneric::GetFieldRect(int n, wxRect& rect) const
{
wxCHECK_MSG( (n >= 0) && ((size_t)n < m_panes.GetCount()), false,
return true;
}
-// Initialize colours
+int wxStatusBarGeneric::GetFieldFromPoint(const wxPoint& pt) const
+{
+ if (m_widthsAbs.IsEmpty())
+ return wxNOT_FOUND;
+
+ // NOTE: we explicitely don't take in count the borders since they are only
+ // useful when rendering the status text, not for hit-test computations
+
+ if (pt.y <= 0 || pt.y >= m_lastClientHeight)
+ return wxNOT_FOUND;
+
+ int x = 0;
+ for ( size_t i = 0; i < m_panes.GetCount(); i++ )
+ {
+ if (pt.x > x && pt.x < x+m_widthsAbs[i])
+ return i;
+
+ x += m_widthsAbs[i];
+ }
+
+ return wxNOT_FOUND;
+}
+
void wxStatusBarGeneric::InitColours()
{
#if defined(__WXPM__)
DrawField(dc, i, textHeight);
}
-// Responds to colour changes, and passes event on to children.
void wxStatusBarGeneric::OnSysColourChanged(wxSysColourChangedEvent& event)
{
InitColours();