28
28
#include "Widget.h"
30
30
#include "../GUIManager.h"
31
#include "../EmberOgre.h"
31
33
#include "services/input/Input.h"
32
#include "../EmberOgre.h"
33
34
#include "framework/Exception.h"
35
#include <CEGUIWindow.h>
36
#include <CEGUIExceptions.h>
37
#include <CEGUIWindowManager.h>
38
#include <elements/CEGUIFrameWindow.h>
39
#include <elements/CEGUIPushButton.h>
41
35
#include "framework/ConsoleBackend.h"
37
#include <CEGUI/Window.h>
38
#include <CEGUI/Exceptions.h>
39
#include <CEGUI/WindowManager.h>
40
#include <CEGUI/widgets/FrameWindow.h>
41
#include <CEGUI/widgets/PushButton.h>
43
44
using namespace CEGUI;
45
46
namespace OgreView {
48
49
const std::string Widget::DEFAULT_TAB_GROUP("default");
50
Widget::Widget() : mCommandSuffix(""), mMainWindow(0), mActiveWindowIsOpaque(true), mFirstTabWindow(0), mLastTabWindow(0), mWindowHasBeenShown(false)
51
Widget::Widget() : mCommandSuffix(""), mMainWindow(0), mGuiManager(0), mWindowManager(0), mOriginalWindowAlpha(1.0f), mActiveWindowIsOpaque(true), mFirstTabWindow(0), mLastTabWindow(0), mWindowHasBeenShown(false)
83
84
return mGuiManager->getMainSheet();
87
87
CEGUI::Window* Widget::loadMainSheet(const std::string& filename, const std::string& prefix) {
88
88
assert(mWindowManager && "You must call init() before you can call any other methods.");
90
90
std::string finalFileName(mGuiManager->getLayoutDir() + filename);
92
mMainWindow = mWindowManager->loadWindowLayout(finalFileName, prefix);
92
mMainWindow = mWindowManager->loadLayoutFromFile(finalFileName);
93
93
} catch (const std::exception& ex) {
94
94
S_LOG_FAILURE("Error when loading from " << filename << "." << ex);
96
97
S_LOG_FAILURE("Unknown error when loading from " << filename << ".");
99
mOriginalWindowAlpha = mMainWindow->getAlpha();
100
getMainSheet()->addChildWindow(mMainWindow);
101
BIND_CEGUI_EVENT(mMainWindow, CEGUI::FrameWindow::EventActivated, Widget::MainWindow_Activated);
102
BIND_CEGUI_EVENT(mMainWindow, CEGUI::FrameWindow::EventDeactivated, Widget::MainWindow_Deactivated);
103
//we want to catch all click events, so we'll listen for the mouse button down event
104
BIND_CEGUI_EVENT(mMainWindow, CEGUI::Window::EventMouseButtonDown, Widget::MainWindow_MouseButtonDown);
105
if (mMainWindow->isVisible()) {
106
onEventFirstTimeShown();
108
//Set it up to listen for the first time the window is shown.
109
BIND_CEGUI_EVENT(mMainWindow, CEGUI::Window::EventShown, Widget::MainWindow_Shown);
100
mMainWindow->setName(prefix);
101
mOriginalWindowAlpha = mMainWindow->getAlpha();
102
getMainSheet()->addChild(mMainWindow);
103
BIND_CEGUI_EVENT(mMainWindow, CEGUI::FrameWindow::EventActivated, Widget::MainWindow_Activated);
104
BIND_CEGUI_EVENT(mMainWindow, CEGUI::FrameWindow::EventDeactivated, Widget::MainWindow_Deactivated);
105
//we want to catch all click events, so we'll listen for the mouse button down event
106
BIND_CEGUI_EVENT(mMainWindow, CEGUI::Window::EventMouseButtonDown, Widget::MainWindow_MouseButtonDown);
107
if (mMainWindow->isVisible()) {
108
onEventFirstTimeShown();
110
//Set it up to listen for the first time the window is shown.
111
BIND_CEGUI_EVENT(mMainWindow, CEGUI::Window::EventShown, Widget::MainWindow_Shown);
113
114
return mMainWindow;
130
131
assert(mMainWindow && "You must call loadMainSheet(...) before you can call this method.");
131
CEGUI::Window* window = mWindowManager->getWindow(mPrefix + windowName);
132
CEGUI::Window* window = mMainWindow->getChildRecursive(windowName);
133
S_LOG_WARNING("The window with id " << mPrefix << windowName << " does not exist.");
134
S_LOG_WARNING("The window with id " << windowName << ", located under widget " << mPrefix << " does not exist.");
136
137
} catch (const CEGUI::Exception&) {