src/xfont.cpp

Go to the documentation of this file.
00001 // Copyright (c) 2003 - 2004 Anselm R. Garbe <anselmg at t-online.de>
00002 // See ../LICENSE.txt for license details.
00003 //
00004 // $Id: xfont.cpp 2 2007-05-16 10:38:27Z eg $
00005 
00006 #include "xfont.h"
00007 
00008 #include "monitor.h"
00009 #include "xcore.h"
00010 
00011 XFont::XFont(Monitor *monitor, XFontStruct *font) :
00012     WFont(monitor)
00013 {
00014     font_ = font;
00015     type_ = WFont::NORMAL;
00016 }
00017 
00018 XFont *XFont::load(Monitor *monitor, string name) {
00019 
00020     XFontStruct *font = XCORE->loadQueryFont(name);
00021     XFont *xfont = 0;
00022     if (font) {
00023         xfont = new XFont(monitor, font);
00024         xfont->setHeight(font->ascent + font->descent);
00025     }
00026     else {
00027         delete font;
00028     }
00029     return xfont;
00030 }
00031 
00032 XFont::~XFont() {
00033 }
00034 
00035 int XFont::textWidth(string text) {
00036     return XCORE->textWidth(font_, text);
00037 }
00038 
00039 unsigned int XFont::height() {
00040     return height_;
00041 }
00042 
00043 void XFont::setHeight(unsigned int height) {
00044     height_ = height;
00045 }
00046 
00047 void XFont::drawText(Window window, GC gc, int x, int y, string text) {
00048     XCORE->drawText(window, gc, x, y, text);
00049 }
00050 
00051 int XFont::ascent() {
00052     return font_->ascent;
00053 }
00054 
00055 int XFont::descent() {
00056     return font_->descent;
00057 }
00058 
00059 
00060 XFontStruct *XFont::font() const {
00061     return font_;
00062 }

Generated on Thu May 24 15:19:32 2007 for ncwm by  doxygen 1.5.1