tesseract  4.1.0
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)
 
SVEventAwaitEventAnyWindow ()
 
const char * GetName ()
 
int GetId ()
 
void Image (struct Pix *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 Image (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 *format,...)
 
void ZoomToRectangle (int x1, int y1, int x2, int y2)
 
void SendMsg (const char *msg,...)
 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)
 

Static Public Member Functions

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

Detailed Description

Definition at line 102 of file scrollview.h.

Member Enumeration Documentation

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 105 of file scrollview.h.

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

Constructor & Destructor Documentation

ScrollView::~ScrollView ( )

Definition at line 359 of file scrollview.cpp.

359  {
360  #ifndef GRAPHICS_DISABLED
361  svmap_mu->Lock();
362  if (svmap[window_id_] != nullptr) {
363  svmap_mu->Unlock();
364  // So the event handling thread can quit.
365  SendMsg("destroy()");
366 
368  delete sve;
369  svmap_mu->Lock();
370  svmap[window_id_] = nullptr;
371  svmap_mu->Unlock();
372  // The event handler thread for this window *must* receive the
373  // destroy event and set its pointer to this to nullptr before we allow
374  // the destructor to exit.
375  while (!event_handler_ended_)
376  Update();
377  } else {
378  svmap_mu->Unlock();
379  }
380  delete mutex_;
381  delete semaphore_;
382  delete points_;
383  for (auto & i : event_table_) {
384  delete i;
385  }
386  #endif // GRAPHICS_DISABLED
387 }
void Lock()
Locks on a mutex.
Definition: svutil.cpp:63
SVEvent * AwaitEvent(SVEventType type)
Definition: scrollview.cpp:443
static void Update()
Definition: scrollview.cpp:709
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void Unlock()
Unlocks on a mutex.
Definition: svutil.cpp:71
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 262 of file scrollview.cpp.

263  {
264  Initialize(name, x_pos, y_pos, x_size, y_size, x_canvas_size, y_canvas_size,
265  false, "localhost");
266 }
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 254 of file scrollview.cpp.

256  {
257  Initialize(name, x_pos, y_pos, x_size, y_size, x_canvas_size, y_canvas_size,
258  y_axis_reversed, "localhost");
259 }
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 247 of file scrollview.cpp.

249  {
250  Initialize(name, x_pos, y_pos, x_size, y_size, x_canvas_size, y_canvas_size,
251  y_axis_reversed, server_name);}

Member Function Documentation

void ScrollView::AddEventHandler ( SVEventHandler listener)

Add an Event Listener to this ScrollView Window.

Definition at line 414 of file scrollview.cpp.

414  {
415  event_handler_ = listener;
416 }
void ScrollView::AddMessage ( const char *  format,
  ... 
)

Definition at line 561 of file scrollview.cpp.

561  {
562  va_list args;
563  char message[kMaxMsgSize - 4];
564 
565  va_start(args, format); // variable list
566  vsnprintf(message, sizeof(message), format, args);
567  va_end(args);
568 
569  char form[kMaxMsgSize];
570  snprintf(form, sizeof(form), "w%u:%s", window_id_, message);
571 
572  char* esc = AddEscapeChars(form);
573  SendMsg("addMessage(\"%s\")", esc);
574  delete[] esc;
575 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
const int kMaxMsgSize
Definition: scrollview.cpp:38
void ScrollView::AddMessageBox ( )

Definition at line 578 of file scrollview.cpp.

578  {
579  SendMsg("addMessageBox()");
580 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::AlwaysOnTop ( bool  b)

Definition at line 555 of file scrollview.cpp.

555  {
556  if (b) { SendMsg("setAlwaysOnTop(true)");
557  } else { SendMsg("setAlwaysOnTop(false)"); }
558 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
SVEvent * 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 443 of file scrollview.cpp.

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

Definition at line 464 of file scrollview.cpp.

464  {
465  // Initialize the waiting semaphore.
466  auto* sem = new SVSemaphore();
467  std::pair<ScrollView*, SVEventType> ea((ScrollView*)nullptr, SVET_ANY);
468  waiting_for_events_mu->Lock();
469  waiting_for_events[ea] = std::pair<SVSemaphore*, SVEvent*> (sem, (SVEvent*)nullptr);
470  waiting_for_events_mu->Unlock();
471  // Wait on it.
472  stream_->Flush();
473  sem->Wait();
474  // Process the event we got woken up for (its in waiting_for_events pair).
475  waiting_for_events_mu->Lock();
476  SVEvent* ret = waiting_for_events[ea].second;
477  waiting_for_events.erase(ea);
478  waiting_for_events_mu->Unlock();
479  return ret;
480 }
void Lock()
Locks on a mutex.
Definition: svutil.cpp:63
void Flush()
Flush the buffer.
Definition: svutil.cpp:209
void Unlock()
Unlocks on a mutex.
Definition: svutil.cpp:71
void ScrollView::Brush ( Color  color)

Definition at line 725 of file scrollview.cpp.

725  {
726  Brush(table_colors[color][0],
727  table_colors[color][1],
728  table_colors[color][2],
729  table_colors[color][3]);
730 }
void Brush(Color color)
Definition: scrollview.cpp:725
void ScrollView::Brush ( int  red,
int  green,
int  blue 
)

Definition at line 625 of file scrollview.cpp.

625  {
626  SendMsg("brush(%d,%d,%d)", red, green, blue);
627 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::Brush ( int  red,
int  green,
int  blue,
int  alpha 
)

Definition at line 630 of file scrollview.cpp.

630  {
631  SendMsg("brush(%d,%d,%d,%d)", red, green, blue, alpha);
632 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::Clear ( )

Definition at line 589 of file scrollview.cpp.

589  {
590  SendMsg("clear()");
591 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::DrawTo ( int  x,
int  y 
)

Definition at line 525 of file scrollview.cpp.

525  {
526  points_->xcoords.push_back(x);
527  points_->ycoords.push_back(TranslateYCoordinate(y));
528  points_->empty = false;
529 }
int TranslateYCoordinate(int y)
Definition: scrollview.cpp:827
std::vector< int > ycoords
Definition: scrollview.cpp:48
std::vector< int > xcoords
Definition: scrollview.cpp:47
void ScrollView::Ellipse ( int  x,
int  y,
int  width,
int  height 
)

Definition at line 609 of file scrollview.cpp.

609  {
610  SendMsg("drawEllipse(%d,%d,%u,%u)",
611  x1, TranslateYCoordinate(y1), width, height);
612 }
int TranslateYCoordinate(int y)
Definition: scrollview.cpp:827
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::Exit ( )
static

Definition at line 583 of file scrollview.cpp.

583  {
584  SendRawMessage("svmain:exit()");
585  exit(0);
586 }
static void SendRawMessage(const char *msg)
Definition: scrollview.cpp:409
int ScrollView::GetId ( )
inline

Definition at line 197 of file scrollview.h.

197 { return window_id_; }
const char* ScrollView::GetName ( )
inline

Definition at line 194 of file scrollview.h.

194 { return window_name_; }
void ScrollView::Image ( struct Pix *  image,
int  x_pos,
int  y_pos 
)

Definition at line 765 of file scrollview.cpp.

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

Definition at line 657 of file scrollview.cpp.

657  {
658  SendMsg("openImage('%s')", image);
659  SendMsg("drawImage('%s',%d,%d)",
660  image, x_pos, TranslateYCoordinate(y_pos));
661 }
int TranslateYCoordinate(int y)
Definition: scrollview.cpp:827
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::Line ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 532 of file scrollview.cpp.

532  {
533  if (!points_->xcoords.empty() && x1 == points_->xcoords.back() &&
534  TranslateYCoordinate(y1) == points_->ycoords.back()) {
535  // We are already at x1, y1, so just draw to x2, y2.
536  DrawTo(x2, y2);
537  } else if (!points_->xcoords.empty() && x2 == points_->xcoords.back() &&
538  TranslateYCoordinate(y2) == points_->ycoords.back()) {
539  // We are already at x2, y2, so just draw to x1, y1.
540  DrawTo(x1, y1);
541  } else {
542  // This is a new line.
543  SetCursor(x1, y1);
544  DrawTo(x2, y2);
545  }
546 }
int TranslateYCoordinate(int y)
Definition: scrollview.cpp:827
void DrawTo(int x, int y)
Definition: scrollview.cpp:525
std::vector< int > ycoords
Definition: scrollview.cpp:48
std::vector< int > xcoords
Definition: scrollview.cpp:47
void SetCursor(int x, int y)
Definition: scrollview.cpp:519
void ScrollView::MenuItem ( const char *  parent,
const char *  name 
)

Definition at line 680 of file scrollview.cpp.

680  {
681  if (parent == nullptr) { parent = ""; }
682  SendMsg("addMenuBarItem('%s','%s')", parent, name);
683 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::MenuItem ( const char *  parent,
const char *  name,
int  cmdEvent 
)

Definition at line 674 of file scrollview.cpp.

674  {
675  if (parent == nullptr) { parent = ""; }
676  SendMsg("addMenuBarItem('%s','%s',%d)", parent, name, cmdEvent);
677 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::MenuItem ( const char *  parent,
const char *  name,
int  cmdEvent,
bool  flagged 
)

Definition at line 664 of file scrollview.cpp.

665  {
666  if (parent == nullptr) { parent = ""; }
667  if (flag) { SendMsg("addMenuBarItem('%s','%s',%d,true)",
668  parent, name, cmdEvent);
669  } else { SendMsg("addMenuBarItem('%s','%s',%d,false)",
670  parent, name, cmdEvent); }
671 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::Pen ( Color  color)

Definition at line 719 of file scrollview.cpp.

719  {
720  Pen(table_colors[color][0], table_colors[color][1],
721  table_colors[color][2], table_colors[color][3]);
722 }
void Pen(Color color)
Definition: scrollview.cpp:719
void ScrollView::Pen ( int  red,
int  green,
int  blue 
)

Definition at line 615 of file scrollview.cpp.

615  {
616  SendMsg("pen(%d,%d,%d)", red, green, blue);
617 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::Pen ( int  red,
int  green,
int  blue,
int  alpha 
)

Definition at line 620 of file scrollview.cpp.

620  {
621  SendMsg("pen(%d,%d,%d,%d)", red, green, blue, alpha);
622 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::PopupItem ( const char *  parent,
const char *  name 
)

Definition at line 686 of file scrollview.cpp.

686  {
687  if (parent == nullptr) { parent = ""; }
688  SendMsg("addPopupMenuItem('%s','%s')", parent, name);
689 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::PopupItem ( const char *  parent,
const char *  name,
int  cmdEvent,
const char *  value,
const char *  desc 
)

Definition at line 692 of file scrollview.cpp.

693  {
694  if (parent == nullptr) { parent = ""; }
695  char* esc = AddEscapeChars(value);
696  char* esc2 = AddEscapeChars(desc);
697  SendMsg("addPopupMenuItem('%s','%s',%d,'%s','%s')", parent, name,
698  cmdEvent, esc, esc2);
699  delete[] esc;
700  delete[] esc2;
701 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::Rectangle ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 600 of file scrollview.cpp.

600  {
601  if (x1 == x2 && y1 == y2)
602  return; // Scrollviewer locks up.
603  SendMsg("drawRectangle(%d,%d,%d,%d)",
604  x1, TranslateYCoordinate(y1), x2, TranslateYCoordinate(y2));
605 }
int TranslateYCoordinate(int y)
Definition: scrollview.cpp:827
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::SendMsg ( const char *  msg,
  ... 
)

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

Definition at line 391 of file scrollview.cpp.

391  {
392  if (!points_->empty)
393  SendPolygon();
394  va_list args;
395  char message[kMaxMsgSize - 4];
396 
397  va_start(args, format); // variable list
398  vsnprintf(message, sizeof(message), format, args);
399  va_end(args);
400 
401  char form[kMaxMsgSize];
402  snprintf(form, sizeof(form), "w%u:%s\n", window_id_, message);
403 
404  stream_->Send(form);
405 }
void Send(const char *msg)
Put a message in the messagebuffer to the server and try to send it.
Definition: svutil.cpp:202
const int kMaxMsgSize
Definition: scrollview.cpp:38
void 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 409 of file scrollview.cpp.

409  {
410  stream_->Send(msg);
411 }
void Send(const char *msg)
Put a message in the messagebuffer to the server and try to send it.
Definition: svutil.cpp:202
void ScrollView::SetCursor ( int  x,
int  y 
)

Definition at line 519 of file scrollview.cpp.

519  {
520  SendPolygon();
521  DrawTo(x, y);
522 }
void DrawTo(int x, int y)
Definition: scrollview.cpp:525
void ScrollView::SetVisible ( bool  visible)

Definition at line 549 of file scrollview.cpp.

549  {
550  if (visible) { SendMsg("setVisible(true)");
551  } else { SendMsg("setVisible(false)"); }
552 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
char * ScrollView::ShowInputDialog ( const char *  msg)

Definition at line 733 of file scrollview.cpp.

733  {
734  SendMsg("showInputDialog(\"%s\")", msg);
735  SVEvent* ev;
736  // wait till an input event (all others are thrown away)
737  ev = AwaitEvent(SVET_INPUT);
738  char* p = new char[strlen(ev->parameter) + 1];
739  strcpy(p, ev->parameter);
740  delete ev;
741  return p;
742 }
SVEvent * AwaitEvent(SVEventType type)
Definition: scrollview.cpp:443
char * parameter
Definition: scrollview.h:71
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
int ScrollView::ShowYesNoDialog ( const char *  msg)

Definition at line 745 of file scrollview.cpp.

745  {
746  SendMsg("showYesNoDialog(\"%s\")", msg);
747  SVEvent* ev;
748  // Wait till an input event (all others are thrown away)
749  ev = AwaitEvent(SVET_INPUT);
750  int a = ev->parameter[0];
751  delete ev;
752  return a;
753 }
SVEvent * AwaitEvent(SVEventType type)
Definition: scrollview.cpp:443
char * parameter
Definition: scrollview.h:71
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::Stroke ( float  width)

Definition at line 594 of file scrollview.cpp.

594  {
595  SendMsg("setStrokeWidth(%f)", width);
596 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::Text ( int  x,
int  y,
const char *  mystring 
)

Definition at line 652 of file scrollview.cpp.

652  {
653  SendMsg("drawText(%d,%d,'%s')", x, TranslateYCoordinate(y), mystring);
654 }
int TranslateYCoordinate(int y)
Definition: scrollview.cpp:827
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::TextAttributes ( const char *  font,
int  pixel_size,
bool  bold,
bool  italic,
bool  underlined 
)

Definition at line 635 of file scrollview.cpp.

636  {
637  const char* b;
638  const char* i;
639  const char* u;
640 
641  if (bold) { b = "true";
642  } else { b = "false"; }
643  if (italic) { i = "true";
644  } else { i = "false"; }
645  if (underlined) { u = "true";
646  } else { u = "false"; }
647  SendMsg("textAttributes('%s',%u,%s,%s,%s)", font, pixel_size,
648  b, i, u);
649 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
int ScrollView::TranslateYCoordinate ( int  y)

Definition at line 827 of file scrollview.cpp.

827  {
828  if (!y_axis_is_reversed_) { return y;
829  } else { return y_size_ - y; }
830 }
void ScrollView::Update ( )
static

Definition at line 709 of file scrollview.cpp.

709  {
710  svmap_mu->Lock();
711  for (auto & iter : svmap) {
712  if (iter.second != nullptr)
713  iter.second->UpdateWindow();
714  }
715  svmap_mu->Unlock();
716 }
void Lock()
Locks on a mutex.
Definition: svutil.cpp:63
void Unlock()
Unlocks on a mutex.
Definition: svutil.cpp:71
void ScrollView::UpdateWindow ( )

Definition at line 704 of file scrollview.cpp.

704  {
705  SendMsg("update()");
706 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391
void ScrollView::ZoomToRectangle ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 757 of file scrollview.cpp.

757  {
758  y1 = TranslateYCoordinate(y1);
759  y2 = TranslateYCoordinate(y2);
760  SendMsg("zoomRectangle(%d,%d,%d,%d)",
761  std::min(x1, x2), std::min(y1, y2), std::max(x1, x2), std::max(y1, y2));
762 }
int TranslateYCoordinate(int y)
Definition: scrollview.cpp:827
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:391

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