All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SVPaint Class Reference
Inheritance diagram for SVPaint:
SVEventHandler

Public Member Functions

 SVPaint (const char *server_name)
 
void Notify (const SVEvent *sv_event)
 
- Public Member Functions inherited from SVEventHandler
virtual ~SVEventHandler ()
 

Detailed Description

Definition at line 28 of file svpaint.cpp.

Constructor & Destructor Documentation

SVPaint::SVPaint ( const char *  server_name)
explicit

Definition at line 170 of file svpaint.cpp.

170  {
171  window_ = new ScrollView("ScrollView Paint Example", // window caption
172  0, 0, // x,y window position
173  500, 500, // window size
174  500, 500, // canvas size
175  false, // whether the Y axis is inversed.
176  // this is included due to legacy
177  // reasons for tesseract and enables
178  // us to have (0,0) as the LOWER left
179  // of the coordinate system.
180  server_name); // the server address.
181 
182  // Set the start modes to point-to-point and line drawing.
183  click_mode_ = 1;
184  drag_mode_ = 4;
185  has_start_point_ = false;
186 
187  // Bild our menus and add them to the window. The flag illustrates whether
188  // this is a menu bar.
189  SVMenuNode* popup_menu = BuildPopupMenu();
190  popup_menu->BuildMenu(window_,false);
191 
192  SVMenuNode* bar_menu = BuildMenuBar();
193  bar_menu->BuildMenu(window_,true);
194 
195  // Set the initial color values to White (could also be done by
196  // passing (rgb[0], rgb[1], rgb[2]).
197  window_->Pen(ScrollView::WHITE);
198  window_->Brush(ScrollView::WHITE);
199 
200  // Adds the event handler to the window. This actually ensures that Notify
201  // gets called when events occur.
202  window_->AddEventHandler(this);
203 
204  // Set the window visible (calling this is important to actually render
205  // everything. Without this call, the window would also be drawn, but the
206  // menu bars would be missing.
207  window_->SetVisible(true);
208 
209  // Rest this thread until its window is destroyed.
210  // Note that a special eventhandling thread was created when constructing
211  // the window. Due to this, the application will not deadlock here.
212  window_->AwaitEvent(SVET_DESTROY);
213  // We now have 3 Threads running:
214  // (1) The MessageReceiver thread which fetches messages and distributes them
215  // (2) The EventHandler thread which handles all events for window_
216  // (3) The main thread which waits on window_ for a DESTROY event (blocked)
217 }
void Pen(Color color)
Definition: scrollview.cpp:726
void BuildMenu(ScrollView *sv, bool menu_bar=true)
Definition: svmnode.cpp:121
void AddEventHandler(SVEventHandler *listener)
Add an Event Listener to this ScrollView Window.
Definition: scrollview.cpp:418
void Brush(Color color)
Definition: scrollview.cpp:732
SVEvent * AwaitEvent(SVEventType type)
Definition: scrollview.cpp:449
void SetVisible(bool visible)
Definition: scrollview.cpp:555

Member Function Documentation

void SVPaint::Notify ( const SVEvent sv_event)
virtual

Reimplemented from SVEventHandler.

Definition at line 160 of file svpaint.cpp.

160  {
161  if (sv_event->type == SVET_CLICK) { ClickHandler(sv_event); }
162  else if (sv_event->type == SVET_SELECTION) { SelectionHandler(sv_event); }
163  else if (sv_event->type == SVET_MENU) { MenuBarHandler(sv_event); }
164  else if (sv_event->type == SVET_POPUP) { PopupHandler(sv_event); }
165  else {} //throw other events away
166 }
SVEventType type
Definition: scrollview.h:64

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