2
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
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
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.
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
23
#include "mforms/popup.h"
25
#include "wf_mforms.h"
27
using namespace System;
28
using namespace Windows::Forms;
29
using namespace System::Drawing::Drawing2D;
34
// The actual popup window
35
private ref class PopupControl : Windows::Forms::Form
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;
48
virtual void OnKeyPress(KeyPressEventArgs^ e) override;
52
virtual void DoRepaint();
53
virtual int Show(int x, int y);
55
virtual property MySQL::Geometry::Rect DisplayRect
57
MySQL::Geometry::Rect get()
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;
65
return MySQL::Geometry::Rect(content_area.Left, content_area.Top, content_area.Width, content_area.Height);
69
property int ModalResult
71
int get() { return modalResult; }
72
void set(int value) { modalResult = value; }
76
private ref class StandardPopupControl: PopupControl
79
virtual void OnPaint(PaintEventArgs ^e) override;
81
StandardPopupControl();
84
private ref class TransparentPopupControl: PopupControl
87
System::Drawing::Bitmap^ contentBitmap;
88
System::Drawing::Size baseSize;
91
System::Drawing::Color shadowColor;
96
System::Drawing::Point hotSpot;
100
void UpdateAndShowPopup(bool doAnimated);
102
GraphicsPath^ GetPath();
103
void PrepareBitmap();
105
virtual void OnKeyPress(KeyPressEventArgs^ e) override;
106
virtual void OnLostFocus(EventArgs^ e) override;
107
virtual void OnMouseDown(MouseEventArgs^ e) override;
109
TransparentPopupControl();
111
virtual void DoRepaint() override;
112
virtual int Show(int x, int y) override;
114
virtual property MySQL::Geometry::Rect DisplayRect
116
MySQL::Geometry::Rect get() override
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;
128
virtual property bool ShowWithoutActivation
130
bool get() override { return true; }
133
virtual property Windows::Forms::CreateParams^ CreateParams
135
Windows::Forms::CreateParams^ get() override
137
Windows::Forms::CreateParams^ cp = PopupControl::CreateParams;
139
cp->ExStyle |= (int) MySQL::Utilities::SysUtils::WS::EX_LAYERED;
140
cp->ExStyle |= (int) MySQL::Utilities::SysUtils::WS::EX_NOACTIVATE;
146
public ref class PopupImpl : public ObjectImpl
149
PopupImpl(mforms::Popup *self);
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);
160
static void init(Manager ^mgr)
162
mforms::ControlFactory *f= mforms::ControlFactory::get_instance();
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);
176
#endif // _WF_POPUP_H_