~canonical-dx-team/unity/unity.fix-ql-losing-focus

« back to all changes in this revision

Viewing changes to src/Tooltip.h

  • Committer: Neil Jagdish Patel
  • Date: 2010-11-11 18:51:08 UTC
  • mfrom: (572.1.58 unity-3.0)
  • Revision ID: neil.patel@canonical.com-20101111185108-71923a90txzvxbit
[merge] Unity 3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Jay Taoko <jay.taoko@canonical.com>
 
17
 * Authored by: Mirco Müller <mirco.mueller@canonical.com
 
18
 */
 
19
 
 
20
#ifndef TOOLTIP_H
 
21
#define TOOLTIP_H
 
22
 
 
23
 
 
24
#include "Nux/Nux.h"
 
25
#include "Nux/BaseWindow.h"
 
26
#include "NuxGraphics/GraphicsEngine.h"
 
27
#include "Nux/TextureArea.h"
 
28
#include "NuxImage/CairoGraphics.h"
 
29
#include "StaticCairoText.h"
 
30
 
 
31
#include <pango/pango.h>
 
32
#include <pango/pangocairo.h>
 
33
 
 
34
#if defined(NUX_OS_LINUX)
 
35
#include <X11/Xlib.h>
 
36
#endif
 
37
 
 
38
#define ANCHOR_WIDTH         10.0f
 
39
#define ANCHOR_HEIGHT        18.0f
 
40
#define HIGH_LIGHT_Y         -30.0f
 
41
#define HIGH_LIGHT_MIN_WIDTH 200.0f 
 
42
#define RADIUS               5.0f
 
43
#define BLUR_INTENSITY       8
 
44
#define LINE_WIDTH           1.0f
 
45
#define PADDING_SIZE         1
 
46
#define H_MARGIN             30
 
47
#define V_MARGIN             4
 
48
#define FONT_FACE            "Ubuntu 13"
 
49
 
 
50
namespace nux
 
51
{
 
52
  class VLayout;
 
53
  class HLayout;
 
54
  class SpaceLayout;
 
55
  
 
56
  class Tooltip : public BaseWindow
 
57
  {
 
58
    NUX_DECLARE_OBJECT_TYPE (Tooltip, BaseWindow);
 
59
  public:
 
60
    Tooltip ();
 
61
 
 
62
    ~Tooltip ();
 
63
 
 
64
    long ProcessEvent (IEvent& iEvent,
 
65
      long    traverseInfo,
 
66
      long    processEventInfo);
 
67
 
 
68
    void Draw (GraphicsEngine& gfxContext,
 
69
      bool             forceDraw);
 
70
 
 
71
    void DrawContent (GraphicsEngine& gfxContext,
 
72
      bool             forceDraw);
 
73
 
 
74
    void SetText (NString text);
 
75
 
 
76
  private:
 
77
    void RecvCairoTextChanged (StaticCairoText& cairo_text);
 
78
 
 
79
    void PreLayoutManagement ();
 
80
 
 
81
    long PostLayoutManagement (long layoutResult);
 
82
 
 
83
    void PositionChildLayout (float offsetX,
 
84
      float offsetY);
 
85
 
 
86
    void LayoutWindowElements ();
 
87
 
 
88
    void NotifyConfigurationChange (int width,
 
89
      int height);
 
90
 
 
91
    //nux::CairoGraphics*   _cairo_graphics;
 
92
    int                   _anchorX;
 
93
    int                   _anchorY;
 
94
    nux::NString          _labelText;
 
95
    int                   _dpiX;
 
96
    int                   _dpiY;
 
97
 
 
98
    cairo_font_options_t* _fontOpts;
 
99
 
 
100
    nux::StaticCairoText* _tooltip_text;
 
101
    nux::BaseTexture*     _texture_bg;
 
102
    nux::BaseTexture*     _texture_mask;
 
103
    nux::BaseTexture*     _texture_outline;
 
104
 
 
105
    float _anchor_width;
 
106
    float _anchor_height;
 
107
    float _corner_radius;
 
108
    float _padding;
 
109
    nux::HLayout *_hlayout;
 
110
    VLayout *_vlayout;
 
111
    nux::SpaceLayout *_left_space;  //!< Space from the left of the widget to the left of the text.
 
112
    nux::SpaceLayout *_right_space; //!< Space from the right of the text to the right of the widget.
 
113
    nux::SpaceLayout *_top_space;  //!< Space from the left of the widget to the left of the text.
 
114
    nux::SpaceLayout *_bottom_space; //!< Space from the right of the text to the right of the widget.
 
115
 
 
116
    bool _cairo_text_has_changed;
 
117
    void UpdateTexture ();
 
118
  };
 
119
}
 
120
 
 
121
#endif // TOOLTIP_H
 
122