Commit bbbd4222 by Jessica Hawkwell

trying to make things work

1 parent 317c307b
...@@ -52,10 +52,10 @@ ...@@ -52,10 +52,10 @@
namespace nitrogen { namespace nitrogen {
namespace util { namespace util {
class ComponentRenderer;
} }
namespace nwt { namespace nwt {
class Border; class Border;
//class nitrogen::util::ComponentRenderer;
class Graphics; class Graphics;
class NWTEvent; class NWTEvent;
class MouseEvent; class MouseEvent;
......
...@@ -37,8 +37,13 @@ ...@@ -37,8 +37,13 @@
namespace nitrogen { namespace nitrogen {
namespace nwt { namespace nwt {
// Xorg stuffies
Display* xdisp;
GC* xgc;
Drawable* xdraw;
NativeGraphics::NativeGraphics() { NativeGraphics::NativeGraphics() {
xdisp = XOpenDisplay(nullptr);
} }
NativeGraphics::NativeGraphics(NativeGraphics&) { NativeGraphics::NativeGraphics(NativeGraphics&) {
...@@ -46,22 +51,23 @@ namespace nitrogen { ...@@ -46,22 +51,23 @@ namespace nitrogen {
} }
Graphics* NativeGraphics::create() { Graphics* NativeGraphics::create() {
Graphics* rt = new NativeGraphics(this);
} }
void NativeGraphics::drawPoint(int x, int y) { 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) { 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) { 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) { void NativeGraphics::draw3DRect(int x, int y, unsigned int width, unsigned int height, bool) {
...@@ -73,11 +79,13 @@ namespace nitrogen { ...@@ -73,11 +79,13 @@ namespace nitrogen {
} }
void NativeGraphics::drawString(std::string* str, int x, int y) { 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) { 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) { void NativeGraphics::setClip(int x, int y, unsigned int width, unsigned int height) {
...@@ -89,15 +97,15 @@ namespace nitrogen { ...@@ -89,15 +97,15 @@ namespace nitrogen {
} }
void NativeGraphics::setFont(nitrogen::nwt::Font* f) { void NativeGraphics::setFont(nitrogen::nwt::Font* f) {
font = f;
} }
Color* NativeGraphics::getColor() { Color* NativeGraphics::getColor() {
return color;
} }
nitrogen::nwt::Font* NativeGraphics::getFont() { nitrogen::nwt::Font* NativeGraphics::getFont() {
return font;
} }
FontMetrics* NativeGraphics::getFontMetrics() { FontMetrics* NativeGraphics::getFontMetrics() {
...@@ -112,12 +120,6 @@ namespace nitrogen { ...@@ -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() { void NativeGraphics::initGC() {
} }
......
...@@ -51,7 +51,7 @@ namespace nitrogen { ...@@ -51,7 +51,7 @@ namespace nitrogen {
NativeGraphics(NativeGraphics&); NativeGraphics(NativeGraphics&);
Graphics* create() override; Graphics* create() override;
void drawPoint(int x, int y) 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 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 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; void draw3DRect(int x, int y, unsigned int width, unsigned int height, bool) override;
...@@ -78,9 +78,10 @@ namespace nitrogen { ...@@ -78,9 +78,10 @@ namespace nitrogen {
unsigned int width; unsigned int width;
unsigned int height; unsigned int height;
nitrogen::nwt::Font* font;
nitrogen::nwt::Color* color;
NativeGraphics(); NativeGraphics();
virtual void pDrawLine(int, int, int, int);
virtual void pDrawPoint(int, int);
virtual void initGC(); virtual void initGC();
virtual void updateGC(); virtual void updateGC();
virtual void createClip(); virtual void createClip();
......
...@@ -78,8 +78,6 @@ namespace nitrogen { ...@@ -78,8 +78,6 @@ namespace nitrogen {
XRenderPictFormat *pf = XRenderFindVisualFormat(nitrogen::disp, attrs.visual); XRenderPictFormat *pf = XRenderFindVisualFormat(nitrogen::disp, attrs.visual);
surface = cairo_xlib_surface_create_with_xrender_format(nitrogen::disp, window, attrs.screen, pf, width, height); surface = cairo_xlib_surface_create_with_xrender_format(nitrogen::disp, window, attrs.screen, pf, width, height);
cairo = cairo_create(surface); cairo = cairo_create(surface);
/*svg_handle = */resvg_init();
} }
std::string* ComponentRenderer::getName() { std::string* ComponentRenderer::getName() {
...@@ -95,16 +93,6 @@ namespace nitrogen { ...@@ -95,16 +93,6 @@ namespace nitrogen {
} }
void ComponentRenderer::renderComponent() { 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 { ...@@ -49,6 +49,7 @@ namespace nitrogen {
namespace util { namespace util {
class ComponentRenderer : public Object { class ComponentRenderer : public Object {
friend class nitrogen::nwt::Component;
public: public:
ComponentRenderer(std::string* componentName, nwt::Component* component); ComponentRenderer(std::string* componentName, nwt::Component* component);
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!