Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 361 of file scrollview.cpp.

361  {
362  #ifndef GRAPHICS_DISABLED
363  svmap_mu->Lock();
364  if (svmap[window_id_] != NULL) {
365  svmap_mu->Unlock();
366  // So the event handling thread can quit.
367  SendMsg("destroy()");
368 
370  delete sve;
371  svmap_mu->Lock();
372  svmap[window_id_] = NULL;
373  svmap_mu->Unlock();
374  // The event handler thread for this window *must* receive the
375  // destroy event and set its pointer to this to NULL before we allow
376  // the destructor to exit.
377  while (!event_handler_ended_)
378  Update();
379  } else {
380  svmap_mu->Unlock();
381  }
382  delete mutex_;
383  delete semaphore_;
384  delete points_;
385  #endif // GRAPHICS_DISABLED
386 }
void Lock()
Locks on a mutex.
Definition: svutil.cpp:157
SVEvent * AwaitEvent(SVEventType type)
Definition: scrollview.cpp:444
void Unlock()
Unlocks on a mutex.
Definition: svutil.cpp:165
#define NULL
Definition: host.h:144
static void Update()
Definition: scrollview.cpp:710
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:390
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,
267  false, "localhost");
268 }
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 256 of file scrollview.cpp.

258  {
259  Initialize(name, x_pos, y_pos, x_size, y_size, x_canvas_size, y_canvas_size,
260  y_axis_reversed, "localhost");
261 }
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,
253  y_axis_reversed, server_name);}

Member Function Documentation

void ScrollView::AddEventHandler ( SVEventHandler listener)

Add an Event Listener to this ScrollView Window.

Definition at line 413 of file scrollview.cpp.

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

Definition at line 562 of file scrollview.cpp.

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

Definition at line 579 of file scrollview.cpp.

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

Definition at line 556 of file scrollview.cpp.

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

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

Definition at line 465 of file scrollview.cpp.

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

Definition at line 727 of file scrollview.cpp.

727  {
728  Brush(table_colors[color][0],
729  table_colors[color][1],
730  table_colors[color][2],
731  table_colors[color][3]);
732 }
void Brush(Color color)
Definition: scrollview.cpp:727
int table_colors[ScrollView::GREEN_YELLOW+1][4]
Definition: scrollview.cpp:187
void ScrollView::Brush ( int  red,
int  green,
int  blue 
)

Definition at line 626 of file scrollview.cpp.

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

Definition at line 631 of file scrollview.cpp.

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

Definition at line 590 of file scrollview.cpp.

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

Definition at line 526 of file scrollview.cpp.

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

Definition at line 610 of file scrollview.cpp.

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

Definition at line 584 of file scrollview.cpp.

584  {
585  SendRawMessage("svmain:exit()");
586  exit(0);
587 }
static void SendRawMessage(const char *msg)
Definition: scrollview.cpp:408
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 768 of file scrollview.cpp.

768  {
769  int width = image->w;
770  int height = image->h;
771  l_uint32 bpp = image->d;
772  ++image_index_;
773  // PIX* do not have a unique identifier/name associated, so name them "lept".
774  SendMsg("createImage('lept%d',%d,%d,%d)", image_index_, width, height, bpp);
775 
776  if (bpp == 32) {
777  Transfer32bppImage(image);
778  } else if (bpp == 8) {
779  TransferGrayImage(image);
780  } else if (bpp == 1) {
781  TransferBinaryImage(image);
782  }
783  // PIX* do not have a unique identifier/name associated, so name them "lept".
784  SendMsg("drawImage('lept%d',%d,%d)", image_index_, x_pos, y_pos);
785 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:390
void ScrollView::Image ( const char *  image,
int  x_pos,
int  y_pos 
)

Definition at line 658 of file scrollview.cpp.

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

Definition at line 533 of file scrollview.cpp.

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

Definition at line 681 of file scrollview.cpp.

681  {
682  if (parent == NULL) { parent = ""; }
683  SendMsg("addMenuBarItem('%s','%s')", parent, name);
684 }
#define NULL
Definition: host.h:144
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:390
void ScrollView::MenuItem ( const char *  parent,
const char *  name,
int  cmdEvent 
)

Definition at line 675 of file scrollview.cpp.

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

Definition at line 665 of file scrollview.cpp.

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

Definition at line 721 of file scrollview.cpp.

721  {
722  Pen(table_colors[color][0], table_colors[color][1],
723  table_colors[color][2], table_colors[color][3]);
724 }
void Pen(Color color)
Definition: scrollview.cpp:721
int table_colors[ScrollView::GREEN_YELLOW+1][4]
Definition: scrollview.cpp:187
void ScrollView::Pen ( int  red,
int  green,
int  blue 
)

Definition at line 616 of file scrollview.cpp.

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

Definition at line 621 of file scrollview.cpp.

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

Definition at line 687 of file scrollview.cpp.

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

Definition at line 693 of file scrollview.cpp.

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

Definition at line 601 of file scrollview.cpp.

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

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

Definition at line 390 of file scrollview.cpp.

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

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

Definition at line 520 of file scrollview.cpp.

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

Definition at line 550 of file scrollview.cpp.

550  {
551  if (visible) { SendMsg("setVisible(true)");
552  } else { SendMsg("setVisible(false)"); }
553 }
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:390
char * 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  strncpy(p, ev->parameter, strlen(ev->parameter));
742  p[strlen(ev->parameter)] = '\0';
743  delete ev;
744  return p;
745 }
SVEvent * AwaitEvent(SVEventType type)
Definition: scrollview.cpp:444
char * parameter
Definition: scrollview.h:71
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:390
int ScrollView::ShowYesNoDialog ( const char *  msg)

Definition at line 748 of file scrollview.cpp.

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

Definition at line 595 of file scrollview.cpp.

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

Definition at line 653 of file scrollview.cpp.

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

Definition at line 636 of file scrollview.cpp.

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

Definition at line 863 of file scrollview.cpp.

863  {
864  if (!y_axis_is_reversed_) { return y;
865  } else { return y_size_ - y; }
866 }
void ScrollView::Update ( )
static

Definition at line 710 of file scrollview.cpp.

710  {
711  svmap_mu->Lock();
712  for (std::map<int, ScrollView*>::iterator iter = svmap.begin();
713  iter != svmap.end(); ++iter) {
714  if (iter->second != NULL)
715  iter->second->UpdateWindow();
716  }
717  svmap_mu->Unlock();
718 }
void Lock()
Locks on a mutex.
Definition: svutil.cpp:157
void Unlock()
Unlocks on a mutex.
Definition: svutil.cpp:165
#define NULL
Definition: host.h:144
void ScrollView::UpdateWindow ( )

Definition at line 705 of file scrollview.cpp.

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

Definition at line 760 of file scrollview.cpp.

760  {
761  y1 = TranslateYCoordinate(y1);
762  y2 = TranslateYCoordinate(y2);
763  SendMsg("zoomRectangle(%d,%d,%d,%d)",
764  MIN(x1, x2), MIN(y1, y2), MAX(x1, x2), MAX(y1, y2));
765 }
int TranslateYCoordinate(int y)
Definition: scrollview.cpp:863
void SendMsg(const char *msg,...)
Send a message to the server, attaching the window id.
Definition: scrollview.cpp:390
#define MIN(x, y)
Definition: ndminx.h:28
#define MAX(x, y)
Definition: ndminx.h:24

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