GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
BaseDialogBox.cpp
Go to the documentation of this file.
1#include "BaseDialogBox.h"
2
3#include "GUIFramework.h"
6
7using namespace std;
8
9namespace gui_framework
10{
11 BaseDialogBox::messageBoxResponse BaseDialogBox::createMessageBox(const wstring& text, const wstring& title, messageBoxType type, BaseComposite* parent, bool helpButton)
12 {
13 return static_cast<messageBoxResponse>(MessageBoxW(parent ? parent->getHandle() : nullptr, text.data(), title.data(), static_cast<UINT>(type) | (helpButton ? MB_HELP : NULL)));
14 }
15
16 BaseDialogBox::BaseDialogBox(const wstring& className, const wstring& title, const utility::ComponentSettings& settings, const string& dialogBoxFunctionName, const string& moduleName, uint16_t smallIconResource, uint16_t largeIconResource) :
18 (
19 className,
20 title,
21 settings,
22 styles::DialogBoxStyles(),
23 nullptr,
24 dialogBoxFunctionName,
25 moduleName,
26 smallIconResource,
27 largeIconResource
28 ),
29 IComponentVisibility(handle),
30 ICloseable(handle),
31 isShowDialogUsed(false),
32 windowWithUserFocus(nullptr)
33 {
34 this->hide();
35
37 }
38
40 {
41 GUIFramework& instance = GUIFramework::get();
42 unique_lock<recursive_mutex> lock(instance.componentsMutex);
43 WindowHolder holder(this);
44
45 isShowDialogUsed = true;
46
47 windowWithUserFocus = GetFocus();
48
49 this->show();
50
51 for (const auto& component : instance.components)
52 {
53 if (component == this)
54 {
55 break;
56 }
57 else if (dynamic_cast<BaseComposite*>(component))
58 {
59 EnableWindow(component->getHandle(), false);
60 }
61 }
62
63 return holder.runMainLoop();
64 }
65
67 {
69 {
70 GUIFramework& instance = GUIFramework::get();
71 unique_lock<recursive_mutex> lock(instance.componentsMutex);
72
73 for (const auto& component : instance.components)
74 {
75 if (component == this)
76 {
77 break;
78 }
79 else if (dynamic_cast<BaseComposite*>(component))
80 {
81 EnableWindow(component->getHandle(), true);
82 }
83 }
84
85 SetFocus(windowWithUserFocus);
86 }
87 }
88}
Base class for all windows that has children windows.
void setExitMode(exitMode mode)
static messageBoxResponse createMessageBox(const std::wstring &text, const std::wstring &title, messageBoxType type, BaseComposite *parent=nullptr, bool helpButton=false)
BaseDialogBox(const std::wstring &className, const std::wstring &title, const utility::ComponentSettings &settings, const std::string &dialogBoxFunctionName="", const std::string &moduleName="", uint16_t smallIconResource=NULL, uint16_t largeIconResource=NULL)
Singleton with GUIFramework settings and some functionality.
static GUIFramework & get()
Singleton instance access.
Provides runMainLoop for top level window.
int runMainLoop(const std::vector< uint32_t > &registeredHotkeyIds={})
Process messages. Must be called after initialization.