2
* Copyright (c) 2009, 2011, 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
21
* Contains the implementation of the wrapper for a .NET form used by the mforms backend.
26
#include "wf_appview.h"
27
#include "wf_menubar.h"
28
#include "wf_toolbar.h"
31
using namespace System::Drawing::Drawing2D;
33
using namespace MySQL::Forms;
34
using namespace MySQL::Controls;
36
//--------------------------------------------------------------------------------------------------
38
bool AppViewImpl::create(::mforms::AppView *self, bool horizontal)
40
AppViewImpl^ appview= gcnew AppViewImpl(self);
42
if (appview != nullptr)
44
// The next steps are the same as with a BoxImpl.
45
Box^ native_box= ViewImpl::create<Box>(self, appview);
46
native_box->Horizontal= horizontal;
47
self->set_resize_mode(::mforms::ResizeNone);
54
//--------------------------------------------------------------------------------------------------
57
* Called when this app view is about to be docked in a host container. Create the front end
58
* tab document if not yet done and return it to the caller.
60
TabDocument^ AppViewImpl::GetHost()
67
//--------------------------------------------------------------------------------------------------
69
MenuStrip^ AppViewImpl::GetMenuBar()
71
mforms::MenuBar* menu = _appView->get_menubar();
75
MenuBarImpl^ menubar_impl = (MenuBarImpl^) ViewImpl::FromUnmanaged(menu);
77
return menubar_impl->get_control<MenuStrip>();
80
//--------------------------------------------------------------------------------------------------
82
ToolStrip^ AppViewImpl::GetToolBar()
84
mforms::ToolBar* toolbar = _appView->get_toolbar();
88
ToolBarImpl^ toolbar_impl = (ToolBarImpl^) ViewImpl::FromUnmanaged(toolbar);
90
return toolbar_impl->get_control<ToolStrip>();
93
//--------------------------------------------------------------------------------------------------
95
bool AppViewImpl::DocumentClosing()
97
Control^ control= get_control<Control>();
99
if (control->Tag != nullptr)
101
::mforms::AppView* view= ViewImpl::get_backend_control<::mforms::AppView>(control);
103
return view->on_close();
108
//--------------------------------------------------------------------------------------------------
110
AppViewImpl::AppViewImpl(::mforms::AppView* app)
111
: BoxImpl(app), _appView(app)
115
//--------------------------------------------------------------------------------------------------
117
void AppViewImpl::setup()
119
// In order to ease maintenance we create a special document host for our content.
120
_host = gcnew AppViewDockContent(this);
121
Control^ control = get_control<Control>();
122
_host->Controls->Add(control);
123
control->Dock = DockStyle::Fill;
126
//--------------------------------------------------------------------------------------------------
128
void AppViewImpl::ContentPanelPaint(System::Object^ sender, PaintEventArgs^ e)
130
Graphics^ g = e->Graphics;
131
g->SmoothingMode = SmoothingMode::None;
133
System::Drawing::Rectangle clientArea = ((Panel^)(sender))->ClientRectangle;
135
Pen^ pen = gcnew Pen(Color::FromArgb(175, 210, 239), 1);
136
g->DrawRectangle(pen, clientArea.Left, clientArea.Top, clientArea.Width - 1, clientArea.Height - 1);
140
//--------------------------------------------------------------------------------------------------
142
void AppViewImpl::MenuPanelPaint(System::Object^ sender, PaintEventArgs^ e)
144
Graphics^ g = e->Graphics;
145
Panel^ panel = dynamic_cast<Panel^>(sender);
147
ToolStripHelper::MenuPanelPaint(g, panel->ClientRectangle);
150
//----------------- AppViewDockContent -------------------------------------------------------------
152
AppViewDockContent::AppViewDockContent(AppViewImpl^ appview)
155
_appview->get_unmanaged_object()->retain();
158
//--------------------------------------------------------------------------------------------------
160
AppViewDockContent::~AppViewDockContent()
162
_appview->get_unmanaged_object()->release();
166
//--------------------------------------------------------------------------------------------------
168
AppViewImpl^ AppViewDockContent::GetAppView()
173
//--------------------------------------------------------------------------------------------------
175
mforms::AppView* AppViewDockContent::get_unmanaged_object()
177
return _appview->get_unmanaged_object();
180
//--------------------------------------------------------------------------------------------------
182
String^ AppViewDockContent::GetAppViewIdentifier()
184
return CppStringToNative(_appview->get_unmanaged_object()->identifier());
187
//--------------------------------------------------------------------------------------------------