Commit a3cc48fc by Jessica Hawkwell

Adding moar Swing classes, integrated with Boehm-GC

1 parent 6a5218a4
...@@ -55,7 +55,7 @@ build ...@@ -55,7 +55,7 @@ build
.kdev4/ .kdev4/
### NetBeans ### ### NetBeans ###
nbproject/private/ nbproject/
build/ build/
nbbuild/ nbbuild/
dist/ dist/
......
/*
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
# Nitrogen Desktop Experience (NDE)
This is a project I've had ideas about for a few years. The end goal is to create a DE
(Desktop Environment) that can alter itself at runtime using various desktop agents which
dictate the look and feel.
For example:
+ A default desktop agent which provides a basic usable desktop
+ Another desktop agent to provide a macOS-like look and feel
+ A third desktop agent better suited for small screens, like phones and tablets
---
## Components
+ [`libnde`](src/libnde) : Library containing common components
+ [`libntk`](src/libntk) : Nitrogen ToolKit - all the GUI stuffies, API based on Java Swing and [Xwing](https://github.com/qrux/xwing/)
+ [`NitroWin`](src/NitroWin) : Nitrogen Window Manager
---
## Documents
None yet. :crying_cat_face:
---
## Requirements
+ [FreeBSD](http://freebsd.org/) `>= 10.1` (tested using FreeBSD 11)
+ [`x11/libX11`](https://www.freshports.org/x11/libX11/)
+ [`x11/xproto`](https://www.freshports.org/x11/xproto/)
+ [`devel/cmake`](https://www.freshports.org/devel/cmake/)
+ [`devel/cmake-modules`](https://www.freshports.org/devel/cmake-modules/)
+ [`devel/boehm-gc`](https://www.freshports.org/devel/boehm-gc/)
+ [`devel/boehm-gc-threaded`](https://www.freshports.org/devel/boehm-gc-threaded/)
---
## Misc Tooling
+ [`devel/git`](https://www.freshports.org/devel/git/) **or** [`devel/git-gui`](https://www.freshports.org/devel/git-gui/)
...@@ -8,7 +8,9 @@ int main ( int argc, char** argv ) ...@@ -8,7 +8,9 @@ int main ( int argc, char** argv )
{ {
std::cout << NITROWIN_NAME << " v" << NITROWIN_VERSION << std::endl; std::cout << NITROWIN_NAME << " v" << NITROWIN_VERSION << std::endl;
nitrogen::Color no = nitrogen::Color(255, 255, 255); nitrogen::Color no = nitrogen::Color(255, 255, 255);
std::cout << "Color: " << no << std::endl; std::cout << "Color: ";
std::cout << no
<< std::endl;
NWManager *nwm = new NWManager(); NWManager *nwm = new NWManager();
nwm->run(); nwm->run();
} }
...@@ -4,10 +4,14 @@ configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h) ...@@ -4,10 +4,14 @@ configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h)
#include_directories("/usr/local/include") #include_directories("/usr/local/include")
add_library(${PROJECT_NAME} SHARED ndeMain.cpp NPosition.cpp) find_library(BoehmGC gc-threaded REQUIRED)
find_library(CORD cord REQUIRED)
add_library(${PROJECT_NAME} SHARED ndeMain.cpp NPosition.cpp NSize.cpp)
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/${PROJECT_NAME}) install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/${PROJECT_NAME})
file(GLOB HEADERS "*.h") file(GLOB HEADERS "*.h")
install(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME}) install(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${BoehmGC} ${CORD})
target_include_directories (nde PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories (nde PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
...@@ -24,8 +24,9 @@ ...@@ -24,8 +24,9 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <nde.h>
#include <NPosition.h> #include <NPosition.h>
#include <string> //#include <string>
/*template <typename T> /*template <typename T>
NPosition<T>::NPosition(T x, T y) { NPosition<T>::NPosition(T x, T y) {
......
...@@ -31,8 +31,7 @@ ...@@ -31,8 +31,7 @@
#include <string> #include <string>
template <typename T> template <typename T>
class NPosition class NPosition : public gc {
{
protected: protected:
T px; T px;
T py; T py;
...@@ -69,13 +68,13 @@ public: ...@@ -69,13 +68,13 @@ public:
return true; return true;
} }
std::string toString() { std::string* toString() {
std::string out = std::string(); std::string *out = new (UseGC) std::string();
out.append("("); out->append("(");
out.append(std::to_string(px)); out->append(std::to_string(px));
out.append(", "); out->append(", ");
out.append(std::to_string(py)); out->append(std::to_string(py));
out.append(")"); out->append(")");
return out; return out;
} }
......
/*
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <nde.h>
#include <NSize.h>
//#include <string>
void testNSizeInt() {
NSize<int> rawr = NSize<int>(1,1);
rawr.getWidth();
rawr.getHeight();
}
...@@ -29,8 +29,7 @@ ...@@ -29,8 +29,7 @@
#include <nde.h> #include <nde.h>
template <class T> template <class T>
class NSize class NSize : public gc {
{
protected: protected:
T pwidth; T pwidth;
T pheight; T pheight;
...@@ -57,6 +56,16 @@ public: ...@@ -57,6 +56,16 @@ public:
return true; return true;
} }
std::string* toString() {
std::string *out = new (UseGC) std::string();
out->append("(");
out->append(std::to_string(pwidth));
out->append(", ");
out->append(std::to_string(pheight));
out->append(")");
return out;
}
T getWidth() { return pwidth; } T getWidth() { return pwidth; }
T getHeight() { return pheight; } T getHeight() { return pheight; }
}; };
......
...@@ -33,7 +33,14 @@ ...@@ -33,7 +33,14 @@
#ifndef NDE_H #ifndef NDE_H
#define NDE_H #define NDE_H
#include <typeinfo>
#ifndef GC_NAME_CONFLICT
#define GC_NAME_CONFLICT
#include <gc/gc.h>
#include <gc/gc_cpp.h>
#include <gc/gc_allocator.h>
#include <gc/gc_backptr.h>
#endif
#define NDE_NAME "nde" #define NDE_NAME "nde"
#define NDE_VERSION_MAJOR 1 #define NDE_VERSION_MAJOR 1
...@@ -42,6 +49,9 @@ ...@@ -42,6 +49,9 @@
#define NDE_VERSION_TWEAK 0 #define NDE_VERSION_TWEAK 0
#define NDE_VERSION "1.0.0.0" #define NDE_VERSION "1.0.0.0"
#include <typeinfo>
#include <string>
namespace nitrogen { namespace nitrogen {
template <typename T> template <typename T>
char * getTypeName(const T obj) { char * getTypeName(const T obj) {
......
...@@ -33,7 +33,14 @@ ...@@ -33,7 +33,14 @@
#ifndef NDE_H #ifndef NDE_H
#define NDE_H #define NDE_H
#include <typeinfo>
#ifndef GC_NAME_CONFLICT
#define GC_NAME_CONFLICT
#include <gc/gc.h>
#include <gc/gc_cpp.h>
#include <gc/gc_allocator.h>
#include <gc/gc_backptr.h>
#endif
#define NDE_NAME "@PROJECT_NAME@" #define NDE_NAME "@PROJECT_NAME@"
#define NDE_VERSION_MAJOR @Nitrogen_VERSION_MAJOR@ #define NDE_VERSION_MAJOR @Nitrogen_VERSION_MAJOR@
...@@ -42,6 +49,9 @@ ...@@ -42,6 +49,9 @@
#define NDE_VERSION_TWEAK @Nitrogen_VERSION_TWEAK@ #define NDE_VERSION_TWEAK @Nitrogen_VERSION_TWEAK@
#define NDE_VERSION "@Nitrogen_VERSION_MAJOR@.@Nitrogen_VERSION_MINOR@.@Nitrogen_VERSION_PATCH@.@Nitrogen_VERSION_TWEAK@" #define NDE_VERSION "@Nitrogen_VERSION_MAJOR@.@Nitrogen_VERSION_MINOR@.@Nitrogen_VERSION_PATCH@.@Nitrogen_VERSION_TWEAK@"
#include <typeinfo>
#include <string>
namespace nitrogen { namespace nitrogen {
template <typename T> template <typename T>
char * getTypeName(const T obj) { char * getTypeName(const T obj) {
......
...@@ -26,4 +26,3 @@ ...@@ -26,4 +26,3 @@
#include <nde.h> #include <nde.h>
#include <typeinfo> #include <typeinfo>
...@@ -3,6 +3,7 @@ project (ntk) ...@@ -3,6 +3,7 @@ project (ntk)
configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h) configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h)
find_package(X11) find_package(X11)
find_library(BoehmGC gc-threaded)
#include_directories("/usr/local/include") #include_directories("/usr/local/include")
add_library(${PROJECT_NAME} SHARED ntkMain.cpp add_library(${PROJECT_NAME} SHARED ntkMain.cpp
...@@ -10,11 +11,12 @@ NObject.cpp ...@@ -10,11 +11,12 @@ NObject.cpp
Color.cpp Color.cpp
Font.cpp Font.cpp
FontMetrics.cpp FontMetrics.cpp
) )
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/${PROJECT_NAME}) install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/${PROJECT_NAME})
file(GLOB HEADERS "*.h") file(GLOB HEADERS "*.h")
install(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME}) install(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC nde) target_link_libraries(${PROJECT_NAME} LINK_PUBLIC nde ${BoehmGC})
target_include_directories (ntk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories (ntk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
...@@ -83,6 +83,24 @@ namespace nitrogen { ...@@ -83,6 +83,24 @@ namespace nitrogen {
Color::~Color() { Color::~Color() {
} }
std::string* Color::toString() const {
std::string *out = new (UseGC) std::string();
std::string t = getTypeName(this);
out->append((char *)t.c_str());
out->append("(");
out->append(std::to_string(alpha));
out->append(",");
out->append(std::to_string(red));
out->append(",");
out->append(std::to_string(green));
out->append(",");
out->append(std::to_string(blue));
out->append(")");
return out;
}
Color& Color::operator()(unsigned int c) const { Color& Color::operator()(unsigned int c) const {
Color *nc = new Color(c); Color *nc = new Color(c);
return *nc; return *nc;
...@@ -109,30 +127,12 @@ namespace nitrogen { ...@@ -109,30 +127,12 @@ namespace nitrogen {
} }
bool Color::operator!=(const Color& right) const { bool Color::operator!=(const Color& right) const {
return (getARGB() != right.getARGB()); return !(*this == right);
} }
bool Color::operator==(const Color& right) const { bool Color::operator==(const Color& right) const {
return (getARGB() == right.getARGB()); return (getARGB() == right.getARGB());
} }
std::ostream& operator<<(std::ostream& os, const Color& obj) {
// Write obj to stream
std::string out;
out.append(getTypeName(obj));
out.append("(");
out.append(std::to_string(obj.alpha));
out.append(",");
out.append(std::to_string(obj.red));
out.append(",");
out.append(std::to_string(obj.green));
out.append(",");
out.append(std::to_string(obj.blue));
out.append(")");
os << out;
return os;
}
Color* BLACK = new Color(0, 0, 0); Color* BLACK = new Color(0, 0, 0);
Color* RED = new Color(128, 0, 0); Color* RED = new Color(128, 0, 0);
......
...@@ -73,13 +73,13 @@ namespace nitrogen { ...@@ -73,13 +73,13 @@ namespace nitrogen {
virtual ~Color(); virtual ~Color();
virtual std::string* toString() const;
virtual Color& operator()(unsigned int c) const; virtual Color& operator()(unsigned int c) const;
virtual Color& operator()(unsigned char red, unsigned char green, unsigned char blue) const; virtual Color& operator()(unsigned char red, unsigned char green, unsigned char blue) const;
virtual Color& operator()(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha) const; virtual Color& operator()(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha) const;
virtual Color& operator=(const Color& right); virtual Color& operator=(const Color& right);
virtual bool operator!=(const Color& right) const; virtual bool operator!=(const Color& right) const;
virtual bool operator==(const Color& right) const; virtual bool operator==(const Color& right) const;
friend std::ostream& operator<<(std::ostream& os, const Color& obj);
private: private:
unsigned char red; unsigned char red;
......
...@@ -54,6 +54,21 @@ namespace nitrogen { ...@@ -54,6 +54,21 @@ namespace nitrogen {
delete fontName; delete fontName;
} }
std::string* Font::toString() const {
std::string* out;
out->append(getTypeName(*this));
out->append("(");
out->append(fontName->c_str());
out->append(",");
out->append(std::to_string(style));
out->append(",");
out->append(std::to_string(size));
out->append(")");
return out;
}
Font& Font::operator()(std::string* fn, int st, unsigned int si) const { Font& Font::operator()(std::string* fn, int st, unsigned int si) const {
Font *n = new Font(fn, st, si); Font *n = new Font(fn, st, si);
return *n; return *n;
...@@ -73,8 +88,7 @@ namespace nitrogen { ...@@ -73,8 +88,7 @@ namespace nitrogen {
} }
bool Font::operator!=(const Font& right) const { bool Font::operator!=(const Font& right) const {
bool result = !(*this == right); return !(*this == right);
return result;
} }
bool Font::operator==(const Font& right) const { bool Font::operator==(const Font& right) const {
...@@ -83,22 +97,4 @@ namespace nitrogen { ...@@ -83,22 +97,4 @@ namespace nitrogen {
if (style != right.style) { return false; } if (style != right.style) { return false; }
return true; return true;
} }
std::ostream& operator<<(std::ostream& os, const Font& obj) {
// Write obj to stream
std::string out;
out.append(getTypeName(obj));
out.append("(");
out.append(obj.fontName->data());
out.append(",");
out.append(std::to_string(obj.style));
out.append(",");
out.append(std::to_string(obj.size));
out.append(")");
os << out;
return os;
}
} }
...@@ -48,14 +48,12 @@ namespace nitrogen { ...@@ -48,14 +48,12 @@ namespace nitrogen {
virtual unsigned int getSize() const; virtual unsigned int getSize() const;
virtual ~Font(); virtual ~Font();
virtual Font& operator()(std::string*, int, unsigned int) const; virtual std::string* toString() const;
virtual Font& operator()(std::string&, int, unsigned int) const; virtual nitrogen::Font& operator()(std::string*, int, unsigned int) const;
Font& operator=(const Font& right); virtual nitrogen::Font& operator()(std::string&, int, unsigned int) const;
bool operator!=(const Font& right) const; Font& operator=(const nitrogen::Font& right);
bool operator==(const Font& right) const; bool operator!=(const nitrogen::Font& right) const;
bool operator==(const nitrogen::Font& right) const;
friend std::ostream& operator<<(std::ostream& os, const Font& obj);
protected: protected:
std::string* fontName; std::string* fontName;
......
...@@ -56,4 +56,35 @@ namespace nitrogen { ...@@ -56,4 +56,35 @@ namespace nitrogen {
FontMetrics::~FontMetrics() { FontMetrics::~FontMetrics() {
delete font_info; delete font_info;
} }
std::string* FontMetrics::toString() const {
std::string *out;
out->append(getTypeName(this));
out->append("(");
out->append(std::to_string(font_info->fid));
out->append(")");
return out;
}
FontMetrics& FontMetrics::operator()(Font* f) const {
FontMetrics *n = new FontMetrics(f);
return *n;
}
FontMetrics& FontMetrics::operator=(const FontMetrics& right) {
if (*this != right) {
font_info = right.font_info;
}
return *this;
}
bool FontMetrics::operator!=(const FontMetrics& right) const {
return !(*this == right);
}
bool FontMetrics::operator==(const FontMetrics& right) const {
return (font_info == right.font_info);
}
} }
...@@ -49,6 +49,7 @@ namespace nitrogen { ...@@ -49,6 +49,7 @@ namespace nitrogen {
virtual unsigned int stringWidth(std::string& str) const; virtual unsigned int stringWidth(std::string& str) const;
virtual ~FontMetrics(); virtual ~FontMetrics();
virtual std::string* toString() const;
FontMetrics& operator()(Font* f) const; FontMetrics& operator()(Font* f) const;
FontMetrics& operator=(const FontMetrics& right); FontMetrics& operator=(const FontMetrics& right);
bool operator!=(const FontMetrics& right) const; bool operator!=(const FontMetrics& right) const;
......
/*
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: Graphics.cpp
* Author: jlhawkwell
*
* Created on March 17, 2018, 2:16 PM
*/
#include "Graphics.h"
namespace nitrogen {
}
/*
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: Graphics.h
* Author: jlhawkwell
*
* Created on March 17, 2018, 2:16 PM
*/
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include <ntk.h>
#include <Font.h>
#include <FontMetrics.h>
#include <Color.h>
#include <NPosition.h>
#include <NSize.h>
namespace nitrogen {
class Graphics : public NObject {
public:
virtual void drawPoint(NPosition<int>* point) = 0;
virtual void drawLine(NPosition<int>* start, NPosition<int>* end) = 0;
virtual void drawRect(NPosition<int>* start, NSize<int>* size) = 0;
virtual void fillRect(NPosition<int>* start, NSize<int>* size) = 0;
virtual void fill3DRect(NPosition<int>* start, NSize<int>* size) = 0;
virtual void draw3DRect(NPosition<int>* start, NSize<int>* size) = 0;
virtual void drawString(std::string* str, NPosition<int>* point) = 0;
virtual void drawString(std::string& str, NPosition<int>* point) = 0;
virtual Color* getColor() const = 0;
virtual nitrogen::Font* getFont() const = 0;
virtual FontMetrics* getFontMetrics(nitrogen::Font* f) const = 0;
virtual FontMetrics* getFontMetrics() const = 0;
virtual void setClip(NPosition<int>* start, NSize<unsigned int> size) = 0;
virtual void setColor(Color* c) = 0;
virtual void setFont(nitrogen::Font* f) = 0;
virtual void translate(NPosition<int>* pos) = 0;
virtual ~Graphics() = 0;
virtual std::string* toString() const = 0;
virtual Graphics& operator()() const = 0;
virtual Graphics& operator=(const Graphics& right) = 0;
virtual bool operator!=(const Graphics& right) const = 0;
virtual bool operator==(const Graphics& right) const = 0;
protected:
static nitrogen::Font* ntk_font;
private:
};
}
#endif /* GRAPHICS_H */
...@@ -44,6 +44,12 @@ namespace nitrogen { ...@@ -44,6 +44,12 @@ namespace nitrogen {
NObject::~NObject() { NObject::~NObject() {
} }
std::string* NObject::toString() const {
std::string* str;
str->append(getTypeName(this));
return str;
}
NObject& NObject::operator()() const { NObject& NObject::operator()() const {
NObject *tmp = new NObject(); NObject *tmp = new NObject();
return *tmp; return *tmp;
...@@ -68,7 +74,7 @@ namespace nitrogen { ...@@ -68,7 +74,7 @@ namespace nitrogen {
std::ostream& operator<<(std::ostream& os, const NObject& obj) { std::ostream& operator<<(std::ostream& os, const NObject& obj) {
// Write obj to stream // Write obj to stream
os << getTypeName(obj); os << *obj.toString();
return os; return os;
} }
} }
...@@ -36,12 +36,13 @@ ...@@ -36,12 +36,13 @@
#include <ostream> #include <ostream>
namespace nitrogen { namespace nitrogen {
class NObject { class NObject : public gc {
public: public:
NObject(); NObject();
//NObject(const NObject& orig); //NObject(const NObject& orig);
virtual ~NObject(); virtual ~NObject();
virtual std::string* toString() const;
virtual NObject& operator()() const; virtual NObject& operator()() const;
virtual NObject& operator=(const NObject& right); virtual NObject& operator=(const NObject& right);
virtual bool operator!=(const NObject& right) const; virtual bool operator!=(const NObject& right) const;
......
...@@ -33,8 +33,18 @@ ...@@ -33,8 +33,18 @@
#ifndef NTK_H #ifndef NTK_H
#define NTK_H #define NTK_H
#ifndef GC_NAME_CONFLICT
#define GC_NAME_CONFLICT
#include <gc/gc.h>
#include <gc/gc_cpp.h>
#include <gc/gc_allocator.h>
#include <gc/gc_backptr.h>
#endif
#include <nde.h> #include <nde.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <string>
#define NTK_NAME "ntk" #define NTK_NAME "ntk"
#define NTK_VERSION_MAJOR 1 #define NTK_VERSION_MAJOR 1
......
...@@ -33,8 +33,18 @@ ...@@ -33,8 +33,18 @@
#ifndef NTK_H #ifndef NTK_H
#define NTK_H #define NTK_H
#ifndef GC_NAME_CONFLICT
#define GC_NAME_CONFLICT
#include <gc/gc.h>
#include <gc/gc_cpp.h>
#include <gc/gc_allocator.h>
#include <gc/gc_backptr.h>
#endif
#include <nde.h> #include <nde.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <string>
#define NTK_NAME "@PROJECT_NAME@" #define NTK_NAME "@PROJECT_NAME@"
#define NTK_VERSION_MAJOR @Nitrogen_VERSION_MAJOR@ #define NTK_VERSION_MAJOR @Nitrogen_VERSION_MAJOR@
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!