Commit 2f1da0a6 by Jessica Hawkwell

Finished some starter points for NTK

1 parent 9c5b42f3
...@@ -5,9 +5,9 @@ set(CMAKE_CXX_STANDARD 14) ...@@ -5,9 +5,9 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD 11)
set(CMAKE_BUILD_TYPE Debug) set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ./build/bin) 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") include_directories("/usr/local/include")
......
...@@ -2,9 +2,14 @@ cmake_minimum_required (VERSION 3.10) ...@@ -2,9 +2,14 @@ cmake_minimum_required (VERSION 3.10)
project (ntk) project (ntk)
configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h) configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h)
find_package(X11)
#include_directories("/usr/local/include") #include_directories("/usr/local/include")
add_library(${PROJECT_NAME} SHARED ntkMain.cpp NObject.cpp Color.cpp) add_library(${PROJECT_NAME} SHARED ntkMain.cpp
NObject.cpp
Color.cpp
Font.cpp
)
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/${PROJECT_NAME}) install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/${PROJECT_NAME})
......
...@@ -99,8 +99,13 @@ namespace nitrogen { ...@@ -99,8 +99,13 @@ namespace nitrogen {
} }
Color& Color::operator=(const Color& right) { Color& Color::operator=(const Color& right) {
Color *nc = new Color(right.getARGB()); if (this != &right) {
return *nc; alpha = right.getAlpha();
red = right.getRed();
green = right.getGreen();
blue = right.getBlue();
}
return *this;
} }
bool Color::operator!=(const Color& right) const { bool Color::operator!=(const Color& right) const {
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#ifndef COLOR_H #ifndef COLOR_H
#define COLOR_H #define COLOR_H
#include <ntk.h> #include <ntk.h>
#include <NObject.h>
namespace nitrogen { namespace nitrogen {
class Color : public NObject { class Color : public NObject {
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#define COMPONENT_H #define COMPONENT_H
#include <list> #include <list>
#include <ntk.h> #include <ntk.h>
#include <NObject.h>
#include <Color.h> #include <Color.h>
#include <NSize.h> #include <NSize.h>
#include <NPosition.h> #include <NPosition.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: Font.cpp
* Author: jlhawkwell
*
* Created on March 16, 2018, 11:02 PM
*/
#include "Font.h"
namespace nitrogen {
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; }
unsigned int Font::getSize() const { return size; }
Font::~Font() {
delete fontName;
}
Font& Font::operator()(std::string* fn, int st, unsigned int si) const {
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;
}
Font& Font::operator=(const Font& right) {
if (this != &right) {
*fontName = *right.fontName;
size = right.size;
style = right.style;
}
return *this;
}
bool Font::operator!=(const Font& right) const {
bool result = !(*this == right);
return result;
}
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; }
return true;
}
std::ostream& operator<<(std::ostream& os, const Font& obj) {
// Write obj to stream
std::string out;
out.append(getTypeName(obj));
out.append("(");
out.append(obj.fontName->data());
out.append(",");
out.append(std::to_string(obj.style));
out.append(",");
out.append(std::to_string(obj.size));
out.append(")");
os << out;
return os;
}
}
/*
* 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: Font.h
* Author: jlhawkwell
*
* Created on March 16, 2018, 11:02 PM
*/
#ifndef FONT_H
#define FONT_H
#include <ntk.h>
#include <ostream>
namespace nitrogen {
class Font : public NObject {
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 ~Font();
virtual Font& operator()(std::string*, int, unsigned int) const;
virtual Font& operator()(std::string&, int, unsigned int) const;
Font& operator=(const Font& right);
bool operator!=(const Font& right) const;
bool operator==(const Font& right) const;
friend std::ostream& operator<<(std::ostream& os, const Font& obj);
protected:
std::string* fontName;
int style;
unsigned int size;
private:
};
}
#endif /* FONT_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: FontMetrics.cpp
* Author: jlhawkwell
*
* Created on March 16, 2018, 11:46 PM
*/
#include "FontMetrics.h"
namespace nitrogen {
FontMetrics::FontMetrics(Font* f) {
}
unsigned int FontMetrics::getAscent() {
}
unsigned int FontMetrics::getHeight() {
}
unsigned int FontMetrics::stringWidth(std::string* str) {
}
unsigned int FontMetrics::stringWidth(std::string& str) {
return stringWidth(&str);
}
FontMetrics::~FontMetrics() {
}
}
/*
* 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: FontMetrics.h
* Author: jlhawkwell
*
* Created on March 16, 2018, 11:46 PM
*/
#ifndef FONTMETRICS_H
#define FONTMETRICS_H
#include <ntk.h>
#include <Font.h>
#include <string>
#include <X11/X.h>
namespace nitrogen {
class FontMetrics : public NObject {
public:
FontMetrics(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 ~FontMetrics();
FontMetrics& operator()(Font* f) const;
FontMetrics& operator=(const FontMetrics& right);
bool operator!=(const FontMetrics& right) const;
bool operator==(const FontMetrics& right) const;
private:
XFontStruct* font_info;
};
}
#endif /* FONTMETRICS_H */
...@@ -33,12 +33,10 @@ ...@@ -33,12 +33,10 @@
#include "NComponent.h" #include "NComponent.h"
NComponent::NComponent() { namespace nitrogen {
} NComponent::NComponent() {
}
NComponent::NComponent(const NComponent& orig) {
}
NComponent::~NComponent() { NComponent::~NComponent() {
}
} }
...@@ -41,7 +41,6 @@ namespace nitrogen { ...@@ -41,7 +41,6 @@ namespace nitrogen {
class NComponent { class NComponent {
public: public:
NComponent(); NComponent();
NComponent(const NComponent& orig);
virtual ~NComponent(); virtual ~NComponent();
private: private:
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#ifndef NTK_H #ifndef NTK_H
#define NTK_H #define NTK_H
#include <nde.h> #include <nde.h>
#include <X11/Xlib.h>
#define NTK_NAME "ntk" #define NTK_NAME "ntk"
#define NTK_VERSION_MAJOR 1 #define NTK_VERSION_MAJOR 1
...@@ -42,5 +43,13 @@ ...@@ -42,5 +43,13 @@
#define NTK_VERSION_TWEAK 0 #define NTK_VERSION_TWEAK 0
#define NTK_VERSION "1.0.0.0" #define NTK_VERSION "1.0.0.0"
#ifndef NOBJECT_H
#include <NObject.h>
#endif
namespace nitrogen {
static Display *disp;
void init(Display *d);
}
#endif /* NTK_H */ #endif /* NTK_H */
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#ifndef NTK_H #ifndef NTK_H
#define NTK_H #define NTK_H
#include <nde.h> #include <nde.h>
#include <X11/Xlib.h>
#define NTK_NAME "@PROJECT_NAME@" #define NTK_NAME "@PROJECT_NAME@"
#define NTK_VERSION_MAJOR @Nitrogen_VERSION_MAJOR@ #define NTK_VERSION_MAJOR @Nitrogen_VERSION_MAJOR@
...@@ -42,5 +43,13 @@ ...@@ -42,5 +43,13 @@
#define NTK_VERSION_TWEAK @Nitrogen_VERSION_TWEAK@ #define NTK_VERSION_TWEAK @Nitrogen_VERSION_TWEAK@
#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
#include <NObject.h>
#endif
namespace nitrogen {
static Display *disp;
void init(Display *d);
}
#endif /* NTK_H */ #endif /* NTK_H */
...@@ -24,3 +24,9 @@ ...@@ -24,3 +24,9 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <ntk.h> #include <ntk.h>
namespace nitrogen {
void init(Display *d) {
disp = d;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!