16 #include "config_auto.h"
19 #ifndef GRAPHICS_DISABLED
26 int rgb[3] = { 255, 255, 255 };
30 explicit SVPaint(
const char* server_name);
37 void PopupHandler(
const SVEvent* sv_event);
38 void MenuBarHandler(
const SVEvent* sv_event);
39 void ClickHandler(
const SVEvent* sv_event);
40 void SelectionHandler(
const SVEvent* sv_event);
55 bool has_start_point_;
66 root->
AddChild(
"G", 2,
"255",
"Green Color Value?");
67 root->
AddChild(
"B", 3,
"255",
"Blue Color Value?");
80 click->
AddChild(
"Point to Point Drawing",
85 drag->
AddChild(
"Rectangle Drawing", 5);
86 drag->
AddChild(
"Ellipse Drawing", 6);
92 void SVPaint::PopupHandler(
const SVEvent* sv_event) {
102 void SVPaint::MenuBarHandler(
const SVEvent* sv_event) {
105 has_start_point_ =
false;
112 void SVPaint::ClickHandler(
const SVEvent* sv_event) {
113 switch (click_mode_) {
115 if (has_start_point_) { window_->
DrawTo(sv_event->
x, sv_event->
y);
117 has_start_point_ =
true;
122 window_->
Line(sv_event->
x, sv_event->
y, sv_event->
x, sv_event->
y);
128 window_->
Text(sv_event->
x, sv_event->
y, p);
137 void SVPaint::SelectionHandler(
const SVEvent* sv_event) {
138 switch (drag_mode_) {
141 window_->
Line(sv_event->
x, sv_event->
y,
142 sv_event->
x - sv_event->
x_size,
143 sv_event->
y - sv_event->
y_size);
147 sv_event->
x - sv_event->
x_size,
148 sv_event->
y - sv_event->
y_size);
152 sv_event->
y - sv_event->
y_size,
163 else if (sv_event->
type ==
SVET_MENU) { MenuBarHandler(sv_event); }
164 else if (sv_event->
type ==
SVET_POPUP) { PopupHandler(sv_event); }
171 window_ =
new ScrollView(
"ScrollView Paint Example",
185 has_start_point_ =
false;
221 int main(
int argc,
char** argv) {
222 const char* server_name;
223 if (argc > 1) { server_name = argv[1]; }
else { server_name =
"localhost"; }
226 #endif // GRAPHICS_DISABLED
int main(int argc, char **argv)
void Notify(const SVEvent *sv_event)
void Text(int x, int y, const char *mystring)
void DrawTo(int x, int y)
void BuildMenu(ScrollView *sv, bool menu_bar=true)
void AddEventHandler(SVEventHandler *listener)
Add an Event Listener to this ScrollView Window.
void SetCursor(int x, int y)
SVEvent * AwaitEvent(SVEventType type)
void Ellipse(int x, int y, int width, int height)
char * ShowInputDialog(const char *msg)
SVPaint(const char *server_name)
void Rectangle(int x1, int y1, int x2, int y2)
SVMenuNode * AddChild(const char *txt)
void Line(int x1, int y1, int x2, int y2)
void SetVisible(bool visible)