NetSurf
treeview.c
Go to the documentation of this file.
1/*
2 * Copyright 2013 Ole Loots <ole@monochrom.net>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "assert.h"
20
21#include "utils/log.h"
22#include "utils/messages.h"
23#include "netsurf/inttypes.h"
24#include "netsurf/core_window.h"
25#include "netsurf/plotters.h"
26
27#include "atari/gui.h"
28#include "atari/plot/plot.h"
29#include "atari/misc.h"
30#include "atari/gemtk/gemtk.h"
31#include "atari/treeview.h"
32#include "atari/res/netsurf.rsh"
33
34
38 GUIWIN * window;
40 bool redraw;
41 bool is_open;
42 GRECT rdw_area;
47 void * user_data;
48};
49
51
52/**
53 * Schedule a redraw of the treeview content
54 *
55 */
56static void
57atari_treeview_redraw_grect_request(struct core_window *cw, GRECT *area)
58{
59 struct atari_treeview_window *tv = (struct atari_treeview_window *)cw;
60 if (cw != NULL) {
61 if( tv->redraw == false ){
62 tv->redraw = true;
63 tv->rdw_area.g_x = area->g_x;
64 tv->rdw_area.g_y = area->g_y;
65 tv->rdw_area.g_w = area->g_w;
66 tv->rdw_area.g_h = area->g_h;
67 } else {
68 /* merge the redraw area to the new area.: */
69 int newx1 = area->g_x+area->g_w;
70 int newy1 = area->g_y+area->g_h;
71 int oldx1 = tv->rdw_area.g_x + tv->rdw_area.g_w;
72 int oldy1 = tv->rdw_area.g_y + tv->rdw_area.g_h;
73 tv->rdw_area.g_x = MIN(tv->rdw_area.g_x, area->g_x);
74 tv->rdw_area.g_y = MIN(tv->rdw_area.g_y, area->g_y);
75
76 if ( oldx1 > newx1 ) {
77 tv->rdw_area.g_w = oldx1 - tv->rdw_area.g_x;
78 } else {
79 tv->rdw_area.g_w = newx1 - tv->rdw_area.g_x;
80 }
81
82 if ( oldy1 > newy1 ) {
83 tv->rdw_area.g_h = oldy1 - tv->rdw_area.g_y;
84 } else {
85 tv->rdw_area.g_h = newy1 - tv->rdw_area.g_y;
86 }
87 }
88 //dbg_grect("atari_treeview_request_redraw_grect", &tv->rdw_area);
89 }
90}
91
92
93#ifdef ATARI_TREEVIEW_DUMP
94static void
95atari_treeview_dump_info(struct atari_treeview_window *tv, char * title)
96{
97 printf("Treeview Dump (%s)\n", title);
98 printf("=================================\n");
99 gemtk_wm_dump_window_info(atari_treeview_get_gemtk_window((struct core_window *)tv));
100 GEMTK_DBG_GRECT("Redraw Area: \n", &tv->rdw_area)
101 dbg_grect("Redraw Area2: \n", &tv->rdw_area);
102 printf("Extent: x: %d, y: %d\n", tv->extent.x, tv->extent.y);
103}
104#endif
105
106
107static bool atari_treeview_is_iconified(struct core_window *cw)
108{
109 struct atari_treeview_window *tv = (struct atari_treeview_window *)cw;
110
111 return((gemtk_wm_get_state(tv->window)&GEMTK_WM_STATUS_ICONIFIED) != 0);
112}
113
114
115static void atari_treeview_redraw_icon(struct core_window *cw, GRECT *clip)
116{
117 struct atari_treeview_window *tv = (struct atari_treeview_window *)cw;
118 GRECT visible, work;
119 OBJECT * tree = gemtk_obj_get_tree(ICONIFY);
120 short aesh = gemtk_wm_get_handle(tv->window);
121
122 gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_WORK, &work);
123
124 tree->ob_x = work.g_x;
125 tree->ob_y = work.g_y;
126 tree->ob_width = work.g_w;
127 tree->ob_height = work.g_h;
128
129 wind_get_grect(aesh, WF_FIRSTXYWH, &visible);
130 while (visible.g_h > 0 && visible.g_w > 0) {
131
132 if (rc_intersect(&work, &visible)) {
133 objc_draw(tree, 0, 8, visible.g_x, visible.g_y, visible.g_w,
134 visible.g_h);
135 } else {
136 //dbg_grect("redraw vis area outside", &visible);
137 }
138
139 wind_get_grect(aesh, WF_NEXTXYWH, &visible);
140 }
141}
142
143
144static void __CDECL
145on_redraw_event(struct core_window *cw, EVMULT_OUT *ev_out, short msg[8])
146{
147 GRECT work, clip;
148 struct atari_treeview_window *tv = (struct atari_treeview_window *)cw;
149
150 if (tv == NULL)
151 return;
152
153 gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, &work);
154 //dbg_grect("treeview work: ", &work);
155
157 //dbg_grect("treeview work: ", &work);
158 gemtk_wm_get_scroll_info(tv->window);
159
160 clip = work;
161
162 /* check if the redraw area intersects with the content area: */
163 if ( !rc_intersect( (GRECT*)&msg[4], &clip)) {
164 return;
165 }
166
167 if (atari_treeview_is_iconified(cw) == true) {
169 return;
170 }
171
172 /* make redraw coords relative to content viewport */
173 clip.g_x -= work.g_x;
174 clip.g_y -= work.g_y;
175
176 /* normalize the redraw coords: */
177 if( clip.g_x < 0 ) {
178 clip.g_w = work.g_w + clip.g_x;
179 clip.g_x = 0;
180 }
181 if( clip.g_y < 0 ) {
182 clip.g_h = work.g_h + clip.g_y;
183 clip.g_y = 0;
184 }
185
186 /* Merge redraw coords: */
187 if( clip.g_h > 0 && clip.g_w > 0 ) {
188
189 GRECT rdrw_area;
190
191 rdrw_area.g_x = clip.g_x;
192 rdrw_area.g_y = clip.g_y;
193 rdrw_area.g_w = clip.g_w;
194 rdrw_area.g_h = clip.g_h;
195
196 //dbg_grect("treeview on_redraw_event ", &rdrw_area);
197
199 }
200}
201
202
203static void __CDECL
204on_mbutton_event(struct core_window *cw, EVMULT_OUT *ev_out, short msg[8])
205{
206 struct atari_treeview_window *tv = (struct atari_treeview_window *)cw;
207 struct gemtk_wm_scroll_info_s *slid;
208 GRECT work;
209 short mx, my;
210 short cur_rel_x, cur_rel_y, dummy, mbut;
211
212 assert(tv);
213
214 gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, &work);
215 slid = gemtk_wm_get_scroll_info(tv->window);
216 mx = ev_out->emo_mouse.p_x;
217 my = ev_out->emo_mouse.p_y;
218
219 /* mouse click relative origin: */
220
221 short origin_rel_x = (mx-work.g_x) + (slid->x_pos*slid->x_unit_px);
222 short origin_rel_y = (my-work.g_y) + (slid->y_pos*slid->y_unit_px);
223
224 /* Only pass on events in the content area: */
225 if ((origin_rel_x >= 0) &&
226 (origin_rel_y >= 0) &&
227 (mx < work.g_x + work.g_w) &&
228 (my < work.g_y + work.g_h)) {
229 if (ev_out->emo_mclicks == 2) {
230 tv->io->mouse_action(cw,
233 origin_rel_x,
234 origin_rel_y);
235 return;
236 }
237
238 graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy);
239 /* check for click or hold: */
240 if ((mbut & 1) == 0 ) {
241 int bms;
243 if(ev_out->emo_mclicks == 2 ) {
245 }
246 tv->io->mouse_action(cw, bms, origin_rel_x, origin_rel_y);
247 } else {
248 /* button still pressed */
249 short prev_x = origin_rel_x;
250 short prev_y = origin_rel_y;
251
252 cur_rel_x = origin_rel_x;
253 cur_rel_y = origin_rel_y;
254
256
257 tv->startdrag.x = origin_rel_x;
258 tv->startdrag.y = origin_rel_y;
259 /* First, report mouse press, to trigger entry selection */
260 tv->io->mouse_action(cw,
263 cur_rel_x,
264 cur_rel_y);
266 tv->io->mouse_action(cw,
269 cur_rel_x,
270 cur_rel_y);
271 do {
272 if (abs(prev_x-cur_rel_x) > 5 ||
273 abs(prev_y-cur_rel_y) > 5) {
274 tv->io->mouse_action(cw,
277 cur_rel_x,
278 cur_rel_y);
279 prev_x = cur_rel_x;
280 prev_y = cur_rel_y;
281 }
282
283 if (tv->redraw) {
284 // TODO: maybe GUI poll would fit better here?
285 // ... is gui_poll re-entrance save?
287 }
288
289 /* sample mouse button state: */
290 graf_mkstate(&cur_rel_x,
291 &cur_rel_y,
292 &mbut,
293 &dummy);
294 cur_rel_x = (cur_rel_x-work.g_x) +
295 (slid->x_pos*slid->x_unit_px);
296 cur_rel_y = (cur_rel_y-work.g_y) +
297 (slid->y_pos*slid->y_unit_px);
298 } while (mbut & 1);
299
300 /* End drag: */
301 tv->io->mouse_action(cw,
303 cur_rel_x,
304 cur_rel_y);
306 }
307 }
308}
309
310
311static void __CDECL
312on_keybd_event(struct core_window *cw, EVMULT_OUT *ev_out, short msg[8])
313{
314 long kstate = 0;
315 long kcode = 0;
316 long ucs4;
317 long ik;
318 unsigned short nkc = 0;
319 unsigned char ascii;
320 struct atari_treeview_window *tv = (struct atari_treeview_window *)cw;
321
322 kstate = ev_out->emo_kmeta;
323 kcode = ev_out->emo_kreturn;
324 nkc= gem_to_norm( (short)kstate, (short)kcode );
325 ascii = (nkc & 0xFF);
326 ik = nkc_to_input_key(nkc, &ucs4);
327
328 if (ik == 0) {
329 if (ascii >= 9) {
330 tv->io->keypress(cw, ucs4);
331 }
332 } else {
333 tv->io->keypress(cw, ik);
334 }
335}
336
337
338/**
339 * GEMTK (netsurf's GEM toolkit) event sink
340 *
341 */
342static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
343{
344 short retval = 0;
345 struct atari_treeview_window *tv = (struct atari_treeview_window *)
346 gemtk_wm_get_user_data(win);
347 struct core_window *cw = (struct core_window *)tv;
348
349 if( (ev_out->emo_events & MU_MESAG) != 0 ) {
350 // handle message
351 switch (msg[0]) {
352
353 case WM_REDRAW:
354 on_redraw_event(cw, ev_out, msg);
355 break;
356
357 default:
358 break;
359 }
360 }
361 if ((ev_out->emo_events & MU_KEYBD) != 0 ) {
362 on_keybd_event(cw, ev_out, msg);
363 }
364 if ((ev_out->emo_events & MU_BUTTON) != 0 ) {
365 NSLOG(netsurf, INFO, "Treeview click at: %d,%d\n",
366 ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y);
367 on_mbutton_event(cw, ev_out, msg);
368 }
369
370 if (tv != NULL && tv->io->gemtk_user_func != NULL){
371 tv->io->gemtk_user_func(win, ev_out, msg);
372 }
373
374 // TODO: evaluate return values of event handler functions and pass them on:
375 return(retval);
376}
377
378
379/**
380 * callback from core to request an invalidation of a window area.
381 *
382 * The specified area of the window should now be considered
383 * out of date. If the area is NULL the entire window must be
384 * invalidated.
385 *
386 * \param[in] cw The core window to invalidate.
387 * \param[in] r area to redraw or NULL for the entire window area.
388 * \return NSERROR_OK on success or appropriate error code.
389 */
390static nserror
391atari_treeview_invalidate_area(struct core_window *cw,
392 const struct rect *r)
393{
394 GRECT area;
395 struct gemtk_wm_scroll_info_s * slid;
396 struct atari_treeview_window * tv = (struct atari_treeview_window *)cw;
397
398 assert(tv);
399
400 if (r != NULL) {
401 RECT_TO_GRECT(r, &area);
402
403 slid = gemtk_wm_get_scroll_info(tv->window);
404
405 //dbg_rect("redraw rect request", r);
406
407 // treeview redraw is always full window width:
408 area.g_x = 0;
409 area.g_w = 8000;
410 // but vertical redraw region is clipped:
411 area.g_y = r->y0 - (slid->y_pos*slid->y_unit_px);
412 area.g_h = r->y1 - r->y0;
413 } else {
415 }
417
418 return NSERROR_OK;
419}
420
421
422/**
423 * Update the limits of the window
424 *
425 * \param cw the core window object
426 * \param width the width in px, or negative if don't care
427 * \param height the height in px, or negative if don't care
428 */
429static nserror
430atari_treeview_update_size(struct core_window *cw, int width, int height)
431{
432 GRECT area;
433 struct gemtk_wm_scroll_info_s *slid;
434 struct atari_treeview_window *tv = (struct atari_treeview_window *)cw;
435
436 if (tv != NULL) {
437
438 if (tv->disposing)
439 return NSERROR_INVALID;
440
441 /* Get acces to the gemtk window slider settings: */
442 slid = gemtk_wm_get_scroll_info(tv->window);
443
444 /* recalculate and refresh sliders: */
446 if (width > -1) {
447 slid->x_units = (width/slid->x_unit_px);
448 } else {
449 slid->x_units = 1;
450 }
451
452 if (height > -1) {
453 slid->y_units = (height/slid->y_unit_px);
454 } else {
455 slid->y_units = 1;
456 }
457
458 tv->extent.x = width;
459 tv->extent.y = height;
460
461
462 /* printf("units content: %d, units viewport: %d\n",
463 (height/slid->y_unit_px),
464 (area.g_h/slid->y_unit_px));
465 */
466 gemtk_wm_update_slider(tv->window, GEMTK_WM_VH_SLIDER);
467 }
468
469 return NSERROR_OK;
470}
471
472
473/**
474 * Scroll the window to make area visible
475 *
476 * \param cw the core window object
477 * \param r rectangle to make visible
478 */
479static nserror
480atari_treeview_set_scroll(struct core_window *cw, int x, int y)
481{
482 /* TODO */
483 return NSERROR_OK;
484}
485
486static nserror
487atari_treeview_get_scroll(const struct core_window *cw, int *x, int *y)
488{
489 /* TODO */
491}
492
493
494/**
495 * Get window viewport dimensions
496 *
497 * \param cw the core window object
498 * \param width to be set to viewport width in px, if non NULL
499 * \param height to be set to viewport height in px, if non NULL
500 */
501static nserror
502atari_treeview_get_window_dimensions(const struct core_window *cw,
503 int *width,
504 int *height)
505{
506 if ((cw != NULL) &&
507 (width != NULL || height != NULL)) {
508 GRECT work;
510 *width = work.g_w;
511 *height = work.g_h;
512 }
513
514 return NSERROR_OK;
515}
516
517
518/**
519 * Inform corewindow owner of drag status
520 *
521 * \param cw the core window object
522 * \param ds the current drag status
523 */
524static nserror
526{
528}
529
530
531/**
532 * Declare Core Window Callbacks:
533 */
534static struct core_window_table cw_t = {
536 .set_extent = atari_treeview_update_size,
537 .set_scroll = atari_treeview_set_scroll,
538 .get_scroll = atari_treeview_get_scroll,
539 .get_dimensions = atari_treeview_get_window_dimensions,
540 .drag_status = atari_treeview_drag_status
541};
542
544
545/* exported interface documented in atari/treeview.h */
546struct core_window *
548 void * user_data, uint32_t flags)
549{
550
551 /* allocate the core_window struct: */
552 struct atari_treeview_window * tv;
553 struct gemtk_wm_scroll_info_s *slid;
554
555 tv = calloc(1, sizeof(struct atari_treeview_window));
556 if (tv == NULL) {
557 NSLOG(netsurf, INFO, "calloc failed");
559 return NULL;
560 }
561
562 /* Store the window ref inside the new treeview: */
563 tv->window = win;
564 tv->io = callbacks;
565 tv->user_data = user_data;
566
567 // Setup gemtk event handler function:
568 gemtk_wm_set_event_handler(win, handle_event);
569
570 // bind window user data to treeview ref:
571 gemtk_wm_set_user_data(win, (void*)tv);
572
573 // Get acces to the gemtk scroll info struct:
574 slid = gemtk_wm_get_scroll_info(tv->window);
575
576 // Setup line and column height/width of the window,
577 // each scroll takes the configured steps:
578 slid->y_unit_px = 16;
579 slid->x_unit_px = 16;
580
581 assert(tv->io);
582 assert(tv->io->init_phase2);
583
584 /* Now that the window is configured for treeview content, */
585 /* call init_phase2 which must create the treeview */
586 /* descriptor, and at least setup the the default */
587 /* event handlers of the treeview: */
588 /* It would be more simple to not pass around the callbacks */
589 /* but the treeview constructor requires them for initialization... */
590 nserror err = tv->io->init_phase2((struct core_window *)tv);
591 if (err != NSERROR_OK) {
592 free(tv);
593 tv = NULL;
594 }
595
596 return((struct core_window *)tv);
597}
598
599
600/* exported interface documented in atari/treeview.h */
601void
602atari_treeview_get_grect(struct core_window *cw,
604 GRECT *dest)
605{
606
607 struct atari_treeview_window *tv = (struct atari_treeview_window *)cw;
608
610 gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, dest);
611 }
612 else if (mode == TREEVIEW_AREA_TOOLBAR) {
613 gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_TOOLBAR, dest);
614 }
615}
616
617
618/* exported interface documented in atari/treeview.h */
619GUIWIN * atari_treeview_get_gemtk_window(struct core_window *cw)
620{
621 struct atari_treeview_window *tv = (struct atari_treeview_window *)cw;
622 return(tv->window);
623}
624
625
626/* exported interface documented in atari/treeview.h */
627void atari_treeview_redraw(struct core_window *cw)
628{
629 struct atari_treeview_window *tv = (struct atari_treeview_window *)cw;
630 short pxy[4];
631
632 if (tv != NULL && tv->is_open) {
633 if( tv->redraw && ((plot_get_flags() & PLOT_FLAG_OFFSCREEN) == 0) ) {
634
635 short todo[4];
636 GRECT work;
637 short handle = gemtk_wm_get_handle(tv->window);
638 struct gemtk_wm_scroll_info_s *slid;
639
640 gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, &work);
641 slid = gemtk_wm_get_scroll_info(tv->window);
642
643// // Debug code: this 3 lines help to inspect the redraw
644// // areas...
645// pxy[0] = work.g_x;
646// pxy[1] = work.g_y;
647// pxy[2] = pxy[0] + work.g_w-1;
648// pxy[3] = pxy[1] + work.g_h-1;
649//
650// vsf_color(plot_get_vdi_handle(), 0);
651// v_bar(plot_get_vdi_handle(), (short*)&pxy);
652// evnt_timer(500);
653
654 struct redraw_context ctx = {
655 .interactive = true,
656 .background_images = true,
657 .plot = &atari_plotters
658 };
660 work.g_x,
661 work.g_y,
662 work.g_w,
663 work.g_h);
664 if (plot_lock() == false)
665 return;
666
667 if( wind_get(handle, WF_FIRSTXYWH,
668 &todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
669 while (todo[2] && todo[3]) {
670
671 if(!rc_intersect(&work, (GRECT*)&todo)){
672 if (wind_get(handle, WF_NEXTXYWH,
673 &todo[0], &todo[1], &todo[2], &todo[3])==0) {
674 break;
675 }
676 continue;
677 }
678 pxy[0] = todo[0];
679 pxy[1] = todo[1];
680 pxy[2] = todo[0] + todo[2]-1;
681 pxy[3] = todo[1] + todo[3]-1;
682 vs_clip(plot_get_vdi_handle(), 1, (short*)&pxy);
683
684 // Debug code: this 3 lines help to inspect the redraw
685 // areas...
686
687// vsf_color(plot_get_vdi_handle(), 3);
688// v_bar(plot_get_vdi_handle(), (short*)&pxy);
689// evnt_timer(500);
690
691
692 /* convert screen to treeview coords: */
693 todo[0] = todo[0] - work.g_x ;//+ slid->x_pos*slid->x_unit_px;
694 todo[1] = todo[1] - work.g_y ;//+ slid->y_pos*slid->y_unit_px;
695 if( todo[0] < 0 ){
696 todo[2] = todo[2] + todo[0];
697 todo[0] = 0;
698 }
699 if( todo[1] < 0 ){
700 todo[3] = todo[3] + todo[1];
701 todo[1] = 0;
702 }
703
704 if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) {
705 struct rect clip;
706
707 clip.x0 = todo[0]+(slid->x_pos*slid->x_unit_px);
708 clip.y0 = todo[1]+(slid->y_pos*slid->y_unit_px);
709 clip.x1 = clip.x0 + todo[2]+(slid->x_pos*slid->x_unit_px);
710 clip.y1 = clip.y0 + todo[3]+(slid->y_pos*slid->y_unit_px);
711
712 tv->io->draw(cw, -(slid->x_pos*slid->x_unit_px),
713 -(slid->y_pos*slid->y_unit_px),
714 &clip, &ctx);
715 }
716 vs_clip(plot_get_vdi_handle(), 0, (short*)&pxy);
717 if (wind_get(handle, WF_NEXTXYWH,
718 &todo[0], &todo[1], &todo[2], &todo[3])==0) {
719 break;
720 }
721 }
722 } else {
723 plot_unlock();
724 return;
725 }
726 plot_unlock();
727 tv->redraw = false;
728 tv->rdw_area.g_x = 65000;
729 tv->rdw_area.g_y = 65000;
730 tv->rdw_area.g_w = -1;
731 tv->rdw_area.g_h = -1;
732 } else {
733 /* just copy stuff from the offscreen buffer */
734 }
735 }
736}
737
738
739/* exported interface documented in atari/treeview.h */
740void atari_treeview_delete(struct core_window * cw)
741{
742 struct atari_treeview_window *tv = (struct atari_treeview_window*)cw;
743
744 assert(tv);
745 assert(tv->io->finish);
746
747 tv->io->finish(cw);
748
749 free(tv);
750}
751
752
753/* exported interface documented in atari/treeview.h */
754void atari_treeview_open(struct core_window *cw, GRECT *pos)
755{
756 struct atari_treeview_window *tv = (struct atari_treeview_window*)cw;
757 if (tv->window != NULL && tv->is_open == false) {
758 tv->is_open = true;
759 wind_open_grect(gemtk_wm_get_handle(tv->window), pos);
760 gemtk_wm_link(tv->window);
761 if (treeviews_open == NULL) {
762 treeviews_open = tv;
765 } else {
766 struct atari_treeview_window * tmp;
767 tmp = treeviews_open;
768 while(tmp->next_open != NULL){
769 tmp = tmp->next_open;
770 }
771 tmp->next_open = tv;
772 tv->prev_open = tmp;
773 tv->next_open = NULL;
774 }
775 }
776}
777
778
779/* exported interface documented in atari/treeview.h */
780bool atari_treeview_is_open(struct core_window *cw)
781{
782 struct atari_treeview_window *tv = (struct atari_treeview_window*)cw;
783 return(tv->is_open);
784}
785
786
787/* exported interface documented in atari/treeview.h */
788void atari_treeview_set_user_data(struct core_window *cw, void *user_data_ptr)
789{
790 struct atari_treeview_window *tv = (struct atari_treeview_window*)cw;
791 tv->user_data = user_data_ptr;
792}
793
794
795/* exported interface documented in atari/treeview.h */
796void * atari_treeview_get_user_data(struct core_window * cw)
797{
798 struct atari_treeview_window *tv = (struct atari_treeview_window*)cw;
799 return(tv->user_data);
800}
801
802
803/* exported interface documented in atari/treeview.h */
804void atari_treeview_close(struct core_window *cw)
805{
806 struct atari_treeview_window *tv = (struct atari_treeview_window*)cw;
807 if (tv->window != NULL) {
808 tv->is_open = false;
809 wind_close(gemtk_wm_get_handle(tv->window));
810 gemtk_wm_unlink(tv->window);
811 /* unlink the window: */
812 if (tv->prev_open != NULL) {
813 tv->prev_open->next_open = tv->next_open;
814 } else {
816 }
817 if (tv->next_open != NULL) {
818 tv->next_open->prev_open = tv->prev_open;
819 }
820 }
821}
822
823
824/* exported interface documented in atari/treeview.h */
826{
827 struct atari_treeview_window *tmp;
828
829 tmp = treeviews_open;
830
831 while (tmp != NULL) {
832 assert(tmp->is_open);
833 if (tmp->redraw &&
834 (!atari_treeview_is_iconified((struct core_window *)tmp))) {
835 /* Content redraw only for iconified windows
836 * because otherwise the icon draw function
837 * would have to deal with plot canvas coords
838 */
839 atari_treeview_redraw((struct core_window *)tmp);
840 }
841 tmp = tmp->next_open;
842 }
843
844}
struct s_gem_cursors gem_cursors
void dbg_grect(const char *str, GRECT *r)
Definition: misc.c:388
void gem_set_cursor(MFORM_EX *cursor)
Definition: misc.c:196
nserror atari_warn_user(const char *warning, const char *detail)
Warn the user of an event.
Definition: misc.c:56
long nkc_to_input_key(short nkc, long *ucs4_out)
Convert NKC to netsurf input key code and/or to ucs4 (depends on keycode).
Definition: misc.c:213
const struct plotter_table atari_plotters
atari plottr operation table
Definition: plot.c:2507
bool plot_lock(void)
Definition: plot.c:1775
long plot_get_flags(void)
Definition: plot.c:1924
VdiHdl plot_get_vdi_handle(void)
Definition: plot.c:1918
bool plot_set_dimensions(const struct redraw_context *ctx, int x, int y, int w, int h)
Set plot origin and canvas size.
Definition: plot.c:1806
bool plot_unlock(void)
Definition: plot.c:1791
#define PLOT_FLAG_OFFSCREEN
offscreen plotter should set this flag
Definition: plot.h:35
static os_mode mode
The current sprite mode.
Definition: buffer.c:72
Interface to core window handling.
core_window_drag_status
drag status passed to drag_status callback
Definition: core_window.h:41
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_NOT_IMPLEMENTED
Functionality is not implemented.
Definition: errors.h:61
@ NSERROR_INVALID
Invalid data.
Definition: errors.h:49
@ NSERROR_NOMEM
Memory exhaustion.
Definition: errors.h:32
@ NSERROR_OK
No error.
Definition: errors.h:30
#define RECT_TO_GRECT(r, g)
Definition: misc.h:33
static nserror atari_treeview_get_window_dimensions(const struct core_window *cw, int *width, int *height)
Get window viewport dimensions.
Definition: treeview.c:502
static nserror atari_treeview_invalidate_area(struct core_window *cw, const struct rect *r)
callback from core to request an invalidation of a window area.
Definition: treeview.c:391
static void __CDECL on_redraw_event(struct core_window *cw, EVMULT_OUT *ev_out, short msg[8])
Definition: treeview.c:145
static struct atari_treeview_window * treeviews_open
Definition: treeview.c:50
void atari_treeview_flush_redraws(void)
Process all redraw request of all open Treeview windows.
Definition: treeview.c:825
void * atari_treeview_get_user_data(struct core_window *cw)
Return the arbitary user data set by atari_treeview_set_user_data()
Definition: treeview.c:796
void atari_treeview_delete(struct core_window *cw)
Free the Treeview, but not the gemtk window used for the treeview.
Definition: treeview.c:740
void atari_treeview_get_grect(struct core_window *cw, enum treeview_area_e mode, GRECT *dest)
Get an specific area inside the window.
Definition: treeview.c:602
static struct core_window_table cw_t
Declare Core Window Callbacks:
Definition: treeview.c:534
bool atari_treeview_is_open(struct core_window *cw)
Returns the window "open" state.
Definition: treeview.c:780
void atari_treeview_redraw(struct core_window *cw)
Process all pending redraw requests for a single treeview.
Definition: treeview.c:627
void atari_treeview_close(struct core_window *cw)
Closes (hides) the treeview window.
Definition: treeview.c:804
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
GEMTK (netsurf's GEM toolkit) event sink.
Definition: treeview.c:342
static nserror atari_treeview_drag_status(struct core_window *cw, core_window_drag_status ds)
Inform corewindow owner of drag status.
Definition: treeview.c:525
static void __CDECL on_mbutton_event(struct core_window *cw, EVMULT_OUT *ev_out, short msg[8])
Definition: treeview.c:204
void atari_treeview_set_user_data(struct core_window *cw, void *user_data_ptr)
Attach arbitary user data to the treeview.
Definition: treeview.c:788
static void atari_treeview_redraw_grect_request(struct core_window *cw, GRECT *area)
Schedule a redraw of the treeview content.
Definition: treeview.c:57
static nserror atari_treeview_get_scroll(const struct core_window *cw, int *x, int *y)
Definition: treeview.c:487
static nserror atari_treeview_set_scroll(struct core_window *cw, int x, int y)
Scroll the window to make area visible.
Definition: treeview.c:480
GUIWIN * atari_treeview_get_gemtk_window(struct core_window *cw)
Get the window manager window handle.
Definition: treeview.c:619
static void __CDECL on_keybd_event(struct core_window *cw, EVMULT_OUT *ev_out, short msg[8])
Definition: treeview.c:312
struct core_window * atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks *callbacks, void *user_data, uint32_t flags)
Initalize an window to be an treeview window.
Definition: treeview.c:547
void atari_treeview_open(struct core_window *cw, GRECT *pos)
Open the treeview window.
Definition: treeview.c:754
static bool atari_treeview_is_iconified(struct core_window *cw)
Definition: treeview.c:107
static void atari_treeview_redraw_icon(struct core_window *cw, GRECT *clip)
Definition: treeview.c:115
struct core_window_table * atari_core_window_table
Definition: treeview.c:543
static nserror atari_treeview_update_size(struct core_window *cw, int width, int height)
Update the limits of the window.
Definition: treeview.c:430
treeview_area_e
Definition: treeview.h:36
@ TREEVIEW_AREA_CONTENT
Definition: treeview.h:39
@ TREEVIEW_AREA_TOOLBAR
Definition: treeview.h:38
@ BROWSER_MOUSE_PRESS_1
button 1 pressed
Definition: mouse.h:50
@ BROWSER_MOUSE_HOVER
No mouse buttons pressed, May be used to indicate hover or end of drag.
Definition: mouse.h:47
@ BROWSER_MOUSE_CLICK_1
button 1 clicked.
Definition: mouse.h:55
@ BROWSER_MOUSE_DOUBLE_CLICK
button double clicked
Definition: mouse.h:60
@ BROWSER_MOUSE_DRAG_1
start of button 1 drag
Definition: mouse.h:65
@ BROWSER_MOUSE_HOLDING_1
during button 1 drag
Definition: mouse.h:73
@ BROWSER_MOUSE_DRAG_ON
a drag operation was started and a mouse button is still pressed
Definition: mouse.h:70
Target independent plotting interface.
Netsurf additional integer type formatting macros.
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
Definition: messages.c:248
Localised message support (interface).
#define MIN(a, b)
Definition: os3support.h:51
int width
Definition: gui.c:160
int height
Definition: gui.c:161
static BList * callbacks
List of all callbacks.
Definition: schedule.cpp:44
atari_treeview_mouse_action_callback mouse_action
Definition: treeview.h:64
gemtk_wm_event_handler_f gemtk_user_func
Definition: treeview.h:65
atari_treeview_init2_callback init_phase2
Definition: treeview.h:60
atari_treeview_keypress_callback keypress
Definition: treeview.h:63
atari_treeview_finish_callback finish
Definition: treeview.h:61
atari_treeview_draw_callback draw
Definition: treeview.h:62
struct atari_treeview_window * prev_open
Definition: treeview.c:36
struct atari_treeview_callbacks * io
Definition: treeview.c:46
struct atari_treeview_window * next_open
Definition: treeview.c:37
Core user interface window function table.
Definition: core_window.h:53
nserror(* invalidate)(struct core_window *cw, const struct rect *rect)
Invalidate an area of a window.
Definition: core_window.h:71
Definition: gui.h:44
int y
Definition: gui.h:46
int x
Definition: gui.h:45
Rectangle coordinates.
Definition: types.h:40
int y0
Top left.
Definition: types.h:41
int y1
Bottom right.
Definition: types.h:42
Redraw context.
Definition: plotters.h:51
bool interactive
Redraw to show interactive features.
Definition: plotters.h:59
MFORM_EX hand
Definition: gui.h:63
MFORM_EX arrow
Definition: gui.h:77
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357