Commit 6b1be3ff by Jessica Hawkwell

Added new classes for #1

1 parent 9b9552c6
Showing with 1093 additions and 361 deletions
#include "NitroWin.h"
#include <nitrogen/nwt/Color.h>
#include <nitrogen/NObject.h>
#include <nitrogen/Object.h>
#include "NWManager.h"
#include <iostream>
int main ( int argc, char** argv )
{
int main(int argc, char** argv) {
std::cout << NITROWIN_NAME << " v" << NITROWIN_VERSION << std::endl;
nitrogen::nwt::Color no = nitrogen::nwt::Color(255, 255, 255);
std::cout << "Color: ";
......
......@@ -28,66 +28,6 @@
namespace nitrogen {
/*template <typename T>
NPosition<T>::NPosition(T x, T y) {
px = x;
py = y;
} // */
/*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) {
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>
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>
T NPosition<T>::getX() { return px; } // */
/*template <typename T>
T NPosition<T>::getY() { return py; } // */
/*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();
......
......@@ -6,11 +6,14 @@ find_package(X11)
find_library(BoehmGC gc-threaded)
add_library(${PROJECT_NAME} SHARED ntkMain.cpp
nitrogen/NObject.cpp
nitrogen/Object.cpp
nitrogen/nwt/ActionEvent.cpp
nitrogen/nwt/ActionListener.cpp
nitrogen/nwt/Border.cpp
nitrogen/nwt/Color.cpp
nitrogen/nwt/Component.cpp
nitrogen/nwt/ComponentEvent.cpp
nitrogen/nwt/Container.cpp
nitrogen/nwt/Dimension.cpp
nitrogen/nwt/EventListener.cpp
nitrogen/nwt/EventObject.cpp
......@@ -19,10 +22,12 @@ nitrogen/nwt/FontMetrics.cpp
nitrogen/nwt/Graphics.cpp
nitrogen/nwt/InputEvent.cpp
nitrogen/nwt/Insets.cpp
nitrogen/nwt/LayoutManager.cpp
nitrogen/nwt/MouseEvent.cpp
nitrogen/nwt/MouseListener.cpp
nitrogen/nwt/NWTEvent.cpp
nitrogen/nwt/Point.cpp
nitrogen/nwt/Rectangle.cpp
)
......
......@@ -25,51 +25,51 @@
*/
/*
* File: NObject.cpp
* File: Object.cpp
* Author: jlhawkwell
*
* Created on March 16, 2018, 11:12 AM
*/
#include "NObject.h"
#include "Object.h"
#include <ostream>
namespace nitrogen {
NObject::NObject() {
Object::Object() {
}
std::string* NObject::toString() const {
std::string* Object::toString() {
std::string* str;
str->append(getTypeName(this));
return str;
}
NObject& NObject::operator()() const {
NObject *tmp = new NObject();
Object& Object::operator()() {
Object *tmp = new Object();
return *tmp;
}
NObject& NObject::operator=(const NObject& right) {
if (this == &right) {
Object& Object::operator=(Object& right) {
if (*this == right) {
return *this; // Yes, so skip assignment, and just return *this.
}
return *this;
}
bool NObject::operator!=(const NObject& right) const {
bool Object::operator!=(Object& right) {
return !(*this == right);
}
bool NObject::operator==(const NObject& right) const {
bool Object::operator==(Object& right) {
bool result = false;
return result;
}
std::ostream& operator<<(std::ostream& os, const NObject& obj) {
std::ostream& operator<<(std::ostream& os, Object& obj) {
// Write obj to stream
os << *obj.toString();
os << obj.toString()->c_str();
return os;
}
}
......@@ -25,30 +25,30 @@
*/
/*
* File: NObject.h
* File: Object.h
* Author: jlhawkwell
*
* Created on March 16, 2018, 11:12 AM
*/
#ifndef NOBJECT_H
#define NOBJECT_H
#ifndef OBJECT_H
#define OBJECT_H
#include <ntk.h>
namespace nitrogen {
class NObject : public gc {
class Object : public gc {
public:
NObject();
Object();
virtual std::string* toString() const;
virtual NObject& operator()() const;
virtual NObject& operator=(const NObject& right);
virtual bool operator!=(const NObject& right) const;
virtual bool operator==(const NObject& right) const;
friend std::ostream& operator<<(std::ostream& os, const NObject& obj);
virtual std::string* toString();
virtual Object& operator()();
virtual Object& operator=(Object& right);
virtual bool operator!=(Object& right);
virtual bool operator==(Object& right);
friend std::ostream& operator<<(std::ostream& os, Object& obj);
private:
};
}
#endif /* NOBJECT_H */
#endif /* OBJECT_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: ActionEvent.cpp
* Author: jlhawkwell
*
* Created on March 24, 2018, 9:24 AM
*/
#include "ActionEvent.h"
namespace nitrogen {
namespace nwt {
ActionEvent::ActionEvent(Object* object, int i, std::string* cmd)
: NWTEvent(object, i) {
source = object;
id = i;
command = cmd;
}
ActionEvent::ActionEvent(Object* object, int i, std::string& cmd)
: NWTEvent(object, i) {
source = object;
id = i;
command = &cmd;
}
ActionEvent::ActionEvent(Object* object, std::string* cmd)
: NWTEvent(object, 0) {
source = object;
id = 0;
command = cmd;
}
ActionEvent::ActionEvent(Object* object, std::string& cmd)
: NWTEvent(object, 0) {
source = object;
id = 0;
command = &cmd;
}
std::string* ActionEvent::toString() {
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(command->c_str());
out->append(")");
return out;
}
ActionEvent& ActionEvent::operator()(Object& object, int i, std::string* cmd) {
ActionEvent* ae = new ActionEvent(&object, i, cmd);
return *ae;
}
ActionEvent& ActionEvent::operator()(Object& object, std::string* cmd) {
ActionEvent* ae = new ActionEvent(&object, 0, cmd);
return *ae;
}
ActionEvent& ActionEvent::operator=(ActionEvent& right) {
if (*this != right) {
NWTEvent::operator=(right);
command = right.command;
}
return *this;
}
bool ActionEvent::operator==(ActionEvent& right) {
if (*command != *right.command) {
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: ActionEvent.h
* Author: jlhawkwell
*
* Created on March 24, 2018, 9:24 AM
*/
#ifndef ACTIONEVENT_H
#define ACTIONEVENT_H
#include <ntk.h>
#include <nitrogen/nwt/NWTEvent.h>
namespace nitrogen {
namespace nwt {
class ActionEvent : public NWTEvent {
public:
ActionEvent(Object* object, int i, std::string* cmd);
ActionEvent(Object* object, int i, std::string& cmd);
ActionEvent(Object* object, std::string* cmd);
ActionEvent(Object* object, std::string& cmd);
virtual std::string* toString() override;
virtual ActionEvent& operator()(Object& object, int i, std::string* cmd);
virtual ActionEvent& operator()(Object& object, std::string* cmd);
virtual ActionEvent& operator=(ActionEvent& right);
virtual bool operator==(ActionEvent& right);
protected:
std::string* command;
private:
};
}
}
#endif /* ACTIONEVENT_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: ActionListener.cpp
* Author: jlhawkwell
*
* Created on March 24, 2018, 9:43 AM
*/
#include "ActionListener.h"
namespace nitrogen {
namespace nwt {
ActionListener::ActionListener() {
}
}
}
/*
* 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: ActionListener.h
* Author: jlhawkwell
*
* Created on March 24, 2018, 9:43 AM
*/
#ifndef ACTIONLISTENER_H
#define ACTIONLISTENER_H
#include <ntk.h>
#include <nitrogen/nwt/EventListener.h>
namespace nitrogen {
namespace nwt {
class ActionEvent;
class ActionListener : public EventListener {
public:
ActionListener();
virtual void actionPerformed(ActionEvent* event) = 0;
private:
};
}
}
#endif /* ACTIONLISTENER_H */
......@@ -36,25 +36,23 @@
#include <ntk.h>
//#include <nitrogen/nwt/Component.h>
#include <nitrogen/nwt/Graphics.h>
#include <nitrogen/nwt/Insets.h>
namespace nitrogen {
namespace nwt {
class Component;
class Graphics;
class Insets;
class Border : public NObject {
class Border : public Object {
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 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;
virtual Border& operator()(Component& comp) const = 0;
virtual Border& operator=(Border& right) = 0;
//virtual bool operator!=(Color& right) const = 0;
virtual bool operator==(Border& right) const = 0;
protected:
Component* c;
......
......@@ -57,31 +57,31 @@ namespace nitrogen {
blue = b;
}
unsigned char Color::getAlpha() const {
unsigned char Color::getAlpha() {
return alpha;
}
unsigned char Color::getBlue() const {
unsigned char Color::getBlue() {
return blue;
}
unsigned char Color::getGreen() const {
unsigned char Color::getGreen() {
return green;
}
unsigned int Color::getRGB() const {
unsigned int Color::getRGB() {
return (red << 16) + (green << 8) + blue;
}
unsigned int Color::getARGB() const {
unsigned int Color::getARGB() {
return (alpha << 24) +getRGB();
}
unsigned char Color::getRed() const {
unsigned char Color::getRed() {
return red;
}
std::string* Color::toString() const {
std::string* Color::toString() {
std::string *out = new (UseGC) std::string();
std::string t = getTypeName(this);
......@@ -99,22 +99,22 @@ namespace nitrogen {
return out;
}
Color& Color::operator()(unsigned int c) const {
Color& Color::operator()(unsigned int c) {
Color *nc = new Color(c);
return *nc;
}
Color& Color::operator()(unsigned char r, unsigned char g, unsigned char b) const {
Color& Color::operator()(unsigned char r, unsigned char g, unsigned char b) {
Color *nc = new Color(r, g, b);
return *nc;
}
Color& Color::operator()(unsigned char r, unsigned char g, unsigned char b, unsigned char a) const {
Color& Color::operator()(unsigned char r, unsigned char g, unsigned char b, unsigned char a) {
Color *nc = new Color(r, g, b, a);
return *nc;
}
Color& Color::operator=(const Color& right) {
Color& Color::operator=(Color& right) {
if (*this != right) {
alpha = right.getAlpha();
red = right.getRed();
......@@ -124,11 +124,11 @@ namespace nitrogen {
return *this;
}
/*bool Color::operator!=(const Color& right) const {
/*bool Color::operator!=(Color& right) {
return !(*this == right);
}// */
bool Color::operator==(const Color& right) const {
bool Color::operator==(Color& right) {
return (getARGB() == right.getARGB());
}
......
......@@ -39,7 +39,7 @@
namespace nitrogen {
namespace nwt {
class Color : public NObject {
class Color : public Object {
public:
static const unsigned int MASK_ALPHA = 0xff000000;
static const unsigned int MASK_RED = 0x00ff0000;
......@@ -67,20 +67,20 @@ namespace nitrogen {
Color(unsigned char red, unsigned char green, unsigned char blue);
Color(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha);
unsigned char getAlpha() const;
unsigned char getRed() const;
unsigned char getGreen() const;
unsigned char getBlue() const;
unsigned int getRGB() const;
unsigned int getARGB() const;
unsigned char getAlpha();
unsigned char getRed();
unsigned char getGreen();
unsigned char getBlue();
unsigned int getRGB();
unsigned int getARGB();
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 std::string* toString() override;
virtual Color& operator()(unsigned int c);
virtual Color& operator()(unsigned char red, unsigned char green, unsigned char blue);
virtual Color& operator()(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha);
virtual Color& operator=(Color& right);
//virtual bool operator!=(Color& right);
virtual bool operator==(Color& right);
private:
unsigned char red;
......
......@@ -42,27 +42,43 @@ namespace nitrogen {
//font
foreground = Color::BLACK;
//graphics
location = new NPosition<int>(0, 0);
cx = 0;
cy = 0;
cw = 0;
ch = 0;
//me_list = new std::list<MouseEvent>();
parent = nullptr;
preferredSize = new NSize<unsigned int>(0, 0);
size = new NSize<unsigned int>(0, 0);
preferredSize = new Rectangle(0, 0);
}
void Component::addMouseListener(MouseListener* m) {
Border* Component::getBorder() {
return border;
}
Dimension* Component::getSize() {
Dimension* d = new Dimension(cw, ch);
return d;
}
void Component::dispatchEvent(NWTEvent* e) {
Rectangle* Component::getBounds() {
Rectangle* r = new Rectangle(cx, cy, cw, ch);
return r;
}
int Component::getX() {
return cx;
}
Color* Component::getBackground() {
return background;
int Component::getY() {
return cy;
}
Border* Component::getBorder() {
return border;
Component* Component::getParent() {
return parent;
}
Graphics* Component::getGraphics() {
return graphics;
}
nitrogen::nwt::Font* Component::getFont() {
......@@ -77,43 +93,53 @@ namespace nitrogen {
return foreground;
}
Graphics* Component::getGraphics() {
return graphics;
Color* Component::getBackground() {
return background;
}
Component* Component::getParent() {
return parent;
Component* Component::getComponentAt(int x, int y) {
if (getBounds()->contains(x, y)) {
return this;
}
return nullptr;
}
NPosition<int>* Component::getLocation() {
return location;
Dimension* Component::getPreferredSize() {
Dimension* d = new Dimension(cw, ch);
return d;
}
NSize<unsigned int>* Component::getPreferredSize() {
return preferredSize;
void Component::setBorder(Border* b) {
border = b;
}
NSize<unsigned int>* Component::getSize() {
return size;
void Component::setFont(nitrogen::nwt::Font* f) {
font = f;
}
void Component::paint(Graphics* g) {
void Component::setForeground(Color* c) {
foreground = c;
}
void Component::paintAll(Graphics* g) {
void Component::setBackground(Color* c) {
background = c;
}
void Component::processEvent(NWTEvent* e) {
void Component::setSize(Dimension* s) {
setSize(s->getWidth(), s->getHeight());
}
void Component::processMouseEvent(MouseEvent* e) {
void Component::setSize(unsigned int width, unsigned int height) {
cw = width;
ch = height;
}
void Component::setLocation(unsigned int x, unsigned int y) {
cx = x;
cy = y;
}
void Component::removeNotify() {
void Component::paint(Graphics* g) {
}
......@@ -121,35 +147,35 @@ namespace nitrogen {
}
void Component::setBackground(Color* c) {
background = c;
void Component::paintAll(Graphics* g) {
}
void Component::setBorder(Border* b) {
border = b;
void Component::update(Graphics* g) {
}
void Component::setFont(nitrogen::nwt::Font* f) {
font = f;
void Component::validate() {
}
void Component::setForeground(Color* c) {
foreground = c;
void Component::removeNotify() {
}
void Component::setLocation(NPosition<int>* p) {
location = p;
void Component::addMouseListener(MouseListener* m) {
}
void Component::setSize(NSize<unsigned int>* s) {
size = s;
void Component::dispatchEvent(NWTEvent* e) {
}
void Component::update(Graphics* g) {
void Component::processEvent(NWTEvent* e) {
}
void Component::validate() {
void Component::processMouseEvent(MouseEvent* e) {
}
}
......
......@@ -36,17 +36,16 @@
#include <ntk.h>
#include <nitrogen/NPosition.h>
#include <nitrogen/NSize.h>
#include <nitrogen/nwt/Border.h>
#include <nitrogen/nwt/Color.h>
#include <nitrogen/nwt/Dimension.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 <nitrogen/nwt/NWTEvent.h>
#include <nitrogen/nwt/Rectangle.h>
#include <list>
......@@ -58,25 +57,29 @@ namespace nitrogen {
class MouseEvent;
class MouseListener;
class Component : public NObject {
class Component : public Object {
public:
virtual Border* getBorder();
virtual NSize<unsigned int>* getSize();
virtual NPosition<int>* getLocation();
virtual Dimension* getSize();
virtual Rectangle* getBounds();
virtual int getX();
virtual int getY();
virtual Component* getParent();
virtual Graphics* getGraphics();
virtual nitrogen::nwt::Font* getFont();
virtual FontMetrics* getFontMetrics(nitrogen::nwt::Font* f);
virtual Color* getForeground();
virtual Color* getBackground();
virtual NSize<unsigned int>* getPreferredSize();
virtual Component* getComponentAt(int x, int y);
virtual Dimension* getPreferredSize();
virtual void setBorder(Border* b);
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(Dimension* s);
virtual void setSize(unsigned int width, unsigned int height);
virtual void setLocation(unsigned int x, unsigned int y);
virtual void paint(Graphics *g);
virtual void repaint();
virtual void paintAll(Graphics* g);
......@@ -88,16 +91,18 @@ namespace nitrogen {
virtual void dispatchEvent(NWTEvent* e);
protected:
Component *parent;
Graphics *graphics;
NPosition<int> *location;
Border *border;
nitrogen::nwt::Font *font;
Color *foreground;
Color *background;
NSize<unsigned int> *size;
std::list<MouseEvent> *me_list;
NSize<unsigned int> *preferredSize;
Component* parent;
Graphics* graphics;
int cx;
int cy;
unsigned int cw;
unsigned int ch;
Border* border;
nitrogen::nwt::Font* font;
Color* foreground;
Color* background;
std::list<MouseEvent>* me_list;
Rectangle* preferredSize;
Component();
virtual void processEvent(NWTEvent *e);
......
......@@ -41,12 +41,12 @@ namespace nitrogen {
}
Component* ComponentEvent::getComponent() const {
Component* ComponentEvent::getComponent() {
return (Component*) source;
}
ComponentEvent& ComponentEvent::operator()(Component* comp, int i) const {
ComponentEvent* ce = new ComponentEvent(comp, i);
ComponentEvent& ComponentEvent::operator()(Component& comp, int i) {
ComponentEvent* ce = new ComponentEvent(&comp, i);
return *ce;
}
}
......
......@@ -45,9 +45,9 @@ namespace nitrogen {
class ComponentEvent : public NWTEvent {
public:
ComponentEvent(Component* comp, int i);
virtual Component* getComponent() const;
virtual Component* getComponent();
virtual ComponentEvent& operator()(Component* comp, int i) const;
virtual ComponentEvent& operator()(Component& comp, int i);
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: Container.cpp
* Author: jlhawkwell
*
* Created on March 24, 2018, 10:30 AM
*/
#include "Container.h"
namespace nitrogen {
namespace nwt {
Component* Container::add(Component* comp) {
std::vector<Component*>::iterator it;
it = lst->end();
lst->insert(it, comp);
return comp;
}
Component* Container::getComponent(unsigned int n) {
if (lst->size() >= n) {
return nullptr;
}
return (*lst)[n];
}
Component* Container::getComponentAt(int x, int y) {
Component* c;
Rectangle* bounds;
Component* target = this->Component::getComponentAt(x, y);
unsigned int cnt = lst->size();
for (int a = 0; a < cnt; a++) {
c = (*lst)[a];
bounds = c->getBounds();
if (bounds->contains(x, y)) {
target = c;
if ((c = c->getComponentAt(x - bounds->getX(), y = bounds->getY()))) {
target = c;
}
}
}
return target;
}
unsigned int Container::getComponentCount() {
return lst->size();
}
LayoutManager* Container::getLayout() {
return lm;
}
void Container::setLayout(LayoutManager* layout) {
lm = layout;
}
void Container::paintAll(Graphics* g) {
}
void Container::paintComponents(Graphics* g) {
}
void Container::update(Graphics* g) {
}
void Container::validate() {
}
void Container::removeNotify() {
}
Container::Container() {
lst = new std::vector<Component*>();
}
}
}
/*
* 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: Container.h
* Author: jlhawkwell
*
* Created on March 24, 2018, 10:30 AM
*/
#ifndef CONTAINER_H
#define CONTAINER_H
#include <ntk.h>
#include <nitrogen/nwt/Component.h>
#include <nitrogen/nwt/Graphics.h>
#include <nitrogen/nwt/LayoutManager.h>
#include <vector>
namespace nitrogen {
namespace nwt {
class Container : public Component {
public:
virtual Component* add(Component* comp);
virtual Component* getComponent(unsigned int n);
virtual Component* getComponentAt(int x, int y) override;
virtual unsigned int getComponentCount();
virtual LayoutManager* getLayout();
virtual void setLayout(LayoutManager* layout);
virtual void paintAll(Graphics* g) override;
virtual void paintComponents(Graphics* g);
virtual void update(Graphics* g) override;
virtual void validate() override;
virtual void removeNotify() override;
protected:
std::vector<Component*>* lst;
LayoutManager* lm;
Container();
private:
};
}
}
#endif /* CONTAINER_H */
......@@ -46,15 +46,15 @@ namespace nitrogen {
h = height;
}
unsigned int Dimension::getHeight() const {
unsigned int Dimension::getHeight() {
return h;
}
unsigned int Dimension::getWitdh() const {
unsigned int Dimension::getWidth() {
return w;
}
Dimension* Dimension::getSize() const {
Dimension* Dimension::getSize() {
Dimension* d = new Dimension(w, h);
return d;
}
......@@ -74,7 +74,7 @@ namespace nitrogen {
h = height;
}
std::string* Dimension::toString() const {
std::string* Dimension::toString() {
std::string* out;
out->append(getTypeName(this));
......@@ -87,12 +87,12 @@ namespace nitrogen {
return out;
}
Dimension& Dimension::operator()(unsigned int width, unsigned int height) const {
Dimension& Dimension::operator()(unsigned int width, unsigned int height) {
Dimension* d = new Dimension(width, height);
return *d;
}
Dimension& Dimension::operator=(const Dimension& right) {
Dimension& Dimension::operator=(Dimension& right) {
if (*this != right) {
w = right.w;
h = right.h;
......@@ -100,7 +100,7 @@ namespace nitrogen {
return *this;
}
bool Dimension::operator==(const Dimension& right) const {
bool Dimension::operator==(Dimension& right) {
if (w != right.w) {
return false;
}
......
......@@ -39,21 +39,21 @@
namespace nitrogen {
namespace nwt {
class Dimension : public NObject {
class Dimension : public Object {
public:
Dimension();
Dimension(unsigned int width, unsigned int height);
virtual unsigned int getHeight() const;
virtual unsigned int getWitdh() const;
virtual Dimension* getSize() const;
virtual unsigned int getHeight();
virtual unsigned int getWidth();
virtual Dimension* getSize();
virtual void setSize(Dimension* size);
virtual void setSize(unsigned int width, unsigned int height);
virtual void setSize(double width, double height);
virtual std::string* toString() const;
virtual Dimension& operator()(unsigned int width, unsigned int height) const;
virtual Dimension& operator=(const Dimension& right);
virtual bool operator==(const Dimension& right) const;
virtual std::string* toString() override;
virtual Dimension& operator()(unsigned int width, unsigned int height);
virtual Dimension& operator=(Dimension& right);
virtual bool operator==(Dimension& right);
protected:
unsigned int w;
......
......@@ -36,15 +36,15 @@
namespace nitrogen {
namespace nwt {
EventObject::EventObject(NObject* object) {
EventObject::EventObject(Object* object) {
source = object;
}
NObject* EventObject::getSource() {
Object* EventObject::getSource() {
return source;
}
std::string* EventObject::toString() const {
std::string* EventObject::toString() {
std::string *out;
out->append(getTypeName(this));
......@@ -55,19 +55,19 @@ namespace nitrogen {
return out;
}
EventObject& EventObject::operator()(NObject* object) const {
EventObject* eo = new EventObject(object);
EventObject& EventObject::operator()(Object& object) {
EventObject* eo = new EventObject(&object);
return *eo;
}
EventObject& EventObject::operator=(const EventObject& right) {
EventObject& EventObject::operator=(EventObject& right) {
if (*this != right) {
source = right.source;
}
return *this;
}
bool EventObject::operator==(const EventObject& right) const {
bool EventObject::operator==(EventObject& right) {
return (source == right.source);
}
......
......@@ -39,18 +39,18 @@
namespace nitrogen {
namespace nwt {
class EventObject : public NObject {
class EventObject : public Object {
public:
EventObject(NObject* object);
virtual NObject* getSource();
EventObject(Object* object);
virtual Object* 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;
virtual std::string* toString() override;
virtual EventObject& operator()(Object& object);
virtual EventObject& operator=(EventObject& right);
virtual bool operator==(EventObject& right);
protected:
NObject* source;
Object* source;
private:
};
......
......@@ -48,19 +48,19 @@ namespace nitrogen {
style = st;
}
std::string* Font::getFontName() const {
std::string* Font::getFontName() {
return fontName;
}
int Font::getStyle() const {
int Font::getStyle() {
return style;
}
unsigned int Font::getSize() const {
unsigned int Font::getSize() {
return size;
}
std::string* Font::toString() const {
std::string* Font::toString() {
std::string* out;
out->append(getTypeName(*this));
......@@ -75,18 +75,18 @@ namespace nitrogen {
return out;
}
Font& Font::operator()(std::string* fn, int st, unsigned int si) const {
Font& Font::operator()(std::string* fn, int st, unsigned int si) {
Font *n = new Font(fn, st, si);
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) {
Font *n = new Font(fn, st, si);
return *n;
}
Font& Font::operator=(const Font& right) {
if (this != &right) {
Font& Font::operator=(Font& right) {
if (*this != right) {
*fontName = *right.fontName;
size = right.size;
style = right.style;
......@@ -94,12 +94,12 @@ namespace nitrogen {
return *this;
}
/*bool Font::operator!=(const Font& right) const {
/*bool Font::operator!=(Font& right) {
return !(*this == right);
}// */
bool Font::operator==(const Font& right) const {
if (*fontName != *right.fontName) {
bool Font::operator==(Font& right) {
if (*fontName != *(right.fontName)) {
return false;
}
if (size != right.size) {
......
......@@ -39,21 +39,21 @@
namespace nitrogen {
namespace nwt {
class Font : public NObject {
class Font : public Object {
public:
Font(std::string*, int, unsigned int);
Font(std::string&, int, unsigned int);
virtual std::string* getFontName() const;
virtual int getStyle() const;
virtual unsigned int getSize() const;
virtual std::string* getFontName();
virtual int getStyle();
virtual unsigned int getSize();
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;
virtual std::string* toString() override;
virtual nitrogen::nwt::Font& operator()(std::string*, int, unsigned int);
virtual nitrogen::nwt::Font& operator()(std::string&, int, unsigned int);
Font& operator=(nitrogen::nwt::Font& right);
//bool operator!=(nitrogen::nwt::Font& right);
bool operator==(nitrogen::nwt::Font& right);
protected:
std::string* fontName;
......
......@@ -47,23 +47,23 @@ namespace nitrogen {
font_info = XLoadQueryFont(disp, f->getFontName()->c_str());
}
unsigned int FontMetrics::getAscent() const {
unsigned int FontMetrics::getAscent() {
return font_info->max_bounds.ascent;
}
unsigned int FontMetrics::getHeight() const {
unsigned int FontMetrics::getHeight() {
return font_info->max_bounds.ascent + font_info->max_bounds.descent;
}
unsigned int FontMetrics::stringWidth(std::string* str) const {
unsigned int FontMetrics::stringWidth(std::string* str) {
return XTextWidth(font_info, str->c_str(), str->length());
}
unsigned int FontMetrics::stringWidth(std::string& str) const {
unsigned int FontMetrics::stringWidth(std::string& str) {
return stringWidth(&str);
}
std::string* FontMetrics::toString() const {
std::string* FontMetrics::toString() {
std::string *out;
out->append(getTypeName(this));
......@@ -74,23 +74,23 @@ namespace nitrogen {
return out;
}
FontMetrics& FontMetrics::operator()(nitrogen::nwt::Font* f) const {
FontMetrics *n = new FontMetrics(f);
FontMetrics& FontMetrics::operator()(nitrogen::nwt::Font& f) {
FontMetrics *n = new FontMetrics(&f);
return *n;
}
FontMetrics& FontMetrics::operator=(const FontMetrics& right) {
FontMetrics& FontMetrics::operator=(FontMetrics& right) {
if (*this != right) {
font_info = right.font_info;
}
return *this;
}
/*bool FontMetrics::operator!=(const FontMetrics& right) const {
/*bool FontMetrics::operator!=(FontMetrics& right) {
return !(*this == right);
}// */
bool FontMetrics::operator==(const FontMetrics& right) const {
bool FontMetrics::operator==(FontMetrics& right) {
return (font_info == right.font_info);
}
}
......
......@@ -44,19 +44,19 @@ namespace nitrogen {
namespace nwt {
class Font;
class FontMetrics : public NObject {
class FontMetrics : public Object {
public:
FontMetrics(nitrogen::nwt::Font* f);
virtual unsigned int getAscent() 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 getAscent();
virtual unsigned int getHeight();
virtual unsigned int stringWidth(std::string* str);
virtual unsigned int stringWidth(std::string& str);
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;
virtual std::string* toString() override;
FontMetrics& operator()(nitrogen::nwt::Font& f);
FontMetrics& operator=(FontMetrics& right);
//bool operator!=(FontMetrics& right);
bool operator==(FontMetrics& right);
private:
XFontStruct* font_info;
......
......@@ -36,44 +36,40 @@
#include <ntk.h>
#include <nitrogen/NPosition.h>
#include <nitrogen/NSize.h>
#include <nitrogen/nwt/Color.h>
#include <nitrogen/nwt/Font.h>
#include <nitrogen/nwt/FontMetrics.h>
namespace nitrogen {
namespace nwt {
class Color;
class Font;
class FontMetrics;
class Graphics : public NObject {
class Graphics : public Object {
public:
virtual void drawPoint(NPosition<int>* point) = 0;
virtual void drawLine(NPosition<int>* start, NPosition<int>* end) = 0;
virtual void drawRect(NPosition<int>* start, NSize<int>* size) = 0;
virtual void fillRect(NPosition<int>* start, NSize<int>* size) = 0;
virtual void fill3DRect(NPosition<int>* start, NSize<int>* size) = 0;
virtual void draw3DRect(NPosition<int>* start, NSize<int>* size) = 0;
virtual void drawPoint(int x, int y) = 0;
virtual void drawLine(int sx, int xy, int dx, int dy) = 0;
virtual void drawRect(int x, int y, unsigned int width, unsigned int height) = 0;
virtual void fillRect(int x, int y, unsigned int width, unsigned int height) = 0;
virtual void fill3DRect(int x, int y, unsigned int width, unsigned int height) = 0;
virtual void draw3DRect(int x, int y, unsigned int width, unsigned int height, bool = false) = 0;
virtual void drawString(std::string* str, NPosition<int>* point) = 0;
virtual void drawString(std::string& str, NPosition<int>* point) = 0;
virtual void drawString(std::string* str, int x, int y) = 0;
virtual void drawString(std::string& str, int x, int y) = 0;
virtual Color* getColor() const = 0;
virtual nitrogen::nwt::Font* getFont() const = 0;
virtual FontMetrics* getFontMetrics(nitrogen::nwt::Font* f) const = 0;
virtual FontMetrics* getFontMetrics() const = 0;
virtual void setClip(NPosition<int>* start, NSize<unsigned int> size) = 0;
virtual void setClip(int x, int y, unsigned int width, unsigned int height) = 0;
virtual void setColor(Color* c) = 0;
virtual void setFont(nitrogen::nwt::Font* f) = 0;
virtual void translate(NPosition<int>* pos) = 0;
virtual void translate(int x, int y) = 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 Graphics& operator=(Graphics& right) = 0;
//virtual bool operator!=(Graphics& right) const = 0;
virtual bool operator==(Graphics& right) const = 0;
protected:
static nitrogen::nwt::Font* ntk_font;
......
......@@ -40,11 +40,11 @@ namespace nitrogen {
time = std::time(0);
}
long InputEvent::getWhen() const {
long InputEvent::getWhen() {
return time;
}
InputEvent& InputEvent::operator=(const InputEvent& right) {
InputEvent& InputEvent::operator=(InputEvent& right) {
if (*this != right) {
consumed = right.consumed;
id = right.id;
......@@ -54,7 +54,7 @@ namespace nitrogen {
return *this;
}
bool InputEvent::operator==(const InputEvent& right) const {
bool InputEvent::operator==(InputEvent& right) {
if (time != right.time) {
return false;
}
......
......@@ -47,10 +47,10 @@ namespace nitrogen {
class InputEvent : public ComponentEvent {
public:
InputEvent(Component* comp, int i);
virtual long getWhen() const;
virtual long getWhen();
virtual InputEvent& operator=(const InputEvent& right);
virtual bool operator==(const InputEvent& right) const;
virtual InputEvent& operator=(InputEvent& right);
virtual bool operator==(InputEvent& right);
protected:
time_t time;
......
......@@ -43,23 +43,23 @@ namespace nitrogen {
r = right;
}
unsigned int Insets::getBottom() const {
unsigned int Insets::getBottom() {
return b;
}
unsigned int Insets::getLeft() const {
unsigned int Insets::getLeft() {
return l;
}
unsigned int Insets::getRight() const {
unsigned int Insets::getRight() {
return r;
}
unsigned int Insets::getTop() const {
unsigned int Insets::getTop() {
return t;
}
std::string* Insets::toString() const {
std::string* Insets::toString() {
std::string *out;
out->append(getTypeName(this));
......@@ -76,12 +76,12 @@ namespace nitrogen {
return out;
}
Insets& Insets::operator()(unsigned int top, unsigned int left, unsigned int bottom, unsigned int right) const {
Insets& Insets::operator()(unsigned int top, unsigned int left, unsigned int bottom, unsigned int right) {
Insets *i = new Insets(top, left, bottom, right);
return *i;
}
Insets& Insets::operator=(const Insets& right) {
Insets& Insets::operator=(Insets& right) {
if (*this != right) {
t = right.t;
l = right.l;
......@@ -91,11 +91,11 @@ namespace nitrogen {
return *this;
}
/*bool Insets::operator==(const Insets& right) const {
/*bool Insets::operator==(Insets& right) {
return !(*this == right);
} // */
bool Insets::operator==(const Insets& right) const {
bool Insets::operator==(Insets& right) {
if (t != right.t) {
return false;
}
......
......@@ -39,19 +39,19 @@
namespace nitrogen {
namespace nwt {
class Insets : public NObject {
class Insets : public Object {
public:
Insets(unsigned int top, unsigned int left, unsigned int bottom, unsigned int right);
virtual unsigned int getTop() const;
virtual unsigned int getLeft() const;
virtual unsigned int getBottom() const;
virtual unsigned int getRight() const;
virtual unsigned int getTop();
virtual unsigned int getLeft();
virtual unsigned int getBottom();
virtual unsigned int getRight();
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 std::string* toString() override;
virtual Insets& operator()(unsigned int top, unsigned int left, unsigned int bottom, unsigned int right);
virtual Insets& operator=(Insets& right);
//virtual bool operator!=(Insets& right);
virtual bool operator==(Insets& right);
protected:
unsigned int t;
......
/*
* 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: LayoutManager.cpp
* Author: jlhawkwell
*
* Created on March 24, 2018, 10:40 AM
*/
#include "LayoutManager.h"
namespace nitrogen {
namespace nwt {
LayoutManager::LayoutManager() {
}
}
}
/*
* 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: LayoutManager.h
* Author: jlhawkwell
*
* Created on March 24, 2018, 10:40 AM
*/
#ifndef LAYOUTMANAGER_H
#define LAYOUTMANAGER_H
#include <ntk.h>
namespace nitrogen {
namespace nwt {
class Component;
class Container;
class Dimension;
class LayoutManager : public Object {
public:
LayoutManager();
virtual void addLayoutComponent(std::string*, Component* comp) = 0;
virtual void addLayoutComponent(std::string&, Component* comp) = 0;
virtual void removeLayoutComponent(Component* comp) = 0;
virtual Dimension minimumLayoutSize(Container* cont) = 0;
virtual Dimension preferredLayoutSize(Container* cont) = 0;
virtual void layoutContainer(Container* cont) = 0;
private:
};
}
}
#endif /* LAYOUTMANAGER_H */
......@@ -41,27 +41,27 @@ namespace nitrogen {
}
int MouseEvent::getModifiers() const {
int MouseEvent::getModifiers() {
return modifiers;
}
int MouseEvent::getX() const {
int MouseEvent::getX() {
return mx;
}
int MouseEvent::getY() const {
int MouseEvent::getY() {
return my;
}
int MouseEvent::getClickCount() const {
int MouseEvent::getClickCount() {
return clickCount;
}
bool MouseEvent::isPopupTrigger() const {
bool MouseEvent::isPopupTrigger() {
return popupTrigger;
}
std::string* MouseEvent::toString() const {
std::string* MouseEvent::toString() {
std::string *out;
out->append(getTypeName(this));
......@@ -87,12 +87,12 @@ namespace nitrogen {
}
MouseEvent& MouseEvent::operator()
(Component* comp, int i, long when, int mods, int x, int y, int clicks, bool popup) const {
(Component* comp, int i, long when, int mods, int x, int y, int clicks, bool popup) {
MouseEvent* me = new MouseEvent(comp, i, when, mods, x, y, clicks, popup);
return *me;
}
bool MouseEvent::operator==(const MouseEvent& right) const {
bool MouseEvent::operator==(MouseEvent& right) {
if (modifiers != right.modifiers) {
return false;
}
......
......@@ -47,15 +47,15 @@ namespace nitrogen {
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 int getModifiers();
virtual int getX();
virtual int getY();
virtual int getClickCount();
virtual bool isPopupTrigger();
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;
virtual std::string* toString() override;
virtual MouseEvent& operator()(Component* comp, int i, long when, int mods, int x, int y, int clicks, bool popup = false);
bool operator==(MouseEvent& right);
protected:
int modifiers;
......
......@@ -37,10 +37,10 @@
#include <ntk.h>
#include <nitrogen/nwt/EventListener.h>
#include <nitrogen/nwt/MouseEvent.h>
namespace nitrogen {
namespace nwt {
class MouseEvent;
class MouseListener : public EventListener {
public:
......
......@@ -36,18 +36,18 @@
namespace nitrogen {
namespace nwt {
NWTEvent::NWTEvent(NObject* object, int i) : EventObject((NObject*) object) {
//EventObject((NObject) * object);
NWTEvent::NWTEvent(Object* object, int i) : EventObject((Object*) object) {
//EventObject((Object) * object);
//source = object;
id = i;
consumed = false;
}
int NWTEvent::getId() const {
int NWTEvent::getId() {
return id;
}
bool NWTEvent::isConsumed() const {
bool NWTEvent::isConsumed() {
return consumed;
}
......@@ -55,7 +55,7 @@ namespace nitrogen {
consumed = true;
}
std::string* NWTEvent::toString() const {
std::string* NWTEvent::toString() {
std::string *out;
out->append(getTypeName(this));
......@@ -68,12 +68,12 @@ namespace nitrogen {
return out;
}
NWTEvent& NWTEvent::operator()(NObject* object, int i) const {
NWTEvent* e = new NWTEvent(object, i);
NWTEvent& NWTEvent::operator()(Object& object, int i) {
NWTEvent* e = new NWTEvent(&object, i);
return *e;
}
NWTEvent& NWTEvent::operator=(const NWTEvent& right) {
NWTEvent& NWTEvent::operator=(NWTEvent& right) {
if (*this != right) {
source = right.source;
id = right.id;
......@@ -82,7 +82,7 @@ namespace nitrogen {
return *this;
}
bool NWTEvent::operator==(const NWTEvent& right) const {
bool NWTEvent::operator==(NWTEvent& right) {
if (source != right.source) {
return false;
}
......
......@@ -42,15 +42,15 @@ namespace nitrogen {
class NWTEvent : public EventObject {
public:
NWTEvent(NObject* object, int i);
virtual int getId() const;
virtual bool isConsumed() const;
NWTEvent(Object* object, int i);
virtual int getId();
virtual bool isConsumed();
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;
virtual std::string* toString() override;
virtual NWTEvent& operator()(Object& object, int i);
virtual NWTEvent& operator=(NWTEvent& right);
virtual bool operator==(NWTEvent& right);
protected:
int id;
......
......@@ -46,16 +46,16 @@ namespace nitrogen {
py = y;
}
Point* Point::getLocation() const {
Point* Point::getLocation() {
Point *p = new Point(px, py);
return p;
}
int Point::getX() const {
int Point::getX() {
return px;
}
int Point::getY() const {
int Point::getY() {
return py;
}
......@@ -77,7 +77,7 @@ namespace nitrogen {
py += y;
}
std::string* Point::toString() const {
std::string* Point::toString() {
std::string* out;
out->append(getTypeName(this));
......@@ -90,19 +90,19 @@ namespace nitrogen {
return out;
}
Point& Point::operator()(int x, int y) const {
Point& Point::operator()(int x, int y) {
Point* p = new Point(x, y);
return *p;
}
Point& Point::operator=(const Point& right) {
Point& Point::operator=(Point& right) {
if (*this != right) {
move(right.px, right.py);
}
return *this;
}
bool Point::operator==(const Point& right) const {
bool Point::operator==(Point& right) {
if (px != right.px) {
return false;
}
......
......@@ -39,22 +39,22 @@
namespace nitrogen {
namespace nwt {
class Point : public NObject {
class Point : public Object {
public:
Point();
Point(int x, int y);
virtual Point* getLocation() const;
virtual int getX() const;
virtual int getY() const;
virtual Point* getLocation();
virtual int getX();
virtual int getY();
virtual void move(int x, int y);
virtual void setLocation(int x, int y);
virtual void setLocation(Point* loc);
virtual void translate(int x, int y);
virtual std::string* toString() const;
virtual Point& operator()(int x, int y) const;
virtual Point& operator=(const Point& right);
virtual bool operator==(const Point& right) const;
virtual std::string* toString() override;
virtual Point& operator()(int x, int y);
virtual Point& operator=(Point& right);
virtual bool operator==(Point& right);
protected:
int px;
......
/*
* 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: Rectangle.cpp
* Author: jlhawkwell
*
* Created on March 24, 2018, 11:24 AM
*/
#include "Rectangle.h"
namespace nitrogen {
namespace nwt {
Rectangle::Rectangle(unsigned int width, unsigned int height) {
rx = 0;
ry = 0;
rw = width;
rh = height;
}
Rectangle::Rectangle(int x, int y, unsigned int width, unsigned int height) {
rx = x;
ry = y;
rw = width;
rh = height;
}
bool Rectangle::contains(int x, int y) {
if (rx <= x && x <= rw) {
if (ry <= y & y <= rh) {
return true;
}
}
return false;
}
int Rectangle::getX() {
return rx;
}
int Rectangle::getY() {
return ry;
}
int Rectangle::getWidth() {
return rw;
}
int Rectangle::getHeight() {
return rh;
}
std::string* Rectangle::toString() {
std::string* out;
out->append(getTypeName(this));
out->append("(");
out->append(std::to_string(rx));
out->append(",");
out->append(std::to_string(ry));
out->append(",");
out->append(std::to_string(rw));
out->append(",");
out->append(std::to_string(rh));
out->append(")");
return out;
}
Rectangle& Rectangle::operator()(unsigned int width, unsigned int height) {
Rectangle* r = new Rectangle(width, height);
return *r;
}
Rectangle& Rectangle::operator()(int x, int y, unsigned int width, unsigned int height) {
Rectangle* r = new Rectangle(x, y, width, height);
return *r;
}
Rectangle& Rectangle::operator=(Rectangle& right) {
if (*this != right) {
rx = right.rx;
ry = right.ry;
rw = right.rw;
rh = right.rh;
}
return *this;
}
bool Rectangle::operator==(Rectangle& right) {
if (rx != right.rx) {
return false;
}
else if (ry != right.ry) {
return false;
}
else if (rw != right.rw) {
return false;
}
else if (rh != right.rh) {
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: Rectangle.h
* Author: jlhawkwell
*
* Created on March 24, 2018, 11:24 AM
*/
#ifndef RECTANGLE_H
#define RECTANGLE_H
#include <ntk.h>
namespace nitrogen {
namespace nwt {
class Rectangle : public Object {
public:
Rectangle(unsigned int width, unsigned int height);
Rectangle(int x, int y, unsigned int width, unsigned int height);
bool contains(int x, int y);
int getX();
int getY();
int getWidth();
int getHeight();
virtual std::string* toString() override;
Rectangle& operator()(unsigned int width, unsigned int height);
Rectangle& operator()(int x, int y, unsigned int width, unsigned int height);
Rectangle& operator=(Rectangle& right);
bool operator==(Rectangle& right);
protected:
unsigned int rw;
unsigned int rh;
int rx;
int ry;
private:
};
}
}
#endif /* RECTANGLE_H */
......@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
/*
* File: ntk.h
* Author: jlhawkwell
*
......@@ -54,8 +54,8 @@
#define NTK_VERSION_TWEAK 0
#define NTK_VERSION "1.0.0.0"
#ifndef NOBJECT_H
#include <nitrogen/NObject.h>
#ifndef OBJECT_H
#include <nitrogen/Object.h>
#endif
namespace nitrogen {
......
......@@ -24,7 +24,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
/*
* File: ntk.h
* Author: jlhawkwell
*
......@@ -54,8 +54,8 @@
#define NTK_VERSION_TWEAK @Nitrogen_VERSION_TWEAK@
#define NTK_VERSION "@Nitrogen_VERSION_MAJOR@.@Nitrogen_VERSION_MINOR@.@Nitrogen_VERSION_PATCH@.@Nitrogen_VERSION_TWEAK@"
#ifndef NOBJECT_H
#include <nitrogen/NObject.h>
#ifndef OBJECT_H
#include <nitrogen/Object.h>
#endif
namespace nitrogen {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!