2
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; version 2 of the
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
#ifndef _WF_Utilities_H_
21
#define _WF_Utilities_H_
23
#include "mforms/utilities.h"
25
#include "wf_mforms.h"
28
using namespace mforms;
33
// Message type for the C# interface.
34
public enum class MessageType
42
* A custom message box for the output as there is no predefined dialog which allows to
43
* have custom button captions.
45
public ref class CustomMessageBox : Windows::Forms::Form
48
// Constructor is private. CustomMessageBox should be accessed through the public Show() method
51
// GUI Elements, we have 3 buttons whose text can be customized.
52
Windows::Forms::Label^ _messageLabel;
53
Windows::Forms::Button^ _button1;
54
Windows::Forms::Button^ _button2;
55
Windows::Forms::Button^ _button3;
56
Windows::Forms::PictureBox^ _picture;
57
Windows::Forms::CheckBox^ _checkbox;
60
void ButtonClick(System::Object^ sender, EventArgs^ e);
62
static mforms::DialogResult ShowVistaStyle(const std::string& title, const std::string& text,
63
PCWSTR mainIcon, const std::string& buttonOK, const std::string& buttonCancel,
64
const std::string& buttonOther, const std::string& checkbox, bool& checked);
66
static mforms::DialogResult ShowTraditionalStyle(String^ title, String^ text, System::Drawing::Image^ image,
67
String^ button1, String^ button2, String^ button3, String^ checkbox, bool& checked);
70
static mforms::DialogResult Show(const std::string& title, const std::string& text,
71
PCWSTR mainIcon, const std::string& buttonOK, const std::string& buttonCancel,
72
const std::string& buttonOther, const std::string& checkbox, bool& checked);
75
static Windows::Forms::DialogResult Show(MessageType type, String^ title, String^ text, String^ buttonOK,
76
String^ buttonCancel, String^ buttonOther, String^ checkbox, [Out] bool% checked);
77
static Windows::Forms::DialogResult Show(MessageType type, String^ title, String^ text, String^ buttonOK);
80
private ref class InvokationResult
85
InvokationResult(void* result)
99
private ref class DispatchControl : Control
102
const boost::function<void* ()>* _slot;
103
InvokationResult^ RunSlot();
105
void* RunOnMainThread(const boost::function<void* ()>& slot, bool wait);
108
public ref class UtilitiesImpl
111
static DispatchControl^ _dispatcher;
113
static void load_passwords();
114
static void unload_passwords(bool store);
118
static int show_message(const string &title, const string &text, const string &ok,
119
const string &cancel, const string &other);
120
static int show_error(const string &title, const string &text, const string &ok,
121
const string &cancel, const string &other);
122
static int show_warning(const string &title, const string &text, const string &ok,
123
const string &cancel, const string &other);
124
static int show_message_with_checkbox(const string &title, const string &text, const string &ok,
125
const string &cancel, const string &other, const std::string &checkbox_text, bool &isChecked);
126
static void show_wait_message(const string &title, const string &text);
127
static bool hide_wait_message();
128
static bool run_cancelable_wait_message(const string &title, const string &text,
129
const boost::function<void ()> &start_task, const boost::function<bool ()> &cancel_slot);
130
static void stop_cancelable_wait_message();
132
static void set_clipboard_text(const string &content);
133
static string get_clipboard_text();
134
static string get_special_folder(FolderType type);
136
static void open_url(const string &url);
137
static bool move_to_trash(const string &file_name);
139
static void add_timeout(float interval, const boost::function<bool ()> &slot);
141
static void store_password(const std::string &service, const std::string &account, const std::string &password);
142
static bool find_password(const std::string &service, const std::string &account, std::string &password);
143
static void forget_password(const std::string &service, const std::string &account);
145
static void* perform_from_main_thread(const boost::function<void* ()> &slot, bool wait);
147
static Windows::Forms::Form^ get_mainform();
149
static void init(Manager ^mgr)
151
_dispatcher = gcnew DispatchControl();
152
_dispatcher->Handle; // create window handle
154
::mforms::ControlFactory *f= ::mforms::ControlFactory::get_instance();
156
DEF_CALLBACK5(int, const string&, const string&, const string&, const string&, const string&,
157
mgr, f->_utilities_impl, UtilitiesImpl, show_message);
158
DEF_CALLBACK5(int, const string&, const string&, const string&, const string&, const string&,
159
mgr, f->_utilities_impl, UtilitiesImpl, show_error);
160
DEF_CALLBACK5(int, const string&, const string&, const string&, const string&, const string&,
161
mgr, f->_utilities_impl, UtilitiesImpl, show_warning);
162
DEF_CALLBACK7(int, const string&, const string&, const string&, const string&, const string&,
163
const string&, bool&, mgr, f->_utilities_impl, UtilitiesImpl, show_message_with_checkbox);
164
DEF_CALLBACK2(void, const string&, const string&, mgr, f->_utilities_impl, UtilitiesImpl,
166
DEF_CALLBACK0(bool, mgr, f->_utilities_impl, UtilitiesImpl, hide_wait_message);
167
DEF_CALLBACK4(bool, const std::string&, const std::string&, const boost::function<void ()> &, const boost::function<bool ()>&, mgr, f->_utilities_impl, UtilitiesImpl, run_cancelable_wait_message);
168
DEF_CALLBACK0(void, mgr, f->_utilities_impl, UtilitiesImpl, stop_cancelable_wait_message);
169
DEF_CALLBACK1(void, const string&, mgr, f->_utilities_impl, UtilitiesImpl, set_clipboard_text);
170
DEF_CALLBACK0(string, mgr, f->_utilities_impl, UtilitiesImpl, get_clipboard_text);
171
DEF_CALLBACK1(void, const string&, mgr, f->_utilities_impl, UtilitiesImpl, open_url);
172
DEF_CALLBACK1(bool, const string&, mgr, f->_utilities_impl, UtilitiesImpl, move_to_trash);
173
DEF_CALLBACK2(void, float, const boost::function<bool ()>&, mgr, f->_utilities_impl, UtilitiesImpl, add_timeout);
174
DEF_CALLBACK1(string, mforms::FolderType, mgr, f->_utilities_impl, UtilitiesImpl, get_special_folder);
175
DEF_CALLBACK3(void, const string&, const string&, const string&, mgr, f->_utilities_impl, UtilitiesImpl, store_password);
176
DEF_CALLBACK3(bool, const string&, const string&, string&, mgr, f->_utilities_impl, UtilitiesImpl, find_password);
177
DEF_CALLBACK2(void, const string&, const string&, mgr, f->_utilities_impl, UtilitiesImpl, forget_password);
178
DEF_CALLBACK2(void*, const boost::function<void* ()>&, bool, mgr, f->_utilities_impl, UtilitiesImpl, perform_from_main_thread);
184
#endif // _WF_Utilities_H_