tesseract 4.1.1
Loading...
Searching...
No Matches
SVPaint Class Reference
Inheritance diagram for SVPaint:
SVEventHandler

Public Member Functions

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

Detailed Description

Definition at line 37 of file svpaint.cpp.

Constructor & Destructor Documentation

◆ SVPaint()

SVPaint::SVPaint ( const char *  server_name)
explicit

Definition at line 179 of file svpaint.cpp.

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

Member Function Documentation

◆ Notify()

void SVPaint::Notify ( const SVEvent sv_event)
overridevirtual

Reimplemented from SVEventHandler.

Definition at line 169 of file svpaint.cpp.

169 {
170 if (sv_event->type == SVET_CLICK) { ClickHandler(sv_event); }
171 else if (sv_event->type == SVET_SELECTION) { SelectionHandler(sv_event); }
172 else if (sv_event->type == SVET_MENU) { MenuBarHandler(sv_event); }
173 else if (sv_event->type == SVET_POPUP) { PopupHandler(sv_event); }
174 //throw other events away
175}
@ SVET_CLICK
Definition: scrollview.h:48
@ SVET_POPUP
Definition: scrollview.h:54
@ SVET_SELECTION
Definition: scrollview.h:49
@ SVET_MENU
Definition: scrollview.h:55
SVEventType type
Definition: scrollview.h:64

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