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 RFile::drawNameText(float alpha) {
    if(!selected && alpha <= 0.01) return;

    float name_alpha = selected ? 1.0 : alpha;

    if(selected) {
        file_selected_font.draw(screenpos.x, screenpos.y, name);
    } else {
        file_font.setAlpha(name_alpha);
        file_font.draw(screenpos.x, screenpos.y, gGourceSettings.file_extensions ? ext : name);
    }
}
Ejemplo n.º 3
0
void RDirNode::drawDirName(FXFont& dirfont) const{
    if(parent==0) return;
    if(gGourceSettings.hide_dirnames) return;

    if(!gGourceSettings.highlight_dirs && since_last_node_change > 5.0) return;

    float alpha = gGourceSettings.highlight_dirs ? 1.0 : std::max(0.0f, 5.0f - since_last_node_change) / 5.0f;

    vec2f mid = spline.getMidPoint();

    dirfont.setAlpha(alpha);
    dirfont.draw(mid.x, mid.y, path_token);
}
Ejemplo n.º 4
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.º 5
0
void RDirNode::drawDirName(FXFont& dirfont) {
    if(!gGourceDrawDirName) return;

    if(since_last_node_change > 5.0) return;

    float alpha = std::max(0.0f, 5.0f - since_last_node_change) / 5.0f;

    glColor4f(1.0, 1.0, 1.0, alpha);

    vec3f screenpos = display.project(vec3f(0.0, 0.0, 0.0));

    glMatrixMode(GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();
            glOrtho(0, display.width, display.height, 0, -1.0, 1.0);

        glMatrixMode(GL_MODELVIEW);
            glPushMatrix();
            glLoadIdentity();

        dirfont.draw(screenpos.x, screenpos.y, path_token);

        glMatrixMode(GL_PROJECTION);
        glPopMatrix();

        glMatrixMode(GL_MODELVIEW);
        glPopMatrix();
}
Ejemplo n.º 6
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.º 7
0
int FOX16_HtmlCtx::getTextHeight(HTML_FONT *fnt, const char *s) {
  if (s==NULL) {
    DBG_ERROR(GWEN_LOGDOMAIN, "NULLPOINTER, returning size 0");
    return 0;
  }
  else {
    FXFont *xfnt;
    FXString str;

    str=FXString(s);
    xfnt=_getFoxFont(fnt);
    if (xfnt==NULL)
      return _font->getTextHeight(str);
    else
      return xfnt->getTextHeight(str);
  }
}
Ejemplo n.º 8
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());
}
Ejemplo n.º 9
0
void ConfApp::draw() {
    if(!ready || app->isFinished()) return;

    if(background_image != 0) {

        display.mode2D();

        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glEnable(GL_BLEND);
        glEnable(GL_TEXTURE_2D);

        glBindTexture(GL_TEXTURE_2D, background_image->textureid);
        glColor4f(1.0, 1.0, 1.0, 1.0);
        glBegin(GL_QUADS);
            glTexCoord2f(0.0f, 0.0f);
            glVertex2f(0.0f, 0.0f);

            glTexCoord2f(1.0f, 0.0f);
            glVertex2f(display.width, 0.0f);

            glTexCoord2f(1.0f, 1.0f);
            glVertex2f(display.width, display.height);

            glTexCoord2f(0.0f, 1.0f);
            glVertex2i(0.0f, display.height);
        glEnd();

    }

    try {
        app->draw(scaled_t, scaled_dt);
    } catch(...) {
        finished = true;
        return;
    }

    float elapse_time = 15.0;
    float elapsed_fade = 5.0;

    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    glEnable(GL_TEXTURE_2D);

    glColor4f(colour_title.x, colour_title.y, colour_title.z, 1.0);

    FXFont font = fontmanager.grab("FreeSans.ttf", 22);

    font.dropShadow(true);
    font.alignTop(false);

    font.draw(10.0, display.height - 10.0, title.c_str());

    font.alignRight(true);
    font.alignTop(false);

    font.draw(display.width - 10.0, display.height - 10.0, subtitle.c_str());
}
Ejemplo n.º 10
0
Paddle::Paddle(vec2 pos, vec4 colour, std::string token, FXFont font) {
    this->token = token;

// TODO: fix colouring
//    this->token_colour = token.size() > 0 ? colourHash2(token) : vec3(0.5,0.5,0.5);
    this->token_colour = token.size() > 0 ? colourHash(token) : vec3(0.5,0.5,0.5);

    this->pos = pos;
    this->lastcol = colour;
    this->default_colour = colour;
    this->colour  = lastcol;
    this->width = 10;
    this->height = 50;
    this->target = 0;

    font.alignTop(true);
    font.alignRight(true);
    font.dropShadow(true);

    this->font = font;

    dest_y = -1;
}
Ejemplo n.º 11
0
RFile::RFile(const std::string & name, const vec3 & colour, const vec2 & pos, int tagid) : Pawn(name,pos,tagid) {
    hidden = true;
    size = gGourceFileDiameter * 1.05;
    radius = size * 0.5;

    setGraphic(gGourceSettings.file_graphic);

    speed = 5.0;
    nametime = 4.0;
    name_interval = nametime;

    namecol     = vec3(1.0, 1.0, 1.0);
    file_colour = colour;

    last_action    = 0.0f;
    fade_start     = -1.0f;
    expired        = false;
    forced_removal = false;

    shadow = true;

    distance = 0;

    setFilename(name);

    if(!file_selected_font.initialized()) {
        file_selected_font = fontmanager.grab("FreeSans.ttf", 18);
        file_selected_font.dropShadow(true);
        file_selected_font.roundCoordinates(false);
        file_selected_font.setColour(vec4(gGourceSettings.selection_colour, 1.0f));
    }

    if(!file_font.initialized()) {
        file_font = fontmanager.grab("FreeSans.ttf", 14);
        file_font.dropShadow(true);
        file_font.roundCoordinates(false);
        file_font.setColour(vec4(1.0f, 1.0f, 1.0f, 1.0f));
    }

    //namelist = glGenLists(1);
    //label = 0;
    setSelected(false);

    dir = 0;
}
Ejemplo n.º 12
0
FileKeyEntry::FileKeyEntry(const FXFont& font, const std::string& ext, const vec3& colour) {
    this->drawCount = true;
    this->ext    = ext;
    this->colour = colour;
    this->pos_y  = -1.0f;

    this->font = font;
    this->font.dropShadow(false);

    shadow      = vec2(3.0, 3.0);

    width       = 90.0f;
    height      = 18.0f;
    left_margin = 20.0f;
    count       = 0;
    brightness  = 1.0f;
    alpha       = 0.0f;

    move_elapsed = 1.0f;
    src_y        = -1.0f;
    dest_y       = -1.0f;

    show = true;

    display_ext = ext;

    bool truncated = false;

    while(font.getWidth(display_ext) > width - 15.0f) {
        display_ext.resize(display_ext.size()-1);
        truncated = true;
    }

    if(truncated) {
        display_ext += std::string("...");
    }
}
Ejemplo n.º 13
0
void FOX16_HtmlCtx::_paintAt(FXDC *dc, HTML_OBJECT *o,
                             int xOffset, int yOffset,
                             int xText, int yText,
                             int w, int h) {
  HTML_OBJECT *c;
  int x;
  int y;
  int printX;
  int printY;
  int objectW;
  int objectH;

  x=xText+HtmlObject_GetX(o);
  y=yText+HtmlObject_GetY(o);
  objectW=HtmlObject_GetWidth(o);
  objectH=HtmlObject_GetHeight(o);

  printX=x-xOffset;
  printY=y-yOffset;

  if (printX<w && printX+objectW>=0 &&
      printY<h && printY+objectH>=0) {
    switch(HtmlObject_GetObjectType(o)) {
#if 0
    case HtmlObjectType_Grid:
      dc->setForeground(FXRGB(255,0,0));
      dc->fillRectangle(printX, printY,
                        HtmlObject_GetWidth(o),
                        HtmlObject_GetHeight(o));
#endif
    case HtmlObjectType_Word: {
      HTML_PROPS *pr;
      HTML_FONT *fnt;
      FXFont *xfnt;
      int ascent=0;
      uint32_t col;

      pr=HtmlObject_GetProperties(o);

      /* select font */
      fnt=HtmlProps_GetFont(pr);
      xfnt=_getFoxFont(fnt);
      if (xfnt) {
        dc->setFont(xfnt);
        ascent=xfnt->getFontAscent();
      }

      /* select foreground color */
      col=HtmlProps_GetForegroundColor(pr);
      if (col==HTML_PROPS_NOCOLOR)
        dc->setForeground(_fgColor);
      else
        dc->setForeground(col);

      /* select background color */
      col=HtmlProps_GetBackgroundColor(pr);
      if (col==HTML_PROPS_NOCOLOR)
        dc->setBackground(_bgColor);
      else
        dc->setBackground(col);

      dc->drawText(printX, printY+ascent, HtmlObject_GetText(o));
      break;
    }

    case HtmlObjectType_Image: {
      HTML_IMAGE *img;

      img=HtmlObject_Image_GetImage(o);
      if (img) {
        FXImage *ximg;

        ximg=GWEN_INHERIT_GETDATA(HTML_IMAGE, FXImage, img);
        if (ximg) {
          HTML_PROPS *pr;
          uint32_t col;

          pr=HtmlObject_GetProperties(o);

          /* select background color */
          col=HtmlProps_GetBackgroundColor(pr);
          if (col==HTML_PROPS_NOCOLOR) {
            dc->setBackground(_bgColor);
            dc->setForeground(_bgColor);
          }
          else {
            dc->setBackground(col);
            dc->setForeground(col);
          }
          dc->fillRectangle(printX, printY, ximg->getWidth(), ximg->getHeight());

          dc->drawImage(ximg, printX, printY);
        }
      }
      break;
    }
    default:
      break;
    }


    c=HtmlObject_Tree_GetFirstChild(o);
    while(c) {
      _paintAt(dc, c, xOffset, yOffset, x, y, w, h);
      c=HtmlObject_Tree_GetNext(c);
    }
  }
}
Ejemplo n.º 14
0
void FOX16_HtmlCtx::_paint(FXDC *dc, HTML_OBJECT *o, int xOffset, int yOffset) {
  HTML_OBJECT *c;

  xOffset+=HtmlObject_GetX(o);
  yOffset+=HtmlObject_GetY(o);

  switch(HtmlObject_GetObjectType(o)) {
  case HtmlObjectType_Word: {
    HTML_PROPS *pr;
    HTML_FONT *fnt;
    FXFont *xfnt;
    int ascent=0;
    uint32_t col;

    pr=HtmlObject_GetProperties(o);

    /* select font */
    fnt=HtmlProps_GetFont(pr);
    xfnt=_getFoxFont(fnt);
    if (xfnt) {
      dc->setFont(xfnt);
      ascent=xfnt->getFontAscent();
    }

    /* select foreground color */
    col=HtmlProps_GetForegroundColor(pr);
    if (col==HTML_PROPS_NOCOLOR)
      dc->setForeground(_fgColor);
    else
      dc->setForeground(col);

    /* select background color */
    col=HtmlProps_GetBackgroundColor(pr);
    if (col==HTML_PROPS_NOCOLOR)
      dc->setBackground(_bgColor);
    else
      dc->setBackground(col);

    dc->drawText(xOffset, yOffset+ascent, HtmlObject_GetText(o));
    break;
  }

  case HtmlObjectType_Image: {
    HTML_IMAGE *img;

    img=HtmlObject_Image_GetImage(o);
    if (img) {
      FXImage *ximg;

      ximg=GWEN_INHERIT_GETDATA(HTML_IMAGE, FXImage, img);
      if (ximg) {
        HTML_PROPS *pr;
        uint32_t col;

        pr=HtmlObject_GetProperties(o);

        /* select background color */
        col=HtmlProps_GetBackgroundColor(pr);
        if (col==HTML_PROPS_NOCOLOR) {
          dc->setBackground(_bgColor);
          dc->setForeground(_bgColor);
        }
        else {
          dc->setBackground(col);
          dc->setForeground(col);
        }

        dc->fillRectangle(xOffset, yOffset, ximg->getWidth(), ximg->getHeight());

        dc->drawImage(ximg, xOffset, yOffset);
      }
    }
    break;
  }
  default:
    break;
  }

  c=HtmlObject_Tree_GetFirstChild(o);
  while(c) {
    _paint(dc, c, xOffset, yOffset);
    c=HtmlObject_Tree_GetNext(c);
  }
}