Esempio n. 1
0
	void Box::draw_lines() const{
		if(fill_color().visibility()) {    // fill
			fl_color(fill_color().as_int());
			fl_rectf(point(0).x + r, point(0).y, w - r - r, h);								// 丸角四角形内の縦の長方形
			fl_rectf(point(0).x, point(0).y + r, w, h - r - r);								// 丸角四角形内の横の長方形
			fl_pie(point(0).x + w - r - r, point(0).y, r + r, r + r, 0, 90);				// 右上円
			fl_pie(point(0).x, point(0).y, r + r, r + r, 90, 180);							// 左上円
			fl_pie(point(0).x, point(0).y + h - r - r, r + r, r + r, 180, 270);				// 左下円
			fl_pie(point(0).x + w - r - r, point(0).y + h - r - r, r + r, r + r, 270, 360);	// 右下円
			fl_color(color().as_int());    // reset color
		}

		if(color().visibility()) {    // lines on top of fill
			fl_color(color().as_int());
			fl_line(point(0).x + r, point(0).y, point(0).x + w - r, point(0).y);			// 上線
			fl_line(point(0).x + r, point(0).y + h, point(0).x + w - r, point(0).y + h);	// 下線
			fl_line(point(0).x, point(0).y + r, point(0).x, point(0).y + h - r);			// 左線
			fl_line(point(0).x + w, point(0).y + r, point(0).x + w, point(0).y + h - r);	// 右線
			fl_arc(point(0).x + w - r - r, point(0).y, r + r, r + r, 0, 90);				// 右上角丸
			fl_arc(point(0).x, point(0).y, r + r, r + r, 90, 180);							// 左上角丸
			fl_arc(point(0).x, point(0).y + h - r - r, r + r, r + r, 180, 270);				// 左下角丸
			fl_arc(point(0).x + w - r - r, point(0).y + h - r - r, r + r, r + r, 270, 360);	// 右下角丸
		}

		int ofnt = fl_font();
		int osz = fl_size();
		fl_font(fnt.as_int(), fnt_sz);
		fl_draw(lab.c_str(), point(0).x + r, point(0).y + h - r);
		fl_font(ofnt, osz);
	}
Esempio n. 2
0
void Text::draw_lines() const
{
    int ofnt = fl_font();
    int osz = fl_size();
    fl_font(fnt.as_int(),fnt_sz);
    fl_draw(lab.c_str(),point(0).x,point(0).y);
    fl_font(ofnt,osz);
}
Esempio n. 3
0
/*
 * fl_print().
 * Prints the chunks in the order they're encountered on the free list.
 */
void fl_print(void)
// pre: FreeList has been initialized.
// post: prints chunks appearing on the free list to stdout
{
  init();
  int s = fl_size(FreeList);
  printf("Free list contains %d chunks:\n",s);
  chunk *p = FreeList->next;
  int i = 0;
  while (p != FreeList) {
    printf(" %d. ",i); ck_print(p);
    i++;
    p = p->next;
  }
}
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_);
  }
 
};
Esempio n. 5
0
void DesktopIcon::update_label_size(void) {
	labelsize(gsettings->label_fontsize);
    lwidth = gsettings->label_maxwidth;
    lheight= 0;

	/*
	 * make sure current font size/type is set (internaly to fltk)
	 * so fl_measure() can correctly calculate label width and height
	 */
	int old = fl_font();
	int old_sz = fl_size();
	fl_font(labelfont(), labelsize());

	fl_measure(label(), lwidth, lheight, align());

	fl_font(old, old_sz);

    lwidth += 12;
	lheight += 5;
}
Esempio n. 6
0
void DiagramWindow::RedrawBuffer(RNAStructure** structures, const int numStructures, const int resolution)
{
    fl_color(FL_BLACK);
    fl_rectf(0, 0, resolution, resolution);

    int priorFont = fl_font();
    int priorFontSize = fl_size();
    fl_font(priorFont, 10);

    fl_line_style(0);

    if (numStructures == 1)
	Draw1(structures, resolution);
    else if (numStructures == 2)
	Draw2(structures, resolution);
    else if (numStructures == 3)
	Draw3(structures, resolution);

    fl_font(priorFont, priorFontSize);
}
Esempio n. 7
0
void gl_font(Fl_Font font, float size)
{
    fl_font(font, size);         // necessary so fl_measure() works
    size = fl_size();            // get the rounded value
    if (!current || current->font != font || current->size != size)
    {
        FontSize** p = &root;
        while (*p)
        {
            if (font < (*p)->font) p = &((*p)->left);
            else if (font > (*p)->font) p = &((*p)->right);
            else if (size < (*p)->size) p = &((*p)->left);
            else if (size > (*p)->size) p = &((*p)->right);
            else {current = *p; goto GOTIT;}
        }
        *p = current = new FontSize;
        current->font = font;
        current->size = size;
        current->left = current->right = 0;
        current->listbase = glGenLists(256);
#ifdef _WIN32
        int base = fl_textmetric()->tmFirstChar;
        int size = fl_textmetric()->tmLastChar - base + 1;
        HDC hdc = GetDC(0);
        HFONT oldFid = (HFONT)SelectObject(hdc, fl_xfont());
        wglUseFontBitmaps(hdc, base, size, current->listbase+base);
        SelectObject(hdc, oldFid);
#else
        XFontStruct* xfont = fl_xfont();
#if USE_XFT
        current->xfont = xfont;
#endif
        int base = xfont->min_char_or_byte2;
        int size = xfont->max_char_or_byte2-base+1;
        glXUseXFont(xfont->fid, base, size, current->listbase+base);
#endif
    }
GOTIT:
    glListBase(current->listbase);
}
void Fl_Rotated_Text::draw(int x, int y, int W, int H, int cx, int cy){
  
  if(!text_) return;
  if(!rot_){ // standard drawing)
    int olf_font = fl_font();
    int old_size = fl_size();
    fl_font(font_,size_);
    fl_push_clip(x, y, W-cx, H-cy);
    fl_draw(text_, x - cx, y - cy, w(), h(), (Fl_Align)align_, (Fl_Image *) 0, 0);
    fl_pop_clip();
    fl_font(olf_font, old_size);
    return;
  }
  if(!array){ // not drawn yet, building rotated bitmap "cache"
    int w_, h_;
    if(rot_ & 1){
      w_ = h();
      h_ = w();
    }else{
      w_ = w();
      h_ = h();
    }
    int bsize = ((w()+7)/8)  * h();
    array = ar2 = new uchar[bsize];
    alloc_array = 1;
    //memset(ar2, 0, bsize);

    int old_font = fl_font();
    int old_size = fl_size();

    Fl_Color old_color = fl_color();
    Fl_Offscreen offscreen = fl_create_offscreen(w_,h_);
    fl_begin_offscreen(offscreen);
    fl_color(0x000000);
    fl_rectf(0,0,w_,h_);
    fl_font(font_, size_);
    fl_color(0x00FF0000); // we use green color to plot to the offscreen

    fl_draw(text_,0, 0, w_, h_, (Fl_Align)align_, (Fl_Image *)0, 0);
    uchar * rgb = fl_read_image(0, 0, 0, w_, h_, 0);
    fl_end_offscreen();
    fl_delete_offscreen(offscreen);
    fl_font(old_font, old_size);
    fl_color(old_color);

    int i,j;

    uchar * start = rgb;
    int i_iter = 0;
    int j_iter = 0;
    switch(rot_){
    case 3:
      start +=  w_ * (h_ - 1)*3 + 1;
      i_iter = - w_ * 3;
      j_iter =  3;
      break;
    case 2:
      start +=  (w_ * h_ - 1)*3 + 1;
      i_iter = -3;
      j_iter = - w_ * 3;
      break;
    case 1:
      start +=  (w_ - 1)*3 + 1;
      i_iter = w_ * 3;
      j_iter = -3;
      break;
    }

    uchar * stj = start;
    uchar c;
    uchar * where;
    uchar * sti;

    for(j = 0; j< h(); j++, stj += j_iter){
      uchar val = 0;
      c = 8;
      where = ar2 + j*((w()+7)/8);
      for(i = 0, sti = stj; i< w(); i++, sti +=i_iter){
        if(*sti >127) val |= c;
        if(c & (uchar)128){ // pushing value to the array
          *where = val;
          where++;
          c =1;
          val = 0;
        }else
          c <<=1;
      }
      if(w() % 8){ //need to push last byte
        * where = val;
        where++;
      }
    }
    
    delete[] rgb;
  }

  Fl_Bitmap::draw(x, y, W, H, cx, cy); // finaly drawing the bitmap

};
Esempio n. 9
0
void DesktopIcon::draw(void) { 
	// draw_box(FL_UP_BOX, FL_BLACK);

	if(image() && (damage() & FL_DAMAGE_ALL)) {
		Fl_Image* im = image();

		/* center image in the box */
		int ix = (w()/2) - (im->w()/2);
		int iy = (h()/2) - (im->h()/2);
		ix += x();
		iy += y();

		/* darker_img is always present if image() is present */
		if(is_focused())
			darker_img->draw(ix, iy);
		else
			im->draw(ix, iy);

		E_DEBUG(E_STRLOC ": DesktopIcon icon redraw\n");
	}

	if(gsettings->label_draw && (damage() & (FL_DAMAGE_ALL | EDAMAGE_CHILD_LABEL))) {
		int X = x() + w()-(w()/2)-(lwidth/2);
		int Y = y() + h() + LABEL_OFFSET;

		Fl_Color old = fl_color();

		if(!gsettings->label_transparent) {
			fl_color(gsettings->label_background);
			fl_rectf(X, Y, lwidth, lheight);
		}

		int old_font = fl_font();
		int old_font_sz = fl_size();

		/* draw with icon's font */
		fl_font(labelfont(), labelsize());

		/* pseudo-shadow */
		fl_color(FL_BLACK);
		fl_draw(label(), X+1, Y+1, lwidth, lheight, align(), 0, 0);

		fl_color(gsettings->label_foreground);
		fl_draw(label(), X, Y, lwidth, lheight, align(), 0, 0);

		/* restore old font */
		fl_font(old_font, old_font_sz);

		if(is_focused()) {
			/* draw focused box on our way so later this can be used to draw customised boxes */
			fl_color(gsettings->label_foreground);
			fl_line_style(FL_DOT);

			fl_push_matrix();
			fl_begin_loop();
				fl_vertex(X, Y);
				fl_vertex(X + lwidth, Y);
				fl_vertex(X + lwidth, Y + lheight);
				fl_vertex(X, Y + lheight);
				fl_vertex(X, Y);
			fl_end_loop();
			fl_pop_matrix();

			/* revert to default line style */
			fl_line_style(0);
		}

		/* revert to old color whatever that be */
		fl_color(old);
		E_DEBUG(E_STRLOC ": DesktopIcon label redraw\n");
	}
}
Esempio n. 10
0
 FL_EXPORT_C(Fl_Fontsize,flc_size)( ){
   return fl_size();
 }
Esempio n. 11
0
void DiagramWindow::draw()
{
    Fl_Color priorColor = fl_color();
    int priorFont = fl_font();
    int priorFontSize = fl_size();

    fl_color(color());
    fl_rectf(0, 0, w(), h());
    fl_color(priorColor);

    Fl_Window::draw();

    // Get the structures. Be sure the reference structure is first.
    RNAStructure* sequences[3];
    StructureManager* structureManager = RNAStructViz::GetInstance()->GetStructureManager();
    for (int j = 0; j < 3; ++j)
    {
	if ((int)(m_menuItems[m_menus[j]->value()].user_data()) == -1)
	{
	    sequences[j] = 0;
	}
	else
	{
	    sequences[j] = structureManager->GetStructure((int)(m_menuItems[m_menus[j]->value()].user_data()));
	}
    }

    int numToDraw = 0;
    if (sequences[0])
    {
	if (sequences[1])
	{
	    if (sequences[2])
	    {
		numToDraw = 3;
		DrawKey3();
	    }
	    else
	    {
		numToDraw = 2;
		DrawKey2(0, 1);
	    }
	}
	else
	{
	    if (sequences[2])
	    {
		sequences[1] = sequences[2];
		DrawKey2(0, 2);
		numToDraw = 2;
	    }
	    else
	    {
		DrawKey1(0);
		numToDraw = 1;
	    }
	}
    }
    else
    {
	if (sequences[1])
	{
	    if (sequences[2])
	    {
		sequences[0] = sequences[1];
		sequences[1] = sequences[2];
		DrawKey2(1, 2);
		numToDraw = 2;
	    }
	    else
	    {
		sequences[0] = sequences[1];
		DrawKey1(1);
		numToDraw = 1;
	    }
	}
	else
	{
	    if (sequences[2])
	    {
		sequences[0] = sequences[2];
		DrawKey1(2);
		numToDraw = 1;
	    }
	    else
	    {
		numToDraw = 0;
	    }
	}
    }

    if (m_redrawStructures)
    {
	{
	    fl_begin_offscreen(m_offscreenImage[0]);
	    RedrawBuffer(sequences, numToDraw, 2048);
	    fl_read_image(m_imageData[0], 0, 0, 2048, 2048);
	    fl_end_offscreen();
	}

	{
	    fl_begin_offscreen(m_offscreenImage[1]);
	    RedrawBuffer(sequences, numToDraw, 1024);
	    fl_read_image(m_imageData[1], 0, 0, 1024, 1024);
	    fl_end_offscreen();
	}

	m_glWindow->UpdateTexture();
	m_redrawStructures = false;
    }

    m_glWindow->redraw();

    fl_color(priorColor);
    fl_font(priorFont, priorFontSize);
    fl_line_style(0);
}
Esempio n. 12
0
// Draw tick marks. These lines cross the passed rectangle perpendicular to
// the slider direction. In the direction parallel to the slider direction
// the box should have the same size as the area the slider moves in.
void Fl_Slider::draw_ticks(int x, int y, int w, int h, int min_spacing)
{
    int x1, y1, x2, y2, dx, dy;
    if (horizontal())
    {
        x1 = x2 = x+(slider_size_-1)/2; dx = 1;
        y1 = y; y2 = y + h; dy = 0;
    }
    else
    {
        x1 = x; x2 = x+w; dx = 0;
        y1 = y2 = y+(slider_size_-1)/2; dy = 1;
        w = h;
    }
    if (w <= 0) return;
    double A = minimum();
    double B = maximum();
    if (A > B) {A = B; B = minimum();}

    // Figure out approximate size of min_spacing at zero:
    double derivative;
    if (!log())
    {
        derivative = (B-A)/w;
    }
    else if (A > 0)
    {
        // log slider
        derivative = A/w*20;
    }
    else
    {
        // squared slider, derivative at edge is zero, use value at 1 pixel
        derivative = B/(w*w)*30;
        if (A < 0) derivative *= 4;
    }
                                 // fix for fill sliders
    if (min_spacing < 1) min_spacing = 10;
    derivative *= min_spacing;
    if (derivative < step()) derivative = step();

    // Find closest multiple of 10 larger than spacing:
    int num = 1;
    while (num < derivative) num *= 10;
    int denom = 10;
    while (num >= derivative*denom) denom *= 10;
    denom /= 10;

    for (int n = 0; ; n++)
    {
        // every ten they get further apart for log slider:
        if (log() && n > 10) {n = 2; num *= 10;}
        double v = double(num*n)/denom;
        if (v > fabs(A) && v > fabs(B)) break;
        int small = n%5 ? 2 : 0;
        if (v >= A && v <= B)
        {
            int t = slider_position(v, w);
            fl_line(x1+dx*t+dy*small, y1+dy*t+dx*small, x2+dx*t, y2+dy*t);
            if (n%10 == 0)
            {
                char buffer[20]; sprintf(buffer,"%g",v);
                char* p = buffer;
                while (p[0]=='0' && p[1]) p++;
                fl_font(text_font(), text_size());
                fl_draw(p, x1+dx*t+1, y1+dy*t+fl_size()-fl_descent());
            }
        }
        if (v && -v >= A && -v <= B)
        {
            int t = slider_position(-v, w);
            fl_line(x1+dx*t+dy*small, y1+dy*t+dx*small, x2+dx*t, y2+dy*t);
            if (n%10 == 0)
            {
                char buffer[20]; sprintf(buffer+1,"%g",v);
                char* p = buffer+1;
                while (p[0]=='0' && p[1]) p++;
                p--; p[0] = '-';
                fl_font(text_font(), text_size());
                fl_draw(p, x1+dx*t+1, y1+dy*t+fl_size()-fl_descent());
            }
        }
    }
}
Esempio n. 13
0
		Box(Point xy, int ww, int hh, int rr, const string& s = "") : w(ww), h(hh), r(rr), lab(s), fnt(fl_font()), fnt_sz(fl_size())
		{
			add(xy);
			if(h <= 0 || w <= 0 || r <= 0) error("Bad box: non-positive width, height, radius");
		}
Esempio n. 14
0
		Box(Point x, Point y, int rr, const string& s = "") : w(y.x - x.x), h(y.y - x.y), r(rr), lab(s), fnt(fl_font()), fnt_sz(fl_size())
		{
			add(x);
			if(h <= 0 || w <= 0 || r <= 0) error("Bad box: non-positive width, height, radius");
		}