Beispiel #1
0
void gChoice::draw() {
	fl_rectf(x(), y(), w(), h(), COLOR_BG_0);              // bg
	fl_rect(x(), y(), w(), h(), (Fl_Color) COLOR_BD_0);    // border
	if (angle)
		fl_polygon(x()+w()-8, y()+h()-1, x()+w()-1, y()+h()-8, x()+w()-1, y()+h()-1);

	/* pick up the text() from the selected item (value()) and print it in
	 * the box and avoid overflows */

	fl_color(!active() ? COLOR_BD_0 : COLOR_TEXT_0);
	if (value() != -1) {
		if (fl_width(text(value())) < w()-8) {
			fl_draw(text(value()), x(), y(), w(), h(), FL_ALIGN_CENTER);
		}
		else {
			std::string tmp = text(value());
			int size        = tmp.size();
			while (fl_width(tmp.c_str()) >= w()-16) {
				tmp.resize(size);
				size--;
			}
			tmp += "...";
			fl_draw(tmp.c_str(), x(), y(), w(), h(), FL_ALIGN_CENTER);
		}

	}
}
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 #3
0
std::string text_wrap(const char *text, int linewidth, Fl_Font font, int font_size)
{
  std::istringstream iss(text);
  std::ostringstream oss;
  std::string word;
  int w, ws, remain = linewidth;

  if (!text) {
    return "";
  }

  fl_font(font, font_size);
  ws = fl_width(' ');

  while (iss >> word) {
    w = fl_width(word.c_str());
    if (oss.tellp() > 0) {
      oss << ' ';
      remain -= ws;
    }
    if (remain >= w) {
      /* enough space to append the word */
      oss << word;
      remain -= w;
    } else {
      /* not enough space to append the word */
      if (w > linewidth) {
        /* word is longer than line -> split the word */
        w = 0;
        for (size_t i = 0; i < word.size(); ++i) {
          int wi = fl_width(word[i]);
          if (w + wi > remain) {
            oss << '\n' << word[i];
            w = wi;
            remain = linewidth - w;
          } else {
            oss << word[i];
            w += wi;
          }
        }
      } else {
        /* new line */
        if (oss.tellp() > 0) {
          oss << '\n';
        }
        oss << word;
      }
      remain = linewidth - w;
    }
  }

  return oss.str();
}
Beispiel #4
0
void Fl_Device::rtl_draw(const char *str, int n, float x, float y)
{
	// USE BUFFER HERE ALSO
	SetTextColor(fl_gc, fl_colorref);
	SelectObject(fl_gc, current_font);

	int i = 0;
	int lx = 0;
	const WCHAR *skod;
	resize_buffer(n);
	int wn = fl_utf2unicode((const unsigned char *)str, n, wstr);

	while (i < wn) {
	    lx = int(fl_width(wstr[i]));
		x -= lx;
		skod = (const WCHAR*)wstr + i;
#ifndef _WIN32_WCE
		TextOutW(fl_gc, int(floor(x+.5f)), int(floor(y+.5f)), skod, 1);
#else
		RECT rect = {int(floor(x+.5f)),int(floor(y+.5f)), 0,0};
		DrawText(fl_gc, skod, 1, &rect, DT_SINGLELINE | DT_TOP | DT_LEFT | DT_NOCLIP);	
#endif
		if (fl_nonspacing(wstr[i])) {
			x += lx;
		}
		i++;
	}	
}
Beispiel #5
0
Datei: draw.C Projekt: imv/non
int
gui_draw_string ( int x, int y, int w, int h, int color, const char *s, bool draw )
{
    int rw;

    if ( ! s )
        return 0;

    fl_font( FL_COURIER, min( h, 18 ) );

    rw = fl_width( s );

    if ( fl_not_clipped( x, y, rw, h ) && draw )
    {
        gui_clear_area( x, y, w, h );

        if ( color )
            fl_color( velocity_colors[ color ] );
        else
            fl_color( FL_DARK_CYAN );

        fl_draw( s, x, y + h / 2 + fl_descent() );
    }

    return rw;
}
Beispiel #6
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 #7
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;
    }
}
int CLuaInputField::CoreRequestWidth()
{
    int minw = 50;
    
    if (m_pLabel)
    {
        fl_font(m_pLabel->labelfont(), m_pLabel->labelsize());
        minw += static_cast<int>(fl_width(m_pLabel->label()));
    }
    
    return minw;
}
Beispiel #9
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;
    }
Beispiel #10
0
float Fl_Device::width(const char* c, int n) const
{
  int i = 0;
  float w = 0;
  unsigned int ucs;
  while (i < n) {    
    int l = fl_fast_utf2ucs((const unsigned char*)c + i, n - i, &ucs);
    if (l < 1) l = 1; 
    i += l;
    if (!fl_nonspacing(ucs)) {
      w += fl_width(ucs);
    }
  }
  return w;
}
Beispiel #11
0
int measure_button_width(const char *label, int extra_width)
{
  int w = 0;
  if (!label) {
    return 90;
  }
  Fl_Button *o = new Fl_Button(0,0,0,0, label);
  fl_font(o->labelfont(), o->labelsize());
  w = fl_width(o->label()) + extra_width;
  if (w < 90) {
    w = 90;
  }
  delete o;
  return w;
}
void CLuaCFGMenu::SetVarColumnW(const char *var)
{
    const int varspacing = 10;
    const char *trname = GetTranslation(var);
    
    fl_font(m_pVarListView->labelfont(), m_pVarListView->labelsize());
    int w = fl_width(trname) + varspacing;
    
    if (w > m_ColumnWidths[0])
    {
        m_ColumnWidths[0] = w;
        m_pVarListView->column_widths(m_ColumnWidths);
        m_pVarListView->redraw(); // Make's sure that widget uses new column width
    }
}
int CLuaRadioButton::CoreRequestWidth()
{
    TSTLVecSize size = m_RadioButtons.size();
    int ret = 0;
    
    if (!size)
        return 0;
    
    fl_font(m_RadioButtons[0]->labelfont(), m_RadioButtons[0]->labelsize());
    
    for (TSTLVecSize n=0; n<size; n++)
    {
        ret = std::max(ret, static_cast<int>(fl_width(m_RadioButtons[n]->label())));
    }
    
    return ret;
}
Beispiel #14
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 CLuaInputField::UpdateSize()
{
    m_pPack->size(GetGroup()->w(), m_pPack->h());
    
    if (GetLabel().empty() || !m_pLabel)
    {
        m_pInputField->size(GetGroup()->w(), m_pInputField->h());
        return;
    }
    
    std::string label = GetTranslation(GetLabel());
    TSTLStrSize max = SafeConvert<TSTLStrSize>(GetLabelWidth()), length = label.length();
    
    if (length > max)
        m_pLabel->label(MakeCString(label.substr(0, max)));
    
    fl_font(m_pLabel->labelfont(), m_pLabel->labelsize());
    int w = static_cast<int>(fl_width(' ')) * GetLabelWidth();
    m_pLabel->size(w, m_pLabel->h());
    
    m_pInputField->size(GetGroup()->w() - PackSpacing() - w, m_pInputField->h());
}
Beispiel #16
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 #17
0
void MainMenu::layout()
{
    fl_font(label_font(), label_size());
    int W = int(fl_width(label())) + 12;
    int H = h();
    int im_size = H-6;

    if(!e_image || (e_image && e_image->height()!=im_size)) {
        if(e_image) delete e_image;
        if(ede_pix.height()==im_size) {
            e_image=0;
            image(ede_pix);
        }
        else {
            e_image = ede_pix.scale(im_size, im_size);
            image(e_image);
        }
    }
    if(image()) W+=image()->width();

    w(W);
    Fl_Menu_Button::layout();
}
Beispiel #18
0
co_rc_t console_window_t::start()
{
	window = new console_main_window_t(this);
	window->callback(console_window_cb, this);

	Fl_Menu_Item console_menuitems[] = {
		{ "File", 0, 0, 0, FL_SUBMENU },
		{ "Quit", 0, (Fl_Callback *)console_quit_cb, this },
		{ 0 },

		{ "Monitor", 0, 0, 0, FL_SUBMENU },
		{ "Select", 0, (Fl_Callback *)console_select_cb, this, FL_MENU_DIVIDER },
		{ "Attach", 0, (Fl_Callback *)console_attach_cb, this, },
		{ "Detach", 0, (Fl_Callback *)console_detach_cb, this, FL_MENU_DIVIDER },
		{ "Pause", 0, (Fl_Callback *)console_pause_cb, this,  },
		{ "Resume", 0, (Fl_Callback *)console_resume_cb, this, },
		{ "Terminate", 0, (Fl_Callback *)console_terminate_cb, this, },
		{ "Send Ctrl-Alt-Del", 0, (Fl_Callback *)console_send_ctrl_alt_del_cb, this, },
		{ 0 },

		{ "Inspect", 0, 0, 0, FL_SUBMENU },
		{ 0 },

		{ "Help", 0, 0, 0, FL_SUBMENU },
		{ "About", 0, (Fl_Callback *)console_about_cb, this, },
		{ 0 },

		{ 0 }
	};

	unsigned int i;
	for (i=0; i < sizeof(console_menuitems)/sizeof(console_menuitems[0]); i++)
		console_menuitems[i].user_data((void *)this);

	int swidth = 640;
	int sheight = 480;

	menu = new Fl_Menu_Bar(0, 0, swidth, 30);
	menu->box(FL_UP_BOX);
	menu->align(FL_ALIGN_CENTER);
	menu->when(FL_WHEN_RELEASE_ALWAYS);
	menu->copy(console_menuitems, window);

	Fl_Group *tile = new Fl_Group(0, 30, swidth, sheight-30);
	widget = new console_widget_t(0, 30, swidth, sheight-120);
	text_widget = new Fl_Text_Display(0, sheight-120+30, swidth, 70);

	Fl_Group *tile2 = new Fl_Group(0, sheight-120+30, swidth, 90);
	text_widget->buffer(new Fl_Text_Buffer());
	text_widget->insert_position(0);

	Fl_Box *box = new Fl_Box(0, sheight-20, swidth, 20);
	box->label("");
	box->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE); 
	tile2->end();

	tile->resizable(widget);
	tile->end();

	window->resizable(tile);
	window->end();
	window->show();

	menu_item_activate(console_select_cb);
	menu_item_deactivate(console_pause_cb);
	menu_item_deactivate(console_resume_cb);
	menu_item_deactivate(console_terminate_cb);
	menu_item_deactivate(console_detach_cb);
	menu_item_deactivate(console_attach_cb);

	// Default Font is "Terminal" with size 18
	// Sample WinNT environment: set COLINUX_CONSOLE_FONT=Lucida Console:12
	// Change only font size:    set COLINUX_CONSOLE_FONT=:12
	char * env_font = getenv ("COLINUX_CONSOLE_FONT");
	if (env_font) {
		char *p = strchr (env_font, ':');

		if (p) {
			int size = atoi (p+1);
			if (size >= 4 && size <= 24) {
				// Set size
				widget->set_font_size(size);
			}
			*p = 0; // End for Fontname
		}
		
		// Set new font style
		if (strlen (env_font)) {
			// Remember: set_font need a non stack buffer!
			// Environment is global static.
			Fl::set_font(FL_SCREEN, env_font);

			// Now check font width
			fl_font(FL_SCREEN, 18); // Use default High for test here
			if ((int)fl_width('i') != (int)fl_width('W')) {
				Fl::set_font(FL_SCREEN, "Terminal"); // Restore standard font
				log("%s: is not fixed font. Using 'Terminal'\n", env_font);
			}
		}
	}

	log("Cooperative Linux console started\n");
	
	if (start_parameters.attach_id != CO_INVALID_ID)
		attached_id = start_parameters.attach_id;

	if (attached_id == CO_INVALID_ID)
		attached_id = find_first_monitor();

	if (attached_id != CO_INVALID_ID)
		attach(); /* Ignore errors, as we can attach latter */

	return CO_RC(OK);
}
Beispiel #19
0
co_rc_t console_window_t::start()
{
	window = new console_main_window_t(this);
	window->callback(console_window_cb, this);

	// read font and font size from registry
	reg_font = ReadRegistry(REGISTRY_FONT);
	reg_font_size = ReadRegistry(REGISTRY_FONT_SIZE);
	reg_copyspaces = ReadRegistry(REGISTRY_COPYSPACES);
	reg_exitdetach = ReadRegistry(REGISTRY_EXITDETACH);

	if(reg_font==-1)
		reg_font = FL_SCREEN;
	if(reg_font_size==-1)
		reg_font_size = 18;
	if(reg_copyspaces==-1)
		reg_copyspaces = 1;
	if(reg_exitdetach==-1)
		reg_exitdetach = 0;


	Fl_Menu_Item console_menuitems[] = {
		{ "File", 0, NULL, NULL, FL_SUBMENU },
		{ "Select"   , 0, (Fl_Callback*)console_select_cb, this, FL_MENU_DIVIDER },
		{ "Attach"   , 0, (Fl_Callback*)console_attach_cb, this, },
		{ "Detach"   , 0, (Fl_Callback*)console_detach_cb, this, FL_MENU_DIVIDER },
		{ "Power off", 0, (Fl_Callback*)console_send_poweroff_cb, this, },
		{ "Reboot - Ctrl-Alt-Del", 0, (Fl_Callback *)console_send_ctrl_alt_del_cb, this, },
		{ "Shutdown" , 0, (Fl_Callback*)console_send_shutdown_cb, this, FL_MENU_DIVIDER },
		{ "Quit", 0, (Fl_Callback *)console_quit_cb, this },
		{ 0 },

		{ "Edit" , 0, NULL, NULL, FL_SUBMENU },
		{ "Copy (WinKey+C)", 0, (Fl_Callback*)console_copy_cb, this, },
		{ "Paste (WinKey+V)", 0, (Fl_Callback*)console_paste_cb, this,  },
		{ 0 },

		{ "View" , 0, NULL, NULL, FL_SUBMENU },
		{ "Page up (WinKey+PgUp, mouse wheel)", 0, (Fl_Callback*)console_scrollpageup_cb, this, },
		{ "Page down (WinKey+PgDn, mouse wheel)", 0, (Fl_Callback*)console_scrollpagedown_cb, this, },
		{ 0 },

		{ "Config" , 0, NULL, NULL, FL_SUBMENU },
		{ "Font..." , 0, (Fl_Callback*)console_font_cb, this,  FL_MENU_DIVIDER },
		{ "Copy trailing spaces", 0, (Fl_Callback*)console_copyspaces_cb, this,
			FL_MENU_TOGGLE | ((reg_copyspaces) ? FL_MENU_VALUE : 0)},
		{ "Exit on Detach", 0, (Fl_Callback*)console_exitdetach_cb, this,
			FL_MENU_TOGGLE |  ((reg_exitdetach) ? FL_MENU_VALUE : 0)},
		{ 0 },

		{ "Help" , 0, NULL, NULL, FL_SUBMENU },
		{ "About", 0, (Fl_Callback*)console_about_cb, this, },
		{ 0 },
		{ 0 }
	};

	unsigned int i;

	for (i = 0; i < sizeof(console_menuitems) / sizeof(console_menuitems[0]); i++)
		console_menuitems[i].user_data((void*)this);

	int swidth  = 640;
	int sheight = 480;

	menu = new Fl_Menu_Bar(0, 0, swidth, MENU_SIZE_PIXELS);
	menu->box(FL_UP_BOX);
	menu->align(FL_ALIGN_CENTER);
	menu->when(FL_WHEN_RELEASE_ALWAYS);
	menu->copy(console_menuitems, window);

	Fl_Group* tile = new Fl_Group(0, MENU_SIZE_PIXELS, swidth, sheight-MENU_SIZE_PIXELS);

	widget	    = new console_widget_t(0, MENU_SIZE_PIXELS, swidth, sheight - 120);
	if(widget->get_copy_spaces()!=reg_copyspaces)
		widget->toggle_copy_spaces();
	text_widget = new Fl_Text_Display(0, sheight - 120 + MENU_SIZE_PIXELS, swidth, 70);

	Fl_Group* tile2 = new Fl_Group(0, sheight - 120 + MENU_SIZE_PIXELS, swidth, 90);

	text_widget->buffer(new Fl_Text_Buffer());
	text_widget->insert_position(0);

	Fl_Box* box = new Fl_Box(0, sheight - 20, swidth, 20);

	box->label("");
	box->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
	tile2->end();

	tile->resizable(widget);
	tile->end();

	window->resizable(tile);
	window->end();
	window->show();

	menu_item_activate(console_select_cb);
	menu_item_deactivate(console_send_poweroff_cb);
	menu_item_deactivate(console_send_ctrl_alt_del_cb);
	menu_item_deactivate(console_send_shutdown_cb);
	menu_item_deactivate(console_detach_cb);
	menu_item_deactivate(console_attach_cb);

	// Default Font is "Terminal" with size 18
	// Sample WinNT environment: set COLINUX_CONSOLE_FONT=Lucida Console:12
	// Change only font size:    set COLINUX_CONSOLE_FONT=:12
	char* env_font = getenv("COLINUX_CONSOLE_FONT");

	if (env_font)
	{
		char* p = strchr (env_font, ':');

		if (p)
		{
			int size = atoi (p+1);
			if (size >= 4 && size <= 24)
			{
				// Set size
				widget->set_font_size(size);
			}
			*p = 0; // End for Fontname
		}

		// Set new font style
		if(strlen(env_font))
		{
			// Remember: set_font need a non stack buffer!
			// Environment is global static.
			Fl::set_font(FL_SCREEN, env_font);

			// Now check font width
			fl_font(FL_SCREEN, 18); // Use default High for test here
			if ((int)fl_width('i') != (int)fl_width('W'))
			{
				Fl::set_font(FL_SCREEN, "Terminal"); // Restore standard font
				log("%s: is not fixed font. Using 'Terminal'\n", env_font);
			}
		}
	}
	else
	{
		// use registry values and not environment variable
		widget->set_font_name(reg_font);
		widget->set_font_size(reg_font_size);
	}

	log("Cooperative Linux console started\n");

	if (start_parameters.attach_id != CO_INVALID_ID)
		attached_id = start_parameters.attach_id;
	else
		attached_id = find_first_monitor();

	if (attached_id != CO_INVALID_ID)
		attach(); /* Ignore errors, as we can attach latter */

	return CO_RC(OK);
}
Beispiel #20
0
void edit_formula_cb( Fl_Widget* w, void* ) {
    const int heightInput = 28;
    const int heightText = 18;
    const int wideLabel = 50;
    const int wideInput = 450;
    const int Ybetween = 3;
    const int YbetweenMore = 6;
    const int alignStyle = FL_ALIGN_INSIDE | FL_ALIGN_RIGHT;
    const int textStyle = FL_ALIGN_INSIDE | FL_ALIGN_LEFT;
    const Fl_Boxtype inputStyle = FL_PLASTIC_DOWN_BOX;
    int x = 10;
    int y = 10;
    const int wide = x+wideLabel+wideInput+x;
    const int height = y + 3*heightText + Ybetween + 3*(heightInput+Ybetween)
	- Ybetween + YbetweenMore + y;
    Fl_Window* win = new Fl_Window( wide, height, _("Formulas editor") );
    Fl_Group* win2 = new Fl_Group( 0, 0, wide, height );
    win->resizable(win2);
    {
	Fl_Box* o =
	    new Fl_Box( x, y, wideLabel+wideInput, heightText,
			_("Enter the formulas of x(n+1) and y(n+1) using prefix notation.") );
	o->align( textStyle );
    }
    y += heightText;
    {
	Fl_Box* o =  new Fl_Box( x, y, wideLabel+wideInput, heightText,
				 _("Variables: x y x1 x2 y1 y2 xc yc rand, and any number.") );
	o->align( textStyle );
    }
    y += heightText;
    {
	Fl_Box* o = new Fl_Box( x, y, wideLabel+wideInput, heightText, _("Functions: ") );
	o->align( textStyle );
    }
    {
	Fl_Box* o = new Fl_Box( x + (int)( fl_width(_("Functions: ")) ), y,
				wideLabel+wideInput, heightText,
				"+ - * / < pow abs atan2 sin cos tan atan ln sign square sqrt." );
	o->align( textStyle );
    }
    y += heightText + Ybetween;
    {
	Fl_Box* o = new Fl_Box( x, y, wideLabel, heightInput, "x <- " );
	o->align( alignStyle );
    }
    {
	Fl_Input* o = new Fl_Input( x+wideLabel, y, wideInput, heightInput );
	o->box(inputStyle);
	o->value( Function::formulaPoint.getStringX().c_str() );
    }
    y += heightInput + Ybetween;
    {
	Fl_Box* o = new Fl_Box( x, y, wideLabel, heightInput, "y <- " );
	o->align( alignStyle );
    }
    {
	Fl_Input* o = new Fl_Input( x+wideLabel, y, wideInput, heightInput );
	o->box(inputStyle);
	o->value( Function::formulaPoint.getStringY().c_str() );
    }
    y += heightInput + Ybetween + YbetweenMore;
    {
	Fl_Return_Button* o = new Fl_Return_Button( wide - x - 150, y, 150, heightInput,
						    _("Set formulas") );
	o->box(FL_PLASTIC_UP_BOX);
	o->callback( (Fl_Callback*)set_formula, glito );
    }
    win2->end();
    win->end();
    win->show();
}
Beispiel #21
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 #22
0
 FL_EXPORT_C(double,flc_width_with_c)(unsigned int c){
   return fl_width(c);
 }
Beispiel #23
0
 FL_EXPORT_C(double,flc_width_with_n)(const char* txt,int n){
   return fl_width(txt,n);
 }
Beispiel #24
0
 FL_EXPORT_C(double,flc_width)(const char* txt){
   return fl_width(txt);
 }
Beispiel #25
0
// FLTK.width(text)
// Get the width of a string.
mrb_value mrb_fltk_width_module_method( mrb_state *mrb, mrb_value self ) {
  char *text;
  mrb_get_args( mrb, "z", &text );

  return mrb_fixnum_value( fl_width( text ) );
}
Beispiel #26
0
Datei: Module.C Projekt: 0mk/non
void
Module::draw_label ( int tx, int ty, int tw, int th )
{
    bbox( tx, ty, tw, th );

    if ( ! label() )
        return;

    char *lab = strdup( label() );

    Fl_Color c = fl_contrast( FL_FOREGROUND_COLOR, color() );

    fl_color( active_r() && ! bypass() ? c : fl_inactive(c) );

    fl_font( FL_HELVETICA, labelsize() );

    char *di = strstr( lab, " -" );
    
    if ( ! di )
        di = strstr( lab, "  " );

    if ( di )
        *di = '\0';

    int LW = fl_width( lab );
    char *s = NULL;

    bool initial = true;
    if ( LW > tw )
    {
        s = new char[strlen(lab) + 1];
        char *sp = s;
        const char *lp = lab;

        for ( ; *lp; ++lp )
        {
            bool skip = false;

            switch ( *lp )
            {
                case ' ':
                    initial = true;
                    skip = false;
                    break;
                case 'i': case 'e': case 'o': case 'u': case 'a':
                    skip = ! initial;
                    initial = false;
                    break;
                default:
                    skip = false;
                    initial = false;
                    break;
            }
            
            if ( ! skip )
                *(sp++) = *lp;
        }
     
        *sp = '\0';
   
    }

    fl_draw( s ? s : lab, tx, ty, tw, th, align() | FL_ALIGN_CLIP );
    
    if ( bypass() )
    {
        fl_color( fl_color_add_alpha( fl_color(), 127 )  );
        fl_line_style( FL_SOLID, 2 );
        fl_line( tx, ty + th * 0.5, tx + tw, ty + th * 0.5 );
        fl_line_style( FL_SOLID, 0 );
    }


    free(lab);

    if ( s )
        delete[] s;
}
Beispiel #27
0
static inline int wchar_width(WCHAR *wc, int len) {
	float W=0;
	for(int n=0; n<len; n++) W += fl_width(wc[n]);
	return int(W);

}
Beispiel #28
0
void Fl_Device::transformed_draw(const char *str, int n, float x, float y) 
{
	SetTextColor(fl_gc, fl_colorref);
	SelectObject(fl_gc, current_font);
	
#ifdef _WIN32_WCE
	RECT rect = { int(floor(x+.5f)), int(floor(y+.5f)), 0, 0 };	
#else
    int X = int(floor(x+.5f));
    int Y = int(floor(y+.5f));
#endif

	unsigned ucs;
	unsigned no_spc;
    WCHAR buf[128];		// drawing buffer
    int pos = 0;		// position in buffer

	while(n > 0) {

        if(pos>120) {
#ifdef _WIN32_WCE			
			DrawText(fl_gc, buf, pos, &rect, DT_SINGLELINE | DT_TOP | DT_LEFT | DT_NOCLIP);	
			rect.left += wchar_width(buf, pos);
#else
			TextOutW(fl_gc, X, Y, buf, pos);
			X += wchar_width(buf, pos);
#endif
			pos = 0;
        }

        int ulen = fl_fast_utf2ucs((unsigned char*)str, n, &ucs);
        if (ulen < 1) ulen = 1;
        no_spc = fl_nonspacing(ucs);
        if(no_spc) ucs = no_spc;
		buf[pos] = ucs;

        if(no_spc) {
#ifdef _WIN32_WCE
			DrawText(fl_gc, buf, pos, &rect, DT_SINGLELINE | DT_TOP | DT_LEFT | DT_NOCLIP);	
			rect.left += wchar_width(buf, pos);
			rect.left -= fl_width(buf[pos]);
#else
			TextOutW(fl_gc, X, Y, buf, pos);
			X += wchar_width(buf, pos);
			X -= fl_width(buf[pos]);
#endif
            buf[0] = ucs;
			pos = 0;
        }

        pos++;
        str += ulen;
        n-=ulen;
    }
    if(pos>0)
#ifdef _WIN32_WCE			
		DrawText(fl_gc, buf, pos, &rect, DT_SINGLELINE | DT_TOP | DT_LEFT | DT_NOCLIP);	
#else
		TextOutW(fl_gc, X, Y, buf, pos);
#endif
}
Beispiel #29
0
void fieldWindow::editField(Field *f)
{
  editor_group->user_data(f);
  put_on_view_btn->deactivate();
  delete_btn->deactivate();
  if(f == NULL){
    selected_id = -1;
    editor_group->hide();
    empty_message->show();
    loadFieldList();
    return;
  }

  FL_NORMAL_SIZE -= _deltaFontSize;

  selected_id = f->id;
  empty_message->hide();
  editor_group->show();
  editor_group->user_data(f);
  title->label(f->getName());
  options_scroll->clear();
  options_widget.clear();
  options_scroll->begin();
  int xx = options_scroll->x();
  int yy = options_scroll->y();

  std::string help = f->getDescription();
  ConvertToHTML(help);
  if (! f->options.empty())
    help += std::string("<p><center><b>Options</b></center>");
  for(std::map<std::string, FieldOption*>::iterator it = f->options.begin();
      it != f->options.end(); it++){
    Fl_Widget *input;
    help += std::string("<p><b>") + it->first + "</b>";
    help += " (<em>" + it->second->getTypeName() + "</em>): ";
    help += it->second->getDescription();
    switch(it->second->getType()){
    case FIELD_OPTION_INT:
    case FIELD_OPTION_DOUBLE:
      input = new Fl_Value_Input(xx, yy, IW, BH, it->first.c_str());
      input->align(FL_ALIGN_RIGHT);
      break;
    case FIELD_OPTION_BOOL:
      input = new Fl_Check_Button(xx, yy, 2 * BB, BH, it->first.c_str());
      input->type(FL_TOGGLE_BUTTON);
      break;
    case FIELD_OPTION_PATH:
      {
        input = new Fl_Input(xx, yy, IW, BH, it->first.c_str());
        input->align(FL_ALIGN_RIGHT);
        int tw = (int)fl_width(it->first.c_str());
        Fl_Button *b = new Fl_Button(xx + IW + tw + 2 * WB, yy, BB, BH, "Choose");
        b->callback(field_select_file_cb, input);
      }
      break;
    case FIELD_OPTION_STRING:
      input = new Fl_Input(xx, yy, IW, BH, it->first.c_str());
      input->align(FL_ALIGN_RIGHT);
      break;
    case FIELD_OPTION_LIST:
    default:
      input = new Fl_Input(xx, yy, IW, BH, it->first.c_str());
      input->align(FL_ALIGN_RIGHT);
      break;
    }
    options_widget.push_back(input);
    yy += BH;
  }
  if (! f->callbacks.empty())
    help += std::string("<p><center><b>Actions</b></center>");
  for(std::map<std::string, FieldCallback*>::iterator it = f->callbacks.begin();
      it != f->callbacks.end(); it++){
    Fl_Widget *btn;
    help += std::string("<p><b>") + it->first + "</b>: ";
    help += it->second->getDescription();
    btn = new Fl_Button(xx, yy, IW, BH, it->first.c_str());
    btn->callback(field_callback_cb, it->second);
    yy += BH;
  }
  help_display->value(help.c_str());
  options_scroll->end();

  FL_NORMAL_SIZE += _deltaFontSize;

  loadFieldOptions();
  options_scroll->damage(1);
  put_on_view_btn->activate();
  delete_btn->activate();
  loadFieldList();
}
Beispiel #30
0
float gl_width(const char* s, int n) {return fl_width(s,n);}