tesseract v5.3.3.20231005
tesseract::SVPaint Class Reference
Inheritance diagram for tesseract::SVPaint:
tesseract::SVEventHandler

Public Member Functions

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

Detailed Description

Definition at line 40 of file svpaint.cpp.

Constructor & Destructor Documentation

◆ SVPaint()

tesseract::SVPaint::SVPaint ( const char *  server_name)
explicit

Definition at line 188 of file svpaint.cpp.

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

Member Function Documentation

◆ Notify()

void tesseract::SVPaint::Notify ( const SVEvent sv_event)
overridevirtual

Reimplemented from tesseract::SVEventHandler.

Definition at line 173 of file svpaint.cpp.

173 {
174 if (sv_event->type == SVET_CLICK) {
175 ClickHandler(sv_event);
176 } else if (sv_event->type == SVET_SELECTION) {
177 SelectionHandler(sv_event);
178 } else if (sv_event->type == SVET_MENU) {
179 MenuBarHandler(sv_event);
180 } else if (sv_event->type == SVET_POPUP) {
181 PopupHandler(sv_event);
182 }
183 // throw other events away
184}
@ SVET_SELECTION
Definition: scrollview.h:57
@ SVET_POPUP
Definition: scrollview.h:62
@ SVET_CLICK
Definition: scrollview.h:56

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