1 |
673 |
markom |
/*
|
2 |
|
|
* Copyright (c) 2000 Greg Haerr <greg@censoft.com>
|
3 |
|
|
*
|
4 |
|
|
* Copyright © 1999 Keith Packard
|
5 |
|
|
*
|
6 |
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
7 |
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
8 |
|
|
* the above copyright notice appear in all copies and that both that
|
9 |
|
|
* copyright notice and this permission notice appear in supporting
|
10 |
|
|
* documentation, and that the name of Keith Packard not be used in
|
11 |
|
|
* advertising or publicity pertaining to distribution of the software without
|
12 |
|
|
* specific, written prior permission. Keith Packard makes no
|
13 |
|
|
* representations about the suitability of this software for any purpose. It
|
14 |
|
|
* is provided "as is" without express or implied warranty.
|
15 |
|
|
*
|
16 |
|
|
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
17 |
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
18 |
|
|
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
19 |
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
20 |
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
21 |
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
22 |
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
23 |
|
|
*/
|
24 |
|
|
|
25 |
|
|
#define MWINCLUDECOLORS
|
26 |
|
|
#include "nano-X.h"
|
27 |
|
|
#include "hre_api.h"
|
28 |
|
|
#include "li_recognizer.h"
|
29 |
|
|
|
30 |
|
|
#define CS_LETTERS 0
|
31 |
|
|
#define CS_DIGITS 1
|
32 |
|
|
#define CS_PUNCTUATION 2
|
33 |
|
|
|
34 |
|
|
#define NUM_RECS 3
|
35 |
|
|
#define DEFAULT_REC_DIR "classifiers"
|
36 |
|
|
#ifndef REC_DEFAULT_USER_DIR
|
37 |
|
|
#define REC_DEFAULT_USER_DIR "bin"
|
38 |
|
|
#endif
|
39 |
|
|
/*#define REC_DEFAULT_USER_DIR "/home/greg/net/microwin/src/apps/scribble"*/
|
40 |
|
|
/*#define CLASSIFIER_DIR ".classifiers"*/
|
41 |
|
|
#define DEFAULT_LETTERS_FILE "letters.cl"
|
42 |
|
|
#define DEFAULT_DIGITS_FILE "digits.cl"
|
43 |
|
|
#define DEFAULT_PUNC_FILE "punc.cl"
|
44 |
|
|
#define rec_name "libli_recog.so"
|
45 |
|
|
|
46 |
|
|
struct graffiti {
|
47 |
|
|
recognizer rec[3]; /* 3 recognizers, one each for letters, digits,
|
48 |
|
|
and punctuation */
|
49 |
|
|
char cldir[200]; /* directory in which the current classifier
|
50 |
|
|
files are found */
|
51 |
|
|
li_recognizer_train rec_train; /* pointer to training function */
|
52 |
|
|
li_recognizer_getClasses rec_getClasses;
|
53 |
|
|
/* pointer to the function that lists
|
54 |
|
|
the characters in the classifier
|
55 |
|
|
file. */
|
56 |
|
|
};
|
57 |
|
|
|
58 |
|
|
typedef struct {
|
59 |
|
|
/* private state */
|
60 |
|
|
GR_WINDOW_ID win;
|
61 |
|
|
GR_GC_ID gc;
|
62 |
|
|
GR_BOOL down; /* mouse is down*/
|
63 |
|
|
/*GR_WINDOW_ID lastfocusid;*/ /* last window with focus*/
|
64 |
|
|
GR_POINT *pt; /* points */
|
65 |
|
|
int ppasize;
|
66 |
|
|
pen_stroke ps;
|
67 |
|
|
struct graffiti graf;
|
68 |
|
|
int capsLock;
|
69 |
|
|
int puncShift;
|
70 |
|
|
int tmpShift;
|
71 |
|
|
int ctrlShift;
|
72 |
|
|
int curCharSet;
|
73 |
|
|
int lastchar;
|
74 |
|
|
} ScribbleRec, *ScribbleWidget;
|
75 |
|
|
|
76 |
|
|
ScribbleWidget create_scribble(void);
|
77 |
|
|
void destroy_scribble(ScribbleWidget w);
|
78 |
|
|
void ActionStart(ScribbleWidget w, int x, int y);
|
79 |
|
|
void ActionMove(ScribbleWidget w, int x, int y);
|
80 |
|
|
void ActionEnd(ScribbleWidget w, int x, int y);
|
81 |
|
|
void Redisplay (ScribbleWidget w);
|