File: CanvasViewer.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 (166 lines) | stat: -rw-r--r-- 5,212 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* Copyright (c) 2008, 2014, 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 __CANVAS_VIEWER_H__
#define __CANVAS_VIEWER_H__

#include "Canvas.h"

namespace MySQL
{
  namespace GUI
  {
    namespace Mdc
    {
      public ref class WindowsCanvasViewerPanel : System::Windows::Forms::Panel
      {
         System::Windows::Forms::ScrollBar ^vScrollbar = nullptr;
         System::Windows::Forms::ScrollBar ^hScrollbar = nullptr;

         BaseWindowsCanvasView ^canvas = nullptr;
         bool canvasInitialized = false;

         bool scrolling = false;

         bool handleInput = false;
        System::Windows::Forms::ToolStripLabel ^canvasFPSLabel = nullptr;


      public:
        WindowsCanvasViewerPanel();

        WindowsGLCanvasView ^CreateGLCanvas(Form ^ownerForm, bool handleInput);
        WindowsGDICanvasView ^CreateGDICanvas(Form ^ownerForm, bool handleInput);

        void FinalizeCanvas();

        property BaseWindowsCanvasView ^Canvas
        {
          BaseWindowsCanvasView ^get() { return canvas; }
        }

        property Form ^OwnerForm
        {
          Form ^get()
          {
            if (canvas != nullptr)
              return canvas->GetOwnerForm();
            else
              return nullptr;
          }
          void set(Form ^value)
          {
            if (canvas != nullptr)
              canvas->SetOwnerForm(value);
          }
        }

        property ScrollBar ^VScrollbar
        {
          ScrollBar ^get() { return vScrollbar; }
          void set(ScrollBar ^value) { vScrollbar = value; }
        }

        property ScrollBar ^HScrollbar
        {
          ScrollBar ^get() { return hScrollbar; }
          void set(ScrollBar ^value) { hScrollbar = value; }
        }

      protected:
        virtual void OnMouseMove(MouseEventArgs ^e) override;
        virtual void OnMouseDown(MouseEventArgs ^e) override;
        virtual void OnMouseUp(MouseEventArgs ^e) override;
        virtual void OnMouseDoubleClick(MouseEventArgs ^e) override;
        virtual void OnMouseWheel(MouseEventArgs ^e) override;

        virtual void OnKeyDown(KeyEventArgs ^e) override;

        virtual void OnKeyUp(KeyEventArgs ^e) override;
        virtual void OnSizeChanged(EventArgs ^e) override;
        virtual void OnPaintBackground(PaintEventArgs ^e) override;
        virtual void OnPaint(PaintEventArgs ^e) override;

      private:
        void OnNeedsRepaint(int x, int y, int w, int h);
        void OnViewportChanged();

        void ScrollablePanel_Click(Object ^sender, EventArgs ^e);
        void UpdateScrollbars();
        void UpdateScrollBarPositions();
        void UpdateScrollBarSizes();


        void DoMouseMove(MouseEventArgs ^e);

      public:
        void HandleScroll(Object ^sender, ScrollEventArgs ^args);
      };




      public ref class WindowsCanvasViewer : System::Windows::Forms::Panel
      {
        WindowsCanvasViewerPanel ^canvasPanel;

      public:
        WindowsCanvasViewer();

      public:
        property BaseWindowsCanvasView ^Canvas
        {
          BaseWindowsCanvasView ^get() { return canvasPanel->Canvas; }
        }

        property System::Windows::Forms::Form ^OwnerForm
        {
          System::Windows::Forms::Form ^get() { return canvasPanel->OwnerForm; }
          void set(System::Windows::Forms::Form^ value) { canvasPanel->OwnerForm = value; }
        }

        property System::Windows::Forms::Panel ^CanvasPanel
        {
          System::Windows::Forms::Panel^ get() { return canvasPanel; }
        }


        /// <summary>
        /// Initializes a new canvas viewer. Normally we use OpenGL for rendering, but this can be
        /// switched off by the user (either via the application options or via command line).
        /// The opposite force switch can override the sw rendering switch if the user really wants this.
        /// It is usually only used to override forced sw rendering for certain chip sets.
        /// </summary>
        /// <param name="ownerForm">The hosting WB form for the view.</param>
        /// <param name="handleInput">True if the view should act to user input (mouse/keyboard).</param>
        /// <returns>The newly created canvas view</returns>
      public:
        BaseWindowsCanvasView ^CreateCanvasView(System::Windows::Forms::Form ^ownerForm, bool handleInput,
          bool software_rendering_enforced, bool opengl_rendering_enforced);

        void FinalizeCanvas()
        {
          canvasPanel->FinalizeCanvas();
        }
      };
    };
  };
};

#endif