File: caret.h

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (144 lines) | stat: -rw-r--r-- 3,987 bytes parent folder | download | duplicates (11)
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
/////////////////////////////////////////////////////////////////////////////
// Name:        caret.h
// Purpose:     interface of wxCaret
// Author:      wxWidgets team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

/**
    @class wxCaret

    A caret is a blinking cursor showing the position where the typed text will
    appear. Text controls usually have their own caret but wxCaret provides a
    way to use a caret in other windows.

    Currently, the caret appears as a rectangle of the given size. In the
    future, it will be possible to specify a bitmap to be used for the caret
    shape.

    A caret is always associated with a window and the current caret can be
    retrieved using wxWindow::GetCaret(). The same caret can't be reused in two
    different windows.

    @library{wxcore}
    @category{misc}
*/
class wxCaret
{
public:
    /**
        Default constructor.
    */
    wxCaret();

    //@{
    /**
        Creates a caret with the given size (in pixels) and associates it with
        the @a window.
    */
    wxCaret(wxWindow* window, int width, int height);
    wxCaret(wxWindow* window, const wxSize& size);
    //@}

    //@{
    /**
        Creates a caret with the given size (in pixels) and associates it with
        the @a window (same as the equivalent constructors).
    */
    bool Create(wxWindow* window, int width, int height);
    bool Create(wxWindow* window, const wxSize& size);
    //@}

    /**
        Returns the blink time which is measured in milliseconds and is the
        time elapsed between 2 inversions of the caret (blink time of the caret
        is the same for all carets, so this functions is static).
    */
    static int GetBlinkTime();

    //@{
    /**
        Get the caret position (in pixels).

        @beginWxPerlOnly
        In wxPerl there are two methods instead of a single overloaded
        method:
        - GetPosition(): returns a Wx::Point object.
        - GetPositionXY(): returns a 2-element list (x, y).
        @endWxPerlOnly
    */
    void GetPosition(int* x, int* y) const;
    wxPoint GetPosition() const;
    //@}

    //@{
    /**
        Get the caret size.

        @beginWxPerlOnly
        In wxPerl there are two methods instead of a single overloaded
        method:
        - GetSize(): returns a Wx::Size object.
        - GetSizeWH(): returns a 2-element list (width, height).
        @endWxPerlOnly
    */
    void GetSize(int* width, int* height) const;
    wxSize GetSize() const;
    //@}

    /**
        Get the window the caret is associated with.
    */
    wxWindow* GetWindow() const;

    /**
        Hides the caret, same as Show(@false).
    */
    virtual void Hide();

    /**
        Returns @true if the caret was created successfully.
    */
    bool IsOk() const;

    /**
        Returns @true if the caret is visible and @false if it is permanently
        hidden (if it is blinking and not shown currently but will be after
        the next blink, this method still returns @true).
    */
    bool IsVisible() const;

    //@{
    /**
        Move the caret to given position (in logical coordinates).
    */
    void Move(int x, int y);
    void Move(const wxPoint& pt);
    //@}

    /**
        Sets the blink time for all the carets.

        @warning Under Windows, this function will change the blink time for
                 all carets permanently (until the next time it is called),
                 even for carets in other applications.

        @see GetBlinkTime()
    */
    static void SetBlinkTime(int milliseconds);

    //@{
    /**
        Changes the size of the caret.
    */
    void SetSize(int width, int height);
    void SetSize(const wxSize& size);
    //@}

    /**
        Shows or hides the caret. Notice that if the caret was hidden N times,
        it must be shown N times as well to reappear on the screen.
    */
    virtual void Show(bool show = true);
};