Tesseract
3.02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
callcpp.cpp
Go to the documentation of this file.
1
/**********************************************************************
2
* File: callcpp.cpp
3
* Description: extern C interface calling C++ from C.
4
* Author: Ray Smith
5
* Created: Sun Feb 04 20:39:23 MST 1996
6
*
7
* (C) Copyright 1996, Hewlett-Packard Co.
8
** Licensed under the Apache License, Version 2.0 (the "License");
9
** you may not use this file except in compliance with the License.
10
** You may obtain a copy of the License at
11
** http://www.apache.org/licenses/LICENSE-2.0
12
** Unless required by applicable law or agreed to in writing, software
13
** distributed under the License is distributed on an "AS IS" BASIS,
14
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
** See the License for the specific language governing permissions and
16
** limitations under the License.
17
*
18
**********************************************************************/
19
20
// Include automatically generated configuration file if running autoconf.
21
#ifdef HAVE_CONFIG_H
22
#include "config_auto.h"
23
#endif
24
25
#include "
mfcpch.h
"
26
#include "
errcode.h
"
27
#ifdef __UNIX__
28
#include <assert.h>
29
#include <stdarg.h>
30
#endif
31
#include <time.h>
32
#include "
memry.h
"
33
#include "
scrollview.h
"
34
#include "
params.h
"
35
#include "
callcpp.h
"
36
#include "
tprintf.h
"
37
#include "
host.h
"
38
#include "
unichar.h
"
39
40
void
41
cprintf
(
//Trace printf
42
const
char
*format, ...
//special message
43
) {
44
va_list args;
//variable args
45
char
msg[1000];
46
47
va_start(args, format);
//variable list
48
vsprintf(msg, format, args);
//Format into msg
49
va_end(args);
50
51
tprintf
(
"%s"
, msg);
52
}
53
54
55
#ifndef GRAPHICS_DISABLED
56
ScrollView
*
c_create_window
(
/*create a window */
57
const
char
*name,
/*name/title of window */
58
inT16
xpos,
/*coords of window */
59
inT16
ypos,
/*coords of window */
60
inT16
xsize,
/*size of window */
61
inT16
ysize,
/*size of window */
62
double
xmin,
/*scrolling limits */
63
double
xmax,
/*to stop users */
64
double
ymin,
/*getting lost in */
65
double
ymax
/*empty space */
66
) {
67
return
new
ScrollView
(name, xpos, ypos, xsize, ysize, xmax - xmin, ymax - ymin,
true
);
68
}
69
70
71
void
c_line_color_index
(
/*set color */
72
void
*win,
73
C_COL
index) {
74
// The colors are the same as the SV ones except that SV has COLOR:NONE --> offset of 1
75
ScrollView
* window = (
ScrollView
*) win;
76
window->
Pen
((
ScrollView::Color
) (index + 1));
77
}
78
79
80
void
c_move
(
/*move pen */
81
void
*win,
82
double
x,
83
double
y) {
84
ScrollView
* window = (
ScrollView
*) win;
85
window->
SetCursor
((
int
) x, (
int
) y);
86
}
87
88
89
void
c_draw
(
/*move pen */
90
void
*win,
91
double
x,
92
double
y) {
93
ScrollView
* window = (
ScrollView
*) win;
94
window->
DrawTo
((
int
) x, (
int
) y);
95
}
96
97
98
void
c_make_current
(
/*move pen */
99
void
*win) {
100
ScrollView
* window = (
ScrollView
*) win;
101
window->
Update
();
102
}
103
104
105
void
c_clear_window
(
/*move pen */
106
void
*win) {
107
ScrollView
* window = (
ScrollView
*) win;
108
window->
Clear
();
109
}
110
111
112
char
window_wait
(
ScrollView
* win) {
113
SVEvent
* ev;
114
// Wait till an input or click event (all others are thrown away)
115
char
ret =
'\0'
;
116
SVEventType
ev_type =
SVET_ANY
;
117
do
{
118
ev = win->
AwaitEvent
(
SVET_ANY
);
119
ev_type = ev->
type
;
120
if
(ev_type ==
SVET_INPUT
)
121
ret = ev->
parameter
[0];
122
delete
ev;
123
}
while
(ev_type !=
SVET_INPUT
&& ev_type !=
SVET_CLICK
);
124
return
ret;
125
}
126
#endif
127
128
void
reverse32
(
void
*ptr) {
129
char
tmp;
130
char
*cptr = (
char
*) ptr;
131
132
tmp = *cptr;
133
*cptr = *(cptr + 3);
134
*(cptr + 3) = tmp;
135
tmp = *(cptr + 1);
136
*(cptr + 1) = *(cptr + 2);
137
*(cptr + 2) = tmp;
138
}
139
140
141
void
reverse16
(
void
*ptr) {
142
char
tmp;
143
char
*cptr = (
char
*) ptr;
144
145
tmp = *cptr;
146
*cptr = *(cptr + 1);
147
*(cptr + 1) = tmp;
148
}
mnt
data
src
tesseract-ocr
cutil
callcpp.cpp
Generated on Thu Nov 1 2012 20:19:48 for Tesseract by
1.8.1