Finish support for building more than one toolkit at once.

This commit is contained in:
ramiro%netscape.com 1999-08-22 14:06:52 +00:00
Родитель 8d6752f2de
Коммит 20f53e7664
28 изменённых файлов: 1544 добавлений и 7 удалений

Просмотреть файл

@ -346,6 +346,11 @@ webshell/src/Makefile
webshell/tests/Makefile
webshell/tests/viewer/Makefile
webshell/tests/viewer/public/Makefile
webshell/tests/viewer/unix/Makefile
webshell/tests/viewer/unix/gtk/Makefile
webshell/tests/viewer/unix/motif/Makefile
webshell/tests/viewer/unix/qt/Makefile
webshell/tests/viewer/unix/xlib/Makefile
webshell/embed/Makefile
widget/Makefile
widget/public/Makefile

Просмотреть файл

@ -1,3 +1,8 @@
Makefile
viewer
moc_nsQTMenu.cpp
viewer_gtk
viewer_xlib
viewer_qt
viewer_motif

Просмотреть файл

@ -24,6 +24,10 @@ include $(DEPTH)/config/autoconf.mk
DIRS = public
ifeq (,$(filter beos os2 rhapsody photon,$(MOZ_WIDGET_TOOLKIT)))
DIRS += unix
endif
PROGRAM = viewer
RUN_VIEWER_SCRIPT = $(srcdir)/mozilla-viewer.sh
@ -75,11 +79,6 @@ EXPORT_RESOURCE_THROBBER := $(wildcard $(srcdir)/throbber/anim*.gif)
TOOLKIT_CPPSRCS_beos := nsBeOSMain.cpp
TOOLKIT_CPPSRCS_photon := nsPhMain.cpp nsPhMenu.cpp
TOOLKIT_CPPSRCS_gtk := nsGTKMain.cpp nsGTKMenu.cpp
TOOLKIT_CPPSRCS_motif := nsMotifMenu.cpp nsMotifMain.cpp
TOOLKIT_CPPSRCS_xlib := nsXlibMain.cpp
TOOLKIT_CPPSRCS_qt := nsQTMain.cpp nsQTMenu.cpp moc_nsQTMenu.cpp
ifeq ($(MOZ_WIDGET_TOOLKIT),beos)
BEOS_PROGRAM_RESOURCE = $(srcdir)/viewer-beos.rsrc
endif
@ -127,13 +126,22 @@ NETLIB_LIBS = \
$(NULL)
endif
LIBS = \
ifeq (,$(filter beos os2 rhapsody photon,$(MOZ_WIDGET_TOOLKIT)))
UNIX_VIEWER_TK_LIBS = -lviewer_$(MOZ_WIDGET_TOOLKIT)_s
endif
XP_LIBS = \
$(GECKO_LIBS) \
$(NETLIB_LIBS) \
$(IMGLIB_LIBS) \
$(BASE_LIBS) \
$(JSJ_LIB) \
$(NSPR_LIBS) \
$(NULL)
LIBS = \
$(UNIX_VIEWER_TK_LIBS) \
$(XP_LIBS) \
$(TK_LIBS) \
$(NULL)
@ -146,3 +154,68 @@ install:: $(PROGRAM) $(RUN_VIEWER_SCRIPT)
$(INSTALL) $(EXPORT_RESOURCE_THROBBER) $(DIST)/bin/res/throbber
$(INSTALL) $(srcdir)/resources/viewer.properties $(DIST)/bin/res
$(INSTALL) $(RUN_VIEWER_SCRIPT) $(DIST)/bin
##
## Dont try this at home
##
ifdef MOZ_ENABLE_GTK
GTK_LIBS = \
-lviewer_gtk_s \
$(XP_LIBS) \
$(MOZ_GTK_LDFLAGS) \
$(NULL)
$(PROGRAM)_gtk: $(PROGOBJS) $(EXTRA_DEPS) Makefile Makefile.in $(DIST)/lib/libviewer_gtk_s.a
$(CCC) -o $@ $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(GTK_LIBS) $(OS_LIBS)
install:: $(PROGRAM)_gtk
$(INSTALL) -m 555 $(PROGRAM)_gtk $(DIST)/bin
endif
ifdef MOZ_ENABLE_XLIB
XLIB_LIBS = \
-lviewer_xlib_s \
$(XP_LIBS) \
$(MOZ_XLIB_LDFLAGS) \
$(NULL)
$(PROGRAM)_xlib: $(PROGOBJS) $(EXTRA_DEPS) Makefile Makefile.in $(DIST)/lib/libviewer_xlib_s.a
$(CCC) -o $@ $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(XLIB_LIBS) $(OS_LIBS)
install:: $(PROGRAM)_xlib
$(INSTALL) -m 555 $(PROGRAM)_xlib $(DIST)/bin
endif
ifdef MOZ_ENABLE_QT
QT_LIBS = \
-lviewer_qt_s \
$(XP_LIBS) \
$(MOZ_QT_LDFLAGS) \
$(NULL)
$(PROGRAM)_qt: $(PROGOBJS) $(EXTRA_DEPS) Makefile Makefile.in $(DIST)/lib/libviewer_qt_s.a
$(CCC) -o $@ $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(QT_LIBS) $(OS_LIBS)
install:: $(PROGRAM)_qt
$(INSTALL) -m 555 $(PROGRAM)_qt $(DIST)/bin
endif
ifdef MOZ_ENABLE_MOTIF
MOTIF_LIBS = \
-lviewer_motif_s \
$(XP_LIBS) \
$(MOZ_MOTIF_LDFLAGS) \
$(NULL)
$(PROGRAM)_motif: $(PROGOBJS) $(EXTRA_DEPS) Makefile Makefile.in $(DIST)/lib/libviewer_motif_s.a
$(CCC) -o $@ $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(MOTIF_LIBS) $(OS_LIBS)
install:: $(PROGRAM)_motif
$(INSTALL) -m 555 $(PROGRAM)_motif $(DIST)/bin
endif

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,47 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
ifndef MOZ_MONOLITHIC_TOOLKIT
ifdef MOZ_ENABLE_GTK
DIRS += gtk
endif
ifdef MOZ_ENABLE_MOTIF
DIRS += motif
endif
ifdef MOZ_ENABLE_XLIB
DIRS += xlib
endif
ifdef MOZ_ENABLE_QT
DIRS += qt
endif
else
DIRS = $(MOZ_WIDGET_TOOLKIT)
endif # !MOZ_MONOLITHIC_TOOLKIT
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,44 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = viewer_gtk_s
CPPSRCS = \
nsGtkMain.cpp \
nsGtkMenu.cpp \
$(NULL)
MKSHLIB =
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir)/../..
ifndef MOZ_MONOLITHIC_TOOLKIT
CXXFLAGS += $(MOZ_GTK_CFLAGS)
else
CXXFLAGS += $(TK_CFLAGS)
endif

Просмотреть файл

@ -0,0 +1,131 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <gtk/gtk.h>
#include "nsViewerApp.h"
#include "nsBrowserWindow.h"
#include "nsGtkMenu.h"
#include "nsIImageManager.h"
#include <stdlib.h>
#include "plevent.h"
#include "nsIUnixToolkitService.h"
#include "nsIComponentManager.h"
static NS_DEFINE_CID(kCUnixToolkitServiceCID, NS_UNIX_TOOLKIT_SERVICE_CID);
static nsNativeViewerApp* gTheApp;
nsNativeViewerApp::nsNativeViewerApp()
{
}
nsNativeViewerApp::~nsNativeViewerApp()
{
}
int
nsNativeViewerApp::Run()
{
OpenWindow();
mAppShell->Run();
return 0;
}
//----------------------------------------------------------------------
nsNativeBrowserWindow::nsNativeBrowserWindow()
{
}
nsNativeBrowserWindow::~nsNativeBrowserWindow()
{
}
nsresult
nsNativeBrowserWindow::InitNativeWindow()
{
// override to do something special with platform native windows
return NS_OK;
}
nsresult
nsNativeBrowserWindow::CreateMenuBar(PRInt32 aWidth)
{
CreateViewerMenus(mWindow,this);
return NS_OK;
}
nsEventStatus
nsNativeBrowserWindow::DispatchMenuItem(PRInt32 aID)
{
// Dispatch motif-only menu code goes here
// Dispatch xp menu items
return nsBrowserWindow::DispatchMenuItem(aID);
}
//----------------------------------------------------------------------
int main(int argc, char **argv)
{
// Hack to get il_ss set so it doesn't fail in xpcompat.c
nsIImageManager *manager;
NS_NewImageManager(&manager);
gTheApp = new nsNativeViewerApp();
//////////////////////////////////////////////////////////////////////
//
// Toolkit Service setup
//
// Note: This must happend before NS_SetupRegistry() is called so
// that the toolkit specific xpcom components can be registered
// as needed.
//
//////////////////////////////////////////////////////////////////////
nsIUnixToolkitService * unixToolkitService = nsnull;
nsresult rv =
nsComponentManager::CreateInstance(kCUnixToolkitServiceCID,
nsnull,
nsIUnixToolkitService::GetIID(),
(void **) &unixToolkitService);
NS_ASSERTION(NS_SUCCEEDED(rv),"Cannot obtain unix toolkit service.");
if (NS_SUCCEEDED(rv) && (nsnull != unixToolkitService))
{
// Force the toolkit into "gtk" mode
unixToolkitService->SetToolkitName("gtk");
NS_RELEASE(unixToolkitService);
}
//////////////////////////////////////////////////////////////////////
// End toolkit service setup
//////////////////////////////////////////////////////////////////////
gTheApp->Initialize(argc, argv);
gTheApp->Run();
return 0;
}

Просмотреть файл

@ -0,0 +1,173 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <gtk/gtk.h>
#include "nsBrowserWindow.h"
#include "resources.h"
#include "nscore.h"
#include "stdio.h"
typedef GtkItemFactoryCallback GIFC;
void gtk_ifactory_cb (nsBrowserWindow *nbw,
guint callback_action,
GtkWidget *widget)
{
nbw->DispatchMenuItem(callback_action);
}
GtkItemFactoryEntry menu_items[] =
{
{ "/_File", nsnull, nsnull, 0, "<Branch>" },
{ "/File/_New Window", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_WINDOW_OPEN, nsnull },
{ "/File/_Open...", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_FILE_OPEN, nsnull },
{ "/File/_View Source", nsnull, (GIFC)gtk_ifactory_cb, VIEW_SOURCE, nsnull },
{ "/File/_Samples", nsnull, nsnull, 0, "<Branch>" },
{ "/File/Samples/demo #0", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO0, nsnull },
{ "/File/Samples/demo #1", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO1, nsnull },
{ "/File/Samples/demo #2", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO2, nsnull },
{ "/File/Samples/demo #3", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO3, nsnull },
{ "/File/Samples/demo #4", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO4, nsnull },
{ "/File/Samples/demo #5", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO5, nsnull },
{ "/File/Samples/demo #6", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO6, nsnull },
{ "/File/Samples/demo #7", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO7, nsnull },
{ "/File/Samples/demo #8", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO8, nsnull },
{ "/File/Samples/demo #9", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO9, nsnull },
{ "/File/Samples/demo #10", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO10, nsnull },
{ "/File/Samples/demo #11", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO11, nsnull },
{ "/File/Samples/demo #12", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO12, nsnull },
{ "/File/Samples/demo #13", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO13, nsnull },
{ "/File/Samples/demo #14", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO14, nsnull },
{ "/File/Samples/demo #15", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO15, nsnull },
{ "/File/Samples/demo #16", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO16, nsnull },
{ "/File/Samples/demo #17", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO17, nsnull },
{ "/File/_Test Sites", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOP100, nsnull },
{ "/File/XPToolkit Tests", nsnull, nsnull, 0, "<Branch>" },
{ "/File/XPToolkit Tests/Toolbar Test 1", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_XPTOOLKITTOOLBAR1, nsnull },
{ "/File/XPToolkit Tests/Tree Test 1", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_XPTOOLKITTREE1, nsnull },
{ "/File/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/File/Print Preview", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_ONE_COLUMN, nsnull },
{ "/File/Print", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_PRINT, nsnull },
{ "/File/Print Setup", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_PRINT_SETUP, nsnull },
{ "/File/sep2", nsnull, nsnull, 0, "<Separator>" },
{ "/File/_Exit", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EXIT, nsnull },
{ "/_Edit", nsnull, nsnull, 0, "<Branch>" },
{ "/Edit/Cu_t", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_CUT, nsnull },
{ "/Edit/_Copy", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_COPY, nsnull },
{ "/Edit/_Paste", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_PASTE, nsnull },
{ "/Edit/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Edit/Select All", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_SELECTALL, nsnull },
{ "/Edit/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Edit/Find in Page", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_FINDINPAGE, nsnull },
//#ifdef DEBUG // turning off for now
{ "/_Debug", nsnull, nsnull, 0, "<Branch>" },
{ "/Debug/_Visual Debugging", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_VISUAL_DEBUGGING,nsnull },
{ "/Debug/_Reflow Test", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_REFLOW_TEST, nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Dump _Content", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_CONTENT, nsnull },
{ "/Debug/Dump _Frames", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_FRAMES, nsnull },
{ "/Debug/Dump _Views", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_VIEWS, nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Dump _Style Sheets", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_STYLE_SHEETS, nsnull },
{ "/Debug/Dump _Style Contexts", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_STYLE_CONTEXTS, nsnull},
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Show Content Size", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SHOW_CONTENT_SIZE,nsnull },
{ "/Debug/Show Frame Size", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SHOW_FRAME_SIZE, nsnull },
{ "/Debug/Show Style Size", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SHOW_STYLE_SIZE, nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Debug Save", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEBUGSAVE, nsnull },
{ "/Debug/Debug Output Text", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DISPLAYTEXT, nsnull },
{ "/Debug/Debug Output HTML", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DISPLAYHTML, nsnull },
{ "/Debug/Debug Toggle Selection", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_SELECTION,nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Debug Robot", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEBUGROBOT, nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Show Content Quality", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SHOW_CONTENT_QUALITY, nsnull },
{ "/_Style", nsnull, nsnull, 0, "<Branch>" },
{ "/Style/Select _Style Sheet", nsnull, nsnull, 0, "<Branch>" },
{ "/Style/Select Style Sheet/List Available Sheets", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_LIST, nsnull },
{ "/Style/Select Style Sheet/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Style/Select Style Sheet/Select Default", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_DEFAULT, nsnull },
{ "/Style/Select Style Sheet/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Style/Select Style Sheet/Select Alternative 1", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_ONE, nsnull },
{ "/Style/Select Style Sheet/Select Alternative 2", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_TWO, nsnull },
{ "/Style/Select Style Sheet/Select Alternative 3", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_THREE, nsnull },
{ "/Style/Select Style Sheet/Select Alternative 4", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_FOUR, nsnull },
{ "/Style/_Compatibility Mode", nsnull, nsnull, 0, "<Branch>" },
{ "/Style/Compatibility Mode/Nav Quirks", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_NAV_QUIRKS_MODE, nsnull },
{ "/Style/Compatibility Mode/Standard", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_STANDARD_MODE, nsnull },
{ "/Style/_Widget Render Mode", nsnull, nsnull, 0, "<Branch>" },
{ "/Style/Widget Render Mode/Native", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_NATIVE_WIDGET_MODE, nsnull },
{ "/Style/Widget Render Mode/Gfx", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_GFX_WIDGET_MODE, nsnull },
//#endif
{ "/_Tools", nsnull, nsnull, 0, "<Branch>" },
{ "/Tools/_JavaScript Console", nsnull, (GIFC)gtk_ifactory_cb, JS_CONSOLE, nsnull },
{ "/Tools/_Editor Mode", nsnull, (GIFC)gtk_ifactory_cb, EDITOR_MODE, nsnull }
};
void CreateViewerMenus(nsIWidget *aParent, gpointer data)
{
GtkItemFactory *item_factory;
GtkWidget *window;
GtkWidget *menubar;
GtkWidget *vbox;
GtkWidget *aNParent = (GtkWidget*)aParent->GetNativeData(NS_NATIVE_WIDGET);
int nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", nsnull);
gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, data);
/* HACK HACK HACK */
// apprunner no longer needs a vbox, so we're going to remove it
// viewer still use native menus, so we need a vbox, so we'll do a little reparenting dance
// and hack a vbox in.
// we no longer listen to the actual sizes of windows, and instead only listen to the size requested.
// this causes the menu to push the layout down, but the main window stays the same size.
// this means the status area at the bottom is off the page
// to fix that, the layout engine needs to think that the GTK Layout widget is mBounds.height - menubarheight
// i'm not entirely sure how to do this correctly. you could try calling GetBounds on aParent,
// then look at menubar->allocation.height and subtract the two, then call
// gtk_widget_set_usize(aNParent, mBounds.width, newheight)
// or something like that. i'm not entirely sure. this may work
menubar = gtk_item_factory_get_widget (item_factory, "<main>");
gtk_widget_show(menubar);
gtk_menu_bar_set_shadow_type (GTK_MENU_BAR(menubar), GTK_SHADOW_NONE);
window = aNParent->parent;
vbox = gtk_vbox_new(PR_FALSE, PR_FALSE);
gtk_widget_reparent(aNParent, vbox);
gtk_box_pack_start(GTK_BOX(vbox), menubar, PR_FALSE, PR_FALSE, 0);
gtk_box_reorder_child(GTK_BOX(vbox), menubar, 0);
gtk_container_add(GTK_CONTAINER(window), vbox);
gtk_widget_show(vbox);
}

Просмотреть файл

@ -0,0 +1,32 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsMotifMenu_h_
#define _nsMotifMenu_h_
#include "nscore.h"
typedef void (*MenuCallbackProc)(
PRUint32
);
void CreateViewerMenus(nsIWidget *aParent, gpointer data);
#endif // _nsMotifMenu_h_

Просмотреть файл

@ -0,0 +1,44 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = viewer_motif_s
CPPSRCS = \
nsMotifMain.cpp \
nsMotifMenu.cpp \
$(NULL)
MKSHLIB =
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir)/../..
ifndef MOZ_MONOLITHIC_TOOLKIT
CXXFLAGS += $(MOZ_MOTIF_CFLAGS)
else
CXXFLAGS += $(TK_CFLAGS)
endif

Просмотреть файл

@ -0,0 +1,134 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsViewerApp.h"
#include "nsBrowserWindow.h"
#include "nsMotifMenu.h"
#include "nsIImageManager.h"
#include "nsIUnixToolkitService.h"
#include "nsIComponentManager.h"
static NS_DEFINE_CID(kCUnixToolkitServiceCID, NS_UNIX_TOOLKIT_SERVICE_CID);
static nsNativeViewerApp* gTheApp;
nsNativeViewerApp::nsNativeViewerApp()
{
}
nsNativeViewerApp::~nsNativeViewerApp()
{
}
int
nsNativeViewerApp::Run()
{
OpenWindow();
mAppShell->Run();
return 0;
}
//----------------------------------------------------------------------
nsNativeBrowserWindow::nsNativeBrowserWindow()
{
}
nsNativeBrowserWindow::~nsNativeBrowserWindow()
{
}
nsresult
nsNativeBrowserWindow::InitNativeWindow()
{
// override to do something special with platform native windows
return NS_OK;
}
static void MenuProc(PRUint32 aID)
{
// return nsBrowserWindow::DispatchMenuItem(aID);
return;
}
nsresult
nsNativeBrowserWindow::CreateMenuBar(PRInt32 aWidth)
{
CreateViewerMenus(XtParent((Widget)mWindow->GetNativeData(NS_NATIVE_WIDGET)), MenuProc);
return NS_OK;
}
nsEventStatus
nsNativeBrowserWindow::DispatchMenuItem(PRInt32 aID)
{
// Dispatch motif-only menu code goes here
// Dispatch xp menu items
// return nsBrowserWindow::DispatchMenuItem(aID);
return nsEventStatus_eIgnore;
}
//----------------------------------------------------------------------
int main(int argc, char **argv)
{
// Hack to get il_ss set so it doesn't fail in xpcompat.c
nsIImageManager *manager;
NS_NewImageManager(&manager);
gTheApp = new nsNativeViewerApp();
//////////////////////////////////////////////////////////////////////
//
// Toolkit Service setup
//
// Note: This must happend before NS_SetupRegistry() is called so
// that the toolkit specific xpcom components can be registered
// as needed.
//
//////////////////////////////////////////////////////////////////////
nsIUnixToolkitService * unixToolkitService = nsnull;
nsresult rv =
nsComponentManager::CreateInstance(kCUnixToolkitServiceCID,
nsnull,
nsIUnixToolkitService::GetIID(),
(void **) &unixToolkitService);
NS_ASSERTION(NS_SUCCEEDED(rv),"Cannot obtain unix toolkit service.");
if (NS_SUCCEEDED(rv) && (nsnull != unixToolkitService))
{
// Force the toolkit into "motif" mode regardless of MOZ_TOOLKIT
unixToolkitService->SetToolkitName("motif");
NS_RELEASE(unixToolkitService);
}
//////////////////////////////////////////////////////////////////////
// End toolkit service setup
//////////////////////////////////////////////////////////////////////
gTheApp->Initialize(argc, argv);
gTheApp->Run();
return 0;
}

Просмотреть файл

@ -0,0 +1,211 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <Xm/CascadeBG.h>
#include <Xm/PushBG.h>
#include <Xm/SeparatoG.h>
#include <Xm/RowColumn.h>
#include "resources.h"
#include "nsMotifMenu.h"
#include "nsError.h" // For NS_ERROR_OUT_OF_MEMORY.
#include "stdio.h"
//==============================================================
typedef struct _callBackInfo {
MenuCallbackProc mCallback;
PRUint32 mId;
} MenuCallbackStruct;
//==============================================================
void nsXtWidget_Menu_Callback(Widget w, XtPointer p, XtPointer call_data)
{
MenuCallbackStruct * cbs = (MenuCallbackStruct *)p;
if (cbs != NULL) {
if (cbs->mCallback != NULL) {
(*cbs->mCallback)(cbs->mId);
}
}
}
//-----------------------------------------------------
Widget CreatePulldownMenu(Widget aParent,
char * aMenuTitle,
char aMenuMnemonic)
{
Widget pullDown;
Widget casBtn;
XmString str;
pullDown = XmCreatePulldownMenu(aParent, "_pulldown", NULL, 0);
str = XmStringCreateLocalized(aMenuTitle);
casBtn = XtVaCreateManagedWidget(aMenuTitle,
xmCascadeButtonGadgetClass, aParent,
XmNsubMenuId, pullDown,
XmNlabelString, str,
XmNmnemonic, aMenuMnemonic,
NULL);
XmStringFree(str);
return pullDown;
}
//-----------------------------------------------------
Widget CreateMenuItem(Widget aParent,
char * aTitle,
long aID,
MenuCallbackProc aCallback)
{
Widget widget = XtVaCreateManagedWidget(aTitle, xmPushButtonGadgetClass,
aParent,
NULL);
MenuCallbackStruct * cbs = new MenuCallbackStruct();
if (cbs) {
cbs->mCallback = aCallback;
cbs->mId = aID;
}
else cbs = (MenuCallbackStruct *)NS_ERROR_OUT_OF_MEMORY;
XtAddCallback(widget, XmNactivateCallback, nsXtWidget_Menu_Callback, cbs);
return widget;
}
//-----------------------------------------------------
Widget CreateSeparator(Widget aParent)
{
Widget widget = XtVaCreateManagedWidget("__sep", xmSeparatorGadgetClass,
aParent,
NULL);
return widget;
}
typedef struct _menuBtns {
char * title;
char * mneu;
long command;
} MenuBtns;
//-----------------------------------------------------
void AddMenuItems(Widget aParent,
MenuBtns * aBtns,
MenuCallbackProc aCallback)
{
int i = 0;
while (aBtns[i].title != NULL) {
if (!strcmp(aBtns[i].title, "separator")) {
CreateSeparator(aParent);
} else {
CreateMenuItem(aParent, aBtns[i].title, aBtns[i].command, aCallback);
}
i++;
}
}
//-----------------------------------------------------
void CreateViewerMenus(Widget aParent, MenuCallbackProc aCallback)
{
MenuBtns editBtns[] = {
{"Cut", "T", VIEWER_EDIT_CUT},
{"Copy", "C", VIEWER_EDIT_COPY},
{"Paste", "P", VIEWER_EDIT_PASTE},
{"separator", NULL, 0},
{"Select All", "A", VIEWER_EDIT_SELECTALL},
{"separator", NULL, 0},
{"Find in Page", "F", VIEWER_EDIT_FINDINPAGE},
{NULL, NULL, 0}
};
MenuBtns debugBtns[] = {
{"Visual Debugging", "V", VIEWER_VISUAL_DEBUGGING},
{"Reflow Test", "R", VIEWER_REFLOW_TEST},
{"separator", NULL, 0},
{"Dump Content", "C", VIEWER_DUMP_CONTENT},
{"Dump Frames", "F", VIEWER_DUMP_FRAMES},
{"Dump Views", "V", VIEWER_DUMP_VIEWS},
{"separator", NULL, 0},
{"Dump Style Sheets", "S", VIEWER_DUMP_STYLE_SHEETS},
{"Dump Style Contexts", "T", VIEWER_DUMP_STYLE_CONTEXTS},
{"separator", NULL, 0},
{"Show Content Size", "z", VIEWER_SHOW_CONTENT_SIZE},
{"Show Frame Size", "a", VIEWER_SHOW_FRAME_SIZE},
{"Show Style Size", "y", VIEWER_SHOW_STYLE_SIZE},
{"separator", NULL, 0},
{"Debug Save", "v", VIEWER_DEBUGSAVE},
{"Debug Toggle Selection", "q", VIEWER_TOGGLE_SELECTION},
{"separator", NULL, 0},
{"Debug Robot", "R", VIEWER_DEBUGROBOT},
{"separator", NULL, 0},
{"Show Content Quality", ".", VIEWER_SHOW_CONTENT_QUALITY},
{NULL, NULL, 0}
};
Widget menuBar;
Widget fileMenu;
Widget debugMenu;
Widget menu;
menuBar = XmCreateMenuBar(aParent, "menubar", NULL, 0);
fileMenu = CreatePulldownMenu(menuBar, "File", 'F');
CreateMenuItem(fileMenu, "New Window", VIEWER_WINDOW_OPEN, aCallback);
CreateMenuItem(fileMenu, "Open...", VIEWER_FILE_OPEN, aCallback);
menu = CreatePulldownMenu(fileMenu, "Samples", 'S');
CreateMenuItem(menu, "demo #0", VIEWER_DEMO0, aCallback);
CreateMenuItem(menu, "demo #1", VIEWER_DEMO1, aCallback);
CreateMenuItem(menu, "demo #2", VIEWER_DEMO2, aCallback);
CreateMenuItem(menu, "demo #3", VIEWER_DEMO3, aCallback);
CreateMenuItem(menu, "demo #4", VIEWER_DEMO4, aCallback);
CreateMenuItem(menu, "demo #5", VIEWER_DEMO5, aCallback);
CreateMenuItem(menu, "demo #6", VIEWER_DEMO6, aCallback);
CreateMenuItem(menu, "demo #7", VIEWER_DEMO7, aCallback);
CreateMenuItem(menu, "demo #8", VIEWER_DEMO8, aCallback);
CreateMenuItem(menu, "demo #9", VIEWER_DEMO9, aCallback);
CreateMenuItem(menu, "demo #10", VIEWER_DEMO10, aCallback);
CreateMenuItem(menu, "demo #11", VIEWER_DEMO11, aCallback);
CreateMenuItem(menu, "demo #12", VIEWER_DEMO12, aCallback);
CreateMenuItem(fileMenu, "Top 100 Sites", VIEWER_TOP100, aCallback);
menu = CreatePulldownMenu(fileMenu, "Print Preview", 'P');
CreateMenuItem(menu, "One Column", VIEWER_ONE_COLUMN, aCallback);
CreateMenuItem(menu, "Two Column", VIEWER_TWO_COLUMN, aCallback);
CreateMenuItem(menu, "Three Column", VIEWER_THREE_COLUMN, aCallback);
CreateMenuItem(fileMenu, "Exit", VIEWER_EXIT, aCallback);
menu = CreatePulldownMenu(menuBar, "Edit", 'E');
AddMenuItems(menu, editBtns, aCallback);
debugMenu = CreatePulldownMenu(menuBar, "Debug", 'D');
AddMenuItems(debugMenu, debugBtns, aCallback);
menu = CreatePulldownMenu(menuBar, "Tools", 'T');
CreateMenuItem(menu, "Java Script Console", JS_CONSOLE, aCallback);
CreateMenuItem(menu, "Editor Mode", EDITOR_MODE, aCallback);
XtManageChild(menuBar);
}

Просмотреть файл

@ -0,0 +1,33 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsMotifMenu_h_
#define _nsMotifMenu_h_
#include <Xm/Xm.h>
#include "nscore.h"
typedef void (*MenuCallbackProc)(
PRUint32
);
void CreateViewerMenus(Widget aParent, MenuCallbackProc aCallback);
#endif // _nsMotifMenu_h_

Просмотреть файл

@ -0,0 +1,46 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = viewer_qt_s
CPPSRCS = \
nsQtMain.cpp \
nsQtMenu.cpp \
moc_nsQtMenu.cpp \
$(NULL)
MKSHLIB =
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir)/../..
ifndef MOZ_MONOLITHIC_TOOLKIT
CXXFLAGS += $(MOZ_QT_CFLAGS)
else
CXXFLAGS += $(TK_CFLAGS)
endif

Просмотреть файл

@ -0,0 +1,138 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <qwidget.h>
#include "nsViewerApp.h"
#include "nsBrowserWindow.h"
#include "nsIImageManager.h"
#include "nsQtMenu.h"
#include <stdlib.h>
#include "plevent.h"
#include "nsIUnixToolkitService.h"
#include "nsIComponentManager.h"
static NS_DEFINE_CID(kCUnixToolkitServiceCID, NS_UNIX_TOOLKIT_SERVICE_CID);
static nsNativeViewerApp* gTheApp;
nsNativeViewerApp::nsNativeViewerApp()
{
}
nsNativeViewerApp::~nsNativeViewerApp()
{
}
int nsNativeViewerApp::Run()
{
OpenWindow();
mAppShell->Run();
return 0;
}
//----------------------------------------------------------------------
nsNativeBrowserWindow::nsNativeBrowserWindow()
{
}
nsNativeBrowserWindow::~nsNativeBrowserWindow()
{
}
nsresult nsNativeBrowserWindow::InitNativeWindow()
{
// override to do something special with platform native windows
return NS_OK;
}
static void MenuProc(PRUint32 aId)
{
// XXX our menus are horked: we can't support multiple windows!
nsBrowserWindow* bw = (nsBrowserWindow*)
nsBrowserWindow::gBrowsers.ElementAt(0);
bw->DispatchMenuItem(aId);
}
nsresult
nsNativeBrowserWindow::CreateMenuBar(PRInt32 aWidth)
{
CreateViewerMenus((QWidget*)mWindow->GetNativeData(NS_NATIVE_WIDGET),
this);
return NS_OK;
}
nsEventStatus
nsNativeBrowserWindow::DispatchMenuItem(PRInt32 aID)
{
// Dispatch motif-only menu code goes here
// Dispatch xp menu items
return nsBrowserWindow::DispatchMenuItem(aID);
}
//----------------------------------------------------------------------
int main(int argc, char **argv)
{
// Hack to get il_ss set so it doesn't fail in xpcompat.c
nsIImageManager *manager;
NS_NewImageManager(&manager);
gTheApp = new nsNativeViewerApp();
//////////////////////////////////////////////////////////////////////
//
// Toolkit Service setup
//
// Note: This must happend before NS_SetupRegistry() is called so
// that the toolkit specific xpcom components can be registered
// as needed.
//
//////////////////////////////////////////////////////////////////////
nsIUnixToolkitService * unixToolkitService = nsnull;
nsresult rv =
nsComponentManager::CreateInstance(kCUnixToolkitServiceCID,
nsnull,
nsIUnixToolkitService::GetIID(),
(void **) &unixToolkitService);
NS_ASSERTION(NS_SUCCEEDED(rv),"Cannot obtain unix toolkit service.");
if (NS_SUCCEEDED(rv) && (nsnull != unixToolkitService))
{
// Force the toolkit into "qt" mode regardless of MOZ_TOOLKIT
unixToolkitService->SetToolkitName("qt");
NS_RELEASE(unixToolkitService);
}
//////////////////////////////////////////////////////////////////////
// End toolkit service setup
//////////////////////////////////////////////////////////////////////
gTheApp->Initialize(argc, argv);
gTheApp->Run();
return 0;
}

Просмотреть файл

@ -0,0 +1,222 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <qwidget.h>
#include "nsBrowserWindow.h"
#include "nsQtMenu.h"
#include "resources.h"
#include "nscore.h"
#include "stdio.h"
nsMenuEventHandler::nsMenuEventHandler(nsBrowserWindow * window)
{
mWindow = window;
}
void nsMenuEventHandler::MenuItemActivated(int id)
{
mWindow->DispatchMenuItem(id);
}
void CreateViewerMenus(QWidget *aParent, void * data)
{
debug("CreateViewerMenus under (%p)", aParent);
nsBrowserWindow * window = (nsBrowserWindow *) data;
nsMenuEventHandler * eventHandler = new nsMenuEventHandler(window);
QMenuBar * menuBar = new QMenuBar(aParent);
QPopupMenu * file = new QPopupMenu(aParent);
QObject::connect(file,
SIGNAL(activated(int)),
eventHandler,
SLOT(MenuItemActivated(int)));
QPopupMenu * samples = new QPopupMenu(aParent);
QObject::connect(samples,
SIGNAL(activated(int)),
eventHandler,
SLOT(MenuItemActivated(int)));
QPopupMenu * xptests = new QPopupMenu(aParent);
QObject::connect(xptests,
SIGNAL(activated(int)),
eventHandler,
SLOT(MenuItemActivated(int)));
QPopupMenu * edit = new QPopupMenu(aParent);
QObject::connect(edit,
SIGNAL(activated(int)),
eventHandler,
SLOT(MenuItemActivated(int)));
QPopupMenu * debug = new QPopupMenu(aParent);
QObject::connect(debug,
SIGNAL(activated(int)),
eventHandler,
SLOT(MenuItemActivated(int)));
QPopupMenu * style = new QPopupMenu(aParent);
QObject::connect(style,
SIGNAL(activated(int)),
eventHandler,
SLOT(MenuItemActivated(int)));
QPopupMenu * tools = new QPopupMenu(aParent);
QObject::connect(tools,
SIGNAL(activated(int)),
eventHandler,
SLOT(MenuItemActivated(int)));
QPopupMenu * select = new QPopupMenu(aParent);
QObject::connect(select,
SIGNAL(activated(int)),
eventHandler,
SLOT(MenuItemActivated(int)));
QPopupMenu * compatibility = new QPopupMenu(aParent);
QObject::connect(compatibility,
SIGNAL(activated(int)),
eventHandler,
SLOT(MenuItemActivated(int)));
QPopupMenu * render = new QPopupMenu(aParent);
QObject::connect(render,
SIGNAL(activated(int)),
eventHandler,
SLOT(MenuItemActivated(int)));
InsertMenuItem(file, "New Window", eventHandler, VIEWER_WINDOW_OPEN);
InsertMenuItem(file, "Open", eventHandler, VIEWER_FILE_OPEN);
InsertMenuItem(file, "View Source", eventHandler, VIEW_SOURCE);
InsertMenuItem(samples, "demo #0", eventHandler, VIEWER_DEMO0);
InsertMenuItem(samples, "demo #1", eventHandler, VIEWER_DEMO1);
InsertMenuItem(samples, "demo #2", eventHandler, VIEWER_DEMO2);
InsertMenuItem(samples, "demo #3", eventHandler, VIEWER_DEMO3);
InsertMenuItem(samples, "demo #4", eventHandler, VIEWER_DEMO4);
InsertMenuItem(samples, "demo #5", eventHandler, VIEWER_DEMO5);
InsertMenuItem(samples, "demo #6", eventHandler, VIEWER_DEMO6);
InsertMenuItem(samples, "demo #7", eventHandler, VIEWER_DEMO7);
InsertMenuItem(samples, "demo #8", eventHandler, VIEWER_DEMO8);
InsertMenuItem(samples, "demo #9", eventHandler, VIEWER_DEMO9);
InsertMenuItem(samples, "demo #10", eventHandler, VIEWER_DEMO10);
InsertMenuItem(samples, "demo #11", eventHandler, VIEWER_DEMO11);
InsertMenuItem(samples, "demo #12", eventHandler, VIEWER_DEMO12);
InsertMenuItem(samples, "demo #13", eventHandler, VIEWER_DEMO13);
InsertMenuItem(samples, "demo #14", eventHandler, VIEWER_DEMO14);
InsertMenuItem(samples, "demo #15", eventHandler, VIEWER_DEMO15);
file->insertItem("Samples", samples);
InsertMenuItem(file, "Test Sites", eventHandler, VIEWER_TOP100);
InsertMenuItem(xptests, "Toolbar Test 1", eventHandler, VIEWER_XPTOOLKITTOOLBAR1);
InsertMenuItem(xptests, "Tree Test 1", eventHandler, VIEWER_XPTOOLKITTREE1);
InsertMenuItem(file, nsnull, nsnull, 0);
InsertMenuItem(file, "Print Preview", eventHandler, VIEWER_ONE_COLUMN);
InsertMenuItem(file, "Print", eventHandler, VIEWER_PRINT);
InsertMenuItem(file, "Print Setup", eventHandler, VIEWER_PRINT_SETUP);
InsertMenuItem(file, nsnull, nsnull, 0);
InsertMenuItem(file, "Exit", eventHandler, VIEWER_EXIT);
InsertMenuItem(edit, "Cut", eventHandler, VIEWER_EDIT_CUT);
InsertMenuItem(edit, "Copy", eventHandler, VIEWER_EDIT_COPY);
InsertMenuItem(edit, "Paste", eventHandler, VIEWER_EDIT_PASTE);
InsertMenuItem(file, nsnull, nsnull, 0);
InsertMenuItem(edit, "Select All", eventHandler, VIEWER_EDIT_SELECTALL);
InsertMenuItem(file, nsnull, nsnull, 0);
InsertMenuItem(edit, "Find in Page", eventHandler, VIEWER_EDIT_FINDINPAGE);
InsertMenuItem(debug, "Visual Debugging", eventHandler, VIEWER_VISUAL_DEBUGGING);
InsertMenuItem(debug, "Reflow Test", eventHandler, VIEWER_REFLOW_TEST);
InsertMenuItem(file, nsnull, nsnull, 0);
InsertMenuItem(debug, "Dump Content", eventHandler, VIEWER_DUMP_CONTENT);
InsertMenuItem(debug, "Dump Frames", eventHandler, VIEWER_DUMP_FRAMES);
InsertMenuItem(debug, "Dump Views", eventHandler, VIEWER_DUMP_VIEWS);
InsertMenuItem(file, nsnull, nsnull, 0);
InsertMenuItem(debug, "Dump Style Sheets", eventHandler, VIEWER_DUMP_STYLE_SHEETS);
InsertMenuItem(debug, "Dump Style Contexts", eventHandler, VIEWER_DUMP_STYLE_CONTEXTS);
InsertMenuItem(file, nsnull, nsnull, 0);
InsertMenuItem(debug, "Show Content Size", eventHandler, VIEWER_SHOW_CONTENT_SIZE);
InsertMenuItem(debug, "Show Frame Size", eventHandler, VIEWER_SHOW_FRAME_SIZE);
InsertMenuItem(debug, "Show Style Size", eventHandler, VIEWER_SHOW_STYLE_SIZE);
InsertMenuItem(file, nsnull, nsnull, 0);
InsertMenuItem(debug, "Debug Save", eventHandler, VIEWER_DEBUGSAVE);
InsertMenuItem(debug, "Debug Output Text", eventHandler, VIEWER_DISPLAYTEXT);
InsertMenuItem(debug, "Debug Output HTML", eventHandler, VIEWER_DISPLAYHTML);
InsertMenuItem(debug, "Debug Toggle Selection", eventHandler, VIEWER_TOGGLE_SELECTION);
InsertMenuItem(file, nsnull, nsnull, 0);
InsertMenuItem(debug, "Debug Robot", eventHandler, VIEWER_DEBUGROBOT);
InsertMenuItem(file, nsnull, nsnull, 0);
InsertMenuItem(debug, "Show Content Quality", eventHandler, VIEWER_SHOW_CONTENT_QUALITY);
InsertMenuItem(file, nsnull, nsnull, 0);
debug->insertItem("Style", style);
InsertMenuItem(select, "List Available Sheets", eventHandler, VIEWER_SELECT_STYLE_LIST);
InsertMenuItem(file, nsnull, nsnull, 0);
InsertMenuItem(select, "Select Default", eventHandler, VIEWER_SELECT_STYLE_DEFAULT);
InsertMenuItem(file, nsnull, nsnull, 0);
InsertMenuItem(select, "Select Alternative 1", eventHandler, VIEWER_SELECT_STYLE_ONE);
InsertMenuItem(select, "Select Alternative 2", eventHandler, VIEWER_SELECT_STYLE_TWO);
InsertMenuItem(select, "Select Alternative 3", eventHandler, VIEWER_SELECT_STYLE_THREE);
InsertMenuItem(select, "Select Alternative 4", eventHandler, VIEWER_SELECT_STYLE_FOUR);
style->insertItem("Select Style Sheet", select);
InsertMenuItem(compatibility, "Nav Quirks", eventHandler, VIEWER_NAV_QUIRKS_MODE);
InsertMenuItem(compatibility, "Standard", eventHandler, VIEWER_STANDARD_MODE);
style->insertItem("Compatibility Mode", compatibility);
InsertMenuItem(render, "Native", eventHandler, VIEWER_NATIVE_WIDGET_MODE);
InsertMenuItem(render, "Gfx", eventHandler, VIEWER_GFX_WIDGET_MODE);
style->insertItem("Widget Render Mode", render);
InsertMenuItem(tools, "JavaScript Console", eventHandler, JS_CONSOLE);
InsertMenuItem(tools, "Editor Mode", eventHandler, EDITOR_MODE);
menuBar->insertItem("&File", file);
menuBar->insertItem("&Edit", edit);
menuBar->insertItem("&Debug", debug);
menuBar->insertItem("&Tools", tools);
menuBar->show();
}
void InsertMenuItem(QPopupMenu * popup, const char * string, QObject * receiver, int id)
{
if (popup)
{
if (string)
{
popup->insertItem(string, id);
//popup->connectItem(id, receiver, SLOT(MenuItemActivated(int)));
#if 0
popup->insertItem(string,
receiver,
SLOT(MenuItemActivated(int)),
0,
id);
#endif
}
else
{
popup->insertSeparator();
}
}
}

Просмотреть файл

@ -0,0 +1,46 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsMotifMenu_h_
#define _nsMotifMenu_h_
#include "nscore.h"
#include <qpopupmenu.h>
#include <qmenubar.h>
class nsBrowserWindow;
class nsMenuEventHandler : public QObject
{
Q_OBJECT
public:
nsMenuEventHandler(nsBrowserWindow * window);
public slots:
void MenuItemActivated(int id);
private:
nsBrowserWindow * mWindow;
};
void CreateViewerMenus(QWidget *aParent, void * data);
void InsertMenuItem(QPopupMenu * popup, const char * string, QObject * receiver, int id);
#endif // _nsMotifMenu_h_

Просмотреть файл

@ -0,0 +1,43 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = viewer_xlib_s
CPPSRCS = \
nsXlibMain.cpp \
$(NULL)
MKSHLIB =
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir)/../..
ifndef MOZ_MONOLITHIC_TOOLKIT
CXXFLAGS += $(MOZ_XLIB_CFLAGS)
else
CXXFLAGS += $(TK_CFLAGS)
endif

Просмотреть файл

@ -0,0 +1,110 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsBrowserWindow.h"
#include "nsViewerApp.h"
#include "nsIUnixToolkitService.h"
#include "nsIComponentManager.h"
static NS_DEFINE_CID(kCUnixToolkitServiceCID, NS_UNIX_TOOLKIT_SERVICE_CID);
nsNativeViewerApp::nsNativeViewerApp()
{
}
nsNativeViewerApp::~nsNativeViewerApp()
{
}
int
nsNativeViewerApp::Run()
{
OpenWindow();
mAppShell->Run();
return 0;
}
nsNativeBrowserWindow::nsNativeBrowserWindow()
{
}
nsNativeBrowserWindow::~nsNativeBrowserWindow()
{
}
nsresult
nsNativeBrowserWindow::InitNativeWindow()
{
return NS_OK;
}
nsresult
nsNativeBrowserWindow::CreateMenuBar(PRInt32 aWidth)
{
return NS_OK;
}
nsEventStatus
nsNativeBrowserWindow::DispatchMenuItem(PRInt32 aID)
{
return nsEventStatus_eIgnore;
}
int main (int argc, char **argv)
{
nsViewerApp *app = new nsNativeViewerApp();
NS_ADDREF(app);
//////////////////////////////////////////////////////////////////////
//
// Toolkit Service setup
//
// Note: This must happend before NS_SetupRegistry() is called so
// that the toolkit specific xpcom components can be registered
// as needed.
//
//////////////////////////////////////////////////////////////////////
nsIUnixToolkitService * unixToolkitService = nsnull;
nsresult rv =
nsComponentManager::CreateInstance(kCUnixToolkitServiceCID,
nsnull,
nsIUnixToolkitService::GetIID(),
(void **) &unixToolkitService);
NS_ASSERTION(NS_SUCCEEDED(rv),"Cannot obtain unix toolkit service.");
if (NS_SUCCEEDED(rv) && (nsnull != unixToolkitService))
{
// Force the toolkit into "xlib" mode
unixToolkitService->SetToolkitName("xlib");
NS_RELEASE(unixToolkitService);
}
//////////////////////////////////////////////////////////////////////
// End toolkit service setup
//////////////////////////////////////////////////////////////////////
app->Initialize(argc, argv);
app->Run();
NS_RELEASE(app);
return 0;
}