1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 12:00:31 +01:00

WINGs: add functions to set widget background image

With this patch we can set widget background image.
As now, only background color was available.
This commit is contained in:
David Maciejak
2014-12-04 13:25:55 +07:00
committed by Carlos R. Mafra
parent 47ac986b53
commit c10469264d
5 changed files with 50 additions and 4 deletions

View File

@@ -930,6 +930,10 @@ void WMSetWidgetBackgroundColor(WMWidget *w, WMColor *color);
WMColor* WMGetWidgetBackgroundColor(WMWidget *w);
void WMSetWidgetBackgroundPixmap(WMWidget *w, WMPixmap *pix);
WMPixmap *WMGetWidgetBackgroundPixmap(WMWidget *w);
void WMMapSubwidgets(WMWidget *w);
void WMUnmapSubwidgets(WMWidget *w);

View File

@@ -572,6 +572,8 @@ struct W_View {
void *hangedData; /* data holder for user program */
WMColor *backColor;
WMPixmap *backImage;
Cursor cursor;
@@ -664,6 +666,8 @@ void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
void W_SetViewBackgroundColor(W_View *view, WMColor *color);
void W_SetViewBackgroundPixmap(W_View *view, WMPixmap *pix);
void W_SetViewCursor(W_View *view, Cursor cursor);
void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);

View File

@@ -960,6 +960,21 @@ WMColor *WMGetWidgetBackgroundColor(WMWidget * w)
return W_VIEW(w)->backColor;
}
void WMSetWidgetBackgroundPixmap(WMWidget *w, WMPixmap *pix)
{
if (!pix)
return;
W_SetViewBackgroundPixmap(W_VIEW(w), pix);
if (W_VIEW(w)->flags.mapped)
WMRedisplayWidget(w);
}
WMPixmap *WMGetWidgetBackgroundPixmap(WMWidget *w)
{
return W_VIEW(w)->backImage;
}
void WMRaiseWidget(WMWidget * w)
{
W_RaiseView(W_VIEW(w));

View File

@@ -220,12 +220,20 @@ W_PaintTextAndImage(W_View * view, int wrap, WMColor * textColor, W_Font * font,
XFillRectangle(screen->display, d, WMColorGC(backColor),
0, 0, view->size.width, view->size.height);
} else {
if (view->attribs.background_pixmap) {
#ifndef DOUBLE_BUFFER
XClearWindow(screen->display, d);
XClearWindow(screen->display, d);
#else
XSetForeground(screen->display, screen->copyGC, view->attribs.background_pixel);
XFillRectangle(screen->display, d, screen->copyGC, 0, 0, view->size.width, view->size.height);
XCopyArea(screen->display, view->attribs.background_pixmap, d, screen->copyGC, 0, 0, view->size.width, view->size.height, 0, 0);
#endif
} else {
#ifndef DOUBLE_BUFFER
XClearWindow(screen->display, d);
#else
XSetForeground(screen->display, screen->copyGC, view->attribs.background_pixel);
XFillRectangle(screen->display, d, screen->copyGC, 0, 0, view->size.width, view->size.height);
#endif
}
}
if (relief == WRFlat) {

View File

@@ -100,7 +100,8 @@ static W_View *createView(W_Screen * screen, W_View * parent)
view->attribFlags = CWEventMask | CWBitGravity;
view->attribs = defAtts;
view->attribFlags |= CWBackPixel | CWColormap | CWBorderPixel;
view->attribFlags |= CWBackPixel | CWColormap | CWBorderPixel | CWBackPixmap;
view->attribs.background_pixmap = None;
view->attribs.background_pixel = W_PIXEL(screen->gray);
view->attribs.border_pixel = W_PIXEL(screen->black);
view->attribs.colormap = screen->colormap;
@@ -496,6 +497,20 @@ void W_SetViewBackgroundColor(W_View * view, WMColor * color)
}
}
void W_SetViewBackgroundPixmap(W_View *view, WMPixmap *pix)
{
if (view->backImage)
WMReleasePixmap(view->backImage);
view->backImage = WMRetainPixmap(pix);
view->attribFlags |= CWBackPixmap;
view->attribs.background_pixmap = pix->pixmap;
if (view->flags.realized) {
XSetWindowBackgroundPixmap(view->screen->display, view->window, pix->pixmap);
XClearWindow(view->screen->display, view->window);
}
}
void W_SetViewCursor(W_View * view, Cursor cursor)
{
view->cursor = cursor;