Example #1
0
void Fl_Tool_Bar::draw()
{
    int n;

    if(opened())
    {
        // make it not draw the inside label:
        int saved = flags(); align(FL_ALIGN_TOP);

        if(damage() & ~FL_DAMAGE_CHILD) {
            draw_frame();
            fl_push_clip(box()->dx(), box()->dy(), w()-box()->dw()-(m_menubut->visible()?20:0), h()-box()->dh());
            for (n = children(); n--;) draw_child(*child(n));
            draw_box();
            draw_inside_label();
            fl_pop_clip();

            if(m_menubut->visible()) {
                fl_push_clip(w()-box()->dw()-(m_menubut->visible()?20:0), box()->dy(), 30, h()-box()->dh());
                draw_child(*m_menubut);
                draw_box();
                fl_pop_clip();
            }

            for (n = 0; n < children(); n++) draw_outside_label(*child(n));
        } else {
            fl_push_clip(box()->dx(), box()->dy(), w()-box()->dw()-(m_menubut->visible()?20:0), h()-box()->dh());

            for(n = 0; n < children(); n++) {
                Fl_Widget& w = *child(n);
                if (w.damage() & FL_DAMAGE_CHILD_LABEL) {
                    draw_outside_label(w);
                    w.set_damage(w.damage() & ~FL_DAMAGE_CHILD_LABEL);
                }
                update_child(w);
            }

            fl_pop_clip();
        }

        flags(saved);

        if (damage() & (FL_DAMAGE_EXPOSE|FL_DAMAGE_HIGHLIGHT|FL_DAMAGE_ALL))
        {
            Fl_Flags f = 0;
            if (pushed) f.set(FL_VALUE);
            if (highlighted) f.set(FL_HIGHLIGHT);
            draw_glyph(0, 0, 0, glyph_size(), h(), f);
        }

    } else
        Fl_Bar::draw();
}
void Fl_Canvas::draw()
{
	Fl_Widget*const* a = array();

  	if (damage() & ~FL_DAMAGE_CHILD) // redraw the entire thing:
	{
		if (m_BG)
		{
			int X=0,Y=0;
			while (Y<w())
			{
				while (X<h())
				{
					m_BG->draw(parent()->x()+X,parent()->y()+Y);
#if FL_MAJOR_VERSION == 1 && FL_MINOR_VERSION == 0
					X+=m_BG->w;
#else
					X+=m_BG->w();
#endif
				}
#if FL_MAJOR_VERSION == 1 && FL_MINOR_VERSION == 0
 				Y+=m_BG->h;
#else
				Y+=m_BG->h();
#endif
				X=0;
			}
		}
		else
		{
			draw_box();
		}

		// draw minimised modules first
   	 	for (int i=children(); i--;)
		{
   			Fl_Widget& o = **a++;
			if (((Fl_DeviceGUI*)&o)->IsMinimised())
			{
   	 			draw_child(o);
   				draw_outside_label(o);

				std::vector<int>::iterator sel = std::find( m_Selection.m_DeviceIds.begin(), m_Selection.m_DeviceIds.end(), ((Fl_DeviceGUI*)&o)->GetID() );

				if (sel != m_Selection.m_DeviceIds.end())
				{
					fl_color(FL_YELLOW);
					fl_rect(o.x(), o.y(), o.w(), o.h());
				}
			}
		}

		DrawWires();

		// draw maximised modules on top of everything else
   	 	Fl_Widget*const* a = array();
		for (int i=children(); i--;)
		{
   			Fl_Widget& o = **a++;
			if (!((Fl_DeviceGUI*)&o)->IsMinimised())
			{
   	 			draw_child(o);
   				draw_outside_label(o);

				std::vector<int>::iterator sel = std::find( m_Selection.m_DeviceIds.begin(), m_Selection.m_DeviceIds.end(), ((Fl_DeviceGUI*)&o)->GetID() );

				if (sel != m_Selection.m_DeviceIds.end())
				{
					fl_color(FL_YELLOW);
					fl_rect(o.x(), o.y(), o.w(), o.h());
				}
			}
		}
	}
	else // only redraw the children that need it:
	{
		for (int i=children(); i--;) update_child(**a++);
  	}
	DrawSelection();
}