]> git.lyx.org Git - features.git/blob - src/mathed/math_cursor.h
new painter,workarea and lcolor. Read the diff/sources and ChangeLog...
[features.git] / src / mathed / math_cursor.h
1 // -*- C++ -*-
2 /*
3  *  File:        math_cursor.h
4  *  Purpose:     Declaration of interaction classes for mathed
5  *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx> 
6  *  Created:     January 1996
7  *  Description: MathCursor control all user interaction
8  *
9  *  Dependencies: Xlib, XForms
10  *
11  *  Copyright: (c) 1996, Alejandro Aguilar Sierra
12  *
13  *   Version: 0.8beta, Mathed & Lyx project.
14  *
15  *   You are free to use and modify this code under the terms of
16  *   the GNU General Public Licence version 2 or later.
17  */
18
19 #ifndef MATH_CURSOR
20 #define MATH_CURSOR
21
22 #ifdef __GNUG__
23 #pragma interface
24 #endif
25
26 #include "math_iter.h" 
27 #include "math_inset.h"
28
29
30 /// This is the external interface of Mathed's subkernel
31 class MathedCursor {
32  public:
33     ///
34     MathedCursor(MathParInset * p);
35     ///
36     ~MathedCursor() { };
37     ///
38     void Insert(byte, MathedTextCodes t = LM_TC_MIN);
39     ///
40     void Insert(MathedInset *, int t = LM_TC_INSET);
41     ///
42     void Home();
43     ///
44     void End();
45     ///
46     bool Right(bool sel = false);
47     ///
48     bool Left(bool sel = false);
49     ///
50     bool Up(bool sel = false);
51     ///
52     bool Down(bool sel = false);
53     ///
54     bool Pop();
55     ///
56     bool Push();
57     /// Pull out an argument from its container inset
58     bool pullArg();
59 #ifdef USE_PAINTER
60     ///
61     void draw(Painter &, int x, int y);
62     ///
63     void Redraw(Painter &);
64 #else
65     ///
66     void Draw(long unsigned pm, int x, int y);
67     ///
68     void Redraw();
69 #endif
70     ///
71     void Delete();
72     ///
73     void DelLine();
74     ///
75     void SetPos(int, int);
76     ///
77     void GetPos(int & x, int & y) { cursor->GetPos(x, y); }
78     ///
79     short GetFCode() { return cursor->FCode(); }
80     ///
81     MathParInset * GetPar() { return par; }
82     ///
83     MathParInset * getCurrentPar() const { return cursor->p; }
84     ///
85     void SetPar(MathParInset *);
86     ///
87     void Interpret(char const *);
88     ///
89     void SetSize(short);
90     ///
91     void setNumbered();
92     void setLabel(char const *);
93     ///
94     bool Limits();
95     /// Set accent: if argument = 0 it's considered consumed 
96     void setAccent(int ac = 0);
97     /// Returns last accent
98     int getAccent() const;
99     ///
100     bool IsEnd() const { return !cursor->OK(); }
101     // Macro mode methods
102     ///
103     void MacroModeOpen();
104     ///
105     void MacroModeClose();
106     ///
107     bool InMacroMode() { return macro_mode; }
108     
109     // Local selection methods
110     ///
111     bool Selection() { return selection; }
112     ///
113     void SelCopy();
114     ///
115     void SelCut();
116     ///
117     void SelDel();
118     ///
119     void SelPaste();
120     ///
121     void SelStart();
122     ///
123     void SelClear();
124     ///
125     void SelBalance();
126 #ifdef USE_PAINTER
127         void SelGetArea(int * xp, int * yp, int & n);
128 #else
129     ///
130     XPoint * SelGetArea(int &);
131 #endif
132     ///
133     void clearLastCode() { lastcode = LM_TC_MIN; }
134     ///
135     void setLastCode(MathedTextCodes t) { lastcode = t; }
136     ///
137     MathedTextCodes getLastCode() const { return lastcode; }
138     
139  protected:
140     ///
141     bool macro_mode;
142     ///
143     void MacroModeBack();
144     ///
145     void MacroModeInsert(char);
146     
147     // Selection stuff
148     ///
149     bool selection;
150     ///
151     int  selpos;
152     ///
153     MathedXIter cursel, * anchor;
154     ///
155 //    LyxArrayBase *selarray; 
156     ///
157     Bool is_visible;
158     ///
159     long unsigned win;
160     ///
161     MathParInset * par;
162     ///
163     MathedXIter * cursor;
164     ///
165     int xc, yc;
166     ///
167     void doAccent(byte c, MathedTextCodes t);
168     ///
169     void doAccent(MathedInset * p);
170     ///
171     int accent;
172         ///
173     int nestaccent[8];
174         ///
175     MathedTextCodes lastcode;
176
177  private:
178         ///
179     char macrobf[80];
180         ///
181     int macroln;
182         ///
183     MathFuncInset * imacro;
184 };
185
186
187 //--------------------   Inline Functions  -------------------------// 
188
189
190 #endif