-// This functions are here for this proof of concept
-// and will be factored out later. See dockart.cpp
-static wxColor StepColour(const wxColor& c, int percent)
-{
- int r = c.Red(), g = c.Green(), b = c.Blue();
- return wxColour((unsigned char)wxMin((r*percent)/100,255),
- (unsigned char)wxMin((g*percent)/100,255),
- (unsigned char)wxMin((b*percent)/100,255));
-}
+// these functions live in dockart.cpp -- they'll eventually
+// be moved to a new utility cpp file
-// This functions are here for this proof of concept
-// and will be factored out later. See dockart.cpp
-static wxBitmap BitmapFromBits(const unsigned char bits[], int w, int h,
- const wxColour& color)
-{
- wxImage img = wxBitmap((const char*)bits, w, h).ConvertToImage();
- img.Replace(0,0,0,123,123,123);
- img.Replace(255,255,255,color.Red(),color.Green(),color.Blue());
- img.SetMaskColour(123,123,123);
- return wxBitmap(img);
-}
+wxColor wxAuiStepColour(const wxColor& c, int percent);
+
+wxBitmap wxAuiBitmapFromBits(const unsigned char bits[], int w, int h,
+ const wxColour& color);
+
+wxString wxAuiChopText(wxDC& dc, const wxString& text, int max_size);
static void DrawButtons(wxDC& dc,
const wxRect& _rect,
if (button_state == wxAUI_BUTTON_STATE_HOVER ||
button_state == wxAUI_BUTTON_STATE_PRESSED)
{
- dc.SetBrush(wxBrush(StepColour(bkcolour, 120)));
- dc.SetPen(wxPen(StepColour(bkcolour, 70)));
+ dc.SetBrush(wxBrush(wxAuiStepColour(bkcolour, 120)));
+ dc.SetPen(wxPen(wxAuiStepColour(bkcolour, 70)));
// draw the background behind the button
dc.DrawRectangle(rect.x, rect.y, 15, 15);
}
}
-// chops the text so that it fits within |max_size| pixels.
-// Also adds an elipsis if necessary
-
-static wxString ChopText(wxDC& dc, const wxString& text, int max_size)
-{
- wxCoord x,y;
-
- // first check if the text fits with no problems
- dc.GetTextExtent(text, &x, &y);
- if (x <= max_size)
- return text;
-
- size_t i, len = text.Length();
- size_t last_good_length = 0;
- for (i = 0; i < len; ++i)
- {
- wxString s = text.Left(i);
- s += wxT("...");
-
- dc.GetTextExtent(s, &x, &y);
- if (x > max_size)
- break;
-
- last_good_length = i;
- }
-
- wxString ret = text.Left(last_good_length);
- ret += wxT("...");
- return ret;
-}
// -- GUI helper classes and functions --
#endif
m_base_colour = base_colour;
- wxColor darker2_colour = StepColour(base_colour, 70);
+ wxColor darker2_colour = wxAuiStepColour(base_colour, 70);
m_border_pen = wxPen(darker2_colour);
m_base_colour_pen = wxPen(m_base_colour);
m_base_colour_brush = wxBrush(m_base_colour);
- m_active_close_bmp = BitmapFromBits(close_bits, 16, 16, *wxBLACK);
- m_disabled_close_bmp = BitmapFromBits(close_bits, 16, 16, wxColour(128,128,128));
+ m_active_close_bmp = wxAuiBitmapFromBits(close_bits, 16, 16, *wxBLACK);
+ m_disabled_close_bmp = wxAuiBitmapFromBits(close_bits, 16, 16, wxColour(128,128,128));
- m_active_left_bmp = BitmapFromBits(left_bits, 16, 16, *wxBLACK);
- m_disabled_left_bmp = BitmapFromBits(left_bits, 16, 16, wxColour(128,128,128));
+ m_active_left_bmp = wxAuiBitmapFromBits(left_bits, 16, 16, *wxBLACK);
+ m_disabled_left_bmp = wxAuiBitmapFromBits(left_bits, 16, 16, wxColour(128,128,128));
- m_active_right_bmp = BitmapFromBits(right_bits, 16, 16, *wxBLACK);
- m_disabled_right_bmp = BitmapFromBits(right_bits, 16, 16, wxColour(128,128,128));
+ m_active_right_bmp = wxAuiBitmapFromBits(right_bits, 16, 16, *wxBLACK);
+ m_disabled_right_bmp = wxAuiBitmapFromBits(right_bits, 16, 16, wxColour(128,128,128));
- m_active_windowlist_bmp = BitmapFromBits(list_bits, 16, 16, *wxBLACK);
- m_disabled_windowlist_bmp = BitmapFromBits(list_bits, 16, 16, wxColour(128,128,128));
+ m_active_windowlist_bmp = wxAuiBitmapFromBits(list_bits, 16, 16, *wxBLACK);
+ m_disabled_windowlist_bmp = wxAuiBitmapFromBits(list_bits, 16, 16, wxColour(128,128,128));
m_flags = 0;
}
{
// draw background
wxRect r(rect.x, rect.y, rect.width+2, rect.height-3);
- wxColor top_color = StepColour(m_base_colour, 90);
- wxColor bottom_color = StepColour(m_base_colour, 110);
+ wxColor top_color = wxAuiStepColour(m_base_colour, 90);
+ wxColor bottom_color = wxAuiStepColour(m_base_colour, 110);
dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH);
// draw base lines
// -- draw top gradient fill for glossy look
wxColor top_color = m_base_colour;
- wxColor bottom_color = StepColour(top_color, 106);
+ wxColor bottom_color = wxAuiStepColour(top_color, 106);
dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH);
r.y += r.height;
}
- wxString draw_text = ChopText(dc,
+ wxString draw_text = wxAuiChopText(dc,
caption,
tab_width - (text_offset-tab_x) - close_button_width);
wxColour base_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
- wxColour background_colour = StepColour(base_colour, 95);
+ wxColour background_colour = wxAuiStepColour(base_colour, 95);
wxColour normaltab_colour = base_colour;
wxColour selectedtab_colour = *wxWHITE;
m_selected_bkbrush = wxBrush(selectedtab_colour);
m_selected_bkpen = wxPen(selectedtab_colour);
- m_active_close_bmp = BitmapFromBits(close_bits, 16, 16, *wxBLACK);
- m_disabled_close_bmp = BitmapFromBits(close_bits, 16, 16, wxColour(128,128,128));
+ m_active_close_bmp = wxAuiBitmapFromBits(close_bits, 16, 16, *wxBLACK);
+ m_disabled_close_bmp = wxAuiBitmapFromBits(close_bits, 16, 16, wxColour(128,128,128));
- m_active_left_bmp = BitmapFromBits(left_bits, 16, 16, *wxBLACK);
- m_disabled_left_bmp = BitmapFromBits(left_bits, 16, 16, wxColour(128,128,128));
+ m_active_left_bmp = wxAuiBitmapFromBits(left_bits, 16, 16, *wxBLACK);
+ m_disabled_left_bmp = wxAuiBitmapFromBits(left_bits, 16, 16, wxColour(128,128,128));
- m_active_right_bmp = BitmapFromBits(right_bits, 16, 16, *wxBLACK);
- m_disabled_right_bmp = BitmapFromBits(right_bits, 16, 16, wxColour(128,128,128));
+ m_active_right_bmp = wxAuiBitmapFromBits(right_bits, 16, 16, *wxBLACK);
+ m_disabled_right_bmp = wxAuiBitmapFromBits(right_bits, 16, 16, wxColour(128,128,128));
- m_active_windowlist_bmp = BitmapFromBits(list_bits, 16, 16, *wxBLACK);
- m_disabled_windowlist_bmp = BitmapFromBits(list_bits, 16, 16, wxColour(128,128,128));
+ m_active_windowlist_bmp = wxAuiBitmapFromBits(list_bits, 16, 16, *wxBLACK);
+ m_disabled_windowlist_bmp = wxAuiBitmapFromBits(list_bits, 16, 16, wxColour(128,128,128));
}
text_offset = tab_x + tab_height;
// chop text if necessary
- wxString draw_text = ChopText(dc,
+ wxString draw_text = wxAuiChopText(dc,
caption,
tab_width - (text_offset-tab_x) - close_button_width);
// wxAuiManager::SetDockArt()
-// StepColour() it a utility function that simply darkens
-// or lightens a color, based on the specified percentage
-static wxColor StepColour(const wxColor& c, int percent)
+wxColor wxAuiStepColour(const wxColor& c, int percent)
{
int r = c.Red(), g = c.Green(), b = c.Blue();
return wxColour((unsigned char)wxMin((r*percent)/100,255),
(unsigned char)wxMin((b*percent)/100,255));
}
-static wxColor LightContrastColour(const wxColour& c)
+wxColor wxAuiLightContrastColour(const wxColour& c)
{
int amount = 120;
if (c.Red() < 128 && c.Green() < 128 && c.Blue() < 128)
amount = 160;
- return StepColour(c, amount);
+ return wxAuiStepColour(c, amount);
}
-// BitmapFromBits() is a utility function that creates a
+// wxAuiBitmapFromBits() is a utility function that creates a
// masked bitmap from raw bits (XBM format)
-static wxBitmap BitmapFromBits(const unsigned char bits[], int w, int h,
- const wxColour& color)
+wxBitmap wxAuiBitmapFromBits(const unsigned char bits[], int w, int h,
+ const wxColour& color)
{
wxImage img = wxBitmap((const char*)bits, w, h).ConvertToImage();
img.Replace(0,0,0,123,123,123);
img.SetMaskColour(123,123,123);
return wxBitmap(img);
}
-
+
static void DrawGradientRectangle(wxDC& dc,
const wxRect& rect,
else
dc.DrawLine(rect.x+i, rect.y, rect.x+i, rect.y+rect.height);
}
-
}
-static wxString ChopText(wxDC& dc, const wxString& text, int max_size)
+wxString wxAuiChopText(wxDC& dc, const wxString& text, int max_size)
{
wxCoord x,y;
#endif
m_base_colour = base_colour;
- wxColor darker1_colour = StepColour(base_colour, 85);
- wxColor darker2_colour = StepColour(base_colour, 70);
- wxColor darker3_colour = StepColour(base_colour, 60);
- wxColor darker4_colour = StepColour(base_colour, 50);
- wxColor darker5_colour = StepColour(base_colour, 40);
+ wxColor darker1_colour = wxAuiStepColour(base_colour, 85);
+ wxColor darker2_colour = wxAuiStepColour(base_colour, 70);
+ wxColor darker3_colour = wxAuiStepColour(base_colour, 60);
+ wxColor darker4_colour = wxAuiStepColour(base_colour, 50);
+ wxColor darker5_colour = wxAuiStepColour(base_colour, 40);
m_active_caption_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
- m_active_caption_gradient_colour = LightContrastColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
+ m_active_caption_gradient_colour = wxAuiLightContrastColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
m_active_caption_text_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
m_inactive_caption_colour = darker1_colour;
- m_inactive_caption_gradient_colour = StepColour(base_colour, 97);
+ m_inactive_caption_gradient_colour = wxAuiStepColour(base_colour, 97);
m_inactive_caption_text_colour = *wxBLACK;
#ifdef __WXMAC__
0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
#ifdef __WXMAC__
- m_inactive_close_bitmap = BitmapFromBits(close_bits, 16, 16, *wxWHITE);
- m_active_close_bitmap = BitmapFromBits(close_bits, 16, 16, *wxWHITE );
+ m_inactive_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, *wxWHITE);
+ m_active_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, *wxWHITE );
#else
- m_inactive_close_bitmap = BitmapFromBits(close_bits, 16, 16, m_inactive_caption_text_colour);
- m_active_close_bitmap = BitmapFromBits(close_bits, 16, 16, m_active_caption_text_colour);
+ m_inactive_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, m_inactive_caption_text_colour);
+ m_active_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, m_active_caption_text_colour);
#endif
#ifdef __WXMAC__
- m_inactive_maximize_bitmap = BitmapFromBits(maximize_bits, 16, 16, *wxWHITE);
- m_active_maximize_bitmap = BitmapFromBits(maximize_bits, 16, 16, *wxWHITE );
+ m_inactive_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, *wxWHITE);
+ m_active_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, *wxWHITE );
#else
- m_inactive_maximize_bitmap = BitmapFromBits(maximize_bits, 16, 16, m_inactive_caption_text_colour);
- m_active_maximize_bitmap = BitmapFromBits(maximize_bits, 16, 16, m_active_caption_text_colour);
+ m_inactive_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, m_inactive_caption_text_colour);
+ m_active_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, m_active_caption_text_colour);
#endif
#ifdef __WXMAC__
- m_inactive_restore_bitmap = BitmapFromBits(restore_bits, 16, 16, *wxWHITE);
- m_active_restore_bitmap = BitmapFromBits(restore_bits, 16, 16, *wxWHITE );
+ m_inactive_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, *wxWHITE);
+ m_active_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, *wxWHITE );
#else
- m_inactive_restore_bitmap = BitmapFromBits(restore_bits, 16, 16, m_inactive_caption_text_colour);
- m_active_restore_bitmap = BitmapFromBits(restore_bits, 16, 16, m_active_caption_text_colour);
+ m_inactive_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, m_inactive_caption_text_colour);
+ m_active_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, m_active_caption_text_colour);
#endif
- m_inactive_pin_bitmap = BitmapFromBits(pin_bits, 16, 16, m_inactive_caption_text_colour);
- m_active_pin_bitmap = BitmapFromBits(pin_bits, 16, 16, m_active_caption_text_colour);
+ m_inactive_pin_bitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, m_inactive_caption_text_colour);
+ m_active_pin_bitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, m_active_caption_text_colour);
// default metric values
#if defined(__WXMAC__)
case wxAUI_ART_BORDER_COLOUR: m_border_pen.SetColour(colour); break;
case wxAUI_ART_GRIPPER_COLOUR:
m_gripper_brush.SetColour(colour);
- m_gripper_pen1.SetColour(StepColour(colour, 40));
- m_gripper_pen2.SetColour(StepColour(colour, 60));
+ m_gripper_pen1.SetColour(wxAuiStepColour(colour, 40));
+ m_gripper_pen2.SetColour(wxAuiStepColour(colour, 60));
break;
default: wxFAIL_MSG(wxT("Invalid Metric Ordinal")); break;
}
if (pane.HasMaximizeButton())
clip_rect.width -= m_button_size;
- wxString draw_text = ChopText(dc, text, clip_rect.width);
+ wxString draw_text = wxAuiChopText(dc, text, clip_rect.width);
dc.SetClippingRegion(clip_rect);
dc.DrawText(draw_text, rect.x+3, rect.y+(rect.height/2)-(h/2)-1);
{
if (pane.state & wxAuiPaneInfo::optionActive)
{
- dc.SetBrush(wxBrush(StepColour(m_active_caption_colour, 120)));
- dc.SetPen(wxPen(StepColour(m_active_caption_colour, 70)));
+ dc.SetBrush(wxBrush(wxAuiStepColour(m_active_caption_colour, 120)));
+ dc.SetPen(wxPen(wxAuiStepColour(m_active_caption_colour, 70)));
}
else
{
- dc.SetBrush(wxBrush(StepColour(m_inactive_caption_colour, 120)));
- dc.SetPen(wxPen(StepColour(m_inactive_caption_colour, 70)));
+ dc.SetBrush(wxBrush(wxAuiStepColour(m_inactive_caption_colour, 120)));
+ dc.SetPen(wxPen(wxAuiStepColour(m_inactive_caption_colour, 70)));
}
// draw the background behind the button