Commit 89302031 by Jessica Hawkwell

adding more NWT classes

1 parent d408b565
...@@ -81,7 +81,7 @@ nbactions.xml ...@@ -81,7 +81,7 @@ nbactions.xml
# generated directories # generated directories
bin/ bin/
obj/ obj/
generated-doc/
# End of https://www.gitignore.io/api/codeblocks # End of https://www.gitignore.io/api/codeblocks
This diff could not be displayed because it is too large.
...@@ -3,7 +3,6 @@ project (NitroWin) ...@@ -3,7 +3,6 @@ project (NitroWin)
configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h) configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h)
find_package(X11) find_package(X11)
#include_directories("/usr/local/include")
link_libraries(${X11_LIBRARIES}) link_libraries(${X11_LIBRARIES})
......
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
#include "NitroWin.h" #include "NitroWin.h"
#include <NPosition.h> #include <nitrogen/NPosition.h>
#include <NSize.h> #include <nitrogen/NSize.h>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
......
...@@ -5,9 +5,10 @@ configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h) ...@@ -5,9 +5,10 @@ configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h)
#include_directories("/usr/local/include") #include_directories("/usr/local/include")
find_library(BoehmGC gc-threaded REQUIRED) find_library(BoehmGC gc-threaded REQUIRED)
find_library(CORD cord REQUIRED)
add_library(${PROJECT_NAME} SHARED ndeMain.cpp NPosition.cpp NSize.cpp) add_library(${PROJECT_NAME} SHARED ndeMain.cpp
nitrogen/NPosition.cpp
nitrogen/NSize.cpp)
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/${PROJECT_NAME}) install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/${PROJECT_NAME})
......
...@@ -26,68 +26,71 @@ ...@@ -26,68 +26,71 @@
#include "NPosition.h" #include "NPosition.h"
/*template <typename T> namespace nitrogen {
NPosition<T>::NPosition(T x, T y) {
px = x;
py = y;
} // */
/*template <typename T> /*template <typename T>
NPosition<T>::NPosition(const NPosition<T>& other) { NPosition<T>::NPosition(T x, T y) {
px = other.px; px = x;
py = other.py; py = y;
} // */ } // */
/*template <typename T> /*template <typename T>
NPosition<T>& NPosition<T>::operator=(const NPosition<T>&& other) { NPosition<T>::NPosition(const NPosition<T>& other) {
px = other.px; px = other.px;
py = other.py; py = other.py;
return *this; } // */
} // */
/*template <typename T> /*template <typename T>
NPosition<T> NPosition<T>::operator+(const NPosition<T>& other) { NPosition<T>& NPosition<T>::operator=(const NPosition<T>&& other) {
NPosition<T> rt = NPosition<T>(px + other.px, py + other.py); px = other.px;
return rt; py = other.py;
} // */ return *this;
} // */
/*template <typename T> /*template <typename T>
NPosition<T> NPosition<T>::operator-(const NPosition<T>& other) { NPosition<T> NPosition<T>::operator+(const NPosition<T>& other) {
NPosition<T> rt = NPosition<T>(px - other.px, py - other.py); NPosition<T> rt = NPosition<T>(px + other.px, py + other.py);
return rt; return rt;
} // */ } // */
/*template <typename T> /*template <typename T>
bool NPosition<T>::operator==(const NPosition<T>& other) const { NPosition<T> NPosition<T>::operator-(const NPosition<T>& other) {
if (px != other.getX()) { return false; } NPosition<T> rt = NPosition<T>(px - other.px, py - other.py);
if (py != other.getY()) { return false; } return rt;
return true; } // */
} // */
/*template <typename T> /*template <typename T>
std::string NPosition<T>::toString() { bool NPosition<T>::operator==(const NPosition<T>& other) const {
std::string out = std::string(); if (px != other.getX()) { return false; }
out.append("("); if (py != other.getY()) { return false; }
out.append(std::to_string(px)); return true;
out.append(", "); } // */
out.append(std::to_string(py));
out.append(")");
return out;
} // */
/*template <typename T> /*template <typename T>
T NPosition<T>::getX() { return px; } // */ std::string NPosition<T>::toString() {
/*template <typename T> std::string out = std::string();
T NPosition<T>::getY() { return py; } // */ out.append("(");
out.append(std::to_string(px));
out.append(", ");
out.append(std::to_string(py));
out.append(")");
return out;
} // */
/*template <typename T> /*template <typename T>
void NPosition<T>::setZeroIfNegative() { T NPosition<T>::getX() { return px; } // */
if (px < 0) { px = 0; } /*template <typename T>
if (py < 0) { py = 0;} T NPosition<T>::getY() { return py; } // */
} // */
void testNPositionInt() { /*template <typename T>
NPosition<int> rawr = NPosition<int>(1,1); void NPosition<T>::setZeroIfNegative() {
rawr.getX(); if (px < 0) { px = 0; }
rawr.getY(); if (py < 0) { py = 0;}
} // */
void testNPositionInt() {
NPosition<int> rawr = NPosition<int>(1, 1);
rawr.getX();
rawr.getY();
}
} }
...@@ -29,61 +29,78 @@ ...@@ -29,61 +29,78 @@
#include <nde.h> #include <nde.h>
template <typename T> namespace nitrogen {
class NPosition : public gc {
protected:
T px;
T py;
public:
NPosition<T>(T x, T y) {
px = x;
py = y;
}
NPosition<T>(const NPosition<T>& other) { template <typename T>
px = other.px; class NPosition : public gc {
py = other.py; protected:
} T px;
T py;
public:
NPosition<T>& operator=(const NPosition<T>&& other) { NPosition<T>(T x, T y) {
px = other.px; px = x;
py = other.py; py = y;
return *this; }
}
NPosition<T> operator+(const NPosition<T>& other) { NPosition<T>(const NPosition<T>& other) {
NPosition<T> rt = NPosition<T>(px + other.px, py + other.py); px = other.px;
return rt; py = other.py;
} }
NPosition<T> operator-(const NPosition<T>& other) { NPosition<T>& operator=(const NPosition<T>&& other) {
NPosition<T> rt = NPosition<T>(px - other.px, py - other.py); px = other.px;
return rt; py = other.py;
} return *this;
}
bool operator==(const NPosition<T>& other) const { NPosition<T> operator+(const NPosition<T>& other) {
if (px != other.getX()) { return false; } NPosition<T> rt = NPosition<T>(px + other.px, py + other.py);
if (py != other.getY()) { return false; } return rt;
return true; }
}
std::string* toString() { NPosition<T> operator-(const NPosition<T>& other) {
std::string *out = new (UseGC) std::string(); NPosition<T> rt = NPosition<T>(px - other.px, py - other.py);
out->append("("); return rt;
out->append(std::to_string(px)); }
out->append(", ");
out->append(std::to_string(py));
out->append(")");
return out;
}
T getX() { return px; } bool operator==(const NPosition<T>& other) const {
T getY() { return py; } if (px != other.getX()) {
return false;
}
if (py != other.getY()) {
return false;
}
return true;
}
void setZeroIfNegative() { std::string* toString() {
if (px < 0) { px = 0; } std::string *out = new (UseGC) std::string();
if (py < 0) { py = 0;} out->append("(");
} out->append(std::to_string(px));
}; out->append(", ");
out->append(std::to_string(py));
out->append(")");
return out;
}
T getX() {
return px;
}
T getY() {
return py;
}
void setZeroIfNegative() {
if (px < 0) {
px = 0;
}
if (py < 0) {
py = 0;
}
}
};
}
#endif // NPOSITION_H #endif // NPOSITION_H
...@@ -26,8 +26,11 @@ ...@@ -26,8 +26,11 @@
#include "NSize.h" #include "NSize.h"
void testNSizeInt() { namespace nitrogen {
NSize<int> rawr = NSize<int>(1,1);
rawr.getWidth(); void testNSizeInt() {
rawr.getHeight(); NSize<int> rawr = NSize<int>(1, 1);
rawr.getWidth();
rawr.getHeight();
}
} }
...@@ -29,46 +29,59 @@ ...@@ -29,46 +29,59 @@
#include <nde.h> #include <nde.h>
template <class T> namespace nitrogen {
class NSize : public gc {
protected:
T pwidth;
T pheight;
public:
NSize<T>(T width, T height) {
pwidth = width;
pheight = height;
}
NSize<T>(const NSize<T>& other) { template <class T>
pwidth = other.pwidth; class NSize : public gc {
pheight = other.pheight; protected:
} T pwidth;
T pheight;
public:
NSize<T>& operator=(const NSize<T>& other) { NSize<T>(T width, T height) {
pwidth = other.pwidth; pwidth = width;
pheight = other.pheight; pheight = height;
return *this; }
}
bool operator==(const NSize<T>& other) const { NSize<T>(const NSize<T>& other) {
if (pwidth != other.getWidth()) { return false; } pwidth = other.pwidth;
if (pheight != other.getHeight()) { return false; } pheight = other.pheight;
return true; }
}
std::string* toString() { NSize<T>& operator=(const NSize<T>& other) {
std::string *out = new (UseGC) std::string(); pwidth = other.pwidth;
out->append("("); pheight = other.pheight;
out->append(std::to_string(pwidth)); return *this;
out->append(", "); }
out->append(std::to_string(pheight));
out->append(")");
return out;
}
T getWidth() { return pwidth; } bool operator==(const NSize<T>& other) const {
T getHeight() { return pheight; } if (pwidth != other.getWidth()) {
}; return false;
}
if (pheight != other.getHeight()) {
return false;
}
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 getHeight() {
return pheight;
}
};
}
#endif // NSIZE_H #endif // NSIZE_H
...@@ -7,13 +7,20 @@ find_library(BoehmGC gc-threaded) ...@@ -7,13 +7,20 @@ find_library(BoehmGC gc-threaded)
add_library(${PROJECT_NAME} SHARED ntkMain.cpp add_library(${PROJECT_NAME} SHARED ntkMain.cpp
nitrogen/NObject.cpp nitrogen/NObject.cpp
nitrogen/nwt/Border.cpp
nitrogen/nwt/Color.cpp nitrogen/nwt/Color.cpp
nitrogen/nwt/Component.cpp
nitrogen/nwt/ComponentEvent.cpp
nitrogen/nwt/EventListener.cpp
nitrogen/nwt/EventObject.cpp
nitrogen/nwt/Font.cpp nitrogen/nwt/Font.cpp
nitrogen/nwt/FontMetrics.cpp nitrogen/nwt/FontMetrics.cpp
nitrogen/nwt/Graphics.cpp nitrogen/nwt/Graphics.cpp
nitrogen/nwt/InputEvent.cpp
nitrogen/nwt/Insets.cpp nitrogen/nwt/Insets.cpp
# nitrogen/nwt/Border.cpp nitrogen/nwt/MouseEvent.cpp
# nitrogen/nwt/Component.cpp nitrogen/nwt/MouseListener.cpp
nitrogen/nwt/NWTEvent.cpp
) )
......
...@@ -65,8 +65,7 @@ namespace nitrogen { ...@@ -65,8 +65,7 @@ namespace nitrogen {
} }
bool NObject::operator!=(const NObject& right) const { bool NObject::operator!=(const NObject& right) const {
bool result = !(*this == right); return !(*this == right);
return result;
} }
bool NObject::operator==(const NObject& right) const { bool NObject::operator==(const NObject& right) const {
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
/* /*
* File: NObject.h * File: NObject.h
* Author: jlhawkwell * Author: jlhawkwell
* *
...@@ -36,11 +36,10 @@ ...@@ -36,11 +36,10 @@
#include <ntk.h> #include <ntk.h>
namespace nitrogen { namespace nitrogen {
class NObject : public gc { class NObject : public gc {
public: public:
NObject(); NObject();
//NObject(const NObject& orig);
virtual ~NObject();
virtual std::string* toString() const; virtual std::string* toString() const;
virtual NObject& operator()() const; virtual NObject& operator()() const;
......
...@@ -24,21 +24,19 @@ ...@@ -24,21 +24,19 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
/* /*
* File: Border.cpp * File: Border.cpp
* Author: jlhawkwell * Author: jlhawkwell
* *
* Created on March 23, 2018, 1:44 PM * Created on March 23, 2018, 1:44 PM
*/ */
#include "Border.h" #include "nitrogen/nwt/Border.h"
namespace nitrogen { namespace nitrogen {
namespace nwt { namespace nwt {
Border::Border() {
}
Border::~Border() { Border::Border() {
} }
} }
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
/* /*
* File: Border.h * File: Border.h
* Author: jlhawkwell * Author: jlhawkwell
* *
...@@ -36,19 +36,28 @@ ...@@ -36,19 +36,28 @@
#include <ntk.h> #include <ntk.h>
#include <nitrogen/nwt/Component.h> //#include <nitrogen/nwt/Component.h>
#include <nitrogen/nwt/Graphics.h> #include <nitrogen/nwt/Graphics.h>
#include <nitrogen/nwt/Insets.h> #include <nitrogen/nwt/Insets.h>
namespace nitrogen { namespace nitrogen {
namespace nwt { namespace nwt {
class Component;
class Border : public NObject { class Border : public NObject {
public: public:
virtual Insets* getBorderInsets(Component* comp) = 0; virtual Insets* getBorderInsets(Component* comp) = 0;
virtual bool isBorderOpaque() = 0; virtual bool isBorderOpaque() = 0;
virtual void paintBorder(Component* comp, Graphics* g, int, int, unsigned int, unsigned int) = 0; virtual void paintBorder(Component* comp, Graphics* g, int, int, unsigned int, unsigned int) = 0;
virtual ~Border();
virtual std::string* toString() const = 0;
virtual Border& operator()(Component* comp) const = 0;
virtual Border& operator=(const Border& right) = 0;
//virtual bool operator!=(const Color& right) const = 0;
virtual bool operator==(const Border& right) const = 0;
protected: protected:
Component* c;
Border(); Border();
private: private:
......
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
/* /*
* File: Color.cpp * File: Color.cpp
* Author: jlhawkwell * Author: jlhawkwell
* *
* Created on March 16, 2018, 7:19 PM * Created on March 16, 2018, 7:19 PM
*/ */
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
namespace nitrogen { namespace nitrogen {
namespace nwt { namespace nwt {
Color::Color(unsigned int c) { Color::Color(unsigned int c) {
alpha = 255; alpha = 255;
red = ((c & MASK_RED) >> 16); red = ((c & MASK_RED) >> 16);
...@@ -73,21 +74,18 @@ namespace nitrogen { ...@@ -73,21 +74,18 @@ namespace nitrogen {
} }
unsigned int Color::getARGB() const { unsigned int Color::getARGB() const {
return (alpha << 24) + getRGB(); return (alpha << 24) +getRGB();
} }
unsigned char Color::getRed() const { unsigned char Color::getRed() const {
return red; return red;
} }
Color::~Color() {
}
std::string* Color::toString() const { std::string* Color::toString() const {
std::string *out = new (UseGC) std::string(); std::string *out = new (UseGC) std::string();
std::string t = getTypeName(this); std::string t = getTypeName(this);
out->append((char *)t.c_str()); out->append((char *) t.c_str());
out->append("("); out->append("(");
out->append(std::to_string(alpha)); out->append(std::to_string(alpha));
out->append(","); out->append(",");
...@@ -117,7 +115,7 @@ namespace nitrogen { ...@@ -117,7 +115,7 @@ namespace nitrogen {
} }
Color& Color::operator=(const Color& right) { Color& Color::operator=(const Color& right) {
if (this != &right) { if (*this != right) {
alpha = right.getAlpha(); alpha = right.getAlpha();
red = right.getRed(); red = right.getRed();
green = right.getGreen(); green = right.getGreen();
...@@ -126,29 +124,29 @@ namespace nitrogen { ...@@ -126,29 +124,29 @@ namespace nitrogen {
return *this; return *this;
} }
bool Color::operator!=(const Color& right) const { /*bool Color::operator!=(const Color& right) const {
return !(*this == right); 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());
} }
Color* BLACK = new Color(0, 0, 0); Color* Color::BLACK = new Color(0, 0, 0);
Color* RED = new Color(128, 0, 0); Color* Color::RED = new Color(128, 0, 0);
Color* GREEN = new Color(0, 128, 0); Color* Color::GREEN = new Color(0, 128, 0);
Color* YELLOW = new Color(128, 128, 0); Color* Color::YELLOW = new Color(128, 128, 0);
Color* BLUE = new Color(0, 0, 128); Color* Color::BLUE = new Color(0, 0, 128);
Color* MAGENTA = new Color(128, 0, 128); Color* Color::MAGENTA = new Color(128, 0, 128);
Color* CYAN = new Color(0, 128, 128); Color* Color::CYAN = new Color(0, 128, 128);
Color* WHITE = new Color(192, 192, 192); Color* Color::WHITE = new Color(192, 192, 192);
Color* BRIGHT_BLACK = new Color(128, 128, 128); Color* Color::BRIGHT_BLACK = new Color(128, 128, 128);
Color* BRIGHT_RED = new Color(255, 0, 0); Color* Color::BRIGHT_RED = new Color(255, 0, 0);
Color* BRIGHT_GREEN = new Color(0, 255, 0); Color* Color::BRIGHT_GREEN = new Color(0, 255, 0);
Color* BRIGHT_YELLOW = new Color(255, 255, 0); Color* Color::BRIGHT_YELLOW = new Color(255, 255, 0);
Color* BRIGHT_BLUE = new Color(0, 0, 255); Color* Color::BRIGHT_BLUE = new Color(0, 0, 255);
Color* BRIGHT_MAGENTA = new Color(255, 0, 255); Color* Color::BRIGHT_MAGENTA = new Color(255, 0, 255);
Color* BRIGHT_CYAN = new Color(0, 255, 255); Color* Color::BRIGHT_CYAN = new Color(0, 255, 255);
Color* BRIGHT_WHITE = new Color(255, 255, 255); Color* Color::BRIGHT_WHITE = new Color(255, 255, 255);
} }
} }
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
/* /*
* File: Color.h * File: Color.h
* Author: jlhawkwell * Author: jlhawkwell
* *
...@@ -38,12 +38,13 @@ ...@@ -38,12 +38,13 @@
namespace nitrogen { namespace nitrogen {
namespace nwt { namespace nwt {
class Color : public NObject { class Color : public NObject {
public: public:
static const unsigned int MASK_ALPHA = 0xff000000; static const unsigned int MASK_ALPHA = 0xff000000;
static const unsigned int MASK_RED = 0x00ff0000; static const unsigned int MASK_RED = 0x00ff0000;
static const unsigned int MASK_GREEN = 0x0000ff00; static const unsigned int MASK_GREEN = 0x0000ff00;
static const unsigned int MASK_BLUE = 0x000000ff; static const unsigned int MASK_BLUE = 0x000000ff;
static Color* BLACK; static Color* BLACK;
static Color* RED; static Color* RED;
...@@ -73,14 +74,12 @@ namespace nitrogen { ...@@ -73,14 +74,12 @@ namespace nitrogen {
unsigned int getRGB() const; unsigned int getRGB() const;
unsigned int getARGB() const; unsigned int getARGB() const;
virtual ~Color();
virtual std::string* toString() const; 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;
private: private:
......
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
/* /*
* File: Component.cpp * File: Component.cpp
* Author: jlhawkwell * Author: jlhawkwell
* *
* Created on March 16, 2018, 6:04 PM * Created on March 16, 2018, 6:04 PM
*/ */
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
namespace nitrogen { namespace nitrogen {
namespace nwt { namespace nwt {
Component::Component() { Component::Component() {
background = Color::BRIGHT_BLACK; background = Color::BRIGHT_BLACK;
//border //border
...@@ -52,7 +53,7 @@ namespace nitrogen { ...@@ -52,7 +53,7 @@ namespace nitrogen {
} }
void Component::dispatchEvent(Event* e) { void Component::dispatchEvent(NWTEvent* e) {
} }
...@@ -64,12 +65,12 @@ namespace nitrogen { ...@@ -64,12 +65,12 @@ namespace nitrogen {
return border; return border;
} }
nitrogen::Font* Component::getFont() { nitrogen::nwt::Font* Component::getFont() {
return font; return font;
} }
FontMetrics* Component::getFontMetrics(nitrogen::Font* f) { FontMetrics* Component::getFontMetrics(nitrogen::nwt::Font* f) {
return new FontMetrics(font);
} }
Color* Component::getForeground() { Color* Component::getForeground() {
...@@ -104,7 +105,7 @@ namespace nitrogen { ...@@ -104,7 +105,7 @@ namespace nitrogen {
} }
void Component::processEvent(Event* e) { void Component::processEvent(NWTEvent* e) {
} }
...@@ -125,12 +126,10 @@ namespace nitrogen { ...@@ -125,12 +126,10 @@ namespace nitrogen {
} }
void Component::setBorder(Border* b) { void Component::setBorder(Border* b) {
delete border;
border = b; border = b;
} }
void Component::setFont(nitrogen::Font* f) { void Component::setFont(nitrogen::nwt::Font* f) {
delete font;
font = f; font = f;
} }
...@@ -153,9 +152,5 @@ namespace nitrogen { ...@@ -153,9 +152,5 @@ namespace nitrogen {
void Component::validate() { void Component::validate() {
} }
Component::~Component() {
}
} }
} }
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
/* /*
* File: Component.h * File: Component.h
* Author: jlhawkwell * Author: jlhawkwell
* *
...@@ -36,49 +36,56 @@ ...@@ -36,49 +36,56 @@
#include <ntk.h> #include <ntk.h>
#include <NPosition.h> #include <nitrogen/NPosition.h>
#include <NSize.h> #include <nitrogen/NSize.h>
#include <nitrogen/nwt/Border.h> #include <nitrogen/nwt/Border.h>
#include <nitrogen/nwt/Color.h> #include <nitrogen/nwt/Color.h>
#include <nitrogen/nwt/Font.h> #include <nitrogen/nwt/Font.h>
#include <nitrogen/nwt/FontMetrics.h> #include <nitrogen/nwt/FontMetrics.h>
#include <nitrogen/nwt/Graphics.h> #include <nitrogen/nwt/Graphics.h>
#include <nitrogen/nwt/NWTEvent.h>
#include <nitrogen/nwt/MouseEvent.h>
#include <nitrogen/nwt/MouseListener.h>
#include <list> #include <list>
namespace nitrogen { namespace nitrogen {
namespace nwt { namespace nwt {
class Border;
class Graphics;
class NWTEvent;
class MouseEvent;
class MouseListener;
class Component : public NObject { class Component : public NObject {
public: public:
virtual ~Component();
virtual Border* getBorder(); virtual Border* getBorder();
virtual NSize<unsigned int>* getSize(); virtual NSize<unsigned int>* getSize();
virtual NPosition<int>* getLocation(); virtual NPosition<int>* getLocation();
virtual Component* getParent(); virtual Component* getParent();
virtual Graphics* getGraphics(); virtual Graphics* getGraphics();
virtual nitrogen::nwt::Font* getFont(); virtual nitrogen::nwt::Font* getFont();
virtual FontMetrics* getFontMetrics(nitrogen::nwt::Font *f); virtual FontMetrics* getFontMetrics(nitrogen::nwt::Font* f);
virtual Color* getForeground(); virtual Color* getForeground();
virtual Color* getBackground(); virtual Color* getBackground();
virtual NSize<unsigned int>* getPreferredSize(); virtual NSize<unsigned int>* getPreferredSize();
virtual void setBorder(Border* b); virtual void setBorder(Border* b);
virtual void setFont(nitrogen::nwt::Font *f); virtual void setFont(nitrogen::nwt::Font* f);
virtual void setForeground(Color* c); virtual void setForeground(Color* c);
virtual void setBackground(Color* c); virtual void setBackground(Color* c);
virtual void setSize(NSize<unsigned int> *s); virtual void setSize(NSize<unsigned int>* s);
virtual void setLocation(NPosition<int> *p); virtual void setLocation(NPosition<int>* p);
virtual void paint(Graphics *g); virtual void paint(Graphics *g);
virtual void repaint(); virtual void repaint();
virtual void paintAll(Graphics *g); virtual void paintAll(Graphics* g);
virtual void update(Graphics *g); virtual void update(Graphics* g);
virtual void validate(); virtual void validate();
virtual void removeNotify(); virtual void removeNotify();
virtual void addMouseListener(MouseListener *m); virtual void addMouseListener(MouseListener* m);
virtual void dispatchEvent(Event *e); virtual void dispatchEvent(NWTEvent* e);
protected: protected:
Component *parent; Component *parent;
...@@ -93,7 +100,7 @@ namespace nitrogen { ...@@ -93,7 +100,7 @@ namespace nitrogen {
NSize<unsigned int> *preferredSize; NSize<unsigned int> *preferredSize;
Component(); Component();
virtual void processEvent(Event *e); virtual void processEvent(NWTEvent *e);
virtual void processMouseEvent(MouseEvent *e); virtual void processMouseEvent(MouseEvent *e);
private: private:
......
/*
* 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: ComponentEvent.cpp
* Author: jlhawkwell
*
* Created on March 23, 2018, 4:20 PM
*/
#include "ComponentEvent.h"
#include <nitrogen/nwt/Component.h>
namespace nitrogen {
namespace nwt {
ComponentEvent::ComponentEvent(Component* comp, int i) : NWTEvent(comp, i) {
}
Component* ComponentEvent::getComponent() const {
return (Component*) source;
}
ComponentEvent& ComponentEvent::operator()(Component* comp, int i) const {
ComponentEvent* ce = new ComponentEvent(comp, i);
return *ce;
}
}
}
/*
* 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: ComponentEvent.h
* Author: jlhawkwell
*
* Created on March 23, 2018, 4:20 PM
*/
#ifndef COMPONENTEVENT_H
#define COMPONENTEVENT_H
#include <ntk.h>
//#include <nitrogen/nwt/Component.h>
#include <nitrogen/nwt/NWTEvent.h>
namespace nitrogen {
namespace nwt {
class Component;
class ComponentEvent : public NWTEvent {
public:
ComponentEvent(Component* comp, int i);
virtual Component* getComponent() const;
virtual ComponentEvent& operator()(Component* comp, int i) const;
private:
};
}
}
#endif /* COMPONENTEVENT_H */
/*
* 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: EventListener.cpp
* Author: jlhawkwell
*
* Created on March 23, 2018, 7:58 PM
*/
#include "EventListener.h"
namespace nitrogen {
namespace nwt {
EventListener::EventListener() {
}
}
}
/*
* 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: EventListener.h
* Author: jlhawkwell
*
* Created on March 23, 2018, 7:58 PM
*/
#ifndef EVENTLISTENER_H
#define EVENTLISTENER_H
#include <ntk.h>
namespace nitrogen {
namespace nwt {
class EventListener : public gc {
public:
protected:
EventListener();
private:
};
}
}
#endif /* EVENTLISTENER_H */
/*
* 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: EventObject.cpp
* Author: jlhawkwell
*
* Created on March 23, 2018, 2:36 PM
*/
#include "EventObject.h"
namespace nitrogen {
namespace nwt {
EventObject::EventObject(NObject* object) {
source = object;
}
NObject* EventObject::getSource() {
return source;
}
std::string* EventObject::toString() const {
std::string *out;
out->append(getTypeName(this));
out->append("(");
out->append(source->toString()->c_str());
out->append(")");
return out;
}
EventObject& EventObject::operator()(NObject* object) const {
EventObject* eo = new EventObject(object);
return *eo;
}
EventObject& EventObject::operator=(const EventObject& right) {
if (*this != right) {
source = right.source;
}
return *this;
}
bool EventObject::operator==(const EventObject& right) const {
return (source == right.source);
}
}
}
/*
* 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: EventObject.h
* Author: jlhawkwell
*
* Created on March 23, 2018, 2:36 PM
*/
#ifndef EVENTOBJECT_H
#define EVENTOBJECT_H
#include <ntk.h>
namespace nitrogen {
namespace nwt {
class EventObject : public NObject {
public:
EventObject(NObject* object);
virtual NObject* getSource();
virtual std::string* toString() const;
virtual EventObject& operator()(NObject* object) const;
virtual EventObject& operator=(const EventObject& right);
virtual bool operator==(const EventObject& right) const;
protected:
NObject* source;
private:
};
}
}
#endif /* EVENTOBJECT_H */
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
/* /*
* File: Font.cpp * File: Font.cpp
* Author: jlhawkwell * Author: jlhawkwell
* *
* Created on March 16, 2018, 11:02 PM * Created on March 16, 2018, 11:02 PM
*/ */
...@@ -35,25 +35,29 @@ ...@@ -35,25 +35,29 @@
namespace nitrogen { namespace nitrogen {
namespace nwt { namespace nwt {
Font::Font(std::string* fn, int st, unsigned int si) { Font::Font(std::string* fn, int st, unsigned int si) {
fontName = fn; fontName = fn;
size = si; size = si;
style = st; style = st;
} }
Font::Font(std::string& fn, int st, unsigned int si) { Font::Font(std::string& fn, int st, unsigned int si) {
fontName = &fn; fontName = &fn;
size = si; size = si;
style = st; style = st;
} }
std::string* Font::getFontName() const { return fontName; } std::string* Font::getFontName() const {
return fontName;
int Font::getStyle() const { return style; } }
unsigned int Font::getSize() const { return size; } int Font::getStyle() const {
return style;
}
Font::~Font() { unsigned int Font::getSize() const {
delete fontName; return size;
} }
std::string* Font::toString() const { std::string* Font::toString() const {
...@@ -75,6 +79,7 @@ namespace nitrogen { ...@@ -75,6 +79,7 @@ namespace nitrogen {
Font *n = new Font(fn, st, si); Font *n = new Font(fn, st, si);
return *n; return *n;
} }
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;
...@@ -89,14 +94,20 @@ namespace nitrogen { ...@@ -89,14 +94,20 @@ namespace nitrogen {
return *this; return *this;
} }
bool Font::operator!=(const Font& right) const { /*bool Font::operator!=(const Font& right) const {
return !(*this == right); return !(*this == right);
} }// */
bool Font::operator==(const Font& right) const { bool Font::operator==(const Font& right) const {
if (*fontName != *right.fontName) { return false; } if (*fontName != *right.fontName) {
if (size != right.size) { return false; } return false;
if (style != right.style) { return false; } }
if (size != right.size) {
return false;
}
if (style != right.style) {
return false;
}
return true; return true;
} }
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
/* /*
* File: Font.h * File: Font.h
* Author: jlhawkwell * Author: jlhawkwell
* *
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
namespace nitrogen { namespace nitrogen {
namespace nwt { namespace nwt {
class Font : public NObject { class Font : public NObject {
public: public:
Font(std::string*, int, unsigned int); Font(std::string*, int, unsigned int);
...@@ -46,13 +47,12 @@ namespace nitrogen { ...@@ -46,13 +47,12 @@ namespace nitrogen {
virtual std::string* getFontName() const; virtual std::string* getFontName() const;
virtual int getStyle() const; virtual int getStyle() const;
virtual unsigned int getSize() const; virtual unsigned int getSize() const;
virtual ~Font();
virtual std::string* toString() const; virtual std::string* toString() const;
virtual nitrogen::nwt::Font& operator()(std::string*, int, unsigned int) const; virtual nitrogen::nwt::Font& operator()(std::string*, int, unsigned int) const;
virtual nitrogen::nwt::Font& operator()(std::string&, int, unsigned int) const; virtual nitrogen::nwt::Font& operator()(std::string&, int, unsigned int) const;
Font& operator=(const nitrogen::nwt::Font& right); Font& operator=(const nitrogen::nwt::Font& right);
bool operator!=(const nitrogen::nwt::Font& right) const; //bool operator!=(const nitrogen::nwt::Font& right) const;
bool operator==(const nitrogen::nwt::Font& right) const; bool operator==(const nitrogen::nwt::Font& right) const;
protected: protected:
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
namespace nitrogen { namespace nitrogen {
namespace nwt { namespace nwt {
FontMetrics::FontMetrics(nitrogen::nwt::Font* f) { FontMetrics::FontMetrics(nitrogen::nwt::Font* f) {
font_info = XLoadQueryFont(disp, f->getFontName()->c_str()); font_info = XLoadQueryFont(disp, f->getFontName()->c_str());
} }
...@@ -57,14 +58,11 @@ namespace nitrogen { ...@@ -57,14 +58,11 @@ namespace nitrogen {
unsigned int FontMetrics::stringWidth(std::string* str) const { unsigned int FontMetrics::stringWidth(std::string* str) const {
return XTextWidth(font_info, str->c_str(), str->length()); return XTextWidth(font_info, str->c_str(), str->length());
} }
unsigned int FontMetrics::stringWidth(std::string& str) const { unsigned int FontMetrics::stringWidth(std::string& str) const {
return stringWidth(&str); return stringWidth(&str);
} }
FontMetrics::~FontMetrics() {
delete font_info;
}
std::string* FontMetrics::toString() const { std::string* FontMetrics::toString() const {
std::string *out; std::string *out;
...@@ -88,9 +86,9 @@ namespace nitrogen { ...@@ -88,9 +86,9 @@ namespace nitrogen {
return *this; return *this;
} }
bool FontMetrics::operator!=(const FontMetrics& right) const { /*bool FontMetrics::operator!=(const FontMetrics& right) const {
return !(*this == right); return !(*this == right);
} }// */
bool FontMetrics::operator==(const FontMetrics& right) const { bool FontMetrics::operator==(const FontMetrics& right) const {
return (font_info == right.font_info); return (font_info == right.font_info);
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
namespace nitrogen { namespace nitrogen {
namespace nwt { namespace nwt {
class Font; class Font;
class FontMetrics : public NObject { class FontMetrics : public NObject {
public: public:
FontMetrics(nitrogen::nwt::Font* f); FontMetrics(nitrogen::nwt::Font* f);
...@@ -50,12 +51,11 @@ namespace nitrogen { ...@@ -50,12 +51,11 @@ namespace nitrogen {
virtual unsigned int getHeight() const; virtual unsigned int getHeight() const;
virtual unsigned int stringWidth(std::string* str) const; virtual unsigned int stringWidth(std::string* str) const;
virtual unsigned int stringWidth(std::string& str) const; virtual unsigned int stringWidth(std::string& str) const;
virtual ~FontMetrics();
virtual std::string* toString() const; virtual std::string* toString() const;
FontMetrics& operator()(nitrogen::nwt::Font* f) const; FontMetrics& operator()(nitrogen::nwt::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;
bool operator==(const FontMetrics& right) const; bool operator==(const FontMetrics& right) const;
private: private:
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
/* /*
* File: Graphics.h * File: Graphics.h
* Author: jlhawkwell * Author: jlhawkwell
* *
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
#include <ntk.h> #include <ntk.h>
#include <NPosition.h> #include <nitrogen/NPosition.h>
#include <NSize.h> #include <nitrogen/NSize.h>
#include <nitrogen/nwt/Color.h> #include <nitrogen/nwt/Color.h>
#include <nitrogen/nwt/Font.h> #include <nitrogen/nwt/Font.h>
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
namespace nitrogen { namespace nitrogen {
namespace nwt { namespace nwt {
class Graphics : public NObject { class Graphics : public NObject {
public: public:
virtual void drawPoint(NPosition<int>* point) = 0; virtual void drawPoint(NPosition<int>* point) = 0;
...@@ -68,12 +69,10 @@ namespace nitrogen { ...@@ -68,12 +69,10 @@ namespace nitrogen {
virtual void translate(NPosition<int>* pos) = 0; virtual void translate(NPosition<int>* pos) = 0;
virtual ~Graphics() = 0;
virtual std::string* toString() const = 0; virtual std::string* toString() const = 0;
virtual Graphics& operator()() const = 0; virtual Graphics& operator()() const = 0;
virtual Graphics& operator=(const Graphics& right) = 0; virtual Graphics& operator=(const Graphics& right) = 0;
virtual bool operator!=(const Graphics& right) const = 0; //virtual bool operator!=(const Graphics& right) const = 0;
virtual bool operator==(const Graphics& right) const = 0; virtual bool operator==(const Graphics& right) const = 0;
protected: protected:
......
/*
* 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: InputEvent.cpp
* Author: jlhawkwell
*
* Created on March 23, 2018, 4:41 PM
*/
#include "InputEvent.h"
namespace nitrogen {
namespace nwt {
InputEvent::InputEvent(Component* comp, int i) : ComponentEvent(comp, i) {
time = std::time(0);
}
long InputEvent::getWhen() const {
return time;
}
InputEvent& InputEvent::operator=(const InputEvent& right) {
if (*this != right) {
consumed = right.consumed;
id = right.id;
source = right.source;
time = right.time;
}
return *this;
}
bool InputEvent::operator==(const InputEvent& right) const {
if (time != right.time) {
return false;
}
return NWTEvent::operator==(right);
}
}
}
/*
* 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: InputEvent.h
* Author: jlhawkwell
*
* Created on March 23, 2018, 4:41 PM
*/
#ifndef INPUTEVENT_H
#define INPUTEVENT_H
#include <ntk.h>
//#include <nitrogen/nwt/Component.h>
#include <nitrogen/nwt/ComponentEvent.h>
#include <time.h>
namespace nitrogen {
namespace nwt {
class Component;
class InputEvent : public ComponentEvent {
public:
InputEvent(Component* comp, int i);
virtual long getWhen() const;
virtual InputEvent& operator=(const InputEvent& right);
virtual bool operator==(const InputEvent& right) const;
protected:
time_t time;
private:
};
}
}
#endif /* INPUTEVENT_H */
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
/* /*
* File: Insets.cpp * File: Insets.cpp
* Author: jlhawkwell * Author: jlhawkwell
* *
* Created on March 23, 2018, 1:53 PM * Created on March 23, 2018, 1:53 PM
*/ */
...@@ -43,12 +43,20 @@ namespace nitrogen { ...@@ -43,12 +43,20 @@ namespace nitrogen {
r = right; r = right;
} }
unsigned int Insets::getBottom() const { return b; } unsigned int Insets::getBottom() const {
unsigned int Insets::getLeft() const { return l; } return b;
unsigned int Insets::getRight() const { return r; } }
unsigned int Insets::getTop() const { return t; }
unsigned int Insets::getLeft() const {
return l;
}
unsigned int Insets::getRight() const {
return r;
}
Insets::~Insets() { unsigned int Insets::getTop() const {
return t;
} }
std::string* Insets::toString() const { std::string* Insets::toString() const {
...@@ -83,15 +91,23 @@ namespace nitrogen { ...@@ -83,15 +91,23 @@ namespace nitrogen {
return *this; return *this;
} }
bool Insets::operator!=(const Insets& right) const { /*bool Insets::operator==(const Insets& right) const {
return !(*this == right); return !(*this == right);
} } // */
bool Insets::operator==(const Insets& right) const { bool Insets::operator==(const Insets& right) const {
if (t != right.t) { return false; } if (t != right.t) {
else if (l != right.l) { return false; } return false;
else if (b != right.b) { return false; } }
else if (r != right.r) { return false; } else if (l != right.l) {
return false;
}
else if (b != right.b) {
return false;
}
else if (r != right.r) {
return false;
}
return true; return true;
} }
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
/* /*
* File: Insets.h * File: Insets.h
* Author: jlhawkwell * Author: jlhawkwell
* *
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
namespace nitrogen { namespace nitrogen {
namespace nwt { namespace nwt {
class Insets : public NObject { class Insets : public NObject {
public: public:
Insets(unsigned int top, unsigned int left, unsigned int bottom, unsigned int right); Insets(unsigned int top, unsigned int left, unsigned int bottom, unsigned int right);
...@@ -45,12 +46,11 @@ namespace nitrogen { ...@@ -45,12 +46,11 @@ namespace nitrogen {
virtual unsigned int getLeft() const; virtual unsigned int getLeft() const;
virtual unsigned int getBottom() const; virtual unsigned int getBottom() const;
virtual unsigned int getRight() const; virtual unsigned int getRight() const;
virtual ~Insets();
virtual std::string* toString() const; virtual std::string* toString() const;
virtual Insets& operator()(unsigned int top, unsigned int left, unsigned int bottom, unsigned int right) const; virtual Insets& operator()(unsigned int top, unsigned int left, unsigned int bottom, unsigned int right) const;
virtual Insets& operator=(const Insets& right); virtual Insets& operator=(const Insets& right);
virtual bool operator!=(const Insets& right) const; //virtual bool operator!=(const Insets& right) const;
virtual bool operator==(const Insets& right) const; virtual bool operator==(const Insets& right) const;
protected: protected:
......
/*
* 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: MouseEvent.cpp
* Author: jlhawkwell
*
* Created on March 23, 2018, 5:10 PM
*/
#include "MouseEvent.h"
namespace nitrogen {
namespace nwt {
MouseEvent::MouseEvent(Component* comp, int i, long when, int mods, int x, int y, int clicks, bool popup)
: InputEvent(comp, i) {
}
int MouseEvent::getModifiers() const {
return modifiers;
}
int MouseEvent::getX() const {
return mx;
}
int MouseEvent::getY() const {
return my;
}
int MouseEvent::getClickCount() const {
return clickCount;
}
bool MouseEvent::isPopupTrigger() const {
return popupTrigger;
}
std::string* MouseEvent::toString() const {
std::string *out;
out->append(getTypeName(this));
out->append("(");
out->append(source->toString()->c_str());
out->append(",");
out->append(std::to_string(id));
out->append(",");
out->append(std::to_string(time));
out->append(",");
out->append(std::to_string(modifiers));
out->append(",");
out->append(std::to_string(mx));
out->append(",");
out->append(std::to_string(my));
out->append(",");
out->append(std::to_string(clickCount));
out->append(",");
out->append(popupTrigger ? "true" : "false");
out->append(")");
return out;
}
MouseEvent& MouseEvent::operator()
(Component* comp, int i, long when, int mods, int x, int y, int clicks, bool popup) const {
MouseEvent* me = new MouseEvent(comp, i, when, mods, x, y, clicks, popup);
return *me;
}
bool MouseEvent::operator==(const MouseEvent& right) const {
if (modifiers != right.modifiers) {
return false;
}
else if (mx != right.mx) {
return false;
}
else if (my != right.my) {
return false;
}
else if (clickCount != right.clickCount) {
return false;
}
else if (popupTrigger != right.popupTrigger) {
return false;
}
return InputEvent::operator==(right);
}
}
}
/*
* 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: MouseEvent.h
* Author: jlhawkwell
*
* Created on March 23, 2018, 5:10 PM
*/
#ifndef MOUSEEVENT_H
#define MOUSEEVENT_H
#include <ntk.h>
//#include <nitrogen/nwt/Component.h>
#include <nitrogen/nwt/InputEvent.h>
#include "InputEvent.h"
namespace nitrogen {
namespace nwt {
class Component;
class MouseEvent : public InputEvent {
public:
MouseEvent(Component* comp, int i, long when, int mods, int x, int y, int clicks, bool popupTrigger = false);
virtual int getModifiers() const;
virtual int getX() const;
virtual int getY() const;
virtual int getClickCount() const;
virtual bool isPopupTrigger() const;
virtual std::string* toString() const;
virtual MouseEvent& operator()(Component* comp, int i, long when, int mods, int x, int y, int clicks, bool popup = false) const;
bool operator==(const MouseEvent& right) const;
protected:
int modifiers;
int mx;
int my;
int clickCount;
bool popupTrigger;
private:
};
}
}
#endif /* MOUSEEVENT_H */
/*
* 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: MouseListener.cpp
* Author: jlhawkwell
*
* Created on March 23, 2018, 5:37 PM
*/
#include "MouseListener.h"
namespace nitrogen {
namespace nwt {
MouseListener::MouseListener() {
}
}
}
/*
* 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: MouseListener.h
* Author: jlhawkwell
*
* Created on March 23, 2018, 5:37 PM
*/
#ifndef MOUSELISTENER_H
#define MOUSELISTENER_H
#include <ntk.h>
#include <nitrogen/nwt/EventListener.h>
#include <nitrogen/nwt/MouseEvent.h>
namespace nitrogen {
namespace nwt {
class MouseListener : public EventListener {
public:
MouseListener();
virtual void mouseEntered(MouseEvent* evt) = 0;
virtual void mouseExited(MouseEvent* evt) = 0;
virtual void mousePressed(MouseEvent* evt) = 0;
virtual void mouseReleased(MouseEvent* evt) = 0;
virtual void mouseClicked(MouseEvent* evt) = 0;
private:
};
}
}
#endif /* MOUSELISTENER_H */
/*
* 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: NWTEvent.cpp
* Author: jlhawkwell
*
* Created on March 23, 2018, 2:35 PM
*/
#include "NWTEvent.h"
namespace nitrogen {
namespace nwt {
NWTEvent::NWTEvent(NObject* object, int i) : EventObject((NObject*) object) {
//EventObject((NObject) * object);
//source = object;
id = i;
consumed = false;
}
int NWTEvent::getId() const {
return id;
}
bool NWTEvent::isConsumed() const {
return consumed;
}
void NWTEvent::consume() {
consumed = true;
}
std::string* NWTEvent::toString() const {
std::string *out;
out->append(getTypeName(this));
out->append("(");
out->append(source->toString()->c_str());
out->append(",");
out->append(std::to_string(id));
out->append(")");
return out;
}
NWTEvent& NWTEvent::operator()(NObject* object, int i) const {
NWTEvent* e = new NWTEvent(object, i);
return *e;
}
NWTEvent& NWTEvent::operator=(const NWTEvent& right) {
if (*this != right) {
source = right.source;
id = right.id;
consumed = right.consumed;
}
return *this;
}
bool NWTEvent::operator==(const NWTEvent& right) const {
if (source != right.source) {
return false;
}
else if (id != right.id) {
return false;
}
else if (consumed != right.consumed) {
return false;
}
return true;
}
}
}
/*
* 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: NWTEvent.h
* Author: jlhawkwell
*
* Created on March 23, 2018, 2:35 PM
*/
#ifndef NWTEVENT_H
#define NWTEVENT_H
#include <ntk.h>
#include <nitrogen/nwt/EventObject.h>
namespace nitrogen {
namespace nwt {
class NWTEvent : public EventObject {
public:
NWTEvent(NObject* object, int i);
virtual int getId() const;
virtual bool isConsumed() const;
virtual void consume();
virtual std::string* toString() const;
virtual NWTEvent& operator()(NObject* object, int i) const;
virtual NWTEvent& operator=(const NWTEvent& right);
virtual bool operator==(const NWTEvent& right) const;
protected:
int id;
bool consumed;
private:
};
}
}
#endif /* NWTEVENT_H */
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!