Ejemplo n.º 1
0
FXFont *selectFont(const char *name, int size,
    int weight, int slant, int encoding, int setwidth, int hints)
{
// I start with a simplistic hypothesis that the width if characters in
// fonts here will scale linearly with their point size.
    int pointSize = 200;
    if (size > 0) pointSize = size;
    FXFontDesc fd;
    strncpy(fd.face, name, sizeof(fd.face));
    fd.size = pointSize;    // NB decipoints not points
    fd.weight = weight;
    fd.slant = slant;
    fd.encoding = encoding;
    fd.setwidth = setwidth;
    fd.flags = hints;
    FXFont *f = new FXFont(application_object, fd);
// I really hope that I have a fixed-with font here!
    f->create();
// If the registry had told me what size font to use then I will just
// stick with that. If not then I will have been hended in a negative
// size specifier and I will need to make a guess here.
   if (size > 0) return f;
// My font-size selection will be based in font and screen widths.
    int w = f->getFontWidth();
// Work out what proportion of my screen's width would be filled by
// 80 characters in this font.
    double fill = (80.0*(double)w)/(double)rootWidth;
    f->getFontDesc(fd);
    pointSize = fd.size;   // in deci-points for the one actually found
// I am now going to suggest a font size based on what I will count as
// a half-sensible way to place a window on the screen... Well my idea
// here is that on larger screens you will use a larger font but still fill up
// less of the total screen. On screens down at 800*600 and below I will
// want to use almost all of the screen, while for 1280*1024, 1600*1200 etc
// I will only use half the available width. This must be a matter where
// taste comes in, so others may have different views.
    double bestSize;
    if (rootWidth > 1100)     // try to 60% fill the root width
        bestSize = (double)pointSize*0.6/fill;
    else if (rootWidth > 900) // try to fill 0.75 the root width
        bestSize = (double)pointSize*0.75/fill;
                                // finally on small roots use almost all.
    else bestSize = (double)pointSize*0.9/fill;
    pointSize = (int)(0.5 + bestSize);
// I think that I will avoid over-teeny fonts come what may. So I will
// increate the selected size so that I always use at least 8pt.
    if (pointSize < 80) pointSize = 80;
    fd.size = pointSize;
    delete f;
// Finally create a fond that is the size that may make sense!
    f = new FXFont(application_object, fd);
    f->create();
    return f;
}
Ejemplo n.º 2
0
void FXSmoothCanvas::draw()
{
    // Get DC for the canvas
    FXDCWindow dc(this);

	// Clean the canvas
	dc.setForeground(this->getBackColor());
	dc.fillRectangle(0,0,getWidth(),getHeight());
	
	dc.setForeground(fxcolorfromname("Black"));

	if (!update)
		update_canvas_points();

	// Draw the axes
    dc.drawLine(origin.first, origin.second, endx.first, endx.second);
    dc.drawLine(origin.first, origin.second, endy.first, endy.second);

	// draw the frequency values
	dc.setForeground(fxcolorfromname("Red"));

	Point prev = canvas_points[0], next;
	dc.setLineWidth(4);
	for (unsigned int i=1; i<canvas_points.size(); i++) {
		next = canvas_points[i];
		dc.drawLine(prev.first, prev.second, next.first, next.second);
		prev = next;
	}
	// draw the joints
	dc.setForeground(fxcolorfromname("Blue"));
	dc.setLineWidth(1);
	for (unsigned int i=0; i<canvas_points.size(); i++) {
		Point pt = canvas_points[i];
		int d = radius + radius;
		dc.drawArc(pt.first-radius, pt.second-radius, d, d, 0, 64*360);
	}	
	// add the value on the axis
	int number = int(range.second);
	int decimal, sign;
	FXFont *f = new FXFont(this->getApp(),"Times New Roman",7);
	f->create();

	dc.setFont(f);
	for (int i=0; i<=number; i++) {
		Point p = convertToPoint(Joint(0.,i));
		dc.drawText(p.first-10, p.second+5, fcvt(double(i), 1, &decimal, &sign), 1);
	}
}
Ejemplo n.º 3
0
FXFont *FOX16_HtmlCtx::_getFoxFont(HTML_FONT *fnt) {
  FXFont *xfnt;

  if (GWEN_INHERIT_ISOFTYPE(HTML_FONT, FXFont, fnt)) {
    xfnt=GWEN_INHERIT_GETDATA(HTML_FONT, FXFont, fnt);
    return xfnt;
  }
  else {
    FXuint size;
    FXuint weight;
    FXuint slant;
    FXuint encoding;
    FXString face;
    uint32_t flags;

    if (HtmlFont_GetFontName(fnt))
      face=HtmlFont_GetFontName(fnt);
    else
      face=_font->getName();
    size=HtmlFont_GetFontSize(fnt);
    weight=FXFont::Normal;
    slant=_font->getSlant();
    encoding=_font->getEncoding();

    flags=HtmlFont_GetFontFlags(fnt);
    if (flags & HTML_FONT_FLAGS_STRONG)
      weight=FXFont::Bold;
    if (flags & HTML_FONT_FLAGS_ITALIC)
      slant=FXFont::Italic;

    DBG_DEBUG(GWEN_LOGDOMAIN,
              "Creating font [%s], size=%d, weight=%d, slant=%d, encoding=%d",
              face.text(), size, weight, slant, encoding);

    xfnt=new FXFont(FXApp::instance(), face, size, weight, slant, encoding);
    if (xfnt==NULL) {
      DBG_ERROR(GWEN_LOGDOMAIN,
                "Could not create font [%s], size=%d, weight=%d, slant=%d, encoding=%d",
                face.text(), size, weight, slant, encoding);
      return NULL;
    }
    xfnt->create();
    GWEN_INHERIT_SETDATA(HTML_FONT, FXFont, fnt, xfnt,
                         FOX16_HtmlCtxLinker::freeFontData);
    return xfnt;
  }
}
Ejemplo n.º 4
0
// Make window
void CommandWindow::create()
{
    // Set text font
    FXString fontspec;

    fontspec = getApp()->reg().readStringEntry("SETTINGS", "textfont", "Helvetica,100,normal,regular");
    if (!fontspec.empty())
    {
        FXFont* font = new FXFont(getApp(), fontspec);
        font->create();
        text->setFont(font);
    }

    DialogBox::create();
    show(PLACEMENT_OWNER);

    // Execute command
    execCmd(command.text());
}