[prev in list] [next in list] [prev in thread] [next in thread]
List: sptk-commits
Subject: r1033 - trunk/src/gui
From: alexey () mail ! total-knowledge ! com
Date: 2009-10-28 8:56:01
Message-ID: courier.000000004AE80721.000010BE () mail ! total-knowledge ! com
[Download RAW message or body]
Author: alexey
Date: 2009-10-28 01:56:01 -0700 (Wed, 28 Oct 2009)
New Revision: 1033
Modified:
trunk/src/gui/CToolBar.cpp
Log:
Fixed CToolBar draw problems.
Modified: trunk/src/gui/CToolBar.cpp
===================================================================
--- trunk/src/gui/CToolBar.cpp 2009-10-28 06:22:21 UTC (rev 1032)
+++ trunk/src/gui/CToolBar.cpp 2009-10-28 08:56:01 UTC (rev 1033)
@@ -40,21 +40,24 @@
using namespace std;
using namespace sptk;
-CToolBar::CToolBar(CLayoutAlign layoutAlignment)
- : CGroup("",5,layoutAlignment) {
+CToolBar::CToolBar(CLayoutAlign layoutAlignment) :
+ CGroup("", 5, layoutAlignment)
+{
m_colapsed = false;
layoutSpacing(4);
box(FL_UP_BOX);
}
-CLayoutClient* CToolBar::creator(CXmlNode *node) {
+CLayoutClient* CToolBar::creator(CXmlNode *node)
+{
CToolBar* widget = new CToolBar(SP_ALIGN_TOP);
- widget->load(node,LXM_LAYOUTDATA);
+ widget->load(node, LXM_LAYOUTDATA);
return widget;
}
-CButton *CToolBar::addButton(CButtonKind buttonKind,Fl_Callback_p cb,const char \
*label,CLayoutAlign buttonAlign) {
- CButton *b = new CButton(buttonKind,buttonAlign,label);
+CButton *CToolBar::addButton(CButtonKind buttonKind, Fl_Callback_p cb, const char \
*label, CLayoutAlign buttonAlign) +{
+ CButton *b = new CButton(buttonKind, buttonAlign, label);
if (cb)
b->callback(cb);
return b;
@@ -63,32 +66,36 @@
#define HIDE_BAR_WIDTH 8
#define HIDE_BAR_WIDTH_COLLAPSED 30
-void CToolBar::resize(int xx,int yy,int ww,int hh) {
+void CToolBar::resize(int xx, int yy, int ww, int hh)
+{
if (m_colapsed) {
- Fl_Widget::resize(xx,yy,ww,HIDE_BAR_WIDTH+Fl::box_dh(box()));
+ Fl_Widget::resize(xx, yy, ww, HIDE_BAR_WIDTH+Fl::box_dh(box()));
} else {
- Fl_Widget::resize(xx,yy,ww,hh);
+ Fl_Widget::resize(xx, yy, ww, hh);
xx += HIDE_BAR_WIDTH;
ww -= HIDE_BAR_WIDTH;
- autoLayout(xx,yy,ww,hh,true);
+ getClientArea(xx, yy, ww, hh);
+ autoLayout(xx, yy, ww, hh, true);
}
}
-bool CToolBar::preferredSize(int& ww,int& hh) {
+bool CToolBar::preferredSize(int& ww, int& hh)
+{
if (m_colapsed) {
- hh = HIDE_BAR_WIDTH+Fl::box_dh(box());
- int wm = HIDE_BAR_WIDTH_COLLAPSED+Fl::box_dw(box());
+ hh = HIDE_BAR_WIDTH + Fl::box_dh(box());
+ int wm = HIDE_BAR_WIDTH_COLLAPSED + Fl::box_dw(box());
if (ww < wm)
ww = wm;
} else {
ww -= HIDE_BAR_WIDTH + 1;
- autoLayout(0,0,ww,hh,false);
+ autoLayout(0, 0, ww, hh, false);
ww += HIDE_BAR_WIDTH + 1;
}
return false;
}
-int CToolBar::handle(int event) {
+int CToolBar::handle(int event)
+{
if (event == FL_PUSH) {
int xzone = HIDE_BAR_WIDTH;
if (m_colapsed)
@@ -96,7 +103,7 @@
if (Fl::event_x() <= x() + xzone) {
m_colapsed = !m_colapsed;
- CLayoutManager *parentLayoutManager = dynamic_cast<CLayoutManager \
*>(parent()); + CLayoutManager *parentLayoutManager = \
dynamic_cast<CLayoutManager *> (parent());
//CLayoutManager *parentLayoutManager = dynamic_cast<CLayoutManager \
*>(window()); if (parentLayoutManager)
parentLayoutManager->relayoutControls();
@@ -109,29 +116,30 @@
return CGroup::handle(event);
}
-void CToolBar::draw() {
+void CToolBar::draw()
+{
int dx = Fl::box_dx(box());
int dy = Fl::box_dy(box());
int dh = Fl::box_dh(box());
- int xs = x()+dx+1;
- int ys = y()+dy+1;
- int hs = h()-dh-2;
+ int xs = ORIGIN_X + dx + 1;
+ int ys = ORIGIN_Y + dy + 1;
+ int hs = h() - dh - 2;
if (m_colapsed) {
draw_box();
//fl_draw_box(FL_THIN_UP_BOX,xs,ys,HIDE_BAR_WIDTH_COLLAPSED,hs,color());
//xs += 1;
//ys += 1;
int xe = xs + HIDE_BAR_WIDTH_COLLAPSED - 4;
- for (int xx = xs; xx < xe; xx+= 3) {
- fl_draw_box(FL_THIN_UP_BOX,xx,ys,2,2,FL_WHITE);
- fl_draw_box(FL_THIN_UP_BOX,xx+1,ys+3,2,2,FL_WHITE);
+ for (int xx = xs; xx < xe; xx += 3) {
+ fl_draw_box(FL_THIN_UP_BOX, xx, ys, 2, 2, FL_WHITE);
+ fl_draw_box(FL_THIN_UP_BOX, xx + 1, ys + 3, 2, 2, FL_WHITE);
}
} else {
CGroup::draw();
int ye = ys + hs - 2;
- for (int yy = ys; yy < ye; yy+= 3) {
- fl_draw_box(FL_THIN_UP_BOX,xs,yy,2,2,FL_WHITE);
- fl_draw_box(FL_THIN_UP_BOX,xs+3,yy+1,2,2,FL_WHITE);
+ for (int yy = ys; yy < ye; yy += 3) {
+ fl_draw_box(FL_THIN_UP_BOX, xs, yy, 2, 2, FL_WHITE);
+ fl_draw_box(FL_THIN_UP_BOX, xs + 3, yy + 1, 2, 2, FL_WHITE);
}
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic