2000-07-31 12:30:10 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* =================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
* Copyright 1995 Matthias Ettrich.
|
|
|
|
* Copyright 1995-2000 The LyX Team.
|
|
|
|
*
|
|
|
|
* This file Copyright 2000 Baruch Even
|
|
|
|
* ================================================= */
|
|
|
|
|
|
|
|
#ifndef GRAPHICSCACHEITEM_H
|
|
|
|
#define GRAPHICSCACHEITEM_H
|
|
|
|
|
2000-08-08 09:18:39 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2000-08-08 09:18:39 +00:00
|
|
|
#include XPM_H_LOCATION
|
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
#include "sigc++/signal_system.h"
|
|
|
|
#ifdef SIGC_CXX_NAMESPACES
|
|
|
|
using SigC::Signal0;
|
|
|
|
#endif
|
|
|
|
|
2000-08-10 13:15:05 +00:00
|
|
|
|
2000-08-08 09:18:39 +00:00
|
|
|
/* (Baruch Even 2000-08-05)
|
|
|
|
* This has a major drawback: it is only designed for X servers, no easy
|
|
|
|
* porting to non X-server based platform is offered right now, this is done
|
|
|
|
* in order to get a first version out of the door.
|
|
|
|
*
|
|
|
|
* Later versions should consider how to do this with more platform
|
|
|
|
* independence, this will probably involve changing the Painter class too.
|
|
|
|
*/
|
|
|
|
|
2000-08-10 13:15:05 +00:00
|
|
|
class GraphicsCacheItem_pimpl;
|
|
|
|
|
2000-08-08 09:18:39 +00:00
|
|
|
|
|
|
|
/// A GraphicsCache item holder.
|
2000-07-31 12:30:10 +00:00
|
|
|
class GraphicsCacheItem {
|
|
|
|
public:
|
2000-08-08 09:18:39 +00:00
|
|
|
/// d-tor, frees the image structures.
|
|
|
|
~GraphicsCacheItem();
|
2000-08-10 13:15:05 +00:00
|
|
|
/// copy c-tor.
|
|
|
|
GraphicsCacheItem(GraphicsCacheItem const &);
|
|
|
|
/// Assignment operator.
|
2000-09-14 17:53:12 +00:00
|
|
|
GraphicsCacheItem & operator=(GraphicsCacheItem const &);
|
2000-08-08 09:18:39 +00:00
|
|
|
|
|
|
|
/// Get the height of the image. Returns -1 on error.
|
2000-08-10 13:15:05 +00:00
|
|
|
int getHeight() const;
|
2000-08-08 09:18:39 +00:00
|
|
|
|
|
|
|
/// Get the width of the image. Returns -1 on error.
|
2000-08-10 13:15:05 +00:00
|
|
|
int getWidth() const;
|
2000-08-08 09:18:39 +00:00
|
|
|
|
|
|
|
/// Return a pixmap that can be displayed on X server.
|
2000-08-10 13:15:05 +00:00
|
|
|
Pixmap getImage() const;
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2000-08-08 09:18:39 +00:00
|
|
|
enum ImageStatus {
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2000-08-08 09:18:39 +00:00
|
|
|
Loading = 1,
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2000-08-08 09:18:39 +00:00
|
|
|
ErrorConverting,
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2000-08-08 09:18:39 +00:00
|
|
|
ErrorReading,
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2000-08-08 09:18:39 +00:00
|
|
|
Loaded
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Is the pixmap ready for display?
|
2000-08-10 13:15:05 +00:00
|
|
|
ImageStatus getImageStatus() const;
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
/** Get a notification when the image conversion is done.
|
|
|
|
used by an internal callback mechanism.
|
|
|
|
*/
|
2000-08-08 09:18:39 +00:00
|
|
|
void imageConverted(int retval);
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
private:
|
2000-08-14 15:31:16 +00:00
|
|
|
/// Private c-tor so that only GraphicsCache can create an instance.
|
|
|
|
GraphicsCacheItem();
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2000-08-10 13:15:05 +00:00
|
|
|
/// internal copy mechanism.
|
|
|
|
void copy(GraphicsCacheItem const &);
|
|
|
|
/// internal destroy mechanism.
|
|
|
|
void destroy();
|
|
|
|
|
2000-08-08 09:18:39 +00:00
|
|
|
/// Set the filename this item will be pointing too.
|
|
|
|
bool setFilename(string const & filename);
|
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
|
|
|
friend class GraphicsCache;
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2000-08-10 13:15:05 +00:00
|
|
|
GraphicsCacheItem_pimpl * pimpl;
|
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
/** The filename we refer too.
|
|
|
|
This is used when removing ourselves from the cache.
|
|
|
|
*/
|
2000-08-10 13:15:05 +00:00
|
|
|
string filename_;
|
2000-07-31 12:30:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|