1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
|
//!
//!
//! \addtogroup linuxui Linux UI
//! @{
//!
#ifndef __MAIN_FORM_H__
#define __MAIN_FORM_H__
#include "workbench/wb_context.h"
#include <gtkmm/window.h>
#include <gtkmm/notebook.h>
#include <gtkmm/progressbar.h>
#include <gtkmm/builder.h>
#include "mforms.h"
#include "mforms/dockingpoint.h"
#include "base/notifications.h"
namespace bec
{
class GRTManager;
}
namespace wb
{
class WBContextUI;
};
namespace Gtk
{
class Window;
}
class ActiveLabel;
class FormViewBase;
class ModelPanel;
class OverviewPanel;
class ModelDiagramPanel;
class OutputBox;
class FormViewBase;
class PluginEditorBase;
//==============================================================================
//
//==============================================================================
class MainForm : public sigc::trackable, base::Observer, public mforms::DockingPointDelegate
{
public:
enum TabStateInfo
{
TabClosed,
TabOpen,
TabOpenActive
};
MainForm(wb::WBContextUI* ctx);
~MainForm();
void setup_ui();
Gtk::Window* get_mainwindow() const;
void show();
public:
typedef sigc::slot<FormViewBase*,boost::shared_ptr<bec::UIForm> > FormViewFactory;
void register_form_view_factory(const std::string &name, FormViewFactory factory);
void show_status_text_becb(const std::string& text);
bool show_progress_becb(const std::string& title, const std::string& status, float pct);
NativeHandle open_plugin_becb(bec::GRTManager* mgr, grt::Module *module, const std::string& shlib, const std::string& editor_class, grt::BaseListRef args, bec::GUIPluginFlags flags);
void show_plugin_becb(NativeHandle handle);
void hide_plugin_becb(NativeHandle handle);
void perform_command_becb(const std::string& command);
// Creates diagram view
mdc::CanvasView* create_view_becb(const model_DiagramRef&);
void destroy_view_becb(mdc::CanvasView* view);
void switched_view_becb(mdc::CanvasView* view);
void tool_changed_becb(mdc::CanvasView* view);
void refresh_gui_becb(wb::RefreshType type, const std::string& arg_id, NativeHandle arg_ptr);
void lock_gui_becb(bool lock);
void create_main_form_view_becb(const std::string &name, boost::shared_ptr<bec::UIForm> form);
void destroy_main_form_view_becb(bec::UIForm* form);
bool quit_app_becb();
void exiting() { _exiting = true; }
wb::WBContextUI* get_wbui_context() const { return _wbui_context; }
private:
std::map<mdc::CanvasView*,ModelDiagramPanel*> _diagram_panel_list;
virtual void handle_notification(const std::string &name, void *sender, base::NotificationInfo &info);
void register_commands();
ModelDiagramPanel *get_panel_for_view(mdc::CanvasView *view);
FormViewBase *get_active_pane();
// void add_model_pane(ModelDiagramPanel *pane);
//
void add_form_pane(FormViewBase *pane, TabStateInfo tabState);
void add_plugin_form(PluginEditorBase *frame);
void add_plugin_pane(PluginEditorBase *editor);
void bring_plugin_pane(PluginEditorBase *editor);
// void remove_plugin_pane(PluginEditorBase *editor);
//
void close_active_tab();
void close_main_tab();
void close_inner_tab();
bool close_tab(Gtk::Notebook *note, Gtk::Widget *widget);
void append_tab_page(Gtk::Notebook *note, Gtk::Widget *widget, const std::string &title,
TabStateInfo tabState,
ActiveLabel **title_label_ret= 0);
// void init_tab_menu(mforms::Menu* m);
mforms::Menu* init_tab_menu(Gtk::Widget *widget);
void tab_menu_handler(const std::string& action, ActiveLabel* label, Gtk::Widget* widget, Gtk::Notebook* note);
void show_output();
void show_diagram_options();
void show_page_setup();
void handle_model_created();
void handle_model_closed();
bool close_window(GdkEventAny *ev);
void on_focus_widget(Gtk::Widget* focus);
void on_configure_window(GdkEventConfigure *conf);
void on_window_state(GdkEventWindowState *conf);
void is_active_changed();
void prepare_close_document();
void update_timer();
bool fire_timer();
// command handlers
void reset_layout();
void switch_page(GtkNotebookPage* page, guint pagenum);
Gtk::Notebook *get_upper_note() const;
void call_find_replace();
void call_find();
void call_undo();
void call_redo();
void call_paste();
void call_cut();
void call_copy();
void call_select_all();
void call_delete();
void call_search();
bool validate_find_replace();
bool validate_find();
bool validate_undo();
bool validate_redo();
bool validate_copy();
bool validate_cut();
bool validate_paste();
bool validate_select_all();
bool validate_delete();
bool validate_search();
private:
// mforms integration
void setup_mforms_app();
virtual std::string get_type() { return "MainWindow"; }
virtual void dock_view(mforms::AppView *view, const std::string &position, int arg);
virtual bool select_view(mforms::AppView *view);
virtual void undock_view(mforms::AppView *view);
virtual std::pair<int, int> get_size();
virtual void set_view_title(mforms::AppView *view, const std::string &title);
virtual mforms::AppView *selected_view();
virtual int view_count();
virtual mforms::AppView *view_at_index(int index);
static void set_status_text(mforms::App *app, const std::string &text);
//@@@ bool find_callback(const std::string &search, const std::string &replace,
// mforms::SearchFlags flags, SqlEditorFE *editor);
Gtk::Widget *decorate_widget(Gtk::Widget *panel, bec::UIForm *form);
private:
std::map<std::string, FormViewFactory> _form_view_factories;
wb::WBContextUI *_wbui_context;
ModelPanel *_model_panel;
OverviewPanel *_model_overview; //!< Overview of the model, see overview_panel.h
OutputBox *_output_box;
Glib::RefPtr<Gtk::Builder> _ui; //!< Glade model wrapper of the main window
const char *_db_glade_file; //!< File name of the glade model of the model overview part
bool _gui_locked;
bool _exiting;
Gtk::ProgressBar _progress_bar;
sigc::signal<void, std::string> _signal_close_editor;
sigc::connection _sig_change_status;
sigc::connection _sig_flush_idle;
sigc::connection _sig_set_current_page;
sigc::connection _sig_close_tab;
typedef std::vector<sigc::slot_base> Slots;
Slots _slots;
template <typename R, typename T>
sigc::slot<R> make_slot(R (T::*t)())
{
const sigc::slot<R> slot = sigc::mem_fun(this, t);
_slots.push_back(slot);
return slot;
}
};
#endif
//!
//! @}
//!
//! \addtogroup linuxui Linux UI
//! @{
//!
#ifndef __MAIN_FORM_H__
#define __MAIN_FORM_H__
#include "workbench/wb_context.h"
#include <gtkmm/window.h>
#include <gtkmm/notebook.h>
#include <gtkmm/progressbar.h>
#include <gtkmm/builder.h>
#include "mforms.h"
#include "mforms/dockingpoint.h"
#include "base/notifications.h"
namespace bec
{
class GRTManager;
}
namespace wb
{
class WBContextUI;
};
namespace Gtk
{
class Window;
}
class ActiveLabel;
class FormViewBase;
class ModelPanel;
class OverviewPanel;
class ModelDiagramPanel;
class OutputBox;
class FormViewBase;
class PluginEditorBase;
//==============================================================================
//
//==============================================================================
class MainForm : public sigc::trackable, base::Observer, public mforms::DockingPointDelegate
{
public:
enum TabStateInfo
{
TabClosed,
TabOpen,
TabOpenActive
};
MainForm(wb::WBContextUI* ctx);
~MainForm();
void setup_ui();
Gtk::Window* get_mainwindow() const;
void show();
public:
typedef sigc::slot<FormViewBase*,boost::shared_ptr<bec::UIForm> > FormViewFactory;
void register_form_view_factory(const std::string &name, FormViewFactory factory);
void show_status_text_becb(const std::string& text);
bool show_progress_becb(const std::string& title, const std::string& status, float pct);
NativeHandle open_plugin_becb(bec::GRTManager* mgr, grt::Module *module, const std::string& shlib, const std::string& editor_class, grt::BaseListRef args, bec::GUIPluginFlags flags);
void show_plugin_becb(NativeHandle handle);
void hide_plugin_becb(NativeHandle handle);
void perform_command_becb(const std::string& command);
// Creates diagram view
mdc::CanvasView* create_view_becb(const model_DiagramRef&);
void destroy_view_becb(mdc::CanvasView* view);
void switched_view_becb(mdc::CanvasView* view);
void tool_changed_becb(mdc::CanvasView* view);
void refresh_gui_becb(wb::RefreshType type, const std::string& arg_id, NativeHandle arg_ptr);
void lock_gui_becb(bool lock);
void create_main_form_view_becb(const std::string &name, boost::shared_ptr<bec::UIForm> form);
void destroy_main_form_view_becb(bec::UIForm* form);
bool quit_app_becb();
void exiting() { _exiting = true; }
wb::WBContextUI* get_wbui_context() const { return _wbui_context; }
private:
std::map<mdc::CanvasView*,ModelDiagramPanel*> _diagram_panel_list;
virtual void handle_notification(const std::string &name, void *sender, base::NotificationInfo &info);
void register_commands();
ModelDiagramPanel *get_panel_for_view(mdc::CanvasView *view);
FormViewBase *get_active_pane();
// void add_model_pane(ModelDiagramPanel *pane);
//
void add_form_pane(FormViewBase *pane, TabStateInfo tabState);
void add_plugin_form(PluginEditorBase *frame);
void add_plugin_pane(PluginEditorBase *editor);
void bring_plugin_pane(PluginEditorBase *editor);
// void remove_plugin_pane(PluginEditorBase *editor);
//
void close_active_tab();
void close_main_tab();
void close_inner_tab();
bool close_tab(Gtk::Notebook *note, Gtk::Widget *widget);
void append_tab_page(Gtk::Notebook *note, Gtk::Widget *widget, const std::string &title,
TabStateInfo tabState,
ActiveLabel **title_label_ret= 0);
// void init_tab_menu(mforms::Menu* m);
mforms::Menu* init_tab_menu(Gtk::Widget *widget);
void tab_menu_handler(const std::string& action, ActiveLabel* label, Gtk::Widget* widget, Gtk::Notebook* note);
void show_output();
void show_diagram_options();
void show_page_setup();
void handle_model_created();
void handle_model_closed();
bool close_window(GdkEventAny *ev);
void on_focus_widget(Gtk::Widget* focus);
void on_configure_window(GdkEventConfigure *conf);
void on_window_state(GdkEventWindowState *conf);
void is_active_changed();
void prepare_close_document();
void update_timer();
bool fire_timer();
// command handlers
void reset_layout();
void switch_page(GtkNotebookPage* page, guint pagenum);
Gtk::Notebook *get_upper_note() const;
void call_find_replace();
void call_find();
void call_undo();
void call_redo();
void call_paste();
void call_cut();
void call_copy();
void call_select_all();
void call_delete();
void call_search();
bool validate_find_replace();
bool validate_find();
bool validate_undo();
bool validate_redo();
bool validate_copy();
bool validate_cut();
bool validate_paste();
bool validate_select_all();
bool validate_delete();
bool validate_search();
private:
// mforms integration
void setup_mforms_app();
virtual std::string get_type() { return "MainWindow"; }
virtual void dock_view(mforms::AppView *view, const std::string &position, int arg);
virtual bool select_view(mforms::AppView *view);
virtual void undock_view(mforms::AppView *view);
virtual std::pair<int, int> get_size();
virtual void set_view_title(mforms::AppView *view, const std::string &title);
static void set_status_text(mforms::App *app, const std::string &text);
//@@@ bool find_callback(const std::string &search, const std::string &replace,
// mforms::SearchFlags flags, SqlEditorFE *editor);
Gtk::Widget *decorate_widget(Gtk::Widget *panel, bec::UIForm *form);
private:
std::map<std::string, FormViewFactory> _form_view_factories;
wb::WBContextUI *_wbui_context;
ModelPanel *_model_panel;
OverviewPanel *_model_overview; //!< Overview of the model, see overview_panel.h
OutputBox *_output_box;
Glib::RefPtr<Gtk::Builder> _ui; //!< Glade model wrapper of the main window
const char *_db_glade_file; //!< File name of the glade model of the model overview part
Glib::RefPtr<Gtk::AccelGroup> _accel_group;
bool _gui_locked;
bool _exiting;
Gtk::ProgressBar _progress_bar;
sigc::signal<void, std::string> _signal_close_editor;
sigc::connection _sig_change_status;
sigc::connection _sig_flush_idle;
sigc::connection _sig_set_current_page;
sigc::connection _sig_close_tab;
typedef std::vector<sigc::slot_base> Slots;
Slots _slots;
template <typename R, typename T>
sigc::slot<R> make_slot(R (T::*t)())
{
const sigc::slot<R> slot = sigc::mem_fun(this, t);
_slots.push_back(slot);
return slot;
}
};
#endif
//!
//! @}
//!
|