Commit 46910efe by Jessica Hawkwell

rawr

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