change some extern 'C' functions to static members of the XFE_Image

This commit is contained in:
slamm%netscape.com 1998-09-08 20:13:51 +00:00
parent 0dd1841934
commit 24f113d8e7
6 changed files with 138 additions and 127 deletions

View File

@ -59,6 +59,7 @@
#ifdef MOZ_MAIL_NEWS
#include "MNView.h" /* for MNView::getBiffState() */
#endif
#include "Image.h"
#include "xpassert.h"
#include "xpgetstr.h"
#include "prefapi.h"
@ -216,7 +217,9 @@ MenuSpec XFE_Frame::servertools_submenu_spec[] = {
};
MenuSpec XFE_Frame::window_menu_spec[] = {
#ifdef MOZ_SELECTOR_BAR
{ xfeCmdOpenNavCenter, PUSHBUTTON },
#endif
{ xfeCmdOpenOrBringUpBrowser, PUSHBUTTON },
#ifdef MOZ_MAIL_NEWS
{ xfeCmdOpenInbox, PUSHBUTTON },
@ -1758,7 +1761,8 @@ XFE_Frame::initializeMWContext(EFrameType frame_type,
CONTEXT_DATA (m_context)->colormap = m_cmap;
// set image library Callback functions
CONTEXT_DATA (m_context)->DisplayPixmap = (DisplayPixmapPtr)fe_DisplayPixmap;
CONTEXT_DATA (m_context)->DisplayPixmap
= (DisplayPixmapPtr)fe_DisplayPixmap;
CONTEXT_DATA (m_context)->NewPixmap = (NewPixmapPtr)NULL;
CONTEXT_DATA (m_context)->ImageComplete = (ImageCompletePtr)NULL;

View File

@ -245,13 +245,6 @@ public:
virtual XP_Bool isOkToClose();
virtual void doClose();
// Handles image display in the new setup
/*
void displayImage(MWContext * context, IL_Pixmap * image,
IL_Pixmap * mask, PRInt32 x, PRInt32 y,
PRInt32 x_offset, PRInt32 y_offset,PRInt32 width, PRInt32 height);
*/
protected:
char* geometryPrefName;
// Next two routines return static data -- copy immediately

View File

@ -62,16 +62,16 @@ XFE_Image::XFE_Image(XFE_Component * frame, char * imageURL, fe_colormap * cmap,
// Set up the image library callbacks
CONTEXT_DATA(m_imageContext)->DisplayPixmap = (DisplayPixmapPtr)fe_DisplayPixmap;
CONTEXT_DATA(m_imageContext)->NewPixmap = (NewPixmapPtr)fe_NewPixmap;
CONTEXT_DATA(m_imageContext)->ImageComplete = (ImageCompletePtr)fe_ImageComplete;
CONTEXT_DATA(m_imageContext)->NewPixmap = (NewPixmapPtr)NewPixmap;
CONTEXT_DATA(m_imageContext)->ImageComplete = (ImageCompletePtr)ImageComplete;
/*
* Stolen from Frame.cpp.
*/
CONTEXT_DATA (m_imageContext)->colormap = cmap;
CONTEXT_WIDGET (m_imageContext) = baseWidget;
CONTEXT_DATA(m_imageContext)->drawing_area = baseWidget;
CONTEXT_WIDGET (m_imageContext) = baseWidget;
CONTEXT_DATA (m_imageContext)->drawing_area = baseWidget;
CONTEXT_DATA (m_imageContext)->colormap = cmap;
m_imageContext->funcs = fe_BuildDisplayFunctionTable();
m_imageContext->convertPixX = m_imageContext->convertPixY = 1;
@ -153,7 +153,7 @@ XFE_Image::~XFE_Image(void)
free(m_urlString);
// S'd I destroy the m_mask and m_image and the clientdata inside them?
// Should I destroy the m_mask and m_image and the clientdata inside them?
// Destroy the Image groupcontexts and observers
if (m_imageContext)
{
@ -233,16 +233,14 @@ XFE_Image::getImageHeight(void)
void
XFE_Image::loadImage(void)
{
if (cxtInitSucceeded)
NET_GetURL(NET_CreateURLStruct(m_urlString, NET_DONT_RELOAD), FO_CACHE_AND_PRESENT, m_imageContext, Image_GetUrlExitRoutine);
NET_GetURL(NET_CreateURLStruct(m_urlString, NET_DONT_RELOAD),
FO_CACHE_AND_PRESENT, m_imageContext,
getURLExit_cb);
}
extern "C"
{
void
Image_GetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext)
/*static*/ void
XFE_Image::getURLExit_cb(URL_Struct *pUrl, int iStatus, MWContext *pContext)
{
// Report any errors.
if(iStatus < 0 && pUrl->error_msg != NULL)
@ -252,7 +250,7 @@ Image_GetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext)
XP_FREE(pUrl);
}
};
@ -263,12 +261,13 @@ Image_GetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext)
// ImageLibrary Callbacks //
///////////////////////////////////////////////////////////////////////////
extern "C"
{
/* The XFE handle to the image library callback -IMGCB_DisplayPixmap */
void
fe_DisplayPixmap(MWContext * context, IL_Pixmap * image, IL_Pixmap * mask, PRInt32 x, PRInt32 y, PRInt32 x_offset, PRInt32 y_offset, PRInt32 width, PRInt32 height)
// The XFE handle to the image library callback -IMGCB_DisplayPixmap
extern "C" void
fe_DisplayPixmap(MWContext * context,
IL_Pixmap * image, IL_Pixmap * mask,
PRInt32 x, PRInt32 y,
PRInt32 x_offset, PRInt32 y_offset,
PRInt32 width, PRInt32 height)
{
XFE_Frame * frameHandle=(XFE_Frame *)NULL;
@ -286,8 +285,9 @@ fe_DisplayPixmap(MWContext * context, IL_Pixmap * image, IL_Pixmap * mask, PRInt
if (context->type != MWContextIcon)
{
/* Call the frame's displayImage method */
fe_DisplayImage(context, image, mask, x, y, x_offset, y_offset,
width, height);
XFE_Image::DisplayImage(context, image, mask,
x, y, x_offset, y_offset,
width, height);
}
else
{
@ -307,10 +307,9 @@ fe_DisplayPixmap(MWContext * context, IL_Pixmap * image, IL_Pixmap * mask, PRInt
/* The XFE handle to the image library callback _IMGCB_NewPixmap */
void
fe_NewPixmap(MWContext * context, IL_Pixmap * image, Boolean mask)
// The XFE handle to the image library callback _IMGCB_NewPixmap
/*static*/ void
XFE_Image::NewPixmap(MWContext * context, IL_Pixmap * image, Boolean mask)
{
XFE_Frame * frameHandle=(XFE_Frame *)NULL;
@ -345,9 +344,9 @@ fe_NewPixmap(MWContext * context, IL_Pixmap * image, Boolean mask)
} /* NewPixmap */
/* The XFE handle to the image library callback _IMGCB_ImageComplete */
void
fe_ImageComplete(MWContext * context, IL_Pixmap * image)
// The XFE handle to the image library callback _IMGCB_ImageComplete
/*static*/ void
XFE_Image::ImageComplete(MWContext * context, IL_Pixmap * image)
{
XFE_Frame * frameHandle=(XFE_Frame *)NULL;
/* Get the handle to the frame from the context */
@ -380,11 +379,13 @@ fe_ImageComplete(MWContext * context, IL_Pixmap * image)
} /* ImageComplete */
/* The actual XFE function that renders image on a HTML area */
void
fe_DisplayImage(MWContext * context, IL_Pixmap * image,
IL_Pixmap * mask, PRInt32 x, PRInt32 y,
PRInt32 x_offset, PRInt32 y_offset, PRInt32 width,PRInt32 height)
// The actual XFE function that renders image on a HTML area
/*static*/ void
XFE_Image::DisplayImage(MWContext * context,
IL_Pixmap * image, IL_Pixmap * mask,
PRInt32 x, PRInt32 y,
PRInt32 x_offset, PRInt32 y_offset,
PRInt32 width, PRInt32 height)
{
int32 img_x_offset, img_y_offset; /* Offset of image in drawable. */
@ -533,5 +534,4 @@ fe_DisplayImage(MWContext * context, IL_Pixmap * image,
} /* displayImage */
}; /* extern "C" */

View File

@ -28,47 +28,57 @@
#include "ViewGlue.h"
#include "xfe.h"
extern "C"
class XFE_Image
{
void fe_DisplayImage(MWContext * context, IL_Pixmap * image,
IL_Pixmap * mask,PRInt32 x,PRInt32 y,
PRInt32 x_offset, PRInt32 y_offset,
PRInt32 width, PRInt32 height);
void
Image_GetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext);
};
class XFE_Image{
public:
XFE_Image(XFE_Component * frame, char * imageUrl, fe_colormap *, Widget);
virtual ~XFE_Image();
virtual Pixmap getPixmap();
virtual Pixmap getMask();
virtual PRInt32 getImageWidth();
virtual PRInt32 getImageHeight();
virtual PRBool isImageLoaded();
virtual void loadImage();
virtual Pixmap getPixmap ();
virtual Pixmap getMask ();
virtual PRInt32 getImageWidth ();
virtual PRInt32 getImageHeight ();
virtual PRBool isImageLoaded ();
virtual void loadImage ();
static void getURLExit_cb (URL_Struct *pUrl, int iStatus,
MWContext *pContext);
static void DisplayImage (MWContext * context,
IL_Pixmap * image, IL_Pixmap * mask,
PRInt32 x, PRInt32 y,
PRInt32 x_offset, PRInt32 y_offset,
PRInt32 width, PRInt32 height);
static void NewPixmap (MWContext * context,
IL_Pixmap * image, Boolean mask);
static void ImageComplete (MWContext * context, IL_Pixmap * image);
protected:
MWContext * m_imageContext; // Special MWContext
fe_ContextData * fec; // FE specific data for MWContext
char * m_urlString; // Url string
IL_Pixmap * m_image; // The image
IL_Pixmap * m_mask; // The mask
Pixmap m_badImage; // Bad image to use if the image loading fails
PRInt32 imageWidth;
PRInt32 imageHeight;
XFE_Component * m_frame;
MWContext * m_imageContext; // Special MWContext
fe_ContextData * fec; // FE specific data for MWContext
char * m_urlString; // Url string
IL_Pixmap * m_image; // The image
IL_Pixmap * m_mask; // The mask
Pixmap m_badImage; // Image to use if the image loading fails
PRInt32 imageWidth;
PRInt32 imageHeight;
XFE_Component * m_frame;
Boolean badImage; // Indicates whether to use the bad bitmap
Boolean cxtInitSucceeded; // Indicates if MWcontext is initialized
Boolean completelyLoaded; // Indicates if image is completely loaded
Boolean badImage; // Indicates whether to use the bad bitmap
Boolean cxtInitSucceeded; // Indicates if MWcontext is initialized
Boolean completelyLoaded; // Indicates if image is completely loaded
};
/* This is still used by xfe.c */
extern "C" void fe_DisplayPixmap (MWContext * context,
IL_Pixmap * image, IL_Pixmap * mask,
PRInt32 x, PRInt32 y,
PRInt32 x_offset, PRInt32 y_offset,
PRInt32 width, PRInt32 height);
#endif /* _xfe_image_h */

View File

@ -31,6 +31,7 @@
#define D(x)
#endif
#if 0
extern "C"
{
void DisplayPixmap(MWContext *, IL_Pixmap *, IL_Pixmap * , PRInt32, PRInt32, PRInt32, PRInt32, PRInt32, PRInt32);
@ -38,7 +39,7 @@ void NewPixmap(MWContext *, IL_Pixmap * image, PRBool mask);
void ImageComplete(MWContext *, IL_Pixmap * image);
void fe_load_default_font(MWContext *context);
};
#endif
int XFE_RDFImage::refCount = 0;
int XFE_RDFImage::m_numRDFImagesLoaded = 0;
@ -233,10 +234,10 @@ XFE_RDFImage::getImageHeight(void)
void
XFE_RDFImage::loadImage(void)
{
if (cxtInitSucceeded)
NET_GetURL(NET_CreateURLStruct(m_urlString, NET_DONT_RELOAD), FO_CACHE_AND_PRESENT, m_imageContext, Image_GetUrlExitRoutine);
NET_GetURL(NET_CreateURLStruct(m_urlString, NET_DONT_RELOAD),
FO_CACHE_AND_PRESENT, m_imageContext,
XFE_Image::getURLExit_cb);
}

View File

@ -28,78 +28,81 @@
#include "View.h"
#include "Image.h"
extern "C" {
typedef void (* completeCallbackPtr)(void * client_data);
void Icon_GetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext) ;
};
typedef struct _RDFImageList {
void * requestedObj;
class XFE_RDFImage * obj;
Widget widget;
char * imageURL;
PRBool isSpaceAvailable;
void * requestedObj;
class XFE_RDFImage * obj;
Widget widget;
char * imageURL;
PRBool isSpaceAvailable;
struct _RDFImageList * prev;
struct _RDFImageList * next;
} RDFImageList;
typedef struct _callbackClientData {
Widget widget;
Pixmap image;
Pixmap mask;
Widget widget;
Pixmap image;
Pixmap mask;
PRInt32 width;
PRInt32 height;
}callbackClientData;
} callbackClientData;
//////////////////////////////////////////////////////////////////////////
class XFE_RDFImage : XFE_Image
class XFE_RDFImage : public XFE_Image
{
public:
XFE_RDFImage(XFE_Component * frame, void * requestedObj, char * imageUrl, fe_colormap *, Widget);
XFE_RDFImage(XFE_Component * frame, void * requestedObj,
char * imageUrl, fe_colormap *, Widget);
~XFE_RDFImage();
void setCompleteCallback(completeCallbackPtr callback, void * callbackData);
void RDFDisplayPixmap(IL_Pixmap * image, IL_Pixmap * mask, PRInt32 width, PRInt32 height);
void RDFNewPixmap(IL_Pixmap * image, PRBool isMask);
void RDFImageComplete(IL_Pixmap * image);
void addListener(void * requestedObj, Widget w, char * imageURL);
PRBool isrequestorAlive(Widget w);
virtual Pixmap getPixmap();
virtual Pixmap getMask();
virtual PRInt32 getImageWidth();
virtual PRInt32 getImageHeight();
virtual void loadImage();
virtual PRBool isImageLoaded();
static class XFE_RDFImage * isImageAvailable(char * imageURL);
static void removeListener(void * obj);
static void removeListener(Widget w);
static XFE_RDFImage* getRDFImageObject(Widget);
void setCompleteCallback (completeCallbackPtr callback,
void * callbackData);
void RDFDisplayPixmap (IL_Pixmap * image, IL_Pixmap * mask,
PRInt32 width, PRInt32 height);
void RDFNewPixmap (IL_Pixmap * image, PRBool isMask);
void RDFImageComplete (IL_Pixmap * image);
void addListener (void * requestedObj, Widget w,
char * imageURL);
PRBool isrequestorAlive (Widget w);
virtual Pixmap getPixmap ();
virtual Pixmap getMask ();
virtual PRInt32 getImageWidth ();
virtual PRInt32 getImageHeight ();
virtual void loadImage ();
virtual PRBool isImageLoaded ();
static XFE_RDFImage * isImageAvailable (char * imageURL);
static void removeListener (void * obj);
static void removeListener (Widget w);
static XFE_RDFImage * getRDFImageObject (Widget);
private:
PRBool frameLoaded; // Indicates if frame is loaded
int pairCount; // Specifies whether pixmap and mask are ready
static int refCount; // Count of # of images loaded
static int m_numRDFImagesLoaded; // # of images in the cache
static RDFImageList * RDFImagesCache; // Images cache
static unsigned int MaxRdfImages; // Max # of images the cache can hold
static unsigned int ImageListIncrSize; // cache size increment.
static void removeListener(RDFImageList *);
static void imageCacheInitialize();
completeCallbackPtr completeCallback; // Callback to call after complete image has been obtained.
PRBool frameLoaded; // Indicates if frame is loaded
int pairCount; // Specifies whether pixmap and mask are ready
static int refCount; // Count of # of images loaded
static int m_numRDFImagesLoaded; // # of images in the cache
static RDFImageList * RDFImagesCache; // Images cache
static unsigned int MaxRdfImages; // Max # of images the cache can hold
static unsigned int ImageListIncrSize; // cache size increment.
static void removeListener (RDFImageList *);
static void imageCacheInitialize ();
// Callback to call after complete image has been obtained.
completeCallbackPtr completeCallback;
void * callbackData;
};
#endif /* _xfe_rdfimage_h */