change the render() interface
This commit is contained in:
parent
056c5b435d
commit
e6d6a1b6b5
4 changed files with 12 additions and 10 deletions
|
@ -10,6 +10,7 @@ extern "C" {
|
||||||
namespace otk {
|
namespace otk {
|
||||||
|
|
||||||
class ScreenInfo;
|
class ScreenInfo;
|
||||||
|
class Widget;
|
||||||
|
|
||||||
class RenderControl {
|
class RenderControl {
|
||||||
protected:
|
protected:
|
||||||
|
@ -67,7 +68,7 @@ public:
|
||||||
|
|
||||||
static RenderControl *getRenderControl(int screen);
|
static RenderControl *getRenderControl(int screen);
|
||||||
|
|
||||||
virtual void render(::Window w) = 0;
|
virtual void render(Widget *wi) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
otk::RenderControl *rc = otk::RenderControl::getRenderControl(0);
|
otk::RenderControl *rc = otk::RenderControl::getRenderControl(0);
|
||||||
|
|
||||||
rc->render(foo.window());
|
rc->render(&foo);
|
||||||
|
|
||||||
app.run();
|
app.run();
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "truerendercontrol.hh"
|
#include "truerendercontrol.hh"
|
||||||
#include "display.hh"
|
#include "display.hh"
|
||||||
#include "screeninfo.hh"
|
#include "screeninfo.hh"
|
||||||
|
#include "widget.hh"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#ifdef HAVE_STDLIB_H
|
#ifdef HAVE_STDLIB_H
|
||||||
|
@ -145,13 +146,15 @@ void renderPixel(XImage *im, unsigned char *dp, unsigned long pixel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrueRenderControl::render(::Window win)
|
void TrueRenderControl::render(Widget *wi)
|
||||||
{
|
{
|
||||||
|
assert(wi);
|
||||||
|
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
gcv.cap_style = CapProjecting;
|
gcv.cap_style = CapProjecting;
|
||||||
|
|
||||||
int w = 255, h = 32;
|
int w = 255, h = 31;
|
||||||
Pixmap p = XCreatePixmap(**display, win, w, h, _screen->depth());
|
Pixmap p = XCreatePixmap(**display, wi->window(), w, h, _screen->depth());
|
||||||
XImage *im = XCreateImage(**display, _screen->visual(), _screen->depth(),
|
XImage *im = XCreateImage(**display, _screen->visual(), _screen->depth(),
|
||||||
ZPixmap, 0, NULL, w, h, 32, 0);
|
ZPixmap, 0, NULL, w, h, 32, 0);
|
||||||
//GC gc = XCreateGC(**display, _screen->rootWindow(), GCCapStyle, &gcv);
|
//GC gc = XCreateGC(**display, _screen->rootWindow(), GCCapStyle, &gcv);
|
||||||
|
@ -171,8 +174,6 @@ void TrueRenderControl::render(::Window win)
|
||||||
for (int y = 0; y < 10; ++y)
|
for (int y = 0; y < 10; ++y)
|
||||||
for (int x = 0; x < w; ++x, dp += im->bits_per_pixel/8)
|
for (int x = 0; x < w; ++x, dp += im->bits_per_pixel/8)
|
||||||
renderPixel(im, dp, _blue_color_table[x] << _blue_offset);
|
renderPixel(im, dp, _blue_color_table[x] << _blue_offset);
|
||||||
for (int x = 0; x < w; ++x, dp += im->bits_per_pixel/8)
|
|
||||||
renderPixel(im, dp, 0);
|
|
||||||
|
|
||||||
printf("\nDone\n");
|
printf("\nDone\n");
|
||||||
|
|
||||||
|
@ -185,8 +186,8 @@ void TrueRenderControl::render(::Window win)
|
||||||
//image->data = NULL;
|
//image->data = NULL;
|
||||||
XDestroyImage(im);
|
XDestroyImage(im);
|
||||||
|
|
||||||
XSetWindowBackgroundPixmap(**display, win, p);
|
XSetWindowBackgroundPixmap(**display, wi->window(), p);
|
||||||
XClearWindow(**display, win);
|
XClearWindow(**display, wi->window());
|
||||||
|
|
||||||
XFreePixmap(**display, p);
|
XFreePixmap(**display, p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public:
|
||||||
TrueRenderControl(const ScreenInfo *screen);
|
TrueRenderControl(const ScreenInfo *screen);
|
||||||
virtual ~TrueRenderControl();
|
virtual ~TrueRenderControl();
|
||||||
|
|
||||||
virtual void render(::Window w);
|
virtual void render(Widget *wi);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue