File: app.h

package info (click to toggle)
mysql-workbench 6.2.3%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 102,612 kB
  • ctags: 84,593
  • sloc: ansic: 804,682; cpp: 438,759; yacc: 59,129; python: 54,293; xml: 48,851; sql: 5,512; objc: 1,414; makefile: 505; sh: 455; java: 237; ruby: 6; perl: 5; php: 1
file content (133 lines) | stat: -rw-r--r-- 4,142 bytes parent folder | download
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
/* 
 * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
 *
 * 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; version 2 of the
 * License.
 * 
 * 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 St, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#pragma once

#include <map>

#include "mforms/dockingpoint.h"
#include "base/geometry.h"
#include "base/drawing.h"

namespace mforms {

  // Known system colors.
  enum SystemColor
  {
    SystemColorHighlight,    // The system-defined color of the background of selected items.
                             // This includes selected menu items as well as selected text.
    SystemColorEditor,       // Background color for editor controls.
    SystemColorDisabled,     // Background color for disabled controls.
    SystemColorContainer,    // Usually a gray. The default background for container controls. TODO: Linux.
  };

  class App;
  class AppView;
  class View;

#ifndef DOXYGEN_SHOULD_SKIP_THIS
#ifndef SWIG
  struct AppImplPtrs
  {
    void (*set_status_text)(App *app, const std::string &title);
    
    std::string (*get_resource_path)(App *app, const std::string &file);
    std::string (*get_executable_path)(App *app, const std::string &file);
    base::Rect (*get_application_bounds)(App *app);
    
    int (*enter_event_loop)(App *app, float max_wait_time);
    void (*exit_event_loop)(App *app, int result);
    
    void (*begin_thread_loop)();
    void (*end_thread_loop)();

    base::Color (*get_system_color)(SystemColor type);

    float (*backing_scale_factor)(App *app);
  };
#endif
#endif

  /** Proxy class for interfacing with the host application window.
   
   Provides some utility functions to perform certain actions in the main window
   of the host application. This class uses a singleton.
   */
  class MFORMS_EXPORT App : public DockingPoint
  {
  private:
    App() : DockingPoint() {}

    App(DockingPointDelegate *delegate, bool delete_on_destroy);
    
  public:
#ifndef SWIG
    // for use by host application
    static void instantiate(DockingPointDelegate *delegate, bool delete_on_destroy);
#endif
  public:
    
    /** Gets the instance of the App class.
     */
    static App *get();

    /** Sets the status text at the bottom of the window.
     */
    void set_status_text(const std::string &text);
    
    /** Gets the path to a resource file bundled in the application. 
     
     Passing an empty string will return the path to the resource directory. */
    std::string get_resource_path(const std::string &file);

    std::string get_executable_path(const std::string &file);

    std::string get_user_data_folder() { return _user_data_folder; }
    
    /** Gets the bounds of the main window. */
    base::Rect get_application_bounds();
    
    /** Enters the event loop and exit only once exit_event_loop() is called.
     @param timeout Given in seconds. If > 0.0, the function will return -1 after that time.
       */
    int enter_event_loop(float timeout = 0.0);
    
    /** Exits from enter_event_loop() */
    void exit_event_loop(int retcode);
    
    // use in threads where mforms is called
    static void begin_thread_loop();
    static void end_thread_loop();
    
    // Retrieve system information like predefined colors, screen size, monitor count etc.
    base::Color get_system_color(SystemColor type);

    float backing_scale_factor();
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#ifndef SWIG
    void set_user_data_folder_path(const std::string &path) { _user_data_folder = path; }
#endif
#endif
  protected:
    AppImplPtrs *_app_impl;
    
  private:
    std::string _user_data_folder;
  };
};