00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __HTDIALOG_H__
00022 #define __HTDIALOG_H__
00023
00024 #include <stdarg.h>
00025
00026 #include "htdebug.h"
00027 #include "htobj.h"
00028 #include "htstring.h"
00029
00030
00031
00032
00033
00034 #define ds_normal 0
00035 #define ds_term_ok 1
00036 #define ds_term_cancel 2
00037
00038 #define button_cancel 0
00039 #define button_ok 1
00040 #define button_yes button_ok
00041 #define button_no 2
00042 #define button_skip button_no
00043 #define button_all 3
00044 #define button_none 4
00045
00046 class ht_queued_msg: public Object {
00047 public:
00048 ht_view *target;
00049 htmsg msg;
00050 };
00051
00052 class ht_dialog: public ht_window {
00053 protected:
00054 int state;
00055 int return_val;
00056
00057 ht_queue *msgqueue;
00058
00059
00060 virtual char *defaultpalette();
00061 ht_queued_msg *dequeuemsg();
00062 public:
00063 void init(bounds *b, const char *desc, UINT framestyle);
00064 virtual void done();
00065
00066 virtual int alone();
00067 virtual void draw();
00068 virtual void handlemsg(htmsg *msg);
00069 void queuemsg(ht_view *target, htmsg *msg);
00070
00071 virtual int getstate(int *return_val);
00072 virtual int run(bool modal);
00073 virtual void setstate(int state, int return_val);
00074 };
00075
00076
00077
00078
00079
00080 class ht_cluster: public ht_view {
00081 protected:
00082 ht_string_list *strings;
00083 int sel;
00084 int scount;
00085 ht_key shortcuts[32];
00086
00087 virtual char *defaultpalette();
00088 public:
00089 void init(bounds *b, ht_string_list *strings);
00090 virtual void done();
00091 };
00092
00093
00094
00095
00096
00097 struct ht_checkboxes_data {
00098 DDECL_UINT(state);
00099 };
00100
00101 class ht_checkboxes: public ht_cluster {
00102 protected:
00103 dword state;
00104 public:
00105 void init(bounds *b, ht_string_list *strings);
00106 virtual void done();
00107
00108 virtual int datasize();
00109 virtual void draw();
00110 virtual void handlemsg(htmsg *msg);
00111 virtual void getdata(ht_object_stream *s);
00112 virtual void setdata(ht_object_stream *s);
00113 };
00114
00115
00116
00117
00118
00119 struct ht_radioboxes_data {
00120 DDECL_UINT(sel);
00121 };
00122
00123 class ht_radioboxes: public ht_cluster {
00124 public:
00125 void init(bounds *b, ht_string_list *strings);
00126 virtual void done();
00127
00128 virtual int datasize();
00129 virtual void draw();
00130 virtual void handlemsg(htmsg *msg);
00131 virtual void getdata(ht_object_stream *s);
00132 virtual void setdata(ht_object_stream *s);
00133 };
00134
00135
00136
00137
00138
00139 class ht_inputfield;
00140
00141 struct ht_inputfield_data {
00142 DDECL_UINT(textlen);
00143 DDECL_PTR(byte, text);
00144 };
00145
00146 class ht_inputfield: public ht_view {
00147 protected:
00148 byte **text, *textv;
00149 byte **curchar, *curcharv;
00150 byte **selstart, *selstartv;
00151 byte **selend, *selendv;
00152 int *textlen, textlenv;
00153 int *maxtextlen, maxtextlenv;
00154 int insert;
00155 int ofs;
00156 ht_inputfield *attachedto;
00157 ht_list *history;
00158
00159 void freebuf();
00160 int insertbyte(byte *pos, byte b);
00161 void select_add(byte *start, byte *end);
00162
00163 virtual char *defaultpalette();
00164 public:
00165 void init(bounds *b, int maxtextlen, ht_list *history=0);
00166 virtual void done();
00167
00168 virtual int datasize();
00169 virtual void getdata(ht_object_stream *s);
00170 virtual void setdata(ht_object_stream *s);
00171
00172 void attach(ht_inputfield *inputfield);
00173 void query(byte ***curchar, byte ***text, byte ***selstart, byte ***selend, int **textlen, int **maxtextlen);
00174 void isetcursor(UINT pos);
00175 };
00176
00177
00178
00179
00180
00181 #define ht_strinputfield_data ht_inputfield_data
00182
00183 class ht_strinputfield: public ht_inputfield {
00184 protected:
00185 bool is_virgin;
00186 bool selectmode;
00187
00188
00189 void correct_viewpoint();
00190 void history_dialog();
00191 bool inputbyte(byte a);
00192 bool setbyte(byte a);
00193 public:
00194 void init(bounds *b, int maxtextlen, ht_list *history=0);
00195 virtual void done();
00196
00197 virtual void draw();
00198 virtual void handlemsg(htmsg *msg);
00199 virtual void receivefocus();
00200 };
00201
00202
00203
00204
00205
00206 #define ht_hexinputfield_data ht_inputfield_data
00207
00208 class ht_hexinputfield: public ht_inputfield {
00209 protected:
00210 int nib;
00211
00212 void correct_viewpoint();
00213 public:
00214 void init(bounds *b, int maxtextlen);
00215 virtual void done();
00216
00217 virtual void draw();
00218 virtual void handlemsg(htmsg *msg);
00219 virtual void receivefocus();
00220
00221 void setnibble(byte a);
00222 };
00223
00224
00225
00226
00227
00228 class ht_button: public ht_view {
00229 protected:
00230 int value;
00231 int pressed;
00232 char *text;
00233 char *magicchar;
00234 ht_key shortcut1;
00235 ht_key shortcut2;
00236
00237
00238 virtual char *defaultpalette();
00239 public:
00240 void init(bounds *b, const char *text, int value);
00241 virtual void done();
00242
00243 virtual void draw();
00244 virtual void handlemsg(htmsg *msg);
00245
00246 virtual void push();
00247 };
00248
00249
00250
00251
00252
00253
00254 class ht_listbox;
00255
00256 class ht_listbox_title: public ht_view {
00257 public:
00258 ht_listbox *listbox;
00259 protected:
00260 char **texts;
00261 int cols;
00262
00263
00264 virtual char *defaultpalette();
00265 public:
00266 void init(bounds *b);
00267 virtual void done();
00268
00269 virtual void draw();
00270
00271 virtual vcp getTextColor();
00272 void setText(int cols, ...);
00273 void setTextv(int cols, va_list arguments);
00274 void update();
00275 };
00276
00277
00278
00279
00280
00281 struct ht_listbox_data {
00282 DDECL_PTR(void, top_ptr);
00283 DDECL_PTR(void, cursor_ptr);
00284 };
00285
00286 #define LISTBOX_NORMAL 0
00287 #define LISTBOX_QUICKFIND 1
00288
00289 class ht_listbox: public ht_view {
00290 protected:
00291 public:
00292 int cursor, pos, cached_count;
00293 int visible_height;
00294 void *e_top, *e_cursor;
00295 int x;
00296 char quickfinder[100];
00297 char *qpos;
00298 UINT listboxcaps;
00299
00300 int cols;
00301 int *widths;
00302
00303 ht_scrollbar *scrollbar;
00304 bool mScrollbarEnabled;
00305 ht_listbox_title *title;
00306
00307 public:
00308 void init(bounds *b, UINT Listboxcaps=LISTBOX_QUICKFIND);
00309 virtual void done();
00310 void attachTitle(ht_listbox_title *title);
00311 void adjustPosHack();
00312 void adjustScrollbar();
00313 virtual int calcCount() = 0;
00314 void clearQuickfind();
00315 virtual int cursorAdjust();
00316 int cursorUp(int n);
00317 int cursorDown(int n);
00318 virtual int datasize();
00319 virtual char * defaultpalette();
00320 virtual void draw();
00321 virtual int estimateEntryPos(void *entry);
00322 virtual void getdata(ht_object_stream *s);
00323 virtual void * getFirst() = 0;
00324 virtual void * getLast() = 0;
00325 virtual void * getNext(void *entry) = 0;
00326 virtual void * getPrev(void *entry) = 0;
00327 virtual char * getStr(int col, void *entry) = 0;
00328 void gotoItemByEntry(void *entry, bool clear_quickfind = true);
00329 virtual void gotoItemByPosition(UINT pos);
00330 virtual void handlemsg(htmsg *msg);
00331 virtual int numColumns();
00332 virtual void * quickfind(char *s) = 0;
00333 virtual char * quickfindCompletition(char *s);
00334 virtual void redraw();
00335 virtual void resize(int rw, int rh);
00336 virtual bool selectEntry(void *entry);
00337 virtual void setdata(ht_object_stream *s);
00338 virtual void stateChanged();
00339 virtual void update();
00340 void updateCursor();
00341 virtual Object * vstate_create();
00342 void vstate_save();
00343 protected:
00344 void rearrangeColumns();
00345 };
00346
00347
00348
00349
00350
00351 #define ht_text_listbox_data ht_listbox_data
00352
00353 struct ht_text_listbox_item {
00354 ht_text_listbox_item *next, *prev;
00355 int id;
00356 void *extra_data;
00357 char *data[0];
00358 };
00359
00360 struct ht_text_listbox_sort_order {
00361 int col;
00362 int (*compare_func)(const char *key_a, const char *key_b);
00363 };
00364
00365 class ht_text_listbox: public ht_listbox {
00366 protected:
00367 int cols, keycol, count;
00368 ht_text_listbox_item *first, *last;
00369 int Cursor_adjust;
00370
00371 public:
00372 void init(bounds *b, int Cols=1, int Keycol=0, UINT Listboxcaps=LISTBOX_QUICKFIND);
00373 virtual void done();
00374 virtual int calcCount();
00375 virtual int compare_strn(char *s1, char *s2, int l);
00376 virtual int compare_ccomm(char *s1, char *s2);
00377 virtual int cursorAdjust();
00378 void * getEntryByID(UINT id);
00379 virtual void * getFirst();
00380 virtual void * getLast();
00381 UINT getID(void *entry);
00382 virtual void * getNext(void *entry);
00383 virtual void * getPrev(void *entry);
00384 virtual char * getStr(int col, void *entry);
00385 void insert_str(int id, char *str, ...);
00386 void insert_str(int id, char **strs);
00387 void insert_str_extra(int id, void *extra_data, char *str, ...);
00388 void insert_str_extra(int id, void *extra_data, char **strs);
00389 virtual int numColumns();
00390 virtual void * quickfind(char *s);
00391 virtual char * quickfindCompletition(char *s);
00392 void sort(int count, ht_text_listbox_sort_order *so);
00393 virtual void update();
00394 protected:
00395 virtual void clearAll();
00396 virtual void freeExtraData(void *extra_data);
00397 };
00398
00399 #define ht_itext_listbox_data ht_text_listbox_data
00400
00401 class ht_itext_listbox: public ht_text_listbox {
00402 public:
00403 void init(bounds *b, int Cols=1, int Keycol=0);
00404 virtual void done();
00405 virtual int compare_strn(char *s1, char *s2, int l);
00406 virtual int compare_ccomm(char *s1, char *s2);
00407 };
00408
00409
00410
00411
00412
00413 enum statictext_align {
00414 align_left,
00415 align_center,
00416 align_right,
00417 align_custom
00418 };
00419
00420 #define ALIGN_CHAR_ESCAPE '\e'
00421 #define ALIGN_CHAR_LEFT 'l'
00422 #define ALIGN_CHAR_CENTER 'c'
00423 #define ALIGN_CHAR_RIGHT 'r'
00424
00425 struct ht_statictext_linedesc {
00426 int ofs;
00427 int len;
00428 char *text;
00429 };
00430
00431 class ht_statictext: public ht_text {
00432 protected:
00433 char *text;
00434 statictext_align align;
00435 bool breaklines;
00436 bool transparent;
00437
00438
00439 virtual char *defaultpalette();
00440 public:
00441 void init(bounds *b, const char *text, statictext_align align, bool breaklines=true, bool transparent=false);
00442 virtual void done();
00443
00444 virtual void draw();
00445 virtual char *gettext();
00446
00447 virtual vcp gettextcolor();
00448 virtual void settext(const char *text);
00449 };
00450
00451
00452
00453
00454
00455 struct ht_listpopup_dialog_data {
00456 DDECL_UINT(cursor_pos);
00457 DDECL_PTR(char, cursor_string);
00458 };
00459
00460 class ht_listpopup_dialog: public ht_dialog {
00461 protected:
00462 ht_listbox *listbox;
00463 virtual void init_text_listbox(bounds *b);
00464 public:
00465 void init(bounds *b, char *desc);
00466 virtual void done();
00467
00468 virtual char *defaultpalette();
00469 virtual int datasize();
00470 virtual void getdata(ht_object_stream *s);
00471 void insertstring(char *string);
00472 virtual void setdata(ht_object_stream *s);
00473
00474 void select_next();
00475 void select_prev();
00476 };
00477
00478
00479
00480
00481
00482 #define ht_listpopup_data ht_listpopup_dialog_data
00483
00484 class ht_listpopup: public ht_statictext {
00485 protected:
00486 ht_listpopup_dialog *listpopup;
00487
00488 int run_listpopup();
00489 public:
00490 void init(bounds *b);
00491 virtual void done();
00492
00493 virtual int datasize();
00494 virtual void draw();
00495 virtual vcp gettextcolor();
00496 virtual void getdata(ht_object_stream *s);
00497 virtual char *gettext();
00498 virtual void handlemsg(htmsg *msg);
00499 virtual void setdata(ht_object_stream *s);
00500
00501 void insertstring(char *string);
00502 };
00503
00504
00505
00506
00507
00508 class ht_history_listbox: public ht_listbox {
00509 ht_list *history;
00510 public:
00511 void init(bounds *b, ht_list *hist);
00512 virtual int calcCount();
00513 virtual void *getFirst();
00514 virtual void *getLast();
00515 virtual void *getNext(void *entry);
00516 virtual void *getPrev(void *entry);
00517 virtual char *getStr(int col, void *entry);
00518 virtual void handlemsg(htmsg *msg);
00519 virtual void *quickfind(char *s);
00520 virtual char *quickfindCompletition(char *s);
00521 };
00522
00523
00524
00525
00526
00527 class ht_history_popup_dialog: public ht_listpopup_dialog {
00528 protected:
00529 ht_list *history;
00530 virtual void init_text_listbox(bounds *b);
00531 public:
00532 void init(bounds *b, ht_list *hist);
00533 virtual void getdata(ht_object_stream *s);
00534 virtual void setdata(ht_object_stream *s);
00535 };
00536
00537
00538
00539
00540
00541 class ht_label: public ht_view {
00542 protected:
00543 ht_view *connected;
00544 char *text;
00545 char *magicchar;
00546 ht_key shortcut;
00547
00548
00549 virtual char *defaultpalette();
00550 public:
00551 void init(bounds *b, const char *text, ht_view *connected);
00552 virtual void done();
00553
00554 virtual void draw();
00555 virtual void handlemsg(htmsg *msg);
00556 };
00557
00558
00559
00560
00561
00562 class ht_progress_indicator: public ht_window {
00563 protected:
00564
00565 virtual char *defaultpalette();
00566 public:
00567 ht_statictext *text;
00568
00569 void init(bounds *b, char *hint);
00570
00571 void settext(const char *text);
00572 };
00573
00574
00575
00576
00577
00578 struct ht_color_block_data {
00579 DDECL_UINT(color);
00580 };
00581
00582 #define cf_light 1
00583 #define cf_transparent 2
00584
00585 class ht_color_block: public ht_view {
00586 protected:
00587 int color;
00588 int colors;
00589 int flags;
00590
00591
00592 virtual char *defaultpalette();
00593 public:
00594 void init(bounds *b, int selected, int flags);
00595 virtual void done();
00596
00597 virtual int datasize();
00598 virtual void draw();
00599 virtual void getdata(ht_object_stream *s);
00600 virtual void setdata(ht_object_stream *s);
00601 virtual void handlemsg(htmsg *msg);
00602 };
00603
00604
00605
00606
00607
00608 class ht_listbox_ptr: public Object {
00609 public:
00610 ht_listbox *listbox;
00611
00612 ht_listbox_ptr(ht_listbox *listbox);
00613 ~ht_listbox_ptr();
00614 };
00615
00616 void center_bounds(bounds *b);
00617
00618 #endif
00619