File: drawing.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 (126 lines) | stat: -rw-r--r-- 3,689 bytes parent folder | download | duplicates (2)
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
/* 
 * Copyright (c) 2011, 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
 */

#ifndef _DRAWING_H_
#define _DRAWING_H_

/**
 * Definitions used for cross-platform drawing.
 */

#ifndef SWIG
#include "common.h"
#endif

#include <map>

#ifdef _WIN32
  #define DEFAULT_FONT_FAMILY "Tahoma"
  #define DEFAULT_FONT_SIZE 11
  
  #define DEFAULT_SMALL_FONT "Modern"
  #define DEFAULT_MONOSPACE_FONT_FAMILY "Consolas"
  #define DEFAULT_MONOSPACE_FONT_FAMILY_ALT "Lucida Console"
#elif defined(__APPLE__)
  #define DEFAULT_FONT_FAMILY "Helvetica"
  #define DEFAULT_FONT_SIZE 11

  #define DEFAULT_MONOSPACE_FONT_FAMILY "AndaleMono"
#else
  #define DEFAULT_FONT_FAMILY "Helvetica"
  #define DEFAULT_FONT_SIZE 11

  #define DEFAULT_MONOSPACE_FONT_FAMILY "Bitstream Vera Sans Mono"
#endif

namespace base {

  enum ColorScheme
  {
    ColorSchemeStandard,
    ColorSchemeStandardWin7,
    ColorSchemeStandardWin8,
    ColorSchemeStandardWin8Alternate,
    ColorSchemeHighContrast,
    ColorSchemeCustom = 128,
  };

  enum ApplicationColor
  {
    AppColorMainTab = 0,
    AppColorMainBackground,
    AppColorPanelHeader,
    AppColorPanelHeaderFocused,
    AppColorPanelToolbar,
    AppColorPanelContentArea,
    AppColorTabUnselected,           // For both, top and bottom style.
                                     // Back color also used for uncovered tab area.
    AppColorBottomTabSelected,       // No focused/unfocused style.
    AppColorTopTabSelectedFocused,
    AppColorTopTabSelectedUnfocused,
    AppColorStatusbar,
  };

  struct HSVColor;

  class BASELIBRARY_PUBLIC_FUNC Color
  {
  public:
    double red, green, blue, alpha;

    Color();
    Color(double ar, double ag, double ab, double aa = 1.0);
    Color(const HSVColor &hsv);
    Color(const std::string &color);

    bool operator !=(const Color &other);
    std::string to_html() const;
    bool is_valid() const;

    static Color parse(const std::string &color);

    static inline Color Black() { return Color(0, 0, 0); }
    static inline Color White() { return Color(1, 1, 1); }
    static inline Color Invalid() { return Color(-1, -1, -1); }

    static Color get_application_color(ApplicationColor color, bool foreground);
    static std::string get_application_color_as_string(ApplicationColor color, bool foreground);
    static void set_active_scheme(ColorScheme scheme);
    static ColorScheme get_active_scheme();
    static bool is_high_contrast_scheme();

    // Persistence support. Also called when colors were changed in preferences.
    static void load_custom_colors(const std::map<std::string, std::string> &colors);
    static void save_custom_colors(std::map<std::string, std::string> &colors);
  };


  struct BASELIBRARY_PUBLIC_FUNC HSVColor
  {
    int h; // 0 ~ 360
    double s, v, a; // 0 ~ 1.0

    HSVColor() : h(0), s(0), v(0), a(1) {};
    HSVColor(int ah, double as, double av, double aa=1.0) : h(ah), s(as), v(av), a(aa) {};
    HSVColor(const Color &rgb);
  };

} // namespace base

#endif // _DRAWING_H_