00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __HTOBJ_H__
00022 #define __HTOBJ_H__
00023
00024 class ht_view;
00025 class ht_group;
00026
00027 #include "common.h"
00028 #include "htcurses.h"
00029
00030 struct palette {
00031 UINT size;
00032 vcp *data;
00033 };
00034
00035
00036 #define msg_message 0x00000000
00037 #define HT_MESSAGE(m) (msg_message+(m))
00038
00039 #define msg_empty HT_MESSAGE(0)
00040 #define msg_retval HT_MESSAGE(1)
00041 #define msg_draw HT_MESSAGE(2)
00042 #define msg_keypressed HT_MESSAGE(3)
00043 #define msg_kill HT_MESSAGE(4)
00044 #define msg_complete_init HT_MESSAGE(5)
00045 #define msg_funcexec HT_MESSAGE(6)
00046 #define msg_funcquery HT_MESSAGE(7)
00047 #define msg_menucapquery HT_MESSAGE(8)
00048 #define msg_menuquery HT_MESSAGE(9)
00049 #define msg_button_pressed HT_MESSAGE(10)
00050 #define msg_dirtyview HT_MESSAGE(11)
00051 #define msg_config_changed HT_MESSAGE(12)
00052 #define msg_accept_close HT_MESSAGE(13)
00053 #define msg_file_changed HT_MESSAGE(14)
00054 #define msg_get_scrollinfo HT_MESSAGE(15)
00055 #define msg_get_analyser HT_MESSAGE(16)
00056 #define msg_set_analyser HT_MESSAGE(17) // (Analyser *)
00057 #define msg_postinit HT_MESSAGE(18)
00058 #define msg_contextmenuquery HT_MESSAGE(19)
00059 #define msg_project_changed HT_MESSAGE(20)
00060 #define msg_vstate_save HT_MESSAGE(21) // (Object *data, ht_view *)
00061 #define msg_vstate_restore HT_MESSAGE(22) // (Object *data)
00062 #define msg_goto_offset HT_MESSAGE(23) // (FILEOFS ofs)
00063
00064 #define msg_filesize_changed HT_MESSAGE(100)
00065 #define msg_log_changed HT_MESSAGE(101)
00066
00067 #define gsi_pindicator 1
00068 #define gsi_hscrollbar 2
00069 #define gsi_vscrollbar 3
00070
00071 struct gsi_scrollbar_t {
00072 int pstart;
00073 int psize;
00074 };
00075
00076
00077 #define mt_empty 0
00078 #define mt_broadcast 1
00079 #define mt_preprocess 2
00080 #define mt_postprocess 3
00081
00082
00083
00084
00085
00086
00087 #define VO_OWNBUFFER 1
00088 #define VO_BROWSABLE 2
00089 #define VO_SELECTABLE 4
00090 #define VO_SELBOUND 8
00091 #define VO_PREPROCESS 16
00092 #define VO_POSTPROCESS 32
00093 #define VO_MOVE 64
00094 #define VO_RESIZE 128
00095 #define VO_FORMAT_VIEW 256
00096 #define VO_TRANSPARENT_CHARS 512
00097
00098
00099
00100 class ht_group;
00101
00102 #define VIEW_DEBUG_NAME(name) ht_view::view_debug_name=name;
00103
00104 #define GMV_TOP 0
00105 #define GMV_BOTTOM 1
00106 #define GMV_FIT 2
00107
00108 #define GMH_LEFT 0
00109 #define GMH_RIGHT 1
00110 #define GMH_FIT 2
00111
00112 #define GET_GM_H(gm) ((gm)>>16)
00113 #define GET_GM_V(gm) ((gm)&0xffff)
00114
00115 #define MK_GM(gmh, gmv) ((gmv) | ((gmh)<<16))
00116
00117 void clearmsg(htmsg *msg);
00118
00119 enum cursor_mode {cm_normal, cm_overwrite};
00120
00121 class ht_view: public Object {
00122 protected:
00123 bool view_is_dirty;
00124
00125 void cleanview();
00126 virtual char *defaultpalette();
00127 virtual char *defaultpaletteclass();
00128 virtual void reloadpalette();
00129 public:
00130 bool focused;
00131 bool enabled;
00132 ht_group *group;
00133 int options;
00134 char *desc;
00135 int browse_idx;
00136 genericdrawbuf *buf;
00137 ht_view *prev, *next;
00138
00139 bounds size;
00140 bounds vsize;
00141 UINT growmode;
00142 UINT g_hdist, g_vdist;
00143
00144 palette pal;
00145 char *pal_class;
00146 char *pal_name;
00147
00148 char *view_debug_name;
00149
00150 void init(bounds *b, int options, const char *desc);
00151 virtual void done();
00152
00153 void *allocdatabuf(void *handle);
00154 virtual int alone();
00155 int buf_lprint(int x, int y, int c, int l, char *text);
00156 int buf_lprintw(int x, int y, int c, int l, int *text);
00157 int buf_print(int x, int y, int c, char *text);
00158 void buf_printchar(int x, int y, int c, int ch);
00159 int buf_printf(int x, int y, int c, char *format, ...);
00160 int buf_printw(int x, int y, int c, int *text);
00161 virtual int childcount();
00162 void clear(int color);
00163 virtual void clipbounds(bounds *b);
00164 virtual void config_changed();
00165 virtual int countselectables();
00166 void databuf_freedup(void *handle);
00167 void databuf_get(void *buf, int bufsize);
00168 void *databuf_getdup(void *buf, int bufsize);
00169 void databuf_set(void *buf, int bufsize);
00170 virtual int datasize();
00171 void dirtyview();
00172 virtual void disable();
00173 void disable_buffering();
00174 virtual void draw();
00175 virtual void enable();
00176 void enable_buffering();
00177 virtual int enum_start();
00178 virtual ht_view *enum_next(int *handle);
00179 bool exposed();
00180 void fill(int x, int y, int w, int h, int c, int chr);
00181 virtual int focus(ht_view *view);
00182 void getbounds(bounds *b);
00183 virtual void getminbounds(int *width, int *height);
00184 vcp getcolor(UINT index);
00185 virtual void getdata(ht_object_stream *s);
00186 virtual ht_view *getfirstchild();
00187 virtual UINT getnumber();
00188 char *getpalette();
00189 virtual ht_view *getselected();
00190 virtual void handlemsg(htmsg *msg);
00191 void hidecursor();
00192 int isviewdirty();
00193 virtual int isalone(ht_view *view);
00194 virtual int load(ht_object_stream *s);
00195 virtual void move(int rx, int ry);
00196 virtual OBJECT_ID object_id() const;
00197 int pointvisible(int x, int y);
00198 virtual void receivefocus();
00199 virtual void redraw();
00200 void relocate_to(ht_view *view);
00201 virtual void resize(int rw, int rh);
00202 virtual void releasefocus();
00203 virtual int select(ht_view *view);
00204 virtual void selectfirst();
00205 virtual void selectlast();
00206 void sendmsg(htmsg *msg);
00207 void sendmsg(int msg, int data1=0, int data2=0);
00208 void sendmsg(int msg, void *data1, void *data2=0);
00209 void setbounds(bounds *b);
00210 void setvisualbounds(bounds *b);
00211 void setcursor(int x, int y, cursor_mode c=cm_normal);
00212 virtual void setdata(ht_object_stream *s);
00213 virtual void setgroup(ht_group *group);
00214 virtual void setnumber(UINT number);
00215 void setoptions(int options);
00216 virtual void setpalette(char *pal_name);
00217 void setpalettefull(char *pal_name, char *pal_class);
00218 virtual void store(ht_object_stream *s);
00219 void unrelocate_to(ht_view *view);
00220 };
00221
00222
00223
00224
00225
00226 class ht_group: public ht_view {
00227 protected:
00228 int view_count;
00229
00230 public:
00231 ht_view *first, *current, *last;
00232 void *shared_data;
00233
00234 void init(bounds *b, int options, const char *desc);
00235 virtual void done();
00236
00237 virtual int childcount();
00238 virtual int countselectables();
00239 virtual int datasize();
00240 virtual int enum_start();
00241 virtual ht_view *enum_next(int *handle);
00242 virtual int focus(ht_view *view);
00243 virtual void getdata(ht_object_stream *s);
00244 virtual ht_view *getselected();
00245 virtual ht_view *getfirstchild();
00246 virtual void handlemsg(htmsg *msg);
00247 virtual int isalone(ht_view *view);
00248 int isviewdirty();
00249 virtual int load(ht_object_stream *s);
00250 virtual void move(int x, int y);
00251 virtual OBJECT_ID object_id() const;
00252 void putontop(ht_view *view);
00253 virtual void receivefocus();
00254 virtual void resize(int rw, int rh);
00255 virtual void releasefocus();
00256 virtual int select(ht_view *view);
00257 virtual void selectfirst();
00258 virtual void selectlast();
00259 virtual void setdata(ht_object_stream *s);
00260 virtual void setpalette(char *pal_name);
00261 virtual void store(ht_object_stream *s);
00262
00263 virtual void reorder_view(ht_view *v, int rx, int ry);
00264 void remove(ht_view *view);
00265 virtual void insert(ht_view *view);
00266 int focusnext();
00267 int focusprev();
00268 ht_view *get_by_browse_idx(int i);
00269 };
00270
00271
00272
00273
00274
00275 class ht_xgroup: public ht_group {
00276 public:
00277 void init(bounds *b, int options, const char *desc);
00278 virtual void done();
00279
00280 virtual int countselectables();
00281 virtual void handlemsg(htmsg *msg);
00282 virtual int isalone(ht_view *view);
00283 virtual int load(ht_object_stream *s);
00284 virtual OBJECT_ID object_id() const;
00285 virtual void redraw();
00286 virtual void selectfirst();
00287 virtual void selectlast();
00288 virtual void store(ht_object_stream *s);
00289 };
00290
00291
00292
00293
00294
00295 class ht_scrollbar: public ht_view {
00296 protected:
00297 int pstart, psize;
00298 palette *gpal;
00299 bool isvertical;
00300 public:
00301 void init(bounds *b, palette *gpal, bool isvertical);
00302 virtual void done();
00303
00304 virtual void enable();
00305 virtual void disable();
00306 virtual void draw();
00307 virtual int load(ht_object_stream *s);
00308 virtual OBJECT_ID object_id() const;
00309 virtual void store(ht_object_stream *s);
00310
00311 virtual void setpos(int pstart, int psize);
00312 };
00313
00314
00315
00316
00317
00318 class ht_text: public ht_view {
00319 public:
00320
00321 virtual void settext(const char *text);
00322 };
00323
00324
00325
00326
00327
00328 #define FS_KILLER 1
00329 #define FS_TITLE 2
00330 #define FS_NUMBER 4
00331 #define FS_RESIZE 8
00332 #define FS_MOVE 16
00333 #define FS_THICK 32
00334
00335 #define FST_FOCUSED 0
00336 #define FST_UNFOCUSED 1
00337 #define FST_MOVE 2
00338 #define FST_RESIZE 3
00339
00340 class ht_frame: public ht_text {
00341 protected:
00342 UINT number;
00343 UINT style;
00344 UINT framestate;
00345
00346
00347 virtual vcp getcurcol_normal();
00348 virtual vcp getcurcol_killer();
00349 public:
00350 void init(bounds *b, const char *desc, UINT style, UINT number=0);
00351 virtual void done();
00352
00353 virtual void draw();
00354 virtual UINT getnumber();
00355 virtual int load(ht_object_stream *s);
00356 virtual OBJECT_ID object_id() const;
00357 virtual void setnumber(UINT number);
00358 virtual void settext(const char *text);
00359 virtual void store(ht_object_stream *s);
00360
00361 UINT getstyle();
00362 void setframestate(UINT framestate);
00363 void setstyle(UINT style);
00364 };
00365
00366
00367
00368
00369
00370 #define WAC_NORMAL 0
00371 #define WAC_MOVE 1
00372 #define WAC_RESIZE 2
00373
00374 class ht_window: public ht_group {
00375 protected:
00376 ht_frame *frame;
00377 ht_scrollbar *hscrollbar;
00378 ht_scrollbar *vscrollbar;
00379 ht_text *pindicator;
00380 UINT number;
00381
00382 int action_state;
00383
00384 bool next_action_state();
00385 public:
00386 void init(bounds *b, const char *desc, UINT framestyle, UINT number=0);
00387 virtual void done();
00388
00389 virtual void draw();
00390 virtual UINT getnumber();
00391 virtual void handlemsg(htmsg *msg);
00392 virtual void insert(ht_view *view);
00393 virtual int load(ht_object_stream *s);
00394 virtual OBJECT_ID object_id() const;
00395 virtual void receivefocus();
00396 virtual void releasefocus();
00397 virtual void redraw();
00398 virtual void resize(int rw, int rh);
00399 virtual void setnumber(UINT number);
00400 virtual void store(ht_object_stream *s);
00401
00402 void getclientarea(bounds *b);
00403 ht_frame *getframe();
00404 void setframe(ht_frame *frame);
00405 void sethscrollbar(ht_scrollbar *scrollbar);
00406 void setpindicator(ht_text *pindicator);
00407 void settitle(char *title);
00408 void setvscrollbar(ht_scrollbar *scrollbar);
00409 };
00410
00411 bool scrollbar_pos(int start, int size, int all, int *pstart, int *psize);
00412
00413
00414
00415
00416
00417 class ht_hbar: public ht_view {
00418 public:
00419
00420 virtual void draw();
00421 };
00422
00423
00424
00425
00426
00427 class ht_vbar: public ht_view {
00428 public:
00429
00430 virtual void draw();
00431 };
00432
00433
00434
00435
00436
00437 bool init_obj();
00438
00439
00440
00441
00442
00443 void done_obj();
00444
00445 #endif