Font::drawText takes reference to FbDrawable instead of X Drawable + some code cleaning

This commit is contained in:
fluxgen 2004-09-11 23:01:34 +00:00
parent acd2176355
commit 049e40c9eb
18 changed files with 137 additions and 135 deletions

View file

@ -1,5 +1,5 @@
// FbDrawable.cc for FbTk - Fluxbox ToolKit
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
// Copyright (c) 2003-2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: FbDrawable.cc,v 1.3 2004/09/10 15:46:08 akir Exp $
// $Id: FbDrawable.cc,v 1.4 2004/09/11 22:58:20 fluxgen Exp $
#include "FbDrawable.hh"
@ -37,9 +37,9 @@ FbDrawable::FbDrawable() {
}
void FbDrawable::copyArea(Drawable src, GC gc,
int src_x, int src_y,
int dest_x, int dest_y,
unsigned int width, unsigned int height) {
int src_x, int src_y,
int dest_x, int dest_y,
unsigned int width, unsigned int height) {
if (drawable() == 0 || src == 0 || gc == 0)
return;
XCopyArea(s_display,
@ -50,7 +50,7 @@ void FbDrawable::copyArea(Drawable src, GC gc,
}
void FbDrawable::fillRectangle(GC gc, int x, int y,
unsigned int width, unsigned int height) {
unsigned int width, unsigned int height) {
if (drawable() == 0 || gc == 0)
return;
XFillRectangle(s_display,
@ -60,7 +60,7 @@ void FbDrawable::fillRectangle(GC gc, int x, int y,
}
void FbDrawable::drawRectangle(GC gc, int x, int y,
unsigned int width, unsigned int height) {
unsigned int width, unsigned int height) {
if (drawable() == 0 || gc == 0)
return;
XDrawRectangle(s_display,
@ -70,7 +70,7 @@ void FbDrawable::drawRectangle(GC gc, int x, int y,
}
void FbDrawable::drawLine(GC gc, int start_x, int start_y,
int end_x, int end_y) {
int end_x, int end_y) {
if (drawable() == 0 || gc == 0)
return;
XDrawLine(s_display,
@ -81,7 +81,7 @@ void FbDrawable::drawLine(GC gc, int start_x, int start_y,
}
void FbDrawable::fillPolygon(GC gc, XPoint *points, int npoints,
int shape, int mode) {
int shape, int mode) {
if (drawable() == 0 || gc == 0 || points == 0 || npoints == 0)
return;
XFillPolygon(s_display,

View file

@ -1,5 +1,5 @@
// FbDrawable.hh for FbTk - Fluxbox ToolKit
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
// Copyright (c) 2003-2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: FbDrawable.hh,v 1.6 2004/09/11 20:30:28 fluxgen Exp $
// $Id: FbDrawable.hh,v 1.7 2004/09/11 22:58:20 fluxgen Exp $
#ifndef FBTK_FBDRAWABLE_HH
#define FBTK_FBDRAWABLE_HH
@ -56,7 +56,7 @@ public:
virtual Drawable drawable() const = 0;
virtual unsigned int width() const = 0;
virtual unsigned int height() const = 0;
inline Display *display() const { return s_display; }
static inline Display *display() { return s_display; }
protected:
static Display *s_display; // display connection // display connection
};

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: FbPixmap.cc,v 1.15 2004/09/11 12:33:14 rathnor Exp $
// $Id: FbPixmap.cc,v 1.16 2004/09/11 22:58:20 fluxgen Exp $
#include "FbPixmap.hh"
#include "App.hh"
@ -90,7 +90,7 @@ FbPixmap &FbPixmap::operator = (Pixmap pm) {
Window root;
int x, y;
unsigned int border_width, bpp;
XGetGeometry(s_display,
XGetGeometry(display(),
pm,
&root,
&x, &y,
@ -148,7 +148,7 @@ void FbPixmap::copy(Pixmap pm) {
unsigned int border_width, bpp;
unsigned int new_width, new_height;
XGetGeometry(s_display,
XGetGeometry(display(),
pm,
&root,
&x, &y,
@ -158,20 +158,20 @@ void FbPixmap::copy(Pixmap pm) {
// create new pixmap and copy area
create(root, new_width, new_height, bpp);
GC gc = XCreateGC(s_display, drawable(), 0, 0);
GC gc = XCreateGC(display(), drawable(), 0, 0);
XCopyArea(s_display, pm, drawable(), gc,
XCopyArea(display(), pm, drawable(), gc,
0, 0,
width(), height(),
0, 0);
XFreeGC(s_display, gc);
XFreeGC(display(), gc);
}
void FbPixmap::rotate() {
// make an image copy
XImage *src_image = XGetImage(s_display, drawable(),
XImage *src_image = XGetImage(display(), drawable(),
0, 0, // pos
width(), height(), // size
~0, // plane mask
@ -186,7 +186,7 @@ void FbPixmap::rotate() {
for (unsigned int x = 0; x < width(); ++x) {
gc.setForeground(XGetPixel(src_image, x, y));
// revers coordinates
XDrawPoint(s_display, new_pm.drawable(), gc.gc(), y, x);
XDrawPoint(display(), new_pm.drawable(), gc.gc(), y, x);
}
}
@ -206,7 +206,7 @@ void FbPixmap::scale(unsigned int dest_width, unsigned int dest_height) {
(dest_width == width() && dest_height == height()))
return;
XImage *src_image = XGetImage(s_display, drawable(),
XImage *src_image = XGetImage(display(), drawable(),
0, 0, // pos
width(), height(), // size
~0, // plane mask
@ -230,7 +230,7 @@ void FbPixmap::scale(unsigned int dest_width, unsigned int dest_height) {
gc.setForeground(XGetPixel(src_image,
static_cast<int>(src_x),
static_cast<int>(src_y)));
XDrawPoint(s_display, new_pm.drawable(), gc.gc(), tx, ty);
XDrawPoint(display(), new_pm.drawable(), gc.gc(), tx, ty);
}
}
@ -306,9 +306,9 @@ Pixmap FbPixmap::getRootPixmap(int screen_num) {
Pixmap root_pm = None;
for (prop = 0; prop_ids[prop]; prop++) {
if (XGetWindowProperty(s_display,
RootWindow(s_display, screen_num),
XInternAtom(s_display, prop_ids[prop], False),
if (XGetWindowProperty(display(),
RootWindow(display(), screen_num),
XInternAtom(display(), prop_ids[prop], False),
0l, 4l,
False, XA_PIXMAP,
&real_type, &real_format,
@ -333,7 +333,7 @@ Pixmap FbPixmap::getRootPixmap(int screen_num) {
void FbPixmap::free() {
if (m_pm != 0) {
XFreePixmap(s_display, m_pm);
XFreePixmap(display(), m_pm);
m_pm = 0;
}
m_width = 0;
@ -347,7 +347,7 @@ void FbPixmap::create(Drawable src,
if (src == 0)
return;
m_pm = XCreatePixmap(s_display,
m_pm = XCreatePixmap(display(),
src, width, height, depth);
if (m_pm == 0)
return;

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: FbWindow.cc,v 1.41 2004/09/11 15:52:23 rathnor Exp $
// $Id: FbWindow.cc,v 1.42 2004/09/11 22:59:15 fluxgen Exp $
#include "FbWindow.hh"
#include "FbPixmap.hh"
@ -74,7 +74,7 @@ FbWindow::FbWindow(int screen_num,
m_destroy(true),
m_buffer_pm(0) {
create(RootWindow(s_display, screen_num),
create(RootWindow(display(), screen_num),
x, y, width, height, eventmask,
override_redirect, save_unders, depth, class_type);
};
@ -119,44 +119,44 @@ FbWindow::~FbWindow() {
// so we don't get any dangling eventhandler for this window
FbTk::EventManager::instance()->remove(m_window);
if (m_destroy)
XDestroyWindow(s_display, m_window);
XDestroyWindow(display(), m_window);
}
}
void FbWindow::setBackgroundColor(const FbTk::Color &bg_color) {
XSetWindowBackground(s_display, m_window, bg_color.pixel());
XSetWindowBackground(display(), m_window, bg_color.pixel());
}
void FbWindow::setBackgroundPixmap(Pixmap bg_pixmap) {
XSetWindowBackgroundPixmap(s_display, m_window, bg_pixmap);
XSetWindowBackgroundPixmap(display(), m_window, bg_pixmap);
}
void FbWindow::setBorderColor(const FbTk::Color &border_color) {
XSetWindowBorder(s_display, m_window, border_color.pixel());
XSetWindowBorder(display(), m_window, border_color.pixel());
}
void FbWindow::setBorderWidth(unsigned int size) {
XSetWindowBorderWidth(s_display, m_window, size);
XSetWindowBorderWidth(display(), m_window, size);
m_border_width = size;
}
void FbWindow::setName(const char *name) {
XStoreName(s_display, m_window, name);
XStoreName(display(), m_window, name);
}
void FbWindow::setEventMask(long mask) {
XSelectInput(s_display, m_window, mask);
XSelectInput(display(), m_window, mask);
}
void FbWindow::clear() {
XClearWindow(s_display, m_window);
XClearWindow(display(), m_window);
}
void FbWindow::clearArea(int x, int y,
unsigned int width, unsigned int height,
bool exposures) {
XClearArea(s_display, window(), x, y, width, height, exposures);
XClearArea(display(), window(), x, y, width, height, exposures);
}
void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, unsigned int the_height) {
@ -255,7 +255,7 @@ FbWindow &FbWindow::operator = (Window win) {
void FbWindow::setNew(Window win) {
if (m_window != 0 && m_destroy)
XDestroyWindow(s_display, m_window);
XDestroyWindow(display(), m_window);
m_window = win;
@ -264,7 +264,7 @@ void FbWindow::setNew(Window win) {
XWindowAttributes attr;
attr.screen = 0;
//get screen number
if (XGetWindowAttributes(s_display,
if (XGetWindowAttributes(display(),
m_window,
&attr) != 0 && attr.screen != 0) {
m_screen_num = XScreenNumberOfScreen(attr.screen);
@ -288,39 +288,39 @@ void FbWindow::setNew(Window win) {
}
void FbWindow::show() {
XMapWindow(s_display, m_window);
XMapWindow(display(), m_window);
}
void FbWindow::showSubwindows() {
XMapSubwindows(s_display, m_window);
XMapSubwindows(display(), m_window);
}
void FbWindow::hide() {
XUnmapWindow(s_display, m_window);
XUnmapWindow(display(), m_window);
}
void FbWindow::lower() {
XLowerWindow(s_display, window());
XLowerWindow(display(), window());
}
void FbWindow::raise() {
XRaiseWindow(s_display, window());
XRaiseWindow(display(), window());
}
void FbWindow::setInputFocus(int revert_to, int time) {
XSetInputFocus(s_display, window(), revert_to, time);
XSetInputFocus(display(), window(), revert_to, time);
}
void FbWindow::setCursor(Cursor cur) {
XDefineCursor(s_display, window(), cur);
XDefineCursor(display(), window(), cur);
}
void FbWindow::unsetCursor() {
XUndefineCursor(s_display, window());
XUndefineCursor(display(), window());
}
void FbWindow::reparent(const FbWindow &parent, int x, int y, bool continuing) {
XReparentWindow(s_display, window(), parent.window(), x, y);
XReparentWindow(display(), window(), parent.window(), x, y);
m_parent = &parent;
if (continuing) // we will continue managing this window after reparent
updateGeometry();
@ -332,7 +332,7 @@ std::string FbWindow::textProperty(Atom property) const {
int count;
std::string ret;
if (XGetTextProperty(s_display, window(), &text_prop, property) == 0)
if (XGetTextProperty(display(), window(), &text_prop, property) == 0)
return "";
if (text_prop.value == 0 || text_prop.nitems == 0)
@ -340,7 +340,7 @@ std::string FbWindow::textProperty(Atom property) const {
if (text_prop.encoding != XA_STRING) {
// still returns a "StringList" despite the different name
if (XmbTextPropertyToTextList(s_display, &text_prop, &stringlist, &count) == 0 || count == 0)
if (XmbTextPropertyToTextList(display(), &text_prop, &stringlist, &count) == 0 || count == 0)
return "";
} else {
if (XTextPropertyToStringList(&text_prop, &stringlist, &count) == 0 || count == 0)
@ -362,7 +362,7 @@ bool FbWindow::property(Atom property,
unsigned long *nitems_return,
unsigned long *bytes_after_return,
unsigned char **prop_return) const {
if (XGetWindowProperty(s_display, window(),
if (XGetWindowProperty(display(), window(),
property, long_offset, long_length, do_delete,
req_type, actual_type_return,
actual_format_return, nitems_return,
@ -378,7 +378,7 @@ void FbWindow::changeProperty(Atom property, Atom type,
unsigned char *data,
int nelements) {
XChangeProperty(s_display, m_window, property, type,
XChangeProperty(display(), m_window, property, type,
format, mode,
data, nelements);
}
@ -389,7 +389,7 @@ int FbWindow::screenNumber() const {
long FbWindow::eventMask() const {
XWindowAttributes attrib;
XGetWindowAttributes(s_display, window(),
XGetWindowAttributes(display(), window(),
&attrib);
return attrib.your_event_mask;
@ -405,7 +405,7 @@ void FbWindow::updateGeometry() {
Window root;
unsigned int border_width, depth;
XGetGeometry(s_display, m_window, &root, &m_x, &m_y,
XGetGeometry(display(), m_window, &root, &m_x, &m_y,
(unsigned int *)&m_width, (unsigned int *)&m_height,
&border_width, &depth);
m_depth = depth;
@ -433,7 +433,7 @@ void FbWindow::create(Window parent, int x, int y,
values.save_under = True;
}
m_window = XCreateWindow(s_display, parent, x, y, width, height,
m_window = XCreateWindow(display(), parent, x, y, width, height,
0, // border width
depth, // depth
class_type, // class

View file

@ -1,5 +1,5 @@
// Font.cc
// Copyright (c) 2002-2004 Henrik Kinnunen (fluxgen@linuxmail.org)
// Copyright (c) 2002-2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//$Id: Font.cc,v 1.20 2004/09/03 14:17:47 akir Exp $
//$Id: Font.cc,v 1.21 2004/09/11 22:58:20 fluxgen Exp $
#include "StringUtil.hh"
@ -350,7 +350,7 @@ void Font::setAntialias(bool flag) {
bool Font::load(const std::string &name) {
if (name.size() == 0)
return false;
// default values for font options
m_shadow = false;
m_halo = false;
@ -380,12 +380,12 @@ bool Font::load(const std::string &name) {
else if ( (*token).find("shadow", 0) != std::string::npos ) {
m_shadow= true;
extract_shadow_options(*token, m_shadow_color, m_shadow_offx, m_shadow_offy);
}
}
else {
if ( !firstone )
fname+= ", ";
fname+= ", ";
else
firstone= false;
firstone= false;
fname= fname + *token;
}
}
@ -424,7 +424,7 @@ int Font::descent() const {
return m_fontimp->descent();
}
void Font::drawText(Drawable w, int screen, GC gc,
void Font::drawText(const FbDrawable &w, int screen, GC gc,
const char *text, size_t len, int x, int y,
bool rotate) const {
if (text == 0 || len == 0)
@ -450,12 +450,12 @@ void Font::drawText(Drawable w, int screen, GC gc,
// draw "effects" first
if (first_run) {
if (m_shadow) {
FbTk::GContext shadow_gc(w);
FbTk::GContext shadow_gc(w);
shadow_gc.setForeground(FbTk::Color(m_shadow_color.c_str(), screen));
first_run = false;
drawText(w, screen, shadow_gc.gc(), real_text, len,
x + m_shadow_offx, y + m_shadow_offy, rotate);
first_run = true;
first_run = true;
} else if (m_halo) {
FbTk::GContext halo_gc(w);
halo_gc.setForeground(FbTk::Color(m_halo_color.c_str(), screen));

View file

@ -1,5 +1,5 @@
// Font.cc for FbTk
// Copyright (c) 2002 Henrik Kinnunen (fluxgen at linuxmail.org)
// Copyright (c) 2002-2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//$Id: Font.hh,v 1.12 2004/08/31 21:24:05 fluxgen Exp $
//$Id: Font.hh,v 1.13 2004/09/11 22:58:20 fluxgen Exp $
#ifndef FBTK_FONT_HH
#define FBTK_FONT_HH
@ -43,6 +43,7 @@ namespace FbTk {
void fontInit();
class FontImp;
class FbDrawable;
/**
Handles the client to fontimp bridge.
@ -92,7 +93,7 @@ public:
@param y position
@param rotate if the text should be drawn rotated (if it's rotated before)
*/
void drawText(Drawable w, int screen, GC gc,
void drawText(const FbDrawable &w, int screen, GC gc,
const char *text, size_t len,
int x, int y, bool rotate=true) const;
bool isAntialias() const { return m_antialias; }

View file

@ -1,5 +1,5 @@
// FontImp.cc for FbTk
// Copyright (c) 2002-2003 Henrik Kinnunen (fluxgen(at)users.sourceforge.net)
// Copyright (c) 2002-2004 Henrik Kinnunen (fluxgen(at)users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: FontImp.hh,v 1.3 2003/04/20 13:52:29 fluxgen Exp $
// $Id: FontImp.hh,v 1.4 2004/09/11 22:58:20 fluxgen Exp $
#ifndef FBTK_FONTIMP_HH
#define FBTK_FONTIMP_HH
@ -32,6 +32,8 @@
namespace FbTk {
class FbDrawable;
/**
FontImp, second part of the bridge pattern for fonts
pure interface class.
@ -41,7 +43,7 @@ class FontImp {
public:
virtual ~FontImp() { }
virtual bool load(const std::string &name) = 0;
virtual void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const = 0;
virtual void drawText(const FbDrawable &w, int screen, GC gc, const char *text, size_t len, int x, int y) const = 0;
virtual unsigned int textWidth(const char * const text, unsigned int size) const = 0;
virtual int ascent() const = 0;
virtual int descent() const = 0;

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Menu.cc,v 1.83 2004/09/11 15:52:23 rathnor Exp $
// $Id: Menu.cc,v 1.84 2004/09/11 22:59:15 fluxgen Exp $
//use GNU extensions
#ifndef _GNU_SOURCE
@ -312,7 +312,7 @@ void Menu::nextItem() {
drawItem(which_press,
true, // clear
true); // transp
}
void Menu::prevItem() {
@ -774,7 +774,7 @@ void Menu::redrawTitle() {
// difference between height based on font, and style-set height
int height_offset = theme().titleHeight() - (font.height() + 2*theme().bevelWidth());
menu.title.updateTransparent();
font.drawText(m_real_title_pm.drawable(), // drawable
font.drawText(m_real_title_pm, // drawable
screenNumber(),
theme().titleTextGC().gc(), // graphic context
text, len, // text string with length
@ -1144,21 +1144,13 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) {
re.y > iy && re.y < (signed) (iy + theme().itemHeight())) {
menuitems[w]->click(re.button, re.time);
itemSelected(re.button, w);
drawItem(w,
true, // clear
true); // transparent
}
} else {
drawItem(p,
true, // clear
true); // transparent
}
} else {
drawItem(p,
true, // clear
true); // transparent
}
drawItem(p,
true, // clear
true); // transparent
}
}

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: MenuItem.cc,v 1.9 2004/09/10 16:48:15 akir Exp $
// $Id: MenuItem.cc,v 1.10 2004/09/11 23:00:08 fluxgen Exp $
#include "MenuItem.hh"
#include "Command.hh"
@ -104,7 +104,7 @@ void MenuItem::draw(FbDrawable &draw,
break;
}
theme.frameFont().drawText(draw.drawable(), // drawable
theme.frameFont().drawText(draw, // drawable
theme.screenNum(),
tgc.gc(),
m_label.c_str(), m_label.size(), // text string and lenght

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: TextBox.cc,v 1.12 2004/08/31 15:26:39 rathnor Exp $
// $Id: TextBox.cc,v 1.13 2004/09/11 22:58:20 fluxgen Exp $
#include "TextBox.hh"
#include "Font.hh"
@ -157,7 +157,7 @@ void TextBox::clear() {
if (gc() == 0)
setGC(DefaultGC(FbTk::App::instance()->display(), screenNumber()));
font().drawText(window(), screenNumber(),
font().drawText(*this, screenNumber(),
gc(),
text().c_str() + m_start_pos,
m_end_pos - m_start_pos,

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: TextButton.cc,v 1.5 2004/01/09 02:19:02 fluxgen Exp $
// $Id: TextButton.cc,v 1.6 2004/09/11 22:58:20 fluxgen Exp $
#include "TextButton.hh"
#include "Font.hh"
@ -142,8 +142,11 @@ void TextButton::drawText(int x_offset, int y_offset) {
// center text by default
int center_pos = height()/2 + font().ascent()/2 - 1;
FbDrawable *drawable = &m_buffer;
if (backgroundPixmap() == ParentRelative)
drawable = this;
font().drawText(backgroundPixmap() == ParentRelative ? window() : m_buffer.drawable(),
font().drawText(*drawable,
screenNumber(),
gc(), // graphic context
text().c_str(), textlen, // string and string size

View file

@ -1,5 +1,5 @@
// XFontImp.cc for FbTk fluxbox toolkit
// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
// Copyright (c) 2002-2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: XFontImp.cc,v 1.9 2004/08/31 15:26:39 rathnor Exp $
// $Id: XFontImp.cc,v 1.10 2004/09/11 22:58:20 fluxgen Exp $
#include "XFontImp.hh"
#include "App.hh"
@ -79,18 +79,17 @@ bool XFontImp::load(const std::string &fontname) {
return true;
}
void XFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const {
void XFontImp::drawText(const FbDrawable &w, int screen, GC gc, const char *text, size_t len, int x, int y) const {
if (m_fontstruct == 0)
return;
// use roated font functions?
if (m_rotfont != 0 && m_rotate) {
drawRotText(w, screen, gc, text, len, x, y);
drawRotText(w.drawable(), screen, gc, text, len, x, y);
return;
}
Display *disp = App::instance()->display();
XSetFont(disp, gc, m_fontstruct->fid);
XDrawString(disp, w, gc, x, y, text, len);
XSetFont(w.display(), gc, m_fontstruct->fid);
XDrawString(w.display(), w.drawable(), gc, x, y, text, len);
}
unsigned int XFontImp::textWidth(const char * const text, unsigned int size) const {

View file

@ -1,5 +1,5 @@
// XFontImp.hh for FbTk fluxbox toolkit
// Copyright (c) 2002-2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
// Copyright (c) 2002-2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: XFontImp.hh,v 1.5 2003/12/16 17:06:52 fluxgen Exp $
// $Id: XFontImp.hh,v 1.6 2004/09/11 22:58:20 fluxgen Exp $
#ifndef FBTK_XFONTIMP_HH
#define FBTK_XFONTIMP_HH
@ -41,7 +41,7 @@ public:
float angle() const { return m_angle; }
int ascent() const;
int descent() const { return m_fontstruct ? m_fontstruct->descent : 0; }
void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const;
void drawText(const FbDrawable &w, int screen, GC gc, const char *text, size_t len, int x, int y) const;
bool loaded() const { return m_fontstruct != 0; }
void rotate(float angle);
/// enable/disable rotation witout alloc/dealloc rotfont structures

View file

@ -1,5 +1,5 @@
// XftFontImp.cc Xft font implementation for FbTk
// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
// Copyright (c) 2002-2004 Henrik Kinnunen (fluxgen@linuxmail.org)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@ -19,10 +19,11 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//$Id: XftFontImp.cc,v 1.5 2004/09/10 16:12:49 akir Exp $
//$Id: XftFontImp.cc,v 1.6 2004/09/11 22:58:20 fluxgen Exp $
#include "XftFontImp.hh"
#include "App.hh"
#include "FbDrawable.hh"
#ifdef HAVE_CONFIG_H
#include "config.h"
@ -32,6 +33,7 @@ namespace FbTk {
XftFontImp::XftFontImp(const char *name, bool utf8):m_xftfont(0),
m_utf8mode(utf8) {
if (name != 0)
load(name);
}
@ -61,25 +63,24 @@ bool XftFontImp::load(const std::string &name) {
return true;
}
void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const {
void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const char *text, size_t len, int x, int y) const {
if (m_xftfont == 0)
return;
Display *disp = App::instance()->display();
XftDraw *draw = XftDrawCreate(disp,
w,
DefaultVisual(disp, screen),
DefaultColormap(disp, screen));
XftDraw *draw = XftDrawCreate(w.display(),
w.drawable(),
DefaultVisual(w.display(), screen),
DefaultColormap(w.display(), screen));
XGCValues gc_val;
// get foreground pixel value and convert it to XRenderColor value
// TODO: we should probably check return status
XGetGCValues(disp, gc, GCForeground, &gc_val);
XGetGCValues(w.display(), gc, GCForeground, &gc_val);
// get red, green, blue values
XColor xcol;
xcol.pixel = gc_val.foreground;
XQueryColor(disp, DefaultColormap(disp, screen), &xcol);
XQueryColor(w.display(), DefaultColormap(w.display(), screen), &xcol);
// convert xcolor to XftColor
XRenderColor rendcol;
@ -88,7 +89,9 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
rendcol.blue = xcol.blue;
rendcol.alpha = 0xFFFF;
XftColor xftcolor;
XftColorAllocValue(disp, DefaultVisual(disp, screen), DefaultColormap(disp, screen),
XftColorAllocValue(w.display(),
DefaultVisual(w.display(), screen),
DefaultColormap(w.display(), screen),
&rendcol, &xftcolor);
// draw string
@ -97,7 +100,7 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
// check the string size,
// if the size is zero we use the XftDrawString8 function instead.
XGlyphInfo ginfo;
XftTextExtentsUtf8(App::instance()->display(),
XftTextExtentsUtf8(w.display(),
m_xftfont,
(XftChar8 *)text, len,
&ginfo);
@ -107,8 +110,9 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
m_xftfont,
x, y,
(XftChar8 *)(text), len);
XftColorFree(disp, DefaultVisual(disp, screen),
DefaultColormap(disp, screen), &xftcolor);
XftColorFree(w.display(),
DefaultVisual(w.display(), screen),
DefaultColormap(w.display(), screen), &xftcolor);
XftDrawDestroy(draw);
return;
}
@ -122,8 +126,9 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
(XftChar8 *)(text), len);
XftColorFree(disp, DefaultVisual(disp, screen),
DefaultColormap(disp, screen), &xftcolor);
XftColorFree(w.display(),
DefaultVisual(w.display(), screen),
DefaultColormap(w.display(), screen), &xftcolor);
XftDrawDestroy(draw);
}

View file

@ -1,5 +1,5 @@
// XftFontImp.hh Xft font implementation for FbTk
// Copyright (c) 2002-2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
// Copyright (c) 2002-2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//$Id: XftFontImp.hh,v 1.4 2003/12/16 17:06:52 fluxgen Exp $
//$Id: XftFontImp.hh,v 1.5 2004/09/11 22:58:20 fluxgen Exp $
#ifndef FBTK_XFTFONTIMP_HH
#define FBTK_XFTFONTIMP_HH
@ -36,7 +36,7 @@ public:
XftFontImp(const char *fontname, bool utf8);
~XftFontImp();
bool load(const std::string &name);
void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const;
void drawText(const FbDrawable &w, int screen, GC gc, const char *text, size_t len, int x, int y) const;
unsigned int textWidth(const char * const text, unsigned int len) const;
unsigned int height() const;
int ascent() const { return m_xftfont ? m_xftfont->ascent : 0; }

View file

@ -19,12 +19,13 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: XmbFontImp.cc,v 1.12 2004/09/10 16:12:01 akir Exp $
// $Id: XmbFontImp.cc,v 1.13 2004/09/11 22:58:20 fluxgen Exp $
#include "XmbFontImp.hh"
#include "App.hh"
#include "StringUtil.hh"
#include "FbDrawable.hh"
#ifdef HAVE_CONFIG_H
#include "config.h"
@ -224,22 +225,21 @@ bool XmbFontImp::load(const std::string &fontname) {
return true;
}
void XmbFontImp::drawText(Drawable w, int screen, GC gc, const char *text,
void XmbFontImp::drawText(const FbDrawable &w, int screen, GC gc, const char *text,
size_t len, int x, int y) const {
if (text == 0 || len == 0 || w == 0 || m_fontset == 0)
if (m_fontset == 0)
return;
Display* disp = App::instance()->display();
#ifdef X_HAVE_UTF8_STRING
if (m_utf8mode) {
Xutf8DrawString(disp, w, m_fontset,
gc, x, y,
text, len);
Xutf8DrawString(w.display(), w.drawable(), m_fontset,
gc, x, y,
text, len);
} else
#endif //X_HAVE_UTF8_STRING
{
XmbDrawString(disp, w, m_fontset,
XmbDrawString(w.display(), w.drawable(), m_fontset,
gc, x, y,
text, len);
}

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: XmbFontImp.hh,v 1.4 2003/12/16 17:06:52 fluxgen Exp $
// $Id: XmbFontImp.hh,v 1.5 2004/09/11 22:58:20 fluxgen Exp $
#ifndef FBTK_XMBFONTIMP_HH
#define FBTK_XMBFONTIMP_HH
@ -36,7 +36,7 @@ public:
XmbFontImp(const char *fontname, bool utf8);
~XmbFontImp();
bool load(const std::string &name);
virtual void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const;
virtual void drawText(const FbDrawable &w, int screen, GC gc, const char *text, size_t len, int x, int y) const;
unsigned int textWidth(const char * const text, unsigned int len) const;
unsigned int height() const;
int ascent() const { return m_setextents ? -m_setextents->max_ink_extent.y : 0; }

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Screen.cc,v 1.290 2004/09/11 13:30:37 fluxgen Exp $
// $Id: Screen.cc,v 1.291 2004/09/11 23:01:34 fluxgen Exp $
#include "Screen.hh"
@ -1871,7 +1871,7 @@ void BScreen::showPosition(int x, int y) {
m_pos_window.clear();
winFrameTheme().font().drawText(m_pos_window.window(),
winFrameTheme().font().drawText(m_pos_window,
screenNumber(),
winFrameTheme().labelTextFocusGC(),
label, strlen(label),
@ -1916,13 +1916,13 @@ void BScreen::showGeometry(unsigned int gx, unsigned int gy) {
sprintf(label,
_FBTEXT(Screen, GeometryFormat,
"W: %4d x H: %4d",
"Format for width and height window, %4d for widht, and %4d for height"),
"Format for width and height window, %4d for width, and %4d for height"),
gx, gy);
m_geom_window.clear();
//!! TODO: geom window again?! repeated
winFrameTheme().font().drawText(m_geom_window.window(),
winFrameTheme().font().drawText(m_geom_window,
screenNumber(),
winFrameTheme().labelTextFocusGC(),
label, strlen(label),