tesseract  4.0.0-1-g2a2b
callcpp.cpp File Reference
#include "callcpp.h"
#include <cstdarg>
#include <cstdio>
#include <memory>
#include "scrollview.h"
#include "tprintf.h"

Go to the source code of this file.

Functions

void cprintf (const char *format,...)
 
ScrollViewc_create_window (const char *name, int16_t xpos, int16_t ypos, int16_t xsize, int16_t ysize, double xmin, double xmax, double ymin, double ymax)
 
void c_line_color_index (void *win, C_COL index)
 
void c_move (void *win, double x, double y)
 
void c_draw (void *win, double x, double y)
 
void c_make_current (void *win)
 
void c_clear_window (void *win)
 
char window_wait (ScrollView *win)
 
void reverse32 (void *ptr)
 
void reverse16 (void *ptr)
 

Function Documentation

◆ c_clear_window()

void c_clear_window ( void *  win)

Definition at line 97 of file callcpp.cpp.

98  {
99  ScrollView* window = (ScrollView*) win;
100  window->Clear();
101 }
void Clear()
Definition: scrollview.cpp:591

◆ c_create_window()

ScrollView* c_create_window ( const char *  name,
int16_t  xpos,
int16_t  ypos,
int16_t  xsize,
int16_t  ysize,
double  xmin,
double  xmax,
double  ymin,
double  ymax 
)

Definition at line 48 of file callcpp.cpp.

58  {
59  return new ScrollView(name, xpos, ypos, xsize, ysize, xmax - xmin, ymax - ymin, true);
60 }

◆ c_draw()

void c_draw ( void *  win,
double  x,
double  y 
)

Definition at line 81 of file callcpp.cpp.

84  {
85  ScrollView* window = (ScrollView*) win;
86  window->DrawTo((int) x, (int) y);
87 }
void DrawTo(int x, int y)
Definition: scrollview.cpp:527

◆ c_line_color_index()

void c_line_color_index ( void *  win,
C_COL  index 
)

Definition at line 63 of file callcpp.cpp.

65  {
66  // The colors are the same as the SV ones except that SV has COLOR:NONE --> offset of 1
67  ScrollView* window = (ScrollView*) win;
68  window->Pen((ScrollView::Color) (index + 1));
69 }
void Pen(Color color)
Definition: scrollview.cpp:722

◆ c_make_current()

void c_make_current ( void *  win)

Definition at line 90 of file callcpp.cpp.

91  {
92  ScrollView* window = (ScrollView*) win;
93  window->Update();
94 }
static void Update()
Definition: scrollview.cpp:711

◆ c_move()

void c_move ( void *  win,
double  x,
double  y 
)

Definition at line 72 of file callcpp.cpp.

75  {
76  ScrollView* window = (ScrollView*) win;
77  window->SetCursor((int) x, (int) y);
78 }
void SetCursor(int x, int y)
Definition: scrollview.cpp:521

◆ cprintf()

void cprintf ( const char *  format,
  ... 
)

Definition at line 33 of file callcpp.cpp.

35  {
36  va_list args; //variable args
37  char msg[1000];
38 
39  va_start(args, format); //variable list
40  vsprintf(msg, format, args); //Format into msg
41  va_end(args);
42 
43  tprintf ("%s", msg);
44 }
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37

◆ reverse16()

void reverse16 ( void *  ptr)

Definition at line 131 of file callcpp.cpp.

131  {
132  char tmp;
133  char *cptr = (char *) ptr;
134 
135  tmp = *cptr;
136  *cptr = *(cptr + 1);
137  *(cptr + 1) = tmp;
138 }

◆ reverse32()

void reverse32 ( void *  ptr)

Definition at line 118 of file callcpp.cpp.

118  {
119  char tmp;
120  char *cptr = (char *) ptr;
121 
122  tmp = *cptr;
123  *cptr = *(cptr + 3);
124  *(cptr + 3) = tmp;
125  tmp = *(cptr + 1);
126  *(cptr + 1) = *(cptr + 2);
127  *(cptr + 2) = tmp;
128 }

◆ window_wait()

char window_wait ( ScrollView win)

Definition at line 104 of file callcpp.cpp.

104  {
105  // Wait till an input or click event (all others are thrown away)
106  char ret = '\0';
107  SVEventType ev_type = SVET_ANY;
108  do {
109  std::unique_ptr<SVEvent> ev(win->AwaitEvent(SVET_ANY));
110  ev_type = ev->type;
111  if (ev_type == SVET_INPUT)
112  ret = ev->parameter[0];
113  } while (ev_type != SVET_INPUT && ev_type != SVET_CLICK);
114  return ret;
115 }
SVEventType
Definition: scrollview.h:45
SVEvent * AwaitEvent(SVEventType type)
Definition: scrollview.cpp:445