From e523f1c6a5dea364bdfe8c536b573600f04231c8 Mon Sep 17 00:00:00 2001 From: Alexander Egorov Date: Fri, 15 Feb 2008 02:52:45 +0100 Subject: [PATCH] nanox/time, nanox/dialogs, etc... --- makefiles/arch/desktop.mk | 1 + zlibrary/ui/Makefile | 6 +-- .../application-desktop/ZLNXApplicationWindow.cpp | 18 +++++-- .../application-desktop/ZLNXApplicationWindow.h | 3 ++ .../ui/src/nanox/dialogs/ZLNXDialogManager.cpp | 49 +++++++++++++++++++ zlibrary/ui/src/nanox/dialogs/ZLNXDialogManager.h | 57 ++++++++++++++++++++++ zlibrary/ui/src/nanox/library/ZLibrary.cpp | 11 ++++- .../ZLNXApplicationWindow.h => time/ZLNXTime.cpp} | 56 +++++++++------------ .../ZLNXApplicationWindow.h => time/ZLNXTime.h} | 37 +++++--------- zlibrary/ui/src/nanox/view/ZLNXPaintContext.cpp | 3 ++ 10 files changed, 172 insertions(+), 69 deletions(-) create mode 100644 zlibrary/ui/src/nanox/dialogs/ZLNXDialogManager.cpp create mode 100644 zlibrary/ui/src/nanox/dialogs/ZLNXDialogManager.h copy zlibrary/ui/src/nanox/{application-desktop/ZLNXApplicationWindow.h => time/ZLNXTime.cpp} (53%) copy zlibrary/ui/src/nanox/{application-desktop/ZLNXApplicationWindow.h => time/ZLNXTime.h} (55%) diff --git a/makefiles/arch/desktop.mk b/makefiles/arch/desktop.mk index d86c17d..71193c1 100644 --- a/makefiles/arch/desktop.mk +++ b/makefiles/arch/desktop.mk @@ -38,6 +38,7 @@ endif ifeq "$(UI_TYPE)" "nanox" UILIBS = -L$(ROOTDIR)/v3/i386/lib -lnano-X NXINCLUDE = -I$(ROOTDIR)/v3/include/nanox/ + ZLSHARED = no endif XML_LIB = -lexpat diff --git a/zlibrary/ui/Makefile b/zlibrary/ui/Makefile index a695159..3ebd408 100644 --- a/zlibrary/ui/Makefile +++ b/zlibrary/ui/Makefile @@ -13,7 +13,7 @@ endif SUBDIRS_ALL = src/win32/view src/win32/w32widgets src/win32/dialogs src/win32/application src/win32/image src/win32/library src/win32/time src/unix/message src/win32/message QTSUBDIRS_ALL = src/qt/time src/qtopia/message src/qtopia/application src/qtopia/dialogs src/qtopia/optionView src/qtopia/view src/qt/dialogs src/qt/view src/qt/image src/qt/util src/opie/view src/opie/dialogs src/opie/application src/qt/application-desktop src/qt/application-pdaxrom src/opie/library src/qt/library src/qtopia/library src/qt/filesystem src/qt4/time src/qt4/dialogs src/qt4/view src/qt4/image src/qt4/util src/qt4/application src/qt4/library src/qt4/filesystem src/ezx/library src/ezx/application src/ezx/dialogs src/ezx/view src/ezx/optionView GTKSUBDIRS_ALL = src/gtk/time src/gtk/dialogs src/gtk/optionView src/gtk/view src/gtk/image src/gtk/util src/maemo/dialogs src/maemo/optionView src/maemo/view src/gpe/dialogs src/gpe/view src/gtk/application-desktop src/gtk/application-pdaxrom src/maemo/application src/gpe/application src/maemo/library src/gtk/library src/gpe/library src/gtk/filesystem src/maemo/message src/gtk/pixbuf -NXSUBDIRS_ALL = src/nanox/application-desktop src/nanox/application-lbook src/nanox/dialogs src/nanox/library src/nanox/view src/nanox/filesystem +NXSUBDIRS_ALL = src/nanox/application-desktop src/nanox/application-lbook src/nanox/dialogs src/nanox/library src/nanox/view src/nanox/filesystem src/nanox/time src/nanox/dialogs SUBDIRS = @@ -34,7 +34,7 @@ ifeq "$(UI_TYPE)" "gpe" endif ifeq "$(UI_TYPE)" "nanox" - NXSUBDIRS = src/nanox/application-$(TARGET_ARCH) src/nanox/library src/nanox/view src/nanox/filesystem + NXSUBDIRS = src/nanox/application-$(TARGET_ARCH) src/nanox/library src/nanox/view src/nanox/filesystem src/nanox/time src/nanox/dialogs endif ifeq "$(UI_TYPE)" "opie" @@ -93,7 +93,7 @@ $(TARGET): .objects ifeq "$(ZLSHARED)" "yes" @$(LD) $(LDFLAGS) -shared -Wl,-soname,$(TARGET) -o $(TARGET) $(patsubst %, %/*.o, $(SUBDIRS) $(QTSUBDIRS) $(GTKSUBDIRS) $(NXSUBDIRS)) $(UILIBS) $(CORE_LIBS) else - @$(AR) $(TARGET) $(patsubst %, %/*.o, $(SUBDIRS) $(QTSUBDIRS) $(GTKSUBDIRS)) + $(AR) $(TARGET) $(patsubst %, %/*.o, $(SUBDIRS) $(QTSUBDIRS) $(GTKSUBDIRS) $(NXSUBDIRS)) endif @echo " OK" diff --git a/zlibrary/ui/src/nanox/application-desktop/ZLNXApplicationWindow.cpp b/zlibrary/ui/src/nanox/application-desktop/ZLNXApplicationWindow.cpp index 3495746..3650c28 100644 --- a/zlibrary/ui/src/nanox/application-desktop/ZLNXApplicationWindow.cpp +++ b/zlibrary/ui/src/nanox/application-desktop/ZLNXApplicationWindow.cpp @@ -23,6 +23,7 @@ #include "../view/ZLNXViewWidget.h" #include "../../../../core/src/dialogs/ZLOptionView.h" +#include "../dialogs/ZLNXDialogManager.h" #include #include @@ -53,9 +54,10 @@ ZLNXApplicationWindow::ZLNXApplicationWindow(ZLApplication *application) : GrSetGCFont(gc, fontid); GrSetFontAttr(fontid, GR_TFKERNING | GR_TFANTIALIAS, 0); -/* GrText_Apollo(win, gc, 5, 20, (void *)"init", 5, GR_TFUTF8); + GrText_Apollo(win, gc, 5, 20, (void *)"init", 5, GR_TFUTF8); GrPrint_Apollo(); -*/ + sleep(3); + } @@ -76,10 +78,12 @@ ZLNXApplicationWindow::~ZLNXApplicationWindow() { GrClose(); } -/*bool ZLNXApplicationWindow::onButtonPress() { - application().doActionByKey(ZLNXKeyUtil::keyName(event)); -}*/ +void ZLNXApplicationWindow::onButtonPress() { +// application().doActionByKey(ZLNXKeyUtil::keyName(event)); +} +void ZLNXApplicationWindow::addToolbarItem(ZLApplication::Toolbar::ItemPtr item) { +} void ZLNXApplicationWindow::setFullscreen(bool fullscreen) { } @@ -98,3 +102,7 @@ void ZLNXApplicationWindow::close() { void ZLNXApplicationWindow::grabAllKeys(bool) { } + +void ZLNXDialogManager::createApplicationWindow(ZLApplication *application) const { + ZLNXApplicationWindow *mw = new ZLNXApplicationWindow(application); +} diff --git a/zlibrary/ui/src/nanox/application-desktop/ZLNXApplicationWindow.h b/zlibrary/ui/src/nanox/application-desktop/ZLNXApplicationWindow.h index a0e7db4..010ea76 100644 --- a/zlibrary/ui/src/nanox/application-desktop/ZLNXApplicationWindow.h +++ b/zlibrary/ui/src/nanox/application-desktop/ZLNXApplicationWindow.h @@ -41,11 +41,14 @@ class ZLNXApplicationWindow : public ZLDesktopApplicationWindow { void onButtonPress(); private: + ZLNXApplicationWindow *myWindow; ZLViewWidget *createViewWidget(); void init(); void close(); void grabAllKeys(bool grab); + void addToolbarItem(ZLApplication::Toolbar::ItemPtr item); + void setCaption(const std::string &caption) { } bool isFullscreen() const; void setFullscreen(bool fullscreen); diff --git a/zlibrary/ui/src/nanox/dialogs/ZLNXDialogManager.cpp b/zlibrary/ui/src/nanox/dialogs/ZLNXDialogManager.cpp new file mode 100644 index 0000000..78be9d1 --- /dev/null +++ b/zlibrary/ui/src/nanox/dialogs/ZLNXDialogManager.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2008 Alexander Egorov + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#include "ZLNXDialogManager.h" + +shared_ptr ZLNXDialogManager::createDialog(const ZLResourceKey &key) const { +} + +shared_ptr ZLNXDialogManager::createOptionsDialog(const ZLResourceKey &id, shared_ptr applyAction, bool showApplyButton) const { +} + +void ZLNXDialogManager::informationBox(const ZLResourceKey &key, const std::string &message) const { +} + +void ZLNXDialogManager::errorBox(const ZLResourceKey &key, const std::string &message) const { +} + +int ZLNXDialogManager::questionBox(const ZLResourceKey &key, const std::string &message, const ZLResourceKey &button0, const ZLResourceKey &button1, const ZLResourceKey &button2) const { +} + +bool ZLNXDialogManager::selectionDialog(const ZLResourceKey &key, ZLTreeHandler &handler) const { +} + +void ZLNXDialogManager::wait(const ZLResourceKey &key, ZLRunnable &runnable) const { +} + +bool ZLNXDialogManager::isClipboardSupported(ClipboardType) const { + return true; +} + +void ZLNXDialogManager::setClipboardText(const std::string &text, ClipboardType type) const { +} + diff --git a/zlibrary/ui/src/nanox/dialogs/ZLNXDialogManager.h b/zlibrary/ui/src/nanox/dialogs/ZLNXDialogManager.h new file mode 100644 index 0000000..1b43fa2 --- /dev/null +++ b/zlibrary/ui/src/nanox/dialogs/ZLNXDialogManager.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2008 Alexander Egorov + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLNXDIALOGMANAGER_H__ +#define __ZLNXDIALOGMANAGER_H__ + +#include + +#include + +class ZLNXDialogManager : public ZLDialogManager { + +public: + static void createInstance() { ourInstance = new ZLNXDialogManager(); } + +private: + ZLNXDialogManager() : myIsKeyboardGrabbed(false) {} + +public: + void createApplicationWindow(ZLApplication *application) const; + + shared_ptr createDialog(const ZLResourceKey &key) const; + shared_ptr createOptionsDialog(const ZLResourceKey &id, shared_ptr applyAction, bool showApplyButton) const; + void informationBox(const ZLResourceKey &key, const std::string &message) const; + void errorBox(const ZLResourceKey &key, const std::string &message) const; + int questionBox(const ZLResourceKey &key, const std::string &message, const ZLResourceKey &button0, const ZLResourceKey &button1, const ZLResourceKey &button2) const; + bool selectionDialog(const ZLResourceKey &key, ZLTreeHandler &handler) const; + void wait(const ZLResourceKey &key, ZLRunnable &runnable) const; + + bool isClipboardSupported(ClipboardType type) const; + void setClipboardText(const std::string &text, ClipboardType type) const; + + void grabKeyboard(bool grab) { myIsKeyboardGrabbed = grab; } + bool isKeyboardGrabbed() const { return myIsKeyboardGrabbed; } + +private: + bool myIsKeyboardGrabbed; + +}; + +#endif /* __ZLNXDIALOGMANAGER_H__ */ diff --git a/zlibrary/ui/src/nanox/library/ZLibrary.cpp b/zlibrary/ui/src/nanox/library/ZLibrary.cpp index 8e16256..d2a5261 100644 --- a/zlibrary/ui/src/nanox/library/ZLibrary.cpp +++ b/zlibrary/ui/src/nanox/library/ZLibrary.cpp @@ -27,7 +27,10 @@ #include "../../../../core/src/unix/iconv/IConvEncodingConverter.h" #include "../filesystem/ZLNXFSManager.h" +#include "../time/ZLNXTime.h" #include "../view/ZLNXPaintContext.h" +#include "../dialogs/ZLNXDialogManager.h" + class ZLNXLibraryImplementation : public ZLibraryImplementation { private: @@ -47,6 +50,8 @@ void ZLNXLibraryImplementation::init(int &argc, char **&argv) { XMLConfigManager::createInstance(); ZLNXFSManager::createInstance(); + ZLNXTimeManager::createInstance(); + ZLNXDialogManager::createInstance(); ZLUnixCommunicationManager::createInstance(); ZLEncodingCollection::instance().registerProvider(new IConvEncodingConverterProvider()); } @@ -56,11 +61,15 @@ ZLPaintContext *ZLNXLibraryImplementation::createContext() { } void ZLNXLibraryImplementation::run(ZLApplication *application) { -// ZLDialogManager::instance().createApplicationWindow(application); + ZLDialogManager::instance().createApplicationWindow(application); printf("run\n"); application->initWindow(); + sleep(3); + std::string x("largeScrollForward"); + application->doActionByKey(x); + sleep(10); delete application; diff --git a/zlibrary/ui/src/nanox/application-desktop/ZLNXApplicationWindow.h b/zlibrary/ui/src/nanox/time/ZLNXTime.cpp similarity index 53% copy from zlibrary/ui/src/nanox/application-desktop/ZLNXApplicationWindow.h copy to zlibrary/ui/src/nanox/time/ZLNXTime.cpp index a0e7db4..06c3a3e 100644 --- a/zlibrary/ui/src/nanox/application-desktop/ZLNXApplicationWindow.h +++ b/zlibrary/ui/src/nanox/time/ZLNXTime.cpp @@ -17,38 +17,26 @@ * 02110-1301, USA. */ -#ifndef __ZLNXAPPLICATIONWINDOW_H__ -#define __ZLNXAPPLICATIONWINDOW_H__ -#include -#include - -#include "../../../../core/src/desktop/application/ZLDesktopApplicationWindow.h" - -#include -#include - -GR_WINDOW_ID win; -GR_GC_ID gc; -GR_FONT_ID fontid; - -class ZLNXApplicationWindow : public ZLDesktopApplicationWindow { - - public: - ZLNXApplicationWindow(ZLApplication *application); - ~ZLNXApplicationWindow(); - - void onButtonPress(); - - private: - ZLViewWidget *createViewWidget(); - void init(); - void close(); - - void grabAllKeys(bool grab); - - bool isFullscreen() const; - void setFullscreen(bool fullscreen); -}; - -#endif /* __ZLNXAPPLICATIONWINDOW_H__ */ +#include "ZLNXTime.h" + +static bool taskFunction(void *data) { + ((ZLRunnable*)data)->run(); + return true; +} + +void ZLNXTimeManager::addTask(shared_ptr task, int interval) { + removeTask(task); + if ((interval > 0) && !task.isNull()) { +// myHandlers[task] = g_timeout_add(interval, (GSourceFunc)taskFunction, &*task); +//TODO: add timer + } +} + +void ZLNXTimeManager::removeTask(shared_ptr task) { + std::map,int>::iterator it = myHandlers.find(task); + if (it != myHandlers.end()) { +//TODO: remove timer + myHandlers.erase(it); + } +} diff --git a/zlibrary/ui/src/nanox/application-desktop/ZLNXApplicationWindow.h b/zlibrary/ui/src/nanox/time/ZLNXTime.h similarity index 55% copy from zlibrary/ui/src/nanox/application-desktop/ZLNXApplicationWindow.h copy to zlibrary/ui/src/nanox/time/ZLNXTime.h index a0e7db4..00e35ac 100644 --- a/zlibrary/ui/src/nanox/application-desktop/ZLNXApplicationWindow.h +++ b/zlibrary/ui/src/nanox/time/ZLNXTime.h @@ -17,38 +17,23 @@ * 02110-1301, USA. */ -#ifndef __ZLNXAPPLICATIONWINDOW_H__ -#define __ZLNXAPPLICATIONWINDOW_H__ +#ifndef __ZLNXTIME_H__ +#define __ZLNXTIME_H__ -#include #include -#include "../../../../core/src/desktop/application/ZLDesktopApplicationWindow.h" +#include "../../../../core/src/unix/time/ZLUnixTime.h" -#include -#include +class ZLNXTimeManager : public ZLUnixTimeManager { -GR_WINDOW_ID win; -GR_GC_ID gc; -GR_FONT_ID fontid; +public: + static void createInstance() { ourInstance = new ZLNXTimeManager(); } -class ZLNXApplicationWindow : public ZLDesktopApplicationWindow { + void addTask(shared_ptr task, int interval); + void removeTask(shared_ptr task); - public: - ZLNXApplicationWindow(ZLApplication *application); - ~ZLNXApplicationWindow(); - - void onButtonPress(); - - private: - ZLViewWidget *createViewWidget(); - void init(); - void close(); - - void grabAllKeys(bool grab); - - bool isFullscreen() const; - void setFullscreen(bool fullscreen); +private: + std::map,int> myHandlers; }; -#endif /* __ZLNXAPPLICATIONWINDOW_H__ */ +#endif /* __ZLNXTIME_H__ */ diff --git a/zlibrary/ui/src/nanox/view/ZLNXPaintContext.cpp b/zlibrary/ui/src/nanox/view/ZLNXPaintContext.cpp index 9576baa..a84de84 100644 --- a/zlibrary/ui/src/nanox/view/ZLNXPaintContext.cpp +++ b/zlibrary/ui/src/nanox/view/ZLNXPaintContext.cpp @@ -57,6 +57,8 @@ int ZLNXPaintContext::stringWidth(const char *str, int len) const { GrGetGCTextSize(gc, (void *)str, len, GR_TFUTF8, &w, &h, &b); + printf("w: %d\n", w); + return w; } @@ -81,6 +83,7 @@ int ZLNXPaintContext::descent() const { } void ZLNXPaintContext::drawString(int x, int y, const char *str, int len) { + printf("x %d, y %d: %s\n", str); GrText_Apollo(win, gc, x, y, (void *)str, len, GR_TFUTF8); } -- 2.11.4.GIT