From 566cf2aa54a137fdba448c0121ba3079e37bdb5d Mon Sep 17 00:00:00 2001 From: "seawood%netscape.com" Date: Sat, 13 Oct 2001 02:59:09 +0000 Subject: [PATCH] Removing motif port from the tree. Bug #89330 r=bryner sr=pavlov --- gfx/src/motif/.cvsignore | 1 - gfx/src/motif/Makefile.in | 59 - gfx/src/motif/nsDeviceContextMotif.cpp | 653 ------- gfx/src/motif/nsDeviceContextMotif.h | 152 -- gfx/src/motif/nsFontMetricsMotif.cpp | 411 ----- gfx/src/motif/nsFontMetricsMotif.h | 105 -- gfx/src/motif/nsGfxFactoryMotif.cpp | 178 -- gfx/src/motif/nsImageMotif.cpp | 456 ----- gfx/src/motif/nsImageMotif.h | 190 -- gfx/src/motif/nsRegionMotif.cpp | 265 --- gfx/src/motif/nsRegionMotif.h | 88 - gfx/src/motif/nsRenderingContextMotif.cpp | 1505 ---------------- gfx/src/motif/nsRenderingContextMotif.h | 218 --- webshell/embed/xlib/motif/.cvsignore | 2 - webshell/embed/xlib/motif/EmbedMozilla.c | 216 --- webshell/embed/xlib/motif/EmbedMozilla.h | 63 - webshell/embed/xlib/motif/EmbedMozillaP.h | 83 - webshell/embed/xlib/motif/Makefile.in | 49 - .../embed/xlib/motif/nsEmbedXlibIntoMotif.cpp | 271 --- webshell/embed/xlib/motif/nsSetupRegistry.cpp | 39 - webshell/embed/xlib/xt/.cvsignore | 1 - webshell/embed/xlib/xt/EmbedMozilla.c | 214 --- webshell/embed/xlib/xt/EmbedMozilla.h | 47 - webshell/embed/xlib/xt/EmbedMozillaP.h | 65 - webshell/embed/xlib/xt/Makefile.in | 50 - webshell/embed/xlib/xt/nsEmbedXlibIntoXt.cpp | 383 ---- webshell/embed/xlib/xt/nsSetupRegistry.cpp | 23 - webshell/tests/viewer/unix/motif/.cvsignore | 1 - webshell/tests/viewer/unix/motif/Makefile.in | 51 - .../tests/viewer/unix/motif/nsMotifMain.cpp | 126 -- .../tests/viewer/unix/motif/nsMotifMenu.cpp | 230 --- .../tests/viewer/unix/motif/nsMotifMenu.h | 52 - widget/src/motif/.cvsignore | 1 - widget/src/motif/Makefile.in | 78 - widget/src/motif/app_context/.cvsignore | 1 - widget/src/motif/app_context/Makefile.in | 48 - .../app_context/nsIMotifAppContextService.h | 72 - .../app_context/nsMotifAppContextService.cpp | 53 - .../app_context/nsMotifAppContextService.h | 39 - .../nsMotifAppContextServiceFactory.cpp | 162 -- widget/src/motif/nsAppShell.cpp | 336 ---- widget/src/motif/nsAppShell.h | 83 - widget/src/motif/nsBidiKeyboard.cpp | 51 - widget/src/motif/nsBidiKeyboard.h | 39 - widget/src/motif/nsButton.cpp | 185 -- widget/src/motif/nsButton.h | 84 - widget/src/motif/nsCheckButton.cpp | 268 --- widget/src/motif/nsCheckButton.h | 99 - widget/src/motif/nsLabel.cpp | 246 --- widget/src/motif/nsLabel.h | 93 - widget/src/motif/nsLookAndFeel.cpp | 214 --- widget/src/motif/nsLookAndFeel.h | 69 - widget/src/motif/nsMenu.cpp | 538 ------ widget/src/motif/nsMenu.h | 132 -- widget/src/motif/nsMenuBar.cpp | 324 ---- widget/src/motif/nsMenuBar.h | 102 -- widget/src/motif/nsMenuItem.cpp | 408 ----- widget/src/motif/nsMenuItem.h | 128 -- widget/src/motif/nsPopUpMenu.cpp | 180 -- widget/src/motif/nsPopUpMenu.h | 87 - widget/src/motif/nsScrollbar.cpp | 471 ----- widget/src/motif/nsScrollbar.h | 105 -- widget/src/motif/nsTextHelper.cpp | 226 --- widget/src/motif/nsTextHelper.h | 74 - widget/src/motif/nsTextWidget.cpp | 191 -- widget/src/motif/nsTextWidget.h | 89 - widget/src/motif/nsToolkit.cpp | 106 -- widget/src/motif/nsToolkit.h | 69 - widget/src/motif/nsWidgetFactory.cpp | 274 --- widget/src/motif/nsWindow.cpp | 1603 ----------------- widget/src/motif/nsWindow.h | 240 --- widget/src/motif/nsXtEventHandler.cpp | 513 ------ widget/src/motif/nsXtEventHandler.h | 78 - widget/src/motif/nsXtManageWidget.c | 180 -- widget/src/motif/nsXtManageWidget.h | 52 - widget/src/motif/nsXtManageWidgetP.h | 80 - widget/timer/src/unix/motif/.cvsignore | 1 - widget/timer/src/unix/motif/Makefile.in | 52 - widget/timer/src/unix/motif/nsTimerMotif.cpp | 208 --- widget/timer/src/unix/motif/nsTimerMotif.h | 99 - .../src/unix/motif/nsTimerMotifFactory.cpp | 188 -- 81 files changed, 15266 deletions(-) delete mode 100644 gfx/src/motif/.cvsignore delete mode 100644 gfx/src/motif/Makefile.in delete mode 100644 gfx/src/motif/nsDeviceContextMotif.cpp delete mode 100644 gfx/src/motif/nsDeviceContextMotif.h delete mode 100644 gfx/src/motif/nsFontMetricsMotif.cpp delete mode 100644 gfx/src/motif/nsFontMetricsMotif.h delete mode 100644 gfx/src/motif/nsGfxFactoryMotif.cpp delete mode 100644 gfx/src/motif/nsImageMotif.cpp delete mode 100644 gfx/src/motif/nsImageMotif.h delete mode 100644 gfx/src/motif/nsRegionMotif.cpp delete mode 100644 gfx/src/motif/nsRegionMotif.h delete mode 100644 gfx/src/motif/nsRenderingContextMotif.cpp delete mode 100644 gfx/src/motif/nsRenderingContextMotif.h delete mode 100644 webshell/embed/xlib/motif/.cvsignore delete mode 100644 webshell/embed/xlib/motif/EmbedMozilla.c delete mode 100644 webshell/embed/xlib/motif/EmbedMozilla.h delete mode 100644 webshell/embed/xlib/motif/EmbedMozillaP.h delete mode 100644 webshell/embed/xlib/motif/Makefile.in delete mode 100644 webshell/embed/xlib/motif/nsEmbedXlibIntoMotif.cpp delete mode 100644 webshell/embed/xlib/motif/nsSetupRegistry.cpp delete mode 100644 webshell/embed/xlib/xt/.cvsignore delete mode 100644 webshell/embed/xlib/xt/EmbedMozilla.c delete mode 100644 webshell/embed/xlib/xt/EmbedMozilla.h delete mode 100644 webshell/embed/xlib/xt/EmbedMozillaP.h delete mode 100644 webshell/embed/xlib/xt/Makefile.in delete mode 100644 webshell/embed/xlib/xt/nsEmbedXlibIntoXt.cpp delete mode 100644 webshell/embed/xlib/xt/nsSetupRegistry.cpp delete mode 100644 webshell/tests/viewer/unix/motif/.cvsignore delete mode 100644 webshell/tests/viewer/unix/motif/Makefile.in delete mode 100644 webshell/tests/viewer/unix/motif/nsMotifMain.cpp delete mode 100644 webshell/tests/viewer/unix/motif/nsMotifMenu.cpp delete mode 100644 webshell/tests/viewer/unix/motif/nsMotifMenu.h delete mode 100644 widget/src/motif/.cvsignore delete mode 100644 widget/src/motif/Makefile.in delete mode 100644 widget/src/motif/app_context/.cvsignore delete mode 100644 widget/src/motif/app_context/Makefile.in delete mode 100644 widget/src/motif/app_context/nsIMotifAppContextService.h delete mode 100644 widget/src/motif/app_context/nsMotifAppContextService.cpp delete mode 100644 widget/src/motif/app_context/nsMotifAppContextService.h delete mode 100644 widget/src/motif/app_context/nsMotifAppContextServiceFactory.cpp delete mode 100644 widget/src/motif/nsAppShell.cpp delete mode 100644 widget/src/motif/nsAppShell.h delete mode 100644 widget/src/motif/nsBidiKeyboard.cpp delete mode 100644 widget/src/motif/nsBidiKeyboard.h delete mode 100644 widget/src/motif/nsButton.cpp delete mode 100644 widget/src/motif/nsButton.h delete mode 100644 widget/src/motif/nsCheckButton.cpp delete mode 100644 widget/src/motif/nsCheckButton.h delete mode 100644 widget/src/motif/nsLabel.cpp delete mode 100644 widget/src/motif/nsLabel.h delete mode 100644 widget/src/motif/nsLookAndFeel.cpp delete mode 100644 widget/src/motif/nsLookAndFeel.h delete mode 100644 widget/src/motif/nsMenu.cpp delete mode 100644 widget/src/motif/nsMenu.h delete mode 100644 widget/src/motif/nsMenuBar.cpp delete mode 100644 widget/src/motif/nsMenuBar.h delete mode 100644 widget/src/motif/nsMenuItem.cpp delete mode 100644 widget/src/motif/nsMenuItem.h delete mode 100644 widget/src/motif/nsPopUpMenu.cpp delete mode 100644 widget/src/motif/nsPopUpMenu.h delete mode 100644 widget/src/motif/nsScrollbar.cpp delete mode 100644 widget/src/motif/nsScrollbar.h delete mode 100644 widget/src/motif/nsTextHelper.cpp delete mode 100644 widget/src/motif/nsTextHelper.h delete mode 100644 widget/src/motif/nsTextWidget.cpp delete mode 100644 widget/src/motif/nsTextWidget.h delete mode 100644 widget/src/motif/nsToolkit.cpp delete mode 100644 widget/src/motif/nsToolkit.h delete mode 100644 widget/src/motif/nsWidgetFactory.cpp delete mode 100644 widget/src/motif/nsWindow.cpp delete mode 100644 widget/src/motif/nsWindow.h delete mode 100644 widget/src/motif/nsXtEventHandler.cpp delete mode 100644 widget/src/motif/nsXtEventHandler.h delete mode 100644 widget/src/motif/nsXtManageWidget.c delete mode 100644 widget/src/motif/nsXtManageWidget.h delete mode 100644 widget/src/motif/nsXtManageWidgetP.h delete mode 100644 widget/timer/src/unix/motif/.cvsignore delete mode 100644 widget/timer/src/unix/motif/Makefile.in delete mode 100644 widget/timer/src/unix/motif/nsTimerMotif.cpp delete mode 100644 widget/timer/src/unix/motif/nsTimerMotif.h delete mode 100644 widget/timer/src/unix/motif/nsTimerMotifFactory.cpp diff --git a/gfx/src/motif/.cvsignore b/gfx/src/motif/.cvsignore deleted file mode 100644 index f3c7a7c5da68..000000000000 --- a/gfx/src/motif/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile diff --git a/gfx/src/motif/Makefile.in b/gfx/src/motif/Makefile.in deleted file mode 100644 index 7325da29b6b2..000000000000 --- a/gfx/src/motif/Makefile.in +++ /dev/null @@ -1,59 +0,0 @@ -# -# The contents of this file are subject to the Netscape Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/NPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# - -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = gfx -LIBRARY_NAME = gfx_motif -EXPORT_LIBRARY = 1 - - -CPPSRCS = \ - nsDeviceContextMotif.cpp \ - nsFontMetricsMotif.cpp \ - nsGfxFactoryMotif.cpp \ - nsRenderingContextMotif.cpp \ - nsRegionMotif.cpp \ - nsImageMotif.cpp \ - $(NULL) - -include $(topsrcdir)/config/rules.mk - -ifndef MOZ_MONOLITHIC_TOOLKIT -EXTRA_DSO_LDOPTS += -L$(DIST)/bin -lxlibrgb $(MOZ_MOTIF_LDFLAGS) -CXXFLAGS += $(MOZ_MOTIF_CFLAGS) -else -EXTRA_DSO_LDOPTS += $(TK_LIBS) -CXXFLAGS += $(TK_CFLAGS) -endif - -DEFINES += -D_IMPL_NS_GFXNONXP - -INCLUDES += \ - -I$(srcdir)/. \ - -I$(srcdir)/.. \ - $(NULL) - diff --git a/gfx/src/motif/nsDeviceContextMotif.cpp b/gfx/src/motif/nsDeviceContextMotif.cpp deleted file mode 100644 index 8dd26edbc8f3..000000000000 --- a/gfx/src/motif/nsDeviceContextMotif.cpp +++ /dev/null @@ -1,653 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsDeviceContextMotif.h" -#include "nsRenderingContextMotif.h" -#include "nsGfxCIID.h" - -#include "math.h" -#include "nspr.h" -#include "il_util.h" -#include "nsReadableUtils.h" - - -#define NS_TO_X_COMPONENT(a) ((a << 8) | (a)) - -#define NS_TO_X_RED(a) (((NS_GET_R(a) >> (8 - mRedBits)) << mRedOffset) & mRedMask) -#define NS_TO_X_GREEN(a) (((NS_GET_G(a) >> (8 - mGreenBits)) << mGreenOffset) & mGreenMask) -#define NS_TO_X_BLUE(a) (((NS_GET_B(a) >> (8 - mBlueBits)) << mBlueOffset) & mBlueMask) - -#define NS_TO_X(a) (NS_TO_X_RED(a) | NS_TO_X_GREEN(a) | NS_TO_X_BLUE(a)) - -#define COLOR_CUBE_SIZE 216 - -typedef struct { - int red, green, blue; -} nsReservedColor; - -#define RESERVED_SIZE 0 - -nsReservedColor sReservedColors[] = { - { 0, 0, 0 }, - { 128, 0, 0 }, - { 0, 128, 0 }, - { 128, 128, 0 }, - { 0, 0, 128 }, - {128, 0, 128 }, - { 0, 128, 128 }, - { 192, 192, 192 }, - { 192, 220, 192 }, - { 166, 202, 240 } }; - - -nsDeviceContextMotif :: nsDeviceContextMotif() -{ - NS_INIT_REFCNT(); - mSurface = nsnull; - mTwipsToPixels = 1.0; - mPixelsToTwips = 1.0; - mVisual = nsnull; - mRedMask = 0; - mGreenMask = 0; - mBlueMask = 0; - mRedBits = 0; - mGreenBits = 0; - mBlueBits = 0; - mRedOffset = 0; - mGreenOffset = 0; - mBlueOffset = 0; - mDepth = 0 ; - mColormap = 0 ; - mPaletteInfo.isPaletteDevice = PR_FALSE; - mPaletteInfo.sizePalette = 0; - mPaletteInfo.numReserved = 0; - mPaletteInfo.palette = NULL; - mColorsAllocated = PR_FALSE; - mIndex = 0; - mDeviceColors = NULL; - mDisplay = 0; -} - -nsDeviceContextMotif :: ~nsDeviceContextMotif() -{ - if (mSurface) { - delete mSurface; - mSurface = nsnull; - } - - if (mIndex) - delete mIndex; - - if (mDeviceColors) - delete mDeviceColors; -} - -NS_IMPL_ISUPPORTS1(nsDeviceContextMotif, nsIDeviceContext) - -NS_IMETHODIMP nsDeviceContextMotif :: Init(nsNativeWidget aNativeWidget) -{ - for (PRInt32 cnt = 0; cnt < 256; cnt++) - mGammaTable[cnt] = cnt; - - // XXX We really need to have Display passed to us since it could be specified - // not from the environment, which is the one we use here. - - mWidget = aNativeWidget; - - if (nsnull != mWidget) - { - Display *display = XtDisplay((Widget)mWidget); - Screen *screen = DefaultScreen(display); - mTwipsToPixels = (((float)::XDisplayWidth(display, screen)) / - ((float)::XDisplayWidthMM(display ,screen )) * 25.4) / - (float)NSIntPointsToTwips(72); - - mPixelsToTwips = 1.0f / mTwipsToPixels; - } - - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextMotif :: CreateRenderingContext(nsIRenderingContext *&aContext) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP nsDeviceContextMotif :: SupportsNativeWidgets(PRBool &aSupportsWidgets) -{ - //XXX it is very critical that this not lie!! MMP - aSupportsWidgets = PR_TRUE; - - return NS_OK; -} - - -NS_IMETHODIMP nsDeviceContextMotif :: GetScrollBarDimensions(float &aWidth, float &aHeight) const -{ - // XXX Should we push this to widget library - aWidth = 240.0; - aHeight = 240.0; - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextMotif :: GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface) -{ - aContext.CreateDrawingSurface(nsnull, 0, aSurface); - return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK; -} - -Display *nsDeviceContextMotif::GetDisplay() -{ - if (mDisplay) - return(mDisplay); - - if (mSurface) { - mDisplay = mSurface->display; - } - else { - mDisplay = XtDisplay((Widget)mWidget); - } - - return(mDisplay); -} - -// Try to find existing color then allocate color if one can not be found and -// aCanAlloc is PR_TRUE. If all else fails try and find the closest match to -// an existing color. - -uint8 nsDeviceContextMotif :: AllocColor(uint8 aRed, uint8 aGreen, uint8 aBlue, PRBool aCanAlloc) -{ - Display* display = GetDisplay(); - - if (NULL == mDeviceColors) { - mDeviceColors = new XColor[256]; - for (int i = 0; i < 256; i++) { - mDeviceColors[i].pixel = i; - } - } - - XQueryColors(display, mColormap, mDeviceColors, 256); - - // Look for perfect match - for (int i = 0; i < 256; i++) { - if (((mDeviceColors[i].red >> 8)== aRed) && - ((mDeviceColors[i].green >> 8) == aGreen) && - ((mDeviceColors[i].blue >> 8) == aBlue)) { - return(mDeviceColors[i].pixel); - } - } - - // Try and allocate the color - XColor color; - color.red = aRed << 8; - color.green = aGreen << 8; - color.blue = aBlue << 8; - color.pixel = 0; - color.flags = DoRed | DoGreen | DoBlue; - color.pad = 0; - - if (::XAllocColor(display, mColormap, &color)) { - return(color.pixel); - } - - // No color found so look for the closest match - - uint8 closest = 0; - uint8 r, g, b; - unsigned long distance = ~0; - unsigned long d; - int dr, dg, db; - for (int colorindex = 0; colorindex < 256; colorindex++) { - r = mDeviceColors[colorindex].red >> 8; - g = mDeviceColors[colorindex].green >> 8; - b = mDeviceColors[colorindex].blue >> 8; - dr = r - aRed; - dg = g - aGreen; - db = b - aBlue; - if (dr < 0) dr = -dr; - if (dg < 0) dg = -dg; - if (db < 0) db = -db; - d = (dr << 1) + (dg << 2) + db; - if (d < distance) { - distance = d; - closest = mDeviceColors[colorindex].pixel; - } - } - - return(closest); -} - - -NS_IMETHODIMP nsDeviceContextMotif :: ConvertPixel(nscolor aColor, PRUint32 & aPixel) -{ - PRUint32 newcolor = 0; - - InstallColormap(); - - /* - For now, we assume anything in 12 planes or more is a TrueColor visual. - If it is not (like older IRIS GL graphics boards, we'll look stupid for now. - */ - - switch (mDepth) { - - case 8: { - newcolor = AllocColor(NS_GET_R(aColor), NS_GET_G(aColor), NS_GET_B(aColor), PR_TRUE); - - } - break; - - default: { - newcolor = (PRUint32)NS_TO_X(aColor); - } - break; - - } - - aPixel = newcolor; - return NS_OK; -} - - -void nsDeviceContextMotif :: InstallColormap() -{ - - /* - Unfortunately, we don't have control of the visual created for this display. - That should be managed at an application level, since the gfx only cares that all - values be passed in as 32 bit RGBA quantites. - - This means we have to write lots and lots of code to support the fact that any - number of visuals may be the one associated with this device context. - */ - - if (mSurface) { - InstallColormap((Display*)mSurface->display, (Drawable)mSurface->drawable); - } - else { - // No surface so we have to create a window just to get a drawable so we - // can install the colormap. - Window w; - Display * d = XtDisplay((Widget)mWidget); - w = ::XCreateSimpleWindow(d, - RootWindow(d, DefaultScreen(d)), - 0, 0, 1, 1, 0, - BlackPixel(d, DefaultScreen(d)), - WhitePixel(d, DefaultScreen(d))); - InstallColormap(d, w); - ::XDestroyWindow(d, w); - } -} - - -void nsDeviceContextMotif :: InstallColormap(Display* aDisplay, Drawable aDrawable) -{ - - XWindowAttributes wa; - - - /* Already installed? */ - if (0 != mColormap) - return; - - // Find the depth of this visual - ::XGetWindowAttributes(aDisplay, - aDrawable, - &wa); - - mDepth = wa.depth; - - // Check to see if the colormap is writable - mVisual = wa.visual; - - if (mVisual->c_class != TrueColor) - mPaletteInfo.isPaletteDevice = PR_TRUE; - else - { - mPaletteInfo.isPaletteDevice = PR_FALSE; - if (mDepth == 8) { - mPaletteInfo.numReserved = RESERVED_SIZE; - mPaletteInfo.sizePalette = (PRUint32) pow(2, mDepth); - } - } - - if (mVisual->c_class == GrayScale || mVisual->c_class == PseudoColor || mVisual->c_class == DirectColor) - { - mWriteable = PR_TRUE; - } - else // We have StaticGray, StaticColor or TrueColor - mWriteable = PR_FALSE; - - mNumCells = (PRUint32) pow(2, mDepth); - mPaletteInfo.sizePalette = mNumCells; - - mColormap = wa.colormap; - - // if the colormap is writeable ..... - if (mWriteable) { - - // XXX We should check the XExtensions to see if this hardware supports multiple - // hardware colormaps. If so, change this colormap to be a RGB ramp. - if (mDepth == 8) { - AllocColors(); - } - } - - // Compute rgb masks and number of bits for each - mRedMask = mVisual->red_mask; - mGreenMask = mVisual->green_mask; - mBlueMask = mVisual->blue_mask; - - PRUint32 i = mRedMask; - - while (i) { - - if ((i & 0x1) != 0) { - mRedBits++; - } else { - mRedOffset++; - } - - i = i >> 1; - - } - - i = mGreenMask; - - while (i) { - - if ((i & 0x1) != 0) - mGreenBits++; - else - mGreenOffset++; - - i = i >> 1; - - } - - i = mBlueMask; - - while (i) { - - if ((i & 0x1) != 0) - mBlueBits++; - else - mBlueOffset++; - - i = i >> 1; - - } - -} - -nsDrawingSurface nsDeviceContextMotif :: GetDrawingSurface() -{ - return mSurface; -} - - - -NS_IMETHODIMP nsDeviceContextMotif :: CheckFontExistence(const nsString& aFontName) -{ - char **fnames = nsnull; - PRInt32 namelen = aFontName.Length() + 1; - char *wildstring = (char *)PR_Malloc(namelen + 200); - float t2d; - GetTwipsToDevUnits(t2d); - PRInt32 dpi = NSToIntRound(t2d * 1440); - Display *dpy = XtDisplay((Widget)mWidget); - int numnames = 0; - XFontStruct *fonts; - nsresult rv = NS_ERROR_FAILURE; - - if (nsnull == wildstring) - return NS_ERROR_UNEXPECTED; - - if (abs(dpi - 75) < abs(dpi - 100)) - dpi = 75; - else - dpi = 100; - - char* fontName = ToNewCString(aFontName); - PR_snprintf(wildstring, namelen + 200, - "*-%s-*-*-normal--*-*-%d-%d-*-*-*", - fontName, dpi, dpi); - delete [] fontName; - - fnames = ::XListFontsWithInfo(dpy, wildstring, 1, &numnames, &fonts); - - if (numnames > 0) - { - ::XFreeFontInfo(fnames, fonts, numnames); - rv = NS_OK; - } - - PR_Free(wildstring); - - return rv; -} - -void nsDeviceContextMotif::AllocColors() -{ - uint8* inx = new uint8[256]; - - if (PR_TRUE == mColorsAllocated) - return; - - mColorsAllocated = PR_TRUE; - - Display* d; - if (mSurface) { - d = mSurface->display; - } - else { - d = XtDisplay((Widget)mWidget); - } - -#if 0 - IL_RGB reserved[RESERVED_SIZE]; - //memset(reserved, 0, sizeof(reserved)); - // Setup the reserved colors - for (int i = 0; i < RESERVED_SIZE; i++) { - reserved[i].red = sReservedColors[i].red; - reserved[i].green = sReservedColors[i].green; - reserved[i].blue = sReservedColors[i].blue; - inx[i] = i; - } -#else - IL_RGB reserved[1]; //XXX REMOVE THIS here and below -#endif - - IL_ColorMap* colorMap = IL_NewCubeColorMap(reserved, RESERVED_SIZE, COLOR_CUBE_SIZE + RESERVED_SIZE); - - // Create a pseudo color space - IL_ColorSpace* colorSpace = IL_CreatePseudoColorSpace(colorMap, 8, 8); - - // Create a logical palette - NI_RGB* map = colorSpace->cmap.map; - - for (PRInt32 colorindex = RESERVED_SIZE; colorindex < (COLOR_CUBE_SIZE + RESERVED_SIZE); colorindex++) { - inx[colorindex] = AllocColor(map->red, map->green, map->blue, PR_TRUE); - map++; - } - - mIndex = inx; - - if (mColorSpace) - mColorSpace->cmap.index = mIndex; - -} - -NS_IMETHODIMP nsDeviceContextMotif::GetPaletteInfo(nsPaletteInfo& aPaletteInfo) -{ - aPaletteInfo.isPaletteDevice = mPaletteInfo.isPaletteDevice; - aPaletteInfo.sizePalette = mPaletteInfo.sizePalette; - aPaletteInfo.numReserved = mPaletteInfo.numReserved; - aPaletteInfo.palette = nsnull; - return NS_OK; -} - - -NS_IMETHODIMP nsDeviceContextMotif::GetILColorSpace(IL_ColorSpace*& aColorSpace) -{ - InstallColormap(); - - if ((8 == mDepth) && mPaletteInfo.isPaletteDevice) { - // - // 8-BIT Visual - // - // Create a color cube. We want to use DIB_PAL_COLORS because it's faster - // than DIB_RGB_COLORS, so make sure the indexes match that of the - // GDI physical palette - // - // Note: the image library doesn't use the reserved colors, so it doesn't - // matter what they're set to... - IL_RGB reserved[10]; - memset(reserved, 0, sizeof(reserved)); -// IL_ColorMap* colorMap = IL_NewCubeColorMap(reserved, 10, COLOR_CUBE_SIZE + 10); - IL_ColorMap* colorMap = IL_NewCubeColorMap(reserved, 0, COLOR_CUBE_SIZE ); - - if (nsnull == colorMap) { - return NS_ERROR_OUT_OF_MEMORY; - } - - // Create a pseudo color space - mColorSpace = IL_CreatePseudoColorSpace(colorMap, 8, 8); - mColorSpace->cmap.index = mIndex; - - - } else if (16 == mDepth) { - // - // 16-BIT Visual - // - IL_RGBBits colorRGBBits; - // Default is to create a 16-bit color space - colorRGBBits.red_shift = mRedOffset; - colorRGBBits.red_bits = mRedBits; - colorRGBBits.green_shift = mGreenOffset; - colorRGBBits.green_bits = mGreenBits; - colorRGBBits.blue_shift = mBlueOffset; - colorRGBBits.blue_bits = mBlueBits; - - mColorSpace = IL_CreateTrueColorSpace(&colorRGBBits, 16); - } - else if (24 == mDepth) { - DeviceContextImpl::GetILColorSpace(aColorSpace); - return NS_OK; - } - else { - DeviceContextImpl::GetILColorSpace(aColorSpace); - return NS_OK; - } - - if (nsnull == mColorSpace) { - aColorSpace = nsnull; - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_POSTCONDITION(nsnull != mColorSpace, "null color space"); - aColorSpace = mColorSpace; - IL_AddRefToColorSpace(aColorSpace); - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextMotif::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight) -{ - aWidth = 1; - aHeight = 1; - - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP nsDeviceContextMotif::GetClientRect(nsRect &aRect) -{ - aRect.x = 0; - aRect.y = 0; - aRect.width = 0; - aRect.height = 0; - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP nsDeviceContextMotif::GetDeviceContextFor(nsIDeviceContextSpec *aDevice, - nsIDeviceContext *&aContext) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP nsDeviceContextMotif::BeginDocument(PRUnichar * aTitle) -{ - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextMotif::EndDocument(void) -{ - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextMotif::BeginPage(void) -{ - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextMotif::EndPage(void) -{ - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextMotif::GetSystemFont(nsSystemFontID aID, - nsFont *aFont) const -{ - nsresult status = NS_OK; - - NS_NOTYETIMPLEMENTED("nsDeviceContextMotif::GetSystemFont"); - - switch (aID) { - case eSystemFont_Caption: - case eSystemFont_Icon: - case eSystemFont_Menu: - case eSystemFont_MessageBox: - case eSystemFont_SmallCaption: - case eSystemFont_StatusBar: - case eSystemFont_Tooltips: - case eSystemFont_Widget: - status = NS_ERROR_FAILURE; - break; - } // switch - - return status; -} diff --git a/gfx/src/motif/nsDeviceContextMotif.h b/gfx/src/motif/nsDeviceContextMotif.h deleted file mode 100644 index 4f1d85109f7f..000000000000 --- a/gfx/src/motif/nsDeviceContextMotif.h +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsDeviceContextMotif_h___ -#define nsDeviceContextMotif_h___ - -#include "nsDeviceContext.h" -#include "nsUnitConversion.h" -#include "nsIWidget.h" -#include "nsIView.h" -#include "nsIRenderingContext.h" - -#include "X11/Xlib.h" -#include "X11/Intrinsic.h" - -#ifdef MITSHM -#include -#include -#include -#endif - -/* nsDrawingSurface is actually the following struct */ -struct nsDrawingSurfaceMotif { - Display *display ; - Drawable drawable ; - GC gc ; - Visual * visual ; - PRUint32 depth ; -#ifdef MITSHM - XShmSegmentInfo shmInfo; - XImage * shmImage; -#endif -}; - - -class nsDeviceContextMotif : public DeviceContextImpl -{ -public: - nsDeviceContextMotif(); - - NS_DECL_ISUPPORTS - - NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext); - NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets); - - //get a low level drawing surface for rendering. the rendering context - //that is passed in is used to create the drawing surface if there isn't - //already one in the device context. the drawing surface is then cached - //in the device context for re-use. - - NS_IMETHOD GetILColorSpace(IL_ColorSpace*& aColorSpace); - NS_IMETHOD GetPaletteInfo(nsPaletteInfo&); - NS_IMETHOD Init(nsNativeWidget aNativeWidget); - NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const; - NS_IMETHOD GetSystemFont(nsSystemFontID anID, nsFont *aFont) const; - NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface); - - NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel); - - - NS_IMETHOD CheckFontExistence(const nsString& aFontName); - - NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight); - NS_IMETHOD GetClientRect(nsRect &aRect); - - NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, - nsIDeviceContext *&aContext); - - NS_IMETHOD BeginDocument(PRUnichar * aTitle); - NS_IMETHOD EndDocument(void); - - NS_IMETHOD BeginPage(void); - NS_IMETHOD EndPage(void); - - -protected: - ~nsDeviceContextMotif(); - void AllocColors(); - uint8 AllocColor(uint8 aRed, uint8 aGreen, - uint8 aBlue, PRBool aCanAlloc); - - - - nsDrawingSurfaceMotif * mSurface ; - - PRUint32 mDepth; - Visual * mVisual; - PRBool mWriteable; - PRUint32 mNumCells; - Colormap mColormap; - nsPaletteInfo mPaletteInfo; - PRBool mColorsAllocated; - uint8* mIndex; - XColor* mDeviceColors; - Display* mDisplay; - -public: - void InstallColormap(void); - void InstallColormap(Display* aDisplay, Drawable aDrawable); - void SetDrawingSurface(nsDrawingSurfaceMotif * aSurface) { mSurface = aSurface; } - nsDrawingSurface GetDrawingSurface(); - Display *GetDisplay(); - -private: - PRUint32 mRedMask; - PRUint32 mGreenMask; - PRUint32 mBlueMask; - PRUint32 mRedBits; - PRUint32 mGreenBits; - PRUint32 mBlueBits; - PRUint32 mRedOffset; - PRUint32 mGreenOffset; - PRUint32 mBlueOffset; - -}; - -#endif /* nsDeviceContextMotif_h___ */ diff --git a/gfx/src/motif/nsFontMetricsMotif.cpp b/gfx/src/motif/nsFontMetricsMotif.cpp deleted file mode 100644 index dcbab19b11b6..000000000000 --- a/gfx/src/motif/nsFontMetricsMotif.cpp +++ /dev/null @@ -1,411 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "xp_core.h" //this is a hack to get it to build. MMP -#include "nsFontMetricsMotif.h" -#include "nsDeviceContextMotif.h" - -#include "nspr.h" -#include "nsCRT.h" -#include "nsReadableUtils.h" - -//#define NOISY_FONTS - -nsFontMetricsMotif :: nsFontMetricsMotif() -{ - NS_INIT_REFCNT(); - mFont = nsnull; - mFontHandle = nsnull; - mFontInfo = nsnull; -} - -nsFontMetricsMotif :: ~nsFontMetricsMotif() -{ - if (nsnull != mFont) { - delete mFont; - mFont = nsnull; - } - - if (nsnull != mFontHandle) { - ::XUnloadFont(((nsDeviceContextMotif *)mContext)->GetDisplay(), mFontHandle); - } -} - -NS_IMPL_ISUPPORTS1(nsFontMetricsMotif, nsIFontMetrics) - -NS_IMETHODIMP nsFontMetricsMotif :: Init(const nsFont& aFont, nsIAtom* aLangGroup, nsIDeviceContext* aCX) -{ - NS_ASSERTION(!(nsnull == aCX), "attempt to init fontmetrics with null device context"); - - nsAutoString firstFace; - if (NS_OK != aCX->FirstExistingFont(aFont, firstFace)) { - aFont.GetFirstFamily(firstFace); - } - - char **fnames = nsnull; - PRInt32 namelen = firstFace.Length() + 1; - char *wildstring = (char *)PR_Malloc((namelen << 1) + 200); - int numnames = 0; - char altitalicization = 0; - XFontStruct *fonts; - float t2d; - aCX->GetTwipsToDevUnits(t2d); - PRInt32 dpi = NSToIntRound(t2d * 1440); - Display *dpy; - dpy = ((nsDeviceContextMotif *)aCX)->GetDisplay(); - - if (nsnull == wildstring) - return NS_ERROR_NOT_INITIALIZED; - - mFont = new nsFont(aFont); - mContext = aCX; - mFontHandle = nsnull; - mLangGroup = aLangGroup; - - firstFace.ToCString(wildstring, namelen); - - if (abs(dpi - 75) < abs(dpi - 100)) - dpi = 75; - else - dpi = 100; - -#ifdef NOISY_FONTS -#ifdef DEBUG - fprintf(stderr, "looking for font %s (%d)", wildstring, aFont.size / 20); -#endif -#endif - - //font properties we care about: - //name - //weight (bold, medium) - //slant (r = normal, i = italic, o = oblique) - //size in nscoords >> 1 - - PR_snprintf(&wildstring[namelen + 1], namelen + 200, - "*-%s-%s-%c-normal--*-*-%d-%d-*-*-*", - wildstring, - (aFont.weight <= NS_FONT_WEIGHT_NORMAL) ? "medium" : "bold", - (aFont.style == NS_FONT_STYLE_NORMAL) ? 'r' : - ((aFont.style == NS_FONT_STYLE_ITALIC) ? 'i' : 'o'), dpi, dpi); - - fnames = ::XListFontsWithInfo(dpy, &wildstring[namelen + 1], 200, &numnames, &fonts); - - if (aFont.style == NS_FONT_STYLE_ITALIC) - altitalicization = 'o'; - else if (aFont.style == NS_FONT_STYLE_OBLIQUE) - altitalicization = 'i'; - - if ((numnames <= 0) && altitalicization) - { - PR_snprintf(&wildstring[namelen + 1], namelen + 200, - "*-%s-%s-%c-normal--*-*-%d-%d-*-*-*", - wildstring, - (aFont.weight <= NS_FONT_WEIGHT_NORMAL) ? "medium" : "bold", - altitalicization, dpi, dpi); - - fnames = ::XListFontsWithInfo(dpy, &wildstring[namelen + 1], 200, &numnames, &fonts); - } - - - if (numnames <= 0) - { - //we were not able to match the font name at all... - - char *newname = ToNewCString(firstFace); - - PR_snprintf(&wildstring[namelen + 1], namelen + 200, - "*-%s-%s-%c-normal--*-*-%d-%d-*-*-*", - newname, - (aFont.weight <= NS_FONT_WEIGHT_NORMAL) ? "medium" : "bold", - (aFont.style == NS_FONT_STYLE_NORMAL) ? 'r' : - ((aFont.style == NS_FONT_STYLE_ITALIC) ? 'i' : 'o'), dpi, dpi); - - fnames = ::XListFontsWithInfo(dpy, &wildstring[namelen + 1], 200, &numnames, &fonts); - - if ((numnames <= 0) && altitalicization) - { - PR_snprintf(&wildstring[namelen + 1], namelen + 200, - "*-%s-%s-%c-normal--*-*-%d-%d-*-*-*", - newname, - (aFont.weight <= NS_FONT_WEIGHT_NORMAL) ? "medium" : "bold", - altitalicization, dpi, dpi); - - fnames = ::XListFontsWithInfo(dpy, &wildstring[namelen + 1], 200, &numnames, &fonts); - } - - delete [] newname; - } - - if (numnames > 0) - { - char *nametouse = PickAppropriateSize(fnames, fonts, numnames, aFont.size); - - mFontHandle = ::XLoadFont(dpy, nametouse); - -#ifdef NOISY_FONTS -#ifdef DEBUG - fprintf(stderr, " is: %s\n", nametouse); -#endif -#endif - - ::XFreeFontInfo(fnames, fonts, numnames); - } - else - { - //ack. we're in real trouble, go for fixed... - -#ifdef NOISY_FONTS -#ifdef DEBUG - fprintf(stderr, " is: %s\n", "fixed (final fallback)"); -#endif -#endif - - mFontHandle = ::XLoadFont(dpy, "fixed"); - } - - RealizeFont(); - - PR_Free(wildstring); - - return NS_OK; -} - -NS_IMETHODIMP -nsFontMetricsMotif :: Destroy() -{ -// NS_IF_RELEASE(mDeviceContext); - return NS_OK; -} - -char * nsFontMetricsMotif::PickAppropriateSize(char **names, XFontStruct *fonts, int cnt, nscoord desired) -{ - int idx; - float app2dev; - mContext->GetAppUnitsToDevUnits(app2dev); - PRInt32 desiredpix = NSToIntRound(app2dev * desired); - XFontStruct *curfont; - PRInt32 closestmin = -1, minidx; - - //first try an exact or closest smaller match... - - for (idx = 0, curfont = fonts; idx < cnt; idx++, curfont++) - { - PRInt32 height = curfont->ascent + curfont->descent; - - if (height == desiredpix) - break; - - if ((height < desiredpix) && (height > closestmin)) - { - closestmin = height; - minidx = idx; - } - } - - if (idx < cnt) - return names[idx]; - else if (closestmin >= 0) - return names[minidx]; - else - { - closestmin = 2000000; - - for (idx = 0, curfont = fonts; idx < cnt; idx++, curfont++) - { - PRInt32 height = curfont->ascent + curfont->descent; - - if ((height > desiredpix) && (height < closestmin)) - { - closestmin = height; - minidx = idx; - } - } - - return names[minidx]; - } -} - -void nsFontMetricsMotif::RealizeFont() -{ - mFontInfo = ::XQueryFont(((nsDeviceContextMotif *)mContext)->GetDisplay(), mFontHandle); - - float f; - mContext->GetDevUnitsToAppUnits(f); - - mAscent = nscoord(mFontInfo->ascent * f); - mDescent = nscoord(mFontInfo->descent * f); - mMaxAscent = nscoord(mFontInfo->ascent * f) ; - mMaxDescent = nscoord(mFontInfo->descent * f); - - mHeight = nscoord((mFontInfo->ascent + mFontInfo->descent) * f) ; - mMaxAdvance = nscoord(mFontInfo->max_bounds.width * f); - - PRUint32 i; - - for (i = 0; i < 256; i++) - { - if ((i < mFontInfo->min_char_or_byte2) || (i > mFontInfo->max_char_or_byte2)) - mCharWidths[i] = mMaxAdvance; - else - mCharWidths[i] = nscoord((mFontInfo->per_char[i - mFontInfo->min_char_or_byte2].width) * f); - } - - mLeading = 0; -} - -NS_IMETHODIMP -nsFontMetricsMotif :: GetXHeight(nscoord& aResult) -{ - aResult = mMaxAscent / 2; // XXX temporary code! - return NS_OK; -} - -NS_IMETHODIMP -nsFontMetricsMotif :: GetSuperscriptOffset(nscoord& aResult) -{ - aResult = mMaxAscent / 2; // XXX temporary code! - return NS_OK; -} - -NS_IMETHODIMP -nsFontMetricsMotif :: GetSubscriptOffset(nscoord& aResult) -{ - aResult = mMaxAscent / 2; // XXX temporary code! - return NS_OK; -} - -NS_IMETHODIMP -nsFontMetricsMotif :: GetStrikeout(nscoord& aOffset, nscoord& aSize) -{ - aOffset = 0; /* XXX */ - aSize = 0; /* XXX */ - return NS_OK; -} - -NS_IMETHODIMP -nsFontMetricsMotif :: GetUnderline(nscoord& aOffset, nscoord& aSize) -{ - aOffset = 0; /* XXX */ - aSize = 0; /* XXX */ - return NS_OK; -} - -NS_IMETHODIMP nsFontMetricsMotif :: GetHeight(nscoord &aHeight) -{ - aHeight = mHeight; - return NS_OK; -} - -NS_IMETHODIMP nsFontMetricsMotif :: GetLeading(nscoord &aLeading) -{ - aLeading = mLeading; - return NS_OK; -} - -NS_IMETHODIMP nsFontMetricsMotif :: GetMaxAscent(nscoord &aAscent) -{ - aAscent = mMaxAscent; - return NS_OK; -} - -NS_IMETHODIMP nsFontMetricsMotif :: GetMaxDescent(nscoord &aDescent) -{ - aDescent = mMaxDescent; - return NS_OK; -} - -NS_IMETHODIMP nsFontMetricsMotif :: GetMaxAdvance(nscoord &aAdvance) -{ - aAdvance = mMaxAdvance; - return NS_OK; -} - -NS_IMETHODIMP nsFontMetricsMotif :: GetFont(const nsFont*& aFont) -{ - aFont = mFont; - return NS_OK; -} - -NS_IMETHODIMP nsFontMetricsMotif :: GetFontHandle(nsFontHandle &aHandle) -{ - aHandle = (nsFontHandle)mFontHandle; - return NS_OK; -} - -NS_IMETHODIMP nsFontMetricsMotif :: GetLangGroup(nsIAtom** aLangGroup) -{ - if (!aLangGroup) { - return NS_ERROR_NULL_POINTER; - } - - *aLangGroup = mLangGroup; - NS_IF_ADDREF(*aLangGroup); - - return NS_OK; -} - -static void MapGenericFamilyToFont(const nsString& aGenericFamily, nsIDeviceContext* aDC, - nsString& aFontFace) -{ - // the CSS generic names (conversions from Nav for now) - // XXX this need to check availability with the dc - PRBool aliased; - if (aGenericFamily.EqualsIgnoreCase("serif")) { - aDC->GetLocalFontName("times", aFontFace, aliased); - } - else if (aGenericFamily.EqualsIgnoreCase("sans-serif")) { - aDC->GetLocalFontName("helvetica", aFontFace, aliased); - } - else if (aGenericFamily.EqualsIgnoreCase("cursive")) { - aDC->GetLocalFontName("script", aFontFace, aliased); // XXX ??? - } - else if (aGenericFamily.EqualsIgnoreCase("fantasy")) { - aDC->GetLocalFontName("helvetica", aFontFace, aliased); - } - else if (aGenericFamily.EqualsIgnoreCase("monospace")) { - aDC->GetLocalFontName("fixed", aFontFace, aliased); - } - else if (aGenericFamily.EqualsIgnoreCase("-moz-fixed")) { - aDC->GetLocalFontName("fixed", aFontFace, aliased); - } - else { - aFontFace.Truncate(); - } -} - - diff --git a/gfx/src/motif/nsFontMetricsMotif.h b/gfx/src/motif/nsFontMetricsMotif.h deleted file mode 100644 index 87b8fa169c00..000000000000 --- a/gfx/src/motif/nsFontMetricsMotif.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsFontMetricsMotif_h__ -#define nsFontMetricsMotif_h__ - -#include "nsIFontMetrics.h" -#include "nsFont.h" -#include "nsString.h" -#include "nsUnitConversion.h" -#include "nsIDeviceContext.h" -#include "nsCRT.h" -#include "nsIAtom.h" -#include "nsCOMPtr.h" - -#include "X11/Xlib.h" - -class nsFontMetricsMotif : public nsIFontMetrics -{ -public: - nsFontMetricsMotif(); - virtual ~nsFontMetricsMotif(); - - NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW - - NS_DECL_ISUPPORTS - - NS_IMETHOD Init(const nsFont& aFont, nsIAtom* aLangGroup, - nsIDeviceContext* aCX); - NS_IMETHOD Destroy(); - - NS_IMETHOD GetXHeight(nscoord& aResult); - NS_IMETHOD GetSuperscriptOffset(nscoord& aResult); - NS_IMETHOD GetSubscriptOffset(nscoord& aResult); - NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize); - NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize); - - NS_IMETHOD GetHeight(nscoord &aHeight); - NS_IMETHOD GetLeading(nscoord &aLeading); - NS_IMETHOD GetMaxAscent(nscoord &aAscent); - NS_IMETHOD GetMaxDescent(nscoord &aDescent); - NS_IMETHOD GetMaxAdvance(nscoord &aAdvance); - - NS_IMETHOD GetFont(const nsFont*& aFont); - NS_IMETHOD GetFontHandle(nsFontHandle &aHandle); - NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup); - -protected: - void RealizeFont(); - -protected: - void QueryFont(); - char *PickAppropriateSize(char **names, XFontStruct *fonts, int cnt, nscoord desired); - - nsFont *mFont; - nsIDeviceContext *mContext; - nsCOMPtr mLangGroup; - XFontStruct *mFontInfo; - Font mFontHandle; - nscoord mCharWidths[256]; - nscoord mHeight; - nscoord mAscent; - nscoord mDescent; - nscoord mLeading; - nscoord mMaxAscent; - nscoord mMaxDescent; - nscoord mMaxAdvance; -}; - -#endif // nsFontMetricsMotif_h__ diff --git a/gfx/src/motif/nsGfxFactoryMotif.cpp b/gfx/src/motif/nsGfxFactoryMotif.cpp deleted file mode 100644 index 84a50492c24d..000000000000 --- a/gfx/src/motif/nsGfxFactoryMotif.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "xp_core.h" //this is a hack to get it to build. MMP -#include "nscore.h" -#include "nsIFactory.h" -#include "nsISupports.h" -#include "nsGfxCIID.h" -#include "nsFontMetricsMotif.h" -#include "nsRenderingContextMotif.h" -#include "nsImageMotif.h" -#include "nsDeviceContextMotif.h" -#include "nsRegionMotif.h" - -static NS_DEFINE_IID(kCFontMetrics, NS_FONT_METRICS_CID); -static NS_DEFINE_IID(kCRenderingContext, NS_RENDERING_CONTEXT_CID); -static NS_DEFINE_IID(kCImage, NS_IMAGE_CID); -static NS_DEFINE_IID(kCDeviceContext, NS_DEVICE_CONTEXT_CID); -static NS_DEFINE_IID(kCRegion, NS_REGION_CID); - -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); - -class nsGfxFactoryMotif : public nsIFactory -{ - public: - NS_DECL_ISUPPORTS - NS_DECL_NSIFACTORY - - nsGfxFactoryMotif(const nsCID &aClass); - virtual ~nsGfxFactoryMotif(); - - private: - nsCID mClassID; -}; - -nsGfxFactoryMotif::nsGfxFactoryMotif(const nsCID &aClass) -{ - NS_INIT_REFCNT(); - mClassID = aClass; -} - -nsGfxFactoryMotif::~nsGfxFactoryMotif() -{ -} - -nsresult nsGfxFactoryMotif::QueryInterface(const nsIID &aIID, - void **aResult) -{ - if (aResult == NULL) { - return NS_ERROR_NULL_POINTER; - } - - // Always NULL result, in case of failure - *aResult = NULL; - - if (aIID.Equals(kISupportsIID)) { - *aResult = (void *)(nsISupports*)this; - } else if (aIID.Equals(kIFactoryIID)) { - *aResult = (void *)(nsIFactory*)this; - } - - if (*aResult == NULL) { - return NS_NOINTERFACE; - } - - AddRef(); // Increase reference count for caller - return NS_OK; -} - -NS_IMPL_ADDREF(nsGfxFactoryMotif); -NS_IMPL_RELEASE(nsGfxFactoryMotif); - -nsresult nsGfxFactoryMotif::CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult) -{ - if (aResult == NULL) { - return NS_ERROR_NULL_POINTER; - } - - *aResult = NULL; - - nsISupports *inst = nsnull; - - if (mClassID.Equals(kCFontMetrics)) { - inst = (nsISupports *)new nsFontMetricsMotif(); - } - else if (mClassID.Equals(kCDeviceContext)) { - inst = (nsISupports *)new nsDeviceContextMotif(); - } - else if (mClassID.Equals(kCRenderingContext)) { - inst = (nsISupports *)new nsRenderingContextMotif(); - } - else if (mClassID.Equals(kCImage)) { - inst = (nsISupports *)new nsImageMotif(); - } - else if (mClassID.Equals(kCRegion)) { - inst = (nsISupports *)new nsRegionMotif(); - } - - if (inst == NULL) { - return NS_ERROR_OUT_OF_MEMORY; - } - - nsresult res = inst->QueryInterface(aIID, aResult); - - if (res != NS_OK) { - // We didn't get the right interface, so clean up - delete inst; - } -// else { -// inst->Release(); -// } - - return res; -} - -nsresult nsGfxFactoryMotif::LockFactory(PRBool aLock) -{ - // Not implemented in simplest case. - return NS_OK; -} - -// return the proper factory to the caller -extern "C" NS_GFXNONXP nsresult NSGetFactory(nsISupports* servMgr, - const nsCID &aClass, - const char *aClassName, - const char *aContractID, - nsIFactory **aFactory) -{ - if (nsnull == aFactory) { - return NS_ERROR_NULL_POINTER; - } - - *aFactory = new nsGfxFactoryMotif(aClass); - - if (nsnull == aFactory) { - return NS_ERROR_OUT_OF_MEMORY; - } - - return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory); -} diff --git a/gfx/src/motif/nsImageMotif.cpp b/gfx/src/motif/nsImageMotif.cpp deleted file mode 100644 index 937ebd5615a3..000000000000 --- a/gfx/src/motif/nsImageMotif.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "xp_core.h" //this is a hack to get it to build. MMP -#include "nsImageMotif.h" -#include "nsRenderingContextMotif.h" -#include "nsDeviceContextMotif.h" - -#include "nspr.h" - -#define IsFlagSet(a,b) (a & b) - -//------------------------------------------------------------ - -nsImageMotif :: nsImageMotif() -{ - NS_INIT_REFCNT(); - mImage = nsnull ; - mImageBits = nsnull; - mConvertedBits = nsnull; - mBitsForCreate = nsnull; - mWidth = 0; - mHeight = 0; - mDepth = 0; - mOriginalDepth = 0; - mColorMap = nsnull; - mAlphaBits = nsnull; - mStaticImage = PR_FALSE; - mNaturalWidth = 0; - mNaturalHeight = 0; - -} - -//------------------------------------------------------------ - -nsImageMotif :: ~nsImageMotif() -{ - if (nsnull != mImage) { - XDestroyImage(mImage); - mImage = nsnull; - } - - if(nsnull != mConvertedBits) { - delete[] (PRUint8*)mConvertedBits; - mConvertedBits = nsnull; - } - - if(nsnull != mImageBits) { - delete[] (PRUint8*)mImageBits; - mImageBits = nsnull; - } - - if(nsnull!= mColorMap) - delete mColorMap; - - if (nsnull != mAlphaBits) { - delete mAlphaBits; - } - -} - -NS_IMPL_ISUPPORTS1(nsImageMotif, nsIImage) - -//------------------------------------------------------------ - -nsresult nsImageMotif :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMaskRequirements aMaskRequirements) -{ - if(nsnull != mImageBits) - delete[] (PRUint8*)mImageBits; - - if(nsnull != mColorMap) - delete[] mColorMap; - - if (nsnull != mImage) { - XDestroyImage(mImage); - mImage = nsnull; - } - mWidth = aWidth; - mHeight = aHeight; - mDepth = aDepth; - mOriginalDepth = aDepth; - mOriginalRowBytes = CalcBytesSpan(aWidth); - mConverted = PR_FALSE; - - SetDecodedRect(0,0,0,0); //init - SetNaturalWidth(0); - SetNaturalHeight(0); - - ComputePaletteSize(aDepth); - - // create the memory for the image - ComputMetrics(); - - mImageBits = (PRUint8*) new PRUint8[mSizeImage]; - mAlphaBits = (PRUint8*) new PRUint8[mSizeImage]; - - mColorMap = new nsColorMap; - - if (mColorMap != nsnull) { - mColorMap->NumColors = mNumPalleteColors; - mColorMap->Index = new PRUint8[3 * mNumPalleteColors]; - memset(mColorMap->Index, 0, sizeof(PRUint8) * (3 * mNumPalleteColors)); - } - - return NS_OK; -} - -//------------------------------------------------------------ - -void nsImageMotif::ComputMetrics() -{ - - mRowBytes = CalcBytesSpan(mWidth); - mSizeImage = mRowBytes * mHeight; - -} - -//------------------------------------------------------------ - -// figure out how big our palette needs to be -void nsImageMotif :: ComputePaletteSize(PRIntn nBitCount) -{ - switch (nBitCount) - { - case 8: - mNumPalleteColors = 256; - mNumBytesPixel = 1; - break; - case 16: - mNumPalleteColors = 0; - mNumBytesPixel = 2; - break; - case 24: - mNumPalleteColors = 0; - mNumBytesPixel = 3; - break; - default: - mNumPalleteColors = -1; - mNumBytesPixel = 0; - break; - } -} - -//------------------------------------------------------------ - -PRInt32 nsImageMotif :: CalcBytesSpan(PRUint32 aWidth) -{ -PRInt32 spanbytes; - - spanbytes = (aWidth * mDepth) >> 5; - - if (((PRUint32)aWidth * mDepth) & 0x1F) - spanbytes++; - spanbytes <<= 2; - return(spanbytes); -} - -//------------------------------------------------------------ - -// set up the pallete to the passed in color array, RGB only in this array -void nsImageMotif :: ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect) -{ - - if (nsnull == mImage) - return; - - if (IsFlagSet(nsImageUpdateFlags_kBitsChanged, aFlags)){ - } - -} - - -//------------------------------------------------------------ - -// Draw the bitmap, this method has a source and destination coordinates -NS_IMETHODIMP nsImageMotif :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight, - PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) -{ - nsDrawingSurfaceMotif *motifdrawing =(nsDrawingSurfaceMotif*) aSurface; - - if ((PR_FALSE==mStaticImage) || (nsnull == mImage)) { - BuildImage(aSurface); - } - - if (nsnull == mImage) - return NS_ERROR_FAILURE; - - XPutImage(motifdrawing->display,motifdrawing->drawable,motifdrawing->gc,mImage, - aSX,aSY,aDX,aDY,aDWidth,aDHeight); - - return NS_OK; -} - -//------------------------------------------------------------ - -// Draw the bitmap, this draw just has destination coordinates -NS_IMETHODIMP nsImageMotif :: Draw(nsIRenderingContext &aContext, - nsDrawingSurface aSurface, - PRInt32 aX, PRInt32 aY, - PRInt32 aWidth, PRInt32 aHeight) -{ - nsDrawingSurfaceMotif *motifdrawing =(nsDrawingSurfaceMotif*) aSurface; - - BuildImage(aSurface); - - // Build Image each time if it's not static. - if ((PR_FALSE==mStaticImage) || (nsnull == mImage)) { - BuildImage(aSurface); - } - - if (nsnull == mImage) - return NS_ERROR_FAILURE; - - XPutImage(motifdrawing->display,motifdrawing->drawable,motifdrawing->gc,mImage, - 0,0,aX,aY,aWidth,aHeight); - return NS_OK; -} - -//------------------------------------------------------------ - -void nsImageMotif::CompositeImage(nsIImage *aTheImage, nsPoint *aULLocation,nsBlendQuality aBlendQuality) -{ -} - -void nsImageMotif::AllocConvertedBits(PRUint32 aSize) -{ - if (nsnull == mConvertedBits) - mConvertedBits = (PRUint8*) new PRUint8[aSize]; -} - -//------------------------------------------------------------ - -void nsImageMotif::ConvertImage(nsDrawingSurface aDrawingSurface) -{ -nsDrawingSurfaceMotif *motifdrawing =(nsDrawingSurfaceMotif*) aDrawingSurface; -PRUint8 *tempbuffer,*cursrc,*curdest; -PRInt32 x,y; -PRUint16 red,green,blue,*cur16; - - mBitsForCreate = mImageBits; - -#if 0 - if((motifdrawing->depth==24) && (mOriginalDepth==8)) - { - // convert this nsImage to a 24 bit image - mDepth = 24; - ComputePaletteSize(mDepth); - ComputMetrics(); - AllocConvertedBits(mSizeImage); - tempbuffer = mConvertedBits; - mBitsForCreate = mConvertedBits; - - for(y=0;yIndex[(3*(*cursrc))+2]; // red - curdest++; - *curdest = mColorMap->Index[(3*(*cursrc))+1]; // green - curdest++; - *curdest = mColorMap->Index[(3*(*cursrc))]; // blue - curdest++; - cursrc++; - } - } - -#if 0 - if(mColorMap) - delete mColorMap; - - // after we are finished converting the image, build a new color map - mColorMap = new nsColorMap; - - if (mColorMap != nsnull) - { - mColorMap->NumColors = mNumPalleteColors; - mColorMap->Index = new PRUint8[3 * mNumPalleteColors]; - memset(mColorMap->Index, 0, sizeof(PRUint8) * (3 * mNumPalleteColors)); - } -#endif - } - - // convert the 8 bit image to 16 bit - if((motifdrawing->depth==16) && (mOriginalDepth==8)) - { - mDepth = 16; - ComputePaletteSize(mDepth); - ComputMetrics(); - AllocConvertedBits(mSizeImage); - tempbuffer = mConvertedBits; - mBitsForCreate = mConvertedBits; - - for(y=0;yIndex[(3*(*cursrc))+2]; // red - green = mColorMap->Index[(3*(*cursrc))+1]; // green - red = mColorMap->Index[(3*(*cursrc))]; // blue - cursrc++; - *cur16 = ((red&0xf8)<<8)|((green&0xfc)<<3)| ((blue&0xf8)>>3); - cur16++; - } - } - -#if 0 - if (mColorMap != nsnull) - { - mColorMap->NumColors = mNumPalleteColors; - mColorMap->Index = new PRUint8[3 * mNumPalleteColors]; - memset(mColorMap->Index, 0, sizeof(PRUint8) * (3 * mNumPalleteColors)); - } -#endif - } -#endif -} - -nsresult nsImageMotif::BuildImage(nsDrawingSurface aDrawingSurface) -{ - if (nsnull != mImage) { -// XDestroyImage(mImage); - mImage = nsnull; - } - - ConvertImage(aDrawingSurface); - CreateImage(aDrawingSurface); - - return NS_OK; -} - -//------------------------------------------------------------ - -nsresult nsImageMotif::Optimize(nsIDeviceContext* aContext) -{ - mStaticImage = PR_TRUE; -#if 0 - BuildImage(aDrawingSurface); -#endif - return NS_OK; -} - -//------------------------------------------------------------ - -void nsImageMotif::CreateImage(nsDrawingSurface aSurface) -{ - PRUint32 wdepth; - Visual * visual ; - PRUint32 format ; - nsDrawingSurfaceMotif *motifdrawing =(nsDrawingSurfaceMotif*) aSurface; - - if(mImageBits) { - format = ZPixmap; - -#if 0 - /* Need to support monochrome too */ - if (motifdrawing->visual->c_class == TrueColor || - motifdrawing->visual->c_class == DirectColor) { - format = ZPixmap; - } - else { -printf("Format XYPixmap\n"); - format = XYPixmap; - } -#endif - -/* printf("Width %d Height %d Visual Depth %d Image Depth %d\n", - mWidth, mHeight, - motifdrawing->depth, mDepth); */ - - mImage = ::XCreateImage(motifdrawing->display, - motifdrawing->visual, - motifdrawing->depth, - format, - 0, - (char *)mBitsForCreate, - (unsigned int)mWidth, - (unsigned int)mHeight, - 32,mRowBytes); - - mImage->byte_order = ImageByteOrder(motifdrawing->display); - mImage->bits_per_pixel = motifdrawing->depth; - mImage->bitmap_bit_order = BitmapBitOrder(motifdrawing->display); - mImage->bitmap_unit = 32; - } - return ; -} - -//------------------------------------------------------------ -// lock the image pixels. nothing to do on gtk -NS_IMETHODIMP -nsImageMotif::LockImagePixels(PRBool aMaskPixels) -{ - return NS_OK; -} - -//------------------------------------------------------------ -// unlock the image pixels. nothing to do on gtk -NS_IMETHODIMP -nsImageMotif::UnlockImagePixels(PRBool aMaskPixels) -{ - return NS_OK; -} - -/** --------------------------------------------------- - * Set the decoded dimens of the image - */ -NS_IMETHODIMP -nsImageMotif::SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2 ) -{ - - mDecodedX1 = x1; - mDecodedY1 = y1; - mDecodedX2 = x2; - mDecodedY2 = y2; - return NS_OK; -} diff --git a/gfx/src/motif/nsImageMotif.h b/gfx/src/motif/nsImageMotif.h deleted file mode 100644 index ae84e1c85b72..000000000000 --- a/gfx/src/motif/nsImageMotif.h +++ /dev/null @@ -1,190 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsImageMotif_h___ -#define nsImageMotif_h___ - -#include "nsIImage.h" - -#include "X11/Xlib.h" -#include "X11/Xutil.h" - -/* taken from ../nsBlender.h */ -typedef enum -{ - nsLowQual = 0, - nsLowMedQual, - nsMedQual, - nsHighMedQual, - nsHighQual -} nsBlendQuality; - -class nsImageMotif : public nsIImage -{ -public: - nsImageMotif(); - virtual ~nsImageMotif(); - - NS_DECL_ISUPPORTS - - /** - @see nsIImage.h - */ - virtual PRInt32 GetBytesPix() { return mNumBytesPixel; } - virtual PRInt32 GetHeight() { return mHeight; } - virtual PRInt32 GetWidth() { return mWidth; } - virtual PRUint8* GetBits() { return mImageBits; } - virtual void* GetBitInfo() { return nsnull; } - virtual PRBool GetIsRowOrderTopToBottom() { return mIsTopToBottom; } - virtual PRInt32 GetLineStride() {return mRowBytes; } - - NS_IMETHOD SetNaturalWidth(PRInt32 naturalwidth) { mNaturalWidth= naturalwidth; return NS_OK;} - NS_IMETHOD SetNaturalHeight(PRInt32 naturalheight) { mNaturalHeight= naturalheight; return NS_OK;} - virtual PRInt32 GetNaturalWidth() {return mNaturalWidth; } - virtual PRInt32 GetNaturalHeight() {return mNaturalHeight; } - - NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2); - virtual PRInt32 GetDecodedX1() { return mDecodedX1;} - virtual PRInt32 GetDecodedY1() { return mDecodedY1;} - virtual PRInt32 GetDecodedX2() { return mDecodedX2;} - virtual PRInt32 GetDecodedY2() { return mDecodedY2;} - - NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight); - NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight, - PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight); - virtual nsColorMap* GetColorMap() {return mColorMap;} - virtual void ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect); - virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements); - virtual PRBool IsOptimized() { return (mImage!=nsnull); } - - virtual nsresult BuildImage(nsDrawingSurface aDrawingSurface); - virtual nsresult Optimize(nsIDeviceContext* aContext); - virtual PRBool GetHasAlphaMask() { return mAlphaBits != nsnull; } - virtual PRUint8* GetAlphaBits() { return mAlphaBits; } - virtual PRInt32 GetAlphaWidth() { return 0;} - virtual PRInt32 GetAlphaHeight() {return 0;} - virtual PRInt32 GetAlphaXLoc() {return 0;} - virtual PRInt32 GetAlphaYLoc() {return 0;} - virtual PRInt32 GetAlphaLineStride(){ return 0; } - virtual void CompositeImage(nsIImage *aTheImage,nsPoint *aULLocation,nsBlendQuality aQuality); - virtual nsIImage* DuplicateImage() {return(nsnull);} - - void AllocConvertedBits(PRUint32 aSize); - - /** - * Return the image size of the Device Independent Bitmap(DIB). - * @return size of image in bytes - */ - PRIntn GetSizeImage(){ return 0; } - - /** - * Make a palette for the DIB. - * @return true or false if the palette was created - */ - PRBool MakePalette(); - - /** - * Calculate the number of bytes spaned for this image for a given width - * @param aWidth is the width to calculate the number of bytes for - * @return the number of bytes in this span - */ - PRInt32 CalcBytesSpan(PRUint32 aWidth); - virtual void SetAlphaLevel(PRInt32 /* aAlphaLevel */) {} - virtual PRInt32 GetAlphaLevel() {return(0);} - /** - * Get the alpha depth for the image mask - * @update - lordpixel 2001/05/16 - * @return the alpha mask depth for the image, ie, 0, 1 or 8 - */ - virtual PRInt8 GetAlphaDepth() {return(mAlphaDepth);} - virtual void MoveAlphaMask(PRInt32 /* aX */, PRInt32 /* aY */) {} - - NS_IMETHOD LockImagePixels(PRBool aMaskPixels); - NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels); - -private: - void CreateImage(nsDrawingSurface aSurface); - void ConvertImage(nsDrawingSurface aSurface); - - /** - * Calculate the amount of memory needed for the initialization of the image - */ - void ComputMetrics(); - void ComputePaletteSize(PRIntn nBitCount); - - -private: - PRBool mStaticImage; - PRInt32 mWidth; - PRInt32 mHeight; - PRInt32 mDepth; // bits per pixel - PRInt32 mOriginalDepth; // bits per pixel - PRInt32 mRowBytes; - PRInt32 mOriginalRowBytes; - Pixmap mThePixMap; - PRUint8 *mImageBits; - PRUint8 *mConvertedBits; - PRBool mConverted; - PRUint8 *mBitsForCreate; - PRInt32 mSizeImage; - PRBool mIsTopToBottom; - XImage *mImage ; - nsColorMap *mColorMap; - PRInt16 mNumPalleteColors; - PRInt8 mNumBytesPixel; - - PRInt32 mNaturalWidth; - PRInt32 mNaturalHeight; - - PRInt32 mDecodedX1; //Keeps track of what part of image - PRInt32 mDecodedY1; // has been decoded. - PRInt32 mDecodedX2; - PRInt32 mDecodedY2; - - // alpha layer members - PRUint8 *mAlphaBits; - PRInt8 mAlphaDepth; // alpha layer depth - PRInt16 mARowBytes; - PRInt16 mAlphaWidth; // alpha layer width - PRInt16 mAlphaHeight; // alpha layer height - nsPoint mLocation; // alpha mask location - - -}; - -#endif // nsImageMotif_h___ diff --git a/gfx/src/motif/nsRegionMotif.cpp b/gfx/src/motif/nsRegionMotif.cpp deleted file mode 100644 index 7156bf464b1a..000000000000 --- a/gfx/src/motif/nsRegionMotif.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsRegionMotif.h" - -nsRegionMotif :: nsRegionMotif() -{ - NS_INIT_REFCNT(); - - mRegion = nsnull; - mRegionType = eRegionComplexity_empty; -} - -nsRegionMotif :: ~nsRegionMotif() -{ - if (mRegion) - ::XDestroyRegion(mRegion); - mRegion = nsnull; -} - -NS_IMPL_ISUPPORTS1(nsRegionMotif, nsIRegion) - -nsresult nsRegionMotif :: Init(void) -{ - mRegion = ::XCreateRegion(); - mRegionType = eRegionComplexity_empty; - - return NS_OK; -} - -void nsRegionMotif :: SetTo(const nsIRegion &aRegion) -{ - nsRegionMotif * pRegion = (nsRegionMotif *)&aRegion; - - SetRegionEmpty(); - - ::XUnionRegion(mRegion, pRegion->mRegion, mRegion); - - SetRegionType(); -} - -void nsRegionMotif :: SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) -{ - - SetRegionEmpty(); - - XRectangle xrect; - - xrect.x = aX; - xrect.y = aY; - xrect.width = aWidth; - xrect.height = aHeight; - - ::XUnionRectWithRegion(&xrect, mRegion, mRegion); - - SetRegionType(); -} - -void nsRegionMotif :: Intersect(const nsIRegion &aRegion) -{ - nsRegionMotif * pRegion = (nsRegionMotif *)&aRegion; - - ::XIntersectRegion(mRegion, pRegion->mRegion, mRegion); - - SetRegionType(); -} - -void nsRegionMotif :: Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) -{ - Region tRegion = CreateRectRegion(aX, aY, aWidth, aHeight); - - ::XIntersectRegion(mRegion, tRegion, mRegion); - - ::XDestroyRegion(tRegion); - - SetRegionType(); - -} - -void nsRegionMotif :: Union(const nsIRegion &aRegion) -{ - nsRegionMotif * pRegion = (nsRegionMotif *)&aRegion; - - ::XUnionRegion(mRegion, pRegion->mRegion, mRegion); - - SetRegionType(); - -} - -void nsRegionMotif :: Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) -{ - - Region tRegion = CreateRectRegion(aX, aY, aWidth, aHeight); - - ::XUnionRegion(mRegion, tRegion, mRegion); - - ::XDestroyRegion(tRegion); - - SetRegionType(); - -} - -void nsRegionMotif :: Subtract(const nsIRegion &aRegion) -{ - nsRegionMotif * pRegion = (nsRegionMotif *)&aRegion; - - ::XSubtractRegion(mRegion, pRegion->mRegion, mRegion); - - SetRegionType(); - -} - -void nsRegionMotif :: Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) -{ - Region tRegion = CreateRectRegion(aX, aY, aWidth, aHeight); - - ::XSubtractRegion(mRegion, tRegion, mRegion); - - ::XDestroyRegion(tRegion); - - SetRegionType(); - -} - -PRBool nsRegionMotif :: IsEmpty(void) -{ - if (mRegionType == eRegionComplexity_empty) - return PR_TRUE; - - return PR_FALSE; -} - -PRBool nsRegionMotif :: IsEqual(const nsIRegion &aRegion) -{ - nsRegionMotif * pRegion = (nsRegionMotif *)&aRegion; - - return(::XEqualRegion(mRegion, pRegion->mRegion)); - -} - -void nsRegionMotif :: GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight) -{ - XRectangle rect; - - ::XClipBox(mRegion, &rect); - - *aX = rect.x; - *aY = rect.y; - *aWidth = rect.width; - *aHeight = rect.height; -} - -void nsRegionMotif :: Offset(PRInt32 aXOffset, PRInt32 aYOffset) -{ - ::XOffsetRegion(mRegion, aXOffset, aYOffset); -} - -PRBool nsRegionMotif :: ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) -{ - PRInt32 containment; - - containment = ::XRectInRegion(mRegion, aX, aY, aWidth, aHeight); - - if (containment == RectangleIn) - return PR_TRUE; - else - return PR_FALSE; - -} - - -NS_IMETHODIMP nsRegionMotif :: GetRects(nsRegionRectSet **aRects) -{ - return NS_OK; -} - -NS_IMETHODIMP nsRegionMotif :: FreeRects(nsRegionRectSet *aRects) -{ - return NS_OK; -} - -NS_IMETHODIMP nsRegionMotif :: GetNativeRegion(void *&aRegion) const -{ - aRegion = (void *)mRegion; - return NS_OK; -} - -NS_IMETHODIMP nsRegionMotif :: GetRegionComplexity(nsRegionComplexity &aComplexity) const -{ - aComplexity = mRegionType; - return NS_OK; -} - -void nsRegionMotif :: SetRegionType() -{ - if (::XEmptyRegion(mRegion) == True) - mRegionType = eRegionComplexity_empty; - else - mRegionType = eRegionComplexity_rect ; -} - -void nsRegionMotif :: SetRegionEmpty() -{ - ::XDestroyRegion(mRegion); - mRegion = ::XCreateRegion(); -} - -Region nsRegionMotif :: CreateRectRegion(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) -{ - Region r = ::XCreateRegion(); - - XRectangle xrect; - - xrect.x = aX; - xrect.y = aY; - xrect.width = aWidth; - xrect.height = aHeight; - - ::XUnionRectWithRegion(&xrect, r, r); - - return (r); -} - - - - - - - - diff --git a/gfx/src/motif/nsRegionMotif.h b/gfx/src/motif/nsRegionMotif.h deleted file mode 100644 index b4bd947d9db9..000000000000 --- a/gfx/src/motif/nsRegionMotif.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsRegionMotif_h___ -#define nsRegionMotif_h___ - -#include "nsIRegion.h" - -#include "X11/Xlib.h" -#include "X11/Xutil.h" - - -class nsRegionMotif : public nsIRegion -{ -public: - nsRegionMotif(); - virtual ~nsRegionMotif(); - - NS_DECL_ISUPPORTS - - virtual nsresult Init(); - - virtual void SetTo(const nsIRegion &aRegion); - virtual void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight); - virtual void Intersect(const nsIRegion &aRegion); - virtual void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight); - virtual void Union(const nsIRegion &aRegion); - virtual void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight); - virtual void Subtract(const nsIRegion &aRegion); - virtual void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight); - virtual PRBool IsEmpty(void); - virtual PRBool IsEqual(const nsIRegion &aRegion); - virtual void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight); - virtual void Offset(PRInt32 aXOffset, PRInt32 aYOffset); - virtual PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight); - NS_IMETHOD GetRects(nsRegionRectSet **aRects); - NS_IMETHOD FreeRects(nsRegionRectSet *aRects); - NS_IMETHOD GetNativeRegion(void *&aRegion) const; - NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const; - NS_IMETHOD GetNumRects(PRUint32 *aRects) const { *aRects = 0; return NS_OK; } - -private: - Region mRegion; - nsRegionComplexity mRegionType; - -private: - virtual void SetRegionType(); - virtual void SetRegionEmpty(); - virtual Region CreateRectRegion(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight); - -}; - -#endif // nsRegionMotif_h___ diff --git a/gfx/src/motif/nsRenderingContextMotif.cpp b/gfx/src/motif/nsRenderingContextMotif.cpp deleted file mode 100644 index d2c78632da32..000000000000 --- a/gfx/src/motif/nsRenderingContextMotif.cpp +++ /dev/null @@ -1,1505 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "xp_core.h" //this is a hack to get it to build. MMP -#include "nsRenderingContextMotif.h" -#include "nsDeviceContextMotif.h" - -#include -#include "nspr.h" - -#include "nsRegionMotif.h" -#include "nsGfxCIID.h" - -#include -#include - -/* - Some Implementation Notes - - REGIONS: Regions are clipping rects associated with a GC. Since - multiple Drawable's can and do share GC's (they are hardware cached) - In order to select clip rect's into GC's, they must be writeable. Thus, - any consumer of the 'gfx' library must assume that GC's created by them - will be modified in gfx. - - */ - -class GraphicsState -{ -public: - GraphicsState(); - ~GraphicsState(); - - nsTransform2D *mMatrix; - nsRect mLocalClip; - Region mClipRegion; - nscolor mColor; - nsLineStyle mLineStyle; - nsIFontMetrics *mFontMetrics; - Font mFont; -}; - -GraphicsState :: GraphicsState() -{ - mMatrix = nsnull; - mLocalClip.x = mLocalClip.y = mLocalClip.width = mLocalClip.height = 0; - mClipRegion = nsnull; - mColor = NS_RGB(0, 0, 0); - mLineStyle = nsLineStyle_kSolid; - mFontMetrics = nsnull; - mFont = nsnull; -} - -GraphicsState :: ~GraphicsState() -{ - mFont = nsnull; -} - -nsRenderingContextMotif :: nsRenderingContextMotif() -{ - NS_INIT_REFCNT(); - - mFontMetrics = nsnull ; - mContext = nsnull ; - mFrontBuffer = nsnull ; - mRenderingSurface = nsnull ; - mCurrentColor = 0; - mCurrentLineStyle = nsLineStyle_kSolid; - mTMatrix = nsnull; - mP2T = 1.0f; - mStateCache = new nsVoidArray(); - mRegion = nsnull; - mCurrFontHandle = 0; - PushState(); - -#ifdef MITSHM - mHasSharedMemory = PR_FALSE; - mSupportsSharedPixmaps = PR_FALSE; -#endif - -} - -nsRenderingContextMotif :: ~nsRenderingContextMotif() -{ - if (mRegion) { - ::XDestroyRegion(mRegion); - mRegion = nsnull; - } - - mTMatrix = nsnull; - - // Destroy the State Machine - if (nsnull != mStateCache) - { - PRInt32 cnt = mStateCache->Count(); - - while (--cnt >= 0) - { - GraphicsState *state = (GraphicsState *)mStateCache->ElementAt(cnt); - mStateCache->RemoveElementAt(cnt); - - if (nsnull != state) - delete state; - } - - delete mStateCache; - mStateCache = nsnull; - } - - // Destroy the front buffer and it's GC if one was allocated for it - if (nsnull != mFrontBuffer) { - delete mFrontBuffer; - } - - NS_IF_RELEASE(mFontMetrics); - NS_IF_RELEASE(mContext); - - if (nsnull != mDrawStringBuf) { - PR_Free(mDrawStringBuf); - } - -} - -NS_IMPL_ISUPPORTS1(nsRenderingContextMotif, nsIRenderingContext) - -NS_IMETHODIMP -nsRenderingContextMotif :: Init(nsIDeviceContext* aContext, - nsIWidget *aWindow) -{ - - if (nsnull == aWindow->GetNativeData(NS_NATIVE_WINDOW)) - return NS_ERROR_NOT_INITIALIZED; - - mContext = aContext; - NS_IF_ADDREF(mContext); - - mRenderingSurface = new nsDrawingSurfaceMotif(); - -#ifdef MITSHM - mRenderingSurface->shmImage = nsnull; -#endif - - mRenderingSurface->display = (Display *)aWindow->GetNativeData(NS_NATIVE_DISPLAY); - mRenderingSurface->drawable = (Drawable)aWindow->GetNativeData(NS_NATIVE_WINDOW); - mRenderingSurface->gc = (GC)aWindow->GetNativeData(NS_NATIVE_GRAPHIC); - - XWindowAttributes wa; - - ::XGetWindowAttributes(mRenderingSurface->display, - mRenderingSurface->drawable, - &wa); - - mRenderingSurface->visual = wa.visual; - mRenderingSurface->depth = wa.depth; - - mFrontBuffer = mRenderingSurface; - - return (CommonInit()); -} - -NS_IMETHODIMP -nsRenderingContextMotif :: Init(nsIDeviceContext* aContext, - nsDrawingSurface aSurface) -{ - - mContext = aContext; - NS_IF_ADDREF(mContext); - - mRenderingSurface = (nsDrawingSurfaceMotif *) aSurface; - - return (CommonInit()); -} - -NS_IMETHODIMP nsRenderingContextMotif :: CommonInit() -{ - -#ifdef MITSHM - PRInt32 shmMajor, shmMinor ; -#endif - - ((nsDeviceContextMotif *)mContext)->SetDrawingSurface(mRenderingSurface); - ((nsDeviceContextMotif *)mContext)->InstallColormap(); - - mContext->GetDevUnitsToAppUnits(mP2T); - float app2dev; - mContext->GetAppUnitsToDevUnits(app2dev); - mTMatrix->AddScale(app2dev, app2dev); - -#ifdef MITSHM - - // We need to query the extension first using straight XLib since - // the Shared memory invocation prints an error message to stdout - - PRInt32 maj, evt, err; - - if (::XQueryExtension(mRenderingSurface->display, - "MIT-SHM", - &maj, &evt, &err) == True) { - - if (XShmQueryVersion(mRenderingSurface->display, - &shmMajor, - &shmMinor, - &mSupportsSharedPixmaps) != 0) { - - mHasSharedMemory = PR_TRUE; - mRenderingSurface->shmImage = nsnull; - mRenderingSurface->shmInfo.shmaddr = nsnull; - } - } -#endif - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: LockDrawingSurface(PRInt32 aX, PRInt32 aY, - PRUint32 aWidth, PRUint32 aHeight, - void **aBits, PRInt32 *aStride, - PRInt32 *aWidthBytes, PRUint32 aFlags) -{ - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: UnlockDrawingSurface(void) -{ - return NS_OK; -} - -NS_IMETHODIMP -nsRenderingContextMotif :: SelectOffScreenDrawingSurface(nsDrawingSurface aSurface) -{ - if (nsnull == aSurface) - mRenderingSurface = mFrontBuffer; - else - mRenderingSurface = (nsDrawingSurfaceMotif *)aSurface; - - return NS_OK; -} - -NS_IMETHODIMP -nsRenderingContextMotif :: GetDrawingSurface(nsDrawingSurface *aSurface) -{ - *aSurface = mRenderingSurface; - return NS_OK; -} - -NS_IMETHODIMP -nsRenderingContextMotif::GetHints(PRUint32& aResult) -{ - PRUint32 result = 0; - - // Most X servers implement 8 bit text rendering alot faster than - // XChar2b rendering. In addition, we can avoid the PRUnichar to - // XChar2b conversion. So we set this bit... - result |= NS_RENDERING_HINT_FAST_8BIT_TEXT; - - // XXX see if we are rendering to the local display or to a remote - // dispaly and set the NS_RENDERING_HINT_REMOTE_RENDERING accordingly - - aResult = result; - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: Reset(void) -{ - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: GetDeviceContext(nsIDeviceContext *&aContext) -{ - NS_IF_ADDREF(mContext); - aContext = mContext; - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: PushState(void) -{ - nsRect rect; - - GraphicsState * state = new GraphicsState(); - - // Push into this state object, add to vector - if(state) { - state->mMatrix = mTMatrix; - - mStateCache->AppendElement(state); - - if (nsnull == mTMatrix) - mTMatrix = new nsTransform2D(); - else - mTMatrix = new nsTransform2D(mTMatrix); - - PRBool clipState; - GetClipRect(state->mLocalClip, clipState); - - state->mClipRegion = mRegion; - } - else return NS_ERROR_OUT_OF_MEMORY; - - if (nsnull != state->mClipRegion) { - mRegion = ::XCreateRegion(); - - XRectangle xrect; - - xrect.x = state->mLocalClip.x; - xrect.y = state->mLocalClip.y; - xrect.width = state->mLocalClip.width; - xrect.height = state->mLocalClip.height; - - ::XUnionRectWithRegion(&xrect, mRegion, mRegion); - } - - state->mColor = mCurrentColor; - state->mLineStyle = mCurrentLineStyle; - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: PopState(PRBool &aClipEmpty) -{ - PRBool bEmpty = PR_FALSE; - - PRUint32 cnt = mStateCache->Count(); - GraphicsState * state; - - if (cnt > 0) { - state = (GraphicsState *)mStateCache->ElementAt(cnt - 1); - mStateCache->RemoveElementAt(cnt - 1); - - // Assign all local attributes from the state object just popped - if (mTMatrix) - delete mTMatrix; - mTMatrix = state->mMatrix; - - if (nsnull != mRegion) - ::XDestroyRegion(mRegion); - - mRegion = state->mClipRegion; - - if (nsnull != mRegion && ::XEmptyRegion(mRegion) == True){ - bEmpty = PR_TRUE; - }else{ - - // Select in the old region. We probably want to set a dirty flag and only - // do this IFF we need to draw before the next Pop. We'd need to check the - // state flag on every draw operation. - if (nsnull != mRegion) - ::XSetRegion(mRenderingSurface->display, - mRenderingSurface->gc, - mRegion); - } - - if (state->mColor != mCurrentColor) - SetColor(state->mColor); - - if (state->mLineStyle != mCurrentLineStyle) - SetLineStyle(state->mLineStyle); - - - // Delete this graphics state object - delete state; - } - - aClipEmpty = bEmpty; - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: IsVisibleRect(const nsRect& aRect, PRBool &aVisible) -{ - aVisible = PR_TRUE; - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: SetClipRectInPixels(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty) -{ - PRBool bEmpty = PR_FALSE; - - nsRect trect = aRect; - - XRectangle xrect; - - xrect.x = trect.x; - xrect.y = trect.y; - xrect.width = trect.width; - xrect.height = trect.height; - - Region a = ::XCreateRegion(); - ::XUnionRectWithRegion(&xrect, a, a); - - if (aCombine == nsClipCombine_kIntersect) - { - Region tRegion = ::XCreateRegion(); - - if (nsnull != mRegion) { - ::XIntersectRegion(a, mRegion, tRegion); - ::XDestroyRegion(mRegion); - ::XDestroyRegion(a); - mRegion = tRegion; - } else { - ::XDestroyRegion(tRegion); - mRegion = a; - } - - } - else if (aCombine == nsClipCombine_kUnion) - { - if (nsnull != mRegion) { - Region tRegion = ::XCreateRegion(); - ::XUnionRegion(a, mRegion, tRegion); - ::XDestroyRegion(mRegion); - ::XDestroyRegion(a); - mRegion = tRegion; - } else { - mRegion = a; - } - - } - else if (aCombine == nsClipCombine_kSubtract) - { - - if (nsnull != mRegion) { - - Region tRegion = ::XCreateRegion(); - ::XSubtractRegion(mRegion, a, tRegion); - ::XDestroyRegion(mRegion); - ::XDestroyRegion(a); - mRegion = tRegion; - - } else { - mRegion = a; - } - - } - else if (aCombine == nsClipCombine_kReplace) - { - - if (nsnull != mRegion) - ::XDestroyRegion(mRegion); - - mRegion = a; - - } - else - NS_ASSERTION(PR_FALSE, "illegal clip combination"); - - if (::XEmptyRegion(mRegion) == True) { - - bEmpty = PR_TRUE; - ::XSetClipMask(mRenderingSurface->display, - mRenderingSurface->gc, - None); - - } else { - - ::XSetRegion(mRenderingSurface->display, - mRenderingSurface->gc, - mRegion); - - } - - aClipEmpty = bEmpty; - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty) -{ - nsRect trect = aRect; - - mTMatrix->TransformCoord(&trect.x, &trect.y, - &trect.width, &trect.height); - return SetClipRectInPixels(trect, aCombine, aClipEmpty); -} - -NS_IMETHODIMP nsRenderingContextMotif :: GetClipRect(nsRect &aRect, PRBool &aClipValid) -{ - if (mRegion != nsnull) { - XRectangle xrect; - ::XClipBox(mRegion, &xrect); - aRect.SetRect(xrect.x, xrect.y, xrect.width, xrect.height); - } else { - aRect.SetRect(0,0,0,0); - aClipValid = PR_TRUE; - return NS_OK; - } - - if (::XEmptyRegion(mRegion) == True) - aClipValid = PR_TRUE; - else - aClipValid = PR_FALSE; - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty) -{ - nsRect rect; - XRectangle xrect; - Region xregion; - - aRegion.GetNativeRegion((void *&)xregion); - - ::XClipBox(xregion, &xrect); - - rect.x = xrect.x; - rect.y = xrect.y; - rect.width = xrect.width; - rect.height = xrect.height; - - SetClipRectInPixels(rect, aCombine, aClipEmpty); - - if (::XEmptyRegion(mRegion) == True) - aClipEmpty = PR_TRUE; - else - aClipEmpty = PR_FALSE; - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: GetClipRegion(nsIRegion **aRegion) -{ -// nsIRegion * pRegion ; - -// static NS_DEFINE_IID(kCRegionCID, NS_REGION_CID); -// static NS_DEFINE_IID(kIRegionIID, NS_IREGION_IID); - -// nsresult rv = nsComponentManager::CreateInstance(kCRegionCID, -// nsnull, -// kIRegionIID, -// (void **)aRegion); - -// if (NS_OK == rv) { -// nsRect rect; -// PRBool clipState; -// pRegion = (nsIRegion *)&aRegion; -// pRegion->Init(); -// GetClipRect(rect, clipState); -// pRegion->Union(rect.x,rect.y,rect.width,rect.height); -// } - -// return NS_OK; - - nsresult rv = NS_OK; - - NS_ASSERTION(!(nsnull == aRegion), "no region ptr"); - - if (nsnull == *aRegion) - { - nsRegionMotif *rgn = new nsRegionMotif(); - - if (nsnull != rgn) - { - NS_ADDREF(rgn); - - rv = rgn->Init(); - - if (NS_OK == rv) - *aRegion = rgn; - else - NS_RELEASE(rgn); - } - else - rv = NS_ERROR_OUT_OF_MEMORY; - } - -// if (rv == NS_OK) -// (*aRegion)->SetTo(*mClipRegion); - -// if (rv == NS_OK) -// (*aRegion)->SetTo(*mClipRegion); - - return rv; -} - -/** - * Fills in |aRegion| with a copy of the current clip region. - */ -NS_IMETHODIMP nsRenderingContextMotif::CopyClipRegion(nsIRegion &aRegion) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP nsRenderingContextMotif :: SetColor(nscolor aColor) -{ - if (nsnull == mContext) - return NS_ERROR_FAILURE; - - XGCValues values; - mContext->ConvertPixel(aColor, mCurrentColor); - - values.foreground = mCurrentColor; - values.background = mCurrentColor; - - ::XChangeGC(mRenderingSurface->display, - mRenderingSurface->gc, - GCForeground | GCBackground, - &values); - - mCurrentColor = aColor; - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: GetColor(nscolor &aColor) const -{ - aColor = mCurrentColor; - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: SetLineStyle(nsLineStyle aLineStyle) -{ - if (aLineStyle != mCurrentLineStyle) - { - XGCValues values ; - - switch(aLineStyle) - { - case nsLineStyle_kSolid: - values.line_style = LineSolid; - ::XChangeGC(mRenderingSurface->display, - mRenderingSurface->gc, - GCLineStyle, - &values); - break; - - case nsLineStyle_kDashed: { - static char dashed[2] = {4,4}; - - ::XSetDashes(mRenderingSurface->display, - mRenderingSurface->gc, - 0, dashed, 2); - } break; - - case nsLineStyle_kDotted: { - static char dotted[2] = {3,1}; - - ::XSetDashes(mRenderingSurface->display, - mRenderingSurface->gc, - 0, dotted, 2); - }break; - - default: - break; - - } - - mCurrentLineStyle = aLineStyle ; - } - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: GetLineStyle(nsLineStyle &aLineStyle) -{ - aLineStyle = mCurrentLineStyle; - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: SetFont(const nsFont& aFont) -{ - NS_IF_RELEASE(mFontMetrics); - mContext->GetMetricsFor(aFont, mFontMetrics); - - if (mFontMetrics) - { -// mCurrFontHandle = ::XLoadFont(mRenderingSurface->display, (char *)mFontMetrics->GetFontHandle()); - nsFontHandle fontHandle; - mFontMetrics->GetFontHandle(fontHandle); - mCurrFontHandle = (Font)fontHandle; - - ::XSetFont(mRenderingSurface->display, - mRenderingSurface->gc, - mCurrFontHandle); - -// ::XFlushGC(mRenderingSurface->display, -// mRenderingSurface->gc); - } - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: SetFont(nsIFontMetrics *aFontMetrics) -{ - NS_IF_RELEASE(mFontMetrics); - mFontMetrics = aFontMetrics; - NS_IF_ADDREF(mFontMetrics); - - //XXX this code and that in SetFont() above need to be factored - //into a function. MMP. - - if (mFontMetrics) - { -// mCurrFontHandle = ::XLoadFont(mRenderingSurface->display, (char *)mFontMetrics->GetFontHandle()); - nsFontHandle fontHandle; - mFontMetrics->GetFontHandle(fontHandle); - mCurrFontHandle = (Font)fontHandle; - - ::XSetFont(mRenderingSurface->display, - mRenderingSurface->gc, - mCurrFontHandle); - -// ::XFlushGC(mRenderingSurface->display, -// mRenderingSurface->gc); - } - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: GetFontMetrics(nsIFontMetrics *&aFontMetrics) -{ - NS_IF_ADDREF(mFontMetrics); - aFontMetrics = mFontMetrics; - - return NS_OK; -} - -// add the passed in translation to the current translation -NS_IMETHODIMP nsRenderingContextMotif :: Translate(nscoord aX, nscoord aY) -{ - mTMatrix->AddTranslation((float)aX,(float)aY); - return NS_OK; -} - -// add the passed in scale to the current scale -NS_IMETHODIMP nsRenderingContextMotif :: Scale(float aSx, float aSy) -{ - mTMatrix->AddScale(aSx, aSy); - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: GetCurrentTransform(nsTransform2D *&aTransform) -{ - aTransform = mTMatrix; - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface) -{ - if (nsnull == mRenderingSurface) { - aSurface = nsnull; - return NS_ERROR_FAILURE; - } - - // Must make sure this code never gets called when nsRenderingSurface is nsnull - PRUint32 depth = DefaultDepth(mRenderingSurface->display, - DefaultScreen(mRenderingSurface->display)); - Pixmap p = nsnull; - - PRInt32 w = 200, h = 200; // Use some reasonable defaults - - if (nsnull != aBounds) { - w = aBounds->width; - h = aBounds->height; - } - -#ifdef MITSHM - - if (mSupportsSharedPixmaps == PR_TRUE) { - - mRenderingSurface->shmImage = - ::XShmCreateImage(mRenderingSurface->display, - mRenderingSurface->visual, - depth, - XShmPixmapFormat(mRenderingSurface->display), - 0, - &(mRenderingSurface->shmInfo), - w,h); - - mRenderingSurface->shmInfo.shmid = - shmget(IPC_PRIVATE, - mRenderingSurface->shmImage->bytes_per_line * - mRenderingSurface->shmImage->height, - IPC_CREAT | 0777); - - if (mRenderingSurface->shmInfo.shmid >= 0) { - - mRenderingSurface->shmInfo.shmaddr = - (char *) shmat(mRenderingSurface->shmInfo.shmid, 0, 0); - - if (mRenderingSurface->shmInfo.shmaddr != ((char*)-1)) { - - mRenderingSurface->shmImage->data = mRenderingSurface->shmInfo.shmaddr; - mRenderingSurface->shmInfo.readOnly = False; - XShmAttach(mRenderingSurface->display, &(mRenderingSurface->shmInfo)); - - p = ::XShmCreatePixmap(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->shmInfo.shmaddr, - &(mRenderingSurface->shmInfo), - mRenderingSurface->shmImage->width, - mRenderingSurface->shmImage->height, - mRenderingSurface->shmImage->depth); - - ::XShmGetImage(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->shmImage, - 0,0,AllPlanes); - } - } - } - - // If we failed along the way, just fall back on - // old sockets pixmap mechanism.... - if (nsnull == p) { - - if (mRenderingSurface->shmInfo.shmaddr != nsnull) { - - if (mRenderingSurface->shmInfo.shmaddr != ((char*)-1)) - shmdt(mRenderingSurface->shmInfo.shmaddr); - - shmctl(mRenderingSurface->shmInfo.shmid, IPC_RMID,0); - - ::XShmDetach(mRenderingSurface->display, - &(mRenderingSurface->shmInfo)); - } - - if (mRenderingSurface->shmImage != nsnull) - XDestroyImage(mRenderingSurface->shmImage); - - mRenderingSurface->shmImage = nsnull; - mRenderingSurface->shmInfo.shmaddr = nsnull; - - } - -#endif - - if (nsnull == p) - p = ::XCreatePixmap(mRenderingSurface->display, - mRenderingSurface->drawable, - w, h, depth); - - - nsDrawingSurfaceMotif * surface = new nsDrawingSurfaceMotif(); - - if(surface) { - surface->drawable = p ; - surface->display = mRenderingSurface->display; - surface->gc = mRenderingSurface->gc; - surface->visual = mRenderingSurface->visual; - surface->depth = mRenderingSurface->depth; - -#ifdef MITSHM - - surface->shmInfo = mRenderingSurface->shmInfo; - surface->shmImage = mRenderingSurface->shmImage; - mRenderingSurface->shmInfo.shmaddr = nsnull; - mRenderingSurface->shmImage = nsnull; - -#endif - } - else { - aSurface = nsnull; - return NS_ERROR_OUT_OF_MEMORY; - } - aSurface = (nsDrawingSurface)surface; - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: DestroyDrawingSurface(nsDrawingSurface aDS) -{ - nsDrawingSurfaceMotif * surface = (nsDrawingSurfaceMotif *) aDS; - -#ifdef MITSHM - if (surface->shmImage != nsnull) { - - shmdt(surface->shmInfo.shmaddr); - shmctl(surface->shmInfo.shmid, IPC_RMID,0); - ::XShmDetach(surface->display, &(surface->shmInfo)); - XDestroyImage(surface->shmImage); - - surface->shmImage = nsnull; - surface->shmInfo.shmaddr = nsnull; - } -#endif - - ::XFreePixmap(surface->display, surface->drawable); - - if (mRenderingSurface == surface) - mRenderingSurface = nsnull; - - delete aDS; - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1) -{ - if (nsnull == mTMatrix || nsnull == mRenderingSurface) { - return NS_ERROR_FAILURE; - } - mTMatrix->TransformCoord(&aX0,&aY0); - mTMatrix->TransformCoord(&aX1,&aY1); - - ::XDrawLine(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - aX0, aY0, aX1, aY1); - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints) -{ - if (nsnull == mTMatrix || nsnull == mRenderingSurface) { - return NS_ERROR_FAILURE; - } - PRUint32 i ; - XPoint * xpoints; - XPoint * thispoint; - - xpoints = (XPoint *) PR_Malloc(sizeof(XPoint) * aNumPoints); - - for (i = 0; i < aNumPoints; i++){ - thispoint = (xpoints+i); - thispoint->x = aPoints[i].x; - thispoint->y = aPoints[i].y; - mTMatrix->TransformCoord((PRInt32*)&thispoint->x,(PRInt32*)&thispoint->y); - } - - ::XDrawLines(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - xpoints, aNumPoints, CoordModeOrigin); - - PR_Free((void *)xpoints); - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: DrawRect(const nsRect& aRect) -{ - return DrawRect(aRect.x, aRect.y, aRect.width, aRect.height); -} - -NS_IMETHODIMP nsRenderingContextMotif :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) -{ - if (nsnull == mTMatrix || nsnull == mRenderingSurface) { - return NS_ERROR_FAILURE; - } - - nscoord x,y,w,h; - - x = aX; - y = aY; - w = aWidth; - h = aHeight; - - mTMatrix->TransformCoord(&x,&y,&w,&h); - - ::XDrawRectangle(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x,y,w,h); - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: FillRect(const nsRect& aRect) -{ - return FillRect(aRect.x, aRect.y, aRect.width, aRect.height); -} - -NS_IMETHODIMP nsRenderingContextMotif :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) -{ - if (nsnull == mTMatrix || nsnull == mRenderingSurface) { - return NS_ERROR_FAILURE; - } - nscoord x,y,w,h; - x = aX; - y = aY; - w = aWidth; - h = aHeight; - - mTMatrix->TransformCoord(&x,&y,&w,&h); - ::XFillRectangle(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x,y,w,h); - - return NS_OK; -} - -NS_IMETHODIMP -nsRenderingContextMotif :: InvertRect(const nsRect& aRect) -{ - NS_NOTYETIMPLEMENTED("nsRenderingContextMotif::InvertRect"); - - return NS_OK; -} - -NS_IMETHODIMP -nsRenderingContextMotif :: InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) -{ - NS_NOTYETIMPLEMENTED("nsRenderingContextMotif::InvertRect"); - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif::DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) -{ - if (nsnull == mTMatrix || nsnull == mRenderingSurface) { - return NS_ERROR_FAILURE; - } - PRUint32 i ; - XPoint * xpoints; - XPoint * thispoint; - - xpoints = (XPoint *) PR_Malloc(sizeof(XPoint) * aNumPoints); - - for (i = 0; i < aNumPoints; i++){ - thispoint = (xpoints+i); - thispoint->x = aPoints[i].x; - thispoint->y = aPoints[i].y; - mTMatrix->TransformCoord((PRInt32*)&thispoint->x,(PRInt32*)&thispoint->y); - } - - ::XDrawLines(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - xpoints, aNumPoints, CoordModeOrigin); - - PR_Free((void *)xpoints); - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif::FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) -{ - if (nsnull == mTMatrix || nsnull == mRenderingSurface) { - return NS_ERROR_FAILURE; - } - PRUint32 i ; - XPoint * xpoints; - XPoint * thispoint; - nscoord x,y; - - xpoints = (XPoint *) PR_Malloc(sizeof(XPoint) * aNumPoints); - - for (i = 0; i < aNumPoints; i++){ - thispoint = (xpoints+i); - x = aPoints[i].x; - y = aPoints[i].y; - mTMatrix->TransformCoord(&x,&y); - thispoint->x = x; - thispoint->y = y; - } - - ::XFillPolygon(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - xpoints, aNumPoints, Convex, CoordModeOrigin); - - PR_Free((void *)xpoints); - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: DrawEllipse(const nsRect& aRect) -{ - return DrawEllipse(aRect.x, aRect.y, aRect.width, aRect.height); -} - -NS_IMETHODIMP nsRenderingContextMotif :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) -{ - if (nsnull == mTMatrix || nsnull == mRenderingSurface) { - return NS_ERROR_FAILURE; - } - nscoord x,y,w,h; - - x = aX; - y = aY; - w = aWidth; - h = aHeight; - - mTMatrix->TransformCoord(&x,&y,&w,&h); - - ::XDrawArc(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x,y,w,h, 0, 360 * 64); - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: FillEllipse(const nsRect& aRect) -{ - return FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height); -} - -NS_IMETHODIMP nsRenderingContextMotif :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) -{ - if (nsnull == mTMatrix || nsnull == mRenderingSurface) { - return NS_ERROR_FAILURE; - } - nscoord x,y,w,h; - - x = aX; - y = aY; - w = aWidth; - h = aHeight; - - mTMatrix->TransformCoord(&x,&y,&w,&h); - - ::XFillArc(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x,y,w,h, 0, 360 * 64); - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: DrawArc(const nsRect& aRect, - float aStartAngle, float aEndAngle) -{ - return DrawArc(aRect.x,aRect.y,aRect.width,aRect.height,aStartAngle,aEndAngle); -} - -NS_IMETHODIMP nsRenderingContextMotif :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, - float aStartAngle, float aEndAngle) -{ - if (nsnull == mTMatrix || nsnull == mRenderingSurface) { - return NS_ERROR_FAILURE; - } - nscoord x,y,w,h; - - x = aX; - y = aY; - w = aWidth; - h = aHeight; - - mTMatrix->TransformCoord(&x,&y,&w,&h); - - ::XDrawArc(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x,y,w,h, NSToIntRound(aStartAngle * 64.0f), - NSToIntRound(aEndAngle * 64.0f)); - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: FillArc(const nsRect& aRect, - float aStartAngle, float aEndAngle) -{ - return FillArc(aRect.x, aRect.y, aRect.width, aRect.height, aStartAngle, aEndAngle); -} - -NS_IMETHODIMP nsRenderingContextMotif :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, - float aStartAngle, float aEndAngle) -{ - if (nsnull == mTMatrix || nsnull == mRenderingSurface) { - return NS_ERROR_FAILURE; - } - nscoord x,y,w,h; - - x = aX; - y = aY; - w = aWidth; - h = aHeight; - - mTMatrix->TransformCoord(&x,&y,&w,&h); - - ::XFillArc(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x,y,w,h, NSToIntRound(aStartAngle * 64.0f), - NSToIntRound(aEndAngle * 64.0f)); - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(char ch, nscoord &aWidth) -{ - char buf[1]; - buf[0] = ch; - return GetWidth(buf, 1, aWidth); -} - -NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(PRUnichar ch, nscoord &aWidth, PRInt32 *aFontID) -{ - PRUnichar buf[1]; - buf[0] = ch; - return GetWidth(buf, 1, aWidth, aFontID); -} - -NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(const nsString& aString, nscoord &aWidth, PRInt32 *aFontID) -{ - return GetWidth(aString.get(), aString.Length(), aWidth, aFontID); -} - -NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(const char *aString, nscoord &aWidth) -{ - return GetWidth(aString, strlen(aString), aWidth); -} - -NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(const char *aString, - PRUint32 aLength, nscoord &aWidth) -{ - PRInt32 rc; - XFontStruct *font; - - font = ::XQueryFont(mRenderingSurface->display, (Font)mCurrFontHandle); - rc = (PRInt32) ::XTextWidth(font, aString, aLength); - aWidth = nscoord(rc * mP2T); - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif :: GetWidth(const PRUnichar *aString, - PRUint32 aLength, - nscoord &aWidth, PRInt32 *aFontID) -{ - XChar2b * thischar ; - PRUint16 aunichar; - nscoord width ; - PRUint32 i ; - PRUint32 desiredSize = sizeof(XChar2b) * aLength; - XFontStruct *font; - - // Make the temporary buffer larger if needed. - if (nsnull == mDrawStringBuf) { - mDrawStringBuf = (XChar2b *) PR_Malloc(desiredSize); - mDrawStringSize = aLength; - } - else { - if (mDrawStringSize < PRInt32(aLength)) { - mDrawStringBuf = (XChar2b *) PR_Realloc(mDrawStringBuf, desiredSize); - mDrawStringSize = aLength; - } - } - - // Translate the unicode data into XChar2b's - XChar2b* xc = mDrawStringBuf; - XChar2b* end = xc + aLength; - while (xc < end) { - PRUnichar ch = *aString++; - xc->byte2 = (ch & 0xff); - xc->byte1 = (ch & 0xff00) >> 8; - xc++; - } - - font = ::XQueryFont(mRenderingSurface->display, (Font)mCurrFontHandle); - width = ::XTextWidth16(font, mDrawStringBuf, aLength); - aWidth = nscoord(width * mP2T); - - if (nsnull != aFontID) - *aFontID = 0; - - return NS_OK; -} - -NS_IMETHODIMP -nsRenderingContextMotif :: DrawString(const char *aString, PRUint32 aLength, - nscoord aX, nscoord aY, - const nscoord* aSpacing) -{ - nscoord x = aX; - nscoord y = aY; - - // Substract xFontStruct ascent since drawing specifies baseline - if (mFontMetrics) { - mFontMetrics->GetMaxAscent(y); - y+=aY; - } - - mTMatrix->TransformCoord(&x,&y); - - ::XDrawString(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x, y, aString, aLength); - -#if 0 - //this code no longer needs to be here. another routine will - //take it places that does this stuff and this code will need - //to be there. MMP - if (mFontMetrics) - { - nsFont *font; - mFontMetrics->GetFont(font); - PRUint8 deco = font->decorations; - - if (deco & NS_FONT_DECORATION_OVERLINE) - DrawLine(aX, aY, aX + aWidth, aY); - - if (deco & NS_FONT_DECORATION_UNDERLINE) - { - nscoord ascent,descent; - - mFontMetrics->GetMaxAscent(ascent); - mFontMetrics->GetMaxDescent(descent); - - DrawLine(aX, aY + ascent + (descent >> 1), - aX + aWidth, aY + ascent + (descent >> 1)); - } - - if (deco & NS_FONT_DECORATION_LINE_THROUGH) - { - nscoord height; - - mFontMetrics->GetHeight(height); - - DrawLine(aX, aY + (height >> 1), aX + aWidth, aY + (height >> 1)); - } - } -#endif - - return NS_OK; -} - -NS_IMETHODIMP -nsRenderingContextMotif :: DrawString(const PRUnichar *aString, PRUint32 aLength, - nscoord aX, nscoord aY, PRInt32 aFontID, - const nscoord* aSpacing) -{ - nscoord x = aX; - nscoord y = aY; - PRUint32 desiredSize = sizeof(XChar2b) * aLength; - - // Substract xFontStruct ascent since drawing specifies baseline - if (mFontMetrics) { - mFontMetrics->GetMaxAscent(y); - y+=aY; - } - - mTMatrix->TransformCoord(&x, &y); - - // Make the temporary buffer larger if needed. - if (nsnull == mDrawStringBuf) { - mDrawStringBuf = (XChar2b *) PR_Malloc(desiredSize); - mDrawStringSize = aLength; - } - else { - if (mDrawStringSize < PRInt32(aLength)) { - mDrawStringBuf = (XChar2b *) PR_Realloc(mDrawStringBuf, desiredSize); - mDrawStringSize = aLength; - } - } - - // Translate the unicode data into XChar2b's - XChar2b* xc = mDrawStringBuf; - XChar2b* end = xc + aLength; - while (xc < end) { - PRUnichar ch = *aString++; - xc->byte2 = (ch & 0xff); - xc->byte1 = (ch & 0xff00) >> 8; - xc++; - } - - ::XDrawString16(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x, y, mDrawStringBuf, aLength); - - return NS_OK; -} - -NS_IMETHODIMP -nsRenderingContextMotif :: DrawString(const nsString& aString, - nscoord aX, nscoord aY, PRInt32 aFontID, - const nscoord* aSpacing) -{ - return DrawString(aString.get(), aString.Length(), aX, aY, aFontID, aSpacing); -} - -NS_IMETHODIMP nsRenderingContextMotif :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY) -{ - nscoord width,height; - width = NSToCoordRound(mP2T * aImage->GetWidth()); - height = NSToCoordRound(mP2T * aImage->GetHeight()); - - return DrawImage(aImage,aX,aY,width,height); -} - -NS_IMETHODIMP nsRenderingContextMotif :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY, - nscoord aWidth, nscoord aHeight) -{ - nsRect tr; - - tr.x = aX; - tr.y = aY; - tr.width = aWidth; - tr.height = aHeight; - - return DrawImage(aImage,tr); -} - -NS_IMETHODIMP nsRenderingContextMotif :: DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect) -{ - nsRect sr,dr; - - sr = aSRect; - mTMatrix ->TransformCoord(&sr.x,&sr.y,&sr.width,&sr.height); - sr.x = aSRect.x; - sr.y a aSRect.y; - mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y); - - dr = aDRect; - mTMatrix->TransformCoord(&dr.x,&dr.y,&dr.width,&dr.height); - - return aImage->Draw(*this,mRenderingSurface,sr.x,sr.y,sr.width,sr.height, - dr.x,dr.y,dr.width,dr.height); -} - -NS_IMETHODIMP nsRenderingContextMotif :: DrawImage(nsIImage *aImage, const nsRect& aRect) -{ - nsRect tr; - - tr = aRect; - mTMatrix->TransformCoord(&tr.x,&tr.y,&tr.width,&tr.height); - - return aImage->Draw(*this,mRenderingSurface,tr.x,tr.y,tr.width,tr.height); -} - -/** --------------------------------------------------- - * See documentation in nsIRenderingContext.h - * @update 3/16/00 dwc - */ -NS_IMETHODIMP -nsRenderingContextMotif::DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1, - nscoord aWidth,nscoord aHeight) -{ - - return NS_OK; -} - - -NS_IMETHODIMP -nsRenderingContextMotif :: CopyOffScreenBits(nsDrawingSurface aSrcSurf, - PRInt32 aSrcX, PRInt32 aSrcY, - const nsRect &aDestBounds, - PRUint32 aCopyFlags) -{ - PRInt32 x = aSrcX; - PRInt32 y = aSrcY; - nsRect drect = aDestBounds; - nsDrawingSurfaceMotif *destsurf; - - if (aCopyFlags & NS_COPYBITS_TO_BACK_BUFFER) - { - NS_ASSERTION(!(nsnull == mRenderingSurface), "no back buffer"); - destsurf = mRenderingSurface; - } - else - destsurf = mFrontBuffer; - - if (aCopyFlags & NS_COPYBITS_XFORM_SOURCE_VALUES) - mTMatrix->TransformCoord(&x, &y); - - if (aCopyFlags & NS_COPYBITS_XFORM_DEST_VALUES) - mTMatrix->TransformCoord(&drect.x, &drect.y, &drect.width, &drect.height); - - //XXX flags are unused. that would seem to mean that there is - //inefficiency somewhere... MMP - - ::XCopyArea(((nsDrawingSurfaceMotif *)aSrcSurf)->display, - ((nsDrawingSurfaceMotif *)aSrcSurf)->drawable, - destsurf->drawable, - ((nsDrawingSurfaceMotif *)aSrcSurf)->gc, - x, y, drect.width, drect.height, - drect.x, drect.y); - - return NS_OK; -} - -NS_IMETHODIMP nsRenderingContextMotif::RetrieveCurrentNativeGraphicData(PRUint32 * ngd) -{ - return NS_OK; -} diff --git a/gfx/src/motif/nsRenderingContextMotif.h b/gfx/src/motif/nsRenderingContextMotif.h deleted file mode 100644 index 6234afc7d88d..000000000000 --- a/gfx/src/motif/nsRenderingContextMotif.h +++ /dev/null @@ -1,218 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsRenderingContextMotif_h___ -#define nsRenderingContextMotif_h___ - -#include "nsIRenderingContext.h" -#include "nsUnitConversion.h" -#include "nsFont.h" -#include "nsIFontMetrics.h" -#include "nsPoint.h" -#include "nsString.h" -#include "nsCRT.h" -#include "nsTransform2D.h" -#include "nsIViewManager.h" -#include "nsIWidget.h" -#include "nsRect.h" -#include "nsImageMotif.h" -#include "nsIDeviceContext.h" -#include "nsVoidArray.h" -#include "nsIRegion.h" -#include "nsDeviceContextMotif.h" - -#include "X11/Xlib.h" -#include "X11/Xutil.h" - -#ifdef MITSHM -#include -#include -#include -#endif - -class GraphicsState; - -class nsRenderingContextMotif : public nsIRenderingContext -{ -public: - nsRenderingContextMotif(); - virtual ~nsRenderingContextMotif(); - - NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW - - NS_DECL_ISUPPORTS - - NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow); - NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface); - - NS_IMETHOD Reset(void); - - NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext); - - NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight, - void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes, - PRUint32 aFlags); - NS_IMETHOD UnlockDrawingSurface(void); - - NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface); - NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface); - NS_IMETHOD GetHints(PRUint32& aResult); - - NS_IMETHOD PushState(void); - NS_IMETHOD PopState(PRBool &aClipEmpty); - - NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aClipEmpty); - - NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty); - NS_IMETHOD CopyClipRegion(nsIRegion &aRegion); - NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipValid); - NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty); - NS_IMETHOD GetClipRegion(nsIRegion **aRegion); - - NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle); - NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle); - - NS_IMETHOD SetColor(nscolor aColor); - NS_IMETHOD GetColor(nscolor &aColor) const; - - NS_IMETHOD SetFont(const nsFont& aFont); - NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics); - - NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics); - - NS_IMETHOD Translate(nscoord aX, nscoord aY); - NS_IMETHOD Scale(float aSx, float aSy); - NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform); - - NS_IMETHOD CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface); - NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS); - - NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1); - NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints); - - NS_IMETHOD DrawRect(const nsRect& aRect); - NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); - - NS_IMETHOD FillRect(const nsRect& aRect); - NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); - - NS_IMETHOD InvertRect(const nsRect& aRect); - NS_IMETHOD InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); - - NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints); - NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints); - - NS_IMETHOD DrawEllipse(const nsRect& aRect); - NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); - NS_IMETHOD FillEllipse(const nsRect& aRect); - NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); - - NS_IMETHOD DrawArc(const nsRect& aRect, - float aStartAngle, float aEndAngle); - NS_IMETHOD DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, - float aStartAngle, float aEndAngle); - NS_IMETHOD FillArc(const nsRect& aRect, - float aStartAngle, float aEndAngle); - NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, - float aStartAngle, float aEndAngle); - - NS_IMETHOD GetWidth(char aC, nscoord &aWidth); - NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth, - PRInt32 *aFontID); - NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth, - PRInt32 *aFontID); - NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth); - NS_IMETHOD GetWidth(const char *aString, PRUint32 aLength, nscoord &aWidth); - NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth, - PRInt32 *aFontID); - - NS_IMETHOD DrawString(const char *aString, PRUint32 aLength, - nscoord aX, nscoord aY, - const nscoord* aSpacing); - NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength, - nscoord aX, nscoord aY, - PRInt32 aFontID, - const nscoord* aSpacing); - NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY, - PRInt32 aFontID, - const nscoord* aSpacing); - - NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY); - NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY, - nscoord aWidth, nscoord aHeight); - NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect); - NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect); - NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1, - nscoord aWidth,nscoord aHeight); - - NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY, - const nsRect &aDestBounds, PRUint32 aCopyFlags); - NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd); - - //locals - NS_IMETHOD CommonInit(); - NS_IMETHOD SetClipRectInPixels(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty); - -protected: - - nscolor mCurrentColor ; - nsTransform2D *mTMatrix; // transform that all the graphics drawn here will obey - float mP2T; - - nsDrawingSurfaceMotif *mRenderingSurface; // Can be a BackBuffer if Selected in - nsDrawingSurfaceMotif *mFrontBuffer; - nsIDeviceContext *mContext; - nsIFontMetrics *mFontMetrics; - Region mRegion; - Font mCurrFontHandle; - XChar2b* mDrawStringBuf; - PRInt32 mDrawStringSize; - nsLineStyle mCurrentLineStyle; - - //state management - nsVoidArray *mStateCache; - -#ifdef MITSHM -private: - PRBool mHasSharedMemory; - PRBool mSupportsSharedPixmaps; -#endif - -}; - -#endif // nsRenderingContextMotif_h___ diff --git a/webshell/embed/xlib/motif/.cvsignore b/webshell/embed/xlib/motif/.cvsignore deleted file mode 100644 index 372eb24dfdb5..000000000000 --- a/webshell/embed/xlib/motif/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -embed_xlib_into_motif diff --git a/webshell/embed/xlib/motif/EmbedMozilla.c b/webshell/embed/xlib/motif/EmbedMozilla.c deleted file mode 100644 index de52d4a59d26..000000000000 --- a/webshell/embed/xlib/motif/EmbedMozilla.c +++ /dev/null @@ -1,216 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include - -#include "EmbedMozilla.h" -#include "EmbedMozillaP.h" - -static XtGeometryResult -GeometryManager(Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply); - -static void -ChangeManaged(Widget w); - -static void CoreRealize (Widget,XtValueMask *,XSetWindowAttributes *); - -static void Resize(Widget w); - - -XmEmbedMozillaClassRec xmEmbedMozillaClassRec = -{ - { -/* core_class fields */ - /* superclass */ (WidgetClass) &xmManagerClassRec, - /* class_name */ "XmEmbedMozilla", - /* widget_size */ sizeof(XmEmbedMozillaRec), - /* class_initialize */ NULL, - /* class_partinit */ NULL /* ClassPartInitialize */, - /* class_inited */ FALSE, - /* initialize */ NULL /* Initialize */, - /* Init hook */ NULL, - CoreRealize, - /* actions */ NULL, - /* num_actions */ 0, - /* resources */ NULL /* resources */, - /* num_resources */ 0 /* XtNumber(resources) */, - /* xrm_class */ NULLQUARK, - /* compress_motion */ TRUE, - /* compress_exposure */ TRUE, - /* compress_enterleave*/ TRUE, - /* visible_interest */ FALSE, - /* destroy */ NULL, - /* resize */ Resize, - /* expose */ XtInheritExpose /* (XtExposeProc) Redisplay */, - /* set_values */ NULL /* (XtSetValuesFunc )SetValues */, - /* set values hook */ NULL, - /* set values almost */ XtInheritSetValuesAlmost, - /* get values hook */ NULL, - /* accept_focus */ NULL, - /* Version */ XtVersion, - /* PRIVATE cb list */ NULL, - /* tm_table */ XtInheritTranslations, - /* query_geometry */ NULL /* QueryProc */, - /* display_accelerator*/ NULL, - /* extension */ NULL, - }, - { -/* composite_class fields */ - /* geometry_mozillar */ GeometryManager /*(XtGeometryHandler )GeometryManager*/, - /* change_mozillad */ ChangeManaged /*(XtWidgetProc) ChangeManaged*/, - /* insert_child */ XtInheritInsertChild /*(XtArgsProc) InsertChild*/, - /* delete_child */ XtInheritDeleteChild, - /* Extension */ NULL, - },{ -/* Constraint class Init */ - NULL, - 0, - 0, - NULL, - NULL, - NULL, - NULL - - }, -/* Mozillar Class */ - { - XmInheritTranslations/*ScrolledWindowXlations*/, /* translations */ - NULL /*get_resources*/, /* get resources */ - 0 /*XtNumber(get_resources)*/, /* num get_resources */ - NULL, /* get_cont_resources */ - 0, /* num_get_cont_resources */ - XmInheritParentProcess, /* parent_process */ - NULL, /* extension */ - }, - - { -/* XmEmbedMozilla class - none */ - /* mumble */ 0 - } -}; - - -WidgetClass xmEmbedMozillaClass = (WidgetClass)&xmEmbedMozillaClassRec; - - -static XtGeometryResult -GeometryManager(Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply) -{ - if (request->request_mode & XtCWQueryOnly) - { - return(XtGeometryYes); - } - - if (request->request_mode & CWX) - { - XtX(w) = request->x; - } - if (request->request_mode & CWY) - { - XtY(w) = request->y; - } - if (request->request_mode & CWWidth) - { - XtWidth(w) = request->width; - } - if (request->request_mode & CWHeight) - { - XtHeight(w) = request->height; - } - if (request->request_mode & CWBorderWidth) - { - XtBorderWidth(w) = request->border_width; - } - - return(XtGeometryYes); -} - - -static void -ChangeManaged(Widget w) -{ - return; -} - -static void Resize (Widget widget) -{ - XmEmbedMozilla em = (XmEmbedMozilla) widget; - -#if 0 - /* Invoke the resize procedure of the superclass. - Probably there's some nominally more portable way to do this - (yeah right, like any of these slot names could possibly change - and have any existing code still work.) - */ - widget->core.widget_class->core_class.superclass->core_class.resize (widget); - - /* Now run our callback (yeah, I should use a real callback, so sue me.) */ - scroller->scroller.resize_hook (widget, scroller->scroller.resize_arg); -#endif - -} - -static void -CoreRealize(Widget w,XtValueMask *mask,XSetWindowAttributes* wa) -{ - XmEmbedMozilla em = (XmEmbedMozilla) w; - - printf("Realize(%s,window = %p\n", - XtName(w), - em->embed_mozilla.embed_window); - - em->core.window = em->embed_mozilla.embed_window; -} -/*----------------------------------------------------------------------*/ - -Widget -XmCreateEmbedMozilla(Widget parent, - Window window, - String name, - Arg * av, - Cardinal ac) -{ - Widget w = XtCreateWidget(name,xmEmbedMozillaClass,parent,av,ac); - - XmEmbedMozilla em = (XmEmbedMozilla) w; - - em->embed_mozilla.embed_window = window; - - return w; -} -/*----------------------------------------------------------------------*/ diff --git a/webshell/embed/xlib/motif/EmbedMozilla.h b/webshell/embed/xlib/motif/EmbedMozilla.h deleted file mode 100644 index 488ab750e401..000000000000 --- a/webshell/embed/xlib/motif/EmbedMozilla.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef __XmEmbedMozilla_h__ -#define __XmEmbedMozilla_h__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -extern WidgetClass xmEmbedMozillaClass; -typedef struct _XmEmbedMozillaClassRec *XmEmbedMozillaClass; -typedef struct _XmEmbedMozillaRec *XmEmbedMozilla; - - -extern Widget -XmCreateEmbedMozilla (Widget parent, - Window window, - String name, - Arg * args, - Cardinal num_args); - -#ifdef __cplusplus -} -#endif - -#endif /* __XmEmbedMozilla_h__ */ diff --git a/webshell/embed/xlib/motif/EmbedMozillaP.h b/webshell/embed/xlib/motif/EmbedMozillaP.h deleted file mode 100644 index fc879fcadf69..000000000000 --- a/webshell/embed/xlib/motif/EmbedMozillaP.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef __XmEmbedMozillaP_h__ -#define __XmEmbedMozillaP_h__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "EmbedMozilla.h" -#include - -typedef struct -{ - int something; -} XmEmbedMozillaClassPart; - -typedef struct _XmEmbedMozillaClassRec -{ - CoreClassPart core_class; - CompositeClassPart composite_class; - ConstraintClassPart constraint_class; - XmManagerClassPart manager_class; - XmEmbedMozillaClassPart embed_mozilla_class; -} XmEmbedMozillaClassRec; - -extern XmEmbedMozillaClassRec xmEmbedMozillaClassRec; - -typedef struct -{ - XtCallbackList input_callback; - Window embed_window; -} XmEmbedMozillaPart; - -typedef struct _XmEmbedMozillaRec -{ - CorePart core; - CompositePart composite; - ConstraintPart constraint; - XmManagerPart manager; - XmEmbedMozillaPart embed_mozilla; -} XmEmbedMozillaRec; - -#ifdef __cplusplus -} -#endif - -#endif /* __XmEmbedMozillaP_h__ */ diff --git a/webshell/embed/xlib/motif/Makefile.in b/webshell/embed/xlib/motif/Makefile.in deleted file mode 100644 index fcba29df7717..000000000000 --- a/webshell/embed/xlib/motif/Makefile.in +++ /dev/null @@ -1,49 +0,0 @@ -# -# The contents of this file are subject to the Netscape Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/NPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -PROGRAM = embed_xlib_into_motif - -CSRCS = EmbedMozilla.c - -CPPSRCS = \ - nsEmbedXlibIntoMotif.cpp \ - nsSetupRegistry.cpp \ - $(NULL) - -LIBS = \ - -lgkgfx \ - $(NETLIB_LIBS) \ - $(MOZ_JS_LIBS) \ - $(XPCOM_LIBS) \ - $(JSJ_LIB) \ - $(NSPR_LIBS) \ - $(MOZ_MOTIF_LDFLAGS) -lxlibrgb \ - $(NULL) - -include $(topsrcdir)/config/rules.mk - diff --git a/webshell/embed/xlib/motif/nsEmbedXlibIntoMotif.cpp b/webshell/embed/xlib/motif/nsEmbedXlibIntoMotif.cpp deleted file mode 100644 index e2eda59c4469..000000000000 --- a/webshell/embed/xlib/motif/nsEmbedXlibIntoMotif.cpp +++ /dev/null @@ -1,271 +0,0 @@ - -#include - -#include - -#include "EmbedMozilla.h" - -#include "nsIServiceManager.h" -#include "nsReadableUtils.h" -#include "nsIEventQueueService.h" -#include "nsIXlibWindowService.h" -#include "nsIUnixToolkitService.h" -#include "nsIWebShell.h" -#include "nsIComponentManager.h" -#include "nsIPref.h" -#include "xlibrgb.h" - -static NS_DEFINE_IID(kIEventQueueServiceIID, - NS_IEVENTQUEUESERVICE_IID); -static NS_DEFINE_IID(kEventQueueServiceCID, - NS_EVENTQUEUESERVICE_CID); -static NS_DEFINE_IID(kWindowServiceCID, - NS_XLIB_WINDOW_SERVICE_CID); -static NS_DEFINE_IID(kWindowServiceIID, - NS_XLIB_WINDOW_SERVICE_IID); -static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); -static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID); -static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID); -static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); -static NS_DEFINE_CID(kCUnixToolkitServiceCID, NS_UNIX_TOOLKIT_SERVICE_CID); - -extern "C" void NS_SetupRegistry(); - -static void event_processor_callback(XtPointer aClosure, - int * aFd, - XtIntervalId * aId) -{ -// printf("event_processor_callback()\n"); - nsIEventQueue *eventQueue = (nsIEventQueue*)aClosure; - eventQueue->ProcessPendingEvents(); -} - -static nsXlibEventDispatcher gsEventDispatcher = nsnull; - -static nsIXlibWindowService * gsWindowService = nsnull; -static nsIWebShell * sgWebShell = nsnull; -static nsIPref * sgPrefs = nsnull; -static Widget sgTopLevel = NULL; - -static void EmbedEventHandler(Widget w, - XtPointer client_data, - XEvent * xevent, - Boolean * cont) -{ -// nsWindow * widgetWindow = (nsWindow *) p ; -// nsMouseEvent mevent; -// nsXtWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_LEFT_BUTTON_DOWN); -// widgetWindow->DispatchMouseEvent(mevent); - - printf("test_filter called\n"); - - if (nsnull != gsEventDispatcher) - { - printf("dispatching native event\n"); - (*gsEventDispatcher)((nsXlibNativeEvent) xevent); - } - -// gsWindowService->DispatchNativeXlibEvent((void *)xevent); - -} - -static void WindowCreateCallback(PRUint32 aID) -{ - Window xid = (Window) aID; - - Widget em = XmCreateEmbedMozilla(sgTopLevel, - xid, - "XmEmbedMozilla", - NULL, - 0); - - XtRealizeWidget(em); - - assert( XtIsRealized(em) ); - - XtAddEventHandler(em, - ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | PointerMotionMask | - EnterWindowMask | LeaveWindowMask | - KeyPressMask | KeyReleaseMask | - ExposureMask, - False, - EmbedEventHandler, - NULL); - -// printf("window created\n"); -} - -static void WindowDestroyCallback(PRUint32 aID) -{ - printf("window destroyed\n"); -} - - -int main(int argc, char **argv) -{ - XtAppContext app_context = nsnull; - - XtSetLanguageProc(NULL, NULL, NULL); - - sgTopLevel = XtAppInitialize(&app_context, // app_context_return - "Mozilla", // application_class - NULL, // options - 0, // num_options - &argc, // argc_in_out - argv, // argv_in_out - NULL, // fallback_resources - NULL, // args - 0); // num_args - - - // XXX this is a hack, will replace with a service RSN - xlib_rgb_init(XtDisplay(sgTopLevel), XtScreen(sgTopLevel)); - - - XtVaSetValues(sgTopLevel, - XmNwidth, 500, - XmNheight, 500, - NULL); - - XtRealizeWidget(sgTopLevel); - - ////////////////////////////////////////////////////////////////////// - // - // 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, - NS_GET_IID(nsIUnixToolkitService), - (void **) &unixToolkitService); - - NS_ASSERTION(NS_SUCCEEDED(rv),"Cannot obtain unix toolkit service."); - - if (!NS_SUCCEEDED(rv)) - return 1; - - // Force the toolkit into "xlib" mode regardless of MOZ_TOOLKIT - unixToolkitService->SetToolkitName("xlib"); - - NS_RELEASE(unixToolkitService); - - ////////////////////////////////////////////////////////////////////// - // End toolkit service setup - ////////////////////////////////////////////////////////////////////// - - - ////////////////////////////////////////////////////////////////////// - // - // Setup the registry - // - ////////////////////////////////////////////////////////////////////// - NS_SetupRegistry(); - - printf("Creating event queue.\n"); - - nsIEventQueueService * eventQueueService = nsnull; - nsIEventQueue * eventQueue = nsnull; - - // Create the Event Queue for the UI thread... - - rv = nsServiceManager::GetService(kEventQueueServiceCID, - kIEventQueueServiceIID, - (nsISupports **)&eventQueueService); - - NS_ASSERTION(NS_SUCCEEDED(rv),"Could not obtain the event queue service."); - - if (!NS_SUCCEEDED(rv)) - return 1; - - rv = eventQueueService->CreateThreadEventQueue(); - - NS_ASSERTION(NS_SUCCEEDED(rv),"Could not create the event queue for the the thread."); - - if (!NS_SUCCEEDED(rv)) - return 1; - - rv = eventQueueService->GetThreadEventQueue(NS_CURRENT_THREAD, &eventQueue); - - NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get the newly created thread event queue.\n"); - - if (!NS_SUCCEEDED(rv)) - return 1; - - NS_RELEASE(eventQueueService); - - rv = nsServiceManager::GetService(kWindowServiceCID, - kWindowServiceIID, - (nsISupports **)&gsWindowService); - - NS_ASSERTION(NS_SUCCEEDED(rv),"Couldn't obtain window service\n"); - - if (!NS_SUCCEEDED(rv)) - return 1; - - gsWindowService->SetWindowCreateCallback(WindowCreateCallback); - gsWindowService->SetWindowDestroyCallback(WindowDestroyCallback); - - - XtAppAddInput(app_context, - eventQueue->GetEventQueueSelectFD(), - (XtPointer) XtInputReadMask, - event_processor_callback, - eventQueue); - - - rv = nsRepository::CreateInstance(kWebShellCID, nsnull, - kIWebShellIID, - (void**)&sgWebShell); - - NS_ASSERTION(NS_SUCCEEDED(rv),"Cannot create WebShell.\n"); - - if (!NS_SUCCEEDED(rv)) - return 1; - - sgWebShell->Init((nsNativeWidget *) XtWindow(sgTopLevel), - 0, 0, - 500, 500); - - gsWindowService->GetEventDispatcher(&gsEventDispatcher); - - rv = nsComponentManager::CreateInstance(kPrefCID, NULL, kIPrefIID, - (void **) &sgPrefs); - - if (NS_OK != rv) { - printf("failed to get prefs instance\n"); - return rv; - } - - sgPrefs->StartUp(); - sgPrefs->ReadUserPrefs(); - - sgWebShell->SetPrefs(sgPrefs); - sgWebShell->Show(); - - char *url = "http://www.slashdot.org/"; - - nsString URL(url); - PRUnichar *u_url = ToNewUnicode(URL); - sgWebShell->LoadURL(u_url); - - XtPopup(sgTopLevel,XtGrabNone); - - XEvent event; - - for (;;) - { - XtAppNextEvent(app_context, &event); - - XtDispatchEvent(&event); - } - - return 0; -} diff --git a/webshell/embed/xlib/motif/nsSetupRegistry.cpp b/webshell/embed/xlib/motif/nsSetupRegistry.cpp deleted file mode 100644 index ea0aa79f7ceb..000000000000 --- a/webshell/embed/xlib/motif/nsSetupRegistry.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "../../../../webshell/tests/viewer/nsSetupRegistry.cpp" - diff --git a/webshell/embed/xlib/xt/.cvsignore b/webshell/embed/xlib/xt/.cvsignore deleted file mode 100644 index f3c7a7c5da68..000000000000 --- a/webshell/embed/xlib/xt/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile diff --git a/webshell/embed/xlib/xt/EmbedMozilla.c b/webshell/embed/xlib/xt/EmbedMozilla.c deleted file mode 100644 index a3bab9d96ca3..000000000000 --- a/webshell/embed/xlib/xt/EmbedMozilla.c +++ /dev/null @@ -1,214 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - * - * Contributor(s): - */ - -#include -#include - -#include "EmbedMozilla.h" -#include "EmbedMozillaP.h" - -static XtGeometryResult -QueryGeometry( Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply ); - -static XtGeometryResult -GeometryManager(Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply); - -static void ChangeManaged(Widget w); - -static void CoreRealize (Widget,XtValueMask *,XSetWindowAttributes *); - -static void Resize(Widget w); - - -XtEmbedMozillaClassRec xtEmbedMozillaClassRec = -{ - { -/* core_class fields */ - /* superclass */ (WidgetClass) &constraintClassRec, - /* class_name */ "XtEmbedMozilla", - /* widget_size */ sizeof(XtEmbedMozillaRec), - /* class_initialize */ NULL, - /* class_partinit */ NULL /* ClassPartInitialize */, - /* class_inited */ FALSE, - /* initialize */ NULL /* Initialize */, - /* Init hook */ NULL, - /* realize */ CoreRealize, - /* actions */ NULL, - /* num_actions */ 0, - /* resources */ NULL /* resources */, - /* num_resources */ 0 /* XtNumber(resources) */, - /* xrm_class */ NULLQUARK, - /* compress_motion */ TRUE, - /* compress_exposure */ TRUE, - /* compress_enterleave*/ TRUE, - /* visible_interest */ FALSE, - /* destroy */ NULL, - /* resize */ Resize, - /* expose */ XtInheritExpose /* (XtExposeProc) Redisplay */, - /* set_values */ NULL /* (XtSetValuesFunc )SetValues */, - /* set values hook */ NULL, - /* set values almost */ XtInheritSetValuesAlmost, - /* get values hook */ NULL, - /* accept_focus */ NULL, - /* Version */ XtVersion, - /* PRIVATE cb list */ NULL, - /* tm_table */ XtInheritTranslations, - /* query_geometry */ QueryGeometry, - /* display_accelerator*/ NULL, - /* extension */ NULL, - }, - { -/* composite_class fields */ - /* geometry_manager */ XtInheritGeometryManager, //GeometryManager, - /* change_managed */ XtInheritChangeManaged, //ChangeManaged, - /* insert_child */ XtInheritInsertChild, - /* delete_child */ XtInheritDeleteChild, - /* Extension */ NULL, - }, - { -/* Constraint class Init */ - NULL, - 0, - 0, - NULL, - NULL, - NULL, - NULL - - }, - { -/* XtEmbedMozilla class - none */ - /* mumble */ 0 - } -}; - - -WidgetClass xtEmbedMozillaClass = (WidgetClass)&xtEmbedMozillaClassRec; - -#define XtX(w) w->core.x -#define XtY(w) w->core.y -#define XtWidth(w) w->core.width -#define XtHeight(w) w->core.height -#define XtBorderWidth(w) w->core.border_width - -static XtGeometryResult -QueryGeometry( Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply ) -{ - if ( request->request_mode == 0 ) - return XtGeometryYes; - - reply->request_mode &= CWWidth | CWHeight; - - if ( request->request_mode & CWWidth ) - reply->width = request->width; - - if ( request->request_mode & CWHeight ) - reply->height = request->height; - - return XtGeometryYes; -} - -static XtGeometryResult -GeometryManager(Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply) -{ - if (request->request_mode & XtCWQueryOnly) - { - return(XtGeometryYes); - } - - if (request->request_mode & CWX) - { - XtX(w) = reply->x = request->x; - } - if (request->request_mode & CWY) - { - XtY(w) = reply->y = request->y; - } - if (request->request_mode & CWWidth) - { - XtWidth(w) = reply->width = request->width; - } - if (request->request_mode & CWHeight) - { - XtHeight(w) = reply->height = request->height; - } - if (request->request_mode & CWBorderWidth) - { - XtBorderWidth(w) = reply->border_width = request->border_width; - } - - return(XtGeometryYes); -} - - -static void -ChangeManaged(Widget w) -{ - return; -} - -static void Resize (Widget widget) -{ - XtEmbedMozilla em = (XtEmbedMozilla) widget; - -#if 0 - /* Invoke the resize procedure of the superclass. - Probably there's some nominally more portable way to do this - (yeah right, like any of these slot names could possibly change - and have any existing code still work.) - */ - widget->core.widget_class->core_class.superclass->core_class.resize (widget); - - /* Now run our callback (yeah, I should use a real callback, so sue me.) */ - scroller->scroller.resize_hook (widget, scroller->scroller.resize_arg); -#endif - -} - -static void -CoreRealize(Widget w,XtValueMask *mask,XSetWindowAttributes* wa) -{ - XtEmbedMozilla em = (XtEmbedMozilla) w; - - printf("CoreRealize(%s),window = %ld\n", - XtName(w), em->embed_mozilla.embed_window); - printf("CoreRealize: parent widget = %p\n", em->core.parent ); - - em->core.window = em->embed_mozilla.embed_window; -} -/*----------------------------------------------------------------------*/ - -Widget -XtCreateEmbedMozilla(Widget parent, - Window window, - String name, - Arg *av, - Cardinal ac) -{ - Widget w = XtCreateWidget(name,xtEmbedMozillaClass,parent,av,ac); - - XtEmbedMozilla em = (XtEmbedMozilla) w; - - em->embed_mozilla.embed_window = window; - - return w; -} -/*----------------------------------------------------------------------*/ diff --git a/webshell/embed/xlib/xt/EmbedMozilla.h b/webshell/embed/xlib/xt/EmbedMozilla.h deleted file mode 100644 index 4285637d132c..000000000000 --- a/webshell/embed/xlib/xt/EmbedMozilla.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - * - * Contributor(s): - */ - -#ifndef __XtEmbedMozilla_h__ -#define __XtEmbedMozilla_h__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -extern WidgetClass xtEmbedMozillaClass; -typedef struct _XtEmbedMozillaClassRec *XtEmbedMozillaClass; -typedef struct _XtEmbedMozillaRec *XtEmbedMozilla; - - -extern Widget -XtCreateEmbedMozilla (Widget parent, - Window window, - String name, - Arg * args, - Cardinal num_args); - -#ifdef __cplusplus -} -#endif - -#endif /* __XtEmbedMozilla_h__ */ diff --git a/webshell/embed/xlib/xt/EmbedMozillaP.h b/webshell/embed/xlib/xt/EmbedMozillaP.h deleted file mode 100644 index 6c15832f4d26..000000000000 --- a/webshell/embed/xlib/xt/EmbedMozillaP.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - * - * Contributor(s): - */ - -#ifndef __XtEmbedMozillaP_h__ -#define __XtEmbedMozillaP_h__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "EmbedMozilla.h" -#include - -typedef struct -{ - int something; -} XtEmbedMozillaClassPart; - -typedef struct _XtEmbedMozillaClassRec -{ - CoreClassPart core_class; - CompositeClassPart composite_class; - ConstraintClassPart constraint_class; - XtEmbedMozillaClassPart embed_mozilla_class; -} XtEmbedMozillaClassRec; - -extern XtEmbedMozillaClassRec xtEmbedMozillaClassRec; - -typedef struct -{ - XtCallbackList input_callback; - Window embed_window; -} XtEmbedMozillaPart; - -typedef struct _XtEmbedMozillaRec -{ - CorePart core; - CompositePart composite; - ConstraintPart constraint; - XtEmbedMozillaPart embed_mozilla; -} XtEmbedMozillaRec; - -#ifdef __cplusplus -} -#endif - -#endif /* __XtEmbedMozillaP_h__ */ diff --git a/webshell/embed/xlib/xt/Makefile.in b/webshell/embed/xlib/xt/Makefile.in deleted file mode 100644 index 2b1c10ffddb2..000000000000 --- a/webshell/embed/xlib/xt/Makefile.in +++ /dev/null @@ -1,50 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Mozilla Communicator client code. -# -# The Initial Developer of the Original Code is Netscape Communications -# Corporation. Portions created by Netscape are Copyright (C) 1998 -# Netscape Communications Corporation. All Rights Reserved. -# -# Contributor(s): -# - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -PROGRAM = embed_xlib_into_xt - -CSRCS = EmbedMozilla.c - -CPPSRCS = \ - nsEmbedXlibIntoXt.cpp \ - nsSetupRegistry.cpp \ - $(NULL) - -LIBS = \ - -lgkgfx \ - $(NETLIB_LIBS) \ - $(MOZ_JS_LIBS) \ - $(XPCOM_LIBS) \ - $(JSJ_LIB) \ - $(NSPR_LIBS) \ - $(MOZ_MOTIF_LDFLAGS) -lxlibrgb \ - $(NULL) - -include $(topsrcdir)/config/rules.mk - -CXXFLAGS += $(MOZ_MOTIF_CFLAGS) - diff --git a/webshell/embed/xlib/xt/nsEmbedXlibIntoXt.cpp b/webshell/embed/xlib/xt/nsEmbedXlibIntoXt.cpp deleted file mode 100644 index 5d2541c21f85..000000000000 --- a/webshell/embed/xlib/xt/nsEmbedXlibIntoXt.cpp +++ /dev/null @@ -1,383 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - */ - -// XXX Milind: -#include -#include -#include -#include -#include -#include -#include - -#include "EmbedMozilla.h" - -#include "nsIServiceManager.h" -#include "nsReadableUtils.h" -#include "nsIEventQueueService.h" -#include "nsIXlibWindowService.h" -#include "nsIUnixToolkitService.h" -#include "nsIWebShell.h" -#include "nsIComponentManager.h" -#include "nsIPref.h" -#include "xlibrgb.h" - - - - -//----------------------------------------------------------------------------- -static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID); -static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); -static NS_DEFINE_IID(kWindowServiceCID, NS_XLIB_WINDOW_SERVICE_CID); -static NS_DEFINE_IID(kWindowServiceIID, NS_XLIB_WINDOW_SERVICE_IID); -static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); -static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID); -static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID); -static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); -static NS_DEFINE_CID(kCUnixToolkitServiceCID, NS_UNIX_TOOLKIT_SERVICE_CID); - - - - -//----------------------------------------------------------------------------- -extern "C" void NS_SetupRegistry(); - -static void resize_callback( Widget w, - XtPointer data, - XEvent *xevent, - Boolean *toContinue ); - -static void window_event_handler( Widget w, - XtPointer data, - XEvent *xevent, - Boolean *toContinue ); - -static void event_processor_callback( XtPointer client_data, - int *fd, - XtInputId *id ); - - -//----------------------------------------------------------------------------- -static nsXlibEventDispatcher gsEventDispatcher = nsnull; - -static nsIXlibWindowService * gsWindowService = nsnull; -static nsIWebShell * sgWebShell = nsnull; -static nsIPref * sgPrefs = nsnull; - -// XXX Milind: the Qt socket notifier which processes pending events -static Widget gTopLevelWidget = 0; -static Window gWebShellWindow = 0; -static Widget gWebShellWidget = 0; - -static const long lEVENT_MASK = - ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | PointerMotionMask | - EnterWindowMask | LeaveWindowMask | - KeyPressMask | KeyReleaseMask | - ExposureMask;// | ResizeRedirectMask; - -// XXX Milind: -Display *gDisplay = NULL; -int gScreenNumber = 0; -Window gTopLevelWindow = 0; - - - - -//----------------------------------------------------------------------------- -static void WindowCreateCallback( PRUint32 aID ) -{ - // XXX Milind: - printf( "window created: %u\n", aID ); - Widget parentwidget = gTopLevelWidget; - - Widget widget = XtCreateEmbedMozilla( parentwidget, - ( Window )aID, - "XtEmbedMozilla", - NULL, - 0 - ); - XtRealizeWidget( widget ); - - printf( "widget(%p) of window(%ld)\n\n", widget, (Window)aID ); - XtAddEventHandler( widget, - ( ExposureMask | - ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | ButtonMotionMask | - EnterWindowMask | LeaveWindowMask | - KeyPressMask | KeyReleaseMask - ), - False, - window_event_handler, - gsEventDispatcher - ); -} - -static void WindowDestroyCallback(PRUint32 aID) -{ - printf("window destroyed\n"); -} - - -// XXX MAIN -int main(int argc, char **argv) -{ - XtAppContext app; - - gTopLevelWidget = XtAppInitialize( &app, // app context - "embed_xlib_into_qt", // app class name - 0, // option list - 0, // number of options - &argc, // argc - argv, // argv - 0, // fallback resrces - 0, // arg list - 0 ); // number of args - - gDisplay = XtDisplay( gTopLevelWidget ); - gScreenNumber = DefaultScreen( gDisplay ); - - printf("TOP LEVEL WIDGET: %p\n", gTopLevelWidget); - - // init xlibrgb - xlib_rgb_init( gDisplay, DefaultScreenOfDisplay( gDisplay ) ); - - XtVaSetValues( gTopLevelWidget, - XtNwidth, 500, - XtNheight, 500, - NULL); - - - printf("realizing TOP LEVEL WIDGET...\n"); - XtRealizeWidget( gTopLevelWidget ); - printf("done.\n"); - - gTopLevelWindow = XtWindow( gTopLevelWidget ); - - printf("Top Level Window = %ld\n", gTopLevelWindow); - - - ////////////////////////////////////////////////////////////////////// - // - // Toolkit Service setup - // - // Note: This must happend before NS_SetupRegistry() is called so - // that the toolkit specific xpcom components can be registered - // as needed. - // - ////////////////////////////////////////////////////////////////////// - nsresult rv; - - nsIUnixToolkitService * unixToolkitService = nsnull; - - rv = nsComponentManager::CreateInstance(kCUnixToolkitServiceCID, - nsnull, - NS_GET_IID(nsIUnixToolkitService), - (void **) &unixToolkitService); - - NS_ASSERTION(NS_SUCCEEDED(rv),"Cannot obtain unix toolkit service."); - - if (!NS_SUCCEEDED(rv)) - return 1; - - // Force the toolkit into "xlib" mode regardless of MOZ_TOOLKIT - unixToolkitService->SetToolkitName("xlib"); - - NS_RELEASE(unixToolkitService); - - ////////////////////////////////////////////////////////////////////// - // End toolkit service setup - ////////////////////////////////////////////////////////////////////// - - - ////////////////////////////////////////////////////////////////////// - // - // Setup the registry - // - ////////////////////////////////////////////////////////////////////// - NS_SetupRegistry(); - - printf("Creating event queue.\n"); - - nsIEventQueueService * eventQueueService = nsnull; - nsIEventQueue * eventQueue = nsnull; - - // Create the Event Queue for the UI thread... - - rv = nsServiceManager::GetService(kEventQueueServiceCID, - kIEventQueueServiceIID, - (nsISupports **)&eventQueueService); - - NS_ASSERTION(NS_SUCCEEDED(rv),"Could not obtain the event queue service."); - - if (!NS_SUCCEEDED(rv)) - return 1; - - rv = eventQueueService->CreateThreadEventQueue(); - - NS_ASSERTION(NS_SUCCEEDED(rv),"Could not create the event queue for the the thread."); - - if (!NS_SUCCEEDED(rv)) - return 1; - - rv = eventQueueService->GetThreadEventQueue(NS_CURRENT_THREAD, - &eventQueue); - - NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get the newly created thread event queue.\n"); - - if (!NS_SUCCEEDED(rv)) - return 1; - - NS_RELEASE(eventQueueService); - - rv = nsServiceManager::GetService(kWindowServiceCID, - kWindowServiceIID, - (nsISupports **)&gsWindowService); - - NS_ASSERTION(NS_SUCCEEDED(rv),"Couldn't obtain window service\n"); - - if (!NS_SUCCEEDED(rv)) - return 1; - - gsWindowService->SetWindowCreateCallback(WindowCreateCallback); - gsWindowService->SetWindowDestroyCallback(WindowDestroyCallback); - - // XXX Milind: - XtAppAddInput( app, - eventQueue->GetEventQueueSelectFD(), - ( XtInputId* )XtInputReadMask, - event_processor_callback, - eventQueue ); - - rv = nsRepository::CreateInstance(kWebShellCID, - nsnull, - kIWebShellIID, - (void**)&sgWebShell); - - NS_ASSERTION(NS_SUCCEEDED(rv),"Cannot create WebShell.\n"); - - if (!NS_SUCCEEDED(rv)) - return 1; - - sgWebShell->Init( ( nsNativeWidget )gTopLevelWindow, 0, 0, 500, 500); - - - gsWindowService->GetEventDispatcher(&gsEventDispatcher); - - rv = nsComponentManager::CreateInstance(kPrefCID, - NULL, - kIPrefIID, - (void **) &sgPrefs); - - if (NS_OK != rv) { - printf("failed to get prefs instance\n"); - return rv; - } - - sgPrefs->StartUp(); - sgPrefs->ReadUserPrefs(); - - sgWebShell->SetPrefs(sgPrefs); - printf("showing webshell...\n"); - sgWebShell->Show(); - - - char *url = "http://www.mozilla.org/unix/xlib.html"; - - nsString URL(url); - PRUnichar *u_url = ToNewUnicode(URL); - sgWebShell->LoadURL(u_url); - - XtPopup( gTopLevelWidget, XtGrabNone ); - - XtAddEventHandler( gTopLevelWidget, - StructureNotifyMask, - False, - resize_callback, - sgWebShell ); - - XtAppMainLoop( app ); -} - - -static void resize_callback( Widget w, - XtPointer data, - XEvent *xevent, - Boolean *toContinue ) -{ - static int x = 0, y = 0, width = 0, height = 0, changed = 0; - - if ( xevent->type == ConfigureNotify ) - { - XConfigureEvent &xconfigure = xevent->xconfigure; - XResizeRequestEvent &xresize = xevent->xresizerequest; - nsIWebShell *webshell = ( nsIWebShell* )data; - - if ( xevent->type == ConfigureNotify ) - { - //x = x != xconfigure.x ? changed = 1, xconfigure.x : x; - //y = y != xconfigure.y ? changed = 1, xconfigure.y : y; - width = width != xconfigure.width ? changed = 1, xconfigure.width : width; - height = height != xconfigure.height ? changed = 1, xconfigure.height : height; - } - else - { - //x = x != xresize.x ? changed = 1, xresize.x : x; - //y = y != xresize.y ? changed = 1, xresize.y : y; - width = width != xresize.width ? changed = 1, xresize.width : width; - height = height != xresize.height ? changed = 1, xresize.height : height; - } - - if ( changed ) - { - printf("RESIZE...%p(%d, %d)\n", w, width, height); - webshell->SetBounds( 0, 0, width, height ); changed = 0; - } - - } - - //*toContinue = False; -} - -// this will pick up size changes in the main window and resize -// the web shell window accordingly -static void window_event_handler( Widget w, - XtPointer data, - XEvent *xevent, - Boolean *toContinue ) -{ - //printf("window_event_handler...\n"); - (*gsEventDispatcher)((nsXlibNativeEvent) xevent); - //*toContinue = True; -} - - -static void event_processor_callback( XtPointer client_data, - int *fd, - XtInputId *id ) -{ - printf("event_processor_callback...\n"); - - nsIEventQueue *eq = ( nsIEventQueue *)client_data; - eq->ProcessPendingEvents(); -} - diff --git a/webshell/embed/xlib/xt/nsSetupRegistry.cpp b/webshell/embed/xlib/xt/nsSetupRegistry.cpp deleted file mode 100644 index e464d09267ea..000000000000 --- a/webshell/embed/xlib/xt/nsSetupRegistry.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - * - * Contributor(s): - */ - -#include "../../../../webshell/tests/viewer/nsSetupRegistry.cpp" - diff --git a/webshell/tests/viewer/unix/motif/.cvsignore b/webshell/tests/viewer/unix/motif/.cvsignore deleted file mode 100644 index f3c7a7c5da68..000000000000 --- a/webshell/tests/viewer/unix/motif/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile diff --git a/webshell/tests/viewer/unix/motif/Makefile.in b/webshell/tests/viewer/unix/motif/Makefile.in deleted file mode 100644 index af5766432730..000000000000 --- a/webshell/tests/viewer/unix/motif/Makefile.in +++ /dev/null @@ -1,51 +0,0 @@ -# -# The contents of this file are subject to the Netscape Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/NPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# - -DEPTH = ../../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -LIBRARY_NAME = viewer_motif_s - -CPPSRCS = \ - nsMotifMain.cpp \ - nsMotifMenu.cpp \ - $(NULL) - -FORCE_STATIC_LIB = 1 - -include $(topsrcdir)/config/rules.mk - -INCLUDES += -I$(srcdir)/../.. - -ifeq ($(OS_ARCH), Linux) -DEFINES += -D_XOPEN_SOURCE=500 -endif - -ifndef MOZ_MONOLITHIC_TOOLKIT -CXXFLAGS += $(MOZ_MOTIF_CFLAGS) -else -CXXFLAGS += $(TK_CFLAGS) -endif - diff --git a/webshell/tests/viewer/unix/motif/nsMotifMain.cpp b/webshell/tests/viewer/unix/motif/nsMotifMain.cpp deleted file mode 100644 index 46f13321e992..000000000000 --- a/webshell/tests/viewer/unix/motif/nsMotifMain.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsViewerApp.h" -#include "nsBrowserWindow.h" -#include "nsMotifMenu.h" -#include "nsIServiceManager.h" -#include "nsGfxCIID.h" - -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; -} - -nsresult -nsNativeBrowserWindow::GetMenuBarHeight(PRInt32 * aHeightOut) -{ - NS_ASSERTION(nsnull != aHeightOut,"null out param."); - - *aHeightOut = 0; - - 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) -{ - gTheApp = new nsNativeViewerApp(); - - putenv("MOZ_TOOLKIT=motif"); - - gTheApp->Initialize(argc, argv); - gTheApp->Run(); - - return 0; -} diff --git a/webshell/tests/viewer/unix/motif/nsMotifMenu.cpp b/webshell/tests/viewer/unix/motif/nsMotifMenu.cpp deleted file mode 100644 index 3b76e06b3dbd..000000000000 --- a/webshell/tests/viewer/unix/motif/nsMotifMenu.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include -#include -#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); - -} diff --git a/webshell/tests/viewer/unix/motif/nsMotifMenu.h b/webshell/tests/viewer/unix/motif/nsMotifMenu.h deleted file mode 100644 index 846f3eee8763..000000000000 --- a/webshell/tests/viewer/unix/motif/nsMotifMenu.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _nsMotifMenu_h_ -#define _nsMotifMenu_h_ - -#include -#include "nscore.h" - - -typedef void (*MenuCallbackProc)( - PRUint32 -); - -void CreateViewerMenus(Widget aParent, MenuCallbackProc aCallback); - - -#endif // _nsMotifMenu_h_ diff --git a/widget/src/motif/.cvsignore b/widget/src/motif/.cvsignore deleted file mode 100644 index f3c7a7c5da68..000000000000 --- a/widget/src/motif/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile diff --git a/widget/src/motif/Makefile.in b/widget/src/motif/Makefile.in deleted file mode 100644 index 70d19da90c6c..000000000000 --- a/widget/src/motif/Makefile.in +++ /dev/null @@ -1,78 +0,0 @@ -# -# The contents of this file are subject to the Netscape Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/NPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# - -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -LIBRARY_NAME = widget_motif -EXPORT_LIBRARY = 1 - - -DIRS = app_context - -CPPSRCS = \ - nsAppShell.cpp \ - nsBidiKeyboard.cpp \ - nsButton.cpp \ - nsCheckButton.cpp \ - nsLabel.cpp \ - nsLookAndFeel.cpp \ - nsMenu.cpp \ - nsMenuBar.cpp \ - nsMenuItem.cpp \ - nsPopUpMenu.cpp \ - nsScrollbar.cpp \ - nsTextHelper.cpp \ - nsTextWidget.cpp \ - nsToolkit.cpp \ - nsWidgetFactory.cpp \ - nsWindow.cpp \ - nsXtEventHandler.cpp \ - nsXtManageWidget.cpp \ - $(NULL) - -SHARED_LIBRARY_LIBS = $(DIST)/lib/libxpwidgets_s.a - -ifndef MOZ_MONOLITHIC_TOOLKIT -EXTRA_DSO_LDOPTS += -L$(DIST)/bin -lxlibrgb $(MOZ_MOTIF_LDFLAGS) -else -EXTRA_DSO_LDOPTS += $(TK_LIBS) -endif - -include $(topsrcdir)/config/rules.mk - -ifndef MOZ_MONOLITHIC_TOOLKIT -CXXFLAGS += $(MOZ_XLIB_CFLAGS) -else -CXXFLAGS += $(TK_CFLAGS) -endif - -DEFINES += -D_IMPL_NS_WIDGET - -INCLUDES += \ - -I$(srcdir)/../xpwidgets \ - -I$(srcdir) \ - $(NULL) - diff --git a/widget/src/motif/app_context/.cvsignore b/widget/src/motif/app_context/.cvsignore deleted file mode 100644 index f3c7a7c5da68..000000000000 --- a/widget/src/motif/app_context/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile diff --git a/widget/src/motif/app_context/Makefile.in b/widget/src/motif/app_context/Makefile.in deleted file mode 100644 index 0afc490beb07..000000000000 --- a/widget/src/motif/app_context/Makefile.in +++ /dev/null @@ -1,48 +0,0 @@ -# -# The contents of this file are subject to the Netscape Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/NPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -LIBRARY_NAME = motif_app_context -EXPORT_LIBRARY = 1 -IS_COMPONENT = 1 - - -CPPSRCS = \ - nsMotifAppContextService.cpp \ - nsMotifAppContextServiceFactory.cpp \ - $(NULL) - -EXPORTS = nsIMotifAppContextService.h - -EXTRA_DSO_LDOPTS = $(TOOLKIT_TK_LIBS) - -include $(topsrcdir)/config/rules.mk - -CXXFLAGS += $(TK_CFLAGS) - -INCLUDES += $(TK_CFLAGS) -I$(srcdir)/.. -I$(srcdir)/../../xpwidgets - diff --git a/widget/src/motif/app_context/nsIMotifAppContextService.h b/widget/src/motif/app_context/nsIMotifAppContextService.h deleted file mode 100644 index fccb602f3600..000000000000 --- a/widget/src/motif/app_context/nsIMotifAppContextService.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsIMotifAppContextService_h__ -#define nsIMotifAppContextService_h__ - -#include "nsISupports.h" -#include - -// Interface id for the MotifAppContext service -// { 90F55E51-40EB-11d3-B219-000064657374 } -#define NS_MOTIF_APP_CONTEXT_SERVICE_IID \ - { 0x90f55e51, 0x40eb, 0x11d3, \ - { 0xb2, 0x19, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } } - -// Class ID for our implementation -// { 90F55E52-40EB-11d3-B219-000064657374 } -#define NS_MOTIF_APP_CONTEXT_SERVICE_CID \ - { 0x90f55e52, 0x40eb, 0x11d3, \ - { 0xb2, 0x19, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } } - -#define NS_MOTIF_APP_CONTEXT_SERVICE_CONTRACTID "@mozilla.org/widget/motif/app_context;1" - -class nsIMotifAppContextService : public nsISupports -{ - public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_MOTIF_APP_CONTEXT_SERVICE_IID); - - /** - * Register your function for window creation and destruction. - * This function will get called whenever a new native X window - * is created. or destroyed. - * - * @param [IN] the function that you would like to register - * @return NS_OK if ok, NS_ERROR_FAILURE if you pass in 0 - */ - - NS_IMETHOD SetAppContext(XtAppContext aAppContext) = 0; - - /** - * This function will dispatch a native X event ( cast to a void * - * here ) to the event handler on the inside of the widget - * toolkit - * @param [IN] a pointer to an XEvent, cast to a void * - * @return NS_OK if ok, NS_ERROR_FAILURE if you pass in an - * invalid window id - */ - - NS_IMETHOD GetAppContext(XtAppContext * aAppContextOut) = 0; - -}; - -#endif /* nsIMotifAppContextService_h__ */ diff --git a/widget/src/motif/app_context/nsMotifAppContextService.cpp b/widget/src/motif/app_context/nsMotifAppContextService.cpp deleted file mode 100644 index eb67804bfa11..000000000000 --- a/widget/src/motif/app_context/nsMotifAppContextService.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - */ - -#include "nsMotifAppContextService.h" - -XtAppContext nsMotifAppContextService::sAppContext = nsnull; -nsMotifAppContextService::nsMotifAppContextService() -{ -} - -nsMotifAppContextService::~nsMotifAppContextService() -{ -} - -NS_IMPL_ISUPPORTS1(nsMotifAppContextService, nsIMotifAppContextService) - -NS_IMETHODIMP -nsMotifAppContextService::SetAppContext(XtAppContext aAppContext) -{ - NS_ASSERTION(sAppContext == nsnull,"App context can only be set once."); - - sAppContext = aAppContext; - - return NS_OK; -} - -NS_IMETHODIMP -nsMotifAppContextService::GetAppContext(XtAppContext * aAppContextOut) -{ - *aAppContextOut = sAppContext; - - return NS_OK; -} diff --git a/widget/src/motif/app_context/nsMotifAppContextService.h b/widget/src/motif/app_context/nsMotifAppContextService.h deleted file mode 100644 index 83907c094a3c..000000000000 --- a/widget/src/motif/app_context/nsMotifAppContextService.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsIMotifAppContextService.h" - -class nsMotifAppContextService : public nsIMotifAppContextService -{ - public: - nsMotifAppContextService(); - virtual ~nsMotifAppContextService(); - - NS_DECL_ISUPPORTS - - NS_IMETHOD SetAppContext(XtAppContext aAppContext); - NS_IMETHOD GetAppContext(XtAppContext * aAppContextOut); - -private: - - static XtAppContext sAppContext; -}; diff --git a/widget/src/motif/app_context/nsMotifAppContextServiceFactory.cpp b/widget/src/motif/app_context/nsMotifAppContextServiceFactory.cpp deleted file mode 100644 index 235564de2725..000000000000 --- a/widget/src/motif/app_context/nsMotifAppContextServiceFactory.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - */ - -#include "nsIMotifAppContextService.h" - -#include "nsIFactory.h" -#include "nsIComponentManager.h" -#include "nsIServiceManager.h" -#include "nsCOMPtr.h" - -#include "nsMotifAppContextService.h" - -static NS_DEFINE_CID(kCMotifAppContextServiceCID, NS_MOTIF_APP_CONTEXT_SERVICE_CID); -static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); - -class nsMotifAppContextServiceFactory : public nsIFactory -{ -public: - NS_DECL_ISUPPORTS - NS_IMETHOD CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult); - - NS_IMETHOD LockFactory(PRBool aLock); - - nsMotifAppContextServiceFactory(const nsCID &aClass); - virtual ~nsMotifAppContextServiceFactory(); - -private: - nsCID mClassID; -}; - -nsMotifAppContextServiceFactory::nsMotifAppContextServiceFactory(const nsCID &aClass) : - mRefCnt(0), - mClassID(aClass) -{ -} - -nsMotifAppContextServiceFactory::~nsMotifAppContextServiceFactory() -{ -} - -NS_IMPL_ISUPPORTS1(nsMotifAppContextServiceFactory, nsIFactory) - -NS_IMETHODIMP -nsMotifAppContextServiceFactory::CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult) -{ - if (aResult == nsnull) - return NS_ERROR_NULL_POINTER; - - *aResult = nsnull; - - nsISupports *inst = nsnull; - if (mClassID.Equals(kCMotifAppContextServiceCID)) { - inst = (nsISupports *)(nsMotifAppContextService *) new nsMotifAppContextService(); - } - - if (inst == nsnull) - return NS_ERROR_OUT_OF_MEMORY; - - nsresult rv = inst->QueryInterface(aIID, aResult); - if (rv != NS_OK) - delete inst; - return rv; -} - -nsresult nsMotifAppContextServiceFactory::LockFactory(PRBool aLock) -{ - // Not implemented in simplest case. - return NS_OK; -} - -extern "C" NS_EXPORT nsresult -NSGetFactory(nsISupports *servMgr, - const nsCID &aClass, - const char *aClassName, - const char *aContractID, - nsIFactory **aFactory) -{ - if (nsnull == aFactory) { - return NS_ERROR_NULL_POINTER; - } - - *aFactory = new nsMotifAppContextServiceFactory(aClass); - - if (nsnull == aFactory) { - return NS_ERROR_OUT_OF_MEMORY; - } - return (*aFactory)->QueryInterface(NS_GET_IID(nsIFactory), - (void **)aFactory); -} - -extern "C" NS_EXPORT PRBool -NSCanUnload(nsISupports *aServMgr) -{ - return PR_FALSE; -} - -extern "C" NS_EXPORT nsresult -NSRegisterSelf(nsISupports* aServMgr, const char *fullpath) -{ - nsresult rv; - -#ifdef NS_DEBUG - printf("*** Registering MotifAppContextService\n"); -#endif - - nsCOMPtr - serviceManager(do_QueryInterface(aServMgr, &rv)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr compMgr = - do_GetService(kComponentManagerCID, &rv); - if (NS_FAILED(rv)) return rv; - - rv = compMgr->RegisterComponent(kCMotifAppContextServiceCID, - "Motif App Context Service", - NS_MOTIF_APP_CONTEXT_SERVICE_CONTRACTID, - fullpath, - PR_TRUE, - PR_TRUE); - return rv; -} - -extern "C" NS_EXPORT nsresult -NSUnregisterSelf(nsISupports *aServMgr, const char *fullpath) -{ - nsresult rv; - nsCOMPtr - serviceManager(do_QueryInterface(aServMgr, &rv)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr compMgr = - do_GetService(kComponentManagerCID, &rv); - if (NS_FAILED(rv)) return rv; - - compMgr->UnregisterComponent(kCMotifAppContextServiceCID, fullpath); - - return NS_OK; -} diff --git a/widget/src/motif/nsAppShell.cpp b/widget/src/motif/nsAppShell.cpp deleted file mode 100644 index 5cf62aeb4832..000000000000 --- a/widget/src/motif/nsAppShell.cpp +++ /dev/null @@ -1,336 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsAppShell.h" -#include "nsIAppShell.h" -#include "nsIServiceManager.h" -#include "nsIEventQueueService.h" -#include "nsICmdLineService.h" - -#include "nsIMotifAppContextService.h" - -#include - -#ifdef LINUX -#define DO_THE_EDITRES_THING -#endif - -#ifdef DO_THE_EDITRES_THING -#include -#endif - -#include "xlibrgb.h" - -#include "nsIPref.h" - -//------------------------------------------------------------------------- -// -// XPCOM CIDs -// -//------------------------------------------------------------------------- -static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); -static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID); -static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); - -//------------------------------------------------------------------------- -// -// nsISupports implementation macro -// -//------------------------------------------------------------------------- -NS_IMPL_ISUPPORTS1(nsAppShell, nsIAppShell) - -//------------------------------------------------------------------------- -NS_METHOD nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener) -{ - mDispatchListener = aDispatchListener; - return NS_OK; -} - -XtAppContext nsAppShell::sAppContext = nsnull; - -//------------------------------------------------------------------------- -// -// Create the application shell -// -//------------------------------------------------------------------------- - -NS_METHOD nsAppShell::Create(int* bac, char ** bav) -{ - int argc = bac ? *bac : 0; - char **argv = bav; - - nsresult rv; - - nsCOMPtr cmdLineArgs = - do_GetService(kCmdLineServiceCID, &rv); - if (NS_SUCCEEDED(rv)) - { - rv = cmdLineArgs->GetArgc(&argc); - if(NS_FAILED(rv)) - argc = bac ? *bac : 0; - - rv = cmdLineArgs->GetArgv(&argv); - if(NS_FAILED(rv)) - argv = bav; - } - - XtSetLanguageProc(NULL, NULL, NULL); - - mTopLevel = XtAppInitialize(&sAppContext, // app_context_return - "nsAppShell", // application_class - NULL, // options - 0, // num_options - &argc, // argc_in_out - argv, // argv_in_out - NULL, // fallback_resources - NULL, // args - 0); // num_args - - printf("nsAppShell::Create() app_context = %p\n",sAppContext); - - xlib_rgb_init(XtDisplay(mTopLevel), XtScreen(mTopLevel)); - - printf("xlib_rgb_init(display=%p,screen=%p)\n", - XtDisplay(mTopLevel), - XtScreen(mTopLevel)); - - SetAppContext(sAppContext); - - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Enter a message handler loop -// -//------------------------------------------------------------------------- - -static void event_processor_callback(XtPointer aClosure, - int * aFd, - XtIntervalId * aId) -{ - nsIEventQueue *eventQueue = (nsIEventQueue*)aClosure; - eventQueue->ProcessPendingEvents(); -} - -NS_METHOD nsAppShell::Run() -{ - NS_ADDREF_THIS(); - nsresult rv = NS_OK; - nsIEventQueue * EQueue = nsnull; - - // Get the event queue service - nsCOMPtr eventQService = - do_GetService(kEventQueueServiceCID, &rv); - if (NS_FAILED(rv)) { - NS_ASSERTION("Could not obtain event queue service", PR_FALSE); - return rv; - } - -#ifdef DEBUG - printf("Got the event queue from the service\n"); -#endif /* DEBUG */ - - //Get the event queue for the thread. - rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &EQueue); - - // If a queue already present use it. - if (EQueue) - goto done; - - // Create the event queue for the thread - rv = eventQService->CreateThreadEventQueue(); - if (NS_OK != rv) { - NS_ASSERTION("Could not create the thread event queue", PR_FALSE); - return rv; - } - //Get the event queue for the thread - rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &EQueue); - if (NS_OK != rv) { - NS_ASSERTION("Could not obtain the thread event queue", PR_FALSE); - return rv; - } - - -done: - - printf("Calling XtAppAddInput() with event queue\n"); - - XtAppAddInput(nsAppShell::GetAppContext(), - EQueue->GetEventQueueSelectFD(), - (XtPointer) XtInputReadMask, - event_processor_callback, - EQueue); - - XtRealizeWidget(mTopLevel); - -#ifdef DO_THE_EDITRES_THING - XtAddEventHandler(mTopLevel, - (EventMask) 0, - True, - (XtEventHandler) _XEditResCheckMessages, - (XtPointer)NULL); -#endif - - XEvent event; - - for (;;) - { - XtAppNextEvent(sAppContext, &event); - - XtDispatchEvent(&event); - - if (mDispatchListener) - mDispatchListener->AfterDispatch(); - } - - NS_IF_RELEASE(EQueue); - Release(); - return NS_OK; -} - -NS_METHOD nsAppShell::Spinup() -{ - return NS_OK; -} - -NS_METHOD nsAppShell::Spindown() -{ - return NS_OK; -} - -NS_METHOD nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *&aEvent) -{ - //XXX:Implement this. - return NS_OK; -} - -NS_METHOD nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void * aEvent) -{ - //XXX:Implement this. - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Exit a message handler loop -// -//------------------------------------------------------------------------- - -NS_METHOD nsAppShell::Exit() -{ - exit(0); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// nsAppShell constructor -// -//------------------------------------------------------------------------- -nsAppShell::nsAppShell() -{ - NS_INIT_REFCNT(); - mDispatchListener = 0; -} - -//------------------------------------------------------------------------- -// -// nsAppShell destructor -// -//------------------------------------------------------------------------- -nsAppShell::~nsAppShell() -{ -} - -//------------------------------------------------------------------------- -// -// GetNativeData -// -//------------------------------------------------------------------------- -void* nsAppShell::GetNativeData(PRUint32 aDataType) -{ - if (aDataType == NS_NATIVE_SHELL) { - return mTopLevel; - } - return nsnull; -} - - -static NS_DEFINE_CID(kCMotifAppContextServiceCID, NS_MOTIF_APP_CONTEXT_SERVICE_CID); - -//------------------------------------------------------------------------- -// -// SetAppContext -// -//------------------------------------------------------------------------- -/* static */ void -nsAppShell::SetAppContext(XtAppContext aAppContext) -{ - NS_ASSERTION(aAppContext != nsnull,"App context cant be null."); - - static PRBool once = PR_TRUE; - - if (once) - { - once = PR_FALSE; - - nsresult rv; - nsIMotifAppContextService * ac_service = nsnull; - - rv = nsComponentManager::CreateInstance(kCMotifAppContextServiceCID, - nsnull, - NS_GET_IID(nsIMotifAppContextService), - (void **)& ac_service); - - NS_ASSERTION(rv == NS_OK,"Cannot obtain app context service."); - - if (ac_service) - { - printf("nsAppShell::SetAppContext() ac_service = %p\n",ac_service); - - nsresult rv2 = ac_service->SetAppContext(aAppContext); - - NS_ASSERTION(rv2 == NS_OK,"Cannot set the app context."); - - printf("nsAppShell::SetAppContext() All is ok.\n"); - - NS_RELEASE(ac_service); - } - } -} diff --git a/widget/src/motif/nsAppShell.h b/widget/src/motif/nsAppShell.h deleted file mode 100644 index 112c27fb4407..000000000000 --- a/widget/src/motif/nsAppShell.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsAppShell_h__ -#define nsAppShell_h__ - -#include "nsIAppShell.h" - -#include - -/** - * Native MOTIF Application shell wrapper - */ - -class nsAppShell : public nsIAppShell -{ - private: - Widget mTopLevel; - nsDispatchListener* mDispatchListener; - - public: - nsAppShell(); - virtual ~nsAppShell(); - - NS_DECL_ISUPPORTS - - // nsIAppShellInterface - NS_IMETHOD Create(int* argc, char ** argv); - NS_IMETHOD Run(); - NS_IMETHOD Spinup(); - NS_IMETHOD Spindown(); - NS_IMETHOD ListenToEventQueue(nsIEventQueue *aQueue, PRBool aListen) - { return NS_OK; } - NS_IMETHOD GetNativeEvent(PRBool &aRealEvent, void *&aEvent); - NS_IMETHOD DispatchNativeEvent(PRBool aRealEvent, void * aEvent); - NS_IMETHOD Exit(); - NS_IMETHOD SetDispatchListener(nsDispatchListener* aDispatchListener); - virtual void* GetNativeData(PRUint32 aDataType); - - static XtAppContext GetAppContext() { return sAppContext; } - -private: - - static void SetAppContext(XtAppContext aAppContext); - - static XtAppContext sAppContext; -}; - -#endif // nsAppShell_h__ diff --git a/widget/src/motif/nsBidiKeyboard.cpp b/widget/src/motif/nsBidiKeyboard.cpp deleted file mode 100644 index 2eacce44b352..000000000000 --- a/widget/src/motif/nsBidiKeyboard.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is IBM code. - * - * The Initial Developer of the Original Code is IBM. - * Portions created by IBM are - * Copyright (C) International Business Machines - * Corporation, 2000. All Rights Reserved. - * - * Contributor(s): Simon Montagu - */ - -#include "nsBidiKeyboard.h" - -NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard) - -nsBidiKeyboard::nsBidiKeyboard() : nsIBidiKeyboard() -{ - NS_INIT_REFCNT(); -} - -nsBidiKeyboard::~nsBidiKeyboard() -{ -} - -NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL) -{ - *aIsRTL = PR_FALSE; -#ifdef IBMBIDI - // XXX Insert platform specific code to determine keyboard direction -#endif - return NS_OK; -} - -NS_IMETHODIMP nsBidiKeyboard::SetLangFromBidiLevel(PRUint8 aLevel) -{ -#ifdef IBMBIDI - // XXX Insert platform specific code to set keyboard language -#endif - return NS_OK; -} diff --git a/widget/src/motif/nsBidiKeyboard.h b/widget/src/motif/nsBidiKeyboard.h deleted file mode 100644 index 107f09a4501e..000000000000 --- a/widget/src/motif/nsBidiKeyboard.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is IBM code. - * - * The Initial Developer of the Original Code is IBM. - * Portions created by IBM are - * Copyright (C) International Business Machines - * Corporation, 2000. All Rights Reserved. - * - * Contributor(s): Simon Montagu - */ - -#ifndef __nsBidiKeyboard -#define __nsBidiKeyboard -#include "nsIBidiKeyboard.h" - -class nsBidiKeyboard : public nsIBidiKeyboard -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIBIDIKEYBOARD - - nsBidiKeyboard(); - virtual ~nsBidiKeyboard(); - /* additional members */ -}; - - -#endif // __nsBidiKeyboard diff --git a/widget/src/motif/nsButton.cpp b/widget/src/motif/nsButton.cpp deleted file mode 100644 index fee783a05c28..000000000000 --- a/widget/src/motif/nsButton.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsButton.h" -#include "nsIButton.h" -#include "nsToolkit.h" -#include "nsColor.h" -#include "nsGUIEvent.h" -#include "nsString.h" -#include "nsStringUtil.h" - -#include "nsXtEventHandler.h" - -#include - -NS_IMPL_ADDREF(nsButton) -NS_IMPL_RELEASE(nsButton) - -//------------------------------------------------------------------------- -// -// nsButton constructor -// -//------------------------------------------------------------------------- -nsButton::nsButton() : nsWindow() , nsIButton() -{ - NS_INIT_REFCNT(); -} - - -NS_METHOD nsButton::Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - aParent->AddChild(this); - Widget parentWidget = nsnull; - - if (aParent) { - parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET); - } else if (aAppShell) { - parentWidget = (Widget) aAppShell->GetNativeData(NS_NATIVE_SHELL); - } - - InitToolkit(aToolkit, aParent); - InitDeviceContext(aContext, parentWidget); - - mWidget = ::XtVaCreateManagedWidget("button", - xmPushButtonWidgetClass, - parentWidget, - XmNwidth, aRect.width, - XmNheight, aRect.height, - XmNrecomputeSize, False, - XmNhighlightOnEnter, False, - XmNx, aRect.x, - XmNy, aRect.y, - nsnull); - - // save the event callback function - mEventCallback = aHandleEventFunction; - - InitCallbacks("nsButton"); - return NS_OK; - -} - -NS_METHOD nsButton::Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - return NS_ERROR_FAILURE; - -} - -//------------------------------------------------------------------------- -// -// nsButton destructor -// -//------------------------------------------------------------------------- -nsButton::~nsButton() -{ -} - - -/** - * Implement the standard QueryInterface for NS_IWIDGET_IID and NS_ISUPPORTS_IID - * @modify gpk 8/4/98 - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -nsresult nsButton::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - static NS_DEFINE_IID(kIButton, NS_IBUTTON_IID); - if (aIID.Equals(kIButton)) { - *aInstancePtr = (void*) ((nsIButton*)this); - AddRef(); - return NS_OK; - } - - return nsWindow::QueryInterface(aIID,aInstancePtr); -} - - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsButton::SetLabel(const nsString& aText) -{ - NS_ALLOC_STR_BUF(label, aText, 256); - XmString str; - str = XmStringCreate(label, XmFONTLIST_DEFAULT_TAG); - XtVaSetValues(mWidget, XmNlabelString, str, nsnull); - NS_FREE_STR_BUF(label); - XmStringFree(str); - return (NS_OK); -} - -//------------------------------------------------------------------------- -// -// Get this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsButton::GetLabel(nsString& aBuffer) -{ - XmString str; - XtVaGetValues(mWidget, XmNlabelString, &str, nsnull); - char * text; - if (XmStringGetLtoR(str, XmFONTLIST_DEFAULT_TAG, &text)) { - aBuffer.SetLength(0); - aBuffer.Append(text); - XtFree(text); - } - - XmStringFree(str); - return (NS_OK); - -} diff --git a/widget/src/motif/nsButton.h b/widget/src/motif/nsButton.h deleted file mode 100644 index 703f4232f5ac..000000000000 --- a/widget/src/motif/nsButton.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsButton_h__ -#define nsButton_h__ - -#include "nsWindow.h" -#include "nsIButton.h" - -/** - * Native Motif button wrapper - */ -class nsButton : public nsWindow, - public nsIButton -{ - -public: - nsButton(); - virtual ~nsButton(); - - // nsISupports - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - - NS_IMETHOD Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - NS_IMETHOD Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - - // nsIButton part - NS_IMETHOD SetLabel(const nsString& aText); - NS_IMETHOD GetLabel(nsString& aBuffer); - - virtual PRBool OnMove(PRInt32 aX, PRInt32 aY) { return PR_FALSE; } - virtual PRBool OnPaint(nsPaintEvent & aEvent) { return PR_FALSE; } - virtual PRBool OnResize(nsSizeEvent &aEvent) { return PR_FALSE; } -}; - -#endif // nsButton_h__ diff --git a/widget/src/motif/nsCheckButton.cpp b/widget/src/motif/nsCheckButton.cpp deleted file mode 100644 index da13d276b808..000000000000 --- a/widget/src/motif/nsCheckButton.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsCheckButton.h" -#include "nsColor.h" -#include "nsGUIEvent.h" -#include "nsString.h" -#include "nsStringUtil.h" - -#include "nsXtEventHandler.h" -#include - -NS_IMPL_ADDREF(nsCheckButton) -NS_IMPL_RELEASE(nsCheckButton) - -//------------------------------------------------------------------------- -// -// nsCheckButton constructor -// -//------------------------------------------------------------------------- -nsCheckButton::nsCheckButton() : nsWindow() , nsICheckButton() -{ - NS_INIT_REFCNT(); -} - -//------------------------------------------------------------------------- -// -// nsCheckButton destructor -// -//------------------------------------------------------------------------- -nsCheckButton::~nsCheckButton() -{ -} - -//------------------------------------------------------------------------- -// -// nsCheckButton Creator -// -//------------------------------------------------------------------------- -NS_METHOD nsCheckButton::Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - aParent->AddChild(this); - Widget parentWidget = nsnull; - - if (aParent) { - parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET); - } else { - parentWidget = (Widget) aAppShell->GetNativeData(NS_NATIVE_SHELL); - } - - InitToolkit(aToolkit, aParent); - InitDeviceContext(aContext, parentWidget); - - mWidget = ::XtVaCreateManagedWidget("", - xmToggleButtonWidgetClass, - parentWidget, - XmNwidth, aRect.width, - XmNheight, aRect.height, - XmNrecomputeSize, False, - XmNhighlightOnEnter, False, - XmNx, aRect.x, - XmNy, aRect.y, - XmNresizeHeight, False, - XmNresizeWidth, False, - XmNmarginHeight, 0, - XmNmarginWidth, 0, - XmNadjustMargin, False, - XmNspacing, 0, - XmNisAligned, False, - XmNentryBorder, 0, - XmNborderWidth, 0, - 0); - - // save the event callback function - mEventCallback = aHandleEventFunction; - - InitCallbacks(); - - XtAddCallback(mWidget, - XmNarmCallback, - nsXtWidget_Toggle_ArmCallback, - this); - - XtAddCallback(mWidget, - XmNdisarmCallback, - nsXtWidget_Toggle_DisArmCallback, - this); - - - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// nsCheckButton Creator -// -//------------------------------------------------------------------------- -NS_METHOD nsCheckButton::Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - return NS_ERROR_FAILURE; -} - -/** - * Implement the standard QueryInterface for NS_IWIDGET_IID and NS_ISUPPORTS_IID - * @modify gpk 8/4/98 - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -nsresult nsCheckButton::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID); - if (aIID.Equals(kICheckButtonIID)) { - *aInstancePtr = (void*) ((nsICheckButton*)this); - AddRef(); - return NS_OK; - } - return nsWindow::QueryInterface(aIID,aInstancePtr); -} - -//------------------------------------------------------------------------- -// -// Armed -// -//------------------------------------------------------------------------- -void nsCheckButton::Armed() -{ - mIsArmed = PR_TRUE; - mValueWasSet = PR_FALSE; - mInitialState = XmToggleButtonGetState(mWidget); -} - -//------------------------------------------------------------------------- -// -// DisArmed -// -//------------------------------------------------------------------------- -void nsCheckButton::DisArmed() -{ - if (mValueWasSet) { - XmToggleButtonSetState(mWidget, mNewValue, TRUE); - } else { - XmToggleButtonSetState(mWidget, mInitialState, TRUE); - } - mIsArmed = PR_FALSE; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsCheckButton::SetState(const PRBool aState) -{ - if (mIsArmed) { - mNewValue = aState; - mValueWasSet = PR_TRUE; - } - XmToggleButtonSetState(mWidget, aState, TRUE); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsCheckButton::GetState(PRBool& aState) -{ - int state = XmToggleButtonGetState(mWidget); - if (mIsArmed) { - if (mValueWasSet) { - aState = mNewValue; - } else { - aState = state; - } - } else { - aState = state; - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set this Checkbox label -// -//------------------------------------------------------------------------- -NS_METHOD nsCheckButton::SetLabel(const nsString& aText) -{ - NS_ALLOC_STR_BUF(label, aText, 256); - XmString str; - str = XmStringCreate(label, XmFONTLIST_DEFAULT_TAG); - XtVaSetValues(mWidget, XmNlabelString, str, nsnull); - NS_FREE_STR_BUF(label); - XmStringFree(str); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsCheckButton::GetLabel(nsString& aBuffer) -{ - XmString str; - XtVaGetValues(mWidget, XmNlabelString, &str, nsnull); - char * text; - if (XmStringGetLtoR(str, XmFONTLIST_DEFAULT_TAG, &text)) { - aBuffer.SetLength(0); - aBuffer.Append(text); - XtFree(text); - } - XmStringFree(str); - return NS_OK; -} diff --git a/widget/src/motif/nsCheckButton.h b/widget/src/motif/nsCheckButton.h deleted file mode 100644 index f38a950af982..000000000000 --- a/widget/src/motif/nsCheckButton.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsCheckButton_h__ -#define nsCheckButton_h__ - -#include "nsWindow.h" -#include "nsICheckButton.h" - -/** - * Native Motif Checkbox wrapper - */ - -class nsCheckButton : public nsWindow, - public nsICheckButton -{ - -public: - nsCheckButton(); - virtual ~nsCheckButton(); - - // nsISupports - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - - // nsICheckButton part - NS_IMETHOD SetLabel(const nsString &aText); - NS_IMETHOD GetLabel(nsString &aBuffer); - NS_IMETHOD SetState(const PRBool aState); - NS_IMETHOD GetState(PRBool& aState); - - NS_IMETHOD Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - NS_IMETHOD Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - - virtual PRBool OnMove(PRInt32 aX, PRInt32 aY) { return PR_FALSE; } - virtual PRBool OnPaint(nsPaintEvent & aEvent) { return PR_FALSE; } - virtual PRBool OnResize(nsSizeEvent & aEvent) { return PR_FALSE; } - - // These are needed to Override the auto check behavior - void Armed(); - void DisArmed(); - -private: - - Boolean mInitialState; - Boolean mNewValue; - Boolean mValueWasSet; - Boolean mIsArmed; - -}; - -#endif // nsCheckButton_h__ diff --git a/widget/src/motif/nsLabel.cpp b/widget/src/motif/nsLabel.cpp deleted file mode 100644 index 27ef0c2cf7b8..000000000000 --- a/widget/src/motif/nsLabel.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsLabel.h" -#include "nsILabel.h" -#include "nsToolkit.h" -#include "nsColor.h" -#include "nsGUIEvent.h" -#include "nsString.h" -#include "nsStringUtil.h" - -#include "nsXtEventHandler.h" - -#include - -NS_IMPL_ADDREF(nsLabel) -NS_IMPL_RELEASE(nsLabel) - -//------------------------------------------------------------------------- -// -// nsLabel constructor -// -//------------------------------------------------------------------------- -nsLabel::nsLabel() : nsWindow(), nsILabel() -{ - NS_INIT_REFCNT(); - mAlignment = eAlign_Left; -} - - -NS_METHOD nsLabel::Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - aParent->AddChild(this); - Widget parentWidget = nsnull; - - if (aParent) { - parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET); - } else if (aAppShell) { - parentWidget = (Widget) aAppShell->GetNativeData(NS_NATIVE_SHELL); - } - - InitToolkit(aToolkit, aParent); - InitDeviceContext(aContext, parentWidget); - - unsigned char alignment = GetNativeAlignment(); - - mWidget = ::XtVaCreateManagedWidget("label", - xmLabelWidgetClass, - parentWidget, - XmNwidth, aRect.width, - XmNheight, aRect.height, - XmNrecomputeSize, False, - XmNhighlightOnEnter, False, - XmNx, aRect.x, - XmNy, aRect.y, - XmNalignment, alignment, - nsnull); - - // save the event callback function - mEventCallback = aHandleEventFunction; - - InitCallbacks("nsLabel"); - return NS_OK; -} - -NS_METHOD nsLabel::Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - return NS_ERROR_FAILURE; -} - -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- -NS_METHOD nsLabel::PreCreateWidget(nsWidgetInitData *aInitData) -{ - if (nsnull != aInitData) { - nsLabelInitData* data = (nsLabelInitData *) aInitData; - mAlignment = data->mAlignment; - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set alignment -// -//------------------------------------------------------------------------- -NS_METHOD nsLabel::SetAlignment(nsLabelAlignment aAlignment) -{ - mAlignment = aAlignment; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// nsLabel destructor -// -//------------------------------------------------------------------------- -nsLabel::~nsLabel() -{ -} - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsLabel::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr); - - static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kILabelIID)) { - *aInstancePtr = (void*) ((nsILabel*)this); - AddRef(); - result = NS_OK; - } - - return result; -} - - -//------------------------------------------------------------------------- -// -// -// -//------------------------------------------------------------------------- -unsigned char nsLabel::GetNativeAlignment() -{ - switch (mAlignment) { - case eAlign_Right : return XmALIGNMENT_END; - case eAlign_Left : return XmALIGNMENT_BEGINNING; - case eAlign_Center: return XmALIGNMENT_CENTER; - default : - return XmALIGNMENT_BEGINNING; - } - return XmALIGNMENT_BEGINNING; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsLabel::SetLabel(const nsString& aText) -{ - NS_ALLOC_STR_BUF(label, aText, 256); - XmString str; - str = XmStringCreate(label, XmFONTLIST_DEFAULT_TAG); - XtVaSetValues(mWidget, XmNlabelString, str, nsnull); - NS_FREE_STR_BUF(label); - XmStringFree(str); - return NS_OK; - -} - -//------------------------------------------------------------------------- -// -// Get this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsLabel::GetLabel(nsString& aBuffer) -{ - XmString str; - XtVaGetValues(mWidget, XmNlabelString, &str, nsnull); - char * text; - if (XmStringGetLtoR(str, XmFONTLIST_DEFAULT_TAG, &text)) { - aBuffer.SetLength(0); - aBuffer.Append(text); - XtFree(text); - } - - XmStringFree(str); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// paint message. Don't send the paint out -// -//------------------------------------------------------------------------- -PRBool nsLabel::OnMove(PRInt32, PRInt32) -{ - return PR_FALSE; -} - -PRBool nsLabel::OnPaint(nsPaintEvent &aEvent) -{ - //printf("** nsLabel::OnPaint **\n"); - return PR_FALSE; -} - -PRBool nsLabel::OnResize(nsSizeEvent &aEvent) -{ - return PR_FALSE; -} - - diff --git a/widget/src/motif/nsLabel.h b/widget/src/motif/nsLabel.h deleted file mode 100644 index 64d852e48169..000000000000 --- a/widget/src/motif/nsLabel.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsLabel_h__ -#define nsLabel_h__ - -#include "nsWindow.h" -#include "nsILabel.h" - -/** - * Native Motif Label wrapper - */ -class nsLabel : public nsWindow, - public nsILabel -{ - -public: - - nsLabel(); - virtual ~nsLabel(); - - // nsISupports - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - - // nsILabel part - NS_IMETHOD SetLabel(const nsString &aText); - NS_IMETHOD GetLabel(nsString &aBuffer); - NS_IMETHOD SetAlignment(nsLabelAlignment aAlignment); - - NS_IMETHOD PreCreateWidget(nsWidgetInitData *aInitData); - - NS_IMETHOD Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - NS_IMETHOD Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - - virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); - virtual PRBool OnPaint(nsPaintEvent &aEvent); - virtual PRBool OnResize(nsSizeEvent &aEvent); - -protected: - unsigned char GetNativeAlignment(); - nsLabelAlignment mAlignment; - -}; - -#endif // nsLabel_h__ diff --git a/widget/src/motif/nsLookAndFeel.cpp b/widget/src/motif/nsLookAndFeel.cpp deleted file mode 100644 index 88907642f69e..000000000000 --- a/widget/src/motif/nsLookAndFeel.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsLookAndFeel.h" - -#include "nsXPLookAndFeel.h" - -NS_IMPL_ISUPPORTS1(nsLookAndFeel, nsILookAndFeel) - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsLookAndFeel::nsLookAndFeel() -{ - NS_INIT_REFCNT(); -} - -nsLookAndFeel::~nsLookAndFeel() -{ -} - -NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor) -{ - nsresult res = NS_OK; - - if (mXPLookAndFeel) - { - res = mXPLookAndFeel->GetColor(aID, aColor); - if (NS_SUCCEEDED(res)) - return res; - res = NS_OK; - } - - /* - * There used to be an entirely separate list of these colors in - * nsDeviceContextMotif::GetSystemAttribute. The colors given there - * were a bit different from these. If these are inaccurate, it - * might be worth looking at cvs history for the ones there to see - * if they were better. - */ - - switch (aID) { - case eColor_WindowBackground: - aColor = NS_RGB(0xff,0xff,0xff); - break; - case eColor_WindowForeground: - aColor = NS_RGB(0x00,0x00,0x00); - break; - case eColor_WidgetBackground: - aColor = NS_RGB(192, 192, 192); - break; - case eColor_WidgetForeground: - aColor = NS_RGB(0x00,0x00,0x00); - break; - case eColor_WidgetSelectBackground: - aColor = NS_RGB(0x80,0x80,0x80); - break; - case eColor_WidgetSelectForeground: - aColor = NS_RGB(0x00,0x00,0x80); - break; - case eColor_Widget3DHighlight: - aColor = NS_RGB(0xa0,0xa0,0xa0); - break; - case eColor_Widget3DShadow: - aColor = NS_RGB(0x40,0x40,0x40); - break; - case eColor_TextBackground: - aColor = NS_RGB(0xff,0xff,0xff); - break; - case eColor_TextForeground: - aColor = NS_RGB(0x00,0x00,0x00); - break; - case eColor_TextSelectBackground: - res = NS_RGB(0x00,0x00,0x80); - break; - case eColor_TextSelectForeground: - aColor = NS_RGB(0xff,0xff,0xff); - break; - default: - aColor = NS_RGB(0xff,0xff,0xff); - res = NS_ERROR_FAILURE; - break; - } - - return res; -} - -NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) -{ - nsresult res = NS_OK; - - if (mXPLookAndFeel) - { - res = mXPLookAndFeel->GetMetric(aID, aMetric); - if (NS_SUCCEEDED(res)) - return res; - res = NS_OK; - } - - /* - * There used to be an entirely separate list of these metrics in - * nsDeviceContextMotif::GetSystemAttribute. The metrics given - * there were a bit different from these. If these are inaccurate, - * it might be worth looking at cvs history for the ones there to - * see if they were better. - */ - - switch (aID) { - case eMetric_WindowTitleHeight: - aMetric = 0; - break; - case eMetric_WindowBorderWidth: - aMetric = 4; - break; - case eMetric_WindowBorderHeight: - aMetric = 4; - break; - case eMetric_Widget3DBorder: - aMetric = 4; - break; - case eMetric_TextFieldHeight: - aMetric = 30; - break; - case eMetric_CheckboxSize: - aMetric = 12; - break; - case eMetric_RadioboxSize: - aMetric = 12; - break; - case eMetric_CaretBlinkTime: - aMetric = 500; - break; - case eMetric_SingleLineCaretWidth: - case eMetric_MultiLineCaretWidth: - aMetric = 1; - break; - case eMetric_SubmenuDelay: - aMetric = 200; - break; - default: - aMetric = 0; - res = NS_ERROR_FAILURE; - } - return res; -} - -NS_METHOD nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetric) -{ - - if (mXPLookAndFeel) - { - res = mXPLookAndFeel->GetMetric(aID, aMetric); - if (NS_SUCCEEDED(res)) - return res; - } - - // FIXME: Need to implement. --ZuperDee - return NS_OK; -} - -#ifdef NS_DEBUG -NS_IMETHODIMP nsLookAndFeel::GetNavSize(const nsMetricNavWidgetID aWidgetID, - const nsMetricNavFontID aFontID, - const PRInt32 aFontSize, - nsSize &aSize) -{ - if (mXPLookAndFeel) - { - nsresult rv = mXPLookAndFeel->GetNavSize(aWidgetID, aFontID, aFontSize, aSize); - if (NS_SUCCEEDED(rv)) - return rv; - } - - aSize.width = 0; - aSize.height = 0; - return NS_ERROR_NOT_IMPLEMENTED; -} -#endif diff --git a/widget/src/motif/nsLookAndFeel.h b/widget/src/motif/nsLookAndFeel.h deleted file mode 100644 index 9198d8181f76..000000000000 --- a/widget/src/motif/nsLookAndFeel.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef __nsLookAndFeel -#define __nsLookAndFeel -#include "nsILookAndFeel.h" -#include "nsCOMPtr.h" - -class nsLookAndFeel: public nsILookAndFeel { - NS_DECL_ISUPPORTS - -public: - nsLookAndFeel(); - virtual ~nsLookAndFeel(); - - NS_IMETHOD GetColor(const nsColorID aID, nscolor &aColor); - NS_IMETHOD GetMetric(const nsMetricID aID, PRInt32 & aMetric); - NS_IMETHOD GetMetric(const nsMetricFloatID aID, float & aMetric); - -#ifdef NS_DEBUG - // This method returns the actual (or nearest estimate) - // of the Navigator size for a given form control for a given font - // and font size. This is used in NavQuirks mode to see how closely - // we match its size - NS_IMETHOD GetNavSize(const nsMetricNavWidgetID aWidgetID, - const nsMetricNavFontID aFontID, - const PRInt32 aFontSize, - nsSize &aSize); -#endif - -protected: - nsCOMPtr mXPLookAndFeel; -}; - -#endif diff --git a/widget/src/motif/nsMenu.cpp b/widget/src/motif/nsMenu.cpp deleted file mode 100644 index 2642b5d264ae..000000000000 --- a/widget/src/motif/nsMenu.cpp +++ /dev/null @@ -1,538 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsMenu.h" -#include "nsIComponentManager.h" -#include "nsIDOMElement.h" -#include "nsIDOMNode.h" -#include "nsIMenu.h" -#include "nsIMenuBar.h" -#include "nsIMenuItem.h" -#include "nsIMenuListener.h" - -#include "nsString.h" -#include "nsReadableUtils.h" -#include "nsStringUtil.h" - -#include "nsCOMPtr.h" -#include "nsWidgetsCID.h" - -#include -#include -#include - -static NS_DEFINE_CID(kMenuCID, NS_MENU_CID); -static NS_DEFINE_CID(kMenuItemCID, NS_MENUITEM_CID); -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); - -nsresult nsMenu::QueryInterface(REFNSIID aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - *aInstancePtr = NULL; - - if (aIID.Equals(NS_GET_IID(nsIMenu))) { - *aInstancePtr = (void*)(nsIMenu*) this; - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*)(nsISupports*)(nsIMenu*)this; - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(kIMenuListenerIID)) { - *aInstancePtr = (void*)(nsIMenuListener*)this; - NS_ADDREF_THIS(); - return NS_OK; - } - return NS_NOINTERFACE; -} - -NS_IMPL_ADDREF(nsMenu) -NS_IMPL_RELEASE(nsMenu) - -//------------------------------------------------------------------------- -// -// nsMenu constructor -// -//------------------------------------------------------------------------- -nsMenu::nsMenu() : nsIMenu() -{ - NS_INIT_REFCNT(); - mNumMenuItems = 0; - mMenu = nsnull; - mMenuParent = nsnull; - mMenuBarParent = nsnull; - mListener = nsnull; - mConstructCalled = PR_FALSE; - - mDOMNode = nsnull; - mWebShell = nsnull; - mDOMElement = nsnull; - mAccessKey = "_"; -} - -//------------------------------------------------------------------------- -// -// nsMenu destructor -// -//------------------------------------------------------------------------- -nsMenu::~nsMenu() -{ - NS_IF_RELEASE(mListener); - // Free our menu items - RemoveAll(); - XtDestroyWidget(mMenu); - mMenu = nsnull; -} - -//------------------------------------------------------------------------- -Widget nsMenu::GetNativeParent() -{ - void * voidData; - if (nsnull != mMenuParent) { - mMenuParent->GetNativeData(&voidData); - } else if (nsnull != mMenuBarParent) { - mMenuBarParent->GetNativeData(voidData); - } else { - return NULL; - } - return (Widget)voidData; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenu::Create(nsISupports * aParent, const nsString &aLabel) -{ - printf("nsMenu::Create called\n"); - if(aParent) - { - nsIMenuBar * menubar = nsnull; - aParent->QueryInterface(NS_GET_IID(nsIMenuBar), (void**) &menubar); - if(menubar) - { - mMenuBarParent = menubar; - NS_RELEASE(menubar); - } - else - { - nsIMenu * menu = nsnull; - aParent->QueryInterface(NS_GET_IID(nsIMenu), (void**) &menu); - if(menu) - { - mMenuParent = menu; - NS_RELEASE(menu); - } - } - } - - mLabel = aLabel; - - char * labelStr = ToNewCString(mLabel); - - char wName[512]; - - sprintf(wName, "__pulldown_%s", labelStr); - NS_ADDREF(mMenuBarParent); - mMenu = XmCreatePulldownMenu(GetNativeParent(), wName, NULL, 0); - - Widget casBtn; - XmString str; - - str = XmStringCreateLocalized(labelStr); - casBtn = XtVaCreateManagedWidget(labelStr, - xmCascadeButtonGadgetClass, GetNativeParent(), - XmNsubMenuId, mMenu, - XmNlabelString, str, - NULL); - XmStringFree(str); - - delete[] labelStr; - - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenu::GetParent(nsISupports*& aParent) -{ - aParent = nsnull; - if (nsnull != mMenuParent) { - return mMenuParent->QueryInterface(kISupportsIID,(void**)&aParent); - } else if (nsnull != mMenuBarParent) { - return mMenuBarParent->QueryInterface(kISupportsIID,(void**)&aParent); - } - - return NS_ERROR_FAILURE; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenu::GetLabel(nsString &aText) -{ - aText = mLabel; - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenu::SetLabel(const nsString &aText) -{ - mLabel = aText; - return NS_OK; -} - -NS_METHOD nsMenu::GetAccessKey(nsString &aText) -{ - return NS_OK; -} - -NS_METHOD nsMenu::SetAccessKey(const nsString &aText) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenu::AddItem(nsISupports * aItem) -{ - printf("nsMenu::AddItem called\n"); - if(aItem) - { - nsIMenuItem * menuitem = nsnull; - aItem->QueryInterface(NS_GET_IID(nsIMenuItem), - (void**)&menuitem); - if(menuitem) - { - AddMenuItem(menuitem); // nsMenu now owns this - NS_RELEASE(menuitem); - } - else - { - nsIMenu * menu = nsnull; - aItem->QueryInterface(NS_GET_IID(nsIMenu), - (void**)&menu); - if(menu) - { - AddMenu(menu); // nsMenu now owns this - NS_RELEASE(menu); - } - } - } - - return NS_OK; -} - -// local method used by nsMenu::AddItem -//------------------------------------------------------------------------- -NS_METHOD nsMenu::AddMenuItem(nsIMenuItem * aMenuItem) -{ - // XXX add aMenuItem to internal data structor list - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenu::AddMenu(nsIMenu * aMenu) -{ - // XXX add aMenu to internal data structor list - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenu::AddSeparator() -{ - printf("nsMenu::AddSeparator() called\n"); - XtVaCreateManagedWidget("__sep", xmSeparatorGadgetClass, mMenu, NULL); - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenu::GetItemCount(PRUint32 &aCount) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenu::GetItemAt(const PRUint32 aPos, nsISupports *& aMenuItem) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenu::InsertItemAt(const PRUint32 aPos, nsISupports * aMenuItem) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenu::RemoveItem(const PRUint32 aCount) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenu::RemoveAll() -{ - return NS_OK; -} - -NS_METHOD nsMenu::SetNativeData(void * aData) -{ - return NS_OK; -} - -NS_METHOD nsMenu::GetNativeData(void ** aData) -{ - aData = (void **)mMenu; - return NS_OK; -} - -NS_METHOD nsMenu::AddMenuListener(nsIMenuListener * aMenuListener) -{ - mListener = aMenuListener; - NS_ADDREF(mListener); - return NS_OK; -} - -NS_METHOD nsMenu::RemoveMenuListener(nsIMenuListener * aMenuListener) -{ - if (aMenuListener == mListener) { - NS_IF_RELEASE(mListener); - } - return NS_OK; -} - -NS_METHOD nsMenu::SetEnabled(PRBool aIsEnabled) -{ - return NS_OK; -} - -NS_METHOD nsMenu::SetDOMNode(nsIDOMNode * aMenuNode) -{ - mDOMNode = aMenuNode; - return NS_OK; -} - -NS_METHOD nsMenu::SetDOMElement(nsIDOMElement * aMenuElement) -{ - mDOMElement = aMenuElement; - return NS_OK; -} - -NS_METHOD nsMenu::SetWebShell(nsIWebShell * aWebShell) -{ - mWebShell = aWebShell; - return NS_OK; -} - -void nsMenu::LoadMenuItem(nsIMenu * pParentMenu, - nsIDOMElement * menuitemElement, - nsIDOMNode * menuitemNode, - unsigned short menuitemIndex, - nsIWebShell * aWebShell) -{ - //XXX:Implement this. - return; -} - -void nsMenu::LoadSubMenu(nsIMenu * pParentMenu, - nsIDOMElement * menuElement, - nsIDOMNode * menuNode) -{ - nsString menuName; - menuElement->GetAttribute(nsAutoString("label"), menuName); - //printf("Creating Menu [%s] \n", NS_LossyConvertUCS2toASCII(menuName).get()); - - // Create nsMenu - nsIMenu * pnsMenu = nsnull; - nsresult rv = nsComponentManager::CreateInstance(kMenuCID, - nsnull, - NS_GET_IID(nsIMenu), - (void**)&pnsMenu); - if (NS_OK == rv) { - // Call Create - nsISupports * supports = nsnull; - pParentMenu->QueryInterface(kISupportsIID, (void**) &supports); - pnsMenu->Create(supports, menuName); - NS_RELEASE(supports); // Balance QI - - // Set nsMenu Name - pnsMenu->SetLabel(menuName); - - supports = nsnull; - pnsMenu->QueryInterface(kISupportsIID, (void**) &supports); - pParentMenu->AddItem(supports); // parent takes ownership - NS_RELEASE(supports); - - pnsMenu->SetWebShell(mWebShell); - pnsMenu->SetDOMNode(menuNode); - - /* - // Begin menuitem inner loop - unsigned short menuIndex = 0; - - nsCOMPtr menuitemNode; - menuNode->GetFirstChild(getter_AddRefs(menuitemNode)); - while (menuitemNode) { - nsCOMPtr menuitemElement(do_QueryInterface(menuitemNode)); - if (menuitemElement) { - nsString menuitemNodeType; - menuitemElement->GetNodeName(menuitemNodeType); - -#ifdef DEBUG_saari - printf("Type [%s] %d\n", NS_LossyConvertUCS2toASCII(menuitemNodeType).get(), menuitemNodeType.Equals("menuseparator")); -#endif - - if (menuitemNodeType.Equals("menuitem")) { - // Load a menuitem - LoadMenuItem(pnsMenu, menuitemElement, menuitemNode, menuIndex, mWebShell); - } else if (menuitemNodeType.Equals("menuseparator")) { - pnsMenu->AddSeparator(); - } else if (menuitemNodeType.Equals("menu")) { - // Add a submenu - LoadSubMenu(pnsMenu, menuitemElement, menuitemNode); - } - } - ++menuIndex; - nsCOMPtr oldmenuitemNode(menuitemNode); - oldmenuitemNode->GetNextSibling(getter_AddRefs(menuitemNode)); - } // end menu item innner loop - */ - } -} - -nsEventStatus nsMenu::MenuItemSelected(const nsMenuEvent & aMenuEvent) -{ - return nsEventStatus_eIgnore; -} - -nsEventStatus nsMenu::MenuSelected(const nsMenuEvent & aMenuEvent) -{ - return nsEventStatus_eIgnore; -} - -nsEventStatus nsMenu::MenuDeselected(const nsMenuEvent & aMenuEvent) -{ - if (nsnull != mListener) { - mListener->MenuDeselected(aMenuEvent); - } - return nsEventStatus_eIgnore; -} - -nsEventStatus nsMenu::MenuConstruct(const nsMenuEvent & aMenuEvent, - nsIWidget * aParentWindow, - void * menuNode, - void * aWebShell) -{ - printf("nsMenu::MenuConstruct called\n"); - if(menuNode){ - SetDOMNode((nsIDOMNode*)menuNode); - } - - if(!aWebShell){ - aWebShell = mWebShell; - } - - // First open the menu. - nsCOMPtr domElement = do_QueryInterface(mDOMNode); - if (domElement) - domElement->SetAttribute("open", "true"); - - - /// Now get the kids. Retrieve our menupopup child. - nsCOMPtr menuPopupNode; - mDOMNode->GetFirstChild(getter_AddRefs(menuPopupNode)); - while (menuPopupNode) { - nsCOMPtr menuPopupElement(do_QueryInterface(menuPopupNode)); - if (menuPopupElement) { - nsString menuPopupNodeType; - menuPopupElement->GetNodeName(menuPopupNodeType); - if (menuPopupNodeType.Equals("menupopup")) - break; - } - nsCOMPtr oldMenuPopupNode(menuPopupNode); - oldMenuPopupNode->GetNextSibling(getter_AddRefs(menuPopupNode)); - } - - if (!menuPopupNode) - return nsEventStatus_eIgnore; - - nsCOMPtr menuitemNode; - menuPopupNode->GetFirstChild(getter_AddRefs(menuitemNode)); - - unsigned short menuIndex = 0; - - while (menuitemNode) { - nsCOMPtr menuitemElement(do_QueryInterface(menuitemNode)); - if (menuitemElement) { - nsString menuitemNodeType; - nsString menuitemName; - menuitemElement->GetNodeName(menuitemNodeType); - if (menuitemNodeType.Equals("menuitem")) { - // LoadMenuItem - LoadMenuItem(this, - menuitemElement, - menuitemNode, - menuIndex, - (nsIWebShell*)aWebShell); - } else if (menuitemNodeType.Equals("menuseparator")) { - AddSeparator(); - } else if (menuitemNodeType.Equals("menu")) { - // Load a submenu - LoadSubMenu(this, menuitemElement, menuitemNode); - } - } - - ++menuIndex; - - nsCOMPtr oldmenuitemNode(menuitemNode); - oldmenuitemNode->GetNextSibling(getter_AddRefs(menuitemNode)); - } // end menu item innner loop - return nsEventStatus_eIgnore; -} - -nsEventStatus nsMenu::MenuDestruct(const nsMenuEvent & aMenuEvent) -{ - printf("nsMenu::MenuDestruct called\n"); - // Close the node. - nsCOMPtr domElement = do_QueryInterface(mDOMNode); - if (domElement) - domElement->RemoveAttribute("open"); - - mConstructCalled = PR_FALSE; - RemoveAll(); - return nsEventStatus_eIgnore; -} diff --git a/widget/src/motif/nsMenu.h b/widget/src/motif/nsMenu.h deleted file mode 100644 index d2c38c9155f0..000000000000 --- a/widget/src/motif/nsMenu.h +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsMenu_h__ -#define nsMenu_h__ - -#include "nsIMenu.h" -#include "nsIMenuListener.h" -#include "nsVoidArray.h" - -#include "Xm/Xm.h" -#include "nsXtManageWidget.h" - -class nsIDOMElement; -class nsIDOMNode; -class nsIMenuBar; -class nsIWebShell; - -/** - * Native Motif Menu wrapper - */ - -class nsMenu : public nsIMenu, public nsIMenuListener -{ - -public: - nsMenu(); - virtual ~nsMenu(); - - NS_DECL_ISUPPORTS - - // nsIMenuListener methods - nsEventStatus MenuItemSelected(const nsMenuEvent & aMenuEvent); - nsEventStatus MenuSelected(const nsMenuEvent & aMenuEvent); - nsEventStatus MenuDeselected(const nsMenuEvent & aMenuEvent); - nsEventStatus MenuConstruct( - const nsMenuEvent & aMenuEvent, - nsIWidget * aParentWindow, - void * menuNode, - void * aWebShell); - nsEventStatus MenuDestruct(const nsMenuEvent & aMenuEvent); - - // nsIMenu Methods - NS_IMETHOD Create(nsISupports * aParent, const nsString &aLabel); - NS_IMETHOD GetParent(nsISupports *&aParent); - NS_IMETHOD GetLabel(nsString &aText); - NS_IMETHOD SetLabel(const nsString &aText); - NS_IMETHOD GetAccessKey(nsString &aText); - NS_IMETHOD SetAccessKey(const nsString &aText); - NS_IMETHOD AddItem(nsISupports* aItem); - NS_IMETHOD AddMenuItem(nsIMenuItem * aMenuItem); - NS_IMETHOD AddMenu(nsIMenu * aMenu); - NS_IMETHOD AddSeparator(); - NS_IMETHOD GetItemCount(PRUint32 &aCount); - NS_IMETHOD GetItemAt(const PRUint32 aPos, nsISupports *& aMenuItem); - NS_IMETHOD InsertItemAt(const PRUint32 aPos, nsISupports * aMenuItem); - NS_IMETHOD RemoveItem(const PRUint32 aCount); - NS_IMETHOD RemoveAll(); - NS_IMETHOD SetNativeData(void* aData); - NS_IMETHOD GetNativeData(void** aData); - NS_IMETHOD AddMenuListener(nsIMenuListener * aMenuListener); - NS_IMETHOD RemoveMenuListener(nsIMenuListener * aMenuListener); - NS_IMETHOD SetDOMNode(nsIDOMNode * aMenuNode); - NS_IMETHOD SetDOMElement(nsIDOMElement * aMenuElement); - NS_IMETHOD SetWebShell(nsIWebShell * aWebShell); - NS_IMETHOD SetEnabled(PRBool aIsEnabled); - -protected: - void LoadMenuItem( - nsIMenu * pParentMenu, - nsIDOMElement * menuitemElement, - nsIDOMNode * menuitemNode, - unsigned short menuitemIndex, - nsIWebShell * aWebShell); - - void LoadSubMenu( - nsIMenu * pParentMenu, - nsIDOMElement * menuElement, - nsIDOMNode * menuNode); - - Widget GetNativeParent(); - - nsString mLabel; - nsString mAccessKey; - PRUint32 mNumMenuItems; - Widget mMenu; - - nsIMenu *mMenuParent; - nsIMenuBar *mMenuBarParent; - nsIMenuListener * mListener; - - PRBool mConstructCalled; - nsIDOMNode * mDOMNode; - nsIWebShell * mWebShell; - nsIDOMElement * mDOMElement; -}; - -#endif // nsMenu_h__ diff --git a/widget/src/motif/nsMenuBar.cpp b/widget/src/motif/nsMenuBar.cpp deleted file mode 100644 index 33a0e437778e..000000000000 --- a/widget/src/motif/nsMenuBar.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include - -#include "nsMenuBar.h" -#include "nsMenuItem.h" -#include "nsIComponentManager.h" -#include "nsIDOMNode.h" -#include "nsIMenu.h" -#include "nsIWebShell.h" -#include "nsIWidget.h" - -#include "nsString.h" - -#include "nsCOMPtr.h" -#include "nsWidgetsCID.h" - -static NS_DEFINE_CID(kMenuBarCID, NS_MENUBAR_CID); -static NS_DEFINE_CID(kMenuCID, NS_MENU_CID); - -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); - -nsresult nsMenuBar::QueryInterface(REFNSIID aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - *aInstancePtr = NULL; - - if (aIID.Equals(NS_GET_IID(nsIMenuBar))) { - *aInstancePtr = (void*) ((nsIMenuBar*) this); - NS_ADDREF_THIS(); - return NS_OK; - } - - if (aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*) ((nsISupports*)(nsIMenuBar*) this); - NS_ADDREF_THIS(); - return NS_OK; - } - - if (aIID.Equals(NS_GET_IID(nsIMenuListener))) { - *aInstancePtr = (void*) ((nsIMenuListener*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return NS_NOINTERFACE; -} - -NS_IMPL_ADDREF(nsMenuBar) -NS_IMPL_RELEASE(nsMenuBar) - -//------------------------------------------------------------------------- -// -// nsMenuBar constructor -// -//------------------------------------------------------------------------- -nsMenuBar::nsMenuBar() : nsIMenuBar(), nsIMenuListener() -{ - NS_INIT_REFCNT(); - mNumMenus = 0; - mMenuBar = nsnull; - mParent = nsnull; - mIsMenuBarAdded = PR_FALSE; - mWebShell = nsnull; - mDOMNode = nsnull; -} - -//------------------------------------------------------------------------- -// -// nsMenuBar destructor -// -//------------------------------------------------------------------------- -nsMenuBar::~nsMenuBar() -{ - NS_IF_RELEASE(mParent); -} - -//------------------------------------------------------------------------- -// -// Create the proper widget -// -//------------------------------------------------------------------------- -NS_METHOD nsMenuBar::Create(nsIWidget *aParent) -{ - SetParent(aParent); - Widget parentWidget = (Widget)mParent->GetNativeData(NS_NATIVE_WIDGET); - Widget mainWindow = XtParent(parentWidget); - mMenuBar = XmCreateMenuBar(mainWindow, "menubar", nsnull, 0); - XtManageChild(mMenuBar); - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuBar::GetParent(nsIWidget *&aParent) -{ - aParent = mParent; - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuBar::SetParent(nsIWidget *aParent) -{ - NS_IF_RELEASE(mParent); - mParent = aParent; - NS_IF_ADDREF(mParent); - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuBar::AddMenu(nsIMenu * aMenu) -{ - // XXX add to internal data structure - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuBar::GetMenuCount(PRUint32 &aCount) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuBar::GetMenuAt(const PRUint32 aCount, nsIMenu *& aMenu) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuBar::InsertMenuAt(const PRUint32 aCount, nsIMenu *& aMenu) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuBar::RemoveMenu(const PRUint32 aCount) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuBar::RemoveAll() -{ - for (int i = mMenusVoidArray.Count(); i > 0; i--) { - if(nsnull != mMenusVoidArray[i-1]) { - nsIMenu * menu = nsnull; - ((nsISupports*)mMenusVoidArray[i-1])->QueryInterface(NS_GET_IID(nsIMenu), (void**)&menu); - if(menu) { - //XXX:implement something here. - NS_RELEASE(menu); - - //XXX:g_print("menu release \n"); - int num =((nsISupports*)mMenusVoidArray[i-1])->Release(); - while(num) { - //XXX:g_print("menu release again!\n"); - num = ((nsISupports*)mMenusVoidArray[i-1])->Release(); - } - } - } - } - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuBar::GetNativeData(void *& aData) -{ - aData = (void *)mMenuBar; - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuBar::SetNativeData(void * aData) -{ - // Temporary hack for MacOS. Will go away when nsMenuBar handles it's own - // construction - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuBar::Paint() -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// nsMenuListener interface -// -//------------------------------------------------------------------------- -nsEventStatus nsMenuBar::MenuItemSelected(const nsMenuEvent & aMenuEvent) -{ - return nsEventStatus_eIgnore; -} - -nsEventStatus nsMenuBar::MenuSelected(const nsMenuEvent & aMenuEvent) -{ - return nsEventStatus_eIgnore; -} - -nsEventStatus nsMenuBar::MenuDeselected(const nsMenuEvent & aMenuEvent) -{ - return nsEventStatus_eIgnore; -} - -nsEventStatus nsMenuBar::MenuConstruct( - const nsMenuEvent& aMenuEvent, - nsIWidget * aParentWindow, - void * menubarNode, - void * aWebShell) -{ - mWebShell = (nsIWebShell*) aWebShell; - mDOMNode = (nsIDOMNode*)menubarNode; - - nsIMenuBar * pnsMenuBar = nsnull; - nsresult rv = nsComponentManager::CreateInstance(kMenuBarCID, - nsnull, - NS_GET_IID(nsIMenuBar), - (void**)&pnsMenuBar); - if (NS_OK == rv) { - if (nsnull != pnsMenuBar) { - pnsMenuBar->Create(aParentWindow); - - // set pnsMenuBar as a nsMenuListener on aParentWindow - nsCOMPtr menuListener; - pnsMenuBar->QueryInterface(NS_GET_IID(nsIMenuListener), getter_AddRefs(menuListener)); - aParentWindow->AddMenuListener(menuListener); - - nsCOMPtr menuNode; - ((nsIDOMNode*)menubarNode)->GetFirstChild(getter_AddRefs(menuNode)); - while (menuNode) { - nsCOMPtr menuElement(do_QueryInterface(menuNode)); - if (menuElement) { - nsString menuNodeType; - nsString menuName; - menuElement->GetNodeName(menuNodeType); - if (menuNodeType.Equals("menu")) { - menuElement->GetAttribute(nsAutoString("label"), menuName); - // Don't create the menu yet, just add in the top level names - - // Create nsMenu - nsIMenu * pnsMenu = nsnull; - rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, NS_GET_IID(nsIMenu), (void**)&pnsMenu); - if (NS_OK == rv) { - // Call Create - nsISupports * supports = nsnull; - pnsMenuBar->QueryInterface(kISupportsIID, (void**) &supports); - pnsMenu->Create(supports, menuName); - NS_RELEASE(supports); - - pnsMenu->SetLabel(menuName); - pnsMenu->SetDOMNode(menuNode); - pnsMenu->SetDOMElement(menuElement); - pnsMenu->SetWebShell(mWebShell); - - // Make nsMenu a child of nsMenuBar - // nsMenuBar takes ownership of the nsMenu - pnsMenuBar->AddMenu(pnsMenu); - - // Release the menu now that the menubar owns it - NS_RELEASE(pnsMenu); - } - } - - } - nsCOMPtr oldmenuNode(menuNode); - oldmenuNode->GetNextSibling(getter_AddRefs(menuNode)); - } // end while (nsnull != menuNode) - - // Give the aParentWindow this nsMenuBar to hold onto. - // The parent window should take ownership at this point - aParentWindow->SetMenuBar(pnsMenuBar); - - // HACK: force a paint for now - pnsMenuBar->Paint(); - - NS_RELEASE(pnsMenuBar); - } // end if ( nsnull != pnsMenuBar ) - } - - return nsEventStatus_eIgnore; -} - -nsEventStatus nsMenuBar::MenuDestruct(const nsMenuEvent & aMenuEvent) -{ - return nsEventStatus_eIgnore; -} diff --git a/widget/src/motif/nsMenuBar.h b/widget/src/motif/nsMenuBar.h deleted file mode 100644 index 2e406f993d0a..000000000000 --- a/widget/src/motif/nsMenuBar.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsMenuBar_h__ -#define nsMenuBar_h__ - -#include "Xm/Xm.h" -#include "nsXtManageWidget.h" - -#include "nsIMenuBar.h" -#include "nsIMenuListener.h" -#include "nsVoidArray.h" - -class nsIDOMNode; -class nsIWebShell; -class nsIWidget; - -/** - * Native Motif MenuBar wrapper - */ - -class nsMenuBar : public nsIMenuBar, public nsIMenuListener -{ - -public: - nsMenuBar(); - virtual ~nsMenuBar(); - - // nsIMenuListener interface - nsEventStatus MenuItemSelected(const nsMenuEvent & aMenuEvent); - nsEventStatus MenuSelected(const nsMenuEvent & aMenuEvent); - nsEventStatus MenuDeselected(const nsMenuEvent & aMenuEvent); - nsEventStatus MenuConstruct( - const nsMenuEvent& aMenuEvent, - nsIWidget * aParentWindow, - void * menubarNode, - void * aWebShell); - nsEventStatus MenuDestruct(const nsMenuEvent & aMenuEvent); - - NS_DECL_ISUPPORTS - - NS_IMETHOD Create(nsIWidget * aParent); - - // nsIMenuBar Methods - NS_IMETHOD GetParent(nsIWidget *&aParent); - NS_IMETHOD SetParent(nsIWidget * aParent); - NS_IMETHOD AddMenu(nsIMenu * aMenu); - NS_IMETHOD GetMenuCount(PRUint32 &aCount); - NS_IMETHOD GetMenuAt(const PRUint32 aCount, nsIMenu *& aMenu); - NS_IMETHOD InsertMenuAt(const PRUint32 aCount, nsIMenu *& aMenu); - NS_IMETHOD RemoveMenu(const PRUint32 aCount); - NS_IMETHOD RemoveAll(); - NS_IMETHOD GetNativeData(void*& aData); - NS_IMETHOD Paint(); - NS_IMETHOD SetNativeData(void* aData); -protected: - Widget mMenuBar; - nsIWidget * mParent; - PRBool mIsMenuBarAdded; - - nsIWebShell * mWebShell; - nsIDOMNode * mDOMNode; - - nsVoidArray mMenusVoidArray; - PRUint32 mNumMenus; -}; - -#endif // nsMenuBar_h__ diff --git a/widget/src/motif/nsMenuItem.cpp b/widget/src/motif/nsMenuItem.cpp deleted file mode 100644 index d97c20bb76fe..000000000000 --- a/widget/src/motif/nsMenuItem.cpp +++ /dev/null @@ -1,408 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include - -#include "nsMenuItem.h" -#include "nsIMenu.h" -#include "nsIMenuBar.h" -#include "nsIWidget.h" - -#include "nsXtEventHandler.h" - -#include "nsIPopUpMenu.h" - -#include "nsCOMPtr.h" -#include "nsReadableUtils.h" -#include "nsIContent.h" -#include "nsIContentViewer.h" -#include "nsIDOMElement.h" -#include "nsIDocumentViewer.h" -#include "nsIPresContext.h" -#include "nsIWebShell.h" -#include "nsICharsetConverterManager.h" -#include "nsIPlatformCharset.h" -#include "nsIServiceManager.h" - -#include "nsStringUtil.h" - -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); - -nsresult nsMenuItem::QueryInterface(REFNSIID aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - *aInstancePtr = NULL; - - if (aIID.Equals(NS_GET_IID(nsIMenuItem))) { - *aInstancePtr = (void*)(nsIMenuItem*)this; - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*)(nsISupports*)(nsIMenuItem*)this; - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(NS_GET_IID(nsIMenuListener))) { - *aInstancePtr = (void*)(nsIMenuListener*)this; - NS_ADDREF_THIS(); - return NS_OK; - } - return NS_NOINTERFACE; -} - -NS_IMPL_ADDREF(nsMenuItem) -NS_IMPL_RELEASE(nsMenuItem) - - -//------------------------------------------------------------------------- -// -// nsMenuItem constructor -// -//------------------------------------------------------------------------- -nsMenuItem::nsMenuItem() : nsIMenuItem() -{ - NS_INIT_REFCNT(); - mMenuItem = nsnull; - mMenuParent = nsnull; - mPopUpParent = nsnull; - mTarget = nsnull; - mXULCommandListener = nsnull; - mIsSeparator = PR_FALSE; - mWebShell = nsnull; - mDOMElement = nsnull; - mIsSubMenu = PR_FALSE; -} - -//------------------------------------------------------------------------- -// -// nsMenuItem destructor -// -//------------------------------------------------------------------------- -nsMenuItem::~nsMenuItem() -{ - NS_IF_RELEASE(mMenuParent); - NS_IF_RELEASE(mPopUpParent); - NS_IF_RELEASE(mTarget); -} - -//------------------------------------------------------------------------- -Widget nsMenuItem::GetNativeParent() -{ - void * voidData; - if (nsnull != mMenuParent) { - mMenuParent->GetNativeData(&voidData); - } else if (nsnull != mPopUpParent) { - mPopUpParent->GetNativeData(voidData); - } else { - return NULL; - } - return (Widget)voidData; -} - - -//------------------------------------------------------------------------- -nsIWidget * nsMenuItem::GetMenuBarParent(nsISupports * aParent) -{ - nsIWidget * widget = nsnull; // MenuBar's Parent - nsIMenu * menu = nsnull; - nsIMenuBar * menuBar = nsnull; - nsIPopUpMenu * popup = nsnull; - nsISupports * parent = aParent; - - // Bump the ref count on the parent, since it gets released unconditionally.. - NS_ADDREF(parent); - while (1) { - if (NS_OK == parent->QueryInterface(NS_GET_IID(nsIMenu),(void**)&menu)) { - NS_RELEASE(parent); - if (NS_OK != menu->GetParent(parent)) { - NS_RELEASE(menu); - return nsnull; - } - NS_RELEASE(menu); - - } else if (NS_OK == parent->QueryInterface(NS_GET_IID(nsIPopUpMenu),(void**)&popup)) { - if (NS_OK != popup->GetParent(widget)) { - widget = nsnull; - } - NS_RELEASE(parent); - NS_RELEASE(popup); - return widget; - - } else if (NS_OK == parent->QueryInterface(NS_GET_IID(nsIMenuBar),(void**)&menuBar)) { - if (NS_OK != menuBar->GetParent(widget)) { - widget = nsnull; - } - NS_RELEASE(parent); - NS_RELEASE(menuBar); - return widget; - } else { - NS_RELEASE(parent); - return nsnull; - } - } - return nsnull; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuItem::GetLabel(nsString &aText) -{ - aText = mLabel; - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuItem::SetLabel(nsString &aText) -{ - mLabel = aText; - return NS_OK; -} - -NS_METHOD nsMenuItem::SetShortcutChar(const nsString &aText) -{ - return NS_OK; -} - -NS_METHOD nsMenuItem::GetShortcutChar(nsString &aText) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuItem::GetCommand(PRUint32 & aCommand) -{ - aCommand = mCommand; - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuItem::GetTarget(nsIWidget *& aTarget) -{ - aTarget = mTarget; - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuItem::GetNativeData(void *& aData) -{ -// aData = (void *)mMenu; - return NS_OK; -} - -//------------------------------------------------------------------------- -// nsIMenuListener interface -//------------------------------------------------------------------------- -nsEventStatus nsMenuItem::MenuItemSelected(const nsMenuEvent & aMenuEvent) -{ - if(!mIsSeparator) { - DoCommand(); - } - return nsEventStatus_eIgnore; -} - -nsEventStatus nsMenuItem::MenuSelected(const nsMenuEvent & aMenuEvent) -{ - printf("nsMenuItem::MenuSelected called\n"); - if(mXULCommandListener) - return mXULCommandListener->MenuSelected(aMenuEvent); - - return nsEventStatus_eIgnore; -} - -nsEventStatus nsMenuItem::MenuDeselected(const nsMenuEvent & aMenuEvent) -{ - printf("nsMenuItem::MenuDeselected called\n"); - return nsEventStatus_eIgnore; -} - -nsEventStatus nsMenuItem::MenuConstruct(const nsMenuEvent &aMenuEvent, - nsIWidget *aParentWindow, - void *menuNode, - void *aWebShell) -{ - printf("nsMenuItem::MenuConstruct called\n"); - return nsEventStatus_eIgnore; -} - -nsEventStatus nsMenuItem::MenuDestruct(const nsMenuEvent & aMenuEvent) -{ - printf("nsMenuItem::MenuDestruct called\n"); - return nsEventStatus_eIgnore; -} - -//---------------------------------------------------- -NS_METHOD nsMenuItem::Create(nsISupports *aParent, - const nsString &aLabel, - PRBool aIsSeparator) -{ - printf("nsMenuItem::Create called\n"); - if (nsnull == aParent) { - return NS_ERROR_FAILURE; - } - - if(aParent) { - nsIMenu * menu; - aParent->QueryInterface(NS_GET_IID(nsIMenu), (void**) &menu); - mMenuParent = menu; - NS_RELEASE(menu); - } - - nsIWidget * widget = nsnull; // MenuBar's Parent - nsISupports * sups; - if (NS_OK == aParent->QueryInterface(kISupportsIID,(void**)&sups)) { - widget = GetMenuBarParent(sups); - // GetMenuBarParent will call release for us - // NS_RELEASE(sups); - mTarget = widget; - } - - mIsSeparator = aIsSeparator; - mLabel = aLabel; - - // create the native menu item - - if(mIsSeparator) { - mMenuItem = nsnull; - } else { - char * nameStr = ToNewCString(mLabel); - Widget parentMenuHandle = GetNativeParent(); - mMenuItem = XtVaCreateManagedWidget(nameStr, xmCascadeButtonGadgetClass, - parentMenuHandle, - NULL); - XtAddCallback(mMenuItem, XmNactivateCallback, nsXtWidget_Menu_Callback, - (nsIMenuItem *)this); - delete[] nameStr; - } - return NS_OK; -} - -NS_METHOD nsMenuItem::SetEnabled(PRBool aIsEnabled) -{ - //XXX:Implement this. - return nsEventStatus_eIgnore; -} - -NS_METHOD nsMenuItem::GetEnabled(PRBool *aIsEnabled) -{ - //XXX:Implement this. - return nsEventStatus_eIgnore; -} - -NS_METHOD nsMenuItem::SetChecked(PRBool aIsEnabled) -{ - return NS_OK; -} - -NS_METHOD nsMenuItem::GetChecked(PRBool *aIsEnabled) -{ - return NS_OK; -} - -NS_METHOD nsMenuItem::AddMenuListener(nsIMenuListener * aMenuListener) -{ - NS_IF_RELEASE(mXULCommandListener); - NS_IF_ADDREF(aMenuListener); - mXULCommandListener = aMenuListener; - return NS_OK; -} - -NS_METHOD nsMenuItem::RemoveMenuListener(nsIMenuListener * aMenuListener) -{ - return NS_OK; -} - -NS_METHOD nsMenuItem::IsSeparator(PRBool & aIsSep) -{ - aIsSep = mIsSeparator; - return NS_OK; -} - -NS_METHOD nsMenuItem::SetCommand(const nsString &aStrCmd) -{ - return nsEventStatus_eIgnore; -} - -NS_METHOD nsMenuItem::DoCommand() -{ - //XXX:Implement this. - return nsEventStatus_eIgnore; -} - -NS_METHOD nsMenuItem::SetDOMNode(nsIDOMNode * aDOMNode) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuItem::GetDOMNode(nsIDOMNode ** aDOMNode) -{ - return NS_OK; -} - - -NS_METHOD nsMenuItem::SetDOMElement(nsIDOMElement * aDOMElement) -{ - mDOMElement = aDOMElement; - return NS_OK; -} - -NS_METHOD nsMenuItem::GetDOMElement(nsIDOMElement ** aDOMElement) -{ - return NS_OK; -} - -NS_METHOD nsMenuItem::SetWebShell(nsIWebShell * aWebShell) -{ - mWebShell = aWebShell; - return NS_OK; -} - -NS_METHOD nsMenuItem::SetModifiers(PRUint8 aModifiers) -{ - mModifiers = aModifiers; - return NS_OK; -} - -NS_METHOD nsMenuItem::GetModifiers(PRUint8 * aModifiers) -{ - *aModifiers = mModifiers; - return NS_OK; -} diff --git a/widget/src/motif/nsMenuItem.h b/widget/src/motif/nsMenuItem.h deleted file mode 100644 index bd794a390dae..000000000000 --- a/widget/src/motif/nsMenuItem.h +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsMenuItem_h__ -#define nsMenuItem_h__ - -#include "Xm/Xm.h" - -#include "nsIMenuItem.h" -#include "nsString.h" -#include "nsIMenuListener.h" - -class nsIDOMElement; -class nsIMenu; -class nsIPopUpMenu; -class nsIWebShell; -class nsIWidget; - -/** - * Native Motif MenuItem wrapper - */ - -class nsMenuItem : public nsIMenuItem, public nsIMenuListener -{ - -public: - nsMenuItem(); - virtual ~nsMenuItem(); - - // nsISupports - NS_DECL_ISUPPORTS - - // nsIMenuItem Methods - NS_IMETHOD Create(nsISupports * aParent, - const nsString & aLabel, - PRBool isSeparator); - NS_IMETHOD GetLabel(nsString &aText); - NS_IMETHOD SetLabel(nsString &aText); - NS_IMETHOD SetEnabled(PRBool aIsEnabled); - NS_IMETHOD GetEnabled(PRBool *aIsEnabled); - NS_IMETHOD SetChecked(PRBool aIsEnabled); - NS_IMETHOD GetChecked(PRBool *aIsEnabled); - NS_IMETHOD GetCommand(PRUint32 & aCommand); - NS_IMETHOD GetTarget(nsIWidget *& aTarget); - NS_IMETHOD GetNativeData(void*& aData); - NS_IMETHOD AddMenuListener(nsIMenuListener * aMenuListener); - NS_IMETHOD RemoveMenuListener(nsIMenuListener * aMenuListener); - NS_IMETHOD IsSeparator(PRBool & aIsSep); - - NS_IMETHOD SetCommand(const nsString & aStrCmd); - NS_IMETHOD DoCommand(); - NS_IMETHOD SetDOMNode(nsIDOMNode * aDOMNode); - NS_IMETHOD GetDOMNode(nsIDOMNode ** aDOMNode); - NS_IMETHOD SetDOMElement(nsIDOMElement * aDOMElement); - NS_IMETHOD GetDOMElement(nsIDOMElement ** aDOMElement); - NS_IMETHOD SetWebShell(nsIWebShell * aWebShell); - - NS_IMETHOD SetShortcutChar(const nsString &aText); - NS_IMETHOD GetShortcutChar(nsString &aText); - NS_IMETHOD SetModifiers(PRUint8 aModifiers); - NS_IMETHOD GetModifiers(PRUint8 * aModifiers); - - // nsIMenuListener interface - nsEventStatus MenuItemSelected(const nsMenuEvent & aMenuEvent); - nsEventStatus MenuSelected(const nsMenuEvent & aMenuEvent); - nsEventStatus MenuDeselected(const nsMenuEvent & aMenuEvent); - nsEventStatus MenuConstruct(const nsMenuEvent & aMenuEvent, - nsIWidget * aParentWindow, - void * menubarNode, - void * aWebShell); - nsEventStatus MenuDestruct(const nsMenuEvent & aMenuEvent); - -protected: - nsIWidget *GetMenuBarParent(nsISupports * aParentSupports); - Widget GetNativeParent(); - - nsIMenuListener *mXULCommandListener; - nsString mLabel; - nsString mKeyEquivalent; - PRUint8 mModifiers; - PRUint32 mCommand; - nsIMenu *mMenuParent; - nsIPopUpMenu *mPopUpParent; - nsIWidget *mTarget; - - Widget mMenuItem; // native cascade widget - PRBool mIsSeparator; - PRBool mIsSubMenu; - - nsIWebShell * mWebShell; - nsIDOMElement * mDOMElement; -}; - -#endif // nsMenuItem_h__ diff --git a/widget/src/motif/nsPopUpMenu.cpp b/widget/src/motif/nsPopUpMenu.cpp deleted file mode 100644 index b0925f81beac..000000000000 --- a/widget/src/motif/nsPopUpMenu.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#include "nsPopUpMenu.h" -#include "nsIPopUpMenu.h" -#include "nsIMenu.h" -#include "nsIWidget.h" - -#include "nsString.h" -#include "nsStringUtil.h" - -#include -#include - -NS_IMPL_ISUPPORTS1(nsPopUpMenu, nsIPopUpMenu) - -//------------------------------------------------------------------------- -// -// nsPopUpMenu constructor -// -//------------------------------------------------------------------------- -nsPopUpMenu::nsPopUpMenu() : nsIPopUpMenu() -{ - NS_INIT_REFCNT(); - mNumMenuItems = 0; - mParent = nsnull; - mMenu = nsnull; -} - -//------------------------------------------------------------------------- -// -// nsPopUpMenu destructor -// -//------------------------------------------------------------------------- -nsPopUpMenu::~nsPopUpMenu() -{ - NS_IF_RELEASE(mParent); -} - - - -//------------------------------------------------------------------------- -// -// Create the proper widget -// -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::Create(nsIWidget *aParent) -{ - - mParent = aParent; - NS_ADDREF(mParent); - - Widget parentWidget = (Widget) mParent->GetNativeData(NS_NATIVE_WINDOW); - mMenu = XmCreatePopupMenu(parentWidget, "_popup", NULL, 0); - return NS_OK; -} - - -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::AddItem(const nsString &aText) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::AddItem(nsIMenuItem * aMenuItem) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::AddMenu(nsIMenu * aMenu) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::AddSeparator() -{ - XtVaCreateManagedWidget("__sep", xmSeparatorGadgetClass, mMenu, NULL); - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::GetItemCount(PRUint32 &aCount) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::GetItemAt(const PRUint32 aCount, nsIMenuItem *& aMenuItem) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::InsertItemAt(const PRUint32 aCount, nsIMenuItem *& aMenuItem) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::InsertItemAt(const PRUint32 aCount, const nsString & aMenuItemName) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::InsertSeparator(const PRUint32 aCount) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::RemoveItem(const PRUint32 aCount) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::RemoveAll() -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::ShowMenu(PRInt32 aX, PRInt32 aY) -{ - - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::GetNativeData(void *& aData) -{ - aData = (void *)mMenu; - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsPopUpMenu::GetParent(nsIWidget *& aParent) -{ - aParent = mParent; - return NS_OK; -} - - diff --git a/widget/src/motif/nsPopUpMenu.h b/widget/src/motif/nsPopUpMenu.h deleted file mode 100644 index 595958a95c10..000000000000 --- a/widget/src/motif/nsPopUpMenu.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsPopUpMenu_h__ -#define nsPopUpMenu_h__ - -#include "Xm/Xm.h" -#include "nsXtManageWidget.h" - -#include "nsIPopUpMenu.h" - -class nsIWidget; - -/** - * Native Motif PopUp wrapper - */ - -class nsPopUpMenu : public nsIPopUpMenu -{ - -public: - nsPopUpMenu(); - virtual ~nsPopUpMenu(); - - NS_DECL_ISUPPORTS - - NS_IMETHOD Create(nsIWidget * aParent); - - // nsIPopUpMenu Methods - NS_IMETHOD AddItem(const nsString &aText); - NS_IMETHOD AddItem(nsIMenuItem * aMenuItem); - NS_IMETHOD AddMenu(nsIMenu * aMenu); - NS_IMETHOD AddSeparator(); - NS_IMETHOD GetItemCount(PRUint32 &aCount); - NS_IMETHOD GetItemAt(const PRUint32 aCount, nsIMenuItem *& aMenuItem); - NS_IMETHOD InsertItemAt(const PRUint32 aCount, nsIMenuItem *& aMenuItem); - NS_IMETHOD InsertItemAt(const PRUint32 aCount, const nsString & aMenuItemName); - NS_IMETHOD InsertSeparator(const PRUint32 aCount); - NS_IMETHOD RemoveItem(const PRUint32 aCount); - NS_IMETHOD RemoveAll(); - NS_IMETHOD ShowMenu(PRInt32 aX, PRInt32 aY); - NS_IMETHOD GetNativeData(void*& aData); - NS_IMETHOD GetParent(nsIWidget*& aParent); - -protected: - - PRUint32 mNumMenuItems; - nsIWidget * mParent; - Widget mMenu; -}; - -#endif // nsPopUpMenu_h__ - diff --git a/widget/src/motif/nsScrollbar.cpp b/widget/src/motif/nsScrollbar.cpp deleted file mode 100644 index 1eca8f1696a2..000000000000 --- a/widget/src/motif/nsScrollbar.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include - -#include "nsScrollbar.h" -#include "nsGUIEvent.h" - -#include "nsXtEventHandler.h" - -NS_IMPL_ADDREF(nsScrollbar) -NS_IMPL_RELEASE(nsScrollbar) - -//------------------------------------------------------------------------- -// -// nsScrollbar constructor -// -//------------------------------------------------------------------------- -nsScrollbar::nsScrollbar(PRBool aIsVertical) : nsWindow(), nsIScrollbar() -{ - NS_INIT_REFCNT(); - - strcpy(gInstanceClassName, "nsScrollbar"); - mOrientation = (aIsVertical) ? XmVERTICAL : XmHORIZONTAL; - mLineIncrement = 0; -} - -//------------------------------------------------------------------------- -// -// Create -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - Widget parentWidget = (Widget)aParent; - strcpy(gInstanceClassName, "nsScrollbar"); - - int procDir = mOrientation == XmVERTICAL? XmMAX_ON_BOTTOM:XmMAX_ON_RIGHT; - - mWidget = ::XtVaCreateManagedWidget("nsScrollbar", - xmScrollBarWidgetClass, - parentWidget, - XmNorientation, mOrientation, - XmNprocessingDirection, procDir, - XmNwidth, aRect.width, - XmNheight, aRect.height, - XmNrecomputeSize, False, - XmNhighlightOnEnter, False, - XmNminimum, 0, - XmNmaximum, 100, - XmNx, aRect.x, - XmNy, aRect.y, - nsnull); - - // save the event callback function - mEventCallback = aHandleEventFunction; - - //InitCallbacks(); - XtAddCallback(mWidget, - XmNdragCallback, - nsXtWidget_Scrollbar_Callback, - this); - - XtAddCallback(mWidget, - XmNdecrementCallback, - nsXtWidget_Scrollbar_Callback, - this); - - XtAddCallback(mWidget, - XmNincrementCallback, - nsXtWidget_Scrollbar_Callback, - this); - - XtAddCallback(mWidget, - XmNvalueChangedCallback, - nsXtWidget_Scrollbar_Callback, - this); - - return NS_OK; -} - - -NS_METHOD nsScrollbar::Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - Widget parentWidget; - - if (aParent) { - parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET); - } else { - parentWidget = (Widget) aAppShell->GetNativeData(NS_NATIVE_SHELL); - } - - Create((nsNativeWidget)parentWidget, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit, aInitData); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// nsScrollbar destructor -// -//------------------------------------------------------------------------- -nsScrollbar::~nsScrollbar() -{ -} - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsScrollbar::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr); - - static NS_DEFINE_IID(kInsScrollbarIID, NS_ISCROLLBAR_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kInsScrollbarIID)) { - *aInstancePtr = (void*) ((nsIScrollbar*)this); - AddRef(); - result = NS_OK; - } - - return result; -} - -//------------------------------------------------------------------------- -// -// Define the range settings -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange) -{ - int max = aEndRange; - XtVaGetValues(mWidget, XmNmaximum, &max, nsnull); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Return the range settings -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetMaxRange(PRUint32 & aMaxRange) -{ - int maxRange = 0; - XtVaGetValues(mWidget, XmNmaximum, &maxRange, nsnull); - aMaxRange = (PRUint32)maxRange; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the thumb position -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos) -{ - int pos = (int)aPos; - XtVaSetValues(mWidget, XmNvalue, pos, nsnull); - - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the current thumb position. -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetPosition(PRUint32 & aPos) -{ - int pagePos = 0; - XtVaGetValues(mWidget, XmNvalue, &pagePos, nsnull); - - aPos = (PRUint32)pagePos; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the thumb size -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize) -{ - if (aSize > 0) { - XtVaSetValues(mWidget, XmNpageIncrement, (int)aSize, nsnull); - XtVaSetValues(mWidget, XmNsliderSize, (int)aSize, nsnull); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the thumb size -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetThumbSize(PRUint32 & aThumbSize) -{ - int pageSize = 0; - XtVaGetValues(mWidget, XmNpageIncrement, &pageSize, nsnull); - - aThumbSize = (PRUint32)pageSize; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the line increment for this scrollbar -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aLineIncrement) -{ - if (aLineIncrement > 0) { - mLineIncrement = aLineIncrement; - XtVaSetValues(mWidget, XmNincrement, aLineIncrement, nsnull); - } - - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the line increment for this scrollbar -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::GetLineIncrement(PRUint32 & aLineInc) -{ - aLineInc = mLineIncrement; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set all scrolling parameters -// -//------------------------------------------------------------------------- -NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement) -{ - - int thumbSize = (((int)aThumbSize) > 0?aThumbSize:1); - int maxRange = (((int)aMaxRange) > 0?aMaxRange:10); - mLineIncrement = (((int)aLineIncrement) > 0?aLineIncrement:1); - - int maxPos = maxRange - thumbSize; - int pos = ((int)aPosition) > maxPos ? maxPos-1 : ((int)aPosition); - - XtVaSetValues(mWidget, - XmNincrement, mLineIncrement, - XmNminimum, 0, - XmNmaximum, maxRange, - XmNsliderSize, thumbSize, - XmNpageIncrement, thumbSize, - XmNvalue, pos, - nsnull); - - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// paint message. Don't send the paint out -// -//------------------------------------------------------------------------- -PRBool nsScrollbar::OnPaint(nsPaintEvent & aEvent) -{ - return PR_FALSE; -} - - -PRBool nsScrollbar::OnResize(nsSizeEvent &aEvent) -{ - return nsWindow::OnResize(aEvent); -} - -//------------------------------------------------------------------------- -int nsScrollbar::AdjustScrollBarPosition(int aPosition) -{ - int maxRange; - int sliderSize; - - XtVaGetValues(mWidget, XmNmaximum, &maxRange, - XmNsliderSize, &sliderSize, - nsnull); - int cap = maxRange - sliderSize; - return aPosition > cap ? cap : aPosition; -} - -//------------------------------------------------------------------------- -// -// Deal with scrollbar messages (actually implemented only in nsScrollbar) -// -//------------------------------------------------------------------------- -PRBool nsScrollbar::OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos) -{ - PRBool result = PR_TRUE; - int newPosition; - - switch (aEvent.message) { - - // scroll one line right or down - case NS_SCROLLBAR_LINE_NEXT: - { - XtVaGetValues(mWidget, XmNvalue, &newPosition, nsnull); - newPosition += mLineIncrement; - PRUint32 thumbSize; - PRUint32 maxRange; - GetThumbSize(thumbSize); - GetMaxRange(maxRange); - PRUint32 max = maxRange - thumbSize; - if (newPosition > (int)max) - newPosition = (int)max; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) { - aEvent.position = newPosition; - result = ConvertStatus((*mEventCallback)(&aEvent)); - newPosition = aEvent.position; - } - - XtVaSetValues(mWidget, XmNvalue, - AdjustScrollBarPosition(newPosition), nsnull); - break; - } - - - // scroll one line left or up - case NS_SCROLLBAR_LINE_PREV: - { - XtVaGetValues(mWidget, XmNvalue, &newPosition, nsnull); - - newPosition -= mLineIncrement; - if (newPosition < 0) - newPosition = 0; - - // if an event callback is registered, give it the chance - // to change the decrement - if (mEventCallback) { - aEvent.position = newPosition; - - result = ConvertStatus((*mEventCallback)(&aEvent)); - newPosition = aEvent.position; - } - - XtVaSetValues(mWidget, XmNvalue, newPosition, nsnull); - - break; - } - - // Scrolls one page right or down - case NS_SCROLLBAR_PAGE_NEXT: - { - XtVaGetValues(mWidget, XmNvalue, &newPosition, nsnull); - PRUint32 thumbSize; - GetThumbSize(thumbSize); - PRUint32 maxRange; - GetThumbSize(thumbSize); - GetMaxRange(maxRange); - PRUint32 max = maxRange - thumbSize; - if (newPosition > (int)max) - newPosition = (int)max; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) { - aEvent.position = newPosition; - result = ConvertStatus((*mEventCallback)(&aEvent)); - newPosition = aEvent.position; - } - XtVaSetValues(mWidget, XmNvalue, - AdjustScrollBarPosition(newPosition+10), nsnull); - break; - } - - // Scrolls one page left or up. - case NS_SCROLLBAR_PAGE_PREV: - { - XtVaGetValues(mWidget, XmNvalue, &newPosition, nsnull); - if (newPosition < 0) - newPosition = 0; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) { - aEvent.position = newPosition; - result = ConvertStatus((*mEventCallback)(&aEvent)); - newPosition = aEvent.position; - } - - XtVaSetValues(mWidget, XmNvalue, newPosition-10, nsnull); - break; - } - - - // Scrolls to the absolute position. The current position is specified by - // the cPos parameter. - case NS_SCROLLBAR_POS: - { - newPosition = cPos; - - // if an event callback is registered, give it the chance - // to change the increment - if (mEventCallback) { - aEvent.position = newPosition; - result = ConvertStatus((*mEventCallback)(&aEvent)); - newPosition = aEvent.position; - } - - XtVaSetValues(mWidget, XmNvalue, - AdjustScrollBarPosition(newPosition), nsnull); - - break; - } - } - return result; -} diff --git a/widget/src/motif/nsScrollbar.h b/widget/src/motif/nsScrollbar.h deleted file mode 100644 index 6fe8898b4889..000000000000 --- a/widget/src/motif/nsScrollbar.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsScrollbar_h__ -#define nsScrollbar_h__ - -#include "nsWindow.h" - -#include "nsIScrollbar.h" - -/** - * Native Motif scrollbar wrapper. - */ - -class nsScrollbar : public nsWindow, - public nsIScrollbar -{ - -public: - nsScrollbar(PRBool aIsVertical); - virtual ~nsScrollbar(); - - // nsISupports - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - - // nsIScrollBar implementation - NS_IMETHOD SetMaxRange(PRUint32 aEndRange); - NS_IMETHOD GetMaxRange(PRUint32& aMaxRange); - NS_IMETHOD SetPosition(PRUint32 aPos); - NS_IMETHOD GetPosition(PRUint32& aPos); - NS_IMETHOD SetThumbSize(PRUint32 aSize); - NS_IMETHOD GetThumbSize(PRUint32& aSize); - NS_IMETHOD SetLineIncrement(PRUint32 aSize); - NS_IMETHOD GetLineIncrement(PRUint32& aSize); - NS_IMETHOD SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, - PRUint32 aPosition, PRUint32 aLineIncrement); - - - NS_IMETHOD Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - - NS_IMETHOD Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - - - virtual PRBool OnPaint(nsPaintEvent & aEvent); - virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos); - virtual PRBool OnResize(nsSizeEvent &aEvent); - -private: - - PRUint32 mLineIncrement; - int mOrientation; - - int AdjustScrollBarPosition(int aPosition); - -}; - -#endif // nsScrollbar_h__ diff --git a/widget/src/motif/nsTextHelper.cpp b/widget/src/motif/nsTextHelper.cpp deleted file mode 100644 index a35e2d245f5c..000000000000 --- a/widget/src/motif/nsTextHelper.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsTextHelper.h" -#include "nsTextWidget.h" -#include "nsToolkit.h" -#include "nsColor.h" -#include "nsGUIEvent.h" -#include "nsString.h" -#include "nsStringUtil.h" - -#include - -#define DBG 0 - -//------------------------------------------------------------------------- -// -// nsTextHelper constructor -// -//------------------------------------------------------------------------- - -nsTextHelper::nsTextHelper() : nsWindow(), nsITextWidget() -{ - mIsReadOnly = PR_FALSE; - mIsPassword = PR_FALSE; -} - -//------------------------------------------------------------------------- -// -// nsTextHelper destructor -// -//------------------------------------------------------------------------- -nsTextHelper::~nsTextHelper() -{ -} - -//------------------------------------------------------------------------- -NS_METHOD nsTextHelper::SetMaxTextLength(PRUint32 aChars) -{ - XmTextSetMaxLength(mWidget, (int)aChars); - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsTextHelper::GetText(nsString& aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize) -{ - if (!mIsPassword) { - char * str = XmTextGetString(mWidget); - aTextBuffer.SetLength(0); - aTextBuffer.Append(str); - PRUint32 len = (PRUint32)strlen(str); - XtFree(str); - aActualSize = len; - } else { - PasswordData * data; - XtVaGetValues(mWidget, XmNuserData, &data, NULL); - aTextBuffer = data->mPassword; - aActualSize = aTextBuffer.Length(); - } - return(NS_OK); -} - -//------------------------------------------------------------------------- -NS_METHOD nsTextHelper::SetText(const nsString& aText, PRUint32& aActualSize) -{ - if (!mIsPassword) { - NS_ALLOC_STR_BUF(buf, aText, 512); - XmTextSetString(mWidget, buf); - NS_FREE_STR_BUF(buf); - } else { - PasswordData * data; - XtVaGetValues(mWidget, XmNuserData, &data, NULL); - data->mPassword = aText; - data->mIgnore = True; - char * buf = new char[aText.Length()+1]; - memset(buf, '*', aText.Length()); - buf[aText.Length()] = 0; - XmTextSetString(mWidget, buf); - data->mIgnore = False; - } - aActualSize = aText.Length(); - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsTextHelper::InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize) -{ - - if (!mIsPassword) { - NS_ALLOC_STR_BUF(buf, aText, 512); - XmTextInsert(mWidget, aStartPos, buf); - NS_FREE_STR_BUF(buf); - } else { - PasswordData * data; - XtVaGetValues(mWidget, XmNuserData, &data, NULL); - data->mIgnore = True; - nsString newText(aText); - data->mPassword.Insert(newText, aStartPos, aText.Length()); - char * buf = new char[data->mPassword.Length()+1]; - memset(buf, '*', data->mPassword.Length()); - buf[data->mPassword.Length()] = 0; - XmTextInsert(mWidget, aStartPos, buf); - data->mIgnore = False; - } - aActualSize = aText.Length(); - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsTextHelper::RemoveText() -{ - char blank[2]; - blank[0] = 0; - - XmTextSetString(mWidget, blank); - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsTextHelper::SetPassword(PRBool aIsPassword) -{ - mIsPassword = aIsPassword; - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsTextHelper::SetReadOnly(PRBool aReadOnlyFlag, PRBool& aOldReadOnlyFlag) -{ - NS_ASSERTION(nsnull != mWidget, - "SetReadOnly - Widget is NULL, Create may not have been called!"); - aOldReadOnlyFlag = mIsReadOnly; - mIsReadOnly = aReadOnlyFlag; - XmTextSetEditable(mWidget, aReadOnlyFlag?False:True); - return NS_OK; -} - - -//------------------------------------------------------------------------- -NS_METHOD nsTextHelper::SelectAll() -{ - nsString text; - PRUint32 actualSize = 0; - PRUint32 numChars = GetText(text, 0, actualSize); - SetSelection(0, numChars); - return NS_OK; -} - - -//------------------------------------------------------------------------- -NS_METHOD nsTextHelper::SetSelection(PRUint32 aStartSel, PRUint32 aEndSel) -{ - XmTextPosition left = (XmTextPosition)aStartSel; - XmTextPosition right = (XmTextPosition)aEndSel; - - XmTextSetSelection(mWidget, left, right, 0); - return NS_OK; -} - - -//------------------------------------------------------------------------- -NS_METHOD nsTextHelper::GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel) -{ - XmTextPosition left; - XmTextPosition right; - - if (XmTextGetSelectionPosition(mWidget, &left, &right)) { - *aStartSel = (PRUint32)left; - *aEndSel = (PRUint32)right; - } else { - printf("nsTextHelper::GetSelection Error getting positions\n"); - return NS_ERROR_FAILURE; - } - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsTextHelper::SetCaretPosition(PRUint32 aPosition) -{ - XmTextSetInsertionPosition(mWidget, (XmTextPosition)aPosition); - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsTextHelper::GetCaretPosition(PRUint32& aPosition) -{ - aPosition = (PRUint32)XmTextGetInsertionPosition(mWidget); - return NS_OK; -} - - - - diff --git a/widget/src/motif/nsTextHelper.h b/widget/src/motif/nsTextHelper.h deleted file mode 100644 index 1c61cf459231..000000000000 --- a/widget/src/motif/nsTextHelper.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef nsTextHelper_h__ -#define nsTextHelper_h__ - -#include "nsITextWidget.h" -#include "nsWindow.h" -#include - -/** - * Base class for nsTextAreaWidget (obsolete) and nsTextWidget - */ - -class nsTextHelper : public nsWindow, - public nsITextWidget -{ - -public: - nsTextHelper(); - virtual ~nsTextHelper(); - NS_IMETHOD SelectAll(); - NS_IMETHOD SetMaxTextLength(PRUint32 aChars); - NS_IMETHOD GetText(nsString& aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize); - NS_IMETHOD SetText(const nsString &aText, PRUint32& aActualSize); - NS_IMETHOD InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize); - NS_IMETHOD RemoveText(); - NS_IMETHOD SetPassword(PRBool aIsPassword); - NS_IMETHOD SetReadOnly(PRBool aNewReadOnlyFlag, PRBool& aOldReadOnlyFlag); - NS_IMETHOD SetSelection(PRUint32 aStartSel, PRUint32 aEndSel); - NS_IMETHOD GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel); - NS_IMETHOD SetCaretPosition(PRUint32 aPosition); - NS_IMETHOD GetCaretPosition(PRUint32& aPosition); - -protected: - PRBool mIsPassword; - PRBool mIsReadOnly; - -}; - -#endif // nsTextHelper_h__ diff --git a/widget/src/motif/nsTextWidget.cpp b/widget/src/motif/nsTextWidget.cpp deleted file mode 100644 index 532e729ff7fd..000000000000 --- a/widget/src/motif/nsTextWidget.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include - -#include "nsTextWidget.h" -#include "nsToolkit.h" -#include "nsColor.h" -#include "nsGUIEvent.h" -#include "xlibrgb.h" -#include "nsString.h" -#include "nsXtEventHandler.h" - -#define DBG 0 - -extern int mIsPasswordCallBacksInstalled; - -NS_IMPL_ADDREF(nsTextWidget) -NS_IMPL_RELEASE(nsTextWidget) - -//------------------------------------------------------------------------- -// -// nsTextWidget constructor -// -//------------------------------------------------------------------------- -nsTextWidget::nsTextWidget() : nsTextHelper(), - mIsPasswordCallBacksInstalled(PR_FALSE), - mMakeReadOnly(PR_FALSE), - mMakePassword(PR_FALSE) -{ - mBackground = NS_RGB(127, 127, 127); - mForeground = NS_RGB(255, 255, 255); - mBackgroundPixel = xlib_rgb_xpixel_from_rgb(mBackground); - mForegroundPixel = xlib_rgb_xpixel_from_rgb(mForeground); -} - -//------------------------------------------------------------------------- -// -// nsTextWidget destructor -// -//------------------------------------------------------------------------- -nsTextWidget::~nsTextWidget() -{ -} - -//------------------------------------------------------------------------- -NS_METHOD nsTextWidget::Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - printf("nsTextWidget::Create called\n"); - aParent->AddChild(this); - Widget parentWidget = nsnull; - - if (DBG) fprintf(stderr, "aParent 0x%x\n", (unsigned int)aParent); - - if (aParent) { - parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET); - } else { - parentWidget = (Widget) aAppShell->GetNativeData(NS_NATIVE_SHELL); - } - - InitToolkit(aToolkit, aParent); - InitDeviceContext(aContext, parentWidget); - - mWidget = ::XtVaCreateManagedWidget("nsTextWidget", - xmTextWidgetClass, - parentWidget, - XmNwidth, aRect.width, - XmNheight, aRect.height, - XmNrecomputeSize, False, - XmNbackground, mBackgroundPixel, - XmNforeground, mForegroundPixel, - XmNhighlightOnEnter, False, - XmNeditable, mMakeReadOnly?False:True, - XmNx, aRect.x, - XmNy, aRect.y, - nsnull); - - // save the event callback function - mEventCallback = aHandleEventFunction; - - InitCallbacks("nsTextWidget"); - - XtAddCallback(mWidget, - XmNfocusCallback, - nsXtWidget_Focus_Callback, - this); - - XtAddCallback(mWidget, - XmNlosingFocusCallback, - nsXtWidget_Focus_Callback, - this); - - if (mMakeReadOnly) { - PRBool oldReadOnly; - SetReadOnly(PR_TRUE, oldReadOnly); - } - if (mMakePassword) { - SetPassword(PR_TRUE); - PasswordData * data = new PasswordData(); - if (data) { - data->mPassword = ""; - } - else return NS_ERROR_OUT_OF_MEMORY; - XtVaSetValues(mWidget, XmNuserData, data, NULL); - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsTextWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr); - - static NS_DEFINE_IID(kInsTextWidgetIID, NS_ITEXTWIDGET_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kInsTextWidgetIID)) { - *aInstancePtr = (void*) ((nsITextWidget*)this); - AddRef(); - result = NS_OK; - } - - return result; -} - -//-------------------------------------------------------------- -NS_METHOD nsTextWidget::SetPassword(PRBool aIsPassword) -{ - if (mWidget == nsnull && aIsPassword) { - mMakePassword = PR_TRUE; - return NS_OK; - } - - if (aIsPassword) { - if (!mIsPasswordCallBacksInstalled) { - XtAddCallback(mWidget, XmNmodifyVerifyCallback, nsXtWidget_Text_Callback, NULL); - XtAddCallback(mWidget, XmNactivateCallback, nsXtWidget_Text_Callback, NULL); - mIsPasswordCallBacksInstalled = PR_TRUE; - } - } else { - if (mIsPasswordCallBacksInstalled) { - XtRemoveCallback(mWidget, XmNmodifyVerifyCallback, nsXtWidget_Text_Callback, NULL); - XtRemoveCallback(mWidget, XmNactivateCallback, nsXtWidget_Text_Callback, NULL); - mIsPasswordCallBacksInstalled = PR_FALSE; - } - } - nsTextHelper::SetPassword(aIsPassword); - return NS_OK; -} diff --git a/widget/src/motif/nsTextWidget.h b/widget/src/motif/nsTextWidget.h deleted file mode 100644 index 2ccc6ddadedb..000000000000 --- a/widget/src/motif/nsTextWidget.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsTextWidget_h__ -#define nsTextWidget_h__ - -#include "nsWindow.h" -#include "nsTextHelper.h" - -#include "nsITextWidget.h" - -typedef struct _PasswordData { - nsString mPassword; - Boolean mIgnore; -} PasswordData; - -/** - * Native Motif single line edit control wrapper. - */ - -class nsTextWidget : public nsTextHelper -{ - -public: - nsTextWidget(); - virtual ~nsTextWidget(); - - // nsISupports. Forware to the nsObject base class - NS_DECL_ISUPPORTS - - - NS_IMETHOD Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - - NS_IMETHOD SetPassword(PRBool aIsPassword); - - virtual PRBool OnMove(PRInt32 aX, PRInt32 aY) { return PR_FALSE; } - virtual PRBool OnPaint(nsPaintEvent & aEvent) { return PR_FALSE; } - virtual PRBool OnResize(nsSizeEvent &aEvent) { return PR_FALSE; } - -protected: - PRBool mIsPasswordCallBacksInstalled; - -private: - PRBool mMakeReadOnly; - PRBool mMakePassword; - -}; - -#endif // nsTextWidget_h__ diff --git a/widget/src/motif/nsToolkit.cpp b/widget/src/motif/nsToolkit.cpp deleted file mode 100644 index c15ccadc5505..000000000000 --- a/widget/src/motif/nsToolkit.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsToolkit.h" -#include - -//------------------------------------------------------------------------- -// -// Error handler -// -//------------------------------------------------------------------------- -int nsToolkitErrorHandler (Display * mydisplay, XErrorEvent * myerr) -{ - char msg[80] ; - - XGetErrorText (mydisplay, myerr->error_code, msg, 80) ; - fprintf (stderr, "-------------------------------------\n"); - fprintf (stderr, "Error code %s\n", msg) ; - fprintf (stderr, "-------------------------------------\n"); - //exit() ; - return 0; -} - - -//------------------------------------------------------------------------- -// -// constructor -// -//------------------------------------------------------------------------- -nsToolkit::nsToolkit() -{ - NS_INIT_REFCNT(); - XSetErrorHandler(nsToolkitErrorHandler); -} - -//------------------------------------------------------------------------- -// -// destructor -// -//------------------------------------------------------------------------- -nsToolkit::~nsToolkit() -{ -} - - -//------------------------------------------------------------------------- -// -// nsISupports implementation macro -// -//------------------------------------------------------------------------- -NS_IMPL_ISUPPORTS1(nsToolkit, nsIToolkit) - - - -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- -NS_METHOD nsToolkit::Init(PRThread *aThread) -{ - return NS_OK; -} - -void nsToolkit::SetSharedGC(GC aGC) -{ - mSharedGC = aGC; -} - -GC nsToolkit::GetSharedGC() -{ - return (mSharedGC); -} diff --git a/widget/src/motif/nsToolkit.h b/widget/src/motif/nsToolkit.h deleted file mode 100644 index 33f4a2e42c1b..000000000000 --- a/widget/src/motif/nsToolkit.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef TOOLKIT_H -#define TOOLKIT_H - -#include "nsIToolkit.h" -#include - -/** - * Wrapper around the thread running the message pump. - * The toolkit abstraction is necessary because the message pump must - * execute within the same thread that created the widget under Win32. - */ - -class nsToolkit : public nsIToolkit -{ - -public: - nsToolkit(); - virtual ~nsToolkit(); - - NS_DECL_ISUPPORTS - NS_IMETHOD Init(PRThread *aThread); - -public: - NS_IMETHOD_(GC) GetSharedGC(); - NS_IMETHOD_(void) SetSharedGC(GC aGC); - -private: - GC mSharedGC; - -}; - -#endif // TOOLKIT_H diff --git a/widget/src/motif/nsWidgetFactory.cpp b/widget/src/motif/nsWidgetFactory.cpp deleted file mode 100644 index 5a98e39477fc..000000000000 --- a/widget/src/motif/nsWidgetFactory.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Dan Rosen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsIFactory.h" -#include "nsISupports.h" -#include "nsIButton.h" -#include "nsITextWidget.h" -#include "nsWidgetsCID.h" - -#include "nsToolkit.h" -#include "nsWindow.h" -#include "nsAppShell.h" -#include "nsButton.h" -#include "nsScrollbar.h" -#include "nsCheckButton.h" -#include "nsTextWidget.h" -#include "nsLookAndFeel.h" -#include "nsLabel.h" - -// Drag & Drop, Clipboard -// #include "nsClipboard.h" -#include "nsClipboardHelper.h" -#include "nsTransferable.h" -#include "nsHTMLFormatConverter.h" - -// #include "nsDragService.h" -// #include "nsDragSource.h" -// #include "nsDragTarget.h" -// #include "nsDraggedObject.h" - -#ifdef IBMBIDI -#include "nsBidiKeyboard.h" -#endif - -static NS_DEFINE_IID(kCWindow, NS_WINDOW_CID); -static NS_DEFINE_IID(kCChild, NS_CHILD_CID); -static NS_DEFINE_IID(kCButton, NS_BUTTON_CID); -static NS_DEFINE_IID(kCCheckButton, NS_CHECKBUTTON_CID); -static NS_DEFINE_IID(kCHorzScrollbar, NS_HORZSCROLLBAR_CID); -static NS_DEFINE_IID(kCVertScrollbar, NS_VERTSCROLLBAR_CID); -static NS_DEFINE_IID(kCTextField, NS_TEXTFIELD_CID); -static NS_DEFINE_IID(kCAppShell, NS_APPSHELL_CID); -static NS_DEFINE_IID(kCToolkit, NS_TOOLKIT_CID); -static NS_DEFINE_IID(kCLookAndFeel, NS_LOOKANDFEEL_CID); -static NS_DEFINE_IID(kCLabel, NS_LABEL_CID); - -// Drag & Drop, Clipboard -static NS_DEFINE_IID(kCClipboard, NS_CLIPBOARD_CID); -static NS_DEFINE_IID(kCClipboardHelper, NS_CLIPBOARDHELPER_CID); -static NS_DEFINE_IID(kCTransferable, NS_TRANSFERABLE_CID); -static NS_DEFINE_IID(kCDataFlavor, NS_DATAFLAVOR_CID); -static NS_DEFINE_IID(kCHTMLFormatConverter, NS_HTMLFORMATCONVERTER_CID); -// static NS_DEFINE_IID(kCDragService, NS_DRAGSERVICE_CID); -// static NS_DEFINE_IID(kCDragSource, NS_DRAGSOURCE_CID); -// static NS_DEFINE_IID(kCDragTarget, NS_DRAGTARGET_CID); -// static NS_DEFINE_IID(kCDraggedObject, NS_DRAGGEDOBJECT_CID); - -#ifdef IBMBIDI -static NS_DEFINE_IID(kCBidiKeyboard, NS_BIDIKEYBOARD_CID); -#endif - -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); - - -class nsWidgetFactory : public nsIFactory -{ -public: - - NS_DECL_ISUPPORTS - - // nsIFactory methods - NS_IMETHOD CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult); - - NS_IMETHOD LockFactory(PRBool aLock); - - nsWidgetFactory(const nsCID &aClass); - virtual ~nsWidgetFactory(); -private: - nsCID mClassID; - -}; - - - -nsWidgetFactory::nsWidgetFactory(const nsCID &aClass) -{ - NS_INIT_REFCNT(); - mClassID = aClass; -} - -nsWidgetFactory::~nsWidgetFactory() -{ -} - -nsresult nsWidgetFactory::QueryInterface(const nsIID &aIID, - void **aResult) -{ - if (NULL == aResult) { - return NS_ERROR_NULL_POINTER; - } - - *aResult = NULL; - - if (aIID.Equals(kISupportsIID)) { - *aResult = (void *)(nsISupports *)this; - } else if (aIID.Equals(kIFactoryIID)) { - *aResult = (void *)(nsIFactory *)this; - } - - if (*aResult == NULL) { - return NS_NOINTERFACE; - } - - NS_ADDREF_THIS(); - return NS_OK; -} - -NS_IMPL_ADDREF(nsWidgetFactory) -NS_IMPL_RELEASE(nsWidgetFactory) - -nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult) -{ - if (aResult == NULL) { - return NS_ERROR_NULL_POINTER; - } - - *aResult = NULL; - - if (nsnull != aOuter) - return NS_ERROR_NO_AGGREGATION; - - nsISupports *inst = nsnull; - if (mClassID.Equals(kCWindow)) { - inst = (nsISupports *)new nsWindow(); - } - else if (mClassID.Equals(kCChild)) { - inst = (nsISupports *)new ChildWindow(); - } - else if (mClassID.Equals(kCButton)) { - inst = (nsISupports*)(nsIWidget *)new nsButton(); - } - else if (mClassID.Equals(kCCheckButton)) { - inst = (nsISupports*)(nsIWidget *)new nsCheckButton(); - } - else if (mClassID.Equals(kCHorzScrollbar)) { - inst = (nsISupports*)(nsIWidget *)new nsScrollbar(PR_FALSE); - } - else if (mClassID.Equals(kCVertScrollbar)) { - inst = (nsISupports*)(nsIWidget *)new nsScrollbar(PR_TRUE); - } - else if (mClassID.Equals(kCTextField)) { - inst = (nsISupports*)(nsIWidget *)new nsTextWidget(); - } - else if (mClassID.Equals(kCAppShell)) { - inst = (nsISupports*)new nsAppShell(); - } - else if (mClassID.Equals(kCToolkit)) { - inst = (nsISupports*)(nsIWidget *)new nsToolkit(); - } - else if (mClassID.Equals(kCLookAndFeel)) { - inst = (nsISupports*)(nsIWidget *)new nsLookAndFeel(); - } - else if (mClassID.Equals(kCLabel)) { - inst = (nsISupports*)(nsIWidget *)new nsLabel(); - } - else if (mClassID.Equals(kCTransferable)) { - inst = (nsISupports*)new nsTransferable(); - } -// else if (mClassID.Equals(kCClipboard)) { -// inst = (nsISupports*)new nsClipboard(); -// } - else if (mClassID.Equals(kCClipboardHelper)) { - inst = (nsISupports*)new nsClipboardHelper(); - } - else if (mClassID.Equals(kCHTMLFormatConverter)) { - inst = (nsISupports*)new nsHTMLFormatConverter(); - } -#ifdef IBMBIDI - else if (mClassID.Equals(kCBidiKeyboard)) { - inst = (nsISupports*)(nsIBidiKeyboard*) new nsBidiKeyboard(); - } -#endif // IBMBIDI -#if 0 - else if (mClassID.Equals(kCDragService)) { - inst = (nsISupports*)new nsDragService(); - } -#endif - else { - printf("nsWidgetFactory::CreateInstance(), unhandled class.\n"); - } - - if (inst == NULL) { - return NS_ERROR_OUT_OF_MEMORY; - } - - nsresult res = inst->QueryInterface(aIID, aResult); - - if (res != NS_OK) { - // We didn't get the right interface, so clean up - delete inst; - } - - return res; - -} - -nsresult nsWidgetFactory::LockFactory(PRBool aLock) -{ - // Not implemented in simplest case. - return NS_OK; -} - -// return the proper factory to the caller -extern "C" NS_WIDGET nsresult -NSGetFactory(nsISupports* serviceMgr, - const nsCID &aClass, - const char *aClassName, - const char *aContractID, - nsIFactory **aFactory) -{ - if (nsnull == aFactory) { - return NS_ERROR_NULL_POINTER; - } - - *aFactory = new nsWidgetFactory(aClass); - - if (nsnull == aFactory) { - return NS_ERROR_OUT_OF_MEMORY; - } - - return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory); -} - - diff --git a/widget/src/motif/nsWindow.cpp b/widget/src/motif/nsWindow.cpp deleted file mode 100644 index 3a81a4a43d7c..000000000000 --- a/widget/src/motif/nsWindow.cpp +++ /dev/null @@ -1,1603 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nsWindow.h" -#include "nsWidgetsCID.h" -#include "nsIFontMetrics.h" -#include "nsFont.h" -#include "nsGUIEvent.h" -#include "nsIRenderingContext.h" -#include "nsIDeviceContext.h" -#include "nsRect.h" -#include "nsTransform2D.h" -#include "nsGfxCIID.h" -#include "nsXtEventHandler.h" -#include "nsXtManageWidget.h" -#include "nsAppShell.h" -#include "nsReadableUtils.h" - -#include "stdio.h" - -static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); - -NS_IMPL_ADDREF(nsWindow) -NS_IMPL_RELEASE(nsWindow) - -//------------------------------------------------------------------------- -// -// nsWindow constructor -// -//------------------------------------------------------------------------- -nsWindow::nsWindow(): - mWidget(nsnull), - mEventCallback(nsnull), - mContext(nsnull), - mFontMetrics(nsnull), - mToolkit(nsnull), - mMouseListener(nsnull), - mEventListener(nsnull) -{ - NS_INIT_REFCNT(); - strcpy(gInstanceClassName, "nsWindow"); - mBounds.x = 0; - mBounds.y = 0; - mBounds.width = 0; - mBounds.height = 0; - mResized = PR_FALSE; - mGC = nsnull ; - mShown = PR_FALSE; - mVisible = PR_FALSE; - mDisplayed = PR_FALSE; - mLowerLeft = PR_FALSE; - mCursor = eCursor_standard; - mClientData = nsnull; - mPreferredWidth = 0; - mPreferredHeight = 0; - mFont = nsnull; - mAppContext = nsnull; -} - -//------------------------------------------------------------------------- -// -// nsWindow destructor -// -//------------------------------------------------------------------------- -nsWindow::~nsWindow() -{ - OnDestroy(); - XtDestroyWidget(mWidget); - if (nsnull != mGC) { - ::XFreeGC((Display *)GetNativeData(NS_NATIVE_DISPLAY),mGC); - mGC = nsnull; - } -} - -//------------------------------------------------------------------------- -void nsWindow::ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY) -{ -} - -//------------------------------------------------------------------------- -NS_METHOD nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsWindow::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Setup initial tooltip rectangles -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::SetTooltips(PRUint32 aNumberOfTips,nsRect* aTooltipAreas[]) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Update all tooltip rectangles -// -//------------------------------------------------------------------------- - -NS_METHOD nsWindow::UpdateTooltips(nsRect* aNewTips[]) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Remove all tooltip rectangles -// -//------------------------------------------------------------------------- - -NS_METHOD nsWindow::RemoveTooltips() -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// -// -//------------------------------------------------------------------------- -void nsWindow::InitToolkit(nsIToolkit *aToolkit, - nsIWidget *aWidgetParent) -{ - if (nsnull == mToolkit) { - if (nsnull != aToolkit) { - mToolkit = (nsToolkit*)aToolkit; - mToolkit->AddRef(); - } - else { - if (nsnull != aWidgetParent) { - mToolkit = (nsToolkit*)(aWidgetParent->GetToolkit()); // the call AddRef's, we don't have to - } - // it's some top level window with no toolkit passed in. - // Create a default toolkit with the current thread - else { - mToolkit = new nsToolkit(); - mToolkit->AddRef(); - mToolkit->Init(PR_GetCurrentThread()); - - // Create a shared GC for all widgets - ((nsToolkit *)mToolkit)->SetSharedGC((GC)GetNativeData(NS_NATIVE_GRAPHIC)); - } - } - } -} - -//------------------------------------------------------------------------- -// -// -// -//------------------------------------------------------------------------- -void nsWindow::InitDeviceContext(nsIDeviceContext *aContext, - Widget aParentWidget) -{ - - // keep a reference to the toolkit object - if (aContext) { - mContext = aContext; - mContext->AddRef(); - } - else { - nsresult res; - - static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID); - static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID); - - //res = !NS_OK; - res = nsComponentManager::CreateInstance(kDeviceContextCID, - nsnull, - kDeviceContextIID, - (void **)&mContext); - if (NS_OK == res) { - mContext->Init(aParentWidget); - } - } -} - -void nsWindow::CreateGC() -{ - // Create a Writeable GC for this Widget. Unfortunatley, - // the Window for the Widget is not created properly at this point and - // we Need the GC prior to the Rendering Context getting created, so - // we create a small dummy window of the default depth as our dummy Drawable - // to create a compatible GC - - if (nsnull == mGC) { - - XGCValues values; - Window w; - Display * d = ::XtDisplay(mWidget); - - w = ::XCreateSimpleWindow(d, - RootWindow(d,DefaultScreen(d)), - 0,0,1,1,0, - BlackPixel(d,DefaultScreen(d)), - WhitePixel(d,DefaultScreen(d))); - mGC = ::XCreateGC(d, w, nsnull, &values); - - ::XDestroyWindow(d,w); - } -} - -//------------------------------------------------------------------------- -// -// Create a window. -// -// Note: aNativeParent is always non-null if aWidgetParent is non-null. -// aNativeaParent is set regardless if the parent for the Create() was an -// nsIWidget or a Native widget. -// aNativeParent is equal to aWidgetParent->GetNativeData(NS_NATIVE_WIDGET) -//------------------------------------------------------------------------- - -void nsWindow::CreateWindow(nsNativeWidget aNativeParent, - nsIWidget *aWidgetParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - mAppContext = nsAppShell::GetAppContext(); - - // keep a reference to the device context - if (aContext) { - mContext = aContext; - NS_ADDREF(mContext); - } - else { - nsresult res; - - static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID); - static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID); - - res = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&mContext); - - if (NS_OK == res) { - mContext->Init(nsnull); - } - } - - mBounds = aRect; - mAppShell = aAppShell; - - InitToolkit(aToolkit, aWidgetParent); - - // save the event callback function - mEventCallback = aHandleEventFunction; - - if (nsnull==aNativeParent) { - /************************/ - /* Create a main window */ - /************************/ - - InitDeviceContext(aContext, - (Widget) aAppShell->GetNativeData(NS_NATIVE_SHELL)); - - Widget mainWindow = ::XtVaCreateManagedWidget("mainWindow", - xmMainWindowWidgetClass, - (Widget) aAppShell->GetNativeData(NS_NATIVE_SHELL), - nsnull); - - // Initially used xmDrawingAreaWidgetClass instead of - // newManageClass. Drawing area will spontaneously resize - // to fit it's contents. - - mWidget = ::XtVaCreateManagedWidget("drawingArea", - newManageClass, - mainWindow, - XmNwidth, aRect.width, - XmNheight, aRect.height, - XmNmarginHeight, 0, - XmNmarginWidth, 0, - XmNrecomputeSize, False, - XmNuserData, this, - nsnull); - - if (mainWindow) { - XmMainWindowSetAreas(mainWindow, nsnull, nsnull, nsnull, nsnull, mWidget); - } - - if (aWidgetParent) { - aWidgetParent->AddChild(this); - } - - InitCallbacks(); - CreateGC(); - } - else { - /*************************/ - /* Create a child window */ - /*************************/ - - InitDeviceContext(aContext, (Widget)aNativeParent); - - // Initially used xmDrawingAreaWidgetClass instead of - // newManageClass. Drawing area will spontaneously resize - // to fit it's contents. - - mWidget = ::XtVaCreateManagedWidget("drawingArea", - newManageClass, - (Widget)aNativeParent, - XmNwidth, aRect.width, - XmNheight, aRect.height, - XmNmarginHeight, 0, - XmNmarginWidth, 0, - XmNrecomputeSize, False, - XmNuserData, this, - nsnull); - if (aWidgetParent) { - aWidgetParent->AddChild(this); - } - - // Force cursor to default setting - - // Note -- is this really necessary?? Ideally should find out--I suspect - // it isn't. --ZuperDee - - mCursor = eCursor_select; - SetCursor(eCursor_standard); - - InitCallbacks(); - CreateGC(); - } -} - -//------------------------------------------------------------------------- -// -// Initialize all the Callbacks -// -//------------------------------------------------------------------------- -void nsWindow::InitCallbacks(char * aName) -{ - XtAddEventHandler(mWidget, - ButtonPressMask, - PR_FALSE, - nsXtWidget_ButtonPressMask_EventHandler, - this); - - XtAddEventHandler(mWidget, - ButtonReleaseMask, - PR_FALSE, - nsXtWidget_ButtonReleaseMask_EventHandler, - this); - - XtAddEventHandler(mWidget, - ButtonMotionMask, - PR_FALSE, - nsXtWidget_ButtonMotionMask_EventHandler, - this); - - XtAddEventHandler(mWidget, - PointerMotionMask, - PR_FALSE, - nsXtWidget_MotionMask_EventHandler, - this); - - XtAddEventHandler(mWidget, - EnterWindowMask, - PR_FALSE, - nsXtWidget_EnterMask_EventHandler, - this); - - XtAddEventHandler(mWidget, - LeaveWindowMask, - PR_FALSE, - nsXtWidget_LeaveMask_EventHandler, - this); - - XtAddEventHandler(mWidget, - ExposureMask, - PR_TRUE, - nsXtWidget_ExposureMask_EventHandler, - this); - - XtAddEventHandler(mWidget, - KeyPressMask, - PR_FALSE, - nsXtWidget_KeyPressMask_EventHandler, - this); - - XtAddEventHandler(mWidget, - KeyReleaseMask, - PR_FALSE, - nsXtWidget_KeyReleaseMask_EventHandler, - this); - -} - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsWindow::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - nsresult result = NS_NOINTERFACE; - static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); - if (aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*) ((nsISupports*)this); - AddRef(); - return NS_OK; - } - - if (aIID.Equals(kIWidgetIID)) { - *aInstancePtr = (void*) ((nsIWidget*)this); - AddRef(); - result = NS_OK; - } - - return result; -} - -//------------------------------------------------------------------------- -// -// create with nsIWidget parent -// -//------------------------------------------------------------------------- - -NS_METHOD nsWindow::Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - if (aParent) - aParent->AddChild(this); - CreateWindow((nsNativeWidget)((aParent) ? aParent->GetNativeData(NS_NATIVE_WIDGET) : 0), - aParent, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit, - aInitData); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// create with a native parent -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - CreateWindow(aParent, 0, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit, aInitData); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Close this nsWindow -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::Destroy() -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Accessor functions to get/set the client data -// -//------------------------------------------------------------------------- - -NS_IMETHODIMP nsWindow::GetClientData(void*& aClientData) -{ - aClientData = mClientData; - return NS_OK; -} - -NS_IMETHODIMP nsWindow::SetClientData(void* aClientData) -{ - mClientData = aClientData; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get this nsWindow parent -// -//------------------------------------------------------------------------- -nsIWidget* nsWindow::GetParent(void) -{ - // XXX: Implement this - return nsnull; -} - - -//------------------------------------------------------------------------- -// -// Get this nsWindow's list of children -// -//------------------------------------------------------------------------- -nsIEnumerator* nsWindow::GetChildren() -{ - //XXX: Implement this - return nsnull; -} - - -//------------------------------------------------------------------------- -// -// Add a child to the list of children -// -//------------------------------------------------------------------------- -void nsWindow::AddChild(nsIWidget* aChild) -{ - // XXX:Implement this -} - - -//------------------------------------------------------------------------- -// -// Remove a child from the list of children -// -//------------------------------------------------------------------------- -void nsWindow::RemoveChild(nsIWidget* aChild) -{ - // XXX:Implement this -} - - -//------------------------------------------------------------------------- -// -// Hide or show this component -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::Show(PRBool aState) -{ - mShown = aState; - if (aState) { - XtManageChild(mWidget); - } - else - XtUnmanageChild(mWidget); - - return NS_OK; -} - -NS_METHOD nsWindow::SetModal(PRBool aModal) -{ - //XXX:Implement this - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsWindow::IsVisible(PRBool & aState) -{ - aState = mShown; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Check a potential new window position to be sure it fits on screen -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::ConstrainPosition(PRInt32 *aX, PRInt32 *aY) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Move this component -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::Move(PRInt32 aX, PRInt32 aY) -{ - mBounds.x = aX; - mBounds.y = aY; - - XtVaSetValues(mWidget, XmNx, aX, XmNy, GetYCoord(aY), nsnull); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Resize this component -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) -{ -//#if 0 - printf("$$$$$$$$$ %s::Resize %d %d Repaint: %s\n", - gInstanceClassName, aWidth, aHeight, (aRepaint?"true":"false")); -//#endif - - // ignore resizes smaller than or equal to 1x1 - if (aWidth <=1 || aHeight <= 1) - return NS_OK; - - mBounds.width = aWidth; - mBounds.height = aHeight; - XtVaSetValues(mWidget, - XmNx, mBounds.x, - XmNy, mBounds.y, - XmNwidth, aWidth, - XmNheight, aHeight, - nsnull); - if (aRepaint) - Invalidate(PR_FALSE); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Resize this component -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, - PRInt32 aHeight, PRBool aRepaint) -{ - Resize(aWidth,aHeight,aRepaint); - Move(aX,aY); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Enable/disable this component -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::Enable(PRBool bState) -{ - XtVaSetValues(mWidget, XmNsensitive, bState, nsnull); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Give the focus to this component -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::SetFocus(PRBool aRaise) -{ - // Go get the parent of all widget's to determine which widget - // tree to use to set the focus. - Widget w = mWidget; - while (NULL != XtParent(w)) { - w = XtParent(w); - } - - XtSetKeyboardFocus(w, mWidget); - return NS_OK; -} - -/* - * Set this component dimension - */ -NS_METHOD nsWindow::SetBounds(const nsRect &aRect) -{ - mBounds = aRect; - return NS_OK; -} - -/* - * Get this component dimension - */ -NS_METHOD nsWindow::GetBounds(nsRect &aRect) -{ - aRect = mBounds; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Get the foreground color -// -//------------------------------------------------------------------------- -nscolor nsWindow::GetForegroundColor(void) -{ - return (mForeground); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the foreground color -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::SetForegroundColor(const nscolor &aColor) -{ - PRUint32 pixel; - mForeground = aColor; - mContext->ConvertPixel(aColor, pixel); - XtVaSetValues(mWidget, XtNforeground, pixel, nsnull); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the background color -// -//------------------------------------------------------------------------- -nscolor nsWindow::GetBackgroundColor(void) -{ - return (mBackground); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the background color -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::SetBackgroundColor(const nscolor &aColor) -{ -// mBackground = aColor ; -// PRUint32 pixel; -// mContext->ConvertPixel(aColor, pixel); -// XtVaSetValues(mWidget, XtNbackground, pixel, nsnull); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get this component font -// -//------------------------------------------------------------------------- -nsIFontMetrics* nsWindow::GetFont(void) -{ - //XXX: Implement this - NS_NOTYETIMPLEMENTED("GetFont not yet implemented"); // to be implemented - return nsnull; -} - - -//------------------------------------------------------------------------- -// -// Set this component font -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::SetFont(const nsFont &aFont) -{ - if (mContext == nsnull) { - return NS_ERROR_FAILURE; - } - nsIFontMetrics* metrics; - mContext->GetMetricsFor(aFont, metrics); - if (metrics != nsnull) { - - XmFontList fontList = NULL; - XmFontListEntry entry = NULL; - nsFontHandle fontHandle; - metrics->GetFontHandle(fontHandle); - XFontStruct * fontStruct = XQueryFont(XtDisplay(mWidget), (XID)fontHandle); - - if (fontStruct != NULL) { - entry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG, - XmFONT_IS_FONT, fontStruct); - fontList = XmFontListAppendEntry(NULL, entry); - - XtVaSetValues(mWidget, XmNfontList, fontList, NULL); - - XmFontListEntryFree(&entry); - XmFontListFree(fontList); - } - - NS_RELEASE(metrics); - } else { - printf("****** Error: Metrics is NULL!\n"); - return NS_ERROR_FAILURE; - } - - // XXX Temporary, should not be caching the font - if (mFont == nsnull) { - mFont = new nsFont(aFont); - } else { - *mFont = aFont; - } - - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get this component cursor -// -//------------------------------------------------------------------------- -nsCursor nsWindow::GetCursor() -{ - return eCursor_standard; -} - - -//------------------------------------------------------------------------- -// -// Set this component cursor -// -//------------------------------------------------------------------------- - -NS_METHOD nsWindow::SetCursor(nsCursor aCursor) -{ - Window window = ::XtWindow(mWidget); - if (nsnull==window) - return NS_ERROR_FAILURE; - - // Only change cursor if it's changing - if (aCursor != mCursor) { - Cursor newCursor = 0; - Display *display = ::XtDisplay(mWidget); - - switch(aCursor) { - case eCursor_select: - newCursor = XCreateFontCursor(display, XC_xterm); - break; - - case eCursor_wait: - newCursor = XCreateFontCursor(display, XC_watch); - break; - - case eCursor_hyperlink: - newCursor = XCreateFontCursor(display, XC_hand2); - break; - - case eCursor_standard: - newCursor = XCreateFontCursor(display, XC_left_ptr); - break; - - case eCursor_arrow_south: - case eCursor_arrow_south_plus: - newCursor = XCreateFontCursor(display, XC_bottom_side); - break; - - case eCursor_arrow_north: - case eCursor_arrow_north_plus: - newCursor = XCreateFontCursor(display, XC_top_side); - break; - - case eCursor_arrow_east: - case eCursor_arrow_east_plus: - newCursor = XCreateFontCursor(display, XC_right_side); - break; - - case eCursor_arrow_west: - case eCursor_arrow_west_plus: - newCursor = XCreateFontCursor(display, XC_left_side); - break; - - default: - //XXX Commenting invalid assertion, there are other cursor types. - //NS_ASSERTION(PR_FALSE, "Invalid cursor type"); - break; - } - - if (nsnull != newCursor) { - mCursor = aCursor; - XDefineCursor(display, window, newCursor); - } - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Invalidate this component visible area -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::Invalidate(PRBool aIsSynchronous) -{ - if (mWidget == nsnull) { - return NS_ERROR_FAILURE; - } - - if (!XtIsRealized(mWidget)) { - return NS_ERROR_FAILURE; - } - - Window win = XtWindow(mWidget); - Display *display = XtDisplay(mWidget); - - - XEvent evt; - evt.xgraphicsexpose.type = GraphicsExpose; - evt.xgraphicsexpose.send_event = False; - evt.xgraphicsexpose.display = display; - evt.xgraphicsexpose.drawable = win; - evt.xgraphicsexpose.x = 0; - evt.xgraphicsexpose.y = 0; - evt.xgraphicsexpose.width = mBounds.width; - evt.xgraphicsexpose.height = mBounds.height; - evt.xgraphicsexpose.count = 0; - XSendEvent(display, win, False, ExposureMask, &evt); - XFlush(display); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Invalidate this component visible area -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::Invalidate(const nsRect & aRect, PRBool aIsSynchronous) -{ - if (mWidget == nsnull) { - return NS_ERROR_FAILURE; - } - - if (!XtIsRealized(mWidget)) { - return NS_ERROR_FAILURE; - } - - Window win = XtWindow(mWidget); - Display *display = XtDisplay(mWidget); - - - XEvent evt; - evt.xgraphicsexpose.type = GraphicsExpose; - evt.xgraphicsexpose.send_event = False; - evt.xgraphicsexpose.display = display; - evt.xgraphicsexpose.drawable = win; - evt.xgraphicsexpose.x = aRect.x; - evt.xgraphicsexpose.y = aRect.y; - evt.xgraphicsexpose.width = aRect.width; - evt.xgraphicsexpose.height = aRect.height; - evt.xgraphicsexpose.count = 0; - XSendEvent(display, win, False, ExposureMask, &evt); - XFlush(display); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Force a synchronous repaint of the window -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsWindow::Update() -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Return some native data according to aDataType -// -//------------------------------------------------------------------------- -void *nsWindow::GetNativeData(PRUint32 aDataType) -{ - switch(aDataType) { - case NS_NATIVE_WINDOW: - return (void*)XtWindow(mWidget); - case NS_NATIVE_DISPLAY: - return (void*)XtDisplay(mWidget); - case NS_NATIVE_WIDGET: - return (void*)(mWidget); - case NS_NATIVE_GRAPHIC: - { - void *res = NULL; - // We Cache a Read-Only Shared GC in the Toolkit. If we don't - // have one ourselves (because it needs to be writeable) grab the - // the shared GC - if (nsnull == mGC) { - NS_ASSERTION(mToolkit, "Unable to return GC, toolkit is null"); - res = (void *)((nsToolkit *)mToolkit)->GetSharedGC(); - } - else { - res = (void *)mGC; - } - NS_ASSERTION(res, "Unable to return GC"); - return res; - } - case NS_NATIVE_COLORMAP: - default: - break; - } - - return NULL; -} - -//~~~ -void nsWindow::FreeNativeData(void * data, PRUint32 aDataType) -{ -} - -//------------------------------------------------------------------------- -// -// Create a rendering context from this nsWindow -// -//------------------------------------------------------------------------- -nsIRenderingContext* nsWindow::GetRenderingContext() -{ - nsIRenderingContext * ctx = nsnull; - - if (GetNativeData(NS_NATIVE_WIDGET)) { - - nsresult res; - - static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID); - static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID); - - res = nsComponentManager::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&ctx); - - if (NS_OK == res) - ctx->Init(mContext, this); - - NS_ASSERTION(NULL != ctx, "Null rendering context"); - } - - return ctx; - -} - -//------------------------------------------------------------------------- -// -// Return the toolkit this widget was created on -// -//------------------------------------------------------------------------- -nsIToolkit* nsWindow::GetToolkit() -{ - return nsnull; -} - - -//------------------------------------------------------------------------- -// -// Set the colormap of the window -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::SetColorMap(nsColorMap *aColorMap) -{ - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Return the used device context -// -//------------------------------------------------------------------------- -nsIDeviceContext* nsWindow::GetDeviceContext() -{ - NS_IF_ADDREF(mContext); - return mContext; -} - -//------------------------------------------------------------------------- -// -// Return the used app shell -// -//------------------------------------------------------------------------- -nsIAppShell* nsWindow::GetAppShell() -{ - NS_IF_ADDREF(mAppShell); - return mAppShell; -} - -//------------------------------------------------------------------------- -// -// Scroll the bits of a window -// -//------------------------------------------------------------------------- -NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) -{ - if (mWidget == nsnull) { - return NS_ERROR_FAILURE; - } - - // Scroll all of the child widgets - Cardinal numChildren; - XtVaGetValues(mWidget, XtNnumChildren, &numChildren, nsnull); - if (numChildren > 0) { - WidgetList children; - XtVaGetValues(mWidget, XtNchildren, &children, nsnull); - unsigned int i; - for(i = 0; i < numChildren; i++) { - Position x; - Position y; - XtVaGetValues(children[i], XtNx, &x, XtNy, &y, nsnull); - - XtVaSetValues(children[i], XmNx, x + aDx, XmNy, y + aDy, nsnull); - } - } - - if (aClipRect) - Invalidate(*aClipRect, PR_TRUE); - else - Invalidate(PR_TRUE); - return NS_OK; -} - -NS_METHOD nsWindow::SetBorderStyle(nsBorderStyle aBorderStyle) -{ - return NS_OK; -} - -NS_METHOD nsWindow::SetTitle(const nsString& aTitle) -{ -/* - if(!mBaseWindow) - return NS_ERROR_FAILURE; - - const char *text = ToNewCString(aTitle); - XStoreName(gDisplay, mBaseWindow, text); - delete [] text; -*/ - return NS_OK; -} - -NS_METHOD nsWindow::CaptureRollupEvents(nsIRollupListener *aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent) -{ - return NS_OK; -} - -/** - * Processes a mouse pressed event - **/ -NS_METHOD nsWindow::AddMouseListener(nsIMouseListener * aListener) -{ - return NS_OK; -} - -/** - * Processes a mouse pressed event - **/ -NS_METHOD nsWindow::AddEventListener(nsIEventListener * aListener) -{ - return NS_OK; -} - -NS_METHOD nsWindow::AddMenuListener(nsIMenuListener * aListener) -{ - //XXX:Implement this. - return NS_OK; -} - -PRBool nsWindow::ConvertStatus(nsEventStatus aStatus) -{ - switch(aStatus) { - case nsEventStatus_eIgnore: - return(PR_FALSE); - case nsEventStatus_eConsumeNoDefault: - return(PR_TRUE); - case nsEventStatus_eConsumeDoDefault: - return(PR_FALSE); - default: - NS_ASSERTION(0, "Illegal nsEventStatus enumeration value"); - break; - } - return(PR_FALSE); -} - -////////////////////////////////////////////////////////////////// -// -// Turning TRACE_EVENTS on will cause printfs for all -// mouse events that are dispatched. -// -// These are extra noisy, and thus have their own switch: -// -// NS_MOUSE_MOVE -// NS_PAINT -// NS_MOUSE_ENTER, NS_MOUSE_EXIT -// -////////////////////////////////////////////////////////////////// - -#define TRACE_EVENTS -#undef TRACE_EVENTS_MOTION -#define TRACE_EVENTS_PAINT -#undef TRACE_EVENTS_CROSSING - -#ifdef DEBUG -void -nsWindow::DebugPrintEvent(nsGUIEvent & aEvent, - Widget aWidget) -{ -#ifndef TRACE_EVENTS_MOTION - if (aEvent.message == NS_MOUSE_MOVE) - { - return; - } -#endif - -#ifndef TRACE_EVENTS_PAINT - if (aEvent.message == NS_PAINT) - { - return; - } -#endif - -#ifndef TRACE_EVENTS_CROSSING - if (aEvent.message == NS_MOUSE_ENTER || aEvent.message == NS_MOUSE_EXIT) - { - return; - } -#endif - - static int sPrintCount=0; - - printf("%4d %-26s(this=%-8p , widget=%-8p", - sPrintCount++, - NS_LossyConvertUCS2toASCII(debug_GuiEventToString(&aEvent)).get(), - this, - (void *) aWidget); - - printf(" , x=%-3d, y=%d)",aEvent.point.x,aEvent.point.y); - - printf("\n"); -} -#endif // DEBUG -////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------- -// -// Invokes callback and ProcessEvent method on Event Listener object -// -//------------------------------------------------------------------------- - -NS_IMETHODIMP nsWindow::DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus) -{ -#ifdef TRACE_EVENTS - DebugPrintEvent(*event,mWidget); -#endif - - NS_ADDREF(event->widget); - - aStatus = nsEventStatus_eIgnore; - - //if (nsnull != mMenuListener) - // aStatus = mMenuListener->MenuSelected(*event); - if (nsnull != mEventCallback) { - aStatus = (*mEventCallback)(event); - } - - // Dispatch to event listener if event was not consumed - if ((aStatus != nsEventStatus_eIgnore) && (nsnull != mEventListener)) { - aStatus = mEventListener->ProcessEvent(*event); - } - NS_RELEASE(event->widget); - - return NS_OK; - -} - -PRBool nsWindow::DispatchWindowEvent(nsGUIEvent* event) -{ - nsEventStatus status; - DispatchEvent(event, status); - return ConvertStatus(status); -} - - -//------------------------------------------------------------------------- -// -// Deals with all sorts of mouse events -// -//------------------------------------------------------------------------- -PRBool nsWindow::DispatchMouseEvent(nsMouseEvent& aEvent) -{ - PRBool result = PR_FALSE; - if (nsnull == mEventCallback && nsnull == mMouseListener) { - return result; - } - - // call the event callback - if (nsnull != mEventCallback) { - result = DispatchWindowEvent(&aEvent); - return result; - } - - if (nsnull != mMouseListener) { - switch (aEvent.message) { - case NS_MOUSE_MOVE: - break; - - case NS_MOUSE_LEFT_BUTTON_DOWN: - case NS_MOUSE_MIDDLE_BUTTON_DOWN: - case NS_MOUSE_RIGHT_BUTTON_DOWN: - result = ConvertStatus(mMouseListener->MousePressed(aEvent)); - break; - - case NS_MOUSE_LEFT_BUTTON_UP: - case NS_MOUSE_MIDDLE_BUTTON_UP: - case NS_MOUSE_RIGHT_BUTTON_UP: - result = ConvertStatus(mMouseListener->MouseReleased(aEvent)); - result = ConvertStatus(mMouseListener->MouseClicked(aEvent)); - break; - } // switch - } - return result; -} - -/** - * Processes an Expose Event - **/ -PRBool nsWindow::OnPaint(nsPaintEvent &event) -{ - nsresult result; - - // call the event callback - if (mEventCallback) { - event.renderingContext = nsnull; -#if 0 - if (event.rect) { - printf("nsWindow::OnPaint(this=%p, {%i,%i,%i,%i})\n", this, - event.rect->x, event.rect->y, - event.rect->width, event.rect->height); - } - else { - printf("nsWindow::OnPaint(this=%p, NO RECT)\n", this); - } -#endif - static NS_DEFINE_CID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID); - if (NS_OK == nsComponentManager::CreateInstance(kRenderingContextCID, - nsnull, - NS_GET_IID(nsIRenderingContext), - (void **)&event.renderingContext)) - { - event.renderingContext->Init(mContext, this); - result = DispatchWindowEvent(&event); - NS_RELEASE(event.renderingContext); - } - else - { - result = PR_FALSE; - } - } - return result; -} - -// FIXME: Needs to be implemented?? Looks like a stub to me... -NS_METHOD nsWindow::BeginResizingChildren(void) -{ - return NS_OK; -} - -// FIXME: Needs to be implemented?? Looks like a stub to me... -NS_METHOD nsWindow::EndResizingChildren(void) -{ - return NS_OK; -} - - -void nsWindow::OnDestroy() -{ - // release references to children, device context, toolkit, and app shell - //XXX: Why is there a problem releasing these - // NS_IF_RELEASE(mChildren); - // NS_IF_RELEASE(mContext); - // NS_IF_RELEASE(mToolkit); - // NS_IF_RELEASE(mAppShell); -} - -PRBool nsWindow::OnResize(nsSizeEvent &aEvent) -{ - if (mEventCallback) { - return DispatchWindowEvent(&aEvent); - } - return FALSE; -} - -PRBool nsWindow::OnKey(PRUint32 aEventType, PRUint32 aKeyCode, nsKeyEvent* aEvent) -{ - if (mEventCallback) { - return DispatchWindowEvent(aEvent); - } - else - return FALSE; -} - - -PRBool nsWindow::DispatchFocus(nsGUIEvent &aEvent) -{ - if (mEventCallback) { - return DispatchWindowEvent(&aEvent); - } - - return FALSE; -} - -PRBool nsWindow::OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos) -{ - return FALSE; -} - -void nsWindow::SetResizeRect(nsRect& aRect) -{ - mResizeRect = aRect; - printf("SetResizeRect: %i %i\n",mResizeRect.width,mResizeRect.height); -} - -void nsWindow::GetResizeRect(nsRect* aRect) -{ - aRect->x = mResizeRect.x; - aRect->y = mResizeRect.y; - aRect->width = mResizeRect.width; - aRect->height = mResizeRect.height; -} - -void nsWindow::SetResized(PRBool aResized) -{ - mResized = aResized; -} - -PRBool nsWindow::GetResized() -{ - return(mResized); -} - -void nsWindow::UpdateDisplay() -{ - // If not displayed and needs to be displayed - if ((PR_FALSE==mDisplayed) && - (PR_TRUE==mShown) && - (PR_TRUE==mVisible)) { - XtManageChild(mWidget); - mDisplayed = PR_TRUE; - } - - // Displayed and needs to be removed - if (PR_TRUE==mDisplayed) { - if ((PR_FALSE==mShown) || (PR_FALSE==mVisible)) { - XtUnmanageChild(mWidget); - mDisplayed = PR_FALSE; - } - } -} - -PRUint32 nsWindow::GetYCoord(PRUint32 aNewY) -{ - if (PR_TRUE==mLowerLeft) { - return(aNewY - mBounds.height); - } - return(aNewY); -} - -//----------------------------------------------------- -// Resize handler code for child and main windows. -//----------------------------------------------------- - -void nsWindow_ResetResize_Callback(XtPointer call_data) -{ - nsWindow* widgetWindow = (nsWindow*)call_data; - widgetWindow->SetResized(PR_FALSE); -} - -void nsWindow_Refresh_Callback(XtPointer call_data) -{ - nsWindow* widgetWindow = (nsWindow*)call_data; - nsRect bounds; - widgetWindow->GetResizeRect(&bounds); - - nsSizeEvent event; - event.message = NS_SIZE; - event.widget = widgetWindow; - event.time = 0; //TBD - event.windowSize = &bounds; - - widgetWindow->SetBounds(bounds); - widgetWindow->OnResize(event); - nsPaintEvent pevent; - pevent.message = NS_PAINT; - pevent.widget = widgetWindow; - pevent.time = 0; - pevent.rect = (nsRect *)&bounds; - widgetWindow->OnPaint(pevent); - - XtAppAddTimeOut(widgetWindow->mAppContext, 50, (XtTimerCallbackProc)nsWindow_ResetResize_Callback, widgetWindow); -} - -// Resize a child window widget. All nsManageWidget's use -// this to resize. The nsManageWidget passes all resize -// request's directly to this function. - -extern "C" void nsWindow_ResizeWidget(Widget w) -{ - int width = 0; - int height = 0; - nsWindow *win = 0; - - // Get the new size for the window - printf("Zuperdee says %-8p\n",(Widget&) w); - XtVaGetValues(w, XmNuserData, &win, XmNwidth, &width, XmNheight, &height, nsnull); - printf("%i %i\n",width,height); - - // Setup the resize rectangle for the window. - nsRect bounds; - bounds.width = width; - bounds.height = height; - bounds.x = 0; - bounds.y = 0; - win->SetResizeRect(bounds); - - if (! win->GetResized()) { - win->SetResized(PR_TRUE); - if (win->IsChild()) { - // Call refresh directly. Don't filter resize events. - nsWindow_Refresh_Callback(win); - } - else { - // XXX: KLUDGE: Do actual resize later. This lets most - // of the resize events come through before actually - // resizing. This is only needed for main (shell) - // windows. This should be replaced with code that actually - // Compresses the event queue. - XtAppAddTimeOut(win->mAppContext, 250, (XtTimerCallbackProc)nsWindow_Refresh_Callback, win); - } - } -} - -NS_METHOD nsWindow::SetMenuBar(nsIMenuBar * aMenuBar) -{ - return NS_ERROR_FAILURE; -} - -NS_METHOD nsWindow::ShowMenuBar(PRBool aShow) -{ - return NS_ERROR_FAILURE; -} - -NS_METHOD nsWindow::GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight) -{ - aWidth = mPreferredWidth; - aHeight = mPreferredHeight; - return (mPreferredWidth != 0 && mPreferredHeight != 0)?NS_OK:NS_ERROR_FAILURE; -} - -NS_METHOD nsWindow::SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight) -{ - mPreferredWidth = aWidth; - mPreferredHeight = aHeight; - return NS_OK; -} - -NS_METHOD nsWindow::EnableFileDrop(PRBool aEnable) -{ - //XXX:Implement this. - return NS_OK; -} - -NS_METHOD nsWindow::CaptureMouse(PRBool aCapture) -{ - //XXX:Implement this. - printf("nsWindow::CaptureMouse called\n"); - return NS_OK; -} diff --git a/widget/src/motif/nsWindow.h b/widget/src/motif/nsWindow.h deleted file mode 100644 index f61c14e5f40b..000000000000 --- a/widget/src/motif/nsWindow.h +++ /dev/null @@ -1,240 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef Window_h__ -#define Window_h__ - -#include "nsBaseWidget.h" -#include "nsToolkit.h" -#include "nsIAppShell.h" - -#include - -class nsFont; - -#define NSRGB_2_COLOREF(color) \ - RGB(NS_GET_R(color),NS_GET_G(color),NS_GET_B(color)) - - -/** - * Native Motif window wrapper. - */ - -class nsWindow : public nsBaseWidget -{ - -public: - // nsIWidget interface - - nsWindow(); - virtual ~nsWindow(); - - // nsISupports - NS_DECL_ISUPPORTS - - virtual void ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY); - - NS_IMETHOD Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - NS_IMETHOD Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - NS_IMETHOD GetClientData(void*& aClientData); - NS_IMETHOD SetClientData(void* aClientData); - NS_IMETHOD Destroy(); - virtual nsIWidget* GetParent(void); - virtual nsIEnumerator* GetChildren(void); - NS_IMETHOD Show(PRBool aState); - NS_IMETHOD SetModal(PRBool aModal); - NS_IMETHOD IsVisible(PRBool & aState); - NS_IMETHOD ConstrainPosition(PRInt32 *aX, PRInt32 *aY); - NS_IMETHOD Move(PRInt32 aX, PRInt32 aY); - virtual void AddChild(nsIWidget* aChild); - virtual void RemoveChild(nsIWidget* aChild); - - NS_IMETHOD Resize(PRInt32 aWidth, - PRInt32 aHeight, - PRBool aRepaint); - NS_IMETHOD Resize(PRInt32 aX, - PRInt32 aY, - PRInt32 aWidth, - PRInt32 aHeight, - PRBool aRepaint); - NS_IMETHOD Enable(PRBool bState); - NS_IMETHOD SetFocus(PRBool aRaise); - NS_IMETHOD GetBounds(nsRect &aRect); - virtual nscolor GetForegroundColor(void); - NS_IMETHOD SetForegroundColor(const nscolor &aColor); - virtual nscolor GetBackgroundColor(void); - NS_IMETHOD SetBackgroundColor(const nscolor &aColor); - virtual nsIFontMetrics* GetFont(void); - NS_IMETHOD SetFont(const nsFont &aFont); - virtual nsCursor GetCursor(); - NS_IMETHOD SetCursor(nsCursor aCursor); - NS_IMETHOD Invalidate(PRBool aIsSynchronous); - NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous); - NS_IMETHOD Update(); - virtual void* GetNativeData(PRUint32 aDataType); - virtual void FreeNativeData(void * data, PRUint32 aDataType);//~~~ - virtual nsIRenderingContext* GetRenderingContext(); - NS_IMETHOD SetColorMap(nsColorMap *aColorMap); - virtual nsIDeviceContext* GetDeviceContext(); - virtual nsIAppShell * GetAppShell(); - NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect); - virtual nsIToolkit* GetToolkit(); - NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle); - NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent); - NS_IMETHOD SetTitle(const nsString& aTitle); - NS_IMETHOD SetTooltips(PRUint32 aNumberOfTips,nsRect* aTooltipAreas[]); - NS_IMETHOD RemoveTooltips(); - NS_IMETHOD UpdateTooltips(nsRect* aNewTips[]); - NS_IMETHOD WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect); - NS_IMETHOD ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect); - NS_IMETHOD AddMouseListener(nsIMouseListener * aListener); - NS_IMETHOD AddEventListener(nsIEventListener * aListener); - NS_IMETHOD AddMenuListener(nsIMenuListener * aListener); - NS_IMETHOD BeginResizingChildren(void); - NS_IMETHOD EndResizingChildren(void); - NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar); - NS_IMETHOD ShowMenuBar(PRBool aShow); - NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight); - NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight); - NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus); - NS_IMETHOD EnableFileDrop(PRBool aEnable); - NS_IMETHOD CaptureMouse(PRBool aCapture); - -#ifdef DEBUG - void DebugPrintEvent(nsGUIEvent & aEvent,Widget aWidget); -#endif - - virtual PRBool IsChild() { return(PR_FALSE); }; - - // Utility methods - NS_IMETHOD SetBounds(const nsRect &aRect); - PRBool ConvertStatus(nsEventStatus aStatus); - virtual PRBool OnPaint(nsPaintEvent &event); - virtual void OnDestroy(); - PRBool OnKey(PRUint32 aEventType, PRUint32 aKeyCode, nsKeyEvent* aEvent); - PRBool DispatchFocus(nsGUIEvent &aEvent); - virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos); - PRUint32 GetYCoord(PRUint32 aNewY); - PRBool DispatchMouseEvent(nsMouseEvent& aEvent); - virtual PRBool OnResize(nsSizeEvent &aEvent); - - // Resize event management - void SetResizeRect(nsRect& aRect); - void SetResized(PRBool aResized); - void GetResizeRect(nsRect* aRect); - PRBool GetResized(); - - char gInstanceClassName[256]; -protected: - void InitCallbacks(char * aName = nsnull); - PRBool DispatchWindowEvent(nsGUIEvent* event); - - - void CreateGC(); - void CreateWindow(nsNativeWidget aNativeParent, nsIWidget *aWidgetParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData); - - void InitToolkit(nsIToolkit *aToolkit, nsIWidget * aWidgetParent); - void InitDeviceContext(nsIDeviceContext *aContext, Widget aWidgetParent); - - virtual void UpdateDisplay(); - -public: - Widget mWidget; - XtAppContext mAppContext; - -protected: - EVENT_CALLBACK mEventCallback; - nsIDeviceContext *mContext; - nsIFontMetrics *mFontMetrics; - nsToolkit *mToolkit; - nsIAppShell *mAppShell; - nsIMouseListener * mMouseListener; - nsIEventListener * mEventListener; - nscolor mBackground; - nscolor mForeground; - unsigned long mBackgroundPixel; - unsigned long mForegroundPixel; - nsCursor mCursor; - nsBorderStyle mBorderStyle; - nsRect mBounds; - PRBool mIgnoreResize; - PRBool mShown; - PRBool mVisible; - PRBool mDisplayed; - void* mClientData; - - // XXX Temporary, should not be caching the font - nsFont * mFont; - PRInt32 mPreferredWidth; - PRInt32 mPreferredHeight; - - // Resize event management - nsRect mResizeRect; - int mResized; - PRBool mLowerLeft; - -private: - GC mGC; -}; - -// -// A child window is a window with different style -// -class ChildWindow : public nsWindow { - public: - ChildWindow() {}; - virtual PRBool IsChild() { return(PR_TRUE); }; -}; - -#endif // Window_h__ diff --git a/widget/src/motif/nsXtEventHandler.cpp b/widget/src/motif/nsXtEventHandler.cpp deleted file mode 100644 index e749034cc253..000000000000 --- a/widget/src/motif/nsXtEventHandler.cpp +++ /dev/null @@ -1,513 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include -#include "nsXtEventHandler.h" - -#include "nsWindow.h" -#include "nsTextWidget.h" -#include "nsCheckButton.h" -#include "nsGUIEvent.h" -#include "nsIMenuItem.h" -#include "nsReadableUtils.h" - -#include "stdio.h" - -#define DBG 0 - -struct nsKeyConverter { - int vkCode; // Platform independent key code - XID keysym; // X keysym key code -}; - -struct nsKeyConverter nsKeycodes[] = { - { NS_VK_CANCEL, XK_Cancel }, - { NS_VK_BACK, XK_BackSpace }, - { NS_VK_TAB, XK_Tab }, -#ifdef XK_ISO_Left_Tab - { NS_VK_TAB, XK_ISO_Left_Tab }, // SunOs 5.5.1 doesnt have it -#endif - { NS_VK_CLEAR, XK_Clear }, - { NS_VK_RETURN, XK_Return }, - { NS_VK_SHIFT, XK_Shift_L }, - { NS_VK_SHIFT, XK_Shift_R }, - { NS_VK_CONTROL, XK_Control_L }, - { NS_VK_CONTROL, XK_Control_R }, - { NS_VK_ALT, XK_Alt_L }, - { NS_VK_ALT, XK_Alt_R }, - { NS_VK_PAUSE, XK_Pause }, - { NS_VK_CAPS_LOCK, XK_Caps_Lock }, - { NS_VK_ESCAPE, XK_Escape }, - { NS_VK_SPACE, XK_space }, - { NS_VK_PAGE_UP, XK_Page_Up }, - { NS_VK_PAGE_DOWN, XK_Page_Down }, - { NS_VK_END, XK_End }, - { NS_VK_HOME, XK_Home }, - { NS_VK_LEFT, XK_Left }, - { NS_VK_UP, XK_Up }, - { NS_VK_RIGHT, XK_Right }, - { NS_VK_DOWN, XK_Down }, - { NS_VK_PRINTSCREEN, XK_Print }, - { NS_VK_INSERT, XK_Insert }, - { NS_VK_DELETE, XK_Delete }, - - { NS_VK_NUMPAD0, XK_KP_0 }, - { NS_VK_NUMPAD1, XK_KP_1 }, - { NS_VK_NUMPAD2, XK_KP_2 }, - { NS_VK_NUMPAD3, XK_KP_3 }, - { NS_VK_NUMPAD4, XK_KP_4 }, - { NS_VK_NUMPAD5, XK_KP_5 }, - { NS_VK_NUMPAD6, XK_KP_6 }, - { NS_VK_NUMPAD7, XK_KP_7 }, - { NS_VK_NUMPAD8, XK_KP_8 }, - { NS_VK_NUMPAD9, XK_KP_9 }, - - { NS_VK_MULTIPLY, XK_KP_Multiply }, - { NS_VK_ADD, XK_KP_Add }, - { NS_VK_SEPARATOR, XK_KP_Separator }, - { NS_VK_SUBTRACT, XK_KP_Subtract }, - { NS_VK_DECIMAL, XK_KP_Decimal }, - { NS_VK_DIVIDE, XK_KP_Divide }, - { NS_VK_F1, XK_F1 }, - { NS_VK_F2, XK_F2 }, - { NS_VK_F3, XK_F3 }, - { NS_VK_F4, XK_F4 }, - { NS_VK_F5, XK_F5 }, - { NS_VK_F6, XK_F6 }, - { NS_VK_F7, XK_F7 }, - { NS_VK_F8, XK_F8 }, - { NS_VK_F9, XK_F9 }, - { NS_VK_F10, XK_F10 }, - { NS_VK_F11, XK_F11 }, - { NS_VK_F12, XK_F12 }, - { NS_VK_F13, XK_F13 }, - { NS_VK_F14, XK_F14 }, - { NS_VK_F15, XK_F15 }, - { NS_VK_F16, XK_F16 }, - { NS_VK_F17, XK_F17 }, - { NS_VK_F18, XK_F18 }, - { NS_VK_F19, XK_F19 }, - { NS_VK_F20, XK_F20 }, - { NS_VK_F21, XK_F21 }, - { NS_VK_F22, XK_F22 }, - { NS_VK_F23, XK_F23 }, - { NS_VK_F24, XK_F24 }, - - { NS_VK_COMMA, XK_comma }, - { NS_VK_PERIOD, XK_period }, - { NS_VK_SLASH, XK_slash }, -//XXX: How do you get a BACK_QUOTE? NS_VK_BACK_QUOTE, XK_backquote, - { NS_VK_OPEN_BRACKET, XK_bracketleft }, - { NS_VK_CLOSE_BRACKET, XK_bracketright }, - { NS_VK_QUOTE, XK_quotedbl } - -}; - -int nsConvertKey(XID keysym) -{ - int i; - int length = sizeof(nsKeycodes) / sizeof(struct nsKeyConverter); - for (i = 0; i < length; i++) { - if (nsKeycodes[i].keysym == keysym) - return(nsKeycodes[i].vkCode); - } - - return((int)keysym); -} - - -//============================================================== -void nsXtWidget_InitNSEvent(XEvent * anXEv, - XtPointer p, - nsGUIEvent &anEvent, - PRUint32 aEventType) -{ - anEvent.message = aEventType; - anEvent.widget = (nsWindow *) p; - anEvent.eventStructType = NS_GUI_EVENT; - - if (anXEv != NULL) { - anEvent.point.x = anXEv->xbutton.x; - anEvent.point.y = anXEv->xbutton.y; - } - - anEvent.time = 0; //XXX: Implement this - -} - -//============================================================== -void nsXtWidget_InitNSMouseEvent(XEvent * anXEv, - XtPointer p, - nsMouseEvent &anEvent, - PRUint32 aEventType) -{ - // Do base initialization - nsXtWidget_InitNSEvent(anXEv, p, anEvent, aEventType); - - if (anXEv != NULL) { // Do Mouse Event specific intialization - anEvent.time = anXEv->xbutton.time; - anEvent.isShift = (anXEv->xbutton.state & ShiftMask) ? PR_TRUE : PR_FALSE; - anEvent.isControl = (anXEv->xbutton.state & ControlMask) ? PR_TRUE : PR_FALSE; - anEvent.isAlt = (anXEv->xbutton.state & Mod1Mask) ? PR_TRUE : PR_FALSE; - anEvent.clickCount = 1; //XXX Fix for double-clicks - anEvent.eventStructType = NS_MOUSE_EVENT; - - } - -} - -//============================================================== -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#define INTERSECTS(r1_x1,r1_x2,r1_y1,r1_y2,r2_x1,r2_x2,r2_y1,r2_y2) \ - !((r2_x2 <= r1_x1) ||\ - (r2_y2 <= r1_y1) ||\ - (r2_x1 >= r1_x2) ||\ - (r2_y1 >= r1_y2)) - -//============================================================== -typedef struct COLLAPSE_INFO { - Window win; - nsRect *r; -} CollapseInfo; - -//============================================================== -void nsXtWidget_ExposureMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b) -{ - nsWindow * widgetWindow = (nsWindow *) p ; - - nsPaintEvent pevent; - nsRect rect; - nsXtWidget_InitNSEvent(event, p, pevent, NS_PAINT); - pevent.rect = (nsRect *)▭ - XEvent xev; - - rect.x = event->xexpose.x; - rect.y = event->xexpose.y; - rect.width = event->xexpose.width; - rect.height = event->xexpose.height; - - - if (widgetWindow->GetResized()) - return; - - if (event->type == NoExpose) { - return; - } - - Display* display = XtDisplay(w); - Window window = XtWindow(w); - - XSync(display, FALSE); - - while (XCheckTypedWindowEvent(display, window, Expose, &xev) == TRUE) { - rect.x = xev.xexpose.x; - rect.y = xev.xexpose.y; - rect.width = xev.xexpose.width; - rect.height = xev.xexpose.height; - } - - widgetWindow->OnPaint(pevent); -} - -//============================================================== -void nsXtWidget_ButtonPressMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b) -{ - nsWindow * widgetWindow = (nsWindow *) p ; - nsMouseEvent mevent; - nsXtWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_LEFT_BUTTON_DOWN); - widgetWindow->DispatchMouseEvent(mevent); -} - -//============================================================== -void nsXtWidget_ButtonReleaseMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b) -{ - nsWindow * widgetWindow = (nsWindow *) p ; - nsMouseEvent mevent; - nsXtWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_LEFT_BUTTON_UP); - widgetWindow->DispatchMouseEvent(mevent); -} - -//============================================================== -void nsXtWidget_ButtonMotionMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b) -{ - nsWindow * widgetWindow = (nsWindow *) p; - nsMouseEvent mevent; - nsXtWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_MOVE); - widgetWindow->DispatchMouseEvent(mevent); -} - -//============================================================== -void nsXtWidget_MotionMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b) -{ - nsWindow * widgetWindow = (nsWindow *) p ; - nsMouseEvent mevent; - nsXtWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_MOVE); - widgetWindow->DispatchMouseEvent(mevent); -} - -//============================================================== -void nsXtWidget_EnterMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b) -{ - nsWindow * widgetWindow = (nsWindow *) p ; - nsMouseEvent mevent; - nsXtWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_ENTER); - widgetWindow->DispatchMouseEvent(mevent); -} - -//============================================================== -void nsXtWidget_LeaveMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b) -{ - if (DBG) fprintf(stderr, "***************** nsXtWidget_LeaveMask_EventHandler\n"); - nsWindow * widgetWindow = (nsWindow *) p ; - nsMouseEvent mevent; - nsXtWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_EXIT); - widgetWindow->DispatchMouseEvent(mevent); -} - -//============================================================== -void nsXtWidget_Focus_Callback(Widget w, XtPointer p, XtPointer call_data) -{ - nsWindow * widgetWindow = (nsWindow *) p ; - - XmAnyCallbackStruct * cbs = (XmAnyCallbackStruct*)call_data; - nsGUIEvent event; - nsXtWidget_InitNSEvent(cbs->event, p, event, - cbs->reason == XmCR_FOCUS?NS_GOTFOCUS:NS_LOSTFOCUS); - widgetWindow->DispatchFocus(event); -} - -//============================================================== -void nsXtWidget_Toggle_ArmCallback(Widget w, XtPointer p, XtPointer call_data) -{ - nsCheckButton * checkBtn = (nsCheckButton *) p; - - XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct*)call_data; - - if (DBG) fprintf(stderr, "Callback struct 0x%x\n", cbs);fflush(stderr); - checkBtn->Armed(); - -} - -//============================================================== -void nsXtWidget_Toggle_DisArmCallback(Widget w, XtPointer p, XtPointer call_data) -{ - nsCheckButton * checkBtn = (nsCheckButton *) p; - checkBtn->DisArmed(); -} - -//============================================================== -void nsXtWidget_Scrollbar_Callback(Widget w, XtPointer p, XtPointer call_data) -{ - nsWindow * widgetWindow = (nsWindow *) p ; - nsScrollbarEvent sevent; - XmScrollBarCallbackStruct * cbs = (XmScrollBarCallbackStruct*) call_data; - sevent.widget = (nsWindow *) p; - if (cbs->event != nsnull) { - sevent.point.x = cbs->event->xbutton.x; - sevent.point.y = cbs->event->xbutton.y; - } else { - sevent.point.x = 0; - sevent.point.y = 0; - } - sevent.time = 0; //XXX Implement this - - switch (cbs->reason) { - - case XmCR_INCREMENT: - sevent.message = NS_SCROLLBAR_LINE_NEXT; - break; - - case XmCR_DECREMENT: - sevent.message = NS_SCROLLBAR_LINE_PREV; - break; - - case XmCR_PAGE_INCREMENT: - sevent.message = NS_SCROLLBAR_PAGE_NEXT; - break; - - case XmCR_PAGE_DECREMENT: - sevent.message = NS_SCROLLBAR_PAGE_PREV; - break; - - case XmCR_DRAG: - sevent.message = NS_SCROLLBAR_POS; - break; - - case XmCR_VALUE_CHANGED: - sevent.message = NS_SCROLLBAR_POS; - break; - - default: - break; - } - widgetWindow->OnScroll(sevent, cbs->value); -} - - - -//============================================================== -void nsXtWidget_Expose_Callback(Widget w, XtPointer p, XtPointer call_data) -{ - - nsWindow * widgetWindow = (nsWindow *) p ; - if (widgetWindow == nsnull) { - return; - } - - XmDrawingAreaCallbackStruct * cbs = (XmDrawingAreaCallbackStruct *)call_data; - XEvent * event = cbs->event; - nsPaintEvent pevent; - nsRect rect; - nsXtWidget_InitNSEvent(event, p, pevent, NS_PAINT); - pevent.rect = (nsRect *)▭ - widgetWindow->OnPaint(pevent); -} - -//============================================================== -void nsXtWidget_Resize_Callback(Widget w, XtPointer p, XtPointer call_data) -{ -} - -//============================================================== -void nsXtWidget_Text_Callback(Widget w, XtPointer p, XtPointer call_data) -{ - int len; - XmTextVerifyCallbackStruct *cbs = (XmTextVerifyCallbackStruct *) call_data; - PasswordData * data; - XtVaGetValues(w, XmNuserData, &data, NULL); - if (data == NULL || data->mIgnore) { - return; - } - - if (cbs->reason == XmCR_ACTIVATE) { - char* password = ToNewCString(data->mPassword); - printf ("Password: %s\n", password); - delete[] password; - return; - } - - if (cbs->startPos < cbs->currInsert) { /* backspace */ - cbs->endPos = data->mPassword.Length(); /* delete from here to end */ - data->mPassword.SetLength(cbs->startPos); /* backspace--terminate */ - return; - } - - if (cbs->startPos == cbs->currInsert && cbs->currInsert < data->mPassword.Length()) { - nsString insStr(cbs->text->ptr); - data->mPassword.Insert(insStr, cbs->currInsert, strlen(cbs->text->ptr)); - } else if (cbs->startPos == cbs->currInsert && cbs->endPos != cbs->startPos) { - data->mPassword.SetLength(cbs->startPos); - printf("Setting Length [%s] at %d\n", cbs->text->ptr, cbs->currInsert); - } else if (cbs->startPos == cbs->currInsert) { /* backspace */ - data->mPassword.Append(cbs->text->ptr); - } - - for (len = 0; len < cbs->text->length; len++) - cbs->text->ptr[len] = '*'; - -} - -//============================================================== -void nsXtWidget_InitNSKeyEvent(int aEventType, nsKeyEvent& aKeyEvent, Widget w, XtPointer p, XEvent * event, Boolean * b) -{ - Modifiers modout = 0; - KeySym res; - - nsXtWidget_InitNSEvent(event, p, aKeyEvent, aEventType); - XKeyEvent* xKeyEvent = (XKeyEvent*)event; - - // Get the modout to test for shift + control - XtTranslateKeycode(xKeyEvent->display,xKeyEvent->keycode, xKeyEvent->state, &modout, &res); - res = XKeycodeToKeysym(xKeyEvent->display, xKeyEvent->keycode, 0); - - aKeyEvent.keyCode = nsConvertKey(res) & 0x00FF; - aKeyEvent.time = xKeyEvent->time; - aKeyEvent.isShift = (xKeyEvent->state & ShiftMask) ? PR_TRUE : PR_FALSE; - aKeyEvent.isControl = (xKeyEvent->state & ControlMask) ? PR_TRUE : PR_FALSE; - aKeyEvent.isAlt = (xKeyEvent->state & Mod1Mask) ? PR_TRUE : PR_FALSE; -} - -//============================================================== -void nsXtWidget_KeyPressMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b) -{ - nsKeyEvent kevent; - nsXtWidget_InitNSKeyEvent(NS_KEY_DOWN, kevent, w, p, event, b); - nsWindow * widgetWindow = (nsWindow *) p ; - widgetWindow->OnKey(NS_KEY_DOWN, kevent.keyCode, &kevent); -} - -//============================================================== -void nsXtWidget_KeyReleaseMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b) -{ - nsKeyEvent kevent; - nsXtWidget_InitNSKeyEvent(NS_KEY_UP, kevent, w, p, event, b); - nsWindow * widgetWindow = (nsWindow *) p ; - widgetWindow->OnKey(NS_KEY_UP, kevent.keyCode, &kevent); -} - -//============================================================== -void nsXtWidget_ResetResize_Callback(XtPointer call_data) -{ - nsWindow* widgetWindow = (nsWindow*)call_data; - widgetWindow->SetResized(PR_FALSE); -} - -//============================================================== -void nsXtWidget_Menu_Callback(Widget w, XtPointer p, XtPointer call_data) -{ - - nsIMenuItem * menuItem = (nsIMenuItem *)p; - if (menuItem != NULL) { - nsMenuEvent mevent; - mevent.message = NS_MENU_SELECTED; - mevent.eventStructType = NS_MENU_EVENT; - mevent.point.x = 0; - mevent.point.y = 0; - menuItem->GetTarget(mevent.widget); - menuItem->GetCommand(mevent.mCommand); - mevent.mMenuItem = menuItem; - mevent.time = 0; //XXX: Implement this - nsEventStatus status; - mevent.widget->DispatchEvent((nsGUIEvent *)&mevent, status); - } -} diff --git a/widget/src/motif/nsXtEventHandler.h b/widget/src/motif/nsXtEventHandler.h deleted file mode 100644 index 13b3eb3e9af2..000000000000 --- a/widget/src/motif/nsXtEventHandler.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef __nsXtEventHandler_h -#define __nsXtEventHandler_h - -#include - -class nsIWidget; -class nsIMenuItem; - -void nsXtWidget_KeyPressMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b); -void nsXtWidget_KeyReleaseMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b); -void nsXtWidget_ExposureMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b); -void nsXtWidget_ButtonPressMask_EventHandler(Widget w,XtPointer p, XEvent * event, Boolean * b); -void nsXtWidget_ButtonReleaseMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b); -void nsXtWidget_ButtonMotionMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b); -void nsXtWidget_MotionMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b); -void nsXtWidget_EnterMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b); -void nsXtWidget_LeaveMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b); -//---------------------------------------------------- - -void nsXtWidget_FSBCancel_Callback(Widget w, XtPointer p, XtPointer call_data); -void nsXtWidget_FSBOk_Callback(Widget w, XtPointer p, XtPointer call_data); - -//---------------------------------------------------- -void nsXtWidget_Focus_Callback(Widget w, XtPointer p, XtPointer call_data); -void nsXtWidget_Scrollbar_Callback(Widget w, XtPointer p, XtPointer call_data); -void nsXtWidget_Toggle_ArmCallback(Widget w, XtPointer p, XtPointer call_data); -void nsXtWidget_Toggle_DisArmCallback(Widget w, XtPointer p, XtPointer call_data); -void nsXtWidget_RadioButton_ArmCallback(Widget w, XtPointer p, XtPointer call_data); -void nsXtWidget_RadioButton_DisArmCallback(Widget w, XtPointer p, XtPointer call_data); - -void nsXtWidget_Text_Callback(Widget w, XtPointer p, XtPointer call_data); -void nsXtWidget_Resize_Callback(Widget w, XtPointer p, XtPointer call_data); -void nsXtWidget_Expose_Callback(Widget w, XtPointer p, XtPointer call_data); - -void nsXtWidget_Refresh_Callback(XtPointer call_data); - -void nsXtWidget_ResetResize_Callback(XtPointer call_data); - -void nsXtWidget_Menu_Callback(Widget w, XtPointer p, XtPointer call_data); - -#endif // __nsXtEventHandler.h diff --git a/widget/src/motif/nsXtManageWidget.c b/widget/src/motif/nsXtManageWidget.c deleted file mode 100644 index fc1621d53004..000000000000 --- a/widget/src/motif/nsXtManageWidget.c +++ /dev/null @@ -1,180 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - new_manage.c --- defines a subclass of XmManager - Created: Eric Bina , 17-Aug-94. - - Excerpts from the X Toolkit Intrinsics Programming Manual - O'Reilly: - - "Writing a general-purpose composite widget is not a trivial task - and should only be done when other options fail." - "A truly general-purpose composite widget is a large, complex piece - of software. You should leave this programming to the widget writers - who write commercial widget sets, and concentrate on things that are - more important in your application." - */ - -#include -#include -#include "nsXtManageWidget.h" -#include "nsXtManageWidgetP.h" - -static XtGeometryResult -GeometryManager(Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply); - -static void -ChangeManaged(Widget w); - - -extern void nsWindow_ResizeWidget(Widget w); - - -NewManageClassRec newManageClassRec = -{ - { -/* core_class fields */ - /* superclass */ (WidgetClass) &xmManagerClassRec, - /* class_name */ "NewManage", - /* widget_size */ sizeof(NewManageRec), - /* class_initialize */ NULL, - /* class_partinit */ NULL /* ClassPartInitialize */, - /* class_inited */ FALSE, - /* initialize */ NULL /* Initialize */, - /* Init hook */ NULL, - /* realize */ XtInheritRealize /* Realize */, - /* actions */ NULL, - /* num_actions */ 0, - /* resources */ NULL /* resources */, - /* num_resources */ 0 /* XtNumber(resources) */, - /* xrm_class */ NULLQUARK, - /* compress_motion */ TRUE, - /* compress_exposure */ TRUE, - /* compress_enterleave*/ TRUE, - /* visible_interest */ FALSE, - /* destroy */ NULL, - /* resize */ nsWindow_ResizeWidget, - /* expose */ XtInheritExpose /* (XtExposeProc) Redisplay */, - /* set_values */ NULL /* (XtSetValuesFunc )SetValues */, - /* set values hook */ NULL, - /* set values almost */ XtInheritSetValuesAlmost, - /* get values hook */ NULL, - /* accept_focus */ NULL, - /* Version */ XtVersion, - /* PRIVATE cb list */ NULL, - /* tm_table */ XtInheritTranslations, - /* query_geometry */ NULL /* QueryProc */, - /* display_accelerator*/ NULL, - /* extension */ NULL, - }, - { -/* composite_class fields */ - /* geometry_manager */ GeometryManager /*(XtGeometryHandler )GeometryManager*/, - /* change_managed */ ChangeManaged /*(XtWidgetProc) ChangeManaged*/, - /* insert_child */ XtInheritInsertChild /*(XtArgsProc) InsertChild*/, - /* delete_child */ XtInheritDeleteChild, - /* Extension */ NULL, - },{ -/* Constraint class Init */ - NULL, - 0, - 0, - NULL, - NULL, - NULL, - NULL - - }, -/* Manager Class */ - { - XmInheritTranslations/*ScrolledWindowXlations*/, /* translations */ - NULL /*get_resources*/, /* get resources */ - 0 /*XtNumber(get_resources)*/, /* num get_resources */ - NULL, /* get_cont_resources */ - 0, /* num_get_cont_resources */ - XmInheritParentProcess, /* parent_process */ - NULL, /* extension */ - }, - - { -/* NewManage class - none */ - /* mumble */ 0 - } -}; - - -WidgetClass newManageClass = (WidgetClass)&newManageClassRec; - - -static XtGeometryResult -GeometryManager(Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply) -{ - if (request->request_mode & XtCWQueryOnly) - { - return(XtGeometryYes); - } - - if (request->request_mode & CWX) - { - XtX(w) = request->x; - } - if (request->request_mode & CWY) - { - XtY(w) = request->y; - } - if (request->request_mode & CWWidth) - { - XtWidth(w) = request->width; - } - if (request->request_mode & CWHeight) - { - XtHeight(w) = request->height; - } - if (request->request_mode & CWBorderWidth) - { - XtBorderWidth(w) = request->border_width; - } - - return(XtGeometryYes); -} - - -static void -ChangeManaged(Widget w) -{ - return; -} diff --git a/widget/src/motif/nsXtManageWidget.h b/widget/src/motif/nsXtManageWidget.h deleted file mode 100644 index 5978a1b58871..000000000000 --- a/widget/src/motif/nsXtManageWidget.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - nsXtManageWidget.h --- defines a subclass of XmManager - Lifted from xfe code 9/10/98. Modified to support resize. - */ - -#ifndef _FE_NEWMANAGE_H_ -#define _FE_NEWMANAGE_H_ - -#include - -extern WidgetClass newManageClass; -typedef struct _NewManageClassRec *NewManageClass; -typedef struct _NewManageRec *NewManage; - -#endif /* _FE_NEWMANAGE_H_ */ diff --git a/widget/src/motif/nsXtManageWidgetP.h b/widget/src/motif/nsXtManageWidgetP.h deleted file mode 100644 index fabb399ff317..000000000000 --- a/widget/src/motif/nsXtManageWidgetP.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - nsXtManageWidgetP.h --- defines a subclass of XmScrolledWindow - */ - - -#ifndef _nsXtManageWidth_h_ -#define _nsXtManageWidth_h_ - -#include "nsXtManageWidget.h" -#include - -typedef struct -{ - int frogs; -} NewManageClassPart; - -typedef struct _NewManageClassRec -{ - CoreClassPart core_class; - CompositeClassPart composite_class; - ConstraintClassPart constraint_class; - XmManagerClassPart manager_class; - NewManageClassPart newManage_class; -} NewManageClassRec; - -extern NewManageClassRec newManageClassRec; - -typedef struct -{ - void *why; - XtCallbackList input_callback; -} NewManagePart; - -typedef struct _NewManageRec -{ - CorePart core; - CompositePart composite; - ConstraintPart constraint; - XmManagerPart manager; - NewManagePart newManage; -} NewManageRec; - -#endif /* _nsXtManageWidth_h_ */ diff --git a/widget/timer/src/unix/motif/.cvsignore b/widget/timer/src/unix/motif/.cvsignore deleted file mode 100644 index f3c7a7c5da68..000000000000 --- a/widget/timer/src/unix/motif/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile diff --git a/widget/timer/src/unix/motif/Makefile.in b/widget/timer/src/unix/motif/Makefile.in deleted file mode 100644 index 9463fb99fc58..000000000000 --- a/widget/timer/src/unix/motif/Makefile.in +++ /dev/null @@ -1,52 +0,0 @@ -# -# The contents of this file are subject to the Netscape Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/NPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# - -DEPTH = ../../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -LIBRARY_NAME = timer_$(TIMER_SUFFIX) - -CPPSRCS = nsTimerMotif.cpp - -ifndef MOZ_MONOLITHIC_TOOLKIT -EXPORT_LIBRARY = 1 -TIMER_SUFFIX = motif -IS_COMPONENT = 1 -CPPSRCS += nsTimerMotifFactory.cpp -EXTRA_DSO_LDOPTS = $(MOZ_MOTIF_LDFLAGS) -else -TIMER_SUFFIX = s -FORCE_STATIC_LIB = 1 -endif - -include $(topsrcdir)/config/rules.mk - -ifndef MOZ_MONOLITHIC_TOOLKIT -INCLUDES += $(MOZ_MOTIF_CFLAGS) -I$(srcdir)/.. -else -CXXFLAGS += $(TK_CFLAGS) -INCLUDES += $(TK_CFLAGS) -I$(srcdir)/.. -endif - diff --git a/widget/timer/src/unix/motif/nsTimerMotif.cpp b/widget/timer/src/unix/motif/nsTimerMotif.cpp deleted file mode 100644 index 69a728f0b657..000000000000 --- a/widget/timer/src/unix/motif/nsTimerMotif.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsTimerMotif.h" - -// #include "nsITimerCallback.h" -// #include "nsCRT.h" -// #include "prlog.h" -// #include -// #include -// #include - -#include "nsIComponentManager.h" -#include "nsIMotifAppContextService.h" - -extern void nsTimerExpired(XtPointer aCallData); - -void nsTimerMotif::FireTimeout() -{ - if (mFunc != NULL) { - (*mFunc)(this, mClosure); - } - else if (mCallback != NULL) { - mCallback->Notify(this); // Fire the timer - } - -// Always repeating here - -// if (mRepeat) -// mTimerId = XtAppAddTimeOut(gAppContext, GetDelay(),(XtTimerCallbackProc)nsTimerExpired, this); -} - -nsTimerMotif::nsTimerMotif() -{ - NS_INIT_REFCNT(); - mFunc = NULL; - mCallback = NULL; - mNext = NULL; - mTimerId = 0; - mDelay = 0; - mClosure = NULL; - mAppContext = nsnull; -} - -nsTimerMotif::~nsTimerMotif() -{ -} - -static NS_DEFINE_CID(kCMotifAppContextServiceCID, NS_MOTIF_APP_CONTEXT_SERVICE_CID); - -nsresult -nsTimerMotif::Init(nsTimerCallbackFunc aFunc, - void *aClosure, - PRUint32 aDelay, - PRUint32 aPriority, - PRUint32 aType - ) -{ - mFunc = aFunc; - mClosure = aClosure; - // mRepeat = aRepeat; - - EnsureAppContext(); - - mTimerId = XtAppAddTimeOut(mAppContext, - aDelay, - (XtTimerCallbackProc)nsTimerExpired, this); - - return Init(aDelay); -} - -nsresult -nsTimerMotif::Init(nsITimerCallback *aCallback, - PRUint32 aDelay, - PRUint32 aPriority, - PRUint32 aType - ) -{ - mCallback = aCallback; - // mRepeat = aRepeat; - - EnsureAppContext(); - - mTimerId = XtAppAddTimeOut(mAppContext, - aDelay, - (XtTimerCallbackProc)nsTimerExpired, - this); - - return Init(aDelay); -} - -nsresult -nsTimerMotif::Init(PRUint32 aDelay) -{ - EnsureAppContext(); - - mDelay = aDelay; - NS_ADDREF(this); - - return NS_OK; -} - -NS_IMPL_ISUPPORTS1(nsTimerMotif, nsITimer) - - -void -nsTimerMotif::Cancel() -{ - XtRemoveTimeOut(mTimerId); -} - -void nsTimerExpired(XtPointer aCallData) -{ - nsTimerMotif* timer = (nsTimerMotif *)aCallData; - timer->FireTimeout(); -} - -nsresult -nsTimerMotif::EnsureAppContext() -{ - static XtAppContext gsAppContext = nsnull; - - mAppContext = nsnull; - - if (nsnull == gsAppContext) - { - nsresult rv; - nsIMotifAppContextService * ac_service = nsnull; - - rv = nsComponentManager::CreateInstance(kCMotifAppContextServiceCID, - nsnull, - NS_GET_IID(nsIMotifAppContextService), - (void **)& ac_service); - - NS_ASSERTION(rv == NS_OK,"Cannot obtain app context service."); - - if (ac_service) - { - printf("nsTimerMotif::EnsureAppContext() ac_service = %p\n",ac_service); - - nsresult rv2 = ac_service->GetAppContext(&gsAppContext); - - NS_ASSERTION(rv2 == NS_OK,"Cannot get the app context."); - - NS_ASSERTION(nsnull != gsAppContext,"Global app context is null."); - - NS_RELEASE(ac_service); - - printf("nsTimerMotif::EnsureAppContext() gsAppContext = %p\n",gsAppContext); - } - } - - mAppContext = gsAppContext; - - return NS_OK; -} - -#ifdef MOZ_MONOLITHIC_TOOLKIT -nsresult NS_NewTimer(nsITimer** aInstancePtrResult) -{ - NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); - if (nsnull == aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; - } - - nsTimerMotif *timer = new nsTimerMotif(); - if (nsnull == timer) { - return NS_ERROR_OUT_OF_MEMORY; - } - - return CallQueryInterface(timer, aInstancePtrResult); -} -#endif /* MOZ_MONOLITHIC_TOOLKIT */ diff --git a/widget/timer/src/unix/motif/nsTimerMotif.h b/widget/timer/src/unix/motif/nsTimerMotif.h deleted file mode 100644 index 7db0add2062e..000000000000 --- a/widget/timer/src/unix/motif/nsTimerMotif.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef __nsTimerMotif_h -#define __nsTimerMotif_h - -#include "nsITimer.h" -#include "nsITimerCallback.h" - -#include - -/* - * Implementation of timers using Xt timer facility - */ -class nsTimerMotif : public nsITimer -{ -public: - nsTimerMotif(); - virtual ~nsTimerMotif(); - - virtual nsresult Init(nsTimerCallbackFunc aFunc, - void *aClosure, - PRUint32 aDelay, - PRUint32 aPriority = NS_PRIORITY_NORMAL, - PRUint32 aType = NS_TYPE_ONE_SHOT - ); - - virtual nsresult Init(nsITimerCallback *aCallback, - PRUint32 aDelay, - PRUint32 aPriority = NS_PRIORITY_NORMAL, - PRUint32 aType = NS_TYPE_ONE_SHOT - ); - - NS_DECL_ISUPPORTS - - virtual void Cancel(); - - virtual PRUint32 GetDelay() { return mDelay; } - virtual void SetDelay(PRUint32 aDelay) { mDelay=aDelay; }; - - virtual PRUint32 GetPriority() {} - virtual void SetPriority(PRUint32 aPriority) {} - - virtual PRUint32 GetType() {} - virtual void SetType(PRUint32 aType) {} - - virtual void* GetClosure() { return mClosure; } - - void FireTimeout(); - -private: - nsresult Init(PRUint32 aDelay); - nsresult EnsureAppContext(); - - PRUint32 mDelay; - nsTimerCallbackFunc mFunc; - void * mClosure; - nsITimerCallback * mCallback; - // PRBool mRepeat; - nsTimerMotif * mNext; - XtIntervalId mTimerId; - XtAppContext mAppContext; -}; - -#endif // __nsTimerMotif_h diff --git a/widget/timer/src/unix/motif/nsTimerMotifFactory.cpp b/widget/timer/src/unix/motif/nsTimerMotifFactory.cpp deleted file mode 100644 index 2f28841b7375..000000000000 --- a/widget/timer/src/unix/motif/nsTimerMotifFactory.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - - -#include "nsTimerMotif.h" - -#include "nsUnixTimerCIID.h" - -#include "nsIFactory.h" -#include "nsIComponentManager.h" -#include "nsIServiceManager.h" -#include "nsCOMPtr.h" - -static NS_DEFINE_CID(kCTimerMotif, NS_TIMER_MOTIF_CID); -static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); - -class nsTimerMotifFactory : public nsIFactory -{ -public: - NS_DECL_ISUPPORTS - - NS_IMETHOD CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult); - - NS_IMETHOD LockFactory(PRBool aLock); - - nsTimerMotifFactory(const nsCID &aClass); - virtual ~nsTimerMotifFactory(); - -private: - nsCID mClassID; - -}; - -nsTimerMotifFactory::nsTimerMotifFactory(const nsCID &aClass) : - mRefCnt(0), - mClassID(aClass) -{ -} - -nsTimerMotifFactory::~nsTimerMotifFactory() -{ -} - -NS_IMPL_ISUPPORTS1(nsTimerMotifFactory, nsIFactory) - - -NS_IMETHODIMP -nsTimerMotifFactory::CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult) -{ - if (aResult == nsnull) - return NS_ERROR_NULL_POINTER; - - *aResult = nsnull; - - nsISupports *inst = nsnull; - - if (mClassID.Equals(kCTimerMotif)) - { - inst = (nsISupports *)(nsTimerMotif *) new nsTimerMotif(); - } - - if (inst == nsnull) - return NS_ERROR_OUT_OF_MEMORY; - - nsresult rv = inst->QueryInterface(aIID, aResult); - - if (rv != NS_OK) - delete inst; - - return rv; -} - -nsresult nsTimerMotifFactory::LockFactory(PRBool aLock) -{ - // Not implemented in simplest case. - return NS_OK; -} - -nsresult -NSGetFactory(nsISupports* servMgr, - const nsCID &aClass, - const char *aClassName, - const char *aContractID, - nsIFactory **aFactory) -{ - if (nsnull == aFactory) { - return NS_ERROR_NULL_POINTER; - } - - *aFactory = new nsTimerMotifFactory(aClass); - - if (nsnull == aFactory) { - return NS_ERROR_OUT_OF_MEMORY; - } - - return (*aFactory)->QueryInterface(NS_GET_IID(nsIFactory), (void**)aFactory); - -} - -PRBool -NSCanUnload(nsISupports* aServMgr) -{ - return PR_FALSE; -} - -nsresult -NSRegisterSelf(nsISupports* aServMgr, const char *fullpath) -{ - nsresult rv; - -#ifdef NS_DEBUG - printf("*** Registering MOTIF timer\n"); -#endif - - nsCOMPtr - serviceManager(do_QueryInterface(aServMgr, &rv)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr compMgr = - do_GetService(kComponentManagerCID, &rv); - if (NS_FAILED(rv)) return rv; - - rv = compMgr->RegisterComponent(kCTimerMotif, - "MOTIF timer", - "@mozilla.org/timer/unix/motif;1", - fullpath, - PR_TRUE, - PR_TRUE); - - return rv; -} - -nsresult -NSUnregisterSelf(nsISupports* aServMgr, const char *fullpath) -{ - - nsresult rv; - nsCOMPtr - serviceManager(do_QueryInterface(aServMgr, &rv)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr compMgr = - do_GetService(kComponentManagerCID, &rv); - if (NS_FAILED(rv)) return rv; - - compMgr->UnregisterComponent(kCTimerMotif, fullpath); - - return NS_OK; -}