NetSurf
window.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2008 François Revol <mmu_man@users.sourceforge.net>
3 * Copyright 2006 Daniel Silverstone <dsilvers@digital-scurf.org>
4 * Copyright 2006 Rob Kendrick <rjek@rjek.com>
5 *
6 * This file is part of NetSurf, http://www.netsurf-browser.org/
7 *
8 * NetSurf is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * NetSurf is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#define __STDBOOL_H__ 1
22#include <stdlib.h>
23#include <assert.h>
24#include <AppDefs.h>
25#include <BeBuild.h>
26#include <Clipboard.h>
27#include <Cursor.h>
28#include <InterfaceDefs.h>
29#include <Message.h>
30#include <ScrollBar.h>
31#include <String.h>
32#include <String.h>
33#include <TextView.h>
34#include <View.h>
35#include <Window.h>
36
37extern "C" {
38#include "utils/nsoption.h"
39#include "utils/log.h"
40#include "utils/utf8.h"
41#include "utils/utils.h"
42#include "utils/nsurl.h"
45#include "netsurf/mouse.h"
46#include "netsurf/plotters.h"
47#include "netsurf/window.h"
48#include "netsurf/clipboard.h"
49#include "netsurf/url_db.h"
50#include "netsurf/keypress.h"
51}
52
53#include "beos/about.h"
54#include "beos/window.h"
55#include "beos/font.h"
56#include "beos/gui.h"
57#include "beos/scaffolding.h"
58#include "beos/plotters.h"
59
60
62
63struct gui_window {
64 /* All gui_window objects have an ultimate scaffold */
67 /* A gui_window is the rendering of a browser_window */
68 struct browser_window *bw;
69
70 struct {
73 int state; /* browser_mouse_state */
75
76 /* These are the storage for the rendering */
80
82
83 // some cached events to speed up things
84 // those are the last queued event of their kind,
85 // we can safely drop others and avoid wasting cpu.
86 // number of pending resizes
88 // accumulated rects of pending redraws
89 //volatile BMessage *lastRedraw;
90 // UNUSED YET
92
93 /* Keep gui_windows in a list for cleanup later */
94 struct gui_window *next, *prev;
95};
96
97
98
99static const rgb_color kWhiteColor = {255, 255, 255, 255};
100
101static struct gui_window *window_list = 0; /**< first entry in win list*/
102
103static BString current_selection;
105
106/* Methods which apply only to a gui_window */
107static void nsbeos_window_expose_event(BView *view, gui_window *g, BMessage *message);
108static void nsbeos_window_keypress_event(BView *view, gui_window *g, BMessage *event);
109static void nsbeos_window_resize_event(BView *view, gui_window *g, BMessage *event);
110static void nsbeos_window_moved_event(BView *view, gui_window *g, BMessage *event);
111/* Other useful bits */
112static void nsbeos_redraw_caret(struct gui_window *g);
113
114
115// #pragma mark - class NSBrowserFrameView
116
117
119 : BView(frame, "NSBrowserFrameView", B_FOLLOW_ALL_SIDES,
120 B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS ),
121 fGuiWindow(gui)
122{
123}
124
125
127{
128}
129
130
131void
133{
134 switch (message->what) {
135 case B_SIMPLE_DATA:
136 case B_ARGV_RECEIVED:
137 case B_REFS_RECEIVED:
138 case B_COPY:
139 case B_CUT:
140 case B_PASTE:
141 case B_SELECT_ALL:
142 //case B_MOUSE_WHEEL_CHANGED:
144 // NetPositive messages
145 case B_NETPOSITIVE_OPEN_URL:
146 case B_NETPOSITIVE_BACK:
147 case B_NETPOSITIVE_FORWARD:
148 case B_NETPOSITIVE_HOME:
149 case B_NETPOSITIVE_RELOAD:
150 case B_NETPOSITIVE_STOP:
151 case B_NETPOSITIVE_DOWN:
152 case B_NETPOSITIVE_UP:
153 // messages for top-level
154 case 'back':
155 case 'forw':
156 case 'stop':
157 case 'relo':
158 case 'home':
159 case 'urlc':
160 case 'urle':
161 case 'sear':
162 case 'menu':
163 case NO_ACTION:
165 case HELP_OPEN_GUIDE:
167 case HELP_OPEN_ABOUT:
171 case HOTLIST_ADD_URL:
172 case HOTLIST_SHOW:
173 case COOKIES_SHOW:
174 case COOKIES_DELETE:
175 case BROWSER_PAGE:
177 case BROWSER_PRINT:
180 case BROWSER_OBJECT:
188 case BROWSER_SAVE:
195 case HOTLIST_EXPORT:
196 case HISTORY_EXPORT:
216 case TREE_NEW_FOLDER:
217 case TREE_NEW_LINK:
218 case TREE_EXPAND_ALL:
224 case TREE_SELECTION:
228 case TREE_SELECT_ALL:
230 case TOOLBAR_BUTTONS:
232 case TOOLBAR_THROBBER:
233 case TOOLBAR_EDIT:
234 case CHOICES_SHOW:
235 case APPLICATION_QUIT:
236 Window()->DetachCurrentMessage();
238 break;
239 default:
240 //message->PrintToStream();
241 BView::MessageReceived(message);
242 }
243}
244
245
246void
248{
249 BMessage *message = NULL;
250 //message = Window()->DetachCurrentMessage();
251 // might be called directly...
252 if (message == NULL)
253 message = new BMessage(_UPDATE_);
254 message->AddRect("rect", updateRect);
255 nsbeos_pipe_message(message, this, fGuiWindow);
256}
257
258
259
260void
261NSBrowserFrameView::FrameResized(float new_width, float new_height)
262{
263 BMessage *message = Window()->DetachCurrentMessage();
264 // discard any other pending resize,
265 // so we don't end up processing them all, the last one matters.
266 atomic_add(&fGuiWindow->pending_resizes, 1);
267 nsbeos_pipe_message(message, this, fGuiWindow);
268 BView::FrameResized(new_width, new_height);
269}
270
271
272void
273NSBrowserFrameView::KeyDown(const char *bytes, int32 numBytes)
274{
275 BMessage *message = Window()->DetachCurrentMessage();
276 nsbeos_pipe_message(message, this, fGuiWindow);
277}
278
279
280void
282{
283 BMessage *message = Window()->DetachCurrentMessage();
284 BPoint screenWhere;
285 if (message->FindPoint("screen_where", &screenWhere) < B_OK) {
286 screenWhere = ConvertToScreen(where);
287 message->AddPoint("screen_where", screenWhere);
288 }
289 nsbeos_pipe_message(message, this, fGuiWindow);
290}
291
292
293void
295{
296 //BMessage *message = Window()->DetachCurrentMessage();
297 //nsbeos_pipe_message(message, this, fGuiWindow);
298 BMessage *message = Window()->DetachCurrentMessage();
299 BPoint screenWhere;
300 if (message->FindPoint("screen_where", &screenWhere) < B_OK) {
301 screenWhere = ConvertToScreen(where);
302 message->AddPoint("screen_where", screenWhere);
303 }
304 nsbeos_pipe_message(message, this, fGuiWindow);
305}
306
307
308void
309NSBrowserFrameView::MouseMoved(BPoint where, uint32 transit, const BMessage *msg)
310{
311 if (transit != B_INSIDE_VIEW) {
312 BView::MouseMoved(where, transit, msg);
313 return;
314 }
315 BMessage *message = Window()->DetachCurrentMessage();
316 nsbeos_pipe_message(message, this, fGuiWindow);
317}
318
319
320// #pragma mark - gui_window
321
323{
324 return g->bw;
325}
326
328{
329 return g->scaffold;
330}
331
333{
334 return g->bw;
335}
336
337/* Create a gui_window */
339 struct gui_window *existing,
341{
342 struct gui_window *g; /**< what we're creating to return */
343
344 g = (struct gui_window *)malloc(sizeof(*g));
345 if (!g) {
346 beos_warn_user("NoMemory", 0);
347 return 0;
348 }
349
350 NSLOG(netsurf, INFO, "Creating gui window %p for browser window %p",
351 g, bw);
352
353 g->bw = bw;
354 g->mouse.state = 0;
356
357 g->careth = 0;
358 g->pending_resizes = 0;
359
360 /* Attach ourselves to the list (push_top) */
361 if (window_list)
362 window_list->prev = g;
363 g->next = window_list;
364 g->prev = NULL;
365 window_list = g;
366
367 /* Now construct and attach a scaffold */
369 if (!g->scaffold)
370 return NULL;
371
372 /* Construct our primary elements */
373 BRect frame(0,0,-1,-1); // will be resized later
374 g->view = new NSBrowserFrameView(frame, g);
375 /* set the default background colour of the drawing area to white. */
376 //g->view->SetViewColor(kWhiteColor);
377 /* NOOO! Since we defer drawing (DetachCurrent()), the white flickers,
378 * besides sometimes text was drawn twice, making it ugly.
379 * Instead we set to transparent here, and implement plot_clg() to
380 * do it just before the rest. This almost removes the flicker. */
381 g->view->SetViewColor(B_TRANSPARENT_COLOR);
382 g->view->SetLowColor(kWhiteColor);
383
384#ifdef B_BEOS_VERSION_DANO
385 /* enable double-buffering on the content view */
386/*
387 XXX: doesn't really work
388 g->view->SetDoubleBuffering(B_UPDATE_INVALIDATED
389 | B_UPDATE_SCROLLED
390 //| B_UPDATE_RESIZED
391 | B_UPDATE_EXPOSED);
392*/
393#endif
394
395
396 g->toplevel = true;
397
398 /* Attach our viewport into the scaffold */
400
401
402 return g;
403}
404
405/* exported interface documented in beos/window.h */
406void nsbeos_dispatch_event(BMessage *message)
407{
408 struct gui_window *gui = NULL;
409 NSBrowserFrameView *view = NULL;
410 struct beos_scaffolding *scaffold = NULL;
411 NSBrowserWindow *window = NULL;
412
413 //message->PrintToStream();
414 if (message->FindPointer("View", (void **)&view) < B_OK)
415 view = NULL;
416 if (message->FindPointer("gui_window", (void **)&gui) < B_OK)
417 gui = NULL;
418 if (message->FindPointer("Window", (void **)&window) < B_OK)
419 window = NULL;
420 if (message->FindPointer("scaffolding", (void **)&scaffold) < B_OK)
421 scaffold = NULL;
422
423 struct gui_window *z;
424 for (z = window_list; z && gui && z != gui; z = z->next)
425 continue;
426
427 struct gui_window *y;
428 for (y = window_list; y && scaffold && y->scaffold != scaffold; y = y->next)
429 continue;
430
431 if (gui && gui != z) {
432 NSLOG(netsurf, INFO,
433 "discarding event for destroyed gui_window");
434 delete message;
435 return;
436 }
437 if (scaffold && (!y || scaffold != y->scaffold)) {
438 NSLOG(netsurf, INFO,
439 "discarding event for destroyed scaffolding");
440 delete message;
441 return;
442 }
443
444 // messages for top-level
445 if (scaffold) {
446 NSLOG(netsurf, INFO, "dispatching to top-level");
448 delete message;
449 return;
450 }
451
452 NSLOG(netsurf, DEEPDEBUG, "processing message");
453 switch (message->what) {
454 case B_QUIT_REQUESTED:
455 // from the BApplication
456 nsbeos_done = true;
457 break;
458 case B_ABOUT_REQUESTED:
459 {
460 if (gui == NULL)
463 break;
464 }
465 case _UPDATE_:
466 if (gui && view)
468 break;
469 case B_MOUSE_MOVED:
470 {
471 if (gui == NULL)
472 break;
473
474 BPoint where;
475 int32 mods;
476 // where refers to Window coords !?
477 // check be:view_where first
478 if (message->FindPoint("be:view_where", &where) < B_OK) {
479 if (message->FindPoint("where", &where) < B_OK)
480 break;
481 }
482 if (message->FindInt32("modifiers", &mods) < B_OK)
483 mods = 0;
484
485
487 /* Start button 1 drag */
490 /* Replace PRESS with HOLDING and declare drag in progress */
494 } else if (gui->mouse.state & BROWSER_MOUSE_PRESS_2) {
495 /* Start button 2 drag */
498 /* Replace PRESS with HOLDING and declare drag in progress */
502 }
503
504 bool shift = mods & B_SHIFT_KEY;
505 bool ctrl = mods & B_CONTROL_KEY;
506
507 /* Handle modifiers being removed */
508 if (gui->mouse.state & BROWSER_MOUSE_MOD_1 && !shift)
510 if (gui->mouse.state & BROWSER_MOUSE_MOD_2 && !ctrl)
512
515 (int)(where.x),
516 (int)(where.y));
517
518 gui->last_x = (int)where.x;
519 gui->last_y = (int)where.y;
520 break;
521 }
522 case B_MOUSE_DOWN:
523 {
524 if (gui == NULL)
525 break;
526
527 BPoint where;
528 int32 buttons;
529 int32 mods;
530 BPoint screenWhere;
531 if (message->FindPoint("be:view_where", &where) < B_OK) {
532 if (message->FindPoint("where", &where) < B_OK)
533 break;
534 }
535 if (message->FindInt32("buttons", &buttons) < B_OK)
536 break;
537 if (message->FindPoint("screen_where", &screenWhere) < B_OK)
538 break;
539 if (message->FindInt32("modifiers", &mods) < B_OK)
540 mods = 0;
541
542 if (buttons & B_SECONDARY_MOUSE_BUTTON) {
543 /* 2 == right button on BeOS */
544 nsbeos_scaffolding_popup_menu(gui->scaffold, gui->bw, where, screenWhere);
545 break;
546 }
547
549
550 if (buttons & B_TERTIARY_MOUSE_BUTTON) /* 3 == middle button on BeOS */
552
553 if (mods & B_SHIFT_KEY)
555 if (mods & B_CONTROL_KEY)
557
558 gui->mouse.pressed_x = where.x;
559 gui->mouse.pressed_y = where.y;
560
561 // make sure the view is in focus
562 if (view && view->LockLooper()) {
563 if (!view->IsFocus())
564 view->MakeFocus();
565 view->UnlockLooper();
566 }
567
571
572 break;
573 }
574 case B_MOUSE_UP:
575 {
576 if (gui == NULL)
577 break;
578
579 BPoint where;
580 int32 buttons;
581 int32 mods;
582 BPoint screenWhere;
583 if (message->FindPoint("be:view_where", &where) < B_OK) {
584 if (message->FindPoint("where", &where) < B_OK)
585 break;
586 }
587 if (message->FindInt32("buttons", &buttons) < B_OK)
588 break;
589 if (message->FindPoint("screen_where", &screenWhere) < B_OK)
590 break;
591 if (message->FindInt32("modifiers", &mods) < B_OK)
592 mods = 0;
593
594 /* If the mouse state is PRESS then we are waiting for a release to emit
595 * a click event, otherwise just reset the state to nothing*/
600
601 bool shift = mods & B_SHIFT_KEY;
602 bool ctrl = mods & B_CONTROL_KEY;
603
604 /* Handle modifiers being removed */
605 if (gui->mouse.state & BROWSER_MOUSE_MOD_1 && !shift)
607 if (gui->mouse.state & BROWSER_MOUSE_MOD_2 && !ctrl)
609
610 /*
611 if (view && view->LockLooper()) {
612 view->MakeFocus();
613 view->UnlockLooper();
614 }
615 */
616
620 where.x,
621 where.y);
622 else
624 where.x, where.y);
625
626 gui->mouse.state = 0;
627
628 break;
629 }
630 case B_KEY_DOWN:
631 if (gui && view)
633 break;
634 case B_VIEW_RESIZED:
635 if (gui && view)
637 break;
638 case B_VIEW_MOVED:
639 if (gui && view)
641 break;
642 case B_MOUSE_WHEEL_CHANGED:
643 break;
646 break;
647 case 'nsLO': // login
648 {
649 nsurl* url;
650 BString realm;
651 BString username;
652 BString password;
653 void* cbpw;
654 nserror (*cb)(const char *username,
655 const char *password,
656 void *pw);
657
658 if (message->FindPointer("URL", (void**)&url) < B_OK)
659 break;
660 if (message->FindString("Realm", &realm) < B_OK)
661 break;
662 if (message->FindString("User", &username) < B_OK)
663 break;
664 if (message->FindString("Pass", &password) < B_OK)
665 break;
666 if (message->FindPointer("callback", (void**)&cb) < B_OK)
667 break;
668 if (message->FindPointer("callback_pw", (void**)&cbpw) < B_OK)
669 break;
670 cb(username.String(), password.String(), cbpw);
671 break;
672 }
673 default:
674 break;
675 }
676 delete message;
677}
678
679void nsbeos_window_expose_event(BView *view, gui_window *g, BMessage *message)
680{
681 BRect updateRect;
682 struct rect clip;
683
684 struct redraw_context ctx = { true, true, &nsbeos_plotters };
685
686 assert(g);
687 assert(g->bw);
688
689 struct gui_window *z;
690 for (z = window_list; z && z != g; z = z->next)
691 continue;
692 assert(z);
693 assert(g->view == view);
694
695 // we'll be resizing = reflowing = redrawing everything anyway...
696 if (g->pending_resizes > 1)
697 return;
698
699 if (message->FindRect("rect", &updateRect) < B_OK)
700 return;
701
702 if (browser_window_has_content(g->bw) == false)
703 return;
704
705 if (!view->LockLooper())
706 return;
708
709 if (view->Window())
710 view->Window()->BeginViewTransaction();
711
712 clip.x0 = (int)updateRect.left;
713 clip.y0 = (int)updateRect.top;
714 clip.x1 = (int)updateRect.right + 1;
715 clip.y1 = (int)updateRect.bottom + 1;
716
717 browser_window_redraw(g->bw, 0, 0, &clip, &ctx);
718
719 if (g->careth != 0)
721
722 if (view->Window())
723 view->Window()->EndViewTransaction();
724
725 // reset clipping just in case
726 view->ConstrainClippingRegion(NULL);
728 view->UnlockLooper();
729}
730
731void nsbeos_window_keypress_event(BView *view, gui_window *g, BMessage *event)
732{
733 const char *bytes;
734 char buff[6];
735 int numbytes = 0;
736 uint32 mods;
737 uint32 key;
738 uint32 raw_char;
739 uint32_t nskey;
740 int i;
741
742 if (event->FindInt32("modifiers", (int32 *)&mods) < B_OK)
743 mods = modifiers();
744 if (event->FindInt32("key", (int32 *)&key) < B_OK)
745 key = 0;
746 if (event->FindInt32("raw_char", (int32 *)&raw_char) < B_OK)
747 raw_char = 0;
748 /* check for byte[] first, because C-space gives bytes="" (and byte[0] = '\0') */
749 for (i = 0; i < 5; i++) {
750 buff[i] = '\0';
751 if (event->FindInt8("byte", i, (int8 *)&buff[i]) < B_OK)
752 break;
753 }
754
755 if (i) {
756 bytes = buff;
757 numbytes = i;
758 } else if (event->FindString("bytes", &bytes) < B_OK)
759 bytes = "";
760
761 if (!numbytes)
762 numbytes = strlen(bytes);
763
764 NSLOG(netsurf, INFO, "mods 0x%08lx key %ld raw %ld byte[0] %d", mods,
765 key, raw_char, buff[0]);
766
767 char byte;
768 if (numbytes == 1) {
769 byte = bytes[0];
770 if (mods & B_CONTROL_KEY)
771 byte = (char)raw_char;
772 if (byte >= '!' && byte <= '~')
773 nskey = (uint32_t)byte;
774 else {
775 switch (byte) {
776 case B_BACKSPACE: nskey = NS_KEY_DELETE_LEFT; break;
777 case B_TAB: nskey = NS_KEY_TAB; break;
778 /*case XK_Linefeed: return QKlinefeed;*/
779 case B_ENTER: nskey = (uint32_t)10; break;
780 case B_ESCAPE: nskey = (uint32_t)'\033'; break;
781 case B_SPACE: nskey = (uint32_t)' '; break;
782 case B_DELETE: nskey = NS_KEY_DELETE_RIGHT; break;
783 /*
784 case B_INSERT: nskey = NS_KEYSYM("insert"); break;
785 */
786 case B_HOME: nskey = NS_KEY_LINE_START; break; // XXX ?
787 case B_END: nskey = NS_KEY_LINE_END; break; // XXX ?
788 case B_PAGE_UP: nskey = NS_KEY_PAGE_UP; break;
789 case B_PAGE_DOWN: nskey = NS_KEY_PAGE_DOWN; break;
790 case B_LEFT_ARROW: nskey = NS_KEY_LEFT; break;
791 case B_RIGHT_ARROW: nskey = NS_KEY_RIGHT; break;
792 case B_UP_ARROW: nskey = NS_KEY_UP; break;
793 case B_DOWN_ARROW: nskey = NS_KEY_DOWN; break;
794 /*
795 case B_FUNCTION_KEY:
796 switch (scancode) {
797 case B_F1_KEY: nskey = KEYSYM("f1"); break;
798 case B_F2_KEY: nskey = KEYSYM("f2"); break;
799 case B_F3_KEY: nskey = KEYSYM("f3"); break;
800 case B_F4_KEY: nskey = KEYSYM("f4"); break;
801 case B_F5_KEY: nskey = KEYSYM("f5"); break;
802 case B_F6_KEY: nskey = KEYSYM("f6"); break;
803 case B_F7_KEY: nskey = KEYSYM("f7"); break;
804 case B_F8_KEY: nskey = KEYSYM("f8"); break;
805 case B_F9_KEY: nskey = KEYSYM("f9"); break;
806 case B_F10_KEY: nskey = KEYSYM("f10"); break;
807 case B_F11_KEY: nskey = KEYSYM("f11"); break;
808 case B_F12_KEY: nskey = KEYSYM("f12"); break;
809 case B_PRINT_KEY: nskey = KEYSYM("print"); break;
810 case B_SCROLL_KEY: nskey = KEYSYM("scroll-lock"); break;
811 case B_PAUSE_KEY: nskey = KEYSYM("pause"); break;
812 }
813 */
814 case 0:
815 nskey = (uint32_t)0;
816 default:
817 nskey = (uint32_t)raw_char;
818 /*if (simple_p)
819 nskey = (uint32_t)0;*/
820 break;
821 }
822 }
823 } else {
824 nskey = utf8_to_ucs4(bytes, numbytes);
825 }
826
827 if(browser_window_key_press(g->bw, nskey))
828 return;
829
830 // Remaining events are for scrolling the page around
831 float hdelta = 0.0f, vdelta = 0.0f;
832 g->view->LockLooper();
833 BRect size = g->view->Bounds();
834 switch (byte) {
835 case B_HOME:
836 g->view->ScrollTo(0.0f, 0.0f);
837 break;
838 case B_END:
839 {
840 // TODO
841 break;
842 }
843 case B_PAGE_UP:
844 vdelta = -size.Height();
845 break;
846 case B_PAGE_DOWN:
847 vdelta = size.Height();
848 break;
849 case B_LEFT_ARROW:
850 hdelta = -10;
851 break;
852 case B_RIGHT_ARROW:
853 hdelta = 10;
854 break;
855 case B_UP_ARROW:
856 vdelta = -10;
857 break;
858 case B_DOWN_ARROW:
859 vdelta = 10;
860 break;
861 }
862
863 g->view->ScrollBy(hdelta, vdelta);
864 g->view->UnlockLooper();
865}
866
867
868void nsbeos_window_resize_event(BView *view, gui_window *g, BMessage *event)
869{
870 //CALLED();
871 int32 width;
873
874 // drop this event if we have at least 2 resize pending
875 if (atomic_add(&g->pending_resizes, -1) > 1)
876 return;
877
878 if (event->FindInt32("width", &width) < B_OK)
879 width = -1;
880 if (event->FindInt32("height", &height) < B_OK)
881 height = -1;
882 width++;
883 height++;
884
886
887 return;
888}
889
890
891void nsbeos_window_moved_event(BView *view, gui_window *g, BMessage *event)
892{
893 //CALLED();
894
895#warning XXX: Invalidate ?
896 if (!view || !view->LockLooper())
897 return;
898 //view->Invalidate(view->Bounds());
899 view->UnlockLooper();
900
901 return;
902}
903
904
906{
907 for (struct gui_window *g = window_list; g; g = g->next) {
909 }
910}
911
912
914{
916}
917
918static void gui_window_destroy(struct gui_window *g)
919{
920 if (!g)
921 return;
922
923 if (g->prev)
924 g->prev->next = g->next;
925 else
926 window_list = g->next;
927
928 if (g->next)
929 g->next->prev = g->prev;
930
931
932 NSLOG(netsurf, INFO, "Destroying gui_window %p", g);
933 assert(g != NULL);
934 assert(g->bw != NULL);
935 NSLOG(netsurf, INFO, " Scaffolding: %p", g->scaffold);
936
937 if (g->view == NULL)
938 return;
939 if (!g->view->LockLooper())
940 return;
941
942 BLooper *looper = g->view->Looper();
943 /* If we're a top-level gui_window, destroy our scaffold */
944 if (g->toplevel) {
945 g->view->RemoveSelf();
946 delete g->view;
948 } else {
949 g->view->RemoveSelf();
950 delete g->view;
951 looper->Unlock();
952 }
953 //XXX
954 //looper->Unlock();
955
956
957 free(g);
958
959}
960
962{
963 if (g->careth == 0)
964 return;
965
966 if (g->view == NULL)
967 return;
968 if (!g->view->LockLooper())
969 return;
970
972
973 g->view->Invalidate(BRect(g->caretx, g->carety,
974 g->caretx, g->carety + g->careth));
975
977 g->view->UnlockLooper();
978}
979
980/**
981 * Invalidate an area of a beos browser window
982 *
983 * \param g The netsurf window being invalidated.
984 * \param rect area to redraw or NULL for entrire window area.
985 * \return NSERROR_OK or appropriate error code.
986 */
987static nserror
989{
990 if (browser_window_has_content(g->bw) == false) {
991 return NSERROR_OK;
992 }
993
994 if (g->view == NULL) {
995 return NSERROR_OK;
996 }
997
998 if (!g->view->LockLooper()) {
999 return NSERROR_OK;
1000 }
1001
1002 if (rect != NULL) {
1003 //XXX +1 ??
1004 g->view->Invalidate(BRect(rect->x0, rect->y0,
1005 rect->x1 - 1, rect->y1 - 1));
1006 } else {
1007 g->view->Invalidate();
1008 }
1009
1010 g->view->UnlockLooper();
1011
1012 return NSERROR_OK;
1013}
1014
1015static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
1016{
1017 //CALLED();
1018 if (g->view == NULL)
1019 return false;
1020 if (!g->view->LockLooper())
1021 return false;
1022
1023#warning XXX: report to view frame ?
1024 if (g->view->ScrollBar(B_HORIZONTAL))
1025 *sx = (int)g->view->ScrollBar(B_HORIZONTAL)->Value();
1026 if (g->view->ScrollBar(B_VERTICAL))
1027 *sy = (int)g->view->ScrollBar(B_VERTICAL)->Value();
1028
1029 g->view->UnlockLooper();
1030 return true;
1031}
1032
1033/**
1034 * Set the scroll position of a beos browser window.
1035 *
1036 * Scrolls the viewport to ensure the specified rectangle of the
1037 * content is shown. The beos implementation scrolls the contents so
1038 * the specified point in the content is at the top of the viewport.
1039 *
1040 * \param g gui window to scroll
1041 * \param rect The rectangle to ensure is shown.
1042 * \return NSERROR_OK on success or apropriate error code.
1043 */
1044static nserror
1046{
1047 //CALLED();
1048 if (g->view == NULL) {
1049 return NSERROR_BAD_PARAMETER;
1050 }
1051 if (!g->view->LockLooper()) {
1052 return NSERROR_BAD_PARAMETER;
1053 }
1054
1055#warning XXX: report to view frame ?
1056 if (g->view->ScrollBar(B_HORIZONTAL)) {
1057 g->view->ScrollBar(B_HORIZONTAL)->SetValue(rect->x0);
1058 }
1059 if (g->view->ScrollBar(B_VERTICAL)) {
1060 g->view->ScrollBar(B_VERTICAL)->SetValue(rect->y0);
1061 }
1062
1063 g->view->UnlockLooper();
1064
1065 return NSERROR_OK;
1066}
1067
1068
1070{
1071 nserror err;
1072 //CALLED();
1073 if (browser_window_has_content(g->bw) == false)
1074 return;
1075
1076 if (g->view == NULL)
1077 return;
1078 if (!g->view->LockLooper())
1079 return;
1080
1081 int x_max, y_max;
1082
1083 err = browser_window_get_extents(g->bw, true, &x_max, &y_max);
1084 if (err != NSERROR_OK)
1085 return;
1086
1087 float x_prop = g->view->Bounds().Width() / x_max;
1088 float y_prop = g->view->Bounds().Height() / y_max;
1089 x_max -= g->view->Bounds().Width() + 1;
1090 y_max -= g->view->Bounds().Height() + 1;
1091
1092 NSLOG(netsurf, INFO,
1093 "x_max = %d y_max = %d x_prop = %f y_prop = %f\n", x_max,
1094 y_max, x_prop, y_prop);
1095
1096 if (g->view->ScrollBar(B_HORIZONTAL)) {
1097 g->view->ScrollBar(B_HORIZONTAL)->SetRange(0, x_max);
1098 g->view->ScrollBar(B_HORIZONTAL)->SetProportion(x_prop);
1099 g->view->ScrollBar(B_HORIZONTAL)->SetSteps(10, 50);
1100 }
1101 if (g->view->ScrollBar(B_VERTICAL)) {
1102 g->view->ScrollBar(B_VERTICAL)->SetRange(0, y_max);
1103 g->view->ScrollBar(B_VERTICAL)->SetProportion(y_prop);
1104 g->view->ScrollBar(B_VERTICAL)->SetSteps(10, 50);
1105 }
1106
1107
1108 g->view->UnlockLooper();
1109}
1110
1112{
1113 switch (shape) {
1114 case GUI_POINTER_POINT: /* link */
1115 return B_CURSOR_ID_FOLLOW_LINK;
1116
1117 case GUI_POINTER_CARET: /* input */
1118 return B_CURSOR_ID_I_BEAM;
1119
1120 case GUI_POINTER_MENU:
1121 return B_CURSOR_ID_CONTEXT_MENU;
1122
1123 case GUI_POINTER_UP:
1124 return B_CURSOR_ID_RESIZE_NORTH;
1125
1126 case GUI_POINTER_DOWN:
1127 return B_CURSOR_ID_RESIZE_SOUTH;
1128
1129 case GUI_POINTER_LEFT:
1130 return B_CURSOR_ID_RESIZE_WEST;
1131
1132 case GUI_POINTER_RIGHT:
1133 return B_CURSOR_ID_RESIZE_EAST;
1134
1135 case GUI_POINTER_RU:
1136 return B_CURSOR_ID_RESIZE_NORTH_EAST;
1137
1138 case GUI_POINTER_LD:
1139 return B_CURSOR_ID_RESIZE_SOUTH_WEST;
1140
1141 case GUI_POINTER_LU:
1142 return B_CURSOR_ID_RESIZE_NORTH_WEST;
1143
1144 case GUI_POINTER_RD:
1145 return B_CURSOR_ID_RESIZE_SOUTH_EAST;
1146
1147 case GUI_POINTER_CROSS:
1148 return B_CURSOR_ID_CROSS_HAIR;
1149
1150 case GUI_POINTER_MOVE:
1151 return B_CURSOR_ID_MOVE;
1152
1153 case GUI_POINTER_WAIT:
1155 return B_CURSOR_ID_PROGRESS;
1156
1159 return B_CURSOR_ID_NOT_ALLOWED;
1160
1161 case GUI_POINTER_HELP:
1162 return B_CURSOR_ID_HELP;
1163
1165 default:
1166 break;
1167 }
1168 return B_CURSOR_ID_SYSTEM_DEFAULT;
1169}
1170
1172{
1173 if (g->current_pointer == shape)
1174 return;
1175
1176 g->current_pointer = shape;
1177
1178 BCursor cursor(gui_haiku_pointer(shape));
1179
1180 if (g->view && g->view->LockLooper()) {
1181 g->view->SetViewCursor(&cursor);
1182 g->view->UnlockLooper();
1183 }
1184}
1185
1186static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
1187 const struct rect *clip)
1188{
1189 //CALLED();
1190 if (g->view == NULL)
1191 return;
1192 if (!g->view->LockLooper())
1193 return;
1194
1196
1197 g->caretx = x;
1198 g->carety = y + 1;
1199 g->careth = height - 2;
1200
1202 g->view->MakeFocus();
1203
1204 g->view->UnlockLooper();
1205}
1206
1208{
1209 int oh = g->careth;
1210
1211 if (oh == 0)
1212 return;
1213
1214 g->careth = 0;
1215
1216 if (g->view == NULL)
1217 return;
1218 if (!g->view->LockLooper())
1219 return;
1220
1222
1223 g->view->Invalidate(BRect(g->caretx, g->carety, g->caretx, g->carety + oh));
1224
1226 g->view->UnlockLooper();
1227}
1228
1230{
1231 if (!g->toplevel)
1232 return;
1233
1234 if (g->view == NULL)
1235 return;
1236 if (!g->view->LockLooper())
1237 return;
1238
1239 // scroll back to top
1240 g->view->ScrollTo(0,0);
1241
1242 g->view->UnlockLooper();
1243}
1244
1245static void gui_start_selection(struct gui_window *g)
1246{
1247 if (!g->view->LockLooper())
1248 return;
1249
1250 g->view->MakeFocus();
1251
1252 g->view->UnlockLooper();
1253}
1254
1255static void gui_get_clipboard(char **buffer, size_t *length)
1256{
1257 BMessage *clip;
1258 *length = 0;
1259 *buffer = NULL;
1260
1261 if (be_clipboard->Lock()) {
1262 clip = be_clipboard->Data();
1263 if (clip) {
1264 const char *text;
1265 ssize_t textlen;
1266 if (clip->FindData("text/plain", B_MIME_TYPE,
1267 (const void **)&text, &textlen) >= B_OK) {
1268 *buffer = (char *)malloc(textlen);
1269 *length = textlen;
1270 memcpy(*buffer, text, textlen);
1271 }
1272 }
1273 be_clipboard->Unlock();
1274 }
1275}
1276
1277static void gui_set_clipboard(const char *buffer, size_t length,
1278 nsclipboard_styles styles[], int n_styles)
1279{
1280 BMessage *clip;
1281
1282 if (be_clipboard->Lock()) {
1283 be_clipboard->Clear();
1284 clip = be_clipboard->Data();
1285 if (clip) {
1286 clip->AddData("text/plain", B_MIME_TYPE, buffer, length);
1287
1288 int arraySize = sizeof(text_run_array) +
1289 n_styles * sizeof(text_run);
1290 text_run_array *array = (text_run_array *)malloc(arraySize);
1291 array->count = n_styles;
1292 for (int i = 0; i < n_styles; i++) {
1293 BFont font;
1294 nsbeos_style_to_font(font, &styles[i].style);
1295 array->runs[i].offset = styles[i].start;
1296 array->runs[i].font = font;
1297 array->runs[i].color =
1298 nsbeos_rgb_colour(styles[i].style.foreground);
1299 }
1300 clip->AddData("application/x-vnd.Be-text_run_array", B_MIME_TYPE,
1301 array, arraySize);
1302 free(array);
1303 be_clipboard->Commit();
1304 }
1305 be_clipboard->Unlock();
1306 }
1307}
1308
1312};
1313
1315
1316/**
1317 * Find the current dimensions of a beos browser window content area.
1318 *
1319 * \param g The gui window to measure content area of.
1320 * \param width receives width of window
1321 * \param height receives height of window
1322 * \return NSERROR_OK on sucess and width and height updated
1323 * else error code.
1324 */
1325static nserror
1327{
1328 if (g->view &&
1329 g->view->LockLooper()) {
1330 *width = g->view->Bounds().Width() + 1;
1331 *height = g->view->Bounds().Height() + 1;
1332 g->view->UnlockLooper();
1333 }
1334 return NSERROR_OK;
1335}
1336
1337
1338/**
1339 * process miscellaneous window events
1340 *
1341 * \param gw The window receiving the event.
1342 * \param event The event code.
1343 * \return NSERROR_OK when processed ok
1344 */
1345static nserror
1347{
1348 switch (event) {
1351 break;
1352
1355 break;
1356
1359 break;
1360
1363 break;
1364
1367 break;
1368
1371 break;
1372
1373 default:
1374 break;
1375 }
1376 return NSERROR_OK;
1377}
1378
1379
1388
1389 /* from scaffold */
1396 NULL, //drag_start
1397 NULL, //save_link
1398 NULL, //create_form_select_menu
1399 NULL, //file_gadget_open
1400 NULL, //drag_save_object
1401 NULL, //drag_save_selection
1402 NULL //console_log
1403};
1404
void nsbeos_about(struct gui_window *gui)
Creates the about alert.
Definition: about.cpp:44
static void gui_window_set_status(struct gui_window *g, const char *text)
Definition: gui.c:5937
static nserror gui_window_set_url(struct gui_window *g, nsurl *url)
Definition: gui.c:5971
static void gui_window_set_title(struct gui_window *g, const char *restrict title)
Definition: gui.c:3622
static void gui_window_set_icon(struct gui_window *g, struct hlcache_handle *icon)
function to add retrieved favicon to gui
Definition: gui.c:2464
void gui_window_stop_throbber(struct gui_window *g)
Definition: theme.c:432
void gui_window_start_throbber(struct gui_window *g)
Definition: theme.c:413
static struct s_view view
Definition: plot.c:199
#define B_UI_SETTINGS_CHANGED
Definition: gui.h:28
@ HELP_OPEN_ABOUT
Definition: scaffolding.h:86
@ BROWSER_WINDOW_STAGGER
Definition: scaffolding.h:149
@ TREE_EXPAND_FOLDERS
Definition: scaffolding.h:157
@ BROWSER_NAVIGATE_HOME
Definition: scaffolding.h:131
@ TREE_EXPAND_ALL
Definition: scaffolding.h:156
@ BROWSER_SCALE_VIEW
Definition: scaffolding.h:141
@ BROWSER_PAGE_INFO
Definition: scaffolding.h:104
@ BROWSER_OBJECT_SAVE
Definition: scaffolding.h:115
@ BROWSER_NAVIGATE_FORWARD
Definition: scaffolding.h:133
@ BROWSER_BUFFER_ALL
Definition: scaffolding.h:146
@ BROWSER_BUFFER_ANIMS
Definition: scaffolding.h:145
@ TREE_COLLAPSE_FOLDERS
Definition: scaffolding.h:160
@ TOOLBAR_ADDRESS_BAR
Definition: scaffolding.h:171
@ BROWSER_OBJECT_RELOAD
Definition: scaffolding.h:112
@ TREE_SELECTION
Definition: scaffolding.h:162
@ BROWSER_OBJECT_EXPORT_SPRITE
Definition: scaffolding.h:116
@ BROWSER_WINDOW_RESET
Definition: scaffolding.h:151
@ BROWSER_WINDOW_COPY
Definition: scaffolding.h:150
@ CHOICES_SHOW
Definition: scaffolding.h:176
@ BROWSER_OBJECT_SAVE_URL_URI
Definition: scaffolding.h:117
@ COOKIES_SHOW
Definition: scaffolding.h:99
@ BROWSER_SAVE_VIEW
Definition: scaffolding.h:147
@ BROWSER_IMAGES_BACKGROUND
Definition: scaffolding.h:144
@ BROWSER_NAVIGATE_RELOAD
Definition: scaffolding.h:135
@ BROWSER_OBJECT
Definition: scaffolding.h:110
@ BROWSER_NEW_WINDOW
Definition: scaffolding.h:106
@ BROWSER_NAVIGATE_BACK
Definition: scaffolding.h:132
@ BROWSER_PRINT
Definition: scaffolding.h:105
@ BROWSER_NAVIGATE_STOP
Definition: scaffolding.h:137
@ HISTORY_SHOW_LOCAL
Definition: scaffolding.h:91
@ TREE_SELECTION_LAUNCH
Definition: scaffolding.h:164
@ TREE_NEW_FOLDER
Definition: scaffolding.h:154
@ BROWSER_SAVE_URL_TEXT
Definition: scaffolding.h:126
@ TREE_SELECT_ALL
Definition: scaffolding.h:166
@ BROWSER_NAVIGATE_UP
Definition: scaffolding.h:134
@ HOTLIST_ADD_URL
Definition: scaffolding.h:95
@ TREE_CLEAR_SELECTION
Definition: scaffolding.h:167
@ BROWSER_OBJECT_SAVE_URL_URL
Definition: scaffolding.h:118
@ HELP_OPEN_GUIDE
Definition: scaffolding.h:84
@ BROWSER_NAVIGATE_URL
Definition: scaffolding.h:138
@ HOTLIST_SHOW
Definition: scaffolding.h:96
@ BROWSER_PAGE
Definition: scaffolding.h:103
@ BROWSER_SAVE
Definition: scaffolding.h:120
@ TREE_SELECTION_EDIT
Definition: scaffolding.h:163
@ BROWSER_FIND_TEXT
Definition: scaffolding.h:142
@ TREE_EXPAND_LINKS
Definition: scaffolding.h:158
@ BROWSER_OBJECT_INFO
Definition: scaffolding.h:111
@ BROWSER_NAVIGATE_RELOAD_ALL
Definition: scaffolding.h:136
@ BROWSER_IMAGES_FOREGROUND
Definition: scaffolding.h:143
@ TOOLBAR_BUTTONS
Definition: scaffolding.h:170
@ HOTLIST_EXPORT
Definition: scaffolding.h:127
@ BROWSER_OBJECT_SAVE_URL_TEXT
Definition: scaffolding.h:119
@ APPLICATION_QUIT
Definition: scaffolding.h:177
@ TREE_SELECTION_DELETE
Definition: scaffolding.h:165
@ BROWSER_SAVE_COMPLETE
Definition: scaffolding.h:121
@ HELP_OPEN_INFORMATION
Definition: scaffolding.h:85
@ HISTORY_SHOW_GLOBAL
Definition: scaffolding.h:92
@ TOOLBAR_EDIT
Definition: scaffolding.h:173
@ HISTORY_EXPORT
Definition: scaffolding.h:128
@ BROWSER_WINDOW_DEFAULT
Definition: scaffolding.h:148
@ BROWSER_SAVE_URL_URI
Definition: scaffolding.h:124
@ BROWSER_EXPORT_DRAW
Definition: scaffolding.h:122
@ BROWSER_VIEW_SOURCE
Definition: scaffolding.h:107
@ TREE_COLLAPSE_ALL
Definition: scaffolding.h:159
@ COOKIES_DELETE
Definition: scaffolding.h:100
@ BROWSER_SAVE_URL_URL
Definition: scaffolding.h:125
@ BROWSER_EXPORT_TEXT
Definition: scaffolding.h:123
@ TREE_COLLAPSE_LINKS
Definition: scaffolding.h:161
@ HELP_OPEN_CONTENTS
Definition: scaffolding.h:83
@ TREE_NEW_LINK
Definition: scaffolding.h:155
@ TOOLBAR_THROBBER
Definition: scaffolding.h:172
@ HELP_LAUNCH_INTERACTIVE
Definition: scaffolding.h:88
Browser window creation and manipulation interface.
nserror browser_window_schedule_reformat(struct browser_window *bw)
Reformat the browser window contents in a safe context.
bool browser_window_redraw(struct browser_window *bw, int x, int y, const struct rect *clip, const struct redraw_context *ctx)
Redraw an area of a window.
bool browser_window_has_content(struct browser_window *bw)
Find out if a browser window is currently showing a content.
void browser_window_mouse_click(struct browser_window *bw, browser_mouse_state mouse, int x, int y)
Handle mouse clicks in a browser window.
void browser_window_destroy(struct browser_window *bw)
Close and destroy a browser window.
nserror browser_window_get_extents(struct browser_window *bw, bool scaled, int *width, int *height)
Get a browser window's content extents.
void browser_window_mouse_track(struct browser_window *bw, browser_mouse_state mouse, int x, int y)
Handle non-click mouse action in a browser window.
static osspriteop_area * buffer
The buffer characteristics.
Definition: buffer.c:55
virtual void FrameResized(float new_width, float new_height)
Definition: window.cpp:261
virtual ~NSBrowserFrameView()
Definition: window.cpp:126
virtual void MouseDown(BPoint where)
Definition: window.cpp:281
virtual void KeyDown(const char *bytes, int32 numBytes)
Definition: window.cpp:273
struct gui_window * fGuiWindow
Definition: window.h:50
virtual void MouseUp(BPoint where)
Definition: window.cpp:294
virtual void Draw(BRect updateRect)
Definition: window.cpp:247
NSBrowserFrameView(BRect frame, struct gui_window *gui)
Definition: window.cpp:118
virtual void MessageReceived(BMessage *message)
Definition: window.cpp:132
virtual void MouseMoved(BPoint where, uint32 transit, const BMessage *msg)
Definition: window.cpp:309
Declaration of content enumerations.
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_BAD_PARAMETER
Bad Parameter.
Definition: errors.h:48
@ NSERROR_OK
No error.
Definition: errors.h:30
void nsbeos_style_to_font(BFont &font, const struct plot_font_style *fstyle)
Convert a font style to a PangoFontDescription.
Definition: font.cpp:53
Beos font layout handling interface.
Target independent plotting (BeOS interface).
bool nsbeos_done
Definition: gui.cpp:90
void nsbeos_pipe_message_top(BMessage *message, BWindow *_this, struct beos_scaffolding *scaffold)
Definition: gui.cpp:731
void nsbeos_pipe_message(BMessage *message, BView *_this, struct gui_window *gui)
Definition: gui.cpp:717
nserror beos_warn_user(const char *warning, const char *detail)
Display a warning for a serious problem (eg memory exhaustion).
Definition: gui.cpp:116
void nsbeos_update_system_ui_colors(void)
Definition: gui.cpp:503
#define NO_ACTION
Definition: idna.c:695
Interface to platform-specific clipboard operations.
Core mouse and pointer states.
browser_mouse_state
Mouse state: 1 is primary mouse button.
Definition: mouse.h:52
@ BROWSER_MOUSE_PRESS_1
primary button pressed
Definition: mouse.h:59
@ BROWSER_MOUSE_CLICK_2
button 2 clicked.
Definition: mouse.h:72
@ BROWSER_MOUSE_PRESS_2
auxillary button pressed
Definition: mouse.h:61
@ BROWSER_MOUSE_CLICK_1
button 1 clicked.
Definition: mouse.h:70
@ BROWSER_MOUSE_MOD_2
2nd modifier key pressed (eg.
Definition: mouse.h:101
@ BROWSER_MOUSE_MOD_1
1st modifier key pressed (eg.
Definition: mouse.h:99
@ BROWSER_MOUSE_DRAG_1
start of button 1 drag
Definition: mouse.h:86
@ BROWSER_MOUSE_HOLDING_2
during button 2 drag
Definition: mouse.h:96
@ BROWSER_MOUSE_HOLDING_1
during button 1 drag
Definition: mouse.h:94
@ BROWSER_MOUSE_DRAG_ON
a drag operation was started and a mouse button is still pressed
Definition: mouse.h:91
@ BROWSER_MOUSE_DRAG_2
start of button 2 drag
Definition: mouse.h:88
gui_pointer_shape
Definition: mouse.h:112
@ GUI_POINTER_WAIT
Definition: mouse.h:127
@ GUI_POINTER_RIGHT
Definition: mouse.h:120
@ GUI_POINTER_MOVE
Definition: mouse.h:126
@ GUI_POINTER_CARET
Definition: mouse.h:115
@ GUI_POINTER_PROGRESS
Definition: mouse.h:131
@ GUI_POINTER_RD
Definition: mouse.h:124
@ GUI_POINTER_LD
Definition: mouse.h:122
@ GUI_POINTER_NO_DROP
Definition: mouse.h:129
@ GUI_POINTER_DOWN
Definition: mouse.h:118
@ GUI_POINTER_UP
Definition: mouse.h:117
@ GUI_POINTER_RU
Definition: mouse.h:121
@ GUI_POINTER_DEFAULT
Definition: mouse.h:113
@ GUI_POINTER_HELP
Definition: mouse.h:128
@ GUI_POINTER_MENU
Definition: mouse.h:116
@ GUI_POINTER_POINT
Definition: mouse.h:114
@ GUI_POINTER_LEFT
Definition: mouse.h:119
@ GUI_POINTER_NOT_ALLOWED
Definition: mouse.h:130
@ GUI_POINTER_LU
Definition: mouse.h:123
@ GUI_POINTER_CROSS
Definition: mouse.h:125
Target independent plotting interface.
Interface to platform-specific graphical user interface window operations.
gui_window_create_flags
Window creation control flags.
Definition: window.h:66
gui_window_event
Window events.
Definition: window.h:80
@ GW_EVENT_REMOVE_CARET
Remove the caret, if present.
Definition: window.h:98
@ GW_EVENT_NEW_CONTENT
Called when the gui_window has new content.
Definition: window.h:118
@ GW_EVENT_STOP_THROBBER
stop the navigation throbber.
Definition: window.h:108
@ GW_EVENT_UPDATE_EXTENT
Update the extent of the inside of a browser window to that of the current content.
Definition: window.h:93
@ GW_EVENT_START_SELECTION
selection started
Definition: window.h:123
@ GW_EVENT_START_THROBBER
start the navigation throbber.
Definition: window.h:103
Interface to key press operations.
@ NS_KEY_LINE_START
Definition: keypress.h:57
@ NS_KEY_RIGHT
Definition: keypress.h:51
@ NS_KEY_LEFT
Definition: keypress.h:50
@ NS_KEY_TAB
Definition: keypress.h:36
@ NS_KEY_DOWN
Definition: keypress.h:53
@ NS_KEY_PAGE_UP
Definition: keypress.h:65
@ NS_KEY_PAGE_DOWN
Definition: keypress.h:66
@ NS_KEY_LINE_END
Definition: keypress.h:58
@ NS_KEY_DELETE_RIGHT
Definition: keypress.h:55
@ NS_KEY_DELETE_LEFT
Definition: keypress.h:35
@ NS_KEY_UP
Definition: keypress.h:52
bool browser_window_key_press(struct browser_window *bw, uint32_t key)
Handle key presses in a browser window.
Definition: textinput.c:107
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
NetSurf URL handling (interface).
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
int8_t int8
Definition: os3support.h:179
int32_t int32
Definition: os3support.h:183
uint32_t uint32
Definition: os3support.h:184
const struct plotter_table nsbeos_plotters
beos plotter operation table
Definition: plotters.cpp:739
rgb_color nsbeos_rgb_colour(colour c)
Definition: plotters.cpp:169
void nsbeos_current_gc_set(BView *view)
Definition: plotters.cpp:93
void nsbeos_plot_caret(int x, int y, int h)
Plot a caret.
Definition: plotters.cpp:194
int width
Definition: gui.c:160
int height
Definition: gui.c:161
void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *scaffold, struct browser_window *bw, BPoint where, BPoint screenWhere)
nsbeos_scaffolding * nsbeos_new_scaffolding(struct gui_window *toplevel)
void nsbeos_scaffolding_destroy(nsbeos_scaffolding *scaffold)
void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *message)
void nsbeos_attach_toplevel_view(nsbeos_scaffolding *g, BView *view)
NSBrowserWindow * window
Definition: scaffolding.cpp:98
Browser window data.
int x
Window dimensions.
function table for clipboard operations.
Definition: clipboard.h:42
Graphical user interface window function table.
Definition: window.h:137
first entry in window list
Definition: gui.c:298
struct gui_window * prev
Previous in linked list.
Definition: gui.h:159
NSBrowserFrameView * view
Definition: window.cpp:81
MFORM_EX * cursor
Definition: gui.h:150
struct gui_window * next
list for cleanup
Definition: gui.h:159
int state
Definition: window.cpp:73
gui_pointer_shape current_pointer
caret shape for rendering
Definition: window.cpp:78
int last_y
Definition: window.cpp:79
bool toplevel
Definition: window.cpp:66
struct gui_window * gui
Definition: window.c:89
nsbeos_scaffolding * scaffold
Definition: window.cpp:65
char * url
Definition: gui.h:154
int last_x
previous event location
Definition: window.cpp:79
int pressed_y
Definition: window.cpp:72
BRect pendingRedraw
Definition: window.cpp:91
int carety
Definition: window.cpp:77
int pressed_x
Definition: window.cpp:71
int32 pending_resizes
Definition: window.cpp:87
int caretx
caret dimension and location for rendering
Definition: window.cpp:77
struct gui_window::@32 mouse
int careth
Definition: window.cpp:77
struct browser_window * bw
The 'content' window that is rendered in the gui_window.
Definition: gui.c:316
size_t start
Start of run.
Definition: clipboard.h:34
Rectangle coordinates.
Definition: types.h:40
int x0
Definition: types.h:41
int y0
Top left.
Definition: types.h:41
int x1
Definition: types.h:42
int y1
Bottom right.
Definition: types.h:42
Redraw context.
Definition: plotters.h:51
Unified URL information database public interface.
Option reading and saving interface.
uint32_t utf8_to_ucs4(const char *s_in, size_t l)
Convert a UTF-8 multibyte sequence into a single UCS4 character.
Definition: utf8.c:41
UTF-8 manipulation functions (interface).
Interface to a number of general purpose functionality.
static void gui_set_clipboard(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles)
Definition: window.cpp:1277
void nsbeos_dispatch_event(BMessage *message)
Process beos messages into browser operations.
Definition: window.cpp:406
nsbeos_scaffolding * nsbeos_get_scaffold(struct gui_window *g)
Get containing scaffold of a beos gui window.
Definition: window.cpp:327
static nserror gui_window_event(struct gui_window *gw, enum gui_window_event event)
process miscellaneous window events
Definition: window.cpp:1346
static void gui_window_destroy(struct gui_window *g)
Definition: window.cpp:918
static void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
Definition: window.cpp:1171
static void gui_window_remove_caret(struct gui_window *g)
Definition: window.cpp:1207
static void nsbeos_window_resize_event(BView *view, gui_window *g, BMessage *event)
Definition: window.cpp:868
static void gui_window_update_extent(struct gui_window *g)
Definition: window.cpp:1069
static BCursorID gui_haiku_pointer(gui_pointer_shape shape)
Definition: window.cpp:1111
static void gui_get_clipboard(char **buffer, size_t *length)
Definition: window.cpp:1255
static struct gui_window * gui_window_create(struct browser_window *bw, struct gui_window *existing, gui_window_create_flags flags)
Definition: window.cpp:338
struct gui_clipboard_table * beos_clipboard_table
Definition: window.cpp:1314
static struct gui_window_table window_table
Definition: window.cpp:1380
struct browser_window * nsbeos_get_browser_window(struct gui_window *g)
Definition: window.cpp:322
static nserror beos_window_invalidate_area(struct gui_window *g, const struct rect *rect)
Invalidate an area of a beos browser window.
Definition: window.cpp:988
static BList current_selection_textruns
Definition: window.cpp:104
struct gui_window_table * beos_window_table
Definition: window.cpp:1405
static struct gui_clipboard_table clipboard_table
Definition: window.cpp:1309
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height, const struct rect *clip)
Definition: window.cpp:1186
static void nsbeos_window_expose_event(BView *view, gui_window *g, BMessage *message)
Definition: window.cpp:679
static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
Definition: window.cpp:1015
static const rgb_color kWhiteColor
Definition: window.cpp:99
static nserror gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
Set the scroll position of a beos browser window.
Definition: window.cpp:1045
void nsbeos_window_destroy_browser(struct gui_window *g)
Definition: window.cpp:913
static void nsbeos_window_keypress_event(BView *view, gui_window *g, BMessage *event)
Definition: window.cpp:731
static struct gui_window * window_list
first entry in win list
Definition: window.cpp:101
static void gui_window_new_content(struct gui_window *g)
Definition: window.cpp:1229
static void gui_start_selection(struct gui_window *g)
Definition: window.cpp:1245
static nserror gui_window_get_dimensions(struct gui_window *g, int *width, int *height)
Find the current dimensions of a beos browser window content area.
Definition: window.cpp:1326
void nsbeos_reflow_all_windows(void)
Cause all windows to be reflowed.
Definition: window.cpp:905
static void nsbeos_window_moved_event(BView *view, gui_window *g, BMessage *event)
Definition: window.cpp:891
struct browser_window * nsbeos_get_browser_for_gui(struct gui_window *g)
Definition: window.cpp:332
static BString current_selection
Definition: window.cpp:103
static void nsbeos_redraw_caret(struct gui_window *g)
Definition: window.cpp:961
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
Definition: plot.c:978
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357