give gc's/BPen's a width
This commit is contained in:
parent
7cac1f19ac
commit
469b9b3087
2 changed files with 24 additions and 12 deletions
|
@ -43,12 +43,17 @@ BGCCacheContext::~BGCCacheContext(void) {
|
||||||
|
|
||||||
void BGCCacheContext::set(const BColor &_color,
|
void BGCCacheContext::set(const BColor &_color,
|
||||||
const XFontStruct * const _font,
|
const XFontStruct * const _font,
|
||||||
const int _function, const int _subwindow) {
|
const int _function, const int _subwindow,
|
||||||
|
int _linewidth) {
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
pixel = gcv.foreground = _color.pixel();
|
pixel = gcv.foreground = _color.pixel();
|
||||||
function = gcv.function = _function;
|
function = gcv.function = _function;
|
||||||
subwindow = gcv.subwindow_mode = _subwindow;
|
subwindow = gcv.subwindow_mode = _subwindow;
|
||||||
unsigned long mask = GCForeground | GCFunction | GCSubwindowMode;
|
linewidth = gcv.line_width = _linewidth;
|
||||||
|
gcv.cap_style = CapProjecting;
|
||||||
|
|
||||||
|
unsigned long mask = GCForeground | GCFunction | GCSubwindowMode |
|
||||||
|
GCLineWidth | GCCapStyle;
|
||||||
|
|
||||||
if (_font) {
|
if (_font) {
|
||||||
fontid = gcv.font = _font->fid;
|
fontid = gcv.font = _font->fid;
|
||||||
|
@ -131,7 +136,7 @@ void BGCCache::release(BGCCacheContext *ctx) {
|
||||||
|
|
||||||
BGCCacheItem *BGCCache::find(const BColor &_color,
|
BGCCacheItem *BGCCache::find(const BColor &_color,
|
||||||
const XFontStruct * const _font,
|
const XFontStruct * const _font,
|
||||||
int _function, int _subwindow) {
|
int _function, int _subwindow, int _linewidth) {
|
||||||
const unsigned long pixel = _color.pixel();
|
const unsigned long pixel = _color.pixel();
|
||||||
const unsigned int screen = _color.screen();
|
const unsigned int screen = _color.screen();
|
||||||
const int key = _color.red() ^ _color.green() ^ _color.blue();
|
const int key = _color.red() ^ _color.green() ^ _color.blue();
|
||||||
|
@ -142,7 +147,8 @@ BGCCacheItem *BGCCache::find(const BColor &_color,
|
||||||
// this will either loop 8 times then return/abort or it will stop matching
|
// this will either loop 8 times then return/abort or it will stop matching
|
||||||
while (c->ctx &&
|
while (c->ctx &&
|
||||||
(c->ctx->pixel != pixel || c->ctx->function != _function ||
|
(c->ctx->pixel != pixel || c->ctx->function != _function ||
|
||||||
c->ctx->subwindow != _subwindow || c->ctx->screen != screen)) {
|
c->ctx->subwindow != _subwindow || c->ctx->screen != screen ||
|
||||||
|
c->ctx->linewidth != _linewidth)) {
|
||||||
if (i < 7) {
|
if (i < 7) {
|
||||||
prev = c;
|
prev = c;
|
||||||
c = cache[ ++k ];
|
c = cache[ ++k ];
|
||||||
|
@ -151,7 +157,7 @@ BGCCacheItem *BGCCache::find(const BColor &_color,
|
||||||
}
|
}
|
||||||
if (c->count == 0 && c->ctx->screen == screen) {
|
if (c->count == 0 && c->ctx->screen == screen) {
|
||||||
// use this cache item
|
// use this cache item
|
||||||
c->ctx->set(_color, _font, _function, _subwindow);
|
c->ctx->set(_color, _font, _function, _subwindow, _linewidth);
|
||||||
c->ctx->used = true;
|
c->ctx->used = true;
|
||||||
c->count = 1;
|
c->count = 1;
|
||||||
c->hits = 1;
|
c->hits = 1;
|
||||||
|
@ -175,7 +181,7 @@ BGCCacheItem *BGCCache::find(const BColor &_color,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c->ctx = nextContext(screen);
|
c->ctx = nextContext(screen);
|
||||||
c->ctx->set(_color, _font, _function, _subwindow);
|
c->ctx->set(_color, _font, _function, _subwindow, _linewidth);
|
||||||
c->ctx->used = true;
|
c->ctx->used = true;
|
||||||
c->count = 1;
|
c->count = 1;
|
||||||
c->hits = 1;
|
c->hits = 1;
|
||||||
|
|
|
@ -36,7 +36,7 @@ class BGCCacheItem;
|
||||||
class BGCCacheContext {
|
class BGCCacheContext {
|
||||||
public:
|
public:
|
||||||
void set(const BColor &_color, const XFontStruct * const _font,
|
void set(const BColor &_color, const XFontStruct * const _font,
|
||||||
const int _function, const int _subwindow);
|
const int _function, const int _subwindow, const int _linewidth);
|
||||||
void set(const XFontStruct * const _font);
|
void set(const XFontStruct * const _font);
|
||||||
|
|
||||||
~BGCCacheContext(void);
|
~BGCCacheContext(void);
|
||||||
|
@ -44,7 +44,7 @@ public:
|
||||||
private:
|
private:
|
||||||
BGCCacheContext(const BaseDisplay * const _display)
|
BGCCacheContext(const BaseDisplay * const _display)
|
||||||
: display(_display), gc(0), pixel(0ul), fontid(0ul),
|
: display(_display), gc(0), pixel(0ul), fontid(0ul),
|
||||||
function(0), subwindow(0), used(false), screen(~(0u)) {}
|
function(0), subwindow(0), used(false), screen(~(0u)), _linewidth(0) {}
|
||||||
|
|
||||||
const BaseDisplay *display;
|
const BaseDisplay *display;
|
||||||
GC gc;
|
GC gc;
|
||||||
|
@ -54,6 +54,7 @@ private:
|
||||||
int subwindow;
|
int subwindow;
|
||||||
bool used;
|
bool used;
|
||||||
unsigned int screen;
|
unsigned int screen;
|
||||||
|
int linewidth;
|
||||||
|
|
||||||
BGCCacheContext(const BGCCacheContext &_nocopy);
|
BGCCacheContext(const BGCCacheContext &_nocopy);
|
||||||
BGCCacheContext &operator=(const BGCCacheContext &_nocopy);
|
BGCCacheContext &operator=(const BGCCacheContext &_nocopy);
|
||||||
|
@ -89,7 +90,8 @@ public:
|
||||||
void purge(void);
|
void purge(void);
|
||||||
|
|
||||||
BGCCacheItem *find(const BColor &_color, const XFontStruct * const _font = 0,
|
BGCCacheItem *find(const BColor &_color, const XFontStruct * const _font = 0,
|
||||||
int _function = GXcopy, int _subwindow = ClipByChildren);
|
int _function = GXcopy, int _subwindow = ClipByChildren,
|
||||||
|
int _linewidth = 0);
|
||||||
void release(BGCCacheItem *_item);
|
void release(BGCCacheItem *_item);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -111,13 +113,16 @@ private:
|
||||||
class BPen {
|
class BPen {
|
||||||
public:
|
public:
|
||||||
inline BPen(const BColor &_color, const XFontStruct * const _font = 0,
|
inline BPen(const BColor &_color, const XFontStruct * const _font = 0,
|
||||||
int _function = GXcopy, int _subwindow = ClipByChildren)
|
int _function = GXcopy, int _subwindow = ClipByChildren,
|
||||||
|
int _linewidth = 0)
|
||||||
: color(_color), font(_font), function(_function), subwindow(_subwindow),
|
: color(_color), font(_font), function(_function), subwindow(_subwindow),
|
||||||
cache(_color.display()->gcCache()), item(0) { }
|
cache(_color.display()->gcCache()), item(0), linewidth(_linewidth) { }
|
||||||
|
|
||||||
inline ~BPen(void) { if (item) cache->release(item); }
|
inline ~BPen(void) { if (item) cache->release(item); }
|
||||||
|
|
||||||
inline const GC &gc(void) const {
|
inline const GC &gc(void) const {
|
||||||
if (! item) item = cache->find(color, font, function, subwindow);
|
if (! item) item = cache->find(color, font, function, subwindow,
|
||||||
|
linewidth);
|
||||||
return item->gc();
|
return item->gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +131,7 @@ private:
|
||||||
const XFontStruct *font;
|
const XFontStruct *font;
|
||||||
int function;
|
int function;
|
||||||
int subwindow;
|
int subwindow;
|
||||||
|
int linewidth;
|
||||||
|
|
||||||
mutable BGCCache *cache;
|
mutable BGCCache *cache;
|
||||||
mutable BGCCacheItem *item;
|
mutable BGCCacheItem *item;
|
||||||
|
|
Loading…
Reference in a new issue