1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-07 00:35:53 +01:00

- API change in WINGs for WMDraw*String().

WMDrawString() and WMDrawImageString() now take WMColor instead of GC as
  arguments. WMDrawImageString() receives 2 colors (text & background).
  This is to allow easy extension for Xft/Xrender and hide X low level details
- Added alpha channel to WMColor. 2 new functions also:
  WMCreateRGBAColor() and WMSetColorAlpha()
- Miscelaneous code cleanups in wtext.c
- Removed obsoleted acconfig.h and implemented its functionality using
  AC_DEFINE and AC_DEFINE_UNQUOTED as autoconf 2.5x recommends.
  This will definitely enforce the need to use autoconf 2.5x
This commit is contained in:
dan
2002-10-08 08:26:06 +00:00
parent e98da5a628
commit a2b404b5b3
58 changed files with 554 additions and 601 deletions

View File

@@ -4,6 +4,13 @@ Changes since wmaker 0.80.1:
- added WMSetConnectionShutdownOnClose()
- added an extra member to the ConnectionDelegate: canResumeSending
see NEWS for details.
- WMDrawString() and WMDrawImageString() now take WMColor instead of GC as
arguments. WMDrawImageString() receives 2 colors (text & background).
This is to allow easy extension for Xft/Xrender and hide X low level details
- Added alpha channel to WMColor. 2 new functions also:
WMCreateRGBAColor() and WMSetColorAlpha()
- Miscelaneous code cleanups in wtext.c
Changes since wmaker 0.80.0:
............................

View File

@@ -11,7 +11,7 @@ typedef struct {
WMFont *font;
GC gc;
GC selGC;
GC textGC;
WMColor *textColor;
} StringData;
@@ -28,7 +28,7 @@ typedef struct {
WMFont *font;
GC gc;
GC selGC;
GC textGC;
WMColor *textColor;
} StringEditorData;
@@ -40,7 +40,7 @@ typedef struct {
int count;
GC gc;
GC selGC;
GC textGC;
WMColor *textColor;
} EnumSelectorData;
@@ -57,8 +57,8 @@ static char *SelectionColor = "#bbbbcc";
static void stringDraw(WMScreen *scr, Drawable d, GC gc,
GC sgc, GC stgc, WMFont *font, void *data,
static void stringDraw(WMScreen *scr, Drawable d, GC gc, GC sgc,
WMColor *textColor, WMFont *font, void *data,
WMRect rect, Bool selected)
{
int x, y;
@@ -76,13 +76,13 @@ static void stringDraw(WMScreen *scr, Drawable d, GC gc,
if (!selected) {
XFillRectangles(dpy, d, gc, rects, 1);
WMDrawString(scr, d, stgc, font, x, y,
WMDrawString(scr, d, textColor, font, x, y,
data, strlen(data));
} else {
XFillRectangles(dpy, d, sgc, rects, 1);
WMDrawString(scr, d, stgc, font, x, y,
WMDrawString(scr, d, textColor, font, x, y,
data, strlen(data));
}
@@ -142,7 +142,7 @@ static void SECellPainter(WMTableColumnDelegate *self,
WMTableView *table = WMGetTableColumnTableView(column);
stringDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC, strdata->textGC, strdata->font,
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
WMTableViewDataForCell(table, column, row),
WMTableViewRectForCell(table, column, row),
False);
@@ -156,7 +156,7 @@ static void selectedSECellPainter(WMTableColumnDelegate *self,
WMTableView *table = WMGetTableColumnTableView(column);
stringDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC, strdata->textGC, strdata->font,
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
WMTableViewDataForCell(table, column, row),
WMTableViewRectForCell(table, column, row),
True);
@@ -203,9 +203,9 @@ WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *parent)
0, 0);
data->table = parent;
data->font = WMSystemFontOfSize(scr, 12);
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
data->textGC = WMColorGC(WMBlackColor(scr));
data->gc = WMColorGC(WMWhiteColor(scr));
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
data->textColor = WMBlackColor(scr);
delegate->data = data;
delegate->drawCell = SECellPainter;
@@ -229,7 +229,7 @@ static void ESCellPainter(WMTableColumnDelegate *self,
int i = (int)WMTableViewDataForCell(table, column, row);
stringDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC, strdata->textGC, strdata->font,
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
strdata->options[i],
WMTableViewRectForCell(table, column, row),
False);
@@ -244,7 +244,7 @@ static void selectedESCellPainter(WMTableColumnDelegate *self,
int i = (int)WMTableViewDataForCell(table, column, row);
stringDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC, strdata->textGC, strdata->font,
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
strdata->options[i],
WMTableViewRectForCell(table, column, row),
True);
@@ -294,9 +294,9 @@ WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *parent)
0, 0);
data->table = parent;
data->font = WMSystemFontOfSize(scr, 12);
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
data->textGC = WMColorGC(WMBlackColor(scr));
data->gc = WMColorGC(WMWhiteColor(scr));
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
data->textColor = WMBlackColor(scr);
data->count = 0;
data->options = NULL;
@@ -444,7 +444,7 @@ static void SCellPainter(WMTableColumnDelegate *self,
WMTableView *table = WMGetTableColumnTableView(column);
stringDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC, strdata->textGC, strdata->font,
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
WMTableViewDataForCell(table, column, row),
WMTableViewRectForCell(table, column, row),
False);
@@ -458,7 +458,7 @@ static void selectedSCellPainter(WMTableColumnDelegate *self,
WMTableView *table = WMGetTableColumnTableView(column);
stringDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC, strdata->textGC, strdata->font,
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
WMTableViewDataForCell(table, column, row),
WMTableViewRectForCell(table, column, row),
True);
@@ -473,9 +473,9 @@ WMTableColumnDelegate *WTCreateStringDelegate(WMTableView *parent)
data->table = parent;
data->font = WMSystemFontOfSize(scr, 12);
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
data->textGC = WMColorGC(WMBlackColor(scr));
data->gc = WMColorGC(WMWhiteColor(scr));
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
data->textColor = WMBlackColor(scr);
delegate->data = data;
delegate->drawCell = SCellPainter;
@@ -525,8 +525,8 @@ WMTableColumnDelegate *WTCreatePixmapDelegate(WMTableView *table)
StringData *data = wmalloc(sizeof(StringData));
data->table = table;
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
data->gc = WMColorGC(WMWhiteColor(scr));
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
delegate->data = data;
delegate->drawCell = PCellPainter;
@@ -561,22 +561,21 @@ static void drawPSCell(WMTableColumnDelegate *self, Drawable d,
if (pix) {
int owidth = rect.size.width;
size = WMGetPixmapSize(pix);
rect.size.width = size.width;
pixmapDraw(WMWidgetScreen(table),
WMViewXID(WMGetTableViewDocumentView(table)),
strdata->gc, strdata->selGC, pix, rect,
selected);
rect.pos.x += size.width-1;
rect.size.width = owidth-size.width+1;
}
stringDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC, strdata->textGC, strdata->font,
str, rect, selected);
stringDraw(WMWidgetScreen(table), d, strdata->gc, strdata->selGC,
strdata->textColor, strdata->font, str, rect, selected);
}
@@ -602,9 +601,9 @@ WMTableColumnDelegate *WTCreatePixmapStringDelegate(WMTableView *parent)
data->table = parent;
data->font = WMSystemFontOfSize(scr, 12);
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
data->textGC = WMColorGC(WMBlackColor(scr));
data->gc = WMColorGC(WMWhiteColor(scr));
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
data->textColor = WMBlackColor(scr);
delegate->data = data;
delegate->drawCell = PSCellPainter;
@@ -614,3 +613,5 @@ WMTableColumnDelegate *WTCreatePixmapStringDelegate(WMTableView *parent)
return delegate;
}

View File

@@ -150,7 +150,7 @@ paintMyWidget(_MyWidget *mPtr)
color = WMWhiteColor(scr);
W_PaintText(mPtr->view, mPtr->view->window, scr->normalFont, 0, 0,
mPtr->view->size.width, WACenter, WMColorGC(color),
mPtr->view->size.width, WACenter, color,
False, mPtr->text, strlen(mPtr->text));
WMReleaseColor(color);

View File

@@ -804,8 +804,14 @@ WMColor* WMCreateRGBColor(WMScreen *scr, unsigned short red,
unsigned short green, unsigned short blue,
Bool exact);
WMColor* WMCreateRGBAColor(WMScreen *scr, unsigned short red,
unsigned short green, unsigned short blue,
unsigned short alpha, Bool exact);
WMColor* WMCreateNamedColor(WMScreen *scr, char *name, Bool exact);
void WMSetColorAlpha(WMColor *color, unsigned short alpha);
unsigned short WMRedComponentOfColor(WMColor *color);
unsigned short WMGreenComponentOfColor(WMColor *color);
@@ -817,11 +823,12 @@ char* WMGetColorRGBDescription(WMColor *color);
/* ....................................................................... */
void WMDrawString(WMScreen *scr, Drawable d, GC gc, WMFont *font, int x,
int y, char *text, int length);
void WMDrawString(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
int x, int y, char *text, int length);
void WMDrawImageString(WMScreen *scr, Drawable d, GC gc, WMFont *font, int x,
int y, char *text, int length);
void WMDrawImageString(WMScreen *scr, Drawable d, WMColor *color,
WMColor *background, WMFont *font, int x, int y,
char *text, int length);
int WMWidthOfString(WMFont *font, char *text, int length);

View File

@@ -75,6 +75,7 @@ typedef struct W_Color {
struct W_Screen *screen;
XColor color;
unsigned short alpha;
short refCount;
GC gc;
struct {
@@ -183,7 +184,9 @@ typedef struct W_Screen {
GC ixorGC; /* IncludeInferiors XOR */
GC textFieldGC;
GC drawStringGC; /* for WMDrawString() */
GC drawImStringGC; /* for WMDrawImageString() */
W_Font *normalFont;
@@ -488,13 +491,13 @@ void W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y,
void W_CallDestroyHandlers(W_View *view);
void W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
WMReliefType relief, char *text,
void W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor,
W_Font *font, WMReliefType relief, char *text,
WMAlignment alignment, W_Pixmap *image,
WMImagePosition position, GC backGC, int ofs);
WMImagePosition position, WMColor *backColor, int ofs);
void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
int width, WMAlignment alignment, GC gc,
int width, WMAlignment alignment, WMColor *color,
int wrap, char *text, int length);
int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);

View File

@@ -424,7 +424,7 @@ showText(Balloon *bPtr, int x, int y, int h, int w, char *text)
W_PaintText(bPtr->view, pixmap, font, 8, ty + (height - textHeight)/2,
width, bPtr->flags.alignment,
WMColorGC(bPtr->textColor ? bPtr->textColor : scr->black),
bPtr->textColor ? bPtr->textColor : scr->black,
False, text, strlen(text));
XSetWindowBackgroundPixmap(dpy, bPtr->view->window, pixmap);

View File

@@ -280,13 +280,13 @@ drawTitleOfColumn(WMBrowser *bPtr, int column)
&titleLen, widthC);
W_PaintText(bPtr->view, bPtr->view->window, scr->boldFont, x,
(bPtr->titleHeight-WMFontHeight(scr->boldFont))/2,
bPtr->columnSize.width, WACenter, WMColorGC(scr->white),
bPtr->columnSize.width, WACenter, scr->white,
False, titleBuf, titleLen);
wfree (titleBuf);
} else {
W_PaintText(bPtr->view, bPtr->view->window, scr->boldFont, x,
(bPtr->titleHeight-WMFontHeight(scr->boldFont))/2,
bPtr->columnSize.width, WACenter, WMColorGC(scr->white),
bPtr->columnSize.width, WACenter, scr->white,
False, bPtr->titles[column], titleLen);
}
}
@@ -566,11 +566,11 @@ paintItem(WMList *lPtr, int index, Drawable d, char *text, int state,
if (WMWidthOfString(font, text, textLen) > widthC) {
char *textBuf = createTruncatedString(font, text, &textLen, widthC);
W_PaintText(view, d, font, x+4, y, widthC,
WALeft, WMColorGC(scr->black), False, textBuf, textLen);
WALeft, scr->black, False, textBuf, textLen);
wfree(textBuf);
} else {
W_PaintText(view, d, font, x+4, y, widthC,
WALeft, WMColorGC(scr->black), False, text, textLen);
WALeft, scr->black, False, text, textLen);
}
}

View File

@@ -612,9 +612,9 @@ paintButton(Button *bPtr)
char *caption;
WMPixmap *image;
WMColor *textColor;
GC gc;
WMColor *backColor;
gc = NULL;
backColor = NULL;
caption = bPtr->caption;
if (bPtr->flags.enabled) {
@@ -637,7 +637,7 @@ paintButton(Button *bPtr)
if (bPtr->flags.selected) {
if (bPtr->flags.stateLight) {
gc = WMColorGC(scrPtr->white);
backColor = scrPtr->white;
textColor = scrPtr->black;
}
@@ -662,7 +662,7 @@ paintButton(Button *bPtr)
offset = 1;
}
if (bPtr->flags.pushLight) {
gc = WMColorGC(scrPtr->white);
backColor = scrPtr->white;
textColor = scrPtr->black;
}
@@ -676,10 +676,10 @@ paintButton(Button *bPtr)
}
}
W_PaintTextAndImage(bPtr->view, True, WMColorGC(textColor),
W_PaintTextAndImage(bPtr->view, True, textColor,
(bPtr->font!=NULL ? bPtr->font : scrPtr->normalFont),
relief, caption, bPtr->flags.alignment, image,
bPtr->flags.imagePosition, gc, offset);
bPtr->flags.imagePosition, backColor, offset);
}

View File

@@ -16,8 +16,9 @@ static unsigned char DARK_STIPPLE_BITS[] = {
0x0a, 0x04, 0x0a, 0x01};
static WMColor *createRGBColor(WMScreen *scr, unsigned short red,
unsigned short green, unsigned short blue);
static WMColor *createRGBAColor(WMScreen *scr, unsigned short red,
unsigned short green, unsigned short blue,
unsigned short alpha);
/*
* TODO: make the color creation code return the same WMColor for the
@@ -28,7 +29,7 @@ static WMColor *createRGBColor(WMScreen *scr, unsigned short red,
static WMColor*
findCloseColor(WMScreen *scr, unsigned short red, unsigned short green,
unsigned short blue)
unsigned short blue, unsigned short alpha)
{
WMColor *color;
XColor xcolor;
@@ -37,6 +38,7 @@ findCloseColor(WMScreen *scr, unsigned short red, unsigned short green,
rcolor.red = red>>8;
rcolor.green = green>>8;
rcolor.blue = blue>>8;
rcolor.alpha = alpha>>8;
if (!RGetClosestXColor(scr->rcontext, &rcolor, &xcolor))
return NULL;
@@ -49,6 +51,7 @@ findCloseColor(WMScreen *scr, unsigned short red, unsigned short green,
color->screen = scr;
color->refCount = 1;
color->color = xcolor;
color->alpha = alpha;
color->flags.exact = 1;
color->gc = NULL;
@@ -58,8 +61,8 @@ findCloseColor(WMScreen *scr, unsigned short red, unsigned short green,
static WMColor*
createRGBColor(WMScreen *scr, unsigned short red, unsigned short green,
unsigned short blue)
createRGBAColor(WMScreen *scr, unsigned short red, unsigned short green,
unsigned short blue, unsigned short alpha)
{
WMColor *color;
XColor xcolor;
@@ -76,6 +79,7 @@ createRGBColor(WMScreen *scr, unsigned short red, unsigned short green,
color->screen = scr;
color->refCount = 1;
color->color = xcolor;
color->alpha = alpha;
color->flags.exact = 1;
color->gc = NULL;
@@ -83,15 +87,30 @@ createRGBColor(WMScreen *scr, unsigned short red, unsigned short green,
}
WMColor*
WMCreateRGBColor(WMScreen *scr, unsigned short red, unsigned short green,
unsigned short blue, Bool exact)
{
WMColor *color = NULL;
if (!exact || !(color=createRGBAColor(scr, red, green, blue, 0xffff))) {
color = findCloseColor(scr, red, green, blue, 0xffff);
}
if (!color)
color = WMBlackColor(scr);
return color;
}
WMColor*
WMCreateRGBAColor(WMScreen *scr, unsigned short red, unsigned short green,
unsigned short blue, unsigned short alpha, Bool exact)
{
WMColor *color = NULL;
if (!exact || !(color=createRGBColor(scr, red, green, blue))) {
color = findCloseColor(scr, red, green, blue);
if (!exact || !(color=createRGBAColor(scr, red, green, blue, alpha))) {
color = findCloseColor(scr, red, green, blue, alpha);
}
if (!color)
color = WMBlackColor(scr);
@@ -112,9 +131,9 @@ WMCreateNamedColor(WMScreen *scr, char *name, Bool exact)
if (scr->visual->class == TrueColor)
exact = True;
if (!exact || !(color=createRGBColor(scr, xcolor.red, xcolor.green,
xcolor.blue))) {
color = findCloseColor(scr, xcolor.red, xcolor.green, xcolor.blue);
if (!exact || !(color=createRGBAColor(scr, xcolor.red, xcolor.green,
xcolor.blue, 0xffff))) {
color = findCloseColor(scr, xcolor.red, xcolor.green, xcolor.blue, 0xffff);
}
return color;
}
@@ -147,6 +166,13 @@ WMReleaseColor(WMColor *color)
}
void
WMSetColorAlpha(WMColor *color, unsigned short alpha)
{
color->alpha = alpha;
}
void
WMPaintColorSwatch(WMColor *color, Drawable d, int x, int y,
unsigned int width, unsigned int height)
@@ -201,7 +227,6 @@ WMWhiteColor(WMScreen *scr)
}
WMColor*
WMBlackColor(WMScreen *scr)
{
@@ -231,7 +256,7 @@ WMGrayColor(WMScreen *scr)
LIGHT_STIPPLE_BITS, LIGHT_STIPPLE_WIDTH,
LIGHT_STIPPLE_HEIGHT);
color = createRGBColor(scr, 0xffff, 0xffff, 0xffff);
color = createRGBAColor(scr, 0xffff, 0xffff, 0xffff, 0xffff);
gcv.foreground = white->color.pixel;
gcv.background = black->color.pixel;
@@ -261,7 +286,7 @@ WMDarkGrayColor(WMScreen *scr)
{
if (!scr->darkGray) {
WMColor *color;
if (scr->depth == 1) {
Pixmap stipple;
WMColor *white = WMWhiteColor(scr);
@@ -271,8 +296,8 @@ WMDarkGrayColor(WMScreen *scr)
stipple = XCreateBitmapFromData(scr->display, W_DRAWABLE(scr),
DARK_STIPPLE_BITS, DARK_STIPPLE_WIDTH,
DARK_STIPPLE_HEIGHT);
color = createRGBColor(scr, 0, 0, 0);
color = createRGBAColor(scr, 0, 0, 0, 0xffff);
gcv.foreground = white->color.pixel;
gcv.background = black->color.pixel;
@@ -327,3 +352,5 @@ WMGetColorRGBDescription(WMColor *color)
return str;
}

View File

@@ -605,7 +605,7 @@ makeColorPanel(WMScreen *scrPtr, char *name)
if (pixmap)
W_PaintText(W_VIEW(panel->grayBrightnessS), pixmap->pixmap,
panel->font12, 2, 0, 100, WALeft, WMColorGC(scrPtr->white),
panel->font12, 2, 0, 100, WALeft, scrPtr->white,
False, _("Brightness"), strlen(_("Brightness")));
else
wwarning(_("Color Panel: Could not allocate memory"));
@@ -681,8 +681,8 @@ makeColorPanel(WMScreen *scrPtr, char *name)
if (pixmap)
W_PaintText(W_VIEW(panel->rgbRedS), pixmap->pixmap, panel->font12,
2, 0, 100, WALeft, WMColorGC(scrPtr->white), False, _("Red"),
strlen(_("Red")));
2, 0, 100, WALeft, scrPtr->white, False, _("Red"),
strlen(_("Red")));
else
wwarning(_("Color Panel: Could not allocate memory"));
@@ -714,8 +714,8 @@ makeColorPanel(WMScreen *scrPtr, char *name)
if (pixmap)
W_PaintText(W_VIEW(panel->rgbGreenS), pixmap->pixmap, panel->font12,
2, 0, 100, WALeft, WMColorGC(scrPtr->white), False, _("Green"),
strlen(_("Green")));
2, 0, 100, WALeft, scrPtr->white, False, _("Green"),
strlen(_("Green")));
else
wwarning(_("Color Panel: Could not allocate memory"));
@@ -748,8 +748,8 @@ makeColorPanel(WMScreen *scrPtr, char *name)
if (pixmap)
W_PaintText(W_VIEW(panel->rgbBlueS), pixmap->pixmap, panel->font12,
2, 0, 100, WALeft, WMColorGC(scrPtr->white), False, _("Blue"),
strlen(_("Blue")));
2, 0, 100, WALeft, scrPtr->white, False, _("Blue"),
strlen(_("Blue")));
else
wwarning(_("Color Panel: Could not allocate memory"));
@@ -808,8 +808,8 @@ makeColorPanel(WMScreen *scrPtr, char *name)
if (pixmap)
W_PaintText(W_VIEW(panel->cmykCyanS), pixmap->pixmap, panel->font12,
2, 0, 100, WALeft, WMColorGC(scrPtr->black), False, _("Cyan"),
strlen(_("Cyan")));
2, 0, 100, WALeft, scrPtr->black, False, _("Cyan"),
strlen(_("Cyan")));
else
wwarning(_("Color Panel: Could not allocate memory"));
@@ -842,8 +842,8 @@ makeColorPanel(WMScreen *scrPtr, char *name)
if (pixmap)
W_PaintText(W_VIEW(panel->cmykMagentaS), pixmap->pixmap, panel->font12,
2, 0, 100, WALeft, WMColorGC(scrPtr->black), False, _("Magenta"),
strlen(_("Magenta")));
2, 0, 100, WALeft, scrPtr->black, False, _("Magenta"),
strlen(_("Magenta")));
else
wwarning(_("Color Panel: Could not allocate memory"));
@@ -876,8 +876,8 @@ makeColorPanel(WMScreen *scrPtr, char *name)
if (pixmap)
W_PaintText(W_VIEW(panel->cmykYellowS), pixmap->pixmap, panel->font12,
2, 0, 100, WALeft, WMColorGC(scrPtr->black), False, _("Yellow"),
strlen(_("Yellow")));
2, 0, 100, WALeft, scrPtr->black, False, _("Yellow"),
strlen(_("Yellow")));
else
wwarning(_("Color Panel: Could not allocate memory"));
@@ -911,8 +911,8 @@ makeColorPanel(WMScreen *scrPtr, char *name)
if (pixmap)
W_PaintText(W_VIEW(panel->cmykBlackS), pixmap->pixmap, panel->font12,
2, 0, 100, WALeft, WMColorGC(scrPtr->black), False, _("Black"),
strlen(_("Black")));
2, 0, 100, WALeft, scrPtr->black, False, _("Black"),
strlen(_("Black")));
else
wwarning(_("Color Panel: Could not allocate memory"));
@@ -2824,7 +2824,7 @@ hsbUpdateBrightnessGradient(W_ColorPanel *panel)
if (sliderPxmp)
W_PaintText(W_VIEW(panel->hsbBrightnessS), sliderPxmp->pixmap,
panel->font12, 2, 0, 100, WALeft, WMColorGC(scr->white),
panel->font12, 2, 0, 100, WALeft, scr->white,
False, _("Brightness"), strlen(_("Brightness")));
else
wwarning(_("Color Panel: Could not allocate memory"));
@@ -2859,8 +2859,8 @@ hsbUpdateSaturationGradient(W_ColorPanel *panel)
if (sliderPxmp)
W_PaintText(W_VIEW(panel->hsbSaturationS), sliderPxmp->pixmap,
panel->font12, 2, 0, 100, WALeft,
WMColorGC(from.hsv.value < 128 ? scr->white : scr->black), False,
panel->font12, 2, 0, 100, WALeft,
from.hsv.value < 128 ? scr->white : scr->black, False,
_("Saturation"), strlen(_("Saturation")));
else
wwarning(_("Color Panel: Could not allocate memory"));
@@ -2895,8 +2895,8 @@ hsbUpdateHueGradient(W_ColorPanel *panel)
if (sliderPxmp)
W_PaintText(W_VIEW(panel->hsbHueS), sliderPxmp->pixmap,
panel->font12, 2, 0, 100, WALeft,
WMColorGC(hsvcolor.value < 128 ? scr->white : scr->black), False,
panel->font12, 2, 0, 100, WALeft,
hsvcolor.value < 128 ? scr->white : scr->black, False,
_("Hue"), strlen(_("Hue")));
else
wwarning(_("Color Panel: Could not allocate memory"));
@@ -3427,8 +3427,6 @@ colorListPaintItem(WMList *lPtr, int index, Drawable d, char *text,
WMScreen *scr = WMWidgetScreen(lPtr);
Display *dpy = WMScreenDisplay(scr);
W_ColorPanel *panel = WMGetHangedData(lPtr);
WMColor *white = WMWhiteColor(scr);
WMColor *black = WMBlackColor(scr);
WMColor *fillColor;
width = rect->size.width;
@@ -3437,7 +3435,7 @@ colorListPaintItem(WMList *lPtr, int index, Drawable d, char *text,
y = rect->pos.y;
if (state & WLDSSelected)
WMPaintColorSwatch(white, d, x +15, y, width -15, height);
WMPaintColorSwatch(scr->white, d, x +15, y, width -15, height);
else
XClearArea(dpy, d, x +15, y, width -15, height, False);
@@ -3448,11 +3446,7 @@ colorListPaintItem(WMList *lPtr, int index, Drawable d, char *text,
WMPaintColorSwatch(fillColor, d, x, y, 15, 15);
WMReleaseColor(fillColor);
WMDrawString(scr, d, WMColorGC(black), panel->font12, x+18, y, text,
strlen(text));
WMReleaseColor(white);
WMReleaseColor(black);
WMDrawString(scr, d, scr->black, panel->font12, x+18, y, text, strlen(text));
}

View File

@@ -387,33 +387,38 @@ WMWidthOfString(WMFont *font, char *text, int length)
void
WMDrawString(WMScreen *scr, Drawable d, GC gc, WMFont *font, int x, int y,
char *text, int length)
WMDrawString(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
int x, int y, char *text, int length)
{
wassertr(font!=NULL);
XSetForeground(scr->display, scr->drawStringGC, W_PIXEL(color));
if (font->notFontSet) {
XSetFont(scr->display, gc, font->font.normal->fid);
XDrawString(scr->display, d, gc, x, y + font->y, text, length);
XSetFont(scr->display, scr->drawStringGC, font->font.normal->fid);
XDrawString(scr->display, d, scr->drawStringGC, x, y + font->y, text,
length);
} else {
XmbDrawString(scr->display, d, font->font.set, gc, x, y + font->y,
text, length);
XmbDrawString(scr->display, d, font->font.set, scr->drawStringGC,
x, y + font->y, text, length);
}
}
void
WMDrawImageString(WMScreen *scr, Drawable d, GC gc, WMFont *font, int x, int y,
char *text, int length)
WMDrawImageString(WMScreen *scr, Drawable d, WMColor *color, WMColor *background,
WMFont *font, int x, int y, char *text, int length)
{
wassertr(font != NULL);
XSetForeground(scr->display, scr->drawImStringGC, W_PIXEL(color));
XSetBackground(scr->display, scr->drawImStringGC, W_PIXEL(background));
if (font->notFontSet) {
XSetFont(scr->display, gc, font->font.normal->fid);
XDrawImageString(scr->display, d, gc, x, y + font->y, text, length);
XSetFont(scr->display, scr->drawImStringGC, font->font.normal->fid);
XDrawImageString(scr->display, d, scr->drawImStringGC, x, y + font->y,
text, length);
} else {
XmbDrawImageString(scr->display, d, font->font.set, gc, x, y + font->y,
text, length);
XmbDrawImageString(scr->display, d, font->font.set, scr->drawImStringGC,
x, y + font->y, text, length);
}
}

View File

@@ -193,9 +193,8 @@ paintFrame(Frame *fPtr)
}
if (drawTitle) {
WMDrawString(scrPtr, view->window, WMColorGC(scrPtr->black),
scrPtr->normalFont, tx, ty, fPtr->caption,
strlen(fPtr->caption));
WMDrawString(scrPtr, view->window, scrPtr->black, scrPtr->normalFont,
tx, ty, fPtr->caption, strlen(fPtr->caption));
}
}

View File

@@ -727,7 +727,6 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
scrPtr->clipGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
|GCGraphicsExposures, &gcv);
stipple = XCreateBitmapFromData(display, W_DRAWABLE(scrPtr),
STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
gcv.foreground = W_PIXEL(scrPtr->darkGray);
@@ -738,10 +737,10 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
GCForeground|GCBackground|GCStipple
|GCFillStyle|GCGraphicsExposures, &gcv);
gcv.foreground = W_PIXEL(scrPtr->black);
gcv.background = W_PIXEL(scrPtr->white);
scrPtr->textFieldGC = XCreateGC(display, W_DRAWABLE(scrPtr),
GCForeground|GCBackground, &gcv);
scrPtr->drawStringGC = XCreateGC(display, W_DRAWABLE(scrPtr),
GCGraphicsExposures, &gcv);
scrPtr->drawImStringGC = XCreateGC(display, W_DRAWABLE(scrPtr),
GCGraphicsExposures, &gcv);
/* we need a 1bpp drawable for the monoGC, so borrow this one */
scrPtr->monoGC = XCreateGC(display, stipple, 0, NULL);

View File

@@ -205,14 +205,9 @@ static void
paintLabel(Label *lPtr)
{
W_Screen *scrPtr = lPtr->view->screen;
GC gc;
if (lPtr->textColor)
gc = WMColorGC(lPtr->textColor);
else
gc = WMColorGC(scrPtr->black);
W_PaintTextAndImage(lPtr->view, !lPtr->flags.noWrap, gc,
W_PaintTextAndImage(lPtr->view, !lPtr->flags.noWrap,
lPtr->textColor ? lPtr->textColor : scrPtr->black,
(lPtr->font!=NULL ? lPtr->font : scrPtr->normalFont),
lPtr->flags.relief, lPtr->caption,
lPtr->flags.alignment, lPtr->image,

View File

@@ -530,7 +530,7 @@ paintItem(List *lPtr, int index)
}
W_PaintText(view, view->window, scr->normalFont, x+4, y, width,
WALeft, WMColorGC(scr->black), False,
WALeft, scr->black, False,
itemPtr->text, strlen(itemPtr->text));
}

View File

@@ -154,7 +154,7 @@ W_GetTextHeight(WMFont *font, char *text, int width, int wrap)
void
W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
int width, WMAlignment alignment, GC gc,
int width, WMAlignment alignment, WMColor *color,
int wrap, char *text, int length)
{
char *ptr = text;
@@ -174,7 +174,7 @@ W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
else
line_x = x + (width - line_width) / 2;
WMDrawString(view->screen, d, gc, font, line_x, y, ptr, count);
WMDrawString(view->screen, d, color, font, line_x, y, ptr, count);
if (wrap && ptr[count]!='\n')
y += fheight;
@@ -191,10 +191,10 @@ W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
void
W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font,
WMReliefType relief, char *text,
WMAlignment alignment, W_Pixmap *image,
WMImagePosition position, GC backGC, int ofs)
WMImagePosition position, WMColor *backColor, int ofs)
{
W_Screen *screen = view->screen;
int ix, iy;
@@ -209,15 +209,15 @@ W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
/* background */
#ifndef DOUBLE_BUFFER
if (backGC) {
XFillRectangle(screen->display, d, backGC,
if (backColor) {
XFillRectangle(screen->display, d, WMColorGC(backColor),
0, 0, view->size.width, view->size.height);
} else {
XClearWindow(screen->display, d);
}
#else
if (backGC)
XFillRectangle(screen->display, d, backGC, 0, 0,
if (backColor)
XFillRectangle(screen->display, d, WMColorGC(backColor), 0, 0,
view->size.width, view->size.height);
else {
XSetForeground(screen->display, screen->copyGC,
@@ -303,7 +303,7 @@ W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
textHeight = W_GetTextHeight(font, text, w-8, wrap);
W_PaintText(view, d, font, x+ofs+4, y+ofs + (h-textHeight)/2, w-8,
alignment, textGC, wrap, text, strlen(text));
alignment, textColor, wrap, text, strlen(text));
}

View File

@@ -333,7 +333,7 @@ paintPopUpButton(PopUpButton *bPtr)
W_PaintText(bPtr->view, pixmap, scr->normalFont, 6,
(bPtr->view->size.height-WMFontHeight(scr->normalFont))/2,
bPtr->view->size.width, WALeft,
bPtr->flags.enabled ? WMColorGC(scr->black) : WMColorGC(scr->darkGray),
bPtr->flags.enabled ? scr->black : scr->darkGray,
False, caption, strlen(caption));
}
@@ -421,7 +421,7 @@ paintMenuEntry(PopUpButton *bPtr, int index, int highlight)
width, itemHeight, WRRaised);
W_PaintText(bPtr->menuView, bPtr->menuView->window, scr->normalFont, 6,
index*itemHeight + yo, width, WALeft, WMColorGC(scr->black),
index*itemHeight + yo, width, WALeft, scr->black,
False, title, strlen(title));
if (!bPtr->flags.pullsDown && index == bPtr->selectedItemIndex) {
@@ -457,7 +457,7 @@ makeMenuPixmap(PopUpButton *bPtr)
i = 0;
WM_ITERATE_ARRAY(bPtr->items, item, iter) {
GC gc;
WMColor *color;
char *text;
text = WMGetMenuItemTitle(item);
@@ -466,12 +466,12 @@ makeMenuPixmap(PopUpButton *bPtr)
WRRaised);
if (!WMGetMenuItemEnabled(item))
gc = WMColorGC(scr->darkGray);
color = scr->darkGray;
else
gc = WMColorGC(scr->black);
color = scr->black;
W_PaintText(bPtr->menuView, pixmap, scr->normalFont, 6,
i*itemHeight + yo, width, WALeft, gc, False,
i*itemHeight + yo, width, WALeft, color, False,
text, strlen(text));
if (!bPtr->flags.pullsDown && i == bPtr->selectedItemIndex) {

View File

@@ -33,7 +33,8 @@ typedef struct W_Ruler {
WMAction *releaseAction; /* what to do when released */
void *clientData;
GC fg, bg;
WMColor *fg;
GC fgGC, bgGC;
WMFont *font;
WMRulerMargins margins;
int offset;
@@ -68,11 +69,10 @@ static void
drawLeftMarker(Ruler * rPtr)
{
XPoint points[4];
int xpos = (rPtr->flags.whichMarker == 1 ?
rPtr->motion : rPtr->margins.left);
int xpos = (rPtr->flags.whichMarker==1 ? rPtr->motion : rPtr->margins.left);
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer,
rPtr->fg, xpos, 8, xpos, 22);
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer, rPtr->fgGC,
xpos, 8, xpos, 22);
points[0].x = xpos;
points[0].y = 1;
points[1].x = points[0].x + 6;
@@ -81,8 +81,8 @@ drawLeftMarker(Ruler * rPtr)
points[2].y = 9;
points[3].x = points[0].x;
points[3].y = 9;
XFillPolygon(rPtr->view->screen->display, rPtr->drawBuffer,
rPtr->fg, points, 4, Convex, CoordModeOrigin);
XFillPolygon(rPtr->view->screen->display, rPtr->drawBuffer, rPtr->fgGC,
points, 4, Convex, CoordModeOrigin);
}
@@ -98,11 +98,10 @@ drawLeftMarker(Ruler * rPtr)
static void drawRightMarker(Ruler * rPtr)
{
XPoint points[4];
int xpos = (rPtr->flags.whichMarker == 2 ?
rPtr->motion : rPtr->margins.right);
int xpos = (rPtr->flags.whichMarker==2 ? rPtr->motion : rPtr->margins.right);
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer,
rPtr->fg, xpos, 8, xpos, 22);
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer, rPtr->fgGC,
xpos, 8, xpos, 22);
points[0].x = xpos + 1;
points[0].y = 0;
points[1].x = points[0].x - 6;
@@ -111,8 +110,8 @@ static void drawRightMarker(Ruler * rPtr)
points[2].y = 9;
points[3].x = points[0].x;
points[3].y = 9;
XFillPolygon(rPtr->view->screen->display, rPtr->drawBuffer,
rPtr->fg, points, 4, Convex, CoordModeOrigin);
XFillPolygon(rPtr->view->screen->display, rPtr->drawBuffer, rPtr->fgGC,
points, 4, Convex, CoordModeOrigin);
}
@@ -127,10 +126,10 @@ static void drawFirstMarker(Ruler * rPtr)
int xpos = ((rPtr->flags.whichMarker == 3 || rPtr->flags.whichMarker == 6) ?
rPtr->motion : rPtr->margins.first);
XFillRectangle(rPtr->view->screen->display, rPtr->drawBuffer,
rPtr->fg, xpos - 5, 10, 11, 5);
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer,
rPtr->fg, xpos, 12, xpos, 22);
XFillRectangle(rPtr->view->screen->display, rPtr->drawBuffer, rPtr->fgGC,
xpos - 5, 10, 11, 5);
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer, rPtr->fgGC,
xpos, 12, xpos, 22);
}
/* Marker for rest of body
@@ -150,8 +149,8 @@ static void drawBodyMarker(Ruler * rPtr)
points[1].y = 16;
points[2].x = points[0].x + 5;
points[2].y = 22;
XFillPolygon(rPtr->view->screen->display, rPtr->drawBuffer,
rPtr->fg, points, 3, Convex, CoordModeOrigin);
XFillPolygon(rPtr->view->screen->display, rPtr->drawBuffer, rPtr->fgGC,
points, 3, Convex, CoordModeOrigin);
}
@@ -167,7 +166,7 @@ static void createDrawBuffer(Ruler * rPtr)
rPtr->view->window, rPtr->view->size.width, 40,
rPtr->view->screen->depth);
XFillRectangle(rPtr->view->screen->display, rPtr->drawBuffer,
rPtr->bg, 0, 0, rPtr->view->size.width, 40);
rPtr->bgGC, 0, 0, rPtr->view->size.width, 40);
}
@@ -175,15 +174,14 @@ static void drawRulerOnPixmap(Ruler * rPtr)
{
int i, j, w, m;
char c[3];
int marks[9] =
{11, 3, 5, 3, 7, 3, 5, 3};
int marks[9] = {11, 3, 5, 3, 7, 3, 5, 3};
if (!rPtr->drawBuffer || !rPtr->view->flags.realized)
return;
XFillRectangle(rPtr->view->screen->display, rPtr->drawBuffer,
rPtr->bg, 0, 0, rPtr->view->size.width, 40);
rPtr->bgGC, 0, 0, rPtr->view->size.width, 40);
WMDrawString(rPtr->view->screen, rPtr->drawBuffer, rPtr->fg,
rPtr->font, rPtr->margins.left + 2, 26, _("0 inches"), 10);
@@ -192,26 +190,26 @@ static void drawRulerOnPixmap(Ruler * rPtr)
i = j = m = 0;
w = rPtr->view->size.width - rPtr->margins.left;
while (m < w) {
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer,
rPtr->fg, rPtr->margins.left + m, 23,
rPtr->margins.left + m, marks[i % 8] + 23);
if (i != 0 && i % 8 == 0) {
if (j < 10)
snprintf(c, 3, "%d", ++j);
else
snprintf(c, 3, "%2d", ++j);
WMDrawString(rPtr->view->screen, rPtr->drawBuffer, rPtr->fg,
rPtr->font, rPtr->margins.left + 2 + m, 26, c, 2);
}
m = (++i) * 10;
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer,
rPtr->fgGC, rPtr->margins.left + m, 23,
rPtr->margins.left + m, marks[i % 8] + 23);
if (i != 0 && i % 8 == 0) {
if (j < 10)
snprintf(c, 3, "%d", ++j);
else
snprintf(c, 3, "%2d", ++j);
WMDrawString(rPtr->view->screen, rPtr->drawBuffer, rPtr->fg,
rPtr->font, rPtr->margins.left + 2 + m, 26, c, 2);
}
m = (++i) * 10;
}
rPtr->end = rPtr->margins.left + m - 10;
if (rPtr->margins.right > rPtr->end)
rPtr->margins.right = rPtr->end;
/* base line */
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer, rPtr->fg,
rPtr->margins.left, 22, rPtr->margins.left + m - 10, 22);
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer, rPtr->fgGC,
rPtr->margins.left, 22, rPtr->margins.left + m - 10, 22);
drawLeftMarker(rPtr);
drawRightMarker(rPtr);
@@ -230,8 +228,8 @@ static void paintRuler(Ruler * rPtr)
if (rPtr->flags.redraw)
drawRulerOnPixmap(rPtr);
XCopyArea(rPtr->view->screen->display, rPtr->drawBuffer,
rPtr->view->window, rPtr->bg, 0, 0, rPtr->view->size.width, 40,
0, 0);
rPtr->view->window, rPtr->bgGC, 0, 0,
rPtr->view->size.width, 40, 0, 0);
}
@@ -447,8 +445,9 @@ WMCreateRuler(WMWidget * parent)
rPtr->view->delegate = &_RulerViewDelegate;
rPtr->bg = WMColorGC(WMGrayColor(rPtr->view->screen));
rPtr->fg = WMColorGC(WMBlackColor(rPtr->view->screen));
rPtr->fg = WMBlackColor(rPtr->view->screen);
rPtr->fgGC = WMColorGC(rPtr->fg);
rPtr->bgGC = WMColorGC(WMGrayColor(rPtr->view->screen));
rPtr->font = WMSystemFontOfSize(rPtr->view->screen, 8);
rPtr->offset = 22;

View File

@@ -882,7 +882,7 @@ W_DrawLabel(WMTabViewItem *item, Drawable d, WMRect rect, Bool enabled)
if (!item->label)
return;
WMDrawString(scr, d, WMColorGC(enabled ? scr->black : scr->darkGray),
WMDrawString(scr, d, enabled ? scr->black : scr->darkGray,
item->tabView->font, rect.pos.x, rect.pos.y,
item->label, strlen(item->label));
}

View File

@@ -106,8 +106,9 @@ typedef struct W_Text {
WMColor *dColor; /* the default color */
WMPixmap *dBulletPix; /* the default pixmap for bullets */
GC bgGC; /* the background GC to draw with */
GC fgGC; /* the foreground GC to draw with */
WMColor *fgColor; /* The current foreground color */
WMColor *bgColor; /* The background color */
GC stippledGC; /* the GC to overlay selected graphics with */
Pixmap db; /* the buffer on which to draw */
WMPixmap *bgPixmap; /* the background pixmap */
@@ -645,10 +646,9 @@ TextBlock *tb)
static void
paintText(Text *tPtr)
{
{
TextBlock *tb;
WMFont *font;
GC gc, greyGC;
char *text;
int len, y, c, s, done=False, prev_y=-23, dir /* 1 = down */;
WMScreen *scr = tPtr->view->screen;
@@ -660,8 +660,8 @@ paintText(Text *tPtr)
return;
XFillRectangle(dpy, tPtr->db, tPtr->bgGC,
0, 0, tPtr->visible.w, tPtr->visible.h);
XFillRectangle(dpy, tPtr->db, WMColorGC(tPtr->bgColor), 0, 0,
tPtr->visible.w, tPtr->visible.h);
if (tPtr->bgPixmap) {
WMDrawPixmap(tPtr->bgPixmap, tPtr->db,
@@ -674,12 +674,6 @@ paintText(Text *tPtr)
goto _copy_area;
}
}
if (tPtr->flags.ownsSelection) {
color = WMGrayColor(scr);
greyGC = WMColorGC(color);
WMReleaseColor(color);
}
done = False;
@@ -721,8 +715,6 @@ _getSibling:
/* first, place all text that can be viewed */
while (!done && tb) {
if (tb->graphic) {
tb = tb->next;
continue;
@@ -742,10 +734,10 @@ _getSibling:
if (tPtr->flags.monoFont) {
font = tPtr->dFont;
gc = tPtr->fgGC;
color = tPtr->fgColor;
} else {
font = tb->d.font;
gc = WMColorGC(tb->color);
color = tb->color;
}
if (tPtr->flags.ownsSelection) {
@@ -753,7 +745,7 @@ _getSibling:
if ( sectionWasSelected(tPtr, tb, &rect, s)) {
tb->selected = True;
XFillRectangle(dpy, tPtr->db, greyGC,
XFillRectangle(dpy, tPtr->db, WMColorGC(scr->gray),
rect.x, rect.y, rect.width, rect.height);
}
}
@@ -763,23 +755,20 @@ _getSibling:
len = tb->sections[s].end - tb->sections[s].begin;
text = &(tb->text[tb->sections[s].begin]);
y = tb->sections[s].y - tPtr->vpos;
WMDrawString(scr, tPtr->db, gc, font,
tb->sections[s].x - tPtr->hpos, y, text, len);
WMDrawString(scr, tPtr->db, color, font,
tb->sections[s].x - tPtr->hpos, y, text, len);
if (!tPtr->flags.monoFont && tb->underlined) {
XDrawLine(dpy, tPtr->db, gc,
tb->sections[s].x - tPtr->hpos,
y + font->y + 1,
tb->sections[s].x + tb->sections[s].w - tPtr->hpos,
y + font->y + 1);
XDrawLine(dpy, tPtr->db, WMColorGC(color),
tb->sections[s].x - tPtr->hpos,
y + font->y + 1,
tb->sections[s].x + tb->sections[s].w - tPtr->hpos,
y + font->y + 1);
}
}
tb = (!done? tb->next : NULL);
}
/* now , show all graphic items that can be viewed */
c = WMGetArrayItemCount(tPtr->gfxItems);
if (c > 0 && !tPtr->flags.monoFont) {
@@ -855,22 +844,22 @@ _copy_area:
if (tPtr->flags.editable && tPtr->flags.cursorShown
&& tPtr->cursor.x != -23 && tPtr->flags.focused) {
int y = tPtr->cursor.y - tPtr->vpos;
XDrawLine(dpy, tPtr->db, tPtr->fgGC,
tPtr->cursor.x, y,
tPtr->cursor.x, y + tPtr->cursor.h);
XDrawLine(dpy, tPtr->db, WMColorGC(tPtr->fgColor),
tPtr->cursor.x, y,
tPtr->cursor.x, y + tPtr->cursor.h);
}
XCopyArea(dpy, tPtr->db, win, tPtr->bgGC, 0, 0,
tPtr->visible.w, tPtr->visible.h,
tPtr->visible.x, tPtr->visible.y);
XCopyArea(dpy, tPtr->db, win, WMColorGC(tPtr->bgColor), 0, 0,
tPtr->visible.w, tPtr->visible.h,
tPtr->visible.x, tPtr->visible.y);
W_DrawRelief(scr, win, 0, 0,
tPtr->view->size.width, tPtr->view->size.height,
tPtr->flags.relief);
if (tPtr->ruler && tPtr->flags.rulerShown)
XDrawLine(dpy, win, tPtr->fgGC,
2, 42, tPtr->view->size.width-4, 42);
XDrawLine(dpy, win, WMColorGC(tPtr->fgColor),
2, 42, tPtr->view->size.width-4, 42);
}
@@ -3138,30 +3127,27 @@ WMCreateTextForDocumentType(WMWidget *parent, WMAction *parser, WMAction *writer
tPtr->view->attribFlags |= CWOverrideRedirect | CWCursor;
W_ResizeView(tPtr->view, 250, 200);
tPtr->dColor = WMWhiteColor(scr);
tPtr->bgGC = WMColorGC(tPtr->dColor);
W_SetViewBackgroundColor(tPtr->view, tPtr->dColor);
WMReleaseColor(tPtr->dColor);
tPtr->dColor = WMBlackColor(scr);
tPtr->fgGC = WMColorGC(tPtr->dColor);
tPtr->fgColor = WMBlackColor(scr);
tPtr->bgColor = WMWhiteColor(scr);
W_SetViewBackgroundColor(tPtr->view, tPtr->bgColor);
gcv.graphics_exposures = False;
gcv.foreground = W_PIXEL(scr->gray);
gcv.background = W_PIXEL(scr->darkGray);
gcv.fill_style = FillStippled;
/* why not use scr->stipple here? */
gcv.stipple = XCreateBitmapFromData(dpy, W_DRAWABLE(scr),
STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
gcv.stipple = XCreateBitmapFromData(dpy, W_DRAWABLE(scr), STIPPLE_BITS,
STIPPLE_WIDTH, STIPPLE_HEIGHT);
tPtr->stippledGC = XCreateGC(dpy, W_DRAWABLE(scr),
GCForeground|GCBackground|GCStipple
|GCFillStyle|GCGraphicsExposures, &gcv);
GCForeground|GCBackground|GCStipple
|GCFillStyle|GCGraphicsExposures, &gcv);
tPtr->ruler = NULL;
tPtr->vS = NULL;
tPtr->hS = NULL;
tPtr->dFont = WMRetainFont(WMSystemFontOfSize(scr, 12));
tPtr->dFont = WMSystemFontOfSize(scr, 12);
tPtr->view->delegate = &_TextViewDelegate;
@@ -3668,8 +3654,8 @@ WMDestroyTextBlock(WMText *tPtr, void *vtb)
/* 5 months later... destroy it 10 seconds after now which should
* be enough time for the widget's action to be completed... :-) */
/* This is a bad assumption. Just destroy the widget here.
// if the caller needs it, it can protect it with W_RetainView()
//WMAddTimerHandler(10000, destroyWidget, (void *)tb->d.widget);*/
* if the caller needs it, it can protect it with W_RetainView()
* WMAddTimerHandler(10000, destroyWidget, (void *)tb->d.widget);*/
WMDestroyWidget(tb->d.widget);
} else {
WMReleasePixmap(tb->d.pixmap);
@@ -3693,13 +3679,8 @@ WMSetTextForegroundColor(WMText *tPtr, WMColor *color)
if (!tPtr)
return;
if (color)
tPtr->fgGC = WMColorGC(color);
else {
WMColor *color = WMBlackColor(tPtr->view->screen);
tPtr->fgGC = WMColorGC(color);
WMReleaseColor(color);
}
WMReleaseColor(tPtr->fgColor);
tPtr->fgColor = WMRetainColor(color ? color : tPtr->view->screen->black);
paintText(tPtr);
}
@@ -3710,14 +3691,9 @@ WMSetTextBackgroundColor(WMText *tPtr, WMColor *color)
if (!tPtr)
return;
if (color) {
tPtr->bgGC = WMColorGC(color);
W_SetViewBackgroundColor(tPtr->view, color);
} else {
tPtr->bgGC = WMColorGC(WMWhiteColor(tPtr->view->screen));
W_SetViewBackgroundColor(tPtr->view,
WMWhiteColor(tPtr->view->screen));
}
WMReleaseColor(tPtr->bgColor);
tPtr->bgColor = WMRetainColor(color ? color : tPtr->view->screen->white);
W_SetViewBackgroundColor(tPtr->view, tPtr->bgColor);
paintText(tPtr);
}

View File

@@ -816,8 +816,9 @@ paintTextField(TextField *tPtr)
int totalWidth;
char *text;
Pixmap drawbuffer;
WMColor *color;
if (!view->flags.realized || !view->flags.mapped)
return;
@@ -877,12 +878,10 @@ paintTextField(TextField *tPtr)
break;
}
if (!tPtr->flags.enabled)
WMSetColorInGC(screen->darkGray, screen->textFieldGC);
color = tPtr->flags.enabled ? screen->black : screen->darkGray;
WMDrawImageString(screen, drawbuffer, screen->textFieldGC,
tPtr->font, tx, ty,
&(text[tPtr->viewPosition]),
WMDrawImageString(screen, drawbuffer, color, screen->white,
tPtr->font, tx, ty, &(text[tPtr->viewPosition]),
tPtr->textLen - tPtr->viewPosition);
if (tPtr->selection.count) {
@@ -897,27 +896,15 @@ paintTextField(TextField *tPtr)
count = tPtr->viewPosition;
}
rx = tPtr->offsetWidth + 1 + WMWidthOfString(tPtr->font,text,count)
- WMWidthOfString(tPtr->font,text,tPtr->viewPosition);
XSetBackground(screen->display, screen->textFieldGC,
screen->gray->color.pixel);
WMDrawImageString(screen, drawbuffer, screen->textFieldGC,
tPtr->font, rx, ty, &(text[count]),
count2);
XSetBackground(screen->display, screen->textFieldGC,
screen->white->color.pixel);
WMDrawImageString(screen, drawbuffer, color, screen->gray,
tPtr->font, rx, ty, &(text[count]), count2);
}
if (!tPtr->flags.enabled)
WMSetColorInGC(screen->black, screen->textFieldGC);
} else {
XFillRectangle(screen->display, drawbuffer,
WMColorGC(screen->white),
bd,bd, totalWidth,view->size.height-2*bd);
XFillRectangle(screen->display, drawbuffer, WMColorGC(screen->white),
bd, bd, totalWidth,view->size.height-2*bd);
}
/* draw relief */

View File

@@ -560,10 +560,10 @@ W_SetViewBackgroundColor(W_View *view, WMColor *color)
view->backColor = WMRetainColor(color);
view->attribFlags |= CWBackPixel;
view->attribs.background_pixel = color->color.pixel;
view->attribs.background_pixel = W_PIXEL(color);
if (view->flags.realized) {
XSetWindowBackground(view->screen->display, view->window,
color->color.pixel);
W_PIXEL(color));
XClearWindow(view->screen->display, view->window);
}
}

View File

@@ -667,10 +667,10 @@ handleEvents(XEvent *event, void *clientData)
}
break;
/*
// was causing windows to ignore commands like closeWindow
* // after the windows is iconized/restored or a workspace change
* // if this is really needed, put the MapNotify portion too and
* // fix the restack bug in wmaker
* was causing windows to ignore commands like closeWindow
* after the windows is iconized/restored or a workspace change
* if this is really needed, put the MapNotify portion too and
* fix the restack bug in wmaker
case UnmapNotify:
WMUnmapWidget(win);
break;