Subversion Repositories Kolibri OS

Rev

Rev 4364 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4364 Rev 5043
Line 41... Line 41...
41
#include "framebuffer/fbtk.h"
41
#include "framebuffer/fbtk.h"
42
#include "framebuffer/image_data.h"
42
#include "framebuffer/image_data.h"
Line 43... Line 43...
43
 
43
 
Line -... Line 44...
-
 
44
#include "widget.h"
-
 
45
 
-
 
46
#ifdef DBG
-
 
47
#undef DBG
-
 
48
#endif
-
 
49
//#define DBG(s) __menuet__debug_out(s) /* For the debug messages in BOARD */
-
 
50
#define DBG(s) LOG((s))            /* So that we see debug in Netsurf's LOG files */
44
#include "widget.h"
51
 
Line 45... Line 52...
45
 
52
 
46
#ifdef FBTK_LOGGING
53
#ifdef FBTK_LOGGING
47
 
54
 
48
/* tree dump debug, also example of depth first tree walk */
55
/* tree dump debug, also example of depth first tree walk */
49
static void
56
static void
50
dump_tk_tree(fbtk_widget_t *widget)
57
dump_tk_tree(fbtk_widget_t *widget)
Line 51... Line 58...
51
{
58
{
52
	widget = fbtk_get_root_widget(widget);
59
	widget = fbtk_get_root_widget(widget);
53
	int indent = 0;
60
	int indent = 0;
54
 
61
 
55
	while (widget != NULL) {
62
	while (widget != NULL) {
56
		LOG(("%*s%p", indent, "", widget));
63
		/* LOG(("%*s%p", indent, "", widget)); */
57
		if (widget->first_child != NULL) {
64
		if (widget->first_child != NULL) {
Line 98... Line 105...
98
	widget->redraw.x = 0;
105
	widget->redraw.x = 0;
99
	widget->redraw.y = 0;
106
	widget->redraw.y = 0;
100
	widget->redraw.width = widget->width;
107
	widget->redraw.width = widget->width;
101
	widget->redraw.height = widget->height;
108
	widget->redraw.height = widget->height;
Line 102... Line 109...
102
 
109
 
103
	LOG(("redrawing %p %d,%d %d,%d",
110
	/* LOG(("redrawing %p %d,%d %d,%d", */
104
	     widget,
111
	/*      widget, */
105
	     widget->redraw.x,
112
	/*      widget->redraw.x, */
106
	     widget->redraw.y,
113
	/*      widget->redraw.y, */
107
	     widget->redraw.width,
114
	/*      widget->redraw.width, */
Line 108... Line 115...
108
	     widget->redraw.height));
115
	/*      widget->redraw.height)); */
109
 
116
 
110
	cwidget = widget->last_child;
117
	cwidget = widget->last_child;
111
	while (cwidget != NULL) {
118
	while (cwidget != NULL) {
Line 123... Line 130...
123
 
130
 
124
/* exported function documented in fbtk.h */
131
/* exported function documented in fbtk.h */
125
int
132
int
126
fbtk_set_mapping(fbtk_widget_t *widget, bool map)
133
fbtk_set_mapping(fbtk_widget_t *widget, bool map)
127
{
134
{
128
	LOG(("setting mapping on %p to %d", widget, map));
135
	/* LOG(("setting mapping on %p to %d", widget, map)); */
129
	widget->mapped = map;
136
	widget->mapped = map;
130
	if (map) {
137
	if (map) {
131
		fbtk_request_redraw(widget);
138
		fbtk_request_redraw(widget);
132
	} else {
139
	} else {
Line 145... Line 152...
145
	fbtk_widget_t *rw; /* the widget to swap lw with */
152
	fbtk_widget_t *rw; /* the widget to swap lw with */
146
	fbtk_widget_t *before;
153
	fbtk_widget_t *before;
147
	fbtk_widget_t *after;
154
	fbtk_widget_t *after;
Line 148... Line 155...
148
 
155
 
149
	rw = lw->next;
156
	rw = lw->next;
150
	LOG(("Swapping %p with %p", lw, rw));
157
	/* LOG(("Swapping %p with %p", lw, rw)); */
151
	before = lw->prev;
158
	before = lw->prev;
Line 152... Line 159...
152
	after = rw->next;
159
	after = rw->next;
153
 
160
 
Line 392... Line 399...
392
	while (widget->parent != NULL)
399
	while (widget->parent != NULL)
393
		widget = widget->parent;
400
		widget = widget->parent;
Line 394... Line 401...
394
 
401
 
395
	/* check root widget was found */
402
	/* check root widget was found */
396
	if (widget->type != FB_WIDGET_TYPE_ROOT) {
403
	if (widget->type != FB_WIDGET_TYPE_ROOT) {
397
		LOG(("Widget with null parent that is not the root widget!"));
404
		/* LOG(("Widget with null parent that is not the root widget!")); */
398
		return NULL;
405
		return NULL;
Line 399... Line 406...
399
	}
406
	}
400
 
407
 
Line 523... Line 530...
523
		int x,
530
		int x,
524
		int y,
531
		int y,
525
		int width,
532
		int width,
526
		int height)
533
		int height)
527
{
534
{
528
	LOG(("New widget..."));
535
	/* LOG(("New widget...")); */
Line 529... Line 536...
529
 
536
 
Line 530... Line 537...
530
	fbtk_widget_t *neww; /* new widget */
537
	fbtk_widget_t *neww; /* new widget */
531
 
538
 
532
	if (parent == NULL)
539
	if (parent == NULL)
Line 533... Line 540...
533
	{LOG(("parent null..."));
540
	{/* LOG(("parent null...")); */
534
		return NULL;}
541
		return NULL;}
535
 
542
 
536
	LOG(("calloc..."));
543
	/* LOG(("calloc...")); */
Line 537... Line 544...
537
	neww = calloc(1, sizeof(fbtk_widget_t));
544
	neww = calloc(1, sizeof(fbtk_widget_t));
538
	if (neww == NULL)
545
	if (neww == NULL)
Line 539... Line 546...
539
		return NULL;
546
		return NULL;
540
 
547
 
541
	LOG(("super!..."));
548
	/* LOG(("super!...")); */
542
	LOG(("creating %p %d,%d %d,%d", neww, x, y, width, height));
549
	/* LOG(("creating %p %d,%d %d,%d", neww, x, y, width, height)); */
Line 559... Line 566...
559
	if ((height + y) > parent->height) {
566
	if ((height + y) > parent->height) {
560
		height = parent->height - y;
567
		height = parent->height - y;
561
	}
568
	}
Line 562... Line 569...
562
 
569
 
563
 
570
 
564
	LOG(("using %p %d,%d %d,%d", neww, x, y, width, height));
571
	/* LOG(("using %p %d,%d %d,%d", neww, x, y, width, height)); */
565
	/* set values */
572
	/* set values */
566
	neww->type = type;
573
	neww->type = type;
567
	neww->x = x;
574
	neww->x = x;
568
	neww->y = y;
575
	neww->y = y;
Line 569... Line 576...
569
	neww->width = width;
576
	neww->width = width;
Line 570... Line 577...
570
	neww->height = height;
577
	neww->height = height;
571
 
578
 
Line 572... Line 579...
572
	/* insert into widget heiarchy */
579
	/* insert into widget heiarchy */
573
 
580
 
574
	LOG(("into hierarchy..."));
581
	/* LOG(("into hierarchy...")); */
575
	neww->parent = parent;
582
	neww->parent = parent;
576
 
583
 
577
	if (parent->first_child == NULL) {
584
	if (parent->first_child == NULL) {
578
		/* no child widgets yet */
585
		/* no child widgets yet */
579
		LOG(("no childs yet..."));
586
		/* LOG(("no childs yet...")); */
580
		parent->last_child = neww;
587
		parent->last_child = neww;
581
	} else {
588
	} else {
582
		/* add new widget to front of sibling chain */
589
		/* add new widget to front of sibling chain */
Line 583... Line 590...
583
		neww->next = parent->first_child;
590
		neww->next = parent->first_child;
584
		neww->next->prev = neww;
591
		neww->next->prev = neww;
585
		LOG(("n front of sibling..."));
592
		/* LOG(("n front of sibling...")); */
Line 586... Line 593...
586
	}
593
	}
587
	parent->first_child = neww;
594
	parent->first_child = neww;
Line 618... Line 625...
618
{
625
{
619
	nsfb_bbox_t plot_ctx;
626
	nsfb_bbox_t plot_ctx;
620
	fbtk_widget_t *cwidget; /* child widget */
627
	fbtk_widget_t *cwidget; /* child widget */
Line 621... Line 628...
621
 
628
 
622
 
629
 
623
	LOG(("DO REDRAW"));
630
	/* LOG(("DO REDRAW")); */
624
	//__menuet__debug_out("\n***********\nDO REDRAW\n********\n");
631
	//DBG("\n***********\nDO REDRAW\n********\n");
625
	/* check if the widget requires redrawing */
632
	/* check if the widget requires redrawing */
626
	if (widget->redraw.needed == true) {
633
	if (widget->redraw.needed == true) {
627
		plot_ctx.x0 = fbtk_get_absx(widget) + widget->redraw.x;
634
		plot_ctx.x0 = fbtk_get_absx(widget) + widget->redraw.x;
628
		plot_ctx.y0 = fbtk_get_absy(widget) + widget->redraw.y;
635
		plot_ctx.y0 = fbtk_get_absy(widget) + widget->redraw.y;
Line 629... Line 636...
629
		plot_ctx.x1 = plot_ctx.x0 + widget->redraw.width;
636
		plot_ctx.x1 = plot_ctx.x0 + widget->redraw.width;
630
		plot_ctx.y1 = plot_ctx.y0 + widget->redraw.height;
637
		plot_ctx.y1 = plot_ctx.y0 + widget->redraw.height;
631
 
638
 
632
		LOG(("clipping %p %d,%d %d,%d",
639
		/* LOG(("clipping %p %d,%d %d,%d", */
Line 633... Line 640...
633
		     widget, plot_ctx.x0, plot_ctx.y0,
640
		/*      widget, plot_ctx.x0, plot_ctx.y0, */
634
		     plot_ctx.x1, plot_ctx.y1));
641
		/*      plot_ctx.x1, plot_ctx.y1)); */
Line 635... Line 642...
635
		if (nsfb_plot_set_clip(nsfb, &plot_ctx) == true) {
642
		if (nsfb_plot_set_clip(nsfb, &plot_ctx) == true) {
636
			
643
			
637
	LOG(("POST CALLBACK"));
644
	/* LOG(("POST CALLBACK")); */
638
	//__menuet__debug_out("\n***********\nPOST CALLBACK\n********\n");
645
	//DBG("\n***********\nPOST CALLBACK\n********\n");
Line 639... Line 646...
639
			
646
			
640
			fbtk_post_callback(widget, FBTK_CBT_REDRAW);
647
			fbtk_post_callback(widget, FBTK_CBT_REDRAW);
Line 641... Line 648...
641
		}
648
		}
642
		widget->redraw.needed = false;
649
		widget->redraw.needed = false;
643
	}
650
	}
644
 
651
 
645
	
652
	
646
	LOG(("DO CHILD"));
653
	/* LOG(("DO CHILD")); */
647
	//__menuet__debug_out("\n***********\nDO CHILD\n********\n");
654
	//DBG("\n***********\nDO CHILD\n********\n");
648
 
655
 
649
	/* walk the widgets children if child flag is set */
656
	/* walk the widgets children if child flag is set */
650
	if (widget->redraw.child) {
657
	if (widget->redraw.child) {
651
		LOG(("DO CHILD 2"));
658
		/* LOG(("DO CHILD 2")); */
652
	//__menuet__debug_out("\n***********\nDO CHILD 2\n********\n");
659
	//DBG("\n***********\nDO CHILD 2\n********\n");
653
		cwidget = widget->last_child;
660
		cwidget = widget->last_child;
654
		while (cwidget != NULL) {
661
		while (cwidget != NULL) {
655
				LOG(("DO CHILD 3 ZZZ"));
662
				/* LOG(("DO CHILD 3 ZZZ")); */
Line 656... Line 663...
656
	//__menuet__debug_out("\n***********\nDO CHILD 3 ZZZ\n********\n");
663
	//DBG("\n***********\nDO CHILD 3 ZZZ\n********\n");
657
			do_redraw(nsfb, cwidget);
664
			do_redraw(nsfb, cwidget);
Line 658... Line 665...
658
			cwidget = cwidget->prev;
665
			cwidget = cwidget->prev;
659
		}
666
		}
Line 660... Line 667...
660
			LOG(("DO CHILD 4"));
667
			/* LOG(("DO CHILD 4")); */
Line 718... Line 725...
718
/* exported function docuemnted in fbtk.h */
725
/* exported function docuemnted in fbtk.h */
719
int
726
int
720
fbtk_post_callback(fbtk_widget_t *widget, fbtk_callback_type cbt, ...)
727
fbtk_post_callback(fbtk_widget_t *widget, fbtk_callback_type cbt, ...)
721
{
728
{
Line 722... Line 729...
722
	
729
	
723
	LOG(("DO POST CALLBACK"));
730
	/* LOG(("DO POST CALLBACK")); */
Line 724... Line 731...
724
	//__menuet__debug_out("\n***********\nDO POST CALLBACK\n********\n");
731
	//DBG("\n***********\nDO POST CALLBACK\n********\n");
725
	
732
	
726
	fbtk_callback_info cbi;
733
	fbtk_callback_info cbi;
Line 733... Line 740...
733
	 * events to it
740
	 * events to it
734
	 */
741
	 */
735
	if (widget->mapped == false)
742
	if (widget->mapped == false)
736
		return ret;
743
		return ret;
Line 737... Line 744...
737
 
744
 
738
	LOG(("DO POST CALLBACK 2"));
745
	/* LOG(("DO POST CALLBACK 2")); */
Line 739... Line 746...
739
	//__menuet__debug_out("\n***********\nDO POST CALLBACK 2\n********\n");
746
	//DBG("\n***********\nDO POST CALLBACK 2\n********\n");
740
 
747
 
741
	if (widget->callback[cbt] != NULL) {
748
	if (widget->callback[cbt] != NULL) {
Line 742... Line 749...
742
		cbi.type = cbt;
749
		cbi.type = cbt;
743
		cbi.context = widget->callback_context[cbt];
750
		cbi.context = widget->callback_context[cbt];
Line 744... Line 751...
744
 
751
 
Line 745... Line 752...
745
	LOG(("DO POST CALLBACK 3 - VA"));
752
	/* LOG(("DO POST CALLBACK 3 - VA")); */
746
	//__menuet__debug_out("\n***********\nDO POST CALLBACK 3 - VA\n********\n");
753
	//DBG("\n***********\nDO POST CALLBACK 3 - VA\n********\n");
747
	
754
	
748
		va_start(ap, cbt);
755
		va_start(ap, cbt);
749
 
756
 
Line 750... Line 757...
750
		switch (cbt) {
757
		switch (cbt) {
751
		case FBTK_CBT_SCROLLX:
758
		case FBTK_CBT_SCROLLX:
752
			//__menuet__debug_out("\n***********\n scroll x - VA\n********\n");
759
			//DBG("\n***********\n scroll x - VA\n********\n");
753
			cbi.x = va_arg(ap,int);
760
			cbi.x = va_arg(ap,int);
Line 754... Line 761...
754
			break;
761
			break;
755
 
762
 
756
		case FBTK_CBT_SCROLLY:
763
		case FBTK_CBT_SCROLLY:
757
			//__menuet__debug_out("\n***********\n scroll y - VA\n********\n");
764
			//DBG("\n***********\n scroll y - VA\n********\n");
758
			cbi.y = va_arg(ap,int);
765
			cbi.y = va_arg(ap,int);
759
			break;
766
			break;
Line 760... Line 767...
760
 
767
 
761
		case FBTK_CBT_CLICK:
768
		case FBTK_CBT_CLICK:
762
			//__menuet__debug_out("\n***********\n click - VA\n********\n");
769
			//DBG("\n***********\n click - VA\n********\n");
763
			cbi.event = va_arg(ap, void *);
770
			cbi.event = va_arg(ap, void *);
Line 764... Line 771...
764
			cbi.x = va_arg(ap, int);
771
			cbi.x = va_arg(ap, int);
765
			cbi.y = va_arg(ap, int);
772
			cbi.y = va_arg(ap, int);
766
			break;
773
			break;
767
 
774
 
768
		case FBTK_CBT_INPUT:
775
		case FBTK_CBT_INPUT:
Line 769... Line 776...
769
			//__menuet__debug_out("\n***********\n input - VA\n********\n");
776
			//DBG("\n***********\n input - VA\n********\n");
770
			cbi.event = va_arg(ap, void *);
777
			cbi.event = va_arg(ap, void *);
771
			break;
778
			break;
Line 772... Line 779...
772
 
779
 
773
		case FBTK_CBT_POINTERMOVE:
780
		case FBTK_CBT_POINTERMOVE:
774
			//__menuet__debug_out("\n***********\n mouse move - VA\n********\n");
781
			//DBG("\n***********\n mouse move - VA\n********\n");
Line 775... Line 782...
775
			cbi.x = va_arg(ap, int);
782
			cbi.x = va_arg(ap, int);
776
			cbi.y = va_arg(ap, int);
783
			cbi.y = va_arg(ap, int);
777
			break;
784
			break;
Line 778... Line 785...
778
 
785
 
779
		case FBTK_CBT_REDRAW:
786
		case FBTK_CBT_REDRAW:
780
		//__menuet__debug_out("\n***********\n red - VA\n********\n");
787
		//DBG("\n***********\n red - VA\n********\n");
781
			break;
788
			break;
Line 782... Line 789...
782
 
789
 
783
		case FBTK_CBT_USER:
790
		case FBTK_CBT_USER:
784
		//__menuet__debug_out("\n***********\n user - VA\n********\n");
791
		//DBG("\n***********\n user - VA\n********\n");
Line 785... Line 792...
785
			break;
792
			break;
786
 
793
 
787
		case FBTK_CBT_STRIP_FOCUS:
794
		case FBTK_CBT_STRIP_FOCUS:
Line 788... Line 795...
788
		//__menuet__debug_out("\n***********\n focus - VA\n********\n");
795
		//DBG("\n***********\n focus - VA\n********\n");
789
			break;
796
			break;
790
 
797
 
Line 791... Line 798...
791
		default:
798
		default:
792
		//__menuet__debug_out("\n***********\n wtf - VA\n********\n");
799
		//DBG("\n***********\n wtf - VA\n********\n");
793
			break;
800
			break;
794
		}
801
		}
Line 795... Line 802...
795
		
802
		
796
		LOG(("DO POST CALLBACK free"));
803
		/* LOG(("DO POST CALLBACK free")); */
797
	//__menuet__debug_out("\n***********\nDO POST CALLBACK free\n********\n");
804
	//DBG("\n***********\nDO POST CALLBACK free\n********\n");
798
		va_end(ap);
805
		va_end(ap);
Line 799... Line 806...
799
 
806
 
800
		
807