~ubuntu-branches/ubuntu/quantal/mysql-workbench/quantal

« back to all changes in this revision

Viewing changes to library/forms/winforms/wf_popup.h

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2012-03-01 21:57:30 UTC
  • Revision ID: package-import@ubuntu.com-20120301215730-o7y8av8y38n162ro
Tags: upstream-5.2.38+dfsg
ImportĀ upstreamĀ versionĀ 5.2.38+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 
3
 *
 
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
 
7
 * License.
 
8
 * 
 
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.
 
13
 * 
 
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
 
17
 * 02110-1301  USA
 
18
 */
 
19
 
 
20
#ifndef _WF_POPUP_H_
 
21
#define _WF_POPUP_H_
 
22
 
 
23
#include "mforms/popup.h"
 
24
#include "wf_base.h"
 
25
#include "wf_mforms.h"
 
26
 
 
27
using namespace System;
 
28
using namespace Windows::Forms;
 
29
using namespace System::Drawing::Drawing2D;
 
30
 
 
31
namespace MySQL {
 
32
  namespace Forms {
 
33
 
 
34
    // The actual popup window
 
35
    private ref class PopupControl : Windows::Forms::Form
 
36
    {
 
37
    protected:
 
38
      int modalResult;
 
39
 
 
40
      virtual void OnMouseDown(MouseEventArgs ^e) override;
 
41
      virtual void OnMouseUp(MouseEventArgs ^e) override;
 
42
      virtual void OnMouseClick(MouseEventArgs ^e) override;
 
43
      virtual void OnMouseDoubleClick(MouseEventArgs ^e) override;
 
44
      virtual void OnMouseMove(MouseEventArgs ^e) override;
 
45
      virtual void OnMouseEnter(EventArgs ^e) override;
 
46
      virtual void OnMouseLeave(EventArgs ^e) override;
 
47
 
 
48
      virtual void OnKeyPress(KeyPressEventArgs^ e) override;
 
49
    public:
 
50
      PopupControl();
 
51
 
 
52
      virtual void DoRepaint();
 
53
      virtual int Show(int x, int y);
 
54
 
 
55
      virtual property MySQL::Geometry::Rect DisplayRect
 
56
      {
 
57
        MySQL::Geometry::Rect get()
 
58
        {
 
59
          System::Drawing::Rectangle content_area= ClientRectangle;
 
60
          content_area.X += Padding.Left;
 
61
          content_area.Y += Padding.Top;
 
62
          content_area.Width -= Padding.Horizontal;
 
63
          content_area.Height -= Padding.Vertical;
 
64
 
 
65
          return MySQL::Geometry::Rect(content_area.Left, content_area.Top, content_area.Width, content_area.Height);
 
66
        }
 
67
      }
 
68
 
 
69
      property int ModalResult
 
70
      {
 
71
        int get() { return modalResult; }
 
72
        void set(int value) { modalResult = value; }
 
73
      }
 
74
    };
 
75
 
 
76
    private ref class StandardPopupControl: PopupControl
 
77
    {
 
78
    protected:
 
79
      virtual void OnPaint(PaintEventArgs ^e) override;
 
80
    public:
 
81
      StandardPopupControl();
 
82
    };
 
83
 
 
84
    private ref class TransparentPopupControl: PopupControl
 
85
    {
 
86
    private:
 
87
      System::Drawing::Bitmap^ contentBitmap;
 
88
      System::Drawing::Size baseSize;
 
89
      float borderSize;
 
90
      int shadowSize;
 
91
      System::Drawing::Color shadowColor;
 
92
      int shadowOffset;
 
93
      int cornerSize;
 
94
      int animationSteps;
 
95
      bool animated;
 
96
      System::Drawing::Point hotSpot;
 
97
    protected:
 
98
      void RunLoop();
 
99
 
 
100
      void UpdateAndShowPopup(bool doAnimated);
 
101
      void HidePopup();
 
102
      GraphicsPath^ GetPath();
 
103
      void PrepareBitmap();
 
104
 
 
105
      virtual void OnKeyPress(KeyPressEventArgs^ e) override;
 
106
      virtual void OnLostFocus(EventArgs^ e) override;
 
107
      virtual void OnMouseDown(MouseEventArgs^ e) override;
 
108
    public:
 
109
      TransparentPopupControl();
 
110
 
 
111
      virtual void DoRepaint() override;
 
112
      virtual int Show(int x, int y) override;
 
113
 
 
114
      virtual property MySQL::Geometry::Rect DisplayRect
 
115
      {
 
116
        MySQL::Geometry::Rect get() override
 
117
        {
 
118
          MySQL::Geometry::Rect rect(0, 0, baseSize.Width, baseSize.Height);
 
119
          rect.pos.x += shadowSize + shadowOffset + Padding.Left;
 
120
          rect.pos.y += shadowSize + shadowOffset + Padding.Top;
 
121
          rect.size.width -= Padding.Horizontal;
 
122
          rect.size.height -= Padding.Vertical;
 
123
 
 
124
          return rect;
 
125
        }
 
126
      }
 
127
 
 
128
      virtual property bool ShowWithoutActivation
 
129
      {
 
130
        bool get() override { return true; }
 
131
      }
 
132
 
 
133
      virtual property Windows::Forms::CreateParams^ CreateParams       
 
134
      {
 
135
        Windows::Forms::CreateParams^ get() override
 
136
        {
 
137
          Windows::Forms::CreateParams^ cp = PopupControl::CreateParams;
 
138
 
 
139
          cp->ExStyle |= (int) MySQL::Utilities::SysUtils::WS::EX_LAYERED;
 
140
          cp->ExStyle |= (int) MySQL::Utilities::SysUtils::WS::EX_NOACTIVATE;
 
141
          return cp;
 
142
        }
 
143
      }
 
144
    };
 
145
 
 
146
    public ref class PopupImpl : public ObjectImpl
 
147
    {
 
148
    protected:
 
149
      PopupImpl(mforms::Popup *self);
 
150
      ~PopupImpl();
 
151
 
 
152
      static bool create(mforms::Popup *self, mforms::PopupStyle style);
 
153
      static void set_needs_repaint(mforms::Popup *self);
 
154
      static void set_size(mforms::Popup *self, int width, int height);
 
155
      static int show(mforms::Popup *self, int spot_x, int spot_y);
 
156
      static MySQL::Geometry::Rect get_content_rect(mforms::Popup *self);
 
157
      static void set_modal_result(mforms::Popup *self, int result);
 
158
 
 
159
    public:
 
160
      static void init(Manager ^mgr)
 
161
      {
 
162
        mforms::ControlFactory *f= mforms::ControlFactory::get_instance();
 
163
 
 
164
        DEF_CALLBACK2(bool, mforms::Popup*, mforms::PopupStyle, mgr, f->_popup_impl, PopupImpl, create);
 
165
        DEF_CALLBACK1(void, mforms::Popup*, mgr, f->_popup_impl, PopupImpl, set_needs_repaint);
 
166
        DEF_CALLBACK3(void, mforms::Popup*, int, int, mgr, f->_popup_impl, PopupImpl, set_size);
 
167
        DEF_CALLBACK3(int, mforms::Popup*, int, int, mgr, f->_popup_impl, PopupImpl, show);
 
168
        DEF_CALLBACK1(MySQL::Geometry::Rect, mforms::Popup*, mgr, f->_popup_impl, PopupImpl, get_content_rect);
 
169
        DEF_CALLBACK2(void, mforms::Popup*, int, mgr, f->_popup_impl, PopupImpl, set_modal_result);
 
170
      }
 
171
    };
 
172
 
 
173
  };
 
174
};
 
175
 
 
176
#endif // _WF_POPUP_H_