ubit
uremote.hpp
1 /* ==================================================== ======== ======= *
2 *
3 * uremote.hpp : Remote Control for the UMS server
4 * the UMS server provides multiple event flows, pseudo pointers, two-handed
5 * interaction, RendezVous identification, remote control facilities, etc.
6 *
7 * Ubit GUI Toolkit - Version 6.0
8 * (C) 2003-2008 Eric Lecolinet / ENST Paris / www.enst.fr/~elc/ubit
9 *
10 * ***********************************************************************
11 * COPYRIGHT NOTICE :
12 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
13 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
14 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
15 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
16 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
17 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
18 * ***********************************************************************/
19 
20 #ifndef _uremote_hpp_
21 #define _uremote_hpp_
22 
23 #include <ubit/ubit.hpp>
24 #include <ubit/umessage.hpp>
25 #include <ubit/umsproto.hpp>
26 #include <ubit/umservice.hpp>
27 using namespace ubit;
28 
29 struct WinPos {
30  int x, y;
31 };
32 
33 /* ==================================================== ======== ======= */
34 
35 class Remote : public UBox {
36 public:
37  Remote(const char* hostname = null);
38  void sendMsg(UStr* target, const char* action);
39  void sendBoxMsg(UEvent&, UStr* target, const char* action);
40  void sendClick(UStr* target, WinPos* pos);
41  void sendPress(UStr* target, WinPos* pos);
42  void sendRelease(UStr* target, WinPos* pos);
43  void press(UMouseEvent&, int* pointer, int btn);
44  void release(UMouseEvent&, int* pointer, int btn);
45  void moveMouse(UMouseEvent&, int* pointer, int* mag);
46  void pressKey(UKeyEvent&, int* pointer);
47  void releaseKey(UKeyEvent&, int* pointer);
48  void editPos(UMouseEvent&, WinPos*);
49  void serverRequest(UEvent&, int request);
50 
51  void startBrowsing();
52  bool isLocalConnected();
53  bool isHostConnected();
54  void hostDisconnected();
55 
56  UCombobox& getHostbox() {return *host_boxes[0];}
57  void selectHost(UCombobox*);
58  void selectNeighbor(UCombobox* cb, const char* dir);
59  void setMsg(UCombobox&, const UStr& combotext);
60  void setMsg(UCombobox*, const UStr& combotext);
61 
62  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
63 
64  UMService *local_server, *remote_server;
65  UCardbox cardbox;
66  UAlertbox alert;
67  std::vector<UCombobox*> host_boxes;
68  class DisplayPanel* disp_panel;
69  class MacroPanel* macro_panel;
70  class MacroEditor* macedit;
71 
72 protected:
73  void browseCB(UMessageEvent&);
74  void neighborCB(UMessageEvent&);
75  void selectHostCB(UMessageEvent&, UCombobox*);
76  void selectNeighborCB(UMessageEvent&, UCombobox*, const char* dir);
77  void selectHostAction(UCombobox*, const UStr& name, const UStr& address, int port);
78  void selectNeighborAction(UCombobox*, const char* dir, const UStr& name,
79  const UStr& address, int port);
80 };
81 
82 /* ==================================================== ======== ======= */
83 
84 struct DisplayPanel : public UBox {
86  UCombobox *top, *left, *right, *bottom;
87 };
88 
89 /* ==================================================== ======== ======= */
90 
91 struct MousePanel : public UBox {
93 private:
94  Remote& remote;
95  int ptr, mag;
96  UBox* no_drag_btn;
97  void pressPad(UMouseEvent& e, int* pointer);
98  void releasePad(UMouseEvent& e, int* pointer);
100 };
101 
102 /* ==================================================== ======== ======= */
103 
104 class UnixPanel : public UBox {
105 public:
106  static const char* commands[];
107  UnixPanel();
108 private:
109  UFont font;
110  UCardbox cardbox; // box that contains the buttons
111  UScrollpane spane; // scrollpane that contains resbox
112  UStr results; // string that contains the result
113  void createComButtons(const char* comspec);
114  void execCom(UStr* com);
115 };
116 
117 /* ==================================================== ======== ======= */
118 
119 struct FinderPanel : public UBox {
120  static UStr commands;
122 private:
123  UStr target;
124 };
125 
126 /* ==================================================== ======== ======= */
127 
128 struct WebPanel : public UBox {
129  struct Buttons {
130  WinPos back, forward, reload, stop, home,
131  previous_slide, next_slide, top_slide;
132  };
133  static UStr commands;
134  WebPanel(Remote*);
135 private:
136  UStr target;
137  static Buttons btn;
138 };
139 
140 /* ==================================================== ======== ======= */
141 
142 struct VrengPanel : public UBox {
143  static UStr commands;
144  VrengPanel(Remote*);
145 protected:
146  UStr target;
147 };
148 
149 /* ==================================================== ======== ======= */
150 
151 class MacroPanel : public UBox {
152 public:
153  MacroPanel(Remote*);
154  void createMacro();
155  void editMacro();
156  void deleteMacro();
157  void showStatus(const UStr&);
158  Remote& rem;
159  UListbox macro_list;
160  UBox statusbox;
161 };
162 
163 enum MacroType {Click, Message};
164 
165 struct Macro : public UItem {
166  Macro(class MacroEditor*);
167  MacroType mtype;
168  UStr name, target, mesg;
169  WinPos pos;
170 };
171 
172 class MacroEditor : public UBox {
173 public:
175  void open(Macro*);
176  void save();
177  void cancel();
178  void selectTarget();
179  void execMacro(Macro*);
180  void syncData();
181 
182 protected:
183  Remote& rem;
184  MacroPanel& macpanel;
185  int count;
186  bool already_in_list;
187  uptr<Macro> macro;
188  MacroType mtype;
189  UStr title, name, target, mesg;
190  URadioSelect mtypesel;
191  UTextfield namebox, targetbox, mesgbox;
192  USpinbox xbox, ybox;
193 };
194 
195 /* ==================================================== [(c)Elc] ======= */
196 /* ==================================================== ======== ======= */
197 #endif
keyboard events
Definition: uevent.hpp:316
Box container.
Definition: ubox.hpp:64
Definition: uremote.hpp:165
Ubit Event class.
Definition: uevent.hpp:30
Item Button widget (a kind of button that is used in UListbox(es)).
Definition: uinteractors.hpp:303
Definition: uremote.hpp:29
Alertbox gadget.
Definition: uboxes.hpp:192
UMService: Ubit Mouse/Message Service.
Definition: umservice.hpp:25
Definition: uremote.hpp:129
Definition: uremote.hpp:91
Spinbox gadget.
Definition: uinteractors.hpp:397
Definition: uremote.hpp:84
Definition: uremote.hpp:172
List widget: enforces a list layout and makes buttons (and items, checkboxes, etc) contained in this ...
Definition: ulistbox.hpp:117
Definition: uremote.hpp:142
Textfield widget: single line editor.
Definition: uinteractors.hpp:163
A box with (optionnal) scrollbars that manages a viewport.
Definition: uscrollpane.hpp:37
Font of a UElem or UBox container.
Definition: ufont.hpp:30
Definition: uremote.hpp:128
Definition: uremote.hpp:151
Definition: uhardfont.hpp:31
Combo box gadget.
Definition: ulistbox.hpp:213
Makes widgets (exclusively) selectable.
Definition: uchoice.hpp:153
Definition: uremote.hpp:119
Card box (or Tabbed Pane).
Definition: uboxes.hpp:98
Ubit String.
Definition: ustr.hpp:72
mouse events
Definition: uevent.hpp:172
Definition: uremote.hpp:35
Ubit Message events.
Definition: uevent.hpp:462
Definition: uremote.hpp:104