WxGauge
From WxWiki
Contents |
[edit] A Brief Foray into Writing Text Sideways
With a vertical gauge or slider, you may wish to pack in a sideways label. Here's a simple version that can be ->Add'ed into a sizer.
- It does not automatically resize. (Set the size to the same height as the slider.)
- It assumes the text is static.
- You may wish to add extra features; this is bare minimum.
statsidetext.h
/* statsidetext.h */ /* sideways static text */ class StatSideText: public wxControl { public: StatSideText(wxWindow *parent,const wxString& label, wxPoint pos=wxDefaultPosition,wxSize size=wxDefaultSize); ~StatSideText() {}; void OnPaint(wxPaintEvent& event); private: DECLARE_EVENT_TABLE(); };
statsidetext.cpp
/* statsidetext.cpp */ /* sideways static text */ #include <wx/wx.h> #include "statsidetext.h" BEGIN_EVENT_TABLE(StatSideText,wxControl) EVT_PAINT(StatSideText::OnPaint) END_EVENT_TABLE() StatSideText::StatSideText(wxWindow *parent,const wxString& label, wxPoint pos, wxSize size) :wxControl(parent,-1,pos,size) { SetLabel(label); } void StatSideText::OnPaint(wxPaintEvent &event) { wxPaintDC dc(this); wxCoord w,h; const wxString& l=wxControl::GetLabel(); dc.GetTextExtent(l,&w,&h); dc.DrawRotatedText(l,h,0,-90); }
D.F. Smith, Aug2004
[edit] If the Colors are Strange in GTK
If you have unreadable gauges (gray on gray, etc.) with your GTK wxGauge then this might be useful.
First, DON'T call gauge->SetBackgroundColour() or gauge->SetForegroundColour() --- it messes things up. (The former does work in GTK1.x, the latter does not, both mess things up.) The actual colors are set by your .gtkrc.
Add something along the lines of the following to the file ~/.gtkrc
style "gtk-progressbar-style" {
bg[NORMAL] = "#BBBBBB"
bg[PRELIGHT] = "#2222EE"
}
class "GtkProgressBar" style "gtk-progressbar-style"
[edit] Microsoft Windows: Changing Color Doesn't Work with XP Themes
Changing the foreground and background colors doesn't seem to work with XP themes. Without XP themes, it works.
