2 /**************************************************************************
3 ** (c) Copyright 1998, Andromeda Technology & Automation
4 ***************************************************************************
5 ** MODULE INFORMATION *
6 ***********************
8 ** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation
9 ** VERSION NUMBER : $Revision: 1.1 $
11 ** DESCRIPTION : Definition of text editor classes
16 ***************************************************************************
17 ** ADMINISTRATIVE INFORMATION *
18 ********************************
19 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
20 ** CREATION DATE : Mar 13, 1998
21 ** LAST UPDATE : Jun 18, 1998
23 **************************************************************************/
25 /*****************************
27 Revision 1.1 2002-07-25 08:01:26 arjen
28 First checkin, AXE release 0.2
30 *****************************/
32 /* static const char *RCSID = "$Id: edit.h,v 1.1 2002-07-25 08:01:26 arjen Exp $"; */
42 ///////////////////////////////////////////////////////////////////////////
45 // MEMBERS : cursor_position : Index in the text string where edit
46 // operations occur. A visible cursor is drawn before
47 // that character when we have the focus.
48 // selected_until : If text is selected, this is the index
49 // in the text string that marks the end of the selec-
50 // ted text. Characters are selected from the
51 // cursor_position until here or vice versa.
59 // LAST MODIFIED : Jun 18, 1998
60 ///////////////////////////////////////////////////////////////////////////
63 class edit : public window
65 int selected_until; // End of selected text
66 int text_position; // Graphical position in window.
68 enum { No_Focus, Implicit_Focus, Explicit_Focus } focus_state;
71 int map_to_textposition(int x);
72 int map_to_pixelposition(int tp);
73 void toggle_cursor(void);
78 int cursor_position; // Text cursor in String
80 virtual int EV_KeyPress(XKeyEvent ev);
81 virtual int EV_ButtonPress(XButtonEvent ev);
82 virtual int EV_ButtonRelease(XButtonEvent ev);
83 virtual int EV_MotionNotify(XMotionEvent ev);
84 virtual int EV_FocusIn(XFocusChangeEvent ev);
85 virtual int EV_FocusOut(XFocusChangeEvent ev);
86 virtual int EV_EnterNotify(XCrossingEvent ev);
87 virtual int EV_LeaveNotify(XCrossingEvent ev);
91 edit(window &par, int x, int y, const String &txt)
92 : window(par, x, y, 100, 20)
98 focus_state = No_Focus;
99 SelectInput(ExposureMask|KeyPressMask, 1);
100 SelectInput(EnterWindowMask|LeaveWindowMask|FocusChangeMask, 1);
101 SelectInput(ButtonPressMask|Button1MotionMask|ButtonReleaseMask, 1);
102 XDefineCursor(stddpy, ID(), text_cursor);
105 edit & operator =(const String &s)
120 virtual int EV_Expose(XExposeEvent ev)
126 virtual void enter(void);
127 virtual void focuslost(void);
129 void SelectAll(void);
130 int ClearSelection(void);
131 int DeleteSelection(void);
134 #endif /* AXE_EDIT_H */