tesseract  5.0.0
tesseract::ScrollView Class Reference

#include <scrollview.h>

Public Types

enum  Color {
  NONE , BLACK , WHITE , RED ,
  YELLOW , GREEN , CYAN , BLUE ,
  MAGENTA , AQUAMARINE , DARK_SLATE_BLUE , LIGHT_BLUE ,
  MEDIUM_BLUE , MIDNIGHT_BLUE , NAVY_BLUE , SKY_BLUE ,
  SLATE_BLUE , STEEL_BLUE , CORAL , BROWN ,
  SANDY_BROWN , GOLD , GOLDENROD , DARK_GREEN ,
  DARK_OLIVE_GREEN , FOREST_GREEN , LIME_GREEN , PALE_GREEN ,
  YELLOW_GREEN , LIGHT_GREY , DARK_SLATE_GREY , DIM_GREY ,
  GREY , KHAKI , MAROON , ORANGE ,
  ORCHID , PINK , PLUM , INDIAN_RED ,
  ORANGE_RED , VIOLET_RED , SALMON , TAN ,
  TURQUOISE , DARK_TURQUOISE , VIOLET , WHEAT ,
  GREEN_YELLOW
}
 

Public Member Functions

 ~ScrollView ()
 
 ScrollView (const char *name, int x_pos, int y_pos, int x_size, int y_size, int x_canvas_size, int y_canvas_size)
 Calls Initialize with default argument for server_name_ & y_axis_reversed. More...
 
 ScrollView (const char *name, int x_pos, int y_pos, int x_size, int y_size, int x_canvas_size, int y_canvas_size, bool y_axis_reversed)
 Calls Initialize with default argument for server_name_. More...
 
 ScrollView (const char *name, int x_pos, int y_pos, int x_size, int y_size, int x_canvas_size, int y_canvas_size, bool y_axis_reversed, const char *server_name)
 Calls Initialize with all arguments given. More...
 
void AddEventHandler (SVEventHandler *listener)
 Add an Event Listener to this ScrollView Window. More...
 
SVEventAwaitEvent (SVEventType type)
 
const char * GetName ()
 
int GetId ()
 
void Draw (Image image, int x_pos, int y_pos)
 
void UpdateWindow ()
 
void Clear ()
 
void Pen (Color color)
 
void Pen (int red, int green, int blue)
 
void Pen (int red, int green, int blue, int alpha)
 
void Brush (Color color)
 
void Brush (int red, int green, int blue)
 
void Brush (int red, int green, int blue, int alpha)
 
void TextAttributes (const char *font, int pixel_size, bool bold, bool italic, bool underlined)
 
void Line (int x1, int y1, int x2, int y2)
 
void Stroke (float width)
 
void Rectangle (int x1, int y1, int x2, int y2)
 
void Ellipse (int x, int y, int width, int height)
 
void Text (int x, int y, const char *mystring)
 
void Draw (const char *image, int x_pos, int y_pos)
 
void SetCursor (int x, int y)
 
void DrawTo (int x, int y)
 
void SetVisible (bool visible)
 
void AlwaysOnTop (bool b)
 
int ShowYesNoDialog (const char *msg)
 
char * ShowInputDialog (const char *msg)
 
void AddMessageBox ()
 
void AddMessage (const char *message)
 
void AddMessageF (const char *format,...) __attribute__((format(printf
 
void void ZoomToRectangle (int x1, int y1, int x2, int y2)
 
void SendMsg (const char *msg,...) __attribute__((format(printf
 Send a message to the server, attaching the window id. More...
 
void MenuItem (const char *parent, const char *name)
 
void MenuItem (const char *parent, const char *name, int cmdEvent)
 
void MenuItem (const char *parent, const char *name, int cmdEvent, bool flagged)
 
void PopupItem (const char *parent, const char *name)
 
void PopupItem (const char *parent, const char *name, int cmdEvent, const char *value, const char *desc)
 
int TranslateYCoordinate (int y)
 
char Wait ()
 

Static Public Member Functions

static void Update ()
 
static void Exit ()
 
void static void SendRawMessage (const char *msg)
 

Detailed Description

Definition at line 108 of file scrollview.h.

Member Enumeration Documentation

◆ Color

Enumerator
NONE 
BLACK 
WHITE 
RED 
YELLOW 
GREEN 
CYAN 
BLUE 
MAGENTA 
AQUAMARINE 
DARK_SLATE_BLUE 
LIGHT_BLUE 
MEDIUM_BLUE 
MIDNIGHT_BLUE 
NAVY_BLUE 
SKY_BLUE 
SLATE_BLUE 
STEEL_BLUE 
CORAL 
BROWN 
SANDY_BROWN 
GOLD 
GOLDENROD 
DARK_GREEN 
DARK_OLIVE_GREEN 
FOREST_GREEN 
LIME_GREEN 
PALE_GREEN 
YELLOW_GREEN 
LIGHT_GREY 
DARK_SLATE_GREY 
DIM_GREY 
GREY 
KHAKI 
MAROON 
ORANGE 
ORCHID 
PINK 
PLUM 
INDIAN_RED 
ORANGE_RED 
VIOLET_RED 
SALMON 
TAN 
TURQUOISE 
DARK_TURQUOISE 
VIOLET 
WHEAT 
GREEN_YELLOW 

Definition at line 111 of file scrollview.h.

111  {
112  NONE,
113  BLACK,
114  WHITE,
115  RED,
116  YELLOW,
117  GREEN,
118  CYAN,
119  BLUE,
120  MAGENTA,
121  AQUAMARINE,
123  LIGHT_BLUE,
124  MEDIUM_BLUE,
126  NAVY_BLUE,
127  SKY_BLUE,
128  SLATE_BLUE,
129  STEEL_BLUE,
130  CORAL,
131  BROWN,
132  SANDY_BROWN,
133  GOLD,
134  GOLDENROD,
135  DARK_GREEN,
137  FOREST_GREEN,
138  LIME_GREEN,
139  PALE_GREEN,
140  YELLOW_GREEN,
141  LIGHT_GREY,
143  DIM_GREY,
144  GREY,
145  KHAKI,
146  MAROON,
147  ORANGE,
148  ORCHID,
149  PINK,
150  PLUM,
151  INDIAN_RED,
152  ORANGE_RED,
153  VIOLET_RED,
154  SALMON,
155  TAN,
156  TURQUOISE,
158  VIOLET,
159  WHEAT,
160  GREEN_YELLOW // Make sure this one is last.
161  };

Constructor & Destructor Documentation

◆ ~ScrollView()

tesseract::ScrollView::~ScrollView ( )

Definition at line 362 of file scrollview.cpp.

362  {
363 #ifndef GRAPHICS_DISABLED
364  svmap_mu->lock();
365  if (svmap[window_id_] != nullptr) {
366  svmap_mu->unlock();
367  // So the event handling thread can quit.
368  SendMsg("destroy()");
369 
370  SVEvent *sve = AwaitEvent(SVET_DESTROY);
371  delete sve;
372  svmap_mu->lock();
373  svmap[window_id_] = nullptr;
374  svmap_mu->unlock();
375  // The event handler thread for this window *must* receive the
376  // destroy event and set its pointer to this to nullptr before we allow
377  // the destructor to exit.
378  while (!event_handler_ended_) {
379  Update();
380  }
381  } else {
382  svmap_mu->unlock();
383  }
384  delete semaphore_;
385  delete points_;
386  for (auto &i : event_table_) {
387  delete i;
388  }
389 #endif // !GRAPHICS_DISABLED
390 }
@ SVET_DESTROY
Definition: scrollview.h:53
static void Update()
Definition: scrollview.cpp:713
SVEvent * AwaitEvent(SVEventType type)
Definition: scrollview.cpp:445
void SendMsg(const char *msg,...) __attribute__((format(printf
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:394

◆ ScrollView() [1/3]

tesseract::ScrollView::ScrollView ( const char *  name,
int  x_pos,
int  y_pos,
int  x_size,
int  y_size,
int  x_canvas_size,
int  y_canvas_size 
)

Calls Initialize with default argument for server_name_ & y_axis_reversed.

Definition at line 264 of file scrollview.cpp.

265  {
266  Initialize(name, x_pos, y_pos, x_size, y_size, x_canvas_size, y_canvas_size, false, "localhost");
267 }

◆ ScrollView() [2/3]

tesseract::ScrollView::ScrollView ( const char *  name,
int  x_pos,
int  y_pos,
int  x_size,
int  y_size,
int  x_canvas_size,
int  y_canvas_size,
bool  y_axis_reversed 
)

Calls Initialize with default argument for server_name_.

Definition at line 257 of file scrollview.cpp.

258  {
259  Initialize(name, x_pos, y_pos, x_size, y_size, x_canvas_size, y_canvas_size, y_axis_reversed,
260  "localhost");
261 }

◆ ScrollView() [3/3]

tesseract::ScrollView::ScrollView ( const char *  name,
int  x_pos,
int  y_pos,
int  x_size,
int  y_size,
int  x_canvas_size,
int  y_canvas_size,
bool  y_axis_reversed,
const char *  server_name 
)

Calls Initialize with all arguments given.

Definition at line 249 of file scrollview.cpp.

251  {
252  Initialize(name, x_pos, y_pos, x_size, y_size, x_canvas_size, y_canvas_size, y_axis_reversed,
253  server_name);
254 }

Member Function Documentation

◆ AddEventHandler()

void tesseract::ScrollView::AddEventHandler ( SVEventHandler listener)

Add an Event Listener to this ScrollView Window.

Definition at line 418 of file scrollview.cpp.

418  {
419  event_handler_ = listener;
420 }

◆ AddMessage()

void tesseract::ScrollView::AddMessage ( const char *  message)

Definition at line 546 of file scrollview.cpp.

546  {
547  char form[kMaxMsgSize];
548  snprintf(form, sizeof(form), "w%u:%s", window_id_, message);
549 
550  char *esc = AddEscapeChars(form);
551  SendMsg("addMessage(\"%s\")", esc);
552  delete[] esc;
553 }
const int kMaxMsgSize
Definition: scrollview.cpp:46

◆ AddMessageBox()

void tesseract::ScrollView::AddMessageBox ( )

Definition at line 567 of file scrollview.cpp.

567  {
568  SendMsg("addMessageBox()");
569 }

◆ AddMessageF()

void tesseract::ScrollView::AddMessageF ( const char *  format,
  ... 
)

Definition at line 555 of file scrollview.cpp.

555  {
556  va_list args;
557  char message[kMaxMsgSize - 4];
558 
559  va_start(args, format); // variable list
560  vsnprintf(message, sizeof(message), format, args);
561  va_end(args);
562 
563  AddMessage(message);
564 }
void AddMessage(const char *message)
Definition: scrollview.cpp:546

◆ AlwaysOnTop()

void tesseract::ScrollView::AlwaysOnTop ( bool  b)

Definition at line 537 of file scrollview.cpp.

537  {
538  if (b) {
539  SendMsg("setAlwaysOnTop(true)");
540  } else {
541  SendMsg("setAlwaysOnTop(false)");
542  }
543 }

◆ AwaitEvent()

SVEvent * tesseract::ScrollView::AwaitEvent ( SVEventType  type)

Block until an event of the given type is received. Note: The calling function is responsible for deleting the returned SVEvent afterwards!

Definition at line 445 of file scrollview.cpp.

445  {
446  // Initialize the waiting semaphore.
447  auto *sem = new SVSemaphore();
448  std::pair<ScrollView *, SVEventType> ea(this, type);
449  waiting_for_events_mu->lock();
450  waiting_for_events[ea] = std::pair<SVSemaphore *, SVEvent *>(sem, (SVEvent *)nullptr);
451  waiting_for_events_mu->unlock();
452  // Wait on it, but first flush.
453  stream_->Flush();
454  sem->Wait();
455  // Process the event we got woken up for (its in waiting_for_events pair).
456  waiting_for_events_mu->lock();
457  SVEvent *ret = waiting_for_events[ea].second;
458  waiting_for_events.erase(ea);
459  delete sem;
460  waiting_for_events_mu->unlock();
461  return ret;
462 }
void Flush()
Flush the buffer.
Definition: svutil.cpp:170

◆ Brush() [1/3]

void tesseract::ScrollView::Brush ( Color  color)

Definition at line 729 of file scrollview.cpp.

729  {
730  Brush(table_colors[color][0], table_colors[color][1], table_colors[color][2],
731  table_colors[color][3]);
732 }
void Brush(Color color)
Definition: scrollview.cpp:729

◆ Brush() [2/3]

void tesseract::ScrollView::Brush ( int  red,
int  green,
int  blue 
)

Definition at line 613 of file scrollview.cpp.

613  {
614  SendMsg("brush(%d,%d,%d)", red, green, blue);
615 }

◆ Brush() [3/3]

void tesseract::ScrollView::Brush ( int  red,
int  green,
int  blue,
int  alpha 
)

Definition at line 618 of file scrollview.cpp.

618  {
619  SendMsg("brush(%d,%d,%d,%d)", red, green, blue, alpha);
620 }

◆ Clear()

void tesseract::ScrollView::Clear ( )

Definition at line 578 of file scrollview.cpp.

578  {
579  SendMsg("clear()");
580 }

◆ Draw() [1/2]

void tesseract::ScrollView::Draw ( const char *  image,
int  x_pos,
int  y_pos 
)

Definition at line 653 of file scrollview.cpp.

653  {
654  SendMsg("openImage('%s')", image);
655  SendMsg("drawImage('%s',%d,%d)", image, x_pos, TranslateYCoordinate(y_pos));
656 }
int TranslateYCoordinate(int y)
Definition: scrollview.cpp:826

◆ Draw() [2/2]

void tesseract::ScrollView::Draw ( Image  image,
int  x_pos,
int  y_pos 
)

Definition at line 767 of file scrollview.cpp.

767  {
768  l_uint8 *data;
769  size_t size;
770  pixWriteMem(&data, &size, image, IFF_PNG);
771  int base64_len = (size + 2) / 3 * 4;
772  y_pos = TranslateYCoordinate(y_pos);
773  SendMsg("readImage(%d,%d,%d)", x_pos, y_pos, base64_len);
774  // Base64 encode the data.
775  const char kBase64Table[64] = {
776  'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
777  'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
778  'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
779  'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/',
780  };
781  char *base64 = new char[base64_len + 1];
782  memset(base64, '=', base64_len);
783  base64[base64_len] = '\0';
784  int remainder = 0;
785  int bits_left = 0;
786  int code_len = 0;
787  for (size_t i = 0; i < size; ++i) {
788  int code = (data[i] >> (bits_left + 2)) | remainder;
789  base64[code_len++] = kBase64Table[code & 63];
790  bits_left += 2;
791  remainder = data[i] << (6 - bits_left);
792  if (bits_left == 6) {
793  base64[code_len++] = kBase64Table[remainder & 63];
794  bits_left = 0;
795  remainder = 0;
796  }
797  }
798  if (bits_left > 0) {
799  base64[code_len++] = kBase64Table[remainder & 63];
800  }
801  SendRawMessage(base64);
802  delete[] base64;
803  lept_free(data);
804 }
void static void SendRawMessage(const char *msg)
Definition: scrollview.cpp:413

◆ DrawTo()

void tesseract::ScrollView::DrawTo ( int  x,
int  y 
)

Definition at line 504 of file scrollview.cpp.

504  {
505  points_->xcoords.push_back(x);
506  points_->ycoords.push_back(TranslateYCoordinate(y));
507  points_->empty = false;
508 }
std::vector< int > xcoords
Definition: scrollview.cpp:51
std::vector< int > ycoords
Definition: scrollview.cpp:52

◆ Ellipse()

void tesseract::ScrollView::Ellipse ( int  x,
int  y,
int  width,
int  height 
)

Definition at line 598 of file scrollview.cpp.

598  {
599  SendMsg("drawEllipse(%d,%d,%u,%u)", x1, TranslateYCoordinate(y1), width, height);
600 }

◆ Exit()

void tesseract::ScrollView::Exit ( )
static

Definition at line 572 of file scrollview.cpp.

572  {
573  SendRawMessage("svmain:exit()");
574  exit(0);
575 }

◆ GetId()

int tesseract::ScrollView::GetId ( )
inline

Definition at line 201 of file scrollview.h.

201  {
202  return window_id_;
203  }

◆ GetName()

const char* tesseract::ScrollView::GetName ( )
inline

Definition at line 196 of file scrollview.h.

196  {
197  return window_name_;
198  }

◆ Line()

void tesseract::ScrollView::Line ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 511 of file scrollview.cpp.

511  {
512  if (!points_->xcoords.empty() && x1 == points_->xcoords.back() &&
513  TranslateYCoordinate(y1) == points_->ycoords.back()) {
514  // We are already at x1, y1, so just draw to x2, y2.
515  DrawTo(x2, y2);
516  } else if (!points_->xcoords.empty() && x2 == points_->xcoords.back() &&
517  TranslateYCoordinate(y2) == points_->ycoords.back()) {
518  // We are already at x2, y2, so just draw to x1, y1.
519  DrawTo(x1, y1);
520  } else {
521  // This is a new line.
522  SetCursor(x1, y1);
523  DrawTo(x2, y2);
524  }
525 }
void SetCursor(int x, int y)
Definition: scrollview.cpp:498
void DrawTo(int x, int y)
Definition: scrollview.cpp:504

◆ MenuItem() [1/3]

void tesseract::ScrollView::MenuItem ( const char *  parent,
const char *  name 
)

Definition at line 679 of file scrollview.cpp.

679  {
680  if (parent == nullptr) {
681  parent = "";
682  }
683  SendMsg("addMenuBarItem('%s','%s')", parent, name);
684 }

◆ MenuItem() [2/3]

void tesseract::ScrollView::MenuItem ( const char *  parent,
const char *  name,
int  cmdEvent 
)

Definition at line 671 of file scrollview.cpp.

671  {
672  if (parent == nullptr) {
673  parent = "";
674  }
675  SendMsg("addMenuBarItem('%s','%s',%d)", parent, name, cmdEvent);
676 }

◆ MenuItem() [3/3]

void tesseract::ScrollView::MenuItem ( const char *  parent,
const char *  name,
int  cmdEvent,
bool  flagged 
)

Definition at line 659 of file scrollview.cpp.

659  {
660  if (parent == nullptr) {
661  parent = "";
662  }
663  if (flag) {
664  SendMsg("addMenuBarItem('%s','%s',%d,true)", parent, name, cmdEvent);
665  } else {
666  SendMsg("addMenuBarItem('%s','%s',%d,false)", parent, name, cmdEvent);
667  }
668 }

◆ Pen() [1/3]

void tesseract::ScrollView::Pen ( Color  color)

Definition at line 723 of file scrollview.cpp.

723  {
724  Pen(table_colors[color][0], table_colors[color][1], table_colors[color][2],
725  table_colors[color][3]);
726 }
void Pen(Color color)
Definition: scrollview.cpp:723

◆ Pen() [2/3]

void tesseract::ScrollView::Pen ( int  red,
int  green,
int  blue 
)

Definition at line 603 of file scrollview.cpp.

603  {
604  SendMsg("pen(%d,%d,%d)", red, green, blue);
605 }

◆ Pen() [3/3]

void tesseract::ScrollView::Pen ( int  red,
int  green,
int  blue,
int  alpha 
)

Definition at line 608 of file scrollview.cpp.

608  {
609  SendMsg("pen(%d,%d,%d,%d)", red, green, blue, alpha);
610 }

◆ PopupItem() [1/2]

void tesseract::ScrollView::PopupItem ( const char *  parent,
const char *  name 
)

Definition at line 687 of file scrollview.cpp.

687  {
688  if (parent == nullptr) {
689  parent = "";
690  }
691  SendMsg("addPopupMenuItem('%s','%s')", parent, name);
692 }

◆ PopupItem() [2/2]

void tesseract::ScrollView::PopupItem ( const char *  parent,
const char *  name,
int  cmdEvent,
const char *  value,
const char *  desc 
)

Definition at line 695 of file scrollview.cpp.

696  {
697  if (parent == nullptr) {
698  parent = "";
699  }
700  char *esc = AddEscapeChars(value);
701  char *esc2 = AddEscapeChars(desc);
702  SendMsg("addPopupMenuItem('%s','%s',%d,'%s','%s')", parent, name, cmdEvent, esc, esc2);
703  delete[] esc;
704  delete[] esc2;
705 }

◆ Rectangle()

void tesseract::ScrollView::Rectangle ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 589 of file scrollview.cpp.

589  {
590  if (x1 == x2 && y1 == y2) {
591  return; // Scrollviewer locks up.
592  }
593  SendMsg("drawRectangle(%d,%d,%d,%d)", x1, TranslateYCoordinate(y1), x2, TranslateYCoordinate(y2));
594 }

◆ SendMsg()

void tesseract::ScrollView::SendMsg ( const char *  msg,
  ... 
)

Send a message to the server, attaching the window id.

Definition at line 394 of file scrollview.cpp.

394  {
395  if (!points_->empty) {
396  SendPolygon();
397  }
398  va_list args;
399  char message[kMaxMsgSize - 4];
400 
401  va_start(args, format); // variable list
402  vsnprintf(message, sizeof(message), format, args);
403  va_end(args);
404 
405  char form[kMaxMsgSize];
406  snprintf(form, sizeof(form), "w%u:%s\n", window_id_, message);
407 
408  stream_->Send(form);
409 }
void Send(const char *msg)
Put a message in the messagebuffer to the server and try to send it.
Definition: svutil.cpp:164

◆ SendRawMessage()

void tesseract::ScrollView::SendRawMessage ( const char *  msg)
static

Send a message to the server without a window id. Used for global events like exit().

Definition at line 413 of file scrollview.cpp.

413  {
414  stream_->Send(msg);
415 }

◆ SetCursor()

void tesseract::ScrollView::SetCursor ( int  x,
int  y 
)

Definition at line 498 of file scrollview.cpp.

498  {
499  SendPolygon();
500  DrawTo(x, y);
501 }

◆ SetVisible()

void tesseract::ScrollView::SetVisible ( bool  visible)

Definition at line 528 of file scrollview.cpp.

528  {
529  if (visible) {
530  SendMsg("setVisible(true)");
531  } else {
532  SendMsg("setVisible(false)");
533  }
534 }

◆ ShowInputDialog()

char * tesseract::ScrollView::ShowInputDialog ( const char *  msg)

Definition at line 735 of file scrollview.cpp.

735  {
736  SendMsg("showInputDialog(\"%s\")", msg);
737  SVEvent *ev;
738  // wait till an input event (all others are thrown away)
739  ev = AwaitEvent(SVET_INPUT);
740  char *p = new char[strlen(ev->parameter) + 1];
741  strcpy(p, ev->parameter);
742  delete ev;
743  return p;
744 }
@ SVET_INPUT
Definition: scrollview.h:57

◆ ShowYesNoDialog()

int tesseract::ScrollView::ShowYesNoDialog ( const char *  msg)

Definition at line 747 of file scrollview.cpp.

747  {
748  SendMsg("showYesNoDialog(\"%s\")", msg);
749  SVEvent *ev;
750  // Wait till an input event (all others are thrown away)
751  ev = AwaitEvent(SVET_INPUT);
752  int a = ev->parameter[0];
753  delete ev;
754  return a;
755 }

◆ Stroke()

void tesseract::ScrollView::Stroke ( float  width)

Definition at line 583 of file scrollview.cpp.

583  {
584  SendMsg("setStrokeWidth(%f)", width);
585 }

◆ Text()

void tesseract::ScrollView::Text ( int  x,
int  y,
const char *  mystring 
)

Definition at line 648 of file scrollview.cpp.

648  {
649  SendMsg("drawText(%d,%d,'%s')", x, TranslateYCoordinate(y), mystring);
650 }

◆ TextAttributes()

void tesseract::ScrollView::TextAttributes ( const char *  font,
int  pixel_size,
bool  bold,
bool  italic,
bool  underlined 
)

Definition at line 623 of file scrollview.cpp.

624  {
625  const char *b;
626  const char *i;
627  const char *u;
628 
629  if (bold) {
630  b = "true";
631  } else {
632  b = "false";
633  }
634  if (italic) {
635  i = "true";
636  } else {
637  i = "false";
638  }
639  if (underlined) {
640  u = "true";
641  } else {
642  u = "false";
643  }
644  SendMsg("textAttributes('%s',%u,%s,%s,%s)", font, pixel_size, b, i, u);
645 }

◆ TranslateYCoordinate()

int tesseract::ScrollView::TranslateYCoordinate ( int  y)

Definition at line 826 of file scrollview.cpp.

826  {
827  if (!y_axis_is_reversed_) {
828  return y;
829  } else {
830  return y_size_ - y;
831  }
832 }

◆ Update()

void tesseract::ScrollView::Update ( )
static

Definition at line 713 of file scrollview.cpp.

713  {
714  std::lock_guard<std::mutex> guard(*svmap_mu);
715  for (auto &iter : svmap) {
716  if (iter.second != nullptr) {
717  iter.second->UpdateWindow();
718  }
719  }
720 }

◆ UpdateWindow()

void tesseract::ScrollView::UpdateWindow ( )

Definition at line 708 of file scrollview.cpp.

708  {
709  SendMsg("update()");
710 }

◆ Wait()

char tesseract::ScrollView::Wait ( )

Definition at line 834 of file scrollview.cpp.

834  {
835  // Wait till an input or click event (all others are thrown away)
836  char ret = '\0';
837  SVEventType ev_type = SVET_ANY;
838  do {
839  std::unique_ptr<SVEvent> ev(AwaitEvent(SVET_ANY));
840  ev_type = ev->type;
841  if (ev_type == SVET_INPUT) {
842  ret = ev->parameter[0];
843  }
844  } while (ev_type != SVET_INPUT && ev_type != SVET_CLICK);
845  return ret;
846 }
@ SVET_CLICK
Definition: scrollview.h:55

◆ ZoomToRectangle()

void tesseract::ScrollView::ZoomToRectangle ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 759 of file scrollview.cpp.

759  {
760  y1 = TranslateYCoordinate(y1);
761  y2 = TranslateYCoordinate(y2);
762  SendMsg("zoomRectangle(%d,%d,%d,%d)", std::min(x1, x2), std::min(y1, y2), std::max(x1, x2),
763  std::max(y1, y2));
764 }

The documentation for this class was generated from the following files: