Commit 89302031 by Jessica Hawkwell

adding more NWT classes

1 parent d408b565
......@@ -81,7 +81,7 @@ nbactions.xml
# generated directories
bin/
obj/
generated-doc/
# 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)
configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h)
find_package(X11)
#include_directories("/usr/local/include")
link_libraries(${X11_LIBRARIES})
......
......@@ -36,8 +36,8 @@
#include "NitroWin.h"
#include <NPosition.h>
#include <NSize.h>
#include <nitrogen/NPosition.h>
#include <nitrogen/NSize.h>
#include <unordered_map>
#include <vector>
......
......@@ -5,9 +5,10 @@ configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h)
#include_directories("/usr/local/include")
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})
......
......@@ -26,68 +26,71 @@
#include "NPosition.h"
/*template <typename T>
NPosition<T>::NPosition(T x, T y) {
px = x;
py = y;
} // */
namespace nitrogen {
/*template <typename T>
NPosition<T>::NPosition(const NPosition<T>& other) {
px = other.px;
py = other.py;
} // */
/*template <typename T>
NPosition<T>::NPosition(T x, T y) {
px = x;
py = y;
} // */
/*template <typename T>
NPosition<T>& NPosition<T>::operator=(const NPosition<T>&& other) {
px = other.px;
py = other.py;
return *this;
} // */
/*template <typename T>
NPosition<T>::NPosition(const NPosition<T>& other) {
px = other.px;
py = other.py;
} // */
/*template <typename T>
NPosition<T> NPosition<T>::operator+(const NPosition<T>& other) {
NPosition<T> rt = NPosition<T>(px + other.px, py + other.py);
return rt;
} // */
/*template <typename T>
NPosition<T>& NPosition<T>::operator=(const NPosition<T>&& other) {
px = other.px;
py = other.py;
return *this;
} // */
/*template <typename T>
NPosition<T> NPosition<T>::operator-(const NPosition<T>& other) {
NPosition<T> rt = NPosition<T>(px - other.px, py - other.py);
return rt;
} // */
/*template <typename T>
NPosition<T> NPosition<T>::operator+(const NPosition<T>& other) {
NPosition<T> rt = NPosition<T>(px + other.px, py + other.py);
return rt;
} // */
/*template <typename T>
bool NPosition<T>::operator==(const NPosition<T>& other) const {
if (px != other.getX()) { return false; }
if (py != other.getY()) { return false; }
return true;
} // */
/*template <typename T>
NPosition<T> NPosition<T>::operator-(const NPosition<T>& other) {
NPosition<T> rt = NPosition<T>(px - other.px, py - other.py);
return rt;
} // */
/*template <typename T>
std::string NPosition<T>::toString() {
std::string out = std::string();
out.append("(");
out.append(std::to_string(px));
out.append(", ");
out.append(std::to_string(py));
out.append(")");
return out;
} // */
/*template <typename T>
bool NPosition<T>::operator==(const NPosition<T>& other) const {
if (px != other.getX()) { return false; }
if (py != other.getY()) { return false; }
return true;
} // */
/*template <typename T>
T NPosition<T>::getX() { return px; } // */
/*template <typename T>
T NPosition<T>::getY() { return py; } // */
/*template <typename T>
std::string NPosition<T>::toString() {
std::string out = std::string();
out.append("(");
out.append(std::to_string(px));
out.append(", ");
out.append(std::to_string(py));
out.append(")");
return out;
} // */
/*template <typename T>
void NPosition<T>::setZeroIfNegative() {
if (px < 0) { px = 0; }
if (py < 0) { py = 0;}
} // */
/*template <typename T>
T NPosition<T>::getX() { return px; } // */
/*template <typename T>
T NPosition<T>::getY() { return py; } // */
void testNPositionInt() {
NPosition<int> rawr = NPosition<int>(1,1);
rawr.getX();
rawr.getY();
/*template <typename T>
void NPosition<T>::setZeroIfNegative() {
if (px < 0) { px = 0; }
if (py < 0) { py = 0;}
} // */
void testNPositionInt() {
NPosition<int> rawr = NPosition<int>(1, 1);
rawr.getX();
rawr.getY();
}
}
......@@ -29,61 +29,78 @@
#include <nde.h>
template <typename T>
class NPosition : public gc {
protected:
T px;
T py;
public:
NPosition<T>(T x, T y) {
px = x;
py = y;
}
namespace nitrogen {
NPosition<T>(const NPosition<T>& other) {
px = other.px;
py = other.py;
}
template <typename T>
class NPosition : public gc {
protected:
T px;
T py;
public:
NPosition<T>& operator=(const NPosition<T>&& other) {
px = other.px;
py = other.py;
return *this;
}
NPosition<T>(T x, T y) {
px = x;
py = y;
}
NPosition<T> operator+(const NPosition<T>& other) {
NPosition<T> rt = NPosition<T>(px + other.px, py + other.py);
return rt;
}
NPosition<T>(const NPosition<T>& other) {
px = other.px;
py = other.py;
}
NPosition<T> operator-(const NPosition<T>& other) {
NPosition<T> rt = NPosition<T>(px - other.px, py - other.py);
return rt;
}
NPosition<T>& operator=(const NPosition<T>&& other) {
px = other.px;
py = other.py;
return *this;
}
bool operator==(const NPosition<T>& other) const {
if (px != other.getX()) { return false; }
if (py != other.getY()) { return false; }
return true;
}
NPosition<T> operator+(const NPosition<T>& other) {
NPosition<T> rt = NPosition<T>(px + other.px, py + other.py);
return rt;
}
std::string* toString() {
std::string *out = new (UseGC) std::string();
out->append("(");
out->append(std::to_string(px));
out->append(", ");
out->append(std::to_string(py));
out->append(")");
return out;
}
NPosition<T> operator-(const NPosition<T>& other) {
NPosition<T> rt = NPosition<T>(px - other.px, py - other.py);
return rt;
}
T getX() { return px; }
T getY() { return py; }
bool operator==(const NPosition<T>& other) const {
if (px != other.getX()) {
return false;
}
if (py != other.getY()) {
return false;
}
return true;
}
void setZeroIfNegative() {
if (px < 0) { px = 0; }
if (py < 0) { py = 0;}
}
};
std::string* toString() {
std::string *out = new (UseGC) std::string();
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
......@@ -26,8 +26,11 @@
#include "NSize.h"
void testNSizeInt() {
NSize<int> rawr = NSize<int>(1,1);
rawr.getWidth();
rawr.getHeight();
namespace nitrogen {
void testNSizeInt() {
NSize<int> rawr = NSize<int>(1, 1);
rawr.getWidth();
rawr.getHeight();
}
}
......@@ -29,46 +29,59 @@
#include <nde.h>
template <class T>
class NSize : public gc {
protected:
T pwidth;
T pheight;
public:
NSize<T>(T width, T height) {
pwidth = width;
pheight = height;
}
namespace nitrogen {
NSize<T>(const NSize<T>& other) {
pwidth = other.pwidth;
pheight = other.pheight;
}
template <class T>
class NSize : public gc {
protected:
T pwidth;
T pheight;
public:
NSize<T>& operator=(const NSize<T>& other) {
pwidth = other.pwidth;
pheight = other.pheight;
return *this;
}
NSize<T>(T width, T height) {
pwidth = width;
pheight = height;
}
bool operator==(const NSize<T>& other) const {
if (pwidth != other.getWidth()) { return false; }
if (pheight != other.getHeight()) { return false; }
return true;
}
NSize<T>(const NSize<T>& other) {
pwidth = other.pwidth;
pheight = other.pheight;
}
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;
}
NSize<T>& operator=(const NSize<T>& other) {
pwidth = other.pwidth;
pheight = other.pheight;
return *this;
}
T getWidth() { return pwidth; }
T getHeight() { return pheight; }
};
bool operator==(const NSize<T>& other) const {
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
......@@ -7,13 +7,20 @@ find_library(BoehmGC gc-threaded)
add_library(${PROJECT_NAME} SHARED ntkMain.cpp
nitrogen/NObject.cpp
nitrogen/nwt/Border.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/FontMetrics.cpp
nitrogen/nwt/Graphics.cpp
nitrogen/nwt/InputEvent.cpp
nitrogen/nwt/Insets.cpp
# nitrogen/nwt/Border.cpp
# nitrogen/nwt/Component.cpp
nitrogen/nwt/MouseEvent.cpp
nitrogen/nwt/MouseListener.cpp
nitrogen/nwt/NWTEvent.cpp
)
......
......@@ -65,8 +65,7 @@ namespace nitrogen {
}
bool NObject::operator!=(const NObject& right) const {
bool result = !(*this == right);
return result;
return !(*this == right);
}
bool NObject::operator==(const NObject& right) const {
......
......@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
/*
* File: NObject.h
* Author: jlhawkwell
*
......@@ -36,11 +36,10 @@
#include <ntk.h>
namespace nitrogen {
class NObject : public gc {
public:
NObject();
//NObject(const NObject& orig);
virtual ~NObject();
virtual std::string* toString() const;
virtual NObject& operator()() const;
......
......@@ -24,21 +24,19 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
/*
* File: Border.cpp
* Author: jlhawkwell
*
*
* Created on March 23, 2018, 1:44 PM
*/
#include "Border.h"
#include "nitrogen/nwt/Border.h"
namespace nitrogen {
namespace nwt {
Border::Border() {
}
Border::~Border() {
Border::Border() {
}
}
}
......
......@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
/*
* File: Border.h
* Author: jlhawkwell
*
......@@ -36,19 +36,28 @@
#include <ntk.h>
#include <nitrogen/nwt/Component.h>
//#include <nitrogen/nwt/Component.h>
#include <nitrogen/nwt/Graphics.h>
#include <nitrogen/nwt/Insets.h>
namespace nitrogen {
namespace nwt {
class Component;
class Border : public NObject {
public:
virtual Insets* getBorderInsets(Component* comp) = 0;
virtual bool isBorderOpaque() = 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:
Component* c;
Border();
private:
......
......@@ -24,10 +24,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
/*
* File: Color.cpp
* Author: jlhawkwell
*
*
* Created on March 16, 2018, 7:19 PM
*/
......@@ -35,6 +35,7 @@
namespace nitrogen {
namespace nwt {
Color::Color(unsigned int c) {
alpha = 255;
red = ((c & MASK_RED) >> 16);
......@@ -73,21 +74,18 @@ namespace nitrogen {
}
unsigned int Color::getARGB() const {
return (alpha << 24) + getRGB();
return (alpha << 24) +getRGB();
}
unsigned char Color::getRed() const {
return red;
}
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((char *) t.c_str());
out->append("(");
out->append(std::to_string(alpha));
out->append(",");
......@@ -117,7 +115,7 @@ namespace nitrogen {
}
Color& Color::operator=(const Color& right) {
if (this != &right) {
if (*this != right) {
alpha = right.getAlpha();
red = right.getRed();
green = right.getGreen();
......@@ -126,29 +124,29 @@ namespace nitrogen {
return *this;
}
bool Color::operator!=(const Color& right) const {
/*bool Color::operator!=(const Color& right) const {
return !(*this == right);
}
}// */
bool Color::operator==(const Color& right) const {
return (getARGB() == right.getARGB());
}
Color* BLACK = new Color(0, 0, 0);
Color* RED = new Color(128, 0, 0);
Color* GREEN = new Color(0, 128, 0);
Color* YELLOW = new Color(128, 128, 0);
Color* BLUE = new Color(0, 0, 128);
Color* MAGENTA = new Color(128, 0, 128);
Color* CYAN = new Color(0, 128, 128);
Color* WHITE = new Color(192, 192, 192);
Color* BRIGHT_BLACK = new Color(128, 128, 128);
Color* BRIGHT_RED = new Color(255, 0, 0);
Color* BRIGHT_GREEN = new Color(0, 255, 0);
Color* BRIGHT_YELLOW = new Color(255, 255, 0);
Color* BRIGHT_BLUE = new Color(0, 0, 255);
Color* BRIGHT_MAGENTA = new Color(255, 0, 255);
Color* BRIGHT_CYAN = new Color(0, 255, 255);
Color* BRIGHT_WHITE = new Color(255, 255, 255);
Color* Color::BLACK = new Color(0, 0, 0);
Color* Color::RED = new Color(128, 0, 0);
Color* Color::GREEN = new Color(0, 128, 0);
Color* Color::YELLOW = new Color(128, 128, 0);
Color* Color::BLUE = new Color(0, 0, 128);
Color* Color::MAGENTA = new Color(128, 0, 128);
Color* Color::CYAN = new Color(0, 128, 128);
Color* Color::WHITE = new Color(192, 192, 192);
Color* Color::BRIGHT_BLACK = new Color(128, 128, 128);
Color* Color::BRIGHT_RED = new Color(255, 0, 0);
Color* Color::BRIGHT_GREEN = new Color(0, 255, 0);
Color* Color::BRIGHT_YELLOW = new Color(255, 255, 0);
Color* Color::BRIGHT_BLUE = new Color(0, 0, 255);
Color* Color::BRIGHT_MAGENTA = new Color(255, 0, 255);
Color* Color::BRIGHT_CYAN = new Color(0, 255, 255);
Color* Color::BRIGHT_WHITE = new Color(255, 255, 255);
}
}
......@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
/*
* File: Color.h
* Author: jlhawkwell
*
......@@ -38,12 +38,13 @@
namespace nitrogen {
namespace nwt {
class Color : public NObject {
public:
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_BLUE = 0x000000ff;
static const unsigned int MASK_BLUE = 0x000000ff;
static Color* BLACK;
static Color* RED;
......@@ -73,14 +74,12 @@ namespace nitrogen {
unsigned int getRGB() const;
unsigned int getARGB() const;
virtual ~Color();
virtual std::string* toString() 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, unsigned char alpha) const;
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;
private:
......
......@@ -24,10 +24,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
/*
* File: Component.cpp
* Author: jlhawkwell
*
*
* Created on March 16, 2018, 6:04 PM
*/
......@@ -35,6 +35,7 @@
namespace nitrogen {
namespace nwt {
Component::Component() {
background = Color::BRIGHT_BLACK;
//border
......@@ -52,7 +53,7 @@ namespace nitrogen {
}
void Component::dispatchEvent(Event* e) {
void Component::dispatchEvent(NWTEvent* e) {
}
......@@ -64,12 +65,12 @@ namespace nitrogen {
return border;
}
nitrogen::Font* Component::getFont() {
nitrogen::nwt::Font* Component::getFont() {
return font;
}
FontMetrics* Component::getFontMetrics(nitrogen::Font* f) {
FontMetrics* Component::getFontMetrics(nitrogen::nwt::Font* f) {
return new FontMetrics(font);
}
Color* Component::getForeground() {
......@@ -104,7 +105,7 @@ namespace nitrogen {
}
void Component::processEvent(Event* e) {
void Component::processEvent(NWTEvent* e) {
}
......@@ -125,12 +126,10 @@ namespace nitrogen {
}
void Component::setBorder(Border* b) {
delete border;
border = b;
}
void Component::setFont(nitrogen::Font* f) {
delete font;
void Component::setFont(nitrogen::nwt::Font* f) {
font = f;
}
......@@ -153,9 +152,5 @@ namespace nitrogen {
void Component::validate() {
}
Component::~Component() {
}
}
}
......@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
/*
* File: Component.h
* Author: jlhawkwell
*
......@@ -36,49 +36,56 @@
#include <ntk.h>
#include <NPosition.h>
#include <NSize.h>
#include <nitrogen/NPosition.h>
#include <nitrogen/NSize.h>
#include <nitrogen/nwt/Border.h>
#include <nitrogen/nwt/Color.h>
#include <nitrogen/nwt/Font.h>
#include <nitrogen/nwt/FontMetrics.h>
#include <nitrogen/nwt/Graphics.h>
#include <nitrogen/nwt/NWTEvent.h>
#include <nitrogen/nwt/MouseEvent.h>
#include <nitrogen/nwt/MouseListener.h>
#include <list>
namespace nitrogen {
namespace nwt {
class Border;
class Graphics;
class NWTEvent;
class MouseEvent;
class MouseListener;
class Component : public NObject {
public:
virtual ~Component();
virtual Border* getBorder();
virtual NSize<unsigned int>* getSize();
virtual NPosition<int>* getLocation();
virtual Component* getParent();
virtual Graphics* getGraphics();
virtual nitrogen::nwt::Font* getFont();
virtual FontMetrics* getFontMetrics(nitrogen::nwt::Font *f);
virtual FontMetrics* getFontMetrics(nitrogen::nwt::Font* f);
virtual Color* getForeground();
virtual Color* getBackground();
virtual NSize<unsigned int>* getPreferredSize();
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 setBackground(Color* c);
virtual void setSize(NSize<unsigned int> *s);
virtual void setLocation(NPosition<int> *p);
virtual void setSize(NSize<unsigned int>* s);
virtual void setLocation(NPosition<int>* p);
virtual void paint(Graphics *g);
virtual void repaint();
virtual void paintAll(Graphics *g);
virtual void update(Graphics *g);
virtual void paintAll(Graphics* g);
virtual void update(Graphics* g);
virtual void validate();
virtual void removeNotify();
virtual void addMouseListener(MouseListener *m);
virtual void dispatchEvent(Event *e);
virtual void addMouseListener(MouseListener* m);
virtual void dispatchEvent(NWTEvent* e);
protected:
Component *parent;
......@@ -93,7 +100,7 @@ namespace nitrogen {
NSize<unsigned int> *preferredSize;
Component();
virtual void processEvent(Event *e);
virtual void processEvent(NWTEvent *e);
virtual void processMouseEvent(MouseEvent *e);
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 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
/*
* File: Font.cpp
* Author: jlhawkwell
*
*
* Created on March 16, 2018, 11:02 PM
*/
......@@ -35,25 +35,29 @@
namespace nitrogen {
namespace nwt {
Font::Font(std::string* fn, int st, unsigned int si) {
fontName = fn;
size = si;
style = st;
}
Font::Font(std::string& fn, int st, unsigned int si) {
fontName = &fn;
size = si;
style = st;
}
std::string* Font::getFontName() const { return fontName; }
int Font::getStyle() const { return style; }
std::string* Font::getFontName() const {
return fontName;
}
unsigned int Font::getSize() const { return size; }
int Font::getStyle() const {
return style;
}
Font::~Font() {
delete fontName;
unsigned int Font::getSize() const {
return size;
}
std::string* Font::toString() const {
......@@ -75,6 +79,7 @@ namespace nitrogen {
Font *n = new Font(fn, st, si);
return *n;
}
Font& Font::operator()(std::string& fn, int st, unsigned int si) const {
Font *n = new Font(fn, st, si);
return *n;
......@@ -89,14 +94,20 @@ namespace nitrogen {
return *this;
}
bool Font::operator!=(const Font& right) const {
/*bool Font::operator!=(const Font& right) const {
return !(*this == right);
}
}// */
bool Font::operator==(const Font& right) const {
if (*fontName != *right.fontName) { return false; }
if (size != right.size) { return false; }
if (style != right.style) { return false; }
if (*fontName != *right.fontName) {
return false;
}
if (size != right.size) {
return false;
}
if (style != right.style) {
return false;
}
return true;
}
}
......
......@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
/*
* File: Font.h
* Author: jlhawkwell
*
......@@ -38,6 +38,7 @@
namespace nitrogen {
namespace nwt {
class Font : public NObject {
public:
Font(std::string*, int, unsigned int);
......@@ -46,13 +47,12 @@ namespace nitrogen {
virtual std::string* getFontName() const;
virtual int getStyle() const;
virtual unsigned int getSize() const;
virtual ~Font();
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;
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;
protected:
......
......@@ -42,6 +42,7 @@
namespace nitrogen {
namespace nwt {
FontMetrics::FontMetrics(nitrogen::nwt::Font* f) {
font_info = XLoadQueryFont(disp, f->getFontName()->c_str());
}
......@@ -57,14 +58,11 @@ namespace nitrogen {
unsigned int FontMetrics::stringWidth(std::string* str) const {
return XTextWidth(font_info, str->c_str(), str->length());
}
unsigned int FontMetrics::stringWidth(std::string& str) const {
return stringWidth(&str);
}
FontMetrics::~FontMetrics() {
delete font_info;
}
std::string* FontMetrics::toString() const {
std::string *out;
......@@ -88,9 +86,9 @@ namespace nitrogen {
return *this;
}
bool FontMetrics::operator!=(const FontMetrics& right) const {
/*bool FontMetrics::operator!=(const FontMetrics& right) const {
return !(*this == right);
}
}// */
bool FontMetrics::operator==(const FontMetrics& right) const {
return (font_info == right.font_info);
......
......@@ -43,6 +43,7 @@
namespace nitrogen {
namespace nwt {
class Font;
class FontMetrics : public NObject {
public:
FontMetrics(nitrogen::nwt::Font* f);
......@@ -50,12 +51,11 @@ namespace nitrogen {
virtual unsigned int getHeight() const;
virtual unsigned int stringWidth(std::string* str) const;
virtual unsigned int stringWidth(std::string& str) const;
virtual ~FontMetrics();
virtual std::string* toString() const;
FontMetrics& operator()(nitrogen::nwt::Font* f) const;
FontMetrics& operator=(const FontMetrics& right);
bool operator!=(const FontMetrics& right) const;
//bool operator!=(const FontMetrics& right) const;
bool operator==(const FontMetrics& right) const;
private:
......
......@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
/*
* File: Graphics.h
* Author: jlhawkwell
*
......@@ -36,8 +36,8 @@
#include <ntk.h>
#include <NPosition.h>
#include <NSize.h>
#include <nitrogen/NPosition.h>
#include <nitrogen/NSize.h>
#include <nitrogen/nwt/Color.h>
#include <nitrogen/nwt/Font.h>
......@@ -45,6 +45,7 @@
namespace nitrogen {
namespace nwt {
class Graphics : public NObject {
public:
virtual void drawPoint(NPosition<int>* point) = 0;
......@@ -68,12 +69,10 @@ namespace nitrogen {
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;
virtual bool operator==(const Graphics& right) const = 0;
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 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
/*
* File: Insets.cpp
* Author: jlhawkwell
*
*
* Created on March 23, 2018, 1:53 PM
*/
......@@ -43,12 +43,20 @@ namespace nitrogen {
r = right;
}
unsigned int Insets::getBottom() const { return b; }
unsigned int Insets::getLeft() const { return l; }
unsigned int Insets::getRight() const { return r; }
unsigned int Insets::getTop() const { return t; }
unsigned int Insets::getBottom() const {
return b;
}
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 {
......@@ -83,15 +91,23 @@ namespace nitrogen {
return *this;
}
bool Insets::operator!=(const Insets& right) const {
/*bool Insets::operator==(const Insets& right) const {
return !(*this == right);
}
} // */
bool Insets::operator==(const Insets& right) const {
if (t != right.t) { return false; }
else if (l != right.l) { return false; }
else if (b != right.b) { return false; }
else if (r != right.r) { return false; }
if (t != right.t) {
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;
}
}
......
......@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
/*
* File: Insets.h
* Author: jlhawkwell
*
......@@ -38,6 +38,7 @@
namespace nitrogen {
namespace nwt {
class Insets : public NObject {
public:
Insets(unsigned int top, unsigned int left, unsigned int bottom, unsigned int right);
......@@ -45,12 +46,11 @@ namespace nitrogen {
virtual unsigned int getLeft() const;
virtual unsigned int getBottom() const;
virtual unsigned int getRight() const;
virtual ~Insets();
virtual std::string* toString() const;
virtual Insets& operator()(unsigned int top, unsigned int left, unsigned int bottom, unsigned int right) const;
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;
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!