00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 enum
00021 {
00022 ID_LEGEND_ENABLED,
00023 ID_LEGEND_DISABLED,
00024 ID_LEGEND_INPUT,
00025 ID_LEGEND_OUTPUT,
00026 ID_LEGEND_NOSPACE
00027 };
00028
00029 #include "nanoStatusBar.hpp"
00030 #include "resources/red.xpm"
00031 #include "resources/blue.xpm"
00032 #include "resources/black.xpm"
00033 #include "resources/green.xpm"
00034 #include "resources/grey.xpm"
00035
00036 BEGIN_EVENT_TABLE(NanoStatusBar, wxStatusBar)
00037 EVT_SIZE(NanoStatusBar::OnSize)
00038 END_EVENT_TABLE()
00039
00041
00044 NanoStatusBar::NanoStatusBar(wxWindow *parent)
00045 :wxStatusBar(parent, wxID_ANY)
00046 {
00047 SetFieldsCount(2);
00048 initControls();
00049 setWidthHeight();
00050 }
00051
00052
00054 NanoStatusBar::~NanoStatusBar()
00055 {
00056 }
00057
00058
00060 void NanoStatusBar::initControls()
00061 {
00062 wxBitmap bmpEnabled(red_xpm);
00063 wxBitmap bmpDisabled(black_xpm);
00064 wxBitmap bmpInput(green_xpm);
00065 wxBitmap bmpOutput(blue_xpm);
00066 wxBitmap bmpNoSpace(grey_xpm);
00067
00068 labelEnabled = new wxStaticText(this, wxID_ANY, _("Enabled"));
00069 bitmapEnabled = new wxStaticBitmap(this, wxID_ANY, bmpEnabled);
00070 labelDisabled = new wxStaticText(this, wxID_ANY, _("Disabled"));
00071 bitmapDisabled = new wxStaticBitmap(this, wxID_ANY, bmpDisabled);
00072 labelInput = new wxStaticText(this, wxID_ANY, _("Input"));
00073 bitmapInput = new wxStaticBitmap(this, wxID_ANY, bmpInput);
00074 labelOutput = new wxStaticText(this, wxID_ANY, _("Output"));
00075 bitmapOutput = new wxStaticBitmap(this, wxID_ANY, bmpOutput);
00076 labelNoSpace = new wxStaticText(this, wxID_ANY, _("No Space"));
00077 bitmapNoSpace = new wxStaticBitmap(this, wxID_ANY, bmpNoSpace);
00078 }
00079
00080
00082
00088 void NanoStatusBar::OnSize(wxSizeEvent& event)
00089 {
00090
00091 wxRect rect;
00092 GetFieldRect(1, rect);
00093 int x;
00094 int bitmapY;
00095 int labelY;
00096
00097 x = rect.GetX() + INITSPACE;
00098 bitmapY = rect.GetY() + (rect.GetHeight() - bitmapEnabled->GetSize().GetHeight()) / 2;
00099 labelY = rect.GetY() + (rect.GetHeight() - labelEnabled->GetSize().GetHeight()) / 2;;
00100
00101 bitmapEnabled->Move(x, bitmapY);
00102 x = x + bitmapEnabled->GetSize().GetWidth() + INTERSPACE;
00103 labelEnabled->Move(x, labelY);
00104 x = x + labelEnabled->GetSize().GetWidth() + INTERSPACE;
00105
00106 bitmapDisabled->Move(x, bitmapY);
00107 x = x + bitmapDisabled->GetSize().GetWidth() + INTERSPACE;
00108 labelDisabled->Move(x, labelY);
00109 x = x + labelDisabled->GetSize().GetWidth() + INTERSPACE;
00110
00111 bitmapInput->Move(x, bitmapY);
00112 x = x + bitmapInput->GetSize().GetWidth() + INTERSPACE;
00113 labelInput->Move(x, labelY);
00114 x = x + labelInput->GetSize().GetWidth() + INTERSPACE;
00115
00116 bitmapOutput->Move(x, bitmapY);
00117 x = x + bitmapOutput->GetSize().GetWidth() + INTERSPACE;
00118 labelOutput->Move(x, labelY);
00119 x = x + labelOutput->GetSize().GetWidth() + INTERSPACE;
00120
00121 bitmapNoSpace->Move(x, bitmapY);
00122 x = x + bitmapNoSpace->GetSize().GetWidth() + INTERSPACE;
00123 labelNoSpace->Move(x, labelY);
00124 x = x + labelNoSpace->GetSize().GetWidth() + INTERSPACE;
00125 }
00126
00127
00129 void NanoStatusBar::setWidthHeight()
00130 {
00131 int width = 0;
00132 width = INITSPACE +
00133 labelEnabled->GetSize().GetWidth() +
00134 INTERSPACE +
00135 labelDisabled->GetSize().GetWidth() +
00136 INTERSPACE +
00137 labelInput->GetSize().GetWidth() +
00138 INTERSPACE +
00139 labelOutput->GetSize().GetWidth() +
00140 INTERSPACE +
00141 labelNoSpace->GetSize().GetWidth() +
00142 INTERSPACE +
00143 bitmapEnabled->GetSize().GetWidth() +
00144 INTERSPACE +
00145 bitmapDisabled->GetSize().GetWidth() +
00146 INTERSPACE +
00147 bitmapInput->GetSize().GetWidth() +
00148 INTERSPACE +
00149 bitmapOutput->GetSize().GetWidth() +
00150 INTERSPACE +
00151 bitmapNoSpace->GetSize().GetWidth() +
00152 INITSPACE;
00153
00154 static const int widths[2] = { -1, width };
00155 SetStatusWidths(2, widths);
00156 if ((labelEnabled->GetSize().GetHeight() + 2) > (bitmapEnabled->GetSize().GetHeight()) + 2)
00157 {
00158 SetMinHeight(labelEnabled->GetSize().GetHeight() + 2);
00159 }
00160 else
00161 {
00162 SetMinHeight(bitmapEnabled->GetSize().GetHeight() + 2);
00163 }
00164 }