NetSurf
scaffolding.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2015 Adrián Arroyo Calle <adrian.arroyocalle@gmail.com>
3 * Copyright 2008 François Revol <mmu_man@users.sourceforge.net>
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 <assert.h>
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
26
27#include <BeBuild.h>
28#include <Bitmap.h>
29#include <Box.h>
30#include <Button.h>
31#include <Dragger.h>
32#include <Menu.h>
33#include <MenuBar.h>
34#include <MenuItem.h>
35#include <Node.h>
36#include <Path.h>
37#include <PopUpMenu.h>
38#include <Resources.h>
39#include <Roster.h>
40#include <Screen.h>
41#include <ScrollView.h>
42#include <String.h>
43#include <StringView.h>
44#include <TextControl.h>
45#include <View.h>
46#include <Window.h>
47
48#if defined(__HAIKU__)
49#include <IconUtils.h>
50#include "WindowStack.h"
51#endif
52
53#include <fs_attr.h>
54
55extern "C" {
56#include "utils/messages.h"
57#include "utils/utils.h"
58#include "utils/log.h"
59#include "utils/nsurl.h"
60#include "utils/nsoption.h"
61#include "netsurf/netsurf.h"
62#include "netsurf/plotters.h"
63#include "netsurf/clipboard.h"
64#include "netsurf/content.h"
67#include "netsurf/form.h"
68#include "netsurf/keypress.h"
70#include "desktop/version.h"
71#include "desktop/searchweb.h"
72#include "desktop/search.h"
73}
74
75#include "beos/about.h"
76#include "beos/bitmap.h"
77#include "beos/gui.h"
78#include "beos/plotters.h"
79#include "beos/scaffolding.h"
80#include "beos/gui_options.h"
81//#include "beos/completion.h"
82#include "beos/throbber.h"
83#include "beos/window.h"
84#include "beos/schedule.h"
85//#include "beos/download.h"
86#include "beos/cookies.h"
87
88#define TOOLBAR_HEIGHT 32
89#define DRAGGER_WIDTH 8
90
92
94class NSBrowserWindow;
95class NSThrobber;
96
98 NSBrowserWindow *window; // top-level container object
99
100 // top-level view, contains toolbar & top-level browser view
102
103 BMenuBar *menu_bar;
104
105 BPopUpMenu *popup_menu;
106
107#ifdef ENABLE_DRAGGER
108 BDragger *dragger;
109#endif
110
111 BView *tool_bar;
112
113 BControl *back_button;
114 BControl *forward_button;
115 BControl *stop_button;
116 BControl *reload_button;
117 BControl *home_button;
118
120 BTextControl *search_bar;
121 //BMenuField *url_bar_completion;
122
124
125 BStringView *status_bar;
126
127 BScrollView *scroll_view;
128
130
134
136
137 /** Object under menu, or 0 if no object. */
139};
140
143 BWindow *window;
144
145};
146
148 const char *widget;
149};
150
151// passed to the replicant main thread
153 char app[B_PATH_NAME_LENGTH];
154 BString url;
155 char *args[3];
156};
157
158
159static int open_windows = 0; /**< current number of open browsers */
160static NSBaseView *replicant_view = NULL; /**< if not NULL, the replicant View we are running NetSurf for */
161static sem_id replicant_done_sem = -1;
162static thread_id replicant_thread = -1;
163
165static void nsbeos_throb(void *);
166static int32 nsbeos_replicant_main_thread(void *_arg);
167
168// in beos_gui.cpp
169extern int main(int argc, char** argv);
170
171// in fetch_rsrc.cpp
172extern BResources *gAppResources;
173
174// #pragma mark - class NSIconTextControl
175
176#define ICON_WIDTH 16
177
178class NSIconTextControl : public BTextControl {
179public:
180 NSIconTextControl(BRect frame, const char* name,
181 const char* label, const char* initialText,
182 BMessage* message,
183 uint32 resizeMode
184 = B_FOLLOW_LEFT | B_FOLLOW_TOP,
185 uint32 flags
186 = B_WILL_DRAW | B_NAVIGABLE | B_DRAW_ON_CHILDREN);
187virtual ~NSIconTextControl();
188
189virtual void FrameResized(float newWidth, float newHeight);
190virtual void Draw(BRect updateRect);
191virtual void DrawAfterChildren(BRect updateRect);
192virtual void AttachedToWindow();
193
194void SetBitmap(const BBitmap *bitmap);
195void FixupTextRect();
196
197private:
200 const BBitmap *fIconBitmap;
201};
202
203NSIconTextControl::NSIconTextControl(BRect frame, const char* name,
204 const char* label, const char* initialText,
205 BMessage* message,
206 uint32 resizeMode,
207 uint32 flags)
208 : BTextControl(frame, name, label, initialText, message, resizeMode, flags),
209 fIconOffset(0,0),
210 fIconBitmap(NULL)
211{
212 BRect r(Bounds());
213 fIconFrame = r;
214 fIconFrame.right = fIconFrame.left + ICON_WIDTH - 1;
215 fIconFrame.bottom = fIconFrame.top + ICON_WIDTH - 1;
216 fIconFrame.OffsetBy((int32)((r.IntegerHeight() - ICON_WIDTH + 3) / 2),
217 (int32)((r.IntegerHeight() - ICON_WIDTH + 1) / 2));
219}
220
221
223{
224 delete fIconBitmap;
225}
226
227
228void
229NSIconTextControl::FrameResized(float newWidth, float newHeight)
230{
231 BTextControl::FrameResized(newWidth, newHeight);
233}
234
235
236void
237NSIconTextControl::Draw(BRect updateRect)
238{
240 BTextControl::Draw(updateRect);
241}
242
243
244void
246{
247 BTextControl::DrawAfterChildren(updateRect);
248
249 PushState();
250
251 SetDrawingMode(B_OP_ALPHA);
252 DrawBitmap(fIconBitmap, fIconFrame);
253
254 //XXX: is this needed?
255 PopState();
256}
257
258
259void
261{
262 BTextControl::AttachedToWindow();
264}
265
266
267void
269{
270 delete fIconBitmap;
271 fIconBitmap = NULL;
272
273 // keep a copy
274 if (bitmap)
275 fIconBitmap = new BBitmap(bitmap);
276 // invalidate just the icon area
277 Invalidate(fIconFrame);
278}
279
280
281void
283{
284 // FIXME: this flickers on resize, quite ugly
285 BRect r(TextView()->TextRect());
286
287 // don't fix the fix
288 if (r.left > ICON_WIDTH)
289 return;
290
291 r.left += r.bottom - r.top;
292 TextView()->SetTextRect(r);
293}
294
295
296#undef ICON_WIDTH
297
298// #pragma mark - class NSResizeKnob
299
300class NSResizeKnob : public BView {
301public:
302 NSResizeKnob(BRect frame, BView *target);
303virtual ~NSResizeKnob();
304
305virtual void MouseDown(BPoint where);
306virtual void MouseUp(BPoint where);
307virtual void MouseMoved(BPoint where, uint32 code,
308 const BMessage* dragMessage);
309
310virtual void Draw(BRect updateRect);
311
312void SetBitmap(const BBitmap *bitmap);
313
314private:
315 const BBitmap *fBitmap;
316 BView *fTarget;
317 BPoint fOffset;
318};
319
320NSResizeKnob::NSResizeKnob(BRect frame, BView *target)
321 : BView(frame, "NSResizeKnob", B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT, B_WILL_DRAW),
322 fBitmap(NULL),
323 fTarget(target),
324 fOffset(-1, -1)
325{
326 SetViewColor(0, 255, 0);
327}
328
329
331{
332}
333
334
335void
337{
338 SetMouseEventMask(B_POINTER_EVENTS,
339 B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS);
340 fOffset = where;
341}
342
343
344void
346{
347 fOffset.Set(-1, -1);
348}
349
350
351void
353 const BMessage* dragMessage)
354{
355 if (fOffset.x >= 0) {
356 fTarget->ResizeBy(where.x - fOffset.x, where.y - fOffset.y);
357 }
358}
359
360
361void
362NSResizeKnob::Draw(BRect updateRect)
363{
364 if (!fBitmap)
365 return;
366 DrawBitmap(fBitmap);
367}
368
369
370void
372{
373 fBitmap = bitmap;
374 Invalidate();
375}
376
377
378// #pragma mark - class NSThrobber
379
380class NSThrobber : public BView {
381public:
382 NSThrobber(BRect frame);
383virtual ~NSThrobber();
384
385virtual void MessageReceived(BMessage *message);
386virtual void Draw(BRect updateRect);
387void SetBitmap(const BBitmap *bitmap);
388
389private:
390 const BBitmap *fBitmap;
391};
392
394 : BView(frame, "NSThrobber", B_FOLLOW_TOP | B_FOLLOW_RIGHT, B_WILL_DRAW),
395 fBitmap(NULL)
396{
397}
398
399
401{
402}
403
404
405void
407{
408 BView::MessageReceived(message);
409}
410
411
412void
413NSThrobber::Draw(BRect updateRect)
414{
415 if (!fBitmap)
416 return;
417 DrawBitmap(fBitmap);
418}
419
420
421void
423{
424 fBitmap = bitmap;
425 Invalidate();
426}
427
428
429// #pragma mark - class NSBaseView
430
431
433 : BView(frame, "NetSurf", B_FOLLOW_ALL_SIDES,
434 0 /*B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS*/ /*| B_SUBPIXEL_PRECISE*/),
435 fScaffolding(NULL)
436{
437}
438
439NSBaseView::NSBaseView(BMessage *archive)
440 : BView(archive),
441 fScaffolding(NULL)
442{
443}
444
445
447{
448 //beos_warn_user("~NSBaseView()", NULL);
449 if (replicated) {
450 BMessage *message = new BMessage(B_QUIT_REQUESTED);
452 while (acquire_sem(replicant_done_sem) == EINTR);
453 //debugger("plop");
454 status_t status = -1;
455 wait_for_thread(replicant_thread, &status);
456 }
457}
458
459
460void
462{
463 switch (message->what) {
464 case B_SIMPLE_DATA:
465 case B_ABOUT_REQUESTED:
466 case B_ARGV_RECEIVED:
467 case B_REFS_RECEIVED:
468 case B_COPY:
469 case B_CUT:
470 case B_PASTE:
471 case B_SELECT_ALL:
472 //case B_MOUSE_WHEEL_CHANGED:
474 // NetPositive messages
475 case B_NETPOSITIVE_OPEN_URL:
476 case B_NETPOSITIVE_BACK:
477 case B_NETPOSITIVE_FORWARD:
478 case B_NETPOSITIVE_HOME:
479 case B_NETPOSITIVE_RELOAD:
480 case B_NETPOSITIVE_STOP:
481 case B_NETPOSITIVE_DOWN:
482 case B_NETPOSITIVE_UP:
483 // messages for top-level
484 case 'back':
485 case 'forw':
486 case 'stop':
487 case 'relo':
488 case 'home':
489 case 'urlc':
490 case 'urle':
491 case 'sear':
492 case 'menu':
493 case NO_ACTION:
495 case HELP_OPEN_GUIDE:
497 case HELP_OPEN_ABOUT:
502 case HOTLIST_ADD_URL:
503 case HOTLIST_SHOW:
504 case COOKIES_SHOW:
505 case COOKIES_DELETE:
506 case BROWSER_PAGE:
508 case BROWSER_PRINT:
511 case BROWSER_OBJECT:
519 case BROWSER_SAVE:
526 case HOTLIST_EXPORT:
527 case HISTORY_EXPORT:
547 case TREE_NEW_FOLDER:
548 case TREE_NEW_LINK:
549 case TREE_EXPAND_ALL:
555 case TREE_SELECTION:
559 case TREE_SELECT_ALL:
561 case TOOLBAR_BUTTONS:
563 case TOOLBAR_THROBBER:
564 case TOOLBAR_EDIT:
565 case CHOICES_SHOW:
566 case APPLICATION_QUIT:
567 if (Window())
568 Window()->DetachCurrentMessage();
570 break;
571 default:
572 //message->PrintToStream();
573 BView::MessageReceived(message);
574 }
575}
576
577
578status_t
579NSBaseView::Archive(BMessage *archive, bool deep) const
580{
581 // force archiving only the base view
582 deep = false;
583 status_t err;
584 err = BView::Archive(archive, deep);
585 if (err < B_OK)
586 return err;
587 // add our own fields
588 // we try to reuse the same fields as NetPositive
589 archive->AddString("add_on", "application/x-vnd.NetSurf");
590 //archive->AddInt32("version", 2);
591 archive->AddString("url", fScaffolding->url_bar->Text());
592 archive->AddBool("openAsText", false);
593 archive->AddInt32("encoding", 258);
594 return err;
595}
596
597
598BArchivable *
599NSBaseView::Instantiate(BMessage *archive)
600{
601 if (!validate_instantiation(archive, "NSBaseView"))
602 return NULL;
603 const char *url;
604 if (archive->FindString("url", &url) < B_OK
605 || url == NULL || strlen(url) == 0) {
606 url = "about:";
607 }
608
610 info->url = BString(url);
611 if (nsbeos_find_app_path(info->app) < B_OK) {
612 delete info;
613 return NULL;
614 }
615 info->args[0] = info->app;
616 info->args[1] = (char *)info->url.String();
617 info->args[2] = NULL;
618 NSBaseView *view = new NSBaseView(archive);
620 replicated = true;
621
622 //TODO:FIXME: fix replicants
623 // do as much as possible in this thread to avoid deadlocks
624
625 gui_init_replicant(2, info->args);
626
627 replicant_done_sem = create_sem(0, "NS Replicant created");
629 "NetSurf Main Thread", B_NORMAL_PRIORITY, info);
630 if (replicant_thread < B_OK) {
631 delete_sem(replicant_done_sem);
632 delete info;
633 delete view;
634 return NULL;
635 }
636 resume_thread(replicant_thread);
637 //XXX: deadlocks BeHappy
638 //while (acquire_sem(replicant_done_sem) == EINTR);
639
640 return view;
641}
642
643
644void
646{
647 fScaffolding = scaf;
648}
649
650
651// AttachedToWindow() is not enough to get the dragger and status bar
652// stick to the panel color
653void
655{
656 BView::AllAttached();
657
658 struct beos_scaffolding *g = fScaffolding;
659 if (!g)
660 return;
661 // set targets to the topmost ns view
662 g->back_button->SetTarget(this);
663 g->forward_button->SetTarget(this);
664 g->stop_button->SetTarget(this);
665 g->reload_button->SetTarget(this);
666 g->home_button->SetTarget(this);
667
668 rgb_color c = ui_color(B_PANEL_BACKGROUND_COLOR);
669 SetViewColor(c);
670
671 g->tool_bar->SetViewColor(c);
672 g->back_button->SetViewColor(c);
673 g->back_button->SetLowColor(c);
674 g->forward_button->SetViewColor(c);
675 g->forward_button->SetLowColor(c);
676 g->stop_button->SetViewColor(c);
677 g->stop_button->SetLowColor(c);
678 g->reload_button->SetViewColor(c);
679 g->reload_button->SetLowColor(c);
680 g->home_button->SetViewColor(c);
681 g->home_button->SetLowColor(c);
682 g->url_bar->SetViewColor(c);
683 g->search_bar->SetViewColor(c);
684 g->throbber->SetViewColor(c);
685 g->scroll_view->SetViewColor(c);
686
687#ifdef ENABLE_DRAGGER
688 g->dragger->SetViewColor(c);
689#endif
690
691 g->status_bar->SetViewColor(c);
692 g->status_bar->SetLowColor(c);
693#if defined(__HAIKU__) || defined(B_DANO_VERSION)
694 g->status_bar->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
695#endif
696}
697
698
699// #pragma mark - class NSBrowserWindow
700
701
703 : BWindow(frame, "NetSurf", B_DOCUMENT_WINDOW, 0),
704 fScaffolding(scaf)
705{
706}
707
708
710{
711 if(activeWindow == this)
712 activeWindow = NULL;
713}
714
715
716void
717NSBrowserWindow::DispatchMessage(BMessage *message, BHandler *handler)
718{
719 BMessage *msg;
720 switch (message->what) {
722 msg = new BMessage(*message);
724 break;
725 }
726 BWindow::DispatchMessage(message, handler);
727}
728
729
730void
732{
733 switch (message->what) {
734 case B_ARGV_RECEIVED:
735 case B_REFS_RECEIVED:
737 // NetPositive messages
738 case B_NETPOSITIVE_OPEN_URL:
739 case B_NETPOSITIVE_BACK:
740 case B_NETPOSITIVE_FORWARD:
741 case B_NETPOSITIVE_HOME:
742 case B_NETPOSITIVE_RELOAD:
743 case B_NETPOSITIVE_STOP:
744 case B_NETPOSITIVE_DOWN:
745 case B_NETPOSITIVE_UP:
746 DetachCurrentMessage();
748 break;
749 default:
750 BWindow::MessageReceived(message);
751 }
752}
753
754bool
756{
757 BWindow::QuitRequested();
758 BMessage *message = DetachCurrentMessage();
759 // BApplication::Quit() calls us directly...
760 if (message == NULL)
761 message = new BMessage(B_QUIT_REQUESTED);
763 return false; // we will Quit() ourselves from the main thread
764}
765
766
767void
769{
770 if(active)
771 activeWindow = this;
772 else if(activeWindow == this)
773 activeWindow = NULL;
774}
775
776
777// #pragma mark - implementation
778
780{
781 struct replicant_thread_info *info = (struct replicant_thread_info *)_arg;
782 int32 ret = 0;
783
784 while (!nsbeos_done) {
786 }
787
788 netsurf_exit();
789 delete info;
790 delete_sem(replicant_done_sem);
791 return ret;
792}
793
794
795/* event handlers and support functions for them */
796
797static void nsbeos_window_destroy_event(NSBrowserWindow *window, nsbeos_scaffolding *g, BMessage *event)
798{
799 NSLOG(netsurf, INFO, "Being Destroyed = %d", g->being_destroyed);
800
801 if (--open_windows == 0)
802 nsbeos_done = true;
803
804 if (window) {
805 window->Lock();
806 window->Quit();
807 }
808
809 if (!g->being_destroyed) {
810 g->being_destroyed = 1;
812 }
813}
814
815
817{
818 if (!g->top_view->LockLooper())
819 return;
820 rgb_color c = ui_color(B_PANEL_BACKGROUND_COLOR);
821 g->top_view->SetViewColor(c);
822
823 g->tool_bar->SetViewColor(c);
824 g->back_button->SetViewColor(c);
825 g->forward_button->SetViewColor(c);
826 g->stop_button->SetViewColor(c);
827 g->reload_button->SetViewColor(c);
828 g->home_button->SetViewColor(c);
829 g->url_bar->SetViewColor(c);
830 g->search_bar->SetViewColor(c);
831 g->throbber->SetViewColor(c);
832 g->scroll_view->SetViewColor(c);
833
834#ifdef ENABLE_DRAGGER
835 g->dragger->SetViewColor(c);
836#endif
837
838 g->status_bar->SetViewColor(c);
839 g->status_bar->SetLowColor(c);
840#if defined(__HAIKU__) || defined(B_DANO_VERSION)
841 g->status_bar->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
842#endif
843 g->top_view->UnlockLooper();
844}
845
846
847/*static*/ BWindow*
849
850
852{
853 struct browser_window *bw;
855 bool reloadAll = false;
856
857 NSLOG(netsurf, INFO,
858 "nsbeos_scaffolding_dispatch_event() what = 0x%08lx",
859 message->what);
860 switch (message->what) {
861 case B_QUIT_REQUESTED:
863 break;
864 case B_ABOUT_REQUESTED:
865 {
866 nsbeos_about(scaffold->top_level);
867 break;
868 }
869 case B_NETPOSITIVE_DOWN:
870 //XXX WRITEME
871 break;
872 case B_SIMPLE_DATA:
873 {
874 if (!message->HasRef("refs")) {
875 // XXX handle DnD
876 break;
877 }
878 // FALL THROUGH
879 // handle refs
880 }
881 case B_REFS_RECEIVED:
882 {
883 int32 i;
884 entry_ref ref;
885
886 for (i = 0; message->FindRef("refs", i, &ref) >= B_OK; i++) {
887 BString url("file://");
888 BPath path(&ref);
889 if (path.InitCheck() < B_OK)
890 break;
891
892 BNode node(path.Path());
893 if (node.InitCheck() < B_OK)
894 break;
895 if (node.IsSymLink()) {
896 // dereference the symlink
897 BEntry entry(path.Path(), true);
898 if (entry.InitCheck() < B_OK)
899 break;
900 if (entry.GetPath(&path) < B_OK)
901 break;
902 if (node.SetTo(path.Path()) < B_OK)
903 break;
904 }
905
906 attr_info ai;
907 if (node.GetAttrInfo("META:url", &ai) >= B_OK) {
908 char data[(size_t)ai.size + 1];
909 memset(data, 0, (size_t)ai.size + 1);
910 if (node.ReadAttr("META:url", B_STRING_TYPE, 0LL, data, (size_t)ai.size) < 4)
911 break;
912 url = data;
913 } else
914 url << path.Path();
915
916 nsurl *nsurl;
917 nserror error;
918
919 error = nsurl_create(url.String(), &nsurl);
920 if (error == NSERROR_OK) {
921 if (/*message->WasDropped() &&*/ i == 0) {
925 NULL, NULL, NULL);
926 } else {
928 nsurl,
929 NULL,
930 bw,
931 NULL);
932 }
934 }
935 if (error != NSERROR_OK) {
937 }
938 }
939 break;
940 }
941 case B_ARGV_RECEIVED:
942 {
943 int32 i;
944 BString urltxt;
945 nsurl *url;
946 nserror error;
947
948 for (i = 1; message->FindString("argv", i, &urltxt) >= B_OK; i++) {
949 error = nsurl_create(urltxt.String(), &url);
950 if (error == NSERROR_OK) {
952 url,
953 NULL,
954 bw,
955 NULL);
956 nsurl_unref(url);
957 }
958 if (error != NSERROR_OK) {
960 }
961 }
962 break;
963 }
967 break;
968 case B_NETPOSITIVE_OPEN_URL:
969 {
970 BString url;
971 if (message->FindString("be:url", &url) < B_OK)
972 break;
973
974 nsurl *nsurl;
975 nserror error;
976
977 error = nsurl_create(url.String(), &nsurl);
978 if (error != NSERROR_OK) {
980 } else {
982 nsurl,
983 NULL,
985 NULL,
986 NULL,
987 NULL);
989 }
990 break;
991 }
992 case B_COPY:
994 break;
995 case B_CUT:
997 break;
998 case B_PASTE:
1000 break;
1001 case B_SELECT_ALL:
1002 NSLOG(netsurf, INFO, "Selecting all text");
1004 break;
1005 case B_NETPOSITIVE_BACK:
1007 case 'back':
1009 break;
1012 break;
1013 case B_NETPOSITIVE_FORWARD:
1015 case 'forw':
1017 break;
1020 break;
1021 case B_NETPOSITIVE_STOP:
1023 case 'stop':
1025 break;
1026 case B_NETPOSITIVE_RELOAD:
1028 case 'relo':
1029 reloadAll = true;
1030 // FALLTHRU
1032 browser_window_reload(bw, reloadAll);
1033 break;
1034 case B_NETPOSITIVE_HOME:
1036 case 'home':
1037 {
1038 nsurl *url;
1039 nserror error;
1040
1041 static const char *addr = NETSURF_HOMEPAGE;
1042
1043 if (nsoption_charp(homepage_url) != NULL) {
1044 addr = nsoption_charp(homepage_url);
1045 }
1046
1047 error = nsurl_create(addr, &url);
1048 if (error != NSERROR_OK) {
1050 } else {
1052 url,
1053 NULL,
1055 NULL,
1056 NULL,
1057 NULL);
1058 nsurl_unref(url);
1059 }
1060 break;
1061 }
1062 case 'urle':
1063 {
1064 nsurl *url;
1065 nserror error;
1066 BString text;
1067
1068 if (!scaffold->url_bar->LockLooper())
1069 break;
1070
1071 text = scaffold->url_bar->Text();
1072 scaffold->scroll_view->Target()->MakeFocus();
1073 scaffold->url_bar->UnlockLooper();
1074
1075 error = nsurl_create(text.String(), &url);
1076 if (error != NSERROR_OK) {
1078 } else {
1080 url,
1081 NULL,
1083 NULL,
1084 NULL,
1085 NULL);
1086 nsurl_unref(url);
1087 }
1088 break;
1089 }
1090 case 'urlc':
1091 {
1092 BString text;
1093 if (!scaffold->url_bar->LockLooper())
1094 break;
1095 text = scaffold->url_bar->Text();
1096 scaffold->url_bar->UnlockLooper();
1097 //nsbeos_completion_update(text.String());
1098 break;
1099 }
1100 case 'sear':
1101 {
1102 nserror ret;
1103 nsurl* url;
1104 BString text;
1105 if (!scaffold->search_bar->LockLooper())
1106 break;
1107 text = scaffold->search_bar->Text();
1108 scaffold->search_bar->UnlockLooper();
1109
1110 char t[PATH_MAX];
1111 find_resource(t,"SearchEngines","./beos/res/SearchEngines");
1112
1113 search_web_init(&t[0]);
1114
1116 ,&url);
1117 if (ret == NSERROR_OK) {
1120 url,
1121 NULL,
1122 bw,
1123 NULL);
1124 nsurl_unref(url);
1125 }
1126
1127 if (ret != NSERROR_OK) {
1129 }
1130
1132
1133 break;
1134 }
1135/*
1136 case 'menu':
1137 {
1138 menu_action action;
1139 if (message->FindInt32("action", (int32 *)&action) < B_OK)
1140 break;
1141 switch (action) {
1142 case NO_ACTION:
1143 case HELP_OPEN_CONTENTS:
1144 case HELP_OPEN_GUIDE:
1145 case HELP_OPEN_INFORMATION:
1146 case HELP_OPEN_ABOUT:
1147 case HELP_LAUNCH_INTERACTIVE:
1148
1149 break;
1150 }
1151#warning XXX
1152 break;
1153 }
1154*/
1155 case NO_ACTION:
1156 break;
1157 case HELP_OPEN_CONTENTS:
1158 break;
1159 case HELP_OPEN_GUIDE:
1160 break;
1162 break;
1163 case HELP_OPEN_ABOUT:
1164 {
1165 const char *goto_url = "about:credits";
1166 nserror nserr;
1167 nsurl *url;
1168 nserr = nsurl_create(goto_url, &url);
1169 if (nserr == NSERROR_OK) {
1171 url, NULL,
1173 NULL, NULL, NULL);
1174 nsurl_unref(url);
1175 }
1176 if (nserr != NSERROR_OK) {
1178 }
1179 }
1180 break;
1181 case HELP_OPEN_LICENCE:
1182 {
1183 const char *goto_url = "about:licence";
1184 nserror nserr;
1185 nsurl *url;
1186 nserr = nsurl_create(goto_url, &url);
1187 if (nserr == NSERROR_OK) {
1189 url, NULL,
1191 NULL, NULL, NULL);
1192 nsurl_unref(url);
1193 }
1194 if (nserr != NSERROR_OK) {
1196 }
1197 }
1198 break;
1200 break;
1201 case HISTORY_SHOW_LOCAL:
1202 break;
1204 break;
1205 case HOTLIST_ADD_URL:
1206 break;
1207 case HOTLIST_SHOW:
1208 break;
1209 case COOKIES_SHOW:
1210 {
1212 break;
1213 }
1214 case COOKIES_DELETE:
1215 {
1217 break;
1218 }
1219 case BROWSER_PAGE:
1220 break;
1221 case BROWSER_PAGE_INFO:
1222 break;
1223 case BROWSER_PRINT:
1224 break;
1225 case BROWSER_NEW_WINDOW:
1226 {
1227 BString text;
1228 nsurl *url;
1229 nserror error;
1230
1231 if (!scaffold->url_bar->LockLooper())
1232 break;
1233 text = scaffold->url_bar->Text();
1234 scaffold->url_bar->UnlockLooper();
1235
1237
1238 error = nsurl_create(text.String(), &url);
1239 if (error == NSERROR_OK) {
1241 url,
1242 NULL,
1243 bw,
1244 NULL);
1245 nsurl_unref(url);
1246 }
1247 if (error != NSERROR_OK) {
1249 }
1250 break;
1251 }
1253 {
1254 if (!bw || browser_window_has_content(bw) == false)
1255 break;
1257 break;
1258 }
1259 case BROWSER_OBJECT:
1260 break;
1262 break;
1264 if (scaffold->current_menu_object != NULL) {
1266 browser_window_reload(bw, false);
1267 scaffold->current_menu_object = NULL;
1268 }
1269 break;
1271 break;
1273 break;
1275 break;
1277 break;
1279 break;
1280 case BROWSER_SAVE:
1281 break;
1283 break;
1285 break;
1287 break;
1289 break;
1291 break;
1293 break;
1294 case HOTLIST_EXPORT:
1295 break;
1296 case HISTORY_EXPORT:
1297 break;
1298 case B_NETPOSITIVE_UP:
1300 break;
1302 if (!scaffold->url_bar->LockLooper())
1303 break;
1304 scaffold->url_bar->MakeFocus();
1305 scaffold->url_bar->UnlockLooper();
1306 break;
1307 case BROWSER_SCALE_VIEW:
1308 break;
1309 case BROWSER_FIND_TEXT:
1310 break;
1312 break;
1314 break;
1316 break;
1317 case BROWSER_BUFFER_ALL:
1318 break;
1319 case BROWSER_SAVE_VIEW:
1320 break;
1322 break;
1324 break;
1326 break;
1328 break;
1329 case TREE_NEW_FOLDER:
1330 case TREE_NEW_LINK:
1331 case TREE_EXPAND_ALL:
1333 case TREE_EXPAND_LINKS:
1334 case TREE_COLLAPSE_ALL:
1337 case TREE_SELECTION:
1341 case TREE_SELECT_ALL:
1343 break;
1344 case TOOLBAR_BUTTONS:
1345 break;
1347 break;
1348 case TOOLBAR_THROBBER:
1349 break;
1350 case TOOLBAR_EDIT:
1351 break;
1352 case CHOICES_SHOW:
1353 break;
1354 case APPLICATION_QUIT:
1355 nsbeos_done = true;
1356 break;
1357 default:
1358 break;
1359 }
1360}
1361
1363{
1364 NSLOG(netsurf, INFO, "Being Destroyed = %d",
1365 scaffold->being_destroyed);
1366 if (scaffold->being_destroyed) return;
1367 scaffold->being_destroyed = 1;
1368 nsbeos_window_destroy_event(scaffold->window, scaffold, NULL);
1369}
1370
1371
1373{
1375
1376 if (!g->top_view->LockLooper())
1377 return;
1378
1381
1382 g->top_view->UnlockLooper();
1383
1384}
1385
1386void nsbeos_throb(void *p)
1387{
1388 struct beos_scaffolding *g = (struct beos_scaffolding *)p;
1389
1390 if (g->throb_frame >= (nsbeos_throbber->nframes - 1))
1391 g->throb_frame = 1;
1392 else
1393 g->throb_frame++;
1394
1395 if (!g->top_view->LockLooper())
1396 return;
1397
1399 g->throbber->Invalidate();
1400
1401 g->top_view->UnlockLooper();
1402
1403 beos_schedule(100, nsbeos_throb, p);
1404
1405}
1406
1407
1409{
1410 int32 i;
1411 if (!be_app || !be_app->Lock())
1412 return NULL;
1413 for (i = be_app->CountWindows() - 1; i >= 0; i--) {
1414 if (be_app->WindowAt(i) == NULL)
1415 continue;
1416 NSBrowserWindow *win;
1417 win = dynamic_cast<NSBrowserWindow *>(be_app->WindowAt(i));
1418 if (win) {
1419 win->Lock();
1420 be_app->Unlock();
1421 return win;
1422 }
1423 }
1424 be_app->Unlock();
1425 return NULL;
1426}
1427
1429{
1430 return scaffold->window;
1431}
1432
1434{
1435 return scaffold->top_view;
1436}
1437
1438static void recursively_set_menu_items_target(BMenu *menu, BHandler *handler)
1439{
1440 menu->SetTargetForItems(handler);
1441 for (int i = 0; menu->ItemAt(i); i++) {
1442 if (!menu->SubmenuAt(i))
1443 continue;
1444 recursively_set_menu_items_target(menu->SubmenuAt(i), handler);
1445 }
1446}
1447
1449{
1450 NSLOG(netsurf, INFO, "Attaching view to scaffolding %p", g);
1451
1452 // this is a replicant,... and it went bad
1453 if (!g->window) {
1454 if (g->top_view->Looper() && !g->top_view->LockLooper())
1455 return;
1456 }
1457
1458 BRect rect(g->top_view->Bounds());
1459 rect.top += TOOLBAR_HEIGHT;
1460 rect.right -= B_V_SCROLL_BAR_WIDTH;
1461 rect.bottom -= B_H_SCROLL_BAR_HEIGHT;
1462
1463 view->ResizeTo(rect.Width() /*+ 1*/, rect.Height() /*+ 1*/);
1464 view->MoveTo(rect.LeftTop());
1465
1466
1467 g->scroll_view = new BScrollView("NetSurfScrollView", view,
1468 B_FOLLOW_ALL, 0, true, true, B_NO_BORDER);
1469
1470 g->top_view->AddChild(g->scroll_view);
1471
1472 // for replicants, add a NSResizeKnob to allow resizing
1473 if (!g->window) {
1474 BRect frame = g->scroll_view->Bounds();
1475 frame.left = frame.right - B_V_SCROLL_BAR_WIDTH;
1476 frame.top = frame.bottom - B_H_SCROLL_BAR_HEIGHT;
1477 NSResizeKnob *knob = new NSResizeKnob(frame, g->top_view);
1478 //TODO: set bitmap
1479 g->scroll_view->AddChild(knob);
1480 }
1481
1482 view->MakeFocus();
1483
1484 // resize the horiz scrollbar to make room for the status bar and add it.
1485
1486 BScrollBar *sb = g->scroll_view->ScrollBar(B_HORIZONTAL);
1487 rect = sb->Frame();
1488 float divider = rect.Width() + 1;
1489 //divider /= 2;
1490 divider *= 67.0/100; // 67%
1491
1492 sb->ResizeBy(-divider, 0);
1493 sb->MoveBy(divider, 0);
1494
1495 rect.right = rect.left + divider - 1;
1496
1497 /*
1498 BBox *statusBarBox = new BBox(rect, "StatusBarBox",
1499 B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM,
1500 B_WILL_DRAW | B_FRAME_EVENTS,
1501 B_RAISED_BORDER);
1502 */
1503
1504 g->status_bar->MoveTo(rect.LeftTop());
1505 g->status_bar->ResizeTo(rect.Width() + 1, rect.Height() + 1);
1506 g->scroll_view->AddChild(g->status_bar);
1507 g->status_bar->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
1508 g->status_bar->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)) ;
1509#if defined(__HAIKU__) || defined(B_DANO_VERSION)
1510 g->status_bar->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
1511#endif
1512
1513
1514
1515 // set targets to the topmost ns view,
1516 // we might not have a window later (replicant ?)
1517 // this won't work for replicants, since the base view isn't attached yet
1518 // we'll redo this in NSBaseView::AllAttached
1519 g->back_button->SetTarget(view);
1520 g->forward_button->SetTarget(view);
1521 g->stop_button->SetTarget(view);
1522 g->reload_button->SetTarget(view);
1523 g->home_button->SetTarget(view);
1524
1525 g->url_bar->SetTarget(view);
1526 g->search_bar->SetTarget(view);
1527
1529
1531
1532 if (g->window) {
1534
1535 // add toolbar shortcuts
1536 BMessage *message;
1537
1538 message = new BMessage('back');
1539 message->AddPointer("scaffolding", g);
1540 g->window->AddShortcut(B_LEFT_ARROW, 0, message, view);
1541
1542 message = new BMessage('forw');
1543 message->AddPointer("scaffolding", g);
1544 g->window->AddShortcut(B_RIGHT_ARROW, 0, message, view);
1545
1546 message = new BMessage('stop');
1547 message->AddPointer("scaffolding", g);
1548 g->window->AddShortcut('S', 0, message, view);
1549
1550 message = new BMessage('relo');
1551 message->AddPointer("scaffolding", g);
1552 g->window->AddShortcut('R', 0, message, view);
1553
1554 message = new BMessage('home');
1555 message->AddPointer("scaffolding", g);
1556 g->window->AddShortcut('H', 0, message, view);
1557
1558
1559#if defined(__HAIKU__)
1560 // Make sure the window is layouted and answering to events, but do not
1561 // show it before it is actually resized
1562 g->window->Hide();
1563 g->window->Show();
1564
1567 stack.AddWindow(g->window);
1568 }
1569#endif
1570 g->window->Show();
1571
1572 } else {
1573 if (g->top_view->Looper())
1574 g->top_view->UnlockLooper();
1575 }
1576
1577
1578}
1579
1580static BMenuItem *make_menu_item(const char *name, BMessage *message, bool enabled=false)
1581{
1582 BMenuItem *item;
1583 BString label(messages_get(name));
1584 BString accelKey(name);
1585 accelKey += "Accel";
1586 BString accel(messages_get(accelKey));
1587 if (accel == accelKey)
1588 accel = "";
1589 uint32 mods = 0;
1590 char key = 0;
1591 // try to understand accelerators
1592 if (!accel.IsEmpty()) {
1593 if (accel.FindFirst("\xe2\x87\x91") > -1) {
1594 accel.RemoveFirst("\xe2\x87\x91");
1595 mods |= B_SHIFT_KEY;
1596 }
1597 if (accel.FindFirst("^") > -1) {
1598 accel.RemoveFirst("^");
1599 mods |= B_CONTROL_KEY;
1600 }
1601 if (accel.FindFirst("PRINT") > -1) {
1602 accel.RemoveFirst("PRINT");
1603 //mods |= ; // ALT!!!
1604 key = B_PRINT_KEY;
1605 }
1606
1607 /* replace UTF-8 glyphs (arrows...) with API codes */
1608 accel.ReplaceAll("\xE2\x86\x90", (BString()+=B_LEFT_ARROW).String());
1609 accel.ReplaceAll("\xE2\x86\x92", (BString()+=B_RIGHT_ARROW).String());
1610 accel.ReplaceAll("\xE2\x86\x91", (BString()+=B_UP_ARROW).String());
1611
1612 if (accel.Length() > 1 && accel[0] == 'F') { // Function key
1613 int num;
1614 if (sscanf(accel.String(), "F%d", &num) > 0) {
1615 //
1616 }
1617 } else if (accel.Length() > 0) {
1618 key = accel[0];
1619 }
1620 //printf("MENU: detected accel '%s' mods 0x%08lx, key %d\n", accel.String(), mods, key);
1621 }
1622
1623 // turn ... into ellipsis
1624 label.ReplaceAll("...", B_UTF8_ELLIPSIS);
1625
1626 item = new BMenuItem(label.String(), message, key, mods);
1627
1628 item->SetEnabled(enabled);
1629
1630 return item;
1631}
1632
1633
1634class BBitmapButton: public BButton
1635{
1636 public:
1637 BBitmapButton(BRect rect, const char* name, const char* label,
1638 BMessage* message);
1640
1641 void Draw(BRect updateRect);
1642 void SetBitmap(const char* attrName);
1643 private:
1644 BBitmap* fBitmap;
1646};
1647
1648
1649BBitmapButton::BBitmapButton(BRect rect, const char* name, const char* label,
1650 BMessage* message)
1651 : BButton(rect, name, label, message)
1652{
1653 SetBitmap(name);
1654}
1655
1656
1658{
1659 delete fBitmap;
1660 delete fDisabledBitmap;
1661}
1662
1663
1664void BBitmapButton::Draw(BRect updateRect)
1665{
1666 if(fBitmap == NULL) {
1667 BButton::Draw(updateRect);
1668 return;
1669 }
1670
1671 SetDrawingMode(B_OP_COPY);
1672 FillRect(updateRect, B_SOLID_LOW);
1673 rgb_color color = LowColor();
1674
1675 SetDrawingMode(B_OP_ALPHA);
1676 if(IsEnabled()) {
1677 if(Value() != 0) {
1678 // button is clicked
1679 DrawBitmap(fBitmap, BPoint(1, 1));
1680 } else {
1681 // button is released
1682 DrawBitmap(fBitmap, BPoint(0, 0));
1683 }
1684 } else
1685 DrawBitmap(fDisabledBitmap, BPoint(0, 0));
1686}
1687
1688
1689void BBitmapButton::SetBitmap(const char* attrname)
1690{
1691#ifdef __HAIKU__
1692 size_t size = 0;
1693 const void* data = gAppResources->LoadResource('VICN', attrname, &size);
1694
1695 if (!data) {
1696 printf("CANT LOAD RESOURCE %s\n", attrname);
1697 return;
1698 }
1699
1700 fBitmap = new BBitmap(BRect(0, 0, 32, 32), B_RGB32);
1701 status_t status = BIconUtils::GetVectorIcon((const uint8*)data, size, fBitmap);
1702
1703 if(status != B_OK) {
1704 fprintf(stderr, "%s > oops %s\n", attrname, strerror(status));
1705 delete fBitmap;
1706 fBitmap = NULL;
1707 }
1708
1709 fDisabledBitmap = new BBitmap(fBitmap);
1710 rgb_color* pixel = (rgb_color*)fDisabledBitmap->Bits();
1711 for(int i = 0; i < fDisabledBitmap->BitsLength()/4; i++)
1712 {
1713 *pixel = tint_color(*pixel, B_DISABLED_MARK_TINT);
1714 pixel++;
1715 }
1716#else
1717 // No vector icon support on BeOS. We could try to load a bitmap one
1718 fBitmap = NULL;
1719 fDisabledBitmap = NULL;
1720#endif
1721}
1722
1723
1725{
1726 struct beos_scaffolding *g = (struct beos_scaffolding *)malloc(sizeof(*g));
1727
1728 NSLOG(netsurf, INFO,
1729 "Constructing a scaffold of %p for gui_window %p", g, toplevel);
1730
1731 g->top_level = toplevel;
1732 g->being_destroyed = 0;
1733 g->fullscreen = false;
1734
1735 open_windows++;
1736
1737 BMessage *message;
1738 BRect rect;
1739 BMenuItem *item;
1740
1741 g->window = NULL;
1742 g->menu_bar = NULL;
1743
1744 if (replicated && !replicant_view) {
1745 beos_warn_user("Error: No subwindow allowed when replicated.", NULL);
1746 return NULL;
1747 }
1748
1749
1750 if (!replicant_view) {
1751 BRect frame(0, 0, 600-1, 500-1);
1752 if (nsoption_int(window_width) > 0) {
1753 frame.Set(0, 0, nsoption_int(window_width) - 1, nsoption_int(window_height) - 1);
1754 frame.OffsetToSelf(nsoption_int(window_x), nsoption_int(window_y));
1755 } else {
1756 BPoint pos(50, 50);
1757 // XXX: use last BApplication::WindowAt()'s dynamic_cast<NSBrowserWindow *> Frame()
1759 if (win) {
1760 pos = win->Frame().LeftTop();
1761 win->UnlockLooper();
1762 }
1763 pos += BPoint(20, 20);
1764 BScreen screen;
1765 BRect screenFrame(screen.Frame());
1766 if (pos.y + frame.Height() >= screenFrame.Height()) {
1767 pos.y = 50;
1768 pos.x += 50;
1769 }
1770 if (pos.x + frame.Width() >= screenFrame.Width()) {
1771 pos.x = 50;
1772 pos.y = 50;
1773 }
1774 frame.OffsetToSelf(pos);
1775 }
1776
1777 g->window = new NSBrowserWindow(frame, g);
1778
1779 rect = frame.OffsetToCopy(0,0);
1780 rect.bottom = rect.top + 20;
1781
1782 // build menus
1783 g->menu_bar = new BMenuBar(rect, "menu_bar");
1784 g->window->AddChild(g->menu_bar);
1785
1786 BMenu *menu;
1787
1788 // App menu
1789 //XXX: use icon item ?
1790
1791 menu = new BMenu(messages_get("NetSurf"));
1792 g->menu_bar->AddItem(menu);
1793
1794 message = new BMessage(B_ABOUT_REQUESTED);
1795 item = make_menu_item("Info", message, true);
1796 menu->AddItem(item);
1797
1798#if 0
1799 message = new BMessage(NO_ACTION);
1800 item = make_menu_item("AppHelp", message);
1801 menu->AddItem(item);
1802
1803 submenu = new BMenu(messages_get("Open"));
1804 menu->AddItem(submenu);
1805
1806 message = new BMessage(NO_ACTION);
1807 item = make_menu_item("OpenURL", message);
1808 submenu->AddItem(item);
1809
1810 message = new BMessage(CHOICES_SHOW);
1811 item = make_menu_item("Choices", message);
1812 menu->AddItem(item);
1813#endif
1814
1815 message = new BMessage(APPLICATION_QUIT);
1816 item = make_menu_item("Quit", message, true);
1817 menu->AddItem(item);
1818
1819 // Page menu
1820
1821 menu = new BMenu(messages_get("Page"));
1822 g->menu_bar->AddItem(menu);
1823
1824#if 0
1825 message = new BMessage(BROWSER_PAGE_INFO);
1826 item = make_menu_item("PageInfo", message);
1827 menu->AddItem(item);
1828
1829 message = new BMessage(BROWSER_SAVE);
1830 item = make_menu_item("SaveAsNS", message);
1831 menu->AddItem(item);
1832
1833 message = new BMessage(BROWSER_SAVE_COMPLETE);
1834 item = make_menu_item("SaveCompNS", message);
1835 menu->AddItem(item);
1836
1837 submenu = new BMenu(messages_get("Export"));
1838 menu->AddItem(submenu);
1839
1840 /*
1841 message = new BMessage(BROWSER_EXPORT_DRAW);
1842 item = make_menu_item("Draw", message);
1843 submenu->AddItem(item);
1844 */
1845
1846 message = new BMessage(BROWSER_EXPORT_TEXT);
1847 item = make_menu_item("LinkText", message);
1848 submenu->AddItem(item);
1849
1850
1851 submenu = new BMenu(messages_get("SaveURL"));
1852 menu->AddItem(submenu);
1853
1854 //XXX
1855 message = new BMessage(BROWSER_OBJECT_SAVE_URL_URL);
1856 item = make_menu_item("URL", message);
1857 submenu->AddItem(item);
1858
1859
1860 message = new BMessage(BROWSER_PRINT);
1861 item = make_menu_item("PrintNS", message);
1862 menu->AddItem(item);
1863#endif
1864
1865 message = new BMessage(BROWSER_NEW_WINDOW);
1866 item = make_menu_item("NewWindowNS", message, true);
1867 menu->AddItem(item);
1868
1869 message = new BMessage(BROWSER_VIEW_SOURCE);
1870 item = make_menu_item("ViewSrc", message, true);
1871 menu->AddItem(item);
1872
1873#if 0 // FIXME This is supposed to be a popup menu!
1874 // Object menu
1875
1876 menu = new BMenu(messages_get("Object"));
1877 g->menu_bar->AddItem(menu);
1878
1879 message = new BMessage(BROWSER_OBJECT_INFO);
1880 item = make_menu_item("ObjInfo", message);
1881 menu->AddItem(item);
1882
1883 message = new BMessage(BROWSER_OBJECT_SAVE);
1884 item = make_menu_item("ObjSave", message);
1885 menu->AddItem(item);
1886 // XXX: submenu: Sprite ?
1887
1888 message = new BMessage(BROWSER_OBJECT_RELOAD);
1889 item = make_menu_item("ObjReload", message);
1890 menu->AddItem(item);
1891#endif
1892
1893 // Navigate menu
1894
1895 menu = new BMenu(messages_get("Navigate"));
1896 g->menu_bar->AddItem(menu);
1897
1898 message = new BMessage(BROWSER_NAVIGATE_HOME);
1899 item = make_menu_item("Home", message, true);
1900 menu->AddItem(item);
1901
1902 message = new BMessage(BROWSER_NAVIGATE_BACK);
1903 item = make_menu_item("Back", message, true);
1904 menu->AddItem(item);
1905
1906 message = new BMessage(BROWSER_NAVIGATE_FORWARD);
1907 item = make_menu_item("Forward", message, true);
1908 menu->AddItem(item);
1909
1910 message = new BMessage(BROWSER_NAVIGATE_UP);
1911 item = make_menu_item("UpLevel", message);
1912 menu->AddItem(item);
1913
1914 message = new BMessage(BROWSER_NAVIGATE_RELOAD);
1915 item = make_menu_item("Reload", message, true);
1916 menu->AddItem(item);
1917
1918 message = new BMessage(BROWSER_NAVIGATE_STOP);
1919 item = make_menu_item("Stop", message, true);
1920 menu->AddItem(item);
1921
1922#if 0
1923 // View menu
1924
1925 menu = new BMenu(messages_get("View"));
1926 g->menu_bar->AddItem(menu);
1927
1928 message = new BMessage(BROWSER_SCALE_VIEW);
1929 item = make_menu_item("ScaleView", message);
1930 menu->AddItem(item);
1931
1932 submenu = new BMenu(messages_get("Images"));
1933 menu->AddItem(submenu);
1934
1935 message = new BMessage(BROWSER_IMAGES_FOREGROUND);
1936 item = make_menu_item("ForeImg", message);
1937 submenu->AddItem(item);
1938
1939 message = new BMessage(BROWSER_IMAGES_BACKGROUND);
1940 item = make_menu_item("BackImg", message);
1941 submenu->AddItem(item);
1942
1943
1944 submenu = new BMenu(messages_get("Toolbars"));
1945 menu->AddItem(submenu);
1946 submenu->SetEnabled(false);
1947
1948 message = new BMessage(NO_ACTION);
1949 item = make_menu_item("ToolButtons", message);
1950 submenu->AddItem(item);
1951
1952 message = new BMessage(NO_ACTION);
1953 item = make_menu_item("ToolAddress", message);
1954 submenu->AddItem(item);
1955
1956 message = new BMessage(NO_ACTION);
1957 item = make_menu_item("ToolThrob", message);
1958 submenu->AddItem(item);
1959
1960 message = new BMessage(NO_ACTION);
1961 item = make_menu_item("ToolStatus", message);
1962 submenu->AddItem(item);
1963
1964
1965 submenu = new BMenu(messages_get("Render"));
1966 menu->AddItem(submenu);
1967
1968 message = new BMessage(BROWSER_BUFFER_ANIMS);
1969 item = make_menu_item("RenderAnims", message);
1970 submenu->AddItem(item);
1971
1972 message = new BMessage(BROWSER_BUFFER_ALL);
1973 item = make_menu_item("RenderAll", message);
1974 submenu->AddItem(item);
1975
1976
1977 message = new BMessage(NO_ACTION);
1978 item = make_menu_item("OptDefault", message);
1979 menu->AddItem(item);
1980#endif
1981
1982 // Utilities menu
1983
1984 menu = new BMenu(messages_get("Utilities"));
1985 g->menu_bar->AddItem(menu);
1986
1987#if 0
1988 submenu = new BMenu(messages_get("Hotlist"));
1989 menu->AddItem(submenu);
1990
1991 message = new BMessage(HOTLIST_ADD_URL);
1992 item = make_menu_item("HotlistAdd", message);
1993 submenu->AddItem(item);
1994
1995 message = new BMessage(HOTLIST_SHOW);
1996 item = make_menu_item("HotlistShowNS", message);
1997 submenu->AddItem(item);
1998
1999
2000 submenu = new BMenu(messages_get("History"));
2001 menu->AddItem(submenu);
2002
2003 message = new BMessage(HISTORY_SHOW_LOCAL);
2004 item = make_menu_item("HistLocal", message);
2005 submenu->AddItem(item);
2006
2007 message = new BMessage(HISTORY_SHOW_GLOBAL);
2008 item = make_menu_item("HistGlobal", message);
2009 submenu->AddItem(item);
2010#endif
2011
2012 message = new BMessage(COOKIES_SHOW);
2013 item = make_menu_item("Cookie manager", message, true);
2014 menu->AddItem(item);
2015
2016#if 0
2017 message = new BMessage(BROWSER_FIND_TEXT);
2018 item = make_menu_item("FindText", message);
2019 menu->AddItem(item);
2020
2021 submenu = new BMenu(messages_get("Window"));
2022 menu->AddItem(submenu);
2023
2024 message = new BMessage(BROWSER_WINDOW_DEFAULT);
2025 item = make_menu_item("WindowSave", message);
2026 submenu->AddItem(item);
2027
2028 message = new BMessage(BROWSER_WINDOW_STAGGER);
2029 item = make_menu_item("WindowStagr", message);
2030 submenu->AddItem(item);
2031
2032 message = new BMessage(BROWSER_WINDOW_COPY);
2033 item = make_menu_item("WindowSize", message);
2034 submenu->AddItem(item);
2035
2036 message = new BMessage(BROWSER_WINDOW_RESET);
2037 item = make_menu_item("WindowReset", message);
2038 submenu->AddItem(item);
2039#endif
2040
2041
2042 // Help menu
2043
2044 menu = new BMenu(messages_get("Help"));
2045 g->menu_bar->AddItem(menu);
2046
2047#if 0
2048 message = new BMessage(HELP_OPEN_CONTENTS);
2049 item = make_menu_item("HelpContent", message);
2050 menu->AddItem(item);
2051
2052 message = new BMessage(HELP_OPEN_GUIDE);
2053 item = make_menu_item("HelpGuide", message);
2054 menu->AddItem(item);
2055
2056 message = new BMessage(HELP_OPEN_INFORMATION);
2057 item = make_menu_item("HelpInfo", message);
2058 menu->AddItem(item);
2059#endif
2060
2061 message = new BMessage(HELP_OPEN_ABOUT);
2062 item = make_menu_item("HelpCredits", message, true);
2063 menu->AddItem(item);
2064
2065 message = new BMessage(HELP_OPEN_LICENCE);
2066 item = make_menu_item("HelpLicence", message, true);
2067 menu->AddItem(item);
2068
2069#if 0
2070 message = new BMessage(HELP_LAUNCH_INTERACTIVE);
2071 item = make_menu_item("HelpInter", message);
2072 menu->AddItem(item);
2073#endif
2074
2075 // the base view that receives the toolbar, statusbar and top-level view.
2076 rect = frame.OffsetToCopy(0,0);
2077 rect.top = g->menu_bar->Bounds().Height() + 1;
2078 //rect.top = 20 + 1; // XXX
2079 //rect.bottom -= B_H_SCROLL_BAR_HEIGHT;
2080 g->top_view = new NSBaseView(rect);
2081 // add the top view to the window
2082 g->window->AddChild(g->top_view);
2083 } else { // replicant_view
2084 // the base view has already been created with the archive constructor
2086 }
2087 g->top_view->SetScaffolding(g);
2088
2089 // build popup menu
2090 g->popup_menu = new BPopUpMenu("popup", false, false);
2091
2092#if 0
2093 message = new BMessage(BROWSER_OBJECT_INFO);
2094 item = make_menu_item("ObjInfo", message);
2095 g->popup_menu->AddItem(item);
2096
2097 message = new BMessage(BROWSER_OBJECT_SAVE);
2098 item = make_menu_item("ObjSave", message);
2099 g->popup_menu->AddItem(item);
2100 // XXX: submenu: Sprite ?
2101#endif
2102
2103 message = new BMessage(BROWSER_OBJECT_RELOAD);
2104 item = make_menu_item("ObjReload", message, true);
2105 g->popup_menu->AddItem(item);
2106
2107
2108#ifdef ENABLE_DRAGGER
2109 // the dragger to allow replicating us
2110 // XXX: try to stuff it in the status bar at the bottom
2111 // (BDragger *must* be a parent, sibiling or direct child of NSBaseView!)
2112 rect = g->top_view->Bounds();
2113 rect.bottom = rect.top + TOOLBAR_HEIGHT - 1;
2114 rect.left = rect.right - DRAGGER_WIDTH + 1;
2115 g->dragger = new BDragger(rect, g->top_view,
2116 B_FOLLOW_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW);
2117 g->top_view->AddChild(g->dragger);
2118 g->dragger->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
2119 g->dragger->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)) ;
2120#endif
2121
2122 // tool_bar
2123 // the toolbar is also the dragger for now
2124 // XXX: try to stuff it in the status bar at the bottom
2125 // (BDragger *must* be a parent, sibiling or direct child of NSBaseView!)
2126 // XXX: B_FULL_UPDATE_ON_RESIZE avoids leaving bits on resize,
2127 // but causes flicker
2128 rect = g->top_view->Bounds();
2129 rect.bottom = rect.top + TOOLBAR_HEIGHT - 1;
2130#ifdef ENABLE_DRAGGER
2131 rect.right = rect.right - DRAGGER_WIDTH;
2132#else
2133 rect.right = rect.right + 1;
2134#endif
2135 g->tool_bar = new BBox(rect, "Toolbar",
2136 B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS
2137 | B_FULL_UPDATE_ON_RESIZE | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
2138 g->top_view->AddChild(g->tool_bar);
2139 g->tool_bar->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
2140 g->tool_bar->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)) ;
2141
2142 // buttons
2143 rect = g->tool_bar->Bounds();
2144 rect.right = TOOLBAR_HEIGHT;
2145 rect.InsetBySelf(5, 5);
2146 rect.OffsetBySelf(0, -1);
2147 int nButtons = 0;
2148
2149 message = new BMessage('back');
2150 message->AddPointer("scaffolding", g);
2151 g->back_button = new BBitmapButton(rect, "back_button", "<", message);
2152 g->tool_bar->AddChild(g->back_button);
2153 nButtons++;
2154
2155 rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
2156 message = new BMessage('forw');
2157 message->AddPointer("scaffolding", g);
2158 g->forward_button = new BBitmapButton(rect, "forward_button", ">", message);
2159 g->tool_bar->AddChild(g->forward_button);
2160 nButtons++;
2161
2162 rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
2163 message = new BMessage('stop');
2164 message->AddPointer("scaffolding", g);
2165 g->stop_button = new BBitmapButton(rect, "stop_button", "S", message);
2166 g->tool_bar->AddChild(g->stop_button);
2167 nButtons++;
2168
2169 rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
2170 message = new BMessage('relo');
2171 message->AddPointer("scaffolding", g);
2172 g->reload_button = new BBitmapButton(rect, "reload_button", "R", message);
2173 g->tool_bar->AddChild(g->reload_button);
2174 nButtons++;
2175
2176 rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
2177 message = new BMessage('home');
2178 message->AddPointer("scaffolding", g);
2179 g->home_button = new BBitmapButton(rect, "home_button", "H", message);
2180 g->tool_bar->AddChild(g->home_button);
2181 nButtons++;
2182
2183
2184 // url bar
2185 rect = g->tool_bar->Bounds();
2186 rect.left += TOOLBAR_HEIGHT * nButtons;
2187 rect.right -= TOOLBAR_HEIGHT * 1 + 100;
2188 rect.InsetBySelf(5, 5);
2189 message = new BMessage('urle');
2190 message->AddPointer("scaffolding", g);
2191 g->url_bar = new NSIconTextControl(rect, "url_bar", "", "", message,
2192 B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
2193 g->url_bar->SetDivider(0);
2194 rect = g->url_bar->TextView()->TextRect();
2195 rect.left += 16;
2196 g->url_bar->TextView()->SetTextRect(rect);
2197 g->tool_bar->AddChild(g->url_bar);
2198
2199 // search bar
2200
2201 rect = g->tool_bar->Bounds();
2202 rect.left = g->url_bar->Frame().right;
2203 rect.right -= TOOLBAR_HEIGHT * 1;
2204 rect.InsetBy(5,5);
2205 message = new BMessage('sear');
2206 message->AddPointer("scaffolding", g);
2207 g->search_bar = new BTextControl(rect, "search_bar", "",
2208 "Search" B_UTF8_ELLIPSIS, message, B_FOLLOW_RIGHT | B_FOLLOW_TOP);
2209 g->search_bar->SetDivider(0);
2210 g->tool_bar->AddChild(g->search_bar);
2211
2212 // throbber
2213 rect.Set(0, 0, 24, 24);
2214 rect.OffsetTo(g->tool_bar->Bounds().right - 24 - (TOOLBAR_HEIGHT - 24) / 2,
2215 (TOOLBAR_HEIGHT - 24) / 2);
2216 g->throbber = new NSThrobber(rect);
2217 g->tool_bar->AddChild(g->throbber);
2218 g->throbber->SetViewColor(g->tool_bar->ViewColor());
2219 g->throbber->SetLowColor(g->tool_bar->ViewColor());
2220 g->throbber->SetDrawingMode(B_OP_ALPHA);
2221 g->throbber->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
2222 /* set up the throbber. */
2224 g->throb_frame = 0;
2225
2226
2227 // the status bar at the bottom
2228 BString status("NetSurf");
2229 status << " " << netsurf_version;
2230 g->status_bar = new BStringView(BRect(0,0,-1,-1), "StatusBar",
2231 status.String(), B_FOLLOW_LEFT/*_RIGHT*/ | B_FOLLOW_BOTTOM);
2232
2233 // will be added to the scrollview when adding the top view.
2234
2235 // notify the thread creating the replicant that we're done
2236 if (replicant_view)
2237 release_sem(replicant_done_sem);
2238
2239 replicant_view = NULL;
2240
2241 return g;
2242}
2243
2244void gui_window_set_title(struct gui_window *_g, const char *title)
2245{
2246 struct beos_scaffolding *g = nsbeos_get_scaffold(_g);
2247 if (g->top_level != _g) return;
2248
2249 // if we're a replicant, discard
2250 if (!g->window)
2251 return;
2252
2253 BString nt(title);
2254 if (nt.Length())
2255 nt << " - ";
2256 nt << "NetSurf";
2257
2258 if (!g->top_view->LockLooper())
2259 return;
2260
2261 g->window->SetTitle(nt.String());
2262
2263 g->top_view->UnlockLooper();
2264}
2265
2266void gui_window_set_status(struct gui_window *_g, const char *text)
2267{
2268 struct beos_scaffolding *g = nsbeos_get_scaffold(_g);
2269 assert(g);
2270 assert(g->status_bar);
2271
2272 if (!g->top_view->LockLooper())
2273 return;
2274
2275 if (text == NULL || text[0] == '\0')
2276 {
2277 BString status("NetSurf");
2278 status << " " << netsurf_version;
2279 g->status_bar->SetText(status.String());
2280 }
2281 else
2282 {
2283 g->status_bar->SetText(text);
2284 }
2285 g->top_view->UnlockLooper();
2286}
2287
2289{
2290 struct beos_scaffolding *g;
2291
2292 g = nsbeos_get_scaffold(gw);
2293 if (g->top_level != gw)
2294 return NSERROR_OK;
2295
2296 assert(g->status_bar);
2297
2298 if (g->top_view->LockLooper()) {
2299 g->url_bar->SetText(nsurl_access(url));
2300
2301 g->top_view->UnlockLooper();
2302 }
2303
2304 return NSERROR_OK;
2305}
2306
2308{
2309 struct beos_scaffolding *g = nsbeos_get_scaffold(_g);
2310
2311 if (!g->top_view->LockLooper())
2312 return;
2313
2314 g->stop_button->SetEnabled(true);
2315 g->reload_button->SetEnabled(false);
2316
2317 g->top_view->UnlockLooper();
2318
2320
2321 beos_schedule(100, nsbeos_throb, g);
2322}
2323
2325{
2326 struct beos_scaffolding *g = nsbeos_get_scaffold(_g);
2327
2329
2331
2332 if (!g->top_view->LockLooper())
2333 return;
2334
2335 g->stop_button->SetEnabled(false);
2336 g->reload_button->SetEnabled(true);
2337
2339 g->throbber->Invalidate();
2340
2341 g->top_view->UnlockLooper();
2342}
2343
2344/**
2345 * add retrieved favicon to the gui
2346 */
2348{
2349 BBitmap *bitmap = NULL;
2350 struct bitmap *bmp_icon;
2351
2352 bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
2353
2354 if (bmp_icon) {
2356 }
2357
2358 struct beos_scaffolding *g = nsbeos_get_scaffold(_g);
2359
2360 if (!g->top_view->LockLooper())
2361 return;
2362
2364
2365 g->top_view->UnlockLooper();
2366}
2367
2368
2369void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *scaffold, struct browser_window *bw, BPoint where, BPoint screenWhere)
2370{
2371 struct browser_window_features cont;
2372
2373 browser_window_get_features(bw, (int)where.x, (int)where.y, &cont);
2374
2375 scaffold->current_menu_object = cont.object;
2376 bool enabled = !!scaffold->current_menu_object;
2377
2378 for (int i = 0; scaffold->popup_menu->ItemAt(i); i++) {
2379 scaffold->popup_menu->ItemAt(i)->SetEnabled(enabled);
2380 }
2381
2382 scaffold->popup_menu->Go(screenWhere, true, false, true);
2383}
2384
void nsbeos_about(struct gui_window *gui)
Creates the about alert.
Definition: about.cpp:44
#define PATH_MAX
Definition: gui.h:31
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
@ HELP_OPEN_LICENCE
Definition: scaffolding.h:87
@ 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
BBitmap * nsbeos_bitmap_get_primary(struct bitmap *bitmap)
The primary image associated with this bitmap object.
Definition: bitmap.cpp:308
nserror browser_window_history_forward(struct browser_window *bw, bool new_window)
Go forward in the history.
bool browser_window_history_forward_available(struct browser_window *bw)
Check whether it is pssible to go forwards in the history.
bool browser_window_history_back_available(struct browser_window *bw)
Check whether it is pssible to go back in the history.
nserror browser_window_history_back(struct browser_window *bw, bool new_window)
Go back in the history.
Interface to browser history operations.
Browser window creation and manipulation interface.
nserror browser_window_get_features(struct browser_window *bw, int x, int y, struct browser_window_features *data)
Get access to any page features at the given coordinates.
nserror browser_window_navigate(struct browser_window *bw, struct nsurl *url, struct nsurl *referrer, enum browser_window_nav_flags flags, char *post_urlenc, struct fetch_multipart_data *post_multipart, struct hlcache_handle *parent)
Start fetching a page in a browser window.
bool browser_window_has_content(struct browser_window *bw)
Find out if a browser window is currently showing a content.
nserror browser_window_reload(struct browser_window *bw, bool all)
Reload the page in a browser window.
nserror browser_window_create(enum browser_window_create_flags flags, struct nsurl *url, struct nsurl *referrer, struct browser_window *existing, struct browser_window **bw)
Create and open a new root browser window with the given page.
void browser_window_stop(struct browser_window *bw)
Stop all fetching activity in a browser window.
struct hlcache_handle * browser_window_get_content(struct browser_window *bw)
Get a cache handle for the content within a browser window.
browser_window_create_flags
flags to browser_window_create
@ BW_CREATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
@ BW_CREATE_TAB
New gui_window to be tab in same window as "existing" gui_window.
@ BW_CREATE_CLONE
New gui_window to be clone of "existing" gui_window.
browser_window_nav_flags
flags to browser_window_navigate
@ BW_NAVIGATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
@ BW_NAVIGATE_UNVERIFIABLE
Transation not caused by user interaction (e.g.
void Draw(BRect updateRect)
BBitmap * fDisabledBitmap
void SetBitmap(const char *attrName)
BBitmap * fBitmap
BBitmapButton(BRect rect, const char *name, const char *label, BMessage *message)
status_t AddWindow(const BWindow *window)
virtual status_t Archive(BMessage *archive, bool deep=true) const
virtual void MessageReceived(BMessage *message)
static BArchivable * Instantiate(BMessage *archive)
struct beos_scaffolding * fScaffolding
Definition: scaffolding.h:53
NSBaseView(BRect frame)
void SetScaffolding(struct beos_scaffolding *scaf)
virtual ~NSBaseView()
virtual void AllAttached(void)
virtual bool QuitRequested(void)
virtual void DispatchMessage(BMessage *message, BHandler *handler)
NSBrowserWindow(BRect frame, struct beos_scaffolding *scaf)
static BWindow * activeWindow
Definition: scaffolding.h:68
struct beos_scaffolding * fScaffolding
Definition: scaffolding.h:70
void WindowActivated(bool active)
virtual ~NSBrowserWindow()
virtual void MessageReceived(BMessage *message)
virtual void AttachedToWindow()
virtual void FrameResized(float newWidth, float newHeight)
void SetBitmap(const BBitmap *bitmap)
virtual void Draw(BRect updateRect)
const BBitmap * fIconBitmap
virtual ~NSIconTextControl()
NSIconTextControl(BRect frame, const char *name, const char *label, const char *initialText, BMessage *message, uint32 resizeMode=B_FOLLOW_LEFT|B_FOLLOW_TOP, uint32 flags=B_WILL_DRAW|B_NAVIGABLE|B_DRAW_ON_CHILDREN)
virtual void DrawAfterChildren(BRect updateRect)
void SetBitmap(const BBitmap *bitmap)
virtual void MouseUp(BPoint where)
virtual void MouseDown(BPoint where)
virtual void MouseMoved(BPoint where, uint32 code, const BMessage *dragMessage)
NSResizeKnob(BRect frame, BView *target)
BView * fTarget
const BBitmap * fBitmap
virtual void Draw(BRect updateRect)
virtual ~NSResizeKnob()
NSThrobber(BRect frame)
const BBitmap * fBitmap
virtual ~NSThrobber()
virtual void MessageReceived(BMessage *message)
virtual void Draw(BRect updateRect)
void SetBitmap(const BBitmap *bitmap)
Declaration of content enumerations.
void nsbeos_cookies_init(void)
Creates the Cookie Manager.
Definition: cookies.cpp:410
Browseing window text search interface.
nserror search_web_omni(const char *term, enum search_web_omni_flags flags, struct nsurl **url_out)
Generate a nsurl from a search term.
Definition: searchweb.c:318
nserror search_web_init(const char *provider_fname)
Initialise the web search operations.
Definition: searchweb.c:525
nserror search_web_finalise(void)
Finalise the web search operations freeing all resources.
Definition: searchweb.c:582
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_OK
No error.
Definition: errors.h:30
Form handling public interface.
Target independent plotting (BeOS interface).
void nsbeos_gui_view_source(struct hlcache_handle *content)
Send the source of a content to a text editor.
Definition: gui.cpp:830
image_id nsbeos_find_app_path(char *path)
Definition: gui.cpp:246
bool nsbeos_done
Definition: gui.cpp:90
void nsbeos_gui_poll(void)
Definition: gui.cpp:745
int gui_init_replicant(int argc, char **argv)
called when replicated from NSBaseView::Instantiate()
Definition: gui.cpp:1102
void nsbeos_pipe_message_top(BMessage *message, BWindow *_this, struct beos_scaffolding *scaffold)
Definition: gui.cpp:731
char * find_resource(char *buf, const char *filename, const char *def)
Locate a shared resource file by searching known places in order.
Definition: gui.cpp:277
bool replicated
if we are running as a replicant
Definition: gui.cpp:92
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 B_PANEL_TEXT_COLOR
Definition: gui.cpp:403
const char *const netsurf_version
User friendly version string.
Definition: gui_menu.c:92
#define NO_ACTION
Definition: idna.c:695
Interface to platform-specific clipboard operations.
Public content interface.
struct bitmap * content_get_bitmap(struct hlcache_handle *h)
Retrieve the bitmap contained in an image content.
Definition: content.c:1264
void content_invalidate_reuse_data(struct hlcache_handle *h)
Invalidate content reuse data.
Definition: content.c:1229
Target independent plotting interface.
Interface to key press operations.
@ NS_KEY_SELECT_ALL
Definition: keypress.h:32
@ NS_KEY_PASTE
Definition: keypress.h:43
@ NS_KEY_COPY_SELECTION
Definition: keypress.h:33
@ NS_KEY_CUT_SELECTION
Definition: keypress.h:44
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
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
Definition: messages.c:248
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Definition: messages.c:241
Localised message support (interface).
NetSurf core interface registration, construction and destruction.
void netsurf_exit(void)
Finalise NetSurf core.
Definition: netsurf.c:232
NetSurf URL handling (interface).
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
uint8_t uint8
Definition: os3support.h:180
int32_t int32
Definition: os3support.h:183
uint32_t uint32
Definition: os3support.h:184
static void nsbeos_scaffolding_update_colors(nsbeos_scaffolding *g)
void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *scaffold, struct browser_window *bw, BPoint where, BPoint screenWhere)
BResources * gAppResources
Definition: fetch_rsrc.cpp:70
nsbeos_scaffolding * nsbeos_new_scaffolding(struct gui_window *toplevel)
nserror gui_window_set_url(struct gui_window *gw, nsurl *url)
void gui_window_start_throbber(struct gui_window *_g)
#define TOOLBAR_HEIGHT
Definition: scaffolding.cpp:88
static void nsbeos_throb(void *)
NSBaseView * nsbeos_get_baseview_for_scaffolding(nsbeos_scaffolding *scaffold)
void nsbeos_scaffolding_destroy(nsbeos_scaffolding *scaffold)
int main(int argc, char **argv)
Normal entry point from OS.
Definition: gui.c:6543
void gui_window_set_status(struct gui_window *_g, const char *text)
static sem_id replicant_done_sem
static void nsbeos_window_destroy_event(NSBrowserWindow *window, nsbeos_scaffolding *g, BMessage *event)
static BMenuItem * make_menu_item(const char *name, BMessage *message, bool enabled=false)
NSBrowserWindow * nsbeos_find_last_window(void)
static int32 nsbeos_replicant_main_thread(void *_arg)
void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *message)
#define ICON_WIDTH
void gui_window_set_icon(struct gui_window *_g, hlcache_handle *icon)
add retrieved favicon to the gui
NSBrowserWindow * nsbeos_get_bwindow_for_scaffolding(nsbeos_scaffolding *scaffold)
static int open_windows
current number of open browsers
static thread_id replicant_thread
static void nsbeos_window_update_back_forward(struct beos_scaffolding *)
static NSBaseView * replicant_view
if not NULL, the replicant View we are running NetSurf for
static void recursively_set_menu_items_target(BMenu *menu, BHandler *handler)
void gui_window_stop_throbber(struct gui_window *_g)
void nsbeos_attach_toplevel_view(nsbeos_scaffolding *g, BView *view)
#define DRAGGER_WIDTH
Definition: scaffolding.cpp:89
void gui_window_set_title(struct gui_window *_g, const char *title)
nserror beos_schedule(int t, void(*callback)(void *p), void *p)
Definition: schedule.cpp:83
core web search facilities interface.
@ SEARCH_WEB_OMNI_SEARCHONLY
The search does not attempt to interpret the url as a url before using it as a search term.
Definition: searchweb.h:55
Interface to utility string handling.
struct beos_scaffolding * g
BPopUpMenu * popup_menu
BMenuBar * menu_bar
BControl * forward_button
BControl * reload_button
struct beos_history_window * history_window
NSBaseView * top_view
BStringView * status_bar
BControl * back_button
BControl * home_button
struct gui_window * top_level
NSIconTextControl * url_bar
NSThrobber * throbber
struct hlcache_handle * current_menu_object
Object under menu, or 0 if no object.
BScrollView * scroll_view
BTextControl * search_bar
BControl * stop_button
NSBrowserWindow * window
Definition: scaffolding.cpp:98
RISC OS wimp toolkit bitmap.
Definition: bitmap.c:68
Page features at a specific spatial location.
struct hlcache_handle * object
Object at position or NULL.
Browser window data.
int x
Window dimensions.
struct browser_window * bw
first entry in window list
Definition: gui.c:298
High-level cache handle.
Definition: hlcache.c:66
const char * widget
int nframes
Number of frames in the throbber.
Definition: throbber.h:26
BBitmap ** framedata
Definition: throbber.h:27
Rectangle coordinates.
Definition: types.h:40
char app[B_PATH_NAME_LENGTH]
struct rect rect
Rectangle coordinates.
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
Definition: nsoption.h:331
#define nsoption_int(OPTION)
Get the value of an integer option.
Definition: nsoption.h:313
Interface to a number of general purpose functionality.
Version information interface.
nsbeos_scaffolding * nsbeos_get_scaffold(struct gui_window *g)
Get containing scaffold of a beos gui window.
Definition: window.cpp:327
void nsbeos_window_destroy_browser(struct gui_window *g)
Definition: window.cpp:913
struct browser_window * nsbeos_get_browser_for_gui(struct gui_window *g)
Definition: window.cpp:332
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
Definition: plot.c:821
static nserror bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
Definition: plot.c:857
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