Commit bbbd4222 by Jessica Hawkwell

trying to make things work

1 parent 317c307b
......@@ -52,10 +52,10 @@
namespace nitrogen {
namespace util {
class ComponentRenderer;
}
namespace nwt {
class Border;
//class nitrogen::util::ComponentRenderer;
class Graphics;
class NWTEvent;
class MouseEvent;
......
......@@ -37,8 +37,13 @@
namespace nitrogen {
namespace nwt {
// Xorg stuffies
Display* xdisp;
GC* xgc;
Drawable* xdraw;
NativeGraphics::NativeGraphics() {
xdisp = XOpenDisplay(nullptr);
}
NativeGraphics::NativeGraphics(NativeGraphics&) {
......@@ -46,22 +51,23 @@ namespace nitrogen {
}
Graphics* NativeGraphics::create() {
Graphics* rt = new NativeGraphics(this);
}
void NativeGraphics::drawPoint(int x, int y) {
XDrawPoint(xdisp,(*xdraw), (*xgc), x, y);
}
void NativeGraphics::drawLine(int sx, int xy, int dx, int dy) {
void NativeGraphics::drawLine(int sx, int sy, int dx, int dy) {
XDrawLine(xdisp, (*xdraw), (*xgc), sx, sy, dx, dy);
}
void NativeGraphics::drawRect(int x, int y, unsigned int width, unsigned int height) {
XDrawRectangle(xdisp, (*xdraw), (*xgc), x, y, width, height);
}
void NativeGraphics::fillRect(int x, int y, unsigned int width, unsigned int height) {
XFillRectangle(xdisp, (*xdraw), (*xgc), x, y, width, height);
}
void NativeGraphics::draw3DRect(int x, int y, unsigned int width, unsigned int height, bool) {
......@@ -73,11 +79,13 @@ namespace nitrogen {
}
void NativeGraphics::drawString(std::string* str, int x, int y) {
//char * cstr = new char [str->length()+1];
//char * basic = str->c_str();
XDrawString(xdisp, (*xdraw), (*xgc), x, y, str->c_str(), font->getSize());
}
void NativeGraphics::drawString(std::string& str, int x, int y) {
XDrawString(xdisp, (*xdraw), (*xgc), x, y, str.c_str(), font->getSize());
}
void NativeGraphics::setClip(int x, int y, unsigned int width, unsigned int height) {
......@@ -89,15 +97,15 @@ namespace nitrogen {
}
void NativeGraphics::setFont(nitrogen::nwt::Font* f) {
font = f;
}
Color* NativeGraphics::getColor() {
return color;
}
nitrogen::nwt::Font* NativeGraphics::getFont() {
return font;
}
FontMetrics* NativeGraphics::getFontMetrics() {
......@@ -112,12 +120,6 @@ namespace nitrogen {
}
void NativeGraphics::pDrawLine(int x1, int y1, int x2, int y2) {
}
void NativeGraphics::pDrawPoint(int, int) {
}
void NativeGraphics::initGC() {
}
......
......@@ -51,7 +51,7 @@ namespace nitrogen {
NativeGraphics(NativeGraphics&);
Graphics* create() override;
void drawPoint(int x, int y) override;
void drawLine(int sx, int xy, int dx, int dy) override;
void drawLine(int sx, int sy, int dx, int dy) override;
void drawRect(int x, int y, unsigned int width, unsigned int height) override;
void fillRect(int x, int y, unsigned int width, unsigned int height) override;
void draw3DRect(int x, int y, unsigned int width, unsigned int height, bool) override;
......@@ -78,9 +78,10 @@ namespace nitrogen {
unsigned int width;
unsigned int height;
nitrogen::nwt::Font* font;
nitrogen::nwt::Color* color;
NativeGraphics();
virtual void pDrawLine(int, int, int, int);
virtual void pDrawPoint(int, int);
virtual void initGC();
virtual void updateGC();
virtual void createClip();
......
......@@ -78,8 +78,6 @@ namespace nitrogen {
XRenderPictFormat *pf = XRenderFindVisualFormat(nitrogen::disp, attrs.visual);
surface = cairo_xlib_surface_create_with_xrender_format(nitrogen::disp, window, attrs.screen, pf, width, height);
cairo = cairo_create(surface);
/*svg_handle = */resvg_init();
}
std::string* ComponentRenderer::getName() {
......@@ -95,16 +93,6 @@ namespace nitrogen {
}
void ComponentRenderer::renderComponent() {
//void resvg_cairo_render_to_canvas(const resvg_render_tree* rtree, const resvg_options* opt, resvg_size size, cairo_t* cr)
resvg_options ro;
ro.dpi = 96;
ro.draw_background = false;
ro.fit_to.type = resvg_fit_to_type::RESVG_FIT_TO_ZOOM;
resvg_size rs;
rs.width = comp->getSize()->getWidth();
rs.height = comp->getSize()->getWidth();
resvg_cairo_render_to_canvas(svg_tree, &ro, rs, cairo);
}
}
}
......@@ -49,6 +49,7 @@ namespace nitrogen {
namespace util {
class ComponentRenderer : public Object {
friend class nitrogen::nwt::Component;
public:
ComponentRenderer(std::string* componentName, nwt::Component* component);
ComponentRenderer(std::string& componentName, nwt::Component* component);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!