using stPosition = struct _stPosition;
using stRect = struct _stRect;
+using stGeometry = struct _stGeometry;
struct _stPosition
{
uint32_t h;
};
+struct _stGeometry
+{
+ int x;
+ int y;
+ unsigned int w;
+ unsigned int h;
+};
+
} // namespace display_server
#endif //__DS_STRUCT_H__
namespace display_server
{
+DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr)
+ : DSObjectPrivate(p_ptr),
+ __p_ptr(p_ptr),
+ __x(0),
+ __y(0),
+ __w(1),
+ __h(1),
+ __created(false),
+ __hasFocus(false)
+{
+}
+
+DSWindowPrivate::~DSWindowPrivate()
+{
+}
+
+bool DSWindowPrivate::create(DSWindow *pParent)
+{
+ // get screen position (x, y)
+
+ // get screen width (w, h)
+
+ __created = __create(__x, __y, __w, __h, pParent);
+ return __created;
+}
+
+bool DSWindowPrivate::create(int x, int y, unsigned int w, unsigned int h, DSWindow *pParent)
+{
+ __created = __create(x, y, w, h, pParent);
+ return __created;
+}
+
+void DSWindowPrivate::destroy(void)
+{
+}
+
+bool DSWindowPrivate::show(void)
+{
+ return true;
+}
+
+bool DSWindowPrivate::hide(bool autoFocus)
+{
+ return true;
+}
+
+int DSWindowPrivate::showState(void)
+{
+ return 0;
+}
+
+bool DSWindowPrivate::setLayer(int layer)
+{
+ return true;
+}
+
+bool DSWindowPrivate::raise(void)
+{
+ return true;
+}
+
+bool DSWindowPrivate::lower(void)
+{
+ return true;
+}
+
+bool DSWindowPrivate::setFocus(void)
+{
+ return true;
+}
+
+bool DSWindowPrivate::__create(int x, int y, unsigned int w, unsigned int h, DSWindow *pParent)
+{
+ DS_GET_PUB(DSWindow);
+
+ __x = x;
+ __y = y;
+ __w = w;
+ __h = h;
+ pub->__parentWindow = pParent;
+
+ // Do something
+
+ return true;
+}
+
+bool DSWindowPrivate::isCreated()
+{
+ return __created;
+}
+
DSWindow::DSWindow()
- : DS_INIT_PRIVATE_PTR(DSWindow)
-{}
+ : DS_INIT_PRIVATE_PTR(DSWindow),
+ __parentWindow(nullptr)
+{
+}
+
+DSWindow::DSWindow(DSWindow *pParent)
+ : DS_INIT_PRIVATE_PTR(DSWindow),
+ __parentWindow(pParent)
+{
+ create(pParent);
+}
+
+DSWindow::DSWindow(DSWindow *pParent, int x, int y, unsigned int w, unsigned h)
+ : DS_INIT_PRIVATE_PTR(DSWindow),
+ __parentWindow(pParent)
+{
+ create(x, y, w, h, pParent);
+}
DSWindow::~DSWindow()
-{}
+{
+
+}
bool DSWindow::create(DSWindow *pParent)
{
DS_GET_PRIV(DSWindow);
- if (priv->create(this, pParent) == false)
+ if (!priv->isCreated())
{
- return false;
+ return priv->create(pParent);
}
return true;
{
DS_GET_PRIV(DSWindow);
- if (priv->create(x, y, w, h, this, pParent) == false)
+ if (!priv->isCreated())
{
- return false;
+ return priv->create(x, y, w, h, pParent);
}
return true;
return priv->setFocus();
}
+bool DSWindow::hasFocus(void)
+{
+ DS_GET_PRIV(DSWindow);
+
+ return priv->__hasFocus;
+}
+
+DSWindow *DSWindow::getParent()
+{
+ return __parentWindow;
+}
+
+void DSWindow::setParent(DSWindow *pParent)
+{
+ DSLOG_INF("DSWindow", "Parent window has been changed. (%p -> %p)", __parentWindow, pParent);
+ __parentWindow = pParent;
+}
+
+stGeometry DSWindow::getGeometry()
+{
+ DS_GET_PRIV(DSWindow);
+
+ stGeometry geom;
+ geom.x = priv->__x;
+ geom.y = priv->__y;
+ geom.w = priv->__w;
+ geom.h = priv->__h;
+
+ return geom;
+}
} // namespace display_server
\ No newline at end of file
#define _DS_WINDOW_H_
#include "DSCore.h"
+#include "DSStruct.h"
#include "DSObject.h"
namespace display_server
public:
explicit DSWindow();
+ DSWindow(DSWindow *pParent);
+ DSWindow(DSWindow *pParent, int x, int y, unsigned int w, unsigned h);
virtual ~DSWindow();
bool create(DSWindow *pParent);
bool lower(void);
bool setFocus(void);
+ bool hasFocus(void);
+
+ DSWindow *getParent();
+ void setParent(DSWindow *pParent);
+
+ stGeometry getGeometry();
protected:
//virtual bool _onFocus(void);
//virtual bool _onShowStateChange(void);
+
+private:
+ DSWindow *__parentWindow;
};
}
+++ /dev/null
-#include "DSWindow.h"
-#include "DSWindowPrivate.h"
-
-namespace display_server
-{
-
-DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr)
- : DSObjectPrivate(p_ptr),
- __p_ptr(p_ptr)
-{
-}
-
-DSWindowPrivate::~DSWindowPrivate()
-{
-}
-
-bool DSWindowPrivate::create(DSWindow *pWin, DSWindow *pParent)
-{
- int x = 0;
- int y = 0;
- unsigned int w = 1;
- unsigned int h = 1;
-
- // get screen position (x, y)
-
- // get screen width (w, h)
-
- return __create(x, y, w, h, pWin, pParent);
-}
-
-bool DSWindowPrivate::create(int x, int y, unsigned int w, unsigned int h, DSWindow *pWin, DSWindow *pParent)
-{
- return __create(x, y, w, h, pWin, pParent);
-}
-
-void DSWindowPrivate::destroy(void)
-{
-}
-
-bool DSWindowPrivate::show(void)
-{
- return true;
-}
-
-bool DSWindowPrivate::hide(bool autoFocus)
-{
- return true;
-}
-
-int DSWindowPrivate::showState(void)
-{
- return 0;
-}
-
-bool DSWindowPrivate::setLayer(int layer)
-{
- return true;
-}
-
-bool DSWindowPrivate::raise(void)
-{
- return true;
-}
-
-bool DSWindowPrivate::lower(void)
-{
- return true;
-}
-
-bool DSWindowPrivate::setFocus(void)
-{
- return true;
-}
-
-bool DSWindowPrivate::__create(int x, int y, unsigned int w, unsigned int h, DSWindow *pWin, DSWindow *pParent)
-{
- // Do something
-
- return true;
-}
-
-} // namespace display_server
\ No newline at end of file
#ifndef _DS_WINDOW_PRIVATE_H_
#define _DS_WINDOW_PRIVATE_H_
+#include "DSCore.h"
+#include "DSObjectPrivate.h"
+
namespace display_server
{
+class DSWindow;
+
class DSWindowPrivate : public DSObjectPrivate
{
DS_PIMPL_USE_PUBLIC(DSWindow)
DSWindowPrivate(DSWindow *p_ptr);
~DSWindowPrivate();
- bool create(DSWindow *pWin, DSWindow *pParent);
- bool create(int x, int y, unsigned int w, unsigned int h, DSWindow *pWin, DSWindow *pParent);
+ bool create(DSWindow *pParent);
+ bool create(int x, int y, unsigned int w, unsigned int h, DSWindow *pParent);
void destroy(void);
bool lower(void);
bool setFocus(void);
+ bool isCreated();
private:
- bool __create(int x, int y, unsigned int w, unsigned int h, DSWindow *pWin, DSWindow *pParent);
-
+ bool __create(int x, int y, unsigned int w, unsigned int h, DSWindow *pParent);
+
+ int __x;
+ int __y;
+ unsigned int __w;
+ unsigned int __h;
+ bool __created;
+ bool __hasFocus;
};
}
'DSSignal/DSSignal.h',
'DSCore/DSStruct.h',
'DSCore/DSCore.h',
+ 'DSWindow/DSWindow.h',
+ 'DSWindow/DSWindowPrivate.h',
'DSWindow/DSWindow.cpp',
- 'DSWindow/DSWindowPrivate.cpp',
'DSWindowShell/DSWindowShell.cpp',
'DSWindowShell/DSWindowShellPrivate.cpp',
'DSZone/DSZone.cpp',
#include "libds-tests.h"
#include "DSObject.h"
#include "DSWindow.h"
+#include "DSStruct.h"
using namespace display_server;
TEST_F(DSWindowTest, NewDSWindow)
{
- std::unique_ptr<DSWindow> Window = std::make_unique<DSWindow>();
- EXPECT_TRUE(Window != nullptr);
+ DSWindow *win = new DSWindow();
+ EXPECT_TRUE(win != nullptr);
+}
+
+TEST_F(DSWindowTest, NewDSWindowWithParent)
+{
+ DSWindow *wParent = new DSWindow();
+ EXPECT_TRUE(wParent != nullptr);
+
+ DSWindow *wChild = new DSWindow(wParent);
+ EXPECT_TRUE(wChild != nullptr);
+}
+
+TEST_F(DSWindowTest, NewDSWindowWithGeometry)
+{
+ int x = 100;
+ int y = 100;
+ unsigned int w = 500;
+ unsigned int h = 500;
+
+ DSWindow *win = new DSWindow(nullptr, x, y, w, h);
+ EXPECT_TRUE(win != nullptr);
+
+ stGeometry geom = win->getGeometry();
+ EXPECT_TRUE(geom.x == x);
+ EXPECT_TRUE(geom.y == y);
+ EXPECT_TRUE(geom.w == w);
+ EXPECT_TRUE(geom.h == h);
}
TEST_F(DSWindowTest, BasicMethods)
{
- std::unique_ptr<DSWindow> Window = std::make_unique<DSWindow>();
- EXPECT_TRUE(Window != nullptr);
+ bool hasFocus = false;
+
+ DSWindow *win = new DSWindow();
+ EXPECT_TRUE(win != nullptr);
+ EXPECT_TRUE(win->create(0, 0, 720, 1280, nullptr) == true);
- EXPECT_TRUE(Window->create(nullptr) == true);
- EXPECT_TRUE(Window->create(0, 0, 720, 1280, nullptr) == true);
+ stGeometry geom = win->getGeometry();
+ EXPECT_TRUE(geom.x == 0);
+ EXPECT_TRUE(geom.y == 0);
+ EXPECT_TRUE(geom.w == 720);
+ EXPECT_TRUE(geom.h == 1280);
- EXPECT_TRUE(Window->show() == true);
- EXPECT_TRUE(Window->hide(true) == true);
- EXPECT_TRUE(Window->showState() == 0);
+ EXPECT_TRUE(win->show() == true);
+ EXPECT_TRUE(win->hide(true) == true);
+ EXPECT_TRUE(win->showState() == 0);
- EXPECT_TRUE(Window->setLayer(100) == true);
+ EXPECT_TRUE(win->setLayer(100) == true);
- EXPECT_TRUE(Window->raise() == true);
- EXPECT_TRUE(Window->lower() == true);
+ EXPECT_TRUE(win->raise() == true);
+ EXPECT_TRUE(win->lower() == true);
- EXPECT_TRUE(Window->setFocus() == true);
+ hasFocus = win->setFocus();
+ EXPECT_TRUE(hasFocus == win->hasFocus());
}
\ No newline at end of file