void Fl_Value_Slider_Input::draw() {

  int sxx = x(); 
	int syy = y();
	int sww = w();
	int shh = h();

  int bxx = x();
	int byy = y();
	int bww = w();
	int bhh = h();

  int X = x();
	int Y = y();
	int W = w();
	int H = h();

	UNUSED(bxx); 
	UNUSED(byy);
	UNUSED(bhh);

  int border_size=Fl::box_dx(box());

  if (horizontal())
  {
    bww = textboxsize();
    UNUSED(bww);
    sxx += textboxsize(); 
    sww -= textboxsize();
    input.resize(X,Y,W-sww,shh);
  }
  else
  {
    fl_font(input.textfont(), input.textsize());
    syy += fl_height()+(border_size+1)*2; shh -= fl_height()+(border_size+1)*2;
    input.resize(X,Y,W,H-shh);
  }
  if (damage()&~FL_DAMAGE_CHILD)  input.clear_damage(FL_DAMAGE_ALL);
  input.box(box());
  input.color(FL_WHITE, selection_color());
  input.doDraw();
  input.resize(X,Y,W,H);
  input.clear_damage();
//  if (horizontal())   input.doDraw();
  clear_damage();
  draw_box(box(),sxx,syy,sww,shh,color());
  sxx+=border_size;
  syy+=border_size; 
  sww-=border_size*2;  
  shh-=border_size*2;
  if(border_size<2) {
    sxx++;
    syy++;
    sww--;
    shh--;
  }  
  Fl_Slider::draw(sxx,syy,sww,shh);
}
Beispiel #2
0
    void draw()
    {
        static int oX=0, oY=0;

        if(!tW) {
            fl_font(FL_HELVETICA_BOLD, 14);
            tW = int(fl_width(str));
        }

        if(!backing->get_offscreen())
            backing->draw(0,0);

        Pixmap id = backing->get_offscreen();

        int tX = (w()/2)-(tW/2);
        int bW = ball->width();
        int bH = ball->height();

        if(damage()!=FL_DAMAGE_VALUE) {

            fl_copy_offscreen(0, 0, w(), h(), id, 0, 0);

        } else {

            // Erase bg under text
            fl_copy_offscreen(tX, tY, tW, int(fl_height()), id, tX, tY);

            // Erase only area affected, by moving ball!
            int DX = dX>0 ? dX : -dX;
            int DY = dY>0 ? dY : -dY;
            DX+=2; DY+=2;

            // X axis
            if(dX>0) fl_copy_offscreen(oX,   Y-DY, dX,  bH+(DY*2), id, oX, Y-DY);
            else     fl_copy_offscreen(X+bW, Y-DY, -dX, bH+(DY*2), id, X+bW, Y-DY);

            // Y axis
            if(dY>0) fl_copy_offscreen(oX, oY,   bW+DX,  dY, id, oX, oY);
            else     fl_copy_offscreen(oX, Y+bH, bW+DX, -dY, id, oX, Y+bH);
        }

        if(blended) delete blended;
        // Do alphablend and draw it to screen
        if( (blended = ball->blend(backing, X,Y)) ) {
            blended->draw(X, Y);
        }

        // Draw string
        fl_draw(str, float(tX), float(tY+int(fl_height())));

        oX=X; oY=Y;
    }
void DiagramWindow::DrawBase(
    const unsigned int index,
    const RNAStructure::Base base,
    const float centerX,
    const float centerY,
    const float angleBase,
    const float angleDelta,
    const float radius)
{
    float angle1 = angleBase - (float)index * angleDelta;
    float xPosn1 = centerX + cos(angle1) * radius;
    float yPosn1 = centerY - sin(angle1) * radius - fl_descent() + 0.5 * fl_height();

    fl_color(128, 128, 128);
    switch (base)
    {
	case RNAStructure::A:
	    fl_draw("A", xPosn1 - fl_width('A') * 0.5f, yPosn1);
	    break;
	case RNAStructure::C:
	    fl_draw("C", xPosn1 - fl_width('C') * 0.5f, yPosn1);
	    break;
	case RNAStructure::G:
	    fl_draw("G", xPosn1 - fl_width('G') * 0.5f, yPosn1);
	    break;
	case RNAStructure::U:
	    fl_draw("U", xPosn1 - fl_width('U') * 0.5f, yPosn1);
	    break;
    }
}
Beispiel #4
0
void Fl_ProgressBar::draw()
{
    int bdx, bdy;
    double pct;
    if(damage() & FL_DAMAGE_ALL) draw_box();

    int X = 0, Y = 0;
    bdx = box()->dx();
    bdy = box()->dy();

    fl_color(selection_color());
    if(mPresent > mMax)
        mPresent = mMax;
    if(mPresent < mMin)
        mPresent = mMin;
    pct = (mPresent - mMin) / mMax;
    fl_rectf(X + bdx, Y + bdy, (int)(((double)w() - 2*bdx) * pct), h() - (2*bdy + 1));
    if(mShowPct)
    {
        char buffer[30];
        sprintf(buffer, "%d%%", (int) (pct * 100));
        fl_color(textcolor());
        fl_font(this->label_font(), this->label_size());
        fl_draw(buffer, X + (w() - fl_width(buffer))/2, Y + fl_height() + (((h() - 2*bdy) - fl_height())/2));
    }
}
Beispiel #5
0
void FontDisplay::draw() {
  draw_box();
  int ix = 0, iy = 0, iw = w(), ih = h();
  box()->inset(ix, iy, iw, ih);
  fl_push_clip(ix, iy, iw, ih);
  const char* saved_encoding = fl_encoding();
  if (encoding) fl_encoding(encoding);
  fl_font(font, size);
  fl_color(FL_BLACK);
  char buffer[32];
//#if HAVE_XUTF8
  char outbuf[64];
//#endif
  for (int Y = 1; Y < 8; Y++) {
      for (int X = 0; X < 32; X++) buffer[X] = (32*Y+X);
//#if HAVE_XUTF8
      int len = fl_latin12utf((uint8*)buffer, 32, outbuf);
      fl_draw(outbuf, len, 3, 3+fl_height()*Y);
//#else
//      fl_draw(buffer, 32, 3, 3+fl_height()*Y);
//#endif
  }
  fl_encoding(saved_encoding);
  fl_pop_clip();
}
Beispiel #6
0
void Fl_Input_Browser::preferred_size(int& w, int& h) const
{
    fl_font(text_font(), float(text_size()));
    h = int(fl_height()+fl_descent()) + box()->dh() + 2;
    if(m_input.maximum_size()>0) {
        int ms = m_input.maximum_size() + 1;
        if (ms > 50) ms = 50;
        w = ms * (int)fl_width((unsigned int)'W') + h;
    }
}
Beispiel #7
0
void console_widget_t::update_font(void)
{
	Fl::set_fonts(NULL);

	fl_font(font_name, font_size);

	// Calculate constats for this font
	letter_x = (int)fl_width('A');
	letter_y = (int)fl_height();

	if(console)
	{
		fit_x = letter_x * console->config.x;
		fit_y = letter_y * console->config.y;
		damage_console(0, 0, console->config.x, console->config.y);
	}
}
void Fl_Rotated_Text::set(const char *text, Fl_Font font, int size, uchar align, int rotation){

  uncache();
  if(alloc_array) delete[] ar2;
  ar2 = 0;
  array = 0;
  alloc_array = 0;


  delete[] text_;
  text_=0;
  font_ = font;
  size_ = size;
  align_ = align;

  if(!text || !(*text)){
    w(0);
    h(0);
    return;
  }

  text_ = new char[strlen(text) + 1];
  strcpy(text_, text);

  if(rotation >9)
    rot_ = (uchar)(((rotation+45)/90) % 4);
  else
    rot_ = (uchar) (rotation & 3);
  int w_ = 0;
  int h_ = 0;
  int old_font = fl_font();
  int old_size = fl_size();
  fl_font(font,size);
  fl_measure(text_,w_,h_,0); // assure that w() and h() are always available
  fl_font(old_font,old_size);
  h_ += fl_height()/2;
  if(rot_ & 1){
    w(h_);
    h(w_);
  }else{
    w(w_);
    h(h_);
  }
 
};
Beispiel #9
0
void Text_Display::dirty()
{
    Abstract_Text_Widget::dirty();

    _widget->textfont(text_font());
    _widget->textsize(Style::global()->font_size());
    _widget->textcolor(text_color());

    size_hint(
        V2i(
            //Math::max(
            //  Style::global()->size_button(),
            //  base::string_size(_size_string)
            //),
            Font::string_width(_size_string),
            fl_height()
        ) +
        Style::global()->margin_text() * 2 +
        frame_size() * 2);
}
Beispiel #10
0
void console_widget_t::set_console(co_console_t* _console)
{
	console = _console;

	fl_font(FL_SCREEN, font_size);

	// Calculate constats for this font
	letter_x = (int)fl_width('A');
	letter_y = (int)fl_height();

	fit_x = letter_x * console->config.x;
	fit_y = letter_y * console->config.y;

	cell_limit = &console->screen[console->config.y * console->config.x];

	cursize_tab[CO_CUR_UNDERLINE]	= letter_y / 6 + 1; /* round up 0.1667 */
	cursize_tab[CO_CUR_LOWER_THIRD]	= letter_y / 3;
	cursize_tab[CO_CUR_LOWER_HALF]	= letter_y / 2;
	cursize_tab[CO_CUR_TWO_THIRDS]	= (letter_y * 2) / 3 + 1; /* round up 0.667 */
	cursize_tab[CO_CUR_BLOCK]	= letter_y;
	cursize_tab[CO_CUR_DEF]		= cursize_tab[console->config.curs_type_size];
}
Beispiel #11
0
float gl_height() {return fl_height();}
Beispiel #12
0
// Anybody can call this to force the label to draw anywhere, this is
// used by Fl_Group and Fl_Tabs to draw outside labels:
void Fl_Widget::draw_label(int X, int Y, int W, int H, Fl_Flags flags) const
{
	fl_font(label_font(), float(label_size()));
	if (!active_r()) flags.set(FL_INACTIVE);

	Fl_Color color;
    // Figure out if alignment puts the label inside the widget:
	if (!(this->flags()&15) || (this->flags() & FL_ALIGN_INSIDE))
	{
        // yes, inside label is affected by selection or highlight:
		if (flags&FL_SELECTED)
			color = selection_text_color();
		else if (flags&FL_HIGHLIGHT && highlight_label_color())
		    color = highlight_label_color();
		else
			color = label_color();
		if (focused()) flags.set(FL_SELECTED);
	}
	else
	{
		color = label_color();
	}

	if (flags & FL_ALIGN_CLIP) fl_push_clip(X, Y, W, H);

	if (image_)
	{
		fl_color(fl_inactive(color, flags));

		if(flags & FL_ALIGN_TILED || flags & FL_ALIGN_SCALE) {
			image_->draw(X, Y, W, H, flags);
		} else {

			int w = W;
			int h = H;
			image_->measure(w, h);

            // If all the flags are off, draw the image and label centered "nicely"
            // by measuring their total size and centering that rectangle:
			if (!(flags & (FL_ALIGN_LEFT|FL_ALIGN_RIGHT|FL_ALIGN_TOP|FL_ALIGN_BOTTOM|
						FL_ALIGN_INSIDE)) && !label_.empty())
			{
				int d = (H-int(h+fl_height()))>>1;
				if (d >= 0)
				{
                    // put the image atop the text
                                    Y += d;
                                    H -= d;
                                    flags.set(FL_ALIGN_TOP);
				}
				else
				{
                    // put image to left
					int text_w = W; int text_h = H;
					fl_measure(label_.c_str(), text_w, text_h, flags);
					int d = (W-(h+text_w))>>1;
					if (d > 0) {X += d; W -= d;}
					flags.set(FL_ALIGN_LEFT);
				}
			}

			int cx,cy;               // point in image to put at X,Y

			if (flags & FL_ALIGN_RIGHT) {
				cx = w-W;
				if (flags & FL_ALIGN_LEFT && cx < 0) cx = 0;
			}
			else if (flags & FL_ALIGN_LEFT) cx = 0;
			else cx = w/2-W/2;

			if (flags & FL_ALIGN_BOTTOM) {
				cy = h-H;
				if (flags & FL_ALIGN_TOP && cy < 0) cy = 0;
			}
			else if (flags & FL_ALIGN_TOP) cy = 0;
			else cy = h/2-H/2;

			image_->draw(X-cx, Y-cy, W, H, 0,0,0,0,flags);

            // figure out the rectangle that remains for text:
			if (flags & FL_ALIGN_LEFT) { X += (w+2); W -= (w+4); }
			else if (flags & FL_ALIGN_RIGHT) W -= (w+4);
			else if (flags & FL_ALIGN_TOP) {Y += h; H -= h;}
			else if (flags & FL_ALIGN_BOTTOM) H -= h;
			else { /*flags |= FL_ALIGN_TOP;*/
				Y += (h-cy); H -= (h-cy);
			}
		}
	}
int Fl_Value_Slider_Input::handle(int event) {
  int mx = Fl::event_x();
  int my = Fl::event_y();

  static int indrag = 0;
  static int sldrag = 0;
  int sxx = x(), syy = y(), sww = w(), shh = h();
  int border_size=Fl::box_dx(box());
  if (horizontal())
  {
    sxx += textboxsize(); sww -= textboxsize();
  }
  else
  {
    fl_font(input.textfont(), input.textsize());
    syy += fl_height()+(border_size+1)*2; shh -= fl_height()+(border_size+1)*2;
  } 
  if( !indrag && ( !sldrag || !((mx>=sxx && mx<=(sxx+sww)) &&
       (my>=syy && my<=(syy+shh))))) 
  {  
    indrag=0;     
	  switch(event)
    {
    case FL_PUSH:
    case FL_DRAG:
      sldrag=1;
      break;
    case FL_FOCUS:
      input.take_focus();
      break;
    case FL_UNFOCUS:
      redraw();
      break;
    case FL_KEYBOARD:
      switch (Fl::event_key())
      {
      case FL_Up:
        if (!horizontal()) indrag=1 ;
        break;
      case FL_Down:
        if (!horizontal()) indrag=1 ;
		    break;
 	    case FL_Left:
        if (horizontal()) indrag=1 ;
		    break;
	    case FL_Right:
        if (horizontal()) indrag=1 ;
		    break;
	    }
	    break;
    default:
      sldrag=0;
    }
    if(!indrag)
    {
      input.type(step()>=1.0 ? FL_INT_INPUT : FL_FLOAT_INPUT);
      return input.handle(event);
    }
  } 
  switch (event) 
  {
  case FL_PUSH:
    ix = mx;
    drag = Fl::event_button();
    indrag=1;
    return Fl_Slider::handle(event,sxx,syy,sww,shh);
  case FL_DRAG:
  	indrag=1;
  	return Fl_Slider::handle(event,sxx,syy,sww,shh);
  case FL_RELEASE:
    //   if (!step()) goto DEFAULT;
    if (value() != previous_value() || !Fl::event_is_click())
    {
      handle_release();
    }
    else
    {
      input.handle(FL_PUSH);
      input.handle(FL_RELEASE);
    }
    indrag=0;
    return 1;
  case FL_FOCUS:
    indrag=0;
    input.take_focus();
    return Fl_Slider::handle(event,sxx,syy,sww,shh);
  default:
    indrag=0;
    input.type(step()>=1.0 ? FL_INT_INPUT : FL_FLOAT_INPUT);
    input.handle(event);
    return Fl_Slider::handle(event,sxx,syy,sww,shh);
  }
}
Beispiel #14
0
/*
============================================================================
Class constructor
============================================================================
*/
VTTpddServerLog::VTTpddServerLog(int w, int h, const char* title) :
	Fl_Double_Window(w, h, title)
{
	Fl_Box*				o;
	Fl_Button*			b;
	Fl_Group*			g;

	// Initialize everything
	m_pServer = NULL;
	m_enabled = TRUE;
	m_lastWasRx = FALSE;
	m_rxCount = m_txCount = 0;
	m_maxLogEntries = 8192;
	m_nextRef = 1;
	m_callbackActive = FALSE;
	m_autoScroll = TRUE;

	// Define our default colors
	m_colors.background = FL_BLACK;
	m_colors.ref = FL_WHITE;
	m_colors.rxLabel = FL_YELLOW;
	m_colors.txLabel = (Fl_Color) 221;
	m_colors.rxHex = fl_color_average(FL_DARK_GREEN, FL_WHITE, (float) 0.8);
	m_colors.txHex = fl_color_average((Fl_Color) 221, FL_WHITE, (float) 0.5);
	m_colors.rxAscii = FL_GREEN;
	m_colors.txAscii = (Fl_Color) 221;
	m_fontSize = 14;

	fl_font(FL_COURIER, m_fontSize);
	m_height = fl_height();
	m_width = (int) fl_width("W");

	// ===============================
	// Now create the controls we need
	// ===============================

	// Create a menu
	m_pMenu = new Fl_Menu_Bar(0, 0, w, MENU_HEIGHT-2);
	m_pMenu->menu(gServerLog_menuitems);

	// Create a window for the log
	m_pLog = new Fl_Double_Window(10, MENU_HEIGHT+10, w-20-15, h-MENU_HEIGHT-50, "");
	//m_pLog->color(FL_BLACK);
	m_pLog->end();
	m_pLog->hide();

	// Create a scrollbar
	m_pScroll = new Fl_Scrollbar(w-10-15, MENU_HEIGHT+10, 15, h-MENU_HEIGHT-50, "");
	m_pScroll->callback(cb_scroll_log, this);

	// Create a resizing group
	g = new Fl_Group(0, h-35, w, 35, "");

	// Create an auto scroll checkbox
	m_pAutoScroll = new Fl_Check_Button(20, h-37, 110, 20, "Auto scroll");
	m_pAutoScroll->callback(cb_autoscroll, this);

	// Create a disable log checkbox
	m_pDisable = new Fl_Check_Button(20, h-21, 110, 20, "Disable log");
	m_pDisable->callback(cb_disable_log, this);

	// Create a Save button
	b = new Fl_Button(150, h-30, 80, 20, "Save");
	b->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE);
	b->callback(cb_save_log, this);

	// Create a Load button
	b = new Fl_Button(250, h-30, 80, 20, "Load");
	b->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE);
	b->callback(cb_load_log, this);

	// Create a clear button
	b = new Fl_Button(350, h-30, 80, 20, "Clear");
	b->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE);
	b->callback(cb_clear_log, this);
	
	// Make the group resizable
	o = new Fl_Box(440, 350, 5, 5, "");
	g->resizable(o);
	g->end();

	// Make the window resizable
	o = new Fl_Box(20, MENU_HEIGHT + 30, 5, 5, "");
	resizable(o);

	// Set the scrollbar size
	SetScrollSizes();
}
Beispiel #15
0
 FL_EXPORT_C(int,flc_set_height)(int font,int size){
   return fl_height(font,size);
 }
Beispiel #16
0
 FL_EXPORT_C(int,flc_height)( ){
   return fl_height();
 }
Beispiel #17
0
void Fl_Combo_Box::preferred_size(int& w, int& h) const
{
    fl_font(text_font(), float(text_size()));
    h = int(fl_height()+fl_descent()) + box()->dh() + 2;
}
Beispiel #18
0
 void preferred_size(int& w,int& h) const { 
     fl_font(parent()->text_font(),parent()->text_size());
     h = int(fl_height()+fl_descent()) + 2;
     w = 15 + box()->dw() + 1; 
 }
Beispiel #19
0
void tabbar::draw() {
    const u32 startx = x();
    const u32 endx = x() + w() - 1;

    const u32 gradarea = h() - 2;
    u32 i, j;

    // bg
    u32 r1 = 63, g1 = 72, b1 = 81;
    u32 r2 = 38, g2 = 48, b2 = 59;
    for (i = 0; i <= gradarea; i++) {
        const float pos = i / (float) gradarea;

        fl_color(mix(r1, r2, pos),
                 mix(g1, g2, pos),
                 mix(b1, b2, pos));

        const u32 posy = y() + 1 + i;
        fl_line(startx, posy, endx, posy);
    }

    // Borders
    fl_color(37, 46, 52);
    fl_line(startx, y(), endx, y());
    fl_line(startx, y() + h() - 1, endx, y() + h() - 1);

    // Tabs
    u32 max;
    u32 tabw = calctabw(&max, w());

    bool highborder = false;
    if ((mousex - x()) % tabw > tabw / 2)
        highborder = true;

    u32 posx = x();
    const u32 lowy = y();
    const u32 highy = y() + h() - 1;
    for (i = 0; i < max; i++) {
        bool hover = false;
        // Borders
        fl_color(FL_BLACK);
        if (!i)
            fl_line(posx, lowy, posx, highy);
        fl_line(posx + tabw, lowy, posx + tabw, highy);

        // Bg
        r1 = 83, g1 = 92, b1 = 101;
        r2 = 58, g2 = 68, b2 = 79;

        if (i == g->curtab) {
            r1 = 100, g1 = 160, b1 = 191;
            r2 = 42, g2 = 100, b2 = 125;
        } else if ((mousein && mousex >= posx && mousex <= (posx + tabw - 1)) ||
                   (!firstpress && longorder.size() && longorder[longpress] == i)) {
            r1 = 150, g1 = 150, b1 = 191;
            r2 = 100, g2 = 100, b2 = 155;
            hover = true;
        }

        if (dragging && mousein && mousex >= posx && mousex <= (posx + tabw - 1)) {
            fl_color(FL_WHITE);
            if (!highborder)
                fl_line(posx, lowy, posx, highy);
            else
                fl_line(posx + tabw, lowy, posx + tabw, highy);
        }

        for (j = 0; j <= gradarea; j++) {
            const float pos = j / (float) gradarea;

            fl_color(mix(r1, r2, pos),
                     mix(g1, g2, pos),
                     mix(b1, b2, pos));

            const u32 posy = y() + 1 + j;
            fl_line(posx + 1, posy, posx + tabw - 1, posy);
        }

        // Icon
        Fl_Image *img = g->tabs[i].icon;
        if (!img)
            img = Fl_Shared_Image::get("newtab.png");

        const u32 imgy = y() + (h() - 16) / 2;
        img->draw(posx + 4, imgy, 16, 16);

        // Text
        fl_color(200, 200, 200);
        if (i == g->curtab)
            fl_color(FL_WHITE);
        else if (hover)
            fl_color(230, 230, 230);
        fl_font(labelfont(), labelsize());

        char tmp[80];
        memset(tmp, 0, 80);
        strncpy(tmp, g->tabs[i].title(), 79);

        int textw = 0, texth = 0;
        fl_measure(tmp, textw, texth, 0);

        const u32 textarea = tabw - 2 - 8 - 16 - 4;
        while ((u32) textw >= textarea) {
            // Shorten it until it fits
            const u32 len = strlen(tmp) - 1;
            tmp[len] = '\0';
            tmp[len - 1] = '.';
            tmp[len - 2] = '.';
            tmp[len - 3] = '.';

            textw = texth = 0;
            fl_measure(tmp, textw, texth, 0);
        }

        const u32 texty = y() - fl_descent() + fl_height() + (h() - fl_height())/2;
        fl_draw(tmp, posx + 2 + 8 + 16, texty);

        posx += tabw;
    }
}