File: wf_textbox.h

package info (click to toggle)
mysql-workbench 5.2.40%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 53,880 kB
  • sloc: cpp: 419,850; yacc: 74,784; xml: 54,510; python: 31,455; sh: 9,423; ansic: 4,736; makefile: 2,442; php: 529; java: 237
file content (81 lines) | stat: -rw-r--r-- 3,597 bytes parent folder | download
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
/* 
 * Copyright (c) 2008, 2011, 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 _WF_TEXTBOX_H_
#define _WF_TEXTBOX_H_

#include "wf_view.h"

using namespace System::Windows;

namespace MySQL {
  namespace Forms {

    // Small helper class to implement certain key press processing.
    private ref class TextBoxEx : public Windows::Forms::TextBox
    {
    protected:
      virtual bool ProcessCmdKey(Message% msg, Keys keyData) override;
    public:
      mforms::ModifierKey getModifiers(Keys keyData);
    };

    public ref class TextBoxImpl : public ViewImpl
    {
    private:
      mforms::ModifierKey modifiers; // Converted modifier keys for key down and key press events.
    protected:
      static bool create(::mforms::TextBox *self, ::mforms::ScrollBars scroll_bars);
      static void set_text(::mforms::TextBox *self, const std::string &text);
      static void append_text(::mforms::TextBox *self, const std::string &text, bool scroll_to_end);
      static std::string get_text(::mforms::TextBox *self);
      static void set_read_only(::mforms::TextBox *self, bool flag);
      static void set_padding(::mforms::TextBox *self, int pad);
      static void set_bordered(::mforms::TextBox *self, bool flag);
      static void set_monospaced(::mforms::TextBox *self, bool flag);
      static void get_selected_range(::mforms::TextBox *self, int &start, int &end);
      static void clear(::mforms::TextBox *self);

      void OnChange(Object^ sender, EventArgs^ args);
      void OnKeyDown(Object^ sender, KeyEventArgs^ args);
      void OnKeyPress(Object^ sender, KeyPressEventArgs^ args);
    public:
      TextBoxImpl(::mforms::TextBox *text);

      static void init(Manager ^mgr)
      {
        ::mforms::ControlFactory *f= ::mforms::ControlFactory::get_instance();

        DEF_CALLBACK2(bool, ::mforms::TextBox*, ::mforms::ScrollBars, mgr, f->_textbox_impl, TextBoxImpl, create);
        DEF_CALLBACK2(void, ::mforms::TextBox*, bool, mgr, f->_textbox_impl, TextBoxImpl, set_bordered);
        DEF_CALLBACK2(void, ::mforms::TextBox*, const std::string&, mgr, f->_textbox_impl, TextBoxImpl, set_text);
        DEF_CALLBACK3(void, ::mforms::TextBox*, const std::string&, bool, mgr, f->_textbox_impl, TextBoxImpl, append_text);
        DEF_CALLBACK2(void, ::mforms::TextBox*, bool, mgr, f->_textbox_impl, TextBoxImpl, set_read_only);
        DEF_CALLBACK2(void, ::mforms::TextBox*, int, mgr, f->_textbox_impl, TextBoxImpl, set_padding);
        DEF_CALLBACK1(std::string, ::mforms::TextBox*, mgr, f->_textbox_impl, TextBoxImpl, get_text);
        DEF_CALLBACK3(void, ::mforms::TextBox*, int&, int&, mgr, f->_textbox_impl, TextBoxImpl, get_selected_range);
        DEF_CALLBACK2(void, ::mforms::TextBox*, bool, mgr, f->_textbox_impl, TextBoxImpl, set_monospaced);
        DEF_CALLBACK1(void, ::mforms::TextBox*, mgr, f->_textbox_impl, TextBoxImpl, clear);
      }
    };

  };
};

#endif