2003-08-27 13:45:11 +00:00
|
|
|
// GContext.hh for FbTk - fluxbox toolkit
|
2005-01-24 18:02:34 +00:00
|
|
|
// Copyright (c) 2003-2004 Henrik Kinnunen (fluxgen at fluxbox dot org)
|
2003-08-27 13:45:11 +00:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2004-11-19 11:37:27 +00:00
|
|
|
// $Id$
|
2003-08-27 13:45:11 +00:00
|
|
|
|
|
|
|
#ifndef FBTK_GCONTEXT_HH
|
|
|
|
#define FBTK_GCONTEXT_HH
|
|
|
|
|
2003-10-09 16:48:09 +00:00
|
|
|
#include "Color.hh"
|
|
|
|
#include "FbPixmap.hh"
|
|
|
|
|
2003-08-27 13:45:11 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
|
|
|
|
namespace FbTk {
|
|
|
|
|
|
|
|
class FbDrawable;
|
|
|
|
class Font;
|
|
|
|
|
|
|
|
/// wrapper for X GC
|
|
|
|
class GContext {
|
|
|
|
public:
|
2004-03-22 20:56:15 +00:00
|
|
|
|
2004-10-18 20:10:37 +00:00
|
|
|
typedef enum { JOINMITER= JoinMiter,
|
|
|
|
JOINROUND= JoinRound,
|
|
|
|
JOINBEVEL= JoinBevel
|
|
|
|
} JoinStyle;
|
|
|
|
|
|
|
|
typedef enum { LINESOLID= LineSolid,
|
|
|
|
LINEONOFFDASH= LineOnOffDash,
|
|
|
|
LINEDOUBLEDASH= LineDoubleDash
|
|
|
|
} LineStyle;
|
|
|
|
|
|
|
|
typedef enum { CAPNOTLAST= CapNotLast,
|
|
|
|
CAPBUTT= CapButt,
|
|
|
|
CAPROUND= CapRound,
|
|
|
|
CAPPROJECTING= CapProjecting
|
|
|
|
} CapStyle;
|
2004-03-22 20:56:15 +00:00
|
|
|
|
2003-08-27 13:45:11 +00:00
|
|
|
/// for FbTk drawable
|
|
|
|
explicit GContext(const FbTk::FbDrawable &drawable);
|
|
|
|
/// for X drawable
|
|
|
|
explicit GContext(Drawable drawable);
|
2003-11-28 22:50:55 +00:00
|
|
|
GContext(Drawable d, const FbTk::GContext &gc);
|
2003-08-27 13:45:11 +00:00
|
|
|
virtual ~GContext();
|
|
|
|
|
2003-10-09 16:48:09 +00:00
|
|
|
inline void setForeground(const FbTk::Color &color) {
|
|
|
|
setForeground(color.pixel());
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setForeground(long pixel_value) {
|
|
|
|
XSetForeground(m_display, m_gc,
|
|
|
|
pixel_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setBackground(const FbTk::Color &color) {
|
|
|
|
setBackground(color.pixel());
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setBackground(long pixel_value) {
|
|
|
|
XSetBackground(m_display, m_gc, pixel_value);
|
|
|
|
}
|
|
|
|
|
2004-10-06 06:50:27 +00:00
|
|
|
inline void setTile(Drawable draw) {
|
|
|
|
XSetTile(m_display, m_gc, draw);
|
|
|
|
}
|
|
|
|
|
2004-07-06 10:47:36 +00:00
|
|
|
inline void setTile(const FbTk::FbPixmap &draw) {
|
2004-10-06 06:50:27 +00:00
|
|
|
setTile(draw.drawable());
|
2004-07-06 10:47:36 +00:00
|
|
|
}
|
|
|
|
|
2003-09-11 19:57:38 +00:00
|
|
|
/// not implemented
|
2003-12-16 17:06:52 +00:00
|
|
|
inline void setFont(const FbTk::Font &) {}
|
2003-10-09 16:48:09 +00:00
|
|
|
|
2003-09-11 19:57:38 +00:00
|
|
|
/// set font id
|
2003-10-09 16:48:09 +00:00
|
|
|
inline void setFont(int fid) {
|
|
|
|
XSetFont(m_display, m_gc, fid);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setClipMask(const FbTk::FbPixmap &mask) {
|
|
|
|
XSetClipMask(m_display, m_gc, mask.drawable());
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setClipOrigin(int x, int y) {
|
|
|
|
XSetClipOrigin(m_display, m_gc, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setGraphicsExposure(bool value) {
|
|
|
|
XSetGraphicsExposures(m_display, m_gc, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setFunction(int func) {
|
|
|
|
XSetFunction(m_display, m_gc, func);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setSubwindowMode(int mode) {
|
|
|
|
XSetSubwindowMode(m_display, m_gc, mode);
|
|
|
|
}
|
2004-01-11 12:53:46 +00:00
|
|
|
inline void setFillStyle(int style) {
|
|
|
|
XSetFillStyle(m_display, m_gc, style);
|
|
|
|
}
|
|
|
|
inline void setFillRule(int rule) {
|
|
|
|
XSetFillRule(m_display, m_gc, rule);
|
|
|
|
}
|
2003-09-11 19:57:38 +00:00
|
|
|
|
2004-03-22 20:56:15 +00:00
|
|
|
inline void setLineAttributes(unsigned int width,
|
|
|
|
int line_style,
|
|
|
|
int cap_style,
|
|
|
|
int join_style) {
|
|
|
|
|
|
|
|
XSetLineAttributes(m_display, m_gc, width, line_style, cap_style, join_style);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-28 22:50:55 +00:00
|
|
|
void copy(GC gc);
|
|
|
|
void copy(const GContext &gc);
|
|
|
|
inline GContext &operator = (const GContext ©_gc) { copy(copy_gc); return *this; }
|
|
|
|
inline GContext &operator = (GC copy_gc) { copy(copy_gc); return *this; }
|
2003-10-09 16:48:09 +00:00
|
|
|
inline GC gc() const { return m_gc; }
|
2003-08-27 13:45:11 +00:00
|
|
|
|
|
|
|
private:
|
2003-11-28 22:50:55 +00:00
|
|
|
GContext(const GContext &cont);
|
|
|
|
|
2004-01-09 01:19:48 +00:00
|
|
|
static Display *m_display; // worth caching
|
2003-08-27 13:45:11 +00:00
|
|
|
GC m_gc;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace FbTk
|
|
|
|
|
|
|
|
#endif // FBTK_GCONTEXT_HH
|