Commit 46910efe by Jessica Hawkwell

rawr

1 parent 6af7bd56
......@@ -35,5 +35,5 @@ find_package(X11)
#add_subdirectory(deps)
add_subdirectory(src/nde)
#add_subdirectory(src/ntk)
add_subdirectory(src/ntk)
add_subdirectory(src/NitroWin)
......@@ -38,20 +38,50 @@
namespace nitrogen {
namespace nwt {
// Xorg stuffies
Display* xdisp;
GC* xgc;
Drawable* xdraw;
Display* NativeGraphics::xdisp;
Drawable* NativeGraphics::xdraw;
GC* NativeGraphics::xgc;
NativeGraphics::NativeGraphics() {
mask = 0L;
cx = 0;
cy = 0;
tx = 0;
ty = 0;
width = 32;
height = 32;
std::string* fnt = std::string("serif");
font = new Font(fnt, 12, 12);
color = new Color(0,0,0);
xdisp = XOpenDisplay(nullptr);
xdraw = XCreateSimpleWindow(xdisp, DefaultRootWindow(xdisp), tx, ty, width, height, 0, 0, 0);
xgc = XCreateGC(xdisp, 0, 0, nullptr);
}
NativeGraphics::NativeGraphics(NativeGraphics&) {
NativeGraphics::NativeGraphics(NativeGraphics& ng) {
mask = ng.mask;
cx = ng.cx;
cy = ng.cy;
tx = ng.tx;
ty = ng.ty;
width = ng.width;
height = ng.height;
font = ng.font;
color = ng.color;
xdisp = ng.xdisp;
xgc = ng.xgc;
xdraw = ng.xdraw;
}
Graphics* NativeGraphics::create() {
Graphics* rt = new NativeGraphics(this);
Graphics* rt = new NativeGraphics();
return rt;
}
void NativeGraphics::drawPoint(int x, int y) {
......@@ -79,13 +109,13 @@ namespace nitrogen {
}
void NativeGraphics::drawString(std::string* str, int x, int y) {
//char * cstr = new char [str->length()+1];
char * cstr = new char [str->length()+1];
//char * basic = str->c_str();
XDrawString(xdisp, (*xdraw), (*xgc), x, y, str->c_str(), font->getSize());
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());
this->drawString(str, x, y);
}
void NativeGraphics::setClip(int x, int y, unsigned int width, unsigned int height) {
......@@ -108,8 +138,13 @@ namespace nitrogen {
return font;
}
FontMetrics* NativeGraphics::getFontMetrics() {
FontMetrics* NativeGraphics::getFontMetrics(nitrogen::nwt::Font* f) {
FontMetrics* fm = new FontMetrics(f);
return fm;
}
FontMetrics* NativeGraphics::getFontMetrics() {
return this->getFontMetrics(font);
}
void NativeGraphics::translate(int x, int y) {
......
......@@ -65,6 +65,7 @@ namespace nitrogen {
void setFont(nitrogen::nwt::Font* f) override;
Color* getColor() override;
nitrogen::nwt::Font* getFont() override;
FontMetrics* getFontMetrics(nitrogen::nwt::Font* f) override;
FontMetrics* getFontMetrics() override;
void translate(int x, int y) override;
void dispose() override;
......@@ -81,6 +82,10 @@ namespace nitrogen {
nitrogen::nwt::Font* font;
nitrogen::nwt::Color* color;
Display* xdisp;
Drawable* xdraw;
GC* xgc;
NativeGraphics();
virtual void initGC();
virtual void updateGC();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!