Browse CVS Repository
Annotation of /malonnote/mnTextCtrl.cpp
Parent Directory
| Revision Log
| Revision Graph
Revision 1.1 -
( hide annotations)
( download)
( as text)
Thu Aug 11 07:19:39 2005 UTC
(18 years, 7 months ago)
by maloninc
Branch: MAIN
CVS Tags: dev-1_1-0007
File MIME type: text/x-c++src
add
| 1 |
maloninc |
1.1 |
#include "mnTextCtrl.h" |
| 2 |
|
|
|
| 3 |
|
|
BEGIN_EVENT_TABLE(mnTextCtrl, wxTextCtrl) |
| 4 |
|
|
EVT_KEY_DOWN(mnTextCtrl::handleKeyDown) |
| 5 |
|
|
END_EVENT_TABLE() |
| 6 |
|
|
|
| 7 |
|
|
void mnTextCtrl::handleKeyDown(wxKeyEvent& event) |
| 8 |
|
|
{ |
| 9 |
|
|
long pos, x, y, oldY; |
| 10 |
|
|
bool isLineUp = FALSE; |
| 11 |
|
|
bool isLineDown = FALSE; |
| 12 |
|
|
|
| 13 |
|
|
if(event.ControlDown()) { |
| 14 |
|
|
pos = GetInsertionPoint(); |
| 15 |
|
|
PositionToXY(pos, &x, &y); |
| 16 |
|
|
|
| 17 |
|
|
switch(event.GetKeyCode()){ |
| 18 |
|
|
case 'N': // Next line |
| 19 |
|
|
oldY = y; |
| 20 |
|
|
y++; |
| 21 |
|
|
isLineDown = TRUE; |
| 22 |
|
|
break; |
| 23 |
|
|
|
| 24 |
|
|
case 'P': // Previous line |
| 25 |
|
|
oldY = y; |
| 26 |
|
|
y--; |
| 27 |
|
|
isLineUp = TRUE; |
| 28 |
|
|
break; |
| 29 |
|
|
|
| 30 |
|
|
case 'F': // Forward |
| 31 |
|
|
x++; |
| 32 |
|
|
break; |
| 33 |
|
|
|
| 34 |
|
|
case 'B': // Backward |
| 35 |
|
|
x--; |
| 36 |
|
|
break; |
| 37 |
|
|
|
| 38 |
|
|
case 'E': // End of line |
| 39 |
|
|
x = GetLineLength(y); |
| 40 |
|
|
break; |
| 41 |
|
|
|
| 42 |
|
|
case 'A': // Begin of line |
| 43 |
|
|
x = 0; |
| 44 |
|
|
break; |
| 45 |
|
|
|
| 46 |
|
|
case 'H': // Backspace |
| 47 |
|
|
Remove(pos-1, pos); |
| 48 |
|
|
x--; |
| 49 |
|
|
break; |
| 50 |
|
|
|
| 51 |
|
|
case 'D': // Delete |
| 52 |
|
|
Remove(pos, pos+1); |
| 53 |
|
|
break; |
| 54 |
|
|
|
| 55 |
|
|
default: |
| 56 |
|
|
event.Skip(); |
| 57 |
|
|
return; |
| 58 |
|
|
} |
| 59 |
|
|
|
| 60 |
|
|
pos = XYToPosition(x, y); |
| 61 |
|
|
if(isLineUp){ |
| 62 |
|
|
PositionToXY(pos, &x, &y); |
| 63 |
|
|
if(y != oldY - 1){ |
| 64 |
|
|
pos = XYToPosition(GetLineLength(oldY-1), oldY-1); |
| 65 |
|
|
} |
| 66 |
|
|
} |
| 67 |
|
|
else if(isLineDown) { |
| 68 |
|
|
PositionToXY(pos, &x, &y); |
| 69 |
|
|
if(y != oldY + 1) { |
| 70 |
|
|
pos = XYToPosition(GetLineLength(oldY+1), oldY+1); |
| 71 |
|
|
} |
| 72 |
|
|
} |
| 73 |
|
|
SetInsertionPoint(pos); |
| 74 |
|
|
return; |
| 75 |
|
|
} |
| 76 |
|
|
event.Skip(); |
| 77 |
|
|
} |
| |