mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
parent
7ee6ab59a7
commit
566cf2aa54
@ -1 +0,0 @@
|
||||
Makefile
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
@ -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 <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
#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___ */
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<nsIAtom> 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__
|
@ -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);
|
||||
}
|
@ -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;y<mHeight;y++)
|
||||
{
|
||||
cursrc = mImageBits+(y*mOriginalRowBytes);
|
||||
curdest =tempbuffer+(y*mRowBytes);
|
||||
for(x=0;x<mOriginalRowBytes;x++)
|
||||
{
|
||||
*curdest = mColorMap->Index[(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;y<mHeight;y++)
|
||||
{
|
||||
cursrc = mImageBits+(y*mOriginalRowBytes);
|
||||
cur16 = (PRUint16*) (tempbuffer+(y*mRowBytes));
|
||||
|
||||
for(x=0;x<mOriginalRowBytes;x++)
|
||||
{
|
||||
blue = mColorMap->Index[(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;
|
||||
}
|
@ -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___
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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___
|
File diff suppressed because it is too large
Load Diff
@ -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 <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
#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___
|
@ -1,2 +0,0 @@
|
||||
Makefile
|
||||
embed_xlib_into_motif
|
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
@ -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 <Xm/Xm.h>
|
||||
|
||||
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__ */
|
@ -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 <Xm/ManagerP.h>
|
||||
|
||||
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__ */
|
@ -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
|
||||
|
@ -1,271 +0,0 @@
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#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;
|
||||
}
|
@ -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"
|
||||
|
@ -1 +0,0 @@
|
||||
Makefile
|
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
@ -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 <X11/IntrinsicP.h>
|
||||
|
||||
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__ */
|
@ -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 <X11/IntrinsicP.h>
|
||||
|
||||
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__ */
|
@ -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)
|
||||
|
@ -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 <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
// XXX Milind:
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <error.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <X11/StringDefs.h>
|
||||
|
||||
#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();
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -1 +0,0 @@
|
||||
Makefile
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
@ -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 <Xm/CascadeBG.h>
|
||||
#include <Xm/PushBG.h>
|
||||
#include <Xm/SeparatoG.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include "resources.h"
|
||||
#include "nsMotifMenu.h"
|
||||
#include "nsError.h" // For NS_ERROR_OUT_OF_MEMORY.
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
//==============================================================
|
||||
typedef struct _callBackInfo {
|
||||
MenuCallbackProc mCallback;
|
||||
PRUint32 mId;
|
||||
} MenuCallbackStruct;
|
||||
|
||||
//==============================================================
|
||||
void nsXtWidget_Menu_Callback(Widget w, XtPointer p, XtPointer call_data)
|
||||
{
|
||||
MenuCallbackStruct * cbs = (MenuCallbackStruct *)p;
|
||||
if (cbs != NULL) {
|
||||
if (cbs->mCallback != NULL) {
|
||||
(*cbs->mCallback)(cbs->mId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
Widget CreatePulldownMenu(Widget aParent,
|
||||
char * aMenuTitle,
|
||||
char aMenuMnemonic)
|
||||
{
|
||||
|
||||
Widget pullDown;
|
||||
Widget casBtn;
|
||||
XmString str;
|
||||
|
||||
pullDown = XmCreatePulldownMenu(aParent, "_pulldown", NULL, 0);
|
||||
|
||||
str = XmStringCreateLocalized(aMenuTitle);
|
||||
casBtn = XtVaCreateManagedWidget(aMenuTitle,
|
||||
xmCascadeButtonGadgetClass, aParent,
|
||||
XmNsubMenuId, pullDown,
|
||||
XmNlabelString, str,
|
||||
XmNmnemonic, aMenuMnemonic,
|
||||
NULL);
|
||||
XmStringFree(str);
|
||||
|
||||
return pullDown;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
Widget CreateMenuItem(Widget aParent,
|
||||
char * aTitle,
|
||||
long aID,
|
||||
MenuCallbackProc aCallback)
|
||||
{
|
||||
|
||||
Widget widget = XtVaCreateManagedWidget(aTitle, xmPushButtonGadgetClass,
|
||||
aParent,
|
||||
NULL);
|
||||
|
||||
MenuCallbackStruct * cbs = new MenuCallbackStruct();
|
||||
if (cbs) {
|
||||
cbs->mCallback = aCallback;
|
||||
cbs->mId = aID;
|
||||
}
|
||||
else cbs = (MenuCallbackStruct *)NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
XtAddCallback(widget, XmNactivateCallback, nsXtWidget_Menu_Callback, cbs);
|
||||
|
||||
return widget;
|
||||
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
Widget CreateSeparator(Widget aParent)
|
||||
{
|
||||
|
||||
Widget widget = XtVaCreateManagedWidget("__sep", xmSeparatorGadgetClass,
|
||||
aParent,
|
||||
NULL);
|
||||
return widget;
|
||||
}
|
||||
|
||||
typedef struct _menuBtns {
|
||||
char * title;
|
||||
char * mneu;
|
||||
long command;
|
||||
} MenuBtns;
|
||||
|
||||
//-----------------------------------------------------
|
||||
void AddMenuItems(Widget aParent,
|
||||
MenuBtns * aBtns,
|
||||
MenuCallbackProc aCallback)
|
||||
{
|
||||
int i = 0;
|
||||
while (aBtns[i].title != NULL) {
|
||||
if (!strcmp(aBtns[i].title, "separator")) {
|
||||
CreateSeparator(aParent);
|
||||
} else {
|
||||
CreateMenuItem(aParent, aBtns[i].title, aBtns[i].command, aCallback);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
void CreateViewerMenus(Widget aParent, MenuCallbackProc aCallback)
|
||||
{
|
||||
MenuBtns editBtns[] = {
|
||||
{"Cut", "T", VIEWER_EDIT_CUT},
|
||||
{"Copy", "C", VIEWER_EDIT_COPY},
|
||||
{"Paste", "P", VIEWER_EDIT_PASTE},
|
||||
{"separator", NULL, 0},
|
||||
{"Select All", "A", VIEWER_EDIT_SELECTALL},
|
||||
{"separator", NULL, 0},
|
||||
{"Find in Page", "F", VIEWER_EDIT_FINDINPAGE},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
MenuBtns debugBtns[] = {
|
||||
{"Visual Debugging", "V", VIEWER_VISUAL_DEBUGGING},
|
||||
{"Reflow Test", "R", VIEWER_REFLOW_TEST},
|
||||
{"separator", NULL, 0},
|
||||
{"Dump Content", "C", VIEWER_DUMP_CONTENT},
|
||||
{"Dump Frames", "F", VIEWER_DUMP_FRAMES},
|
||||
{"Dump Views", "V", VIEWER_DUMP_VIEWS},
|
||||
{"separator", NULL, 0},
|
||||
{"Dump Style Sheets", "S", VIEWER_DUMP_STYLE_SHEETS},
|
||||
{"Dump Style Contexts", "T", VIEWER_DUMP_STYLE_CONTEXTS},
|
||||
{"separator", NULL, 0},
|
||||
{"Show Content Size", "z", VIEWER_SHOW_CONTENT_SIZE},
|
||||
{"Show Frame Size", "a", VIEWER_SHOW_FRAME_SIZE},
|
||||
{"Show Style Size", "y", VIEWER_SHOW_STYLE_SIZE},
|
||||
{"separator", NULL, 0},
|
||||
{"Debug Save", "v", VIEWER_DEBUGSAVE},
|
||||
{"Debug Toggle Selection", "q", VIEWER_TOGGLE_SELECTION},
|
||||
{"separator", NULL, 0},
|
||||
{"Debug Robot", "R", VIEWER_DEBUGROBOT},
|
||||
{"separator", NULL, 0},
|
||||
{"Show Content Quality", ".", VIEWER_SHOW_CONTENT_QUALITY},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
Widget menuBar;
|
||||
Widget fileMenu;
|
||||
Widget debugMenu;
|
||||
Widget menu;
|
||||
|
||||
menuBar = XmCreateMenuBar(aParent, "menubar", NULL, 0);
|
||||
|
||||
fileMenu = CreatePulldownMenu(menuBar, "File", 'F');
|
||||
CreateMenuItem(fileMenu, "New Window", VIEWER_WINDOW_OPEN, aCallback);
|
||||
CreateMenuItem(fileMenu, "Open...", VIEWER_FILE_OPEN, aCallback);
|
||||
|
||||
menu = CreatePulldownMenu(fileMenu, "Samples", 'S');
|
||||
CreateMenuItem(menu, "demo #0", VIEWER_DEMO0, aCallback);
|
||||
CreateMenuItem(menu, "demo #1", VIEWER_DEMO1, aCallback);
|
||||
CreateMenuItem(menu, "demo #2", VIEWER_DEMO2, aCallback);
|
||||
CreateMenuItem(menu, "demo #3", VIEWER_DEMO3, aCallback);
|
||||
CreateMenuItem(menu, "demo #4", VIEWER_DEMO4, aCallback);
|
||||
CreateMenuItem(menu, "demo #5", VIEWER_DEMO5, aCallback);
|
||||
CreateMenuItem(menu, "demo #6", VIEWER_DEMO6, aCallback);
|
||||
CreateMenuItem(menu, "demo #7", VIEWER_DEMO7, aCallback);
|
||||
CreateMenuItem(menu, "demo #8", VIEWER_DEMO8, aCallback);
|
||||
CreateMenuItem(menu, "demo #9", VIEWER_DEMO9, aCallback);
|
||||
CreateMenuItem(menu, "demo #10", VIEWER_DEMO10, aCallback);
|
||||
CreateMenuItem(menu, "demo #11", VIEWER_DEMO11, aCallback);
|
||||
CreateMenuItem(menu, "demo #12", VIEWER_DEMO12, aCallback);
|
||||
|
||||
CreateMenuItem(fileMenu, "Top 100 Sites", VIEWER_TOP100, aCallback);
|
||||
|
||||
menu = CreatePulldownMenu(fileMenu, "Print Preview", 'P');
|
||||
CreateMenuItem(menu, "One Column", VIEWER_ONE_COLUMN, aCallback);
|
||||
CreateMenuItem(menu, "Two Column", VIEWER_TWO_COLUMN, aCallback);
|
||||
CreateMenuItem(menu, "Three Column", VIEWER_THREE_COLUMN, aCallback);
|
||||
|
||||
CreateMenuItem(fileMenu, "Exit", VIEWER_EXIT, aCallback);
|
||||
|
||||
menu = CreatePulldownMenu(menuBar, "Edit", 'E');
|
||||
AddMenuItems(menu, editBtns, aCallback);
|
||||
|
||||
debugMenu = CreatePulldownMenu(menuBar, "Debug", 'D');
|
||||
AddMenuItems(debugMenu, debugBtns, aCallback);
|
||||
|
||||
menu = CreatePulldownMenu(menuBar, "Tools", 'T');
|
||||
CreateMenuItem(menu, "Java Script Console", JS_CONSOLE, aCallback);
|
||||
CreateMenuItem(menu, "Editor Mode", EDITOR_MODE, aCallback);
|
||||
|
||||
XtManageChild(menuBar);
|
||||
|
||||
}
|
@ -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 <Xm/Xm.h>
|
||||
#include "nscore.h"
|
||||
|
||||
|
||||
typedef void (*MenuCallbackProc)(
|
||||
PRUint32
|
||||
);
|
||||
|
||||
void CreateViewerMenus(Widget aParent, MenuCallbackProc aCallback);
|
||||
|
||||
|
||||
#endif // _nsMotifMenu_h_
|
@ -1 +0,0 @@
|
||||
Makefile
|
@ -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)
|
||||
|
@ -1 +0,0 @@
|
||||
Makefile
|
@ -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
|
||||
|
@ -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 <X11/Intrinsic.h>
|
||||
|
||||
// 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__ */
|
@ -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 <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
@ -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;
|
||||
};
|
@ -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 <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#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<nsIServiceManager>
|
||||
serviceManager(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIComponentManager> 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<nsIServiceManager>
|
||||
serviceManager(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIComponentManager> compMgr =
|
||||
do_GetService(kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
compMgr->UnregisterComponent(kCMotifAppContextServiceCID, fullpath);
|
||||
|
||||
return NS_OK;
|
||||
}
|
@ -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 <pp@ludusdesign.com>
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#ifdef LINUX
|
||||
#define DO_THE_EDITRES_THING
|
||||
#endif
|
||||
|
||||
#ifdef DO_THE_EDITRES_THING
|
||||
#include <X11/Xmu/Editres.h>
|
||||
#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<nsICmdLineService> 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<nsIEventQueueService> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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 <Xm/MainW.h>
|
||||
|
||||
/**
|
||||
* 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__
|
@ -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;
|
||||
}
|
@ -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
|
@ -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 <Xm/PushB.h>
|
||||
|
||||
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);
|
||||
|
||||
}
|
@ -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__
|
@ -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 <Xm/ToggleB.h>
|
||||
|
||||
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;
|
||||
}
|
@ -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__
|
@ -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 <Xm/Label.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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__
|
@ -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
|
@ -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<nsILookAndFeel> mXPLookAndFeel;
|
||||
};
|
||||
|
||||
#endif
|
@ -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 <pp@ludusdesign.com>
|
||||
*
|
||||
* 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 <Xm/CascadeBG.h>
|
||||
#include <Xm/SeparatoG.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
|
||||
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<nsIDOMNode> menuitemNode;
|
||||
menuNode->GetFirstChild(getter_AddRefs(menuitemNode));
|
||||
while (menuitemNode) {
|
||||
nsCOMPtr<nsIDOMElement> 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<nsIDOMNode> 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<nsIDOMElement> domElement = do_QueryInterface(mDOMNode);
|
||||
if (domElement)
|
||||
domElement->SetAttribute("open", "true");
|
||||
|
||||
|
||||
/// Now get the kids. Retrieve our menupopup child.
|
||||
nsCOMPtr<nsIDOMNode> menuPopupNode;
|
||||
mDOMNode->GetFirstChild(getter_AddRefs(menuPopupNode));
|
||||
while (menuPopupNode) {
|
||||
nsCOMPtr<nsIDOMElement> menuPopupElement(do_QueryInterface(menuPopupNode));
|
||||
if (menuPopupElement) {
|
||||
nsString menuPopupNodeType;
|
||||
menuPopupElement->GetNodeName(menuPopupNodeType);
|
||||
if (menuPopupNodeType.Equals("menupopup"))
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> oldMenuPopupNode(menuPopupNode);
|
||||
oldMenuPopupNode->GetNextSibling(getter_AddRefs(menuPopupNode));
|
||||
}
|
||||
|
||||
if (!menuPopupNode)
|
||||
return nsEventStatus_eIgnore;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> menuitemNode;
|
||||
menuPopupNode->GetFirstChild(getter_AddRefs(menuitemNode));
|
||||
|
||||
unsigned short menuIndex = 0;
|
||||
|
||||
while (menuitemNode) {
|
||||
nsCOMPtr<nsIDOMElement> 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<nsIDOMNode> 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<nsIDOMElement> domElement = do_QueryInterface(mDOMNode);
|
||||
if (domElement)
|
||||
domElement->RemoveAttribute("open");
|
||||
|
||||
mConstructCalled = PR_FALSE;
|
||||
RemoveAll();
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
@ -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__
|
@ -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 <pp@ludusdesign.com>
|
||||
*
|
||||
* 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 <Xm/RowColumn.h>
|
||||
|
||||
#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<nsIMenuListener> menuListener;
|
||||
pnsMenuBar->QueryInterface(NS_GET_IID(nsIMenuListener), getter_AddRefs(menuListener));
|
||||
aParentWindow->AddMenuListener(menuListener);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> menuNode;
|
||||
((nsIDOMNode*)menubarNode)->GetFirstChild(getter_AddRefs(menuNode));
|
||||
while (menuNode) {
|
||||
nsCOMPtr<nsIDOMElement> 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<nsIDOMNode> 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;
|
||||
}
|
@ -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__
|
@ -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 <pp@ludusdesign.com>
|
||||
*
|
||||
* 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 <Xm/CascadeBG.h>
|
||||
|
||||
#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;
|
||||
}
|
@ -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__
|
@ -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 <Xm/RowColumn.h>
|
||||
#include <Xm/SeparatoG.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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__
|
||||
|
@ -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 <Xm/ScrollBar.h>
|
||||
|
||||
#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;
|
||||
}
|
@ -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__
|
@ -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 <Xm/Text.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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 <Xm/Xm.h>
|
||||
|
||||
/**
|
||||
* 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__
|
@ -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 <Xm/Text.h>
|
||||
|
||||
#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;
|
||||
}
|
@ -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__
|
@ -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 <stdio.h>
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// 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);
|
||||
}
|
@ -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 <X11/Xlib.h>
|
||||
|
||||
/**
|
||||
* 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
|
@ -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 <dr@netscape.com>
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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 <Xm/Xm.h>
|
||||
|
||||
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__
|
@ -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 <Xm/Xm.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/keysymdef.h>
|
||||
#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);
|
||||
}
|
||||
}
|
@ -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 <Xm/Xm.h>
|
||||
|
||||
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
|
@ -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 <ebina@netscape.com>, 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#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;
|
||||
}
|
@ -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 <Xm/Xm.h>
|
||||
|
||||
extern WidgetClass newManageClass;
|
||||
typedef struct _NewManageClassRec *NewManageClass;
|
||||
typedef struct _NewManageRec *NewManage;
|
||||
|
||||
#endif /* _FE_NEWMANAGE_H_ */
|
@ -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 <Xm/ManagerP.h>
|
||||
|
||||
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_ */
|
@ -1 +0,0 @@
|
||||
Makefile
|
@ -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
|
||||
|
@ -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 <pp@ludusdesign.com>
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
// #include <limits.h>
|
||||
// #include <X11/Intrinsic.h>
|
||||
|
||||
#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 */
|
@ -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 <X11/Intrinsic.h>
|
||||
|
||||
/*
|
||||
* 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
|
@ -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 <pp@ludusdesign.com>
|
||||
*
|
||||
* 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<nsIServiceManager>
|
||||
serviceManager(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIComponentManager> 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<nsIServiceManager>
|
||||
serviceManager(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIComponentManager> compMgr =
|
||||
do_GetService(kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
compMgr->UnregisterComponent(kCTimerMotif, fullpath);
|
||||
|
||||
return NS_OK;
|
||||
}
|
Loading…
Reference in New Issue
Block a user