Commit d408b565 by Jessica Hawkwell

added Insets and Border for #1, restructured libntk, arranged includes

1 parent 6908dbda
...@@ -53,6 +53,7 @@ build ...@@ -53,6 +53,7 @@ build
### KDevelop4 ### ### KDevelop4 ###
*.kdev4 *.kdev4
.kdev4/ .kdev4/
*.kateproject
### NetBeans ### ### NetBeans ###
nbproject/ nbproject/
......
...@@ -9,7 +9,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY build/bin) ...@@ -9,7 +9,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY build/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY build/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY build/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY build/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY build/lib)
include_directories("/usr/local/include") if (EXISTS /usr/local/include)
include_directories(/usr/local/include)
endif()
add_subdirectory(src/libnde) add_subdirectory(src/libnde)
add_subdirectory(src/libntk) add_subdirectory(src/libntk)
......
...@@ -23,18 +23,19 @@ For example: ...@@ -23,18 +23,19 @@ For example:
None yet. :crying_cat_face: None yet. :crying_cat_face:
--- ---
## Requirements ## Runtime Requirements
+ [FreeBSD](http://freebsd.org/) `>= 10.1` (tested using FreeBSD 11) + [FreeBSD](http://freebsd.org/) `>= 10.1` (tested using FreeBSD `11.1-RELEASE`)
+ [`x11/libX11`](https://www.freshports.org/x11/libX11/) + [`x11/libX11`](https://www.freshports.org/x11/libX11/)
+ [`x11/xproto`](https://www.freshports.org/x11/xproto/) + [`x11/xproto`](https://www.freshports.org/x11/xproto/)
+ [`devel/cmake`](https://www.freshports.org/devel/cmake/)
+ [`devel/cmake-modules`](https://www.freshports.org/devel/cmake-modules/) (if this port is not available, then it has been merged with [`devel/cmake`](https://www.freshports.org/devel/cmake/))
+ [`devel/boehm-gc`](https://www.freshports.org/devel/boehm-gc/) + [`devel/boehm-gc`](https://www.freshports.org/devel/boehm-gc/)
+ [`devel/boehm-gc-threaded`](https://www.freshports.org/devel/boehm-gc-threaded/) + [`devel/boehm-gc-threaded`](https://www.freshports.org/devel/boehm-gc-threaded/)
--- ---
## Misc Tooling ## Tooling
+ [`devel/git`](https://www.freshports.org/devel/git/) **or** [`devel/git-gui`](https://www.freshports.org/devel/git-gui/) + [`devel/git`](https://www.freshports.org/devel/git/) **or** [`devel/git-gui`](https://www.freshports.org/devel/git-gui/) (these ports are mutually exclusive, you can only have one of them installed)
+ [`devel/cmake`](https://www.freshports.org/devel/cmake/)
+ [`devel/cmake-modules`](https://www.freshports.org/devel/cmake-modules/) (if this port is not available, then it has been merged with [`devel/cmake`](https://www.freshports.org/devel/cmake/))
+ CLang from the base system (`4.0.0`) is all that's required to build. No need for extra compilers from Ports or `pkg`.
--- ---
## Building the NDE ## Building the NDE
...@@ -60,3 +61,7 @@ $ make ...@@ -60,3 +61,7 @@ $ make
```console ```console
$ ./test_Nitrogen.sh $ ./test_Nitrogen.sh
``` ```
---
## Notes
**I do not recommend using NitroWin as a primary window manager. It is still in very early development.**
#include "NitroWin.h" #include "NitroWin.h"
#include <Color.h> #include <nitrogen/nwt/Color.h>
#include <NObject.h> #include <nitrogen/NObject.h>
#include "NWManager.h" #include "NWManager.h"
#include <iostream> #include <iostream>
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
int main ( int argc, char** argv ) int main ( int argc, char** argv )
{ {
std::cout << NITROWIN_NAME << " v" << NITROWIN_VERSION << std::endl; std::cout << NITROWIN_NAME << " v" << NITROWIN_VERSION << std::endl;
nitrogen::Color no = nitrogen::Color(255, 255, 255); nitrogen::nwt::Color no = nitrogen::nwt::Color(255, 255, 255);
std::cout << "Color: "; std::cout << "Color: ";
std::cout << no std::cout << no
<< std::endl; << std::endl;
......
...@@ -4,19 +4,22 @@ configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h) ...@@ -4,19 +4,22 @@ configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h)
find_package(X11) find_package(X11)
find_library(BoehmGC gc-threaded) find_library(BoehmGC gc-threaded)
#include_directories("/usr/local/include")
add_library(${PROJECT_NAME} SHARED ntkMain.cpp add_library(${PROJECT_NAME} SHARED ntkMain.cpp
NObject.cpp nitrogen/NObject.cpp
Color.cpp nitrogen/nwt/Color.cpp
Font.cpp nitrogen/nwt/Font.cpp
FontMetrics.cpp nitrogen/nwt/FontMetrics.cpp
nitrogen/nwt/Graphics.cpp
nitrogen/nwt/Insets.cpp
# nitrogen/nwt/Border.cpp
# nitrogen/nwt/Component.cpp
) )
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/${PROJECT_NAME}) install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/${PROJECT_NAME})
file(GLOB HEADERS "*.h") file(GLOB HEADERS "*.h")
install(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME}) install(FILES ${HEADERS} DESTINATION include/nitrogen/)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC nde ${BoehmGC}) target_link_libraries(${PROJECT_NAME} LINK_PUBLIC nde ${BoehmGC})
target_include_directories (ntk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories (ntk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
/*
* 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: Border.cpp
* Author: jlhawkwell
*
* Created on March 23, 2018, 1:44 PM
*/
#include "Border.h"
namespace nitrogen {
namespace nwt {
Border::Border() {
}
Border::~Border() {
}
}
}
/*
* 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: Border.h
* Author: jlhawkwell
*
* Created on March 23, 2018, 1:44 PM
*/
#ifndef BORDER_H
#define BORDER_H
#include <ntk.h>
#include <nitrogen/nwt/Component.h>
#include <nitrogen/nwt/Graphics.h>
#include <nitrogen/nwt/Insets.h>
namespace nitrogen {
namespace nwt {
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();
protected:
Border();
private:
};
}
}
#endif /* BORDER_H */
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "Color.h" #include "Color.h"
namespace nitrogen { namespace nitrogen {
namespace nwt {
Color::Color(unsigned int c) { Color::Color(unsigned int c) {
alpha = 255; alpha = 255;
red = ((c & MASK_RED) >> 16); red = ((c & MASK_RED) >> 16);
...@@ -150,4 +150,5 @@ namespace nitrogen { ...@@ -150,4 +150,5 @@ namespace nitrogen {
Color* BRIGHT_MAGENTA = new Color(255, 0, 255); Color* BRIGHT_MAGENTA = new Color(255, 0, 255);
Color* BRIGHT_CYAN = new Color(0, 255, 255); Color* BRIGHT_CYAN = new Color(0, 255, 255);
Color* BRIGHT_WHITE = new Color(255, 255, 255); Color* BRIGHT_WHITE = new Color(255, 255, 255);
}
} }
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <ntk.h> #include <ntk.h>
namespace nitrogen { namespace nitrogen {
namespace nwt {
class Color : public NObject { class Color : public NObject {
public: public:
static const unsigned int MASK_ALPHA = 0xff000000; static const unsigned int MASK_ALPHA = 0xff000000;
...@@ -88,6 +89,7 @@ namespace nitrogen { ...@@ -88,6 +89,7 @@ namespace nitrogen {
unsigned char blue; unsigned char blue;
unsigned char alpha; unsigned char alpha;
}; };
}
} }
#endif /* COLOR_H */ #endif /* COLOR_H */
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "Component.h" #include "Component.h"
namespace nitrogen { namespace nitrogen {
namespace nwt {
Component::Component() { Component::Component() {
background = Color::BRIGHT_BLACK; background = Color::BRIGHT_BLACK;
//border //border
...@@ -157,4 +157,5 @@ namespace nitrogen { ...@@ -157,4 +157,5 @@ namespace nitrogen {
Component::~Component() { Component::~Component() {
} }
}
} }
...@@ -35,13 +35,20 @@ ...@@ -35,13 +35,20 @@
#define COMPONENT_H #define COMPONENT_H
#include <ntk.h> #include <ntk.h>
#include <Color.h>
#include <NSize.h>
#include <NPosition.h> #include <NPosition.h>
#include <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 <list> #include <list>
namespace nitrogen { namespace nitrogen {
namespace nwt {
class Component : public NObject { class Component : public NObject {
public: public:
virtual ~Component(); virtual ~Component();
...@@ -51,14 +58,14 @@ namespace nitrogen { ...@@ -51,14 +58,14 @@ namespace nitrogen {
virtual NPosition<int>* getLocation(); virtual NPosition<int>* getLocation();
virtual Component* getParent(); virtual Component* getParent();
virtual Graphics* getGraphics(); virtual Graphics* getGraphics();
virtual nitrogen::Font* getFont(); virtual nitrogen::nwt::Font* getFont();
virtual FontMetrics* getFontMetrics(nitrogen::Font *f); virtual FontMetrics* getFontMetrics(nitrogen::nwt::Font *f);
virtual Color* getForeground(); virtual Color* getForeground();
virtual Color* getBackground(); virtual Color* getBackground();
virtual NSize<unsigned int>* getPreferredSize(); virtual NSize<unsigned int>* getPreferredSize();
virtual void setBorder(Border* b); virtual void setBorder(Border* b);
virtual void setFont(nitrogen::Font *f); virtual void setFont(nitrogen::nwt::Font *f);
virtual void setForeground(Color* c); virtual void setForeground(Color* c);
virtual void setBackground(Color* c); virtual void setBackground(Color* c);
virtual void setSize(NSize<unsigned int> *s); virtual void setSize(NSize<unsigned int> *s);
...@@ -78,7 +85,7 @@ namespace nitrogen { ...@@ -78,7 +85,7 @@ namespace nitrogen {
Graphics *graphics; Graphics *graphics;
NPosition<int> *location; NPosition<int> *location;
Border *border; Border *border;
nitrogen::Font *font; nitrogen::nwt::Font *font;
Color *foreground; Color *foreground;
Color *background; Color *background;
NSize<unsigned int> *size; NSize<unsigned int> *size;
...@@ -92,6 +99,7 @@ namespace nitrogen { ...@@ -92,6 +99,7 @@ namespace nitrogen {
private: private:
}; };
}
} }
#endif /* COMPONENT_H */ #endif /* COMPONENT_H */
...@@ -33,10 +33,8 @@ ...@@ -33,10 +33,8 @@
#include "Font.h" #include "Font.h"
#include <ntk.h>
#include <string>
namespace nitrogen { namespace nitrogen {
namespace nwt {
Font::Font(std::string* fn, int st, unsigned int si) { Font::Font(std::string* fn, int st, unsigned int si) {
fontName = fn; fontName = fn;
size = si; size = si;
...@@ -101,4 +99,5 @@ namespace nitrogen { ...@@ -101,4 +99,5 @@ namespace nitrogen {
if (style != right.style) { return false; } if (style != right.style) { return false; }
return true; return true;
} }
}
} }
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <ntk.h> #include <ntk.h>
namespace nitrogen { namespace nitrogen {
namespace nwt {
class Font : public NObject { class Font : public NObject {
public: public:
Font(std::string*, int, unsigned int); Font(std::string*, int, unsigned int);
...@@ -48,11 +49,11 @@ namespace nitrogen { ...@@ -48,11 +49,11 @@ namespace nitrogen {
virtual ~Font(); virtual ~Font();
virtual std::string* toString() const; virtual std::string* toString() const;
virtual nitrogen::Font& operator()(std::string*, int, unsigned int) const; virtual nitrogen::nwt::Font& operator()(std::string*, int, unsigned int) const;
virtual nitrogen::Font& operator()(std::string&, int, unsigned int) const; virtual nitrogen::nwt::Font& operator()(std::string&, int, unsigned int) const;
Font& operator=(const nitrogen::Font& right); Font& operator=(const nitrogen::nwt::Font& right);
bool operator!=(const nitrogen::Font& right) const; bool operator!=(const nitrogen::nwt::Font& right) const;
bool operator==(const nitrogen::Font& right) const; bool operator==(const nitrogen::nwt::Font& right) const;
protected: protected:
std::string* fontName; std::string* fontName;
...@@ -61,6 +62,7 @@ namespace nitrogen { ...@@ -61,6 +62,7 @@ namespace nitrogen {
private: private:
}; };
}
} }
#endif /* FONT_H */ #endif /* FONT_H */
...@@ -34,15 +34,15 @@ ...@@ -34,15 +34,15 @@
#include "FontMetrics.h" #include "FontMetrics.h"
#include <ntk.h> #include <ntk.h>
#include <string>
#include "Font.h" #include "nitrogen/nwt/Font.h"
#include <string>
#include "X11/Xlib.h" #include "X11/Xlib.h"
#include "ntk.h"
namespace nitrogen { namespace nitrogen {
namespace nwt {
FontMetrics::FontMetrics(Font* f) { FontMetrics::FontMetrics(nitrogen::nwt::Font* f) {
font_info = XLoadQueryFont(disp, f->getFontName()->c_str()); font_info = XLoadQueryFont(disp, f->getFontName()->c_str());
} }
...@@ -76,7 +76,7 @@ namespace nitrogen { ...@@ -76,7 +76,7 @@ namespace nitrogen {
return out; return out;
} }
FontMetrics& FontMetrics::operator()(Font* f) const { FontMetrics& FontMetrics::operator()(nitrogen::nwt::Font* f) const {
FontMetrics *n = new FontMetrics(f); FontMetrics *n = new FontMetrics(f);
return *n; return *n;
} }
...@@ -95,4 +95,5 @@ namespace nitrogen { ...@@ -95,4 +95,5 @@ namespace nitrogen {
bool FontMetrics::operator==(const FontMetrics& right) const { bool FontMetrics::operator==(const FontMetrics& right) const {
return (font_info == right.font_info); return (font_info == right.font_info);
} }
}
} }
...@@ -35,15 +35,17 @@ ...@@ -35,15 +35,17 @@
#define FONTMETRICS_H #define FONTMETRICS_H
#include <ntk.h> #include <ntk.h>
#include <Font.h>
#include <nitrogen/nwt/Font.h>
#include <X11/X.h> #include <X11/X.h>
namespace nitrogen { namespace nitrogen {
class Font; namespace nwt {
class Font;
class FontMetrics : public NObject { class FontMetrics : public NObject {
public: public:
FontMetrics(Font* f); FontMetrics(nitrogen::nwt::Font* f);
virtual unsigned int getAscent() const; virtual unsigned int getAscent() const;
virtual unsigned int getHeight() const; virtual unsigned int getHeight() const;
virtual unsigned int stringWidth(std::string* str) const; virtual unsigned int stringWidth(std::string* str) const;
...@@ -51,7 +53,7 @@ class Font; ...@@ -51,7 +53,7 @@ class Font;
virtual ~FontMetrics(); virtual ~FontMetrics();
virtual std::string* toString() const; virtual std::string* toString() const;
FontMetrics& operator()(Font* f) const; FontMetrics& operator()(nitrogen::nwt::Font* f) const;
FontMetrics& operator=(const FontMetrics& right); FontMetrics& operator=(const FontMetrics& right);
bool operator!=(const FontMetrics& right) const; bool operator!=(const FontMetrics& right) const;
bool operator==(const FontMetrics& right) const; bool operator==(const FontMetrics& right) const;
...@@ -59,6 +61,7 @@ class Font; ...@@ -59,6 +61,7 @@ class Font;
private: private:
XFontStruct* font_info; XFontStruct* font_info;
}; };
}
} }
#endif /* FONTMETRICS_H */ #endif /* FONTMETRICS_H */
......
...@@ -34,5 +34,6 @@ ...@@ -34,5 +34,6 @@
#include "Graphics.h" #include "Graphics.h"
namespace nitrogen { namespace nitrogen {
namespace nwt {
}
} }
...@@ -35,13 +35,16 @@ ...@@ -35,13 +35,16 @@
#define GRAPHICS_H #define GRAPHICS_H
#include <ntk.h> #include <ntk.h>
#include <Font.h>
#include <FontMetrics.h>
#include <Color.h>
#include <NPosition.h> #include <NPosition.h>
#include <NSize.h> #include <NSize.h>
#include <nitrogen/nwt/Color.h>
#include <nitrogen/nwt/Font.h>
#include <nitrogen/nwt/FontMetrics.h>
namespace nitrogen { namespace nitrogen {
namespace nwt {
class Graphics : public NObject { class Graphics : public NObject {
public: public:
virtual void drawPoint(NPosition<int>* point) = 0; virtual void drawPoint(NPosition<int>* point) = 0;
...@@ -55,13 +58,13 @@ namespace nitrogen { ...@@ -55,13 +58,13 @@ namespace nitrogen {
virtual void drawString(std::string& str, NPosition<int>* point) = 0; virtual void drawString(std::string& str, NPosition<int>* point) = 0;
virtual Color* getColor() const = 0; virtual Color* getColor() const = 0;
virtual nitrogen::Font* getFont() const = 0; virtual nitrogen::nwt::Font* getFont() const = 0;
virtual FontMetrics* getFontMetrics(nitrogen::Font* f) const = 0; virtual FontMetrics* getFontMetrics(nitrogen::nwt::Font* f) const = 0;
virtual FontMetrics* getFontMetrics() const = 0; virtual FontMetrics* getFontMetrics() const = 0;
virtual void setClip(NPosition<int>* start, NSize<unsigned int> size) = 0; virtual void setClip(NPosition<int>* start, NSize<unsigned int> size) = 0;
virtual void setColor(Color* c) = 0; virtual void setColor(Color* c) = 0;
virtual void setFont(nitrogen::Font* f) = 0; virtual void setFont(nitrogen::nwt::Font* f) = 0;
virtual void translate(NPosition<int>* pos) = 0; virtual void translate(NPosition<int>* pos) = 0;
...@@ -74,10 +77,11 @@ namespace nitrogen { ...@@ -74,10 +77,11 @@ namespace nitrogen {
virtual bool operator==(const Graphics& right) const = 0; virtual bool operator==(const Graphics& right) const = 0;
protected: protected:
static nitrogen::Font* ntk_font; static nitrogen::nwt::Font* ntk_font;
private: private:
}; };
}
} }
#endif /* GRAPHICS_H */ #endif /* GRAPHICS_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: Insets.cpp
* Author: jlhawkwell
*
* Created on March 23, 2018, 1:53 PM
*/
#include "Insets.h"
namespace nitrogen {
namespace nwt {
Insets::Insets(unsigned int top, unsigned int left, unsigned int bottom, unsigned int right) {
t = top;
l = left;
b = bottom;
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; }
Insets::~Insets() {
}
std::string* Insets::toString() const {
std::string *out;
out->append(getTypeName(this));
out->append("(");
out->append(std::to_string(t));
out->append(",");
out->append(std::to_string(l));
out->append(",");
out->append(std::to_string(b));
out->append(",");
out->append(std::to_string(r));
out->append(")");
return out;
}
Insets& Insets::operator()(unsigned int top, unsigned int left, unsigned int bottom, unsigned int right) const {
Insets *i = new Insets(top, left, bottom, right);
return *i;
}
Insets& Insets::operator=(const Insets& right) {
if (*this != right) {
t = right.t;
l = right.l;
b = right.b;
r = right.r;
}
return *this;
}
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; }
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: Insets.h
* Author: jlhawkwell
*
* Created on March 23, 2018, 1:53 PM
*/
#ifndef INSETS_H
#define INSETS_H
#include <ntk.h>
namespace nitrogen {
namespace nwt {
class Insets : public NObject {
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 ~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;
protected:
unsigned int t;
unsigned int l;
unsigned int b;
unsigned int r;
private:
};
}
}
#endif /* INSETS_H */
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
#define NTK_VERSION "1.0.0.0" #define NTK_VERSION "1.0.0.0"
#ifndef NOBJECT_H #ifndef NOBJECT_H
#include <NObject.h> #include <nitrogen/NObject.h>
#endif #endif
namespace nitrogen { namespace nitrogen {
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
#define NTK_VERSION "@Nitrogen_VERSION_MAJOR@.@Nitrogen_VERSION_MINOR@.@Nitrogen_VERSION_PATCH@.@Nitrogen_VERSION_TWEAK@" #define NTK_VERSION "@Nitrogen_VERSION_MAJOR@.@Nitrogen_VERSION_MINOR@.@Nitrogen_VERSION_PATCH@.@Nitrogen_VERSION_TWEAK@"
#ifndef NOBJECT_H #ifndef NOBJECT_H
#include <NObject.h> #include <nitrogen/NObject.h>
#endif #endif
namespace nitrogen { namespace nitrogen {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!