25#include "config_auto.h"
28#ifndef GRAPHICS_DISABLED
35static int rgb[3] = { 255, 255, 255 };
39 explicit SVPaint(
const char* server_name);
46 void PopupHandler(
const SVEvent* sv_event);
47 void MenuBarHandler(
const SVEvent* sv_event);
48 void ClickHandler(
const SVEvent* sv_event);
49 void SelectionHandler(
const SVEvent* sv_event);
64 bool has_start_point_;
75 root->AddChild(
"G", 2,
"255",
"Green Color Value?");
76 root->AddChild(
"B", 3,
"255",
"Blue Color Value?");
89 click->
AddChild(
"Point to Point Drawing",
94 drag->
AddChild(
"Rectangle Drawing", 5);
95 drag->
AddChild(
"Ellipse Drawing", 6);
101void SVPaint::PopupHandler(
const SVEvent* sv_event) {
105 window_->
Pen(rgb[0], rgb[1], rgb[2]);
111void SVPaint::MenuBarHandler(
const SVEvent* sv_event) {
114 has_start_point_ =
false;
121void SVPaint::ClickHandler(
const SVEvent* sv_event) {
122 switch (click_mode_) {
124 if (has_start_point_) { window_->
DrawTo(sv_event->
x, sv_event->
y);
126 has_start_point_ =
true;
131 window_->
Line(sv_event->
x, sv_event->
y, sv_event->
x, sv_event->
y);
137 window_->
Text(sv_event->
x, sv_event->
y, p);
146void SVPaint::SelectionHandler(
const SVEvent* sv_event) {
147 switch (drag_mode_) {
150 window_->
Line(sv_event->
x, sv_event->
y,
151 sv_event->
x - sv_event->
x_size,
152 sv_event->
y - sv_event->
y_size);
156 sv_event->
x - sv_event->
x_size,
157 sv_event->
y - sv_event->
y_size);
161 sv_event->
y - sv_event->
y_size,
172 else if (sv_event->
type ==
SVET_MENU) { MenuBarHandler(sv_event); }
173 else if (sv_event->
type ==
SVET_POPUP) { PopupHandler(sv_event); }
180 window_ =
new ScrollView(
"ScrollView Paint Example",
194 has_start_point_ =
false;
230int main(
int argc,
char** argv) {
231 const char* server_name;
232 if (argc > 1) { server_name = argv[1]; }
else { server_name =
"localhost"; }
int main(int argc, char **argv)
SVEvent * AwaitEvent(SVEventType type)
void DrawTo(int x, int y)
void Line(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 AddEventHandler(SVEventHandler *listener)
Add an Event Listener to this ScrollView Window.
void SetCursor(int x, int y)
void SetVisible(bool visible)
void Rectangle(int x1, int y1, int x2, int y2)
char * ShowInputDialog(const char *msg)
SVMenuNode * AddChild(const char *txt)
void BuildMenu(ScrollView *sv, bool menu_bar=true)
void Notify(const SVEvent *sv_event) override
SVPaint(const char *server_name)