void wxStatusBarGeneric::OnPaint(wxPaintEvent& WXUNUSED(event) ) { wxPaintDC dc(this); #ifdef __WXGTK20__ // Draw grip first if ( ShowsSizeGrip() ) { const wxRect& rc = GetSizeGripRect(); GdkWindowEdge edge = GetLayoutDirection() == wxLayout_RightToLeft ? GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST; gtk_paint_resize_grip(gtk_widget_get_style(m_widget), GTKGetDrawingWindow(), gtk_widget_get_state(m_widget), NULL, m_widget, "statusbar", edge, rc.x, rc.y, rc.width, rc.height ); } #endif // __WXGTK20__ if (GetFont().IsOk()) dc.SetFont(GetFont()); // compute char height only once for all panes: int textHeight = dc.GetCharHeight(); dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); for (size_t i = 0; i < m_panes.GetCount(); i ++) DrawField(dc, i, textHeight); }
void wxStatusBarGeneric::DoUpdateFieldWidths() { m_lastClientSize = GetClientSize(); int width = m_lastClientSize.x; if ( ShowsSizeGrip() ) width -= GetSizeGripRect().width; // recompute the cache of the field widths if the status bar width has changed m_widthsAbs = CalculateAbsWidths(width); }
void wxStatusBarGeneric::OnPaint(wxPaintEvent& WXUNUSED(event) ) { wxPaintDC dc(this); #ifdef __WXGTK20__ // Draw grip first if ( ShowsSizeGrip() ) { const wxRect& rc = GetSizeGripRect(); #ifdef __WXGTK3__ GtkWidget* toplevel = gtk_widget_get_toplevel(m_widget); GdkRectangle rect; if (toplevel && (!gtk_window_get_resize_grip_area(GTK_WINDOW(toplevel), &rect) || rect.width == 0 || rect.height == 0)) { GtkStyleContext* sc = gtk_widget_get_style_context(toplevel); gtk_style_context_save(sc); gtk_style_context_add_class(sc, GTK_STYLE_CLASS_GRIP); GtkJunctionSides sides = GTK_JUNCTION_CORNER_BOTTOMRIGHT; if (GetLayoutDirection() == wxLayout_RightToLeft) sides = GTK_JUNCTION_CORNER_BOTTOMLEFT; gtk_style_context_set_junction_sides(sc, sides); gtk_render_handle(sc, static_cast<cairo_t*>(dc.GetImpl()->GetCairoContext()), rc.x, rc.y, rc.width, rc.height); gtk_style_context_restore(sc); } #else GdkWindowEdge edge = GetLayoutDirection() == wxLayout_RightToLeft ? GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST; gtk_paint_resize_grip(gtk_widget_get_style(m_widget), GTKGetDrawingWindow(), gtk_widget_get_state(m_widget), NULL, m_widget, "statusbar", edge, rc.x, rc.y, rc.width, rc.height ); #endif } #endif // __WXGTK20__ if (GetFont().IsOk()) dc.SetFont(GetFont()); // compute char height only once for all panes: int textHeight = dc.GetCharHeight(); dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); for (size_t i = 0; i < m_panes.GetCount(); i ++) DrawField(dc, i, textHeight); }
void wxStatusBarGeneric::OnPaint(wxPaintEvent& WXUNUSED(event) ) { wxPaintDC dc(this); #ifdef __WXGTK20__ // Draw grip first if ( ShowsSizeGrip() ) { const wxRect& rc = GetSizeGripRect(); #ifdef __WXGTK3__ GtkWidget* toplevel = gtk_widget_get_toplevel(m_widget); GdkRectangle rect; wxGCC_WARNING_SUPPRESS(deprecated-declarations) if (toplevel && (!gtk_window_get_resize_grip_area(GTK_WINDOW(toplevel), &rect) || rect.width == 0 || rect.height == 0)) wxGCC_WARNING_RESTORE() { GtkStyleContext* sc = gtk_widget_get_style_context(toplevel); gtk_style_context_save(sc); gtk_style_context_add_class(sc, GTK_STYLE_CLASS_GRIP); GtkJunctionSides sides = GTK_JUNCTION_CORNER_BOTTOMRIGHT; if (GetLayoutDirection() == wxLayout_RightToLeft) sides = GTK_JUNCTION_CORNER_BOTTOMLEFT; gtk_style_context_set_junction_sides(sc, sides); gtk_render_handle(sc, static_cast<cairo_t*>(dc.GetImpl()->GetCairoContext()), rc.x, rc.y, rc.width, rc.height); gtk_style_context_restore(sc); } #else GdkWindowEdge edge = GetLayoutDirection() == wxLayout_RightToLeft ? GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST; gtk_paint_resize_grip(gtk_widget_get_style(m_widget), GTKGetDrawingWindow(), gtk_widget_get_state(m_widget), NULL, m_widget, "statusbar", edge, rc.x, rc.y, rc.width, rc.height ); #endif }
void wxStatusBarGeneric::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int textHeight) { wxString text(GetStatusText(i)); if (text.empty()) return; // optimization int xpos = rect.x + wxFIELD_TEXT_MARGIN, maxWidth = rect.width - 2*wxFIELD_TEXT_MARGIN, ypos = (int) (((rect.height - textHeight) / 2) + rect.y + 0.5); if (ShowsSizeGrip()) { // don't write text over the size grip: // NOTE: overloading DoGetClientSize() and GetClientAreaOrigin() wouldn't // work because the adjustment needs to be done only when drawing // the field text and not also when drawing the background, the // size grip itself, etc if ((GetLayoutDirection() == wxLayout_RightToLeft && i == 0) || (GetLayoutDirection() != wxLayout_RightToLeft && i == (int)m_panes.GetCount()-1)) { const wxRect& gripRc = GetSizeGripRect(); // NOTE: we don't need any special treatment wrt to the layout direction // since DrawText() will automatically adjust the origin of the // text accordingly to the layout in use maxWidth -= gripRc.width; } } // eventually ellipsize the text so that it fits the field width wxEllipsizeMode ellmode = wxELLIPSIZE_NONE; if (HasFlag(wxSTB_ELLIPSIZE_START)) ellmode = wxELLIPSIZE_START; else if (HasFlag(wxSTB_ELLIPSIZE_MIDDLE)) ellmode = wxELLIPSIZE_MIDDLE; else if (HasFlag(wxSTB_ELLIPSIZE_END)) ellmode = wxELLIPSIZE_END; if (ellmode == wxELLIPSIZE_NONE) { // if we have the wxSTB_SHOW_TIPS we must set the ellipsized flag even if // we don't ellipsize the text but just truncate it if (HasFlag(wxSTB_SHOW_TIPS)) SetEllipsizedFlag(i, dc.GetTextExtent(text).GetWidth() > maxWidth); dc.SetClippingRegion(rect); } else { text = wxControl::Ellipsize(text, dc, ellmode, maxWidth, wxELLIPSIZE_FLAGS_EXPAND_TABS); // Ellipsize() will do something only if necessary // update the ellipsization status for this pane; this is used later to // decide whether a tooltip should be shown or not for this pane // (if we have wxSTB_SHOW_TIPS) SetEllipsizedFlag(i, text != GetStatusText(i)); } #if defined( __WXGTK__ ) || defined(__WXMAC__) xpos++; ypos++; #endif // draw the text dc.DrawText(text, xpos, ypos); if (ellmode == wxELLIPSIZE_NONE) dc.DestroyClippingRegion(); }