I've been trying to create a solution to the GUII pixmaps, that is the
long term independence, so as to allow a native Windows port for example.

The solution I came up with is to replace Pixmap with a class LyXImage
that is defined in src/frontends/support/ and a factory class
LyXImageFactory with a static method createLyXImage().

I've added a method to PainterBase and Painter, called image() which is
equivalent to pixmap() but gets a LyXImage const *, the Painter::image()
actually gets the Pixmap out of the LyXImage and calls Painter::pixmap(),
I didn't remove Painter::pixmap() to avoid a long and wide operation on
LyX.

My problem with the current scheme is that I use a LyXImage class as a
base class, it has no methods other than c-tor and virtual d-tor. The
LyXImage_X class has a getPixmap() class and a c-tor that takes a Pixmap.
Later on I'll have a LyXImage_X_Imlib that uses imlib (good for the gnome
port), other desktops can use their own image libraries and windows can
have its LyXImage_Windows class with a getBitmap method that returns
whatever is the native Pixmap of windows.

The problem (finally) is that in the Painter class I need to use a
dynamic_cast operator to get the class I want from LyXImage, currently
Painter does something like:
Pixmap bitmap = dynamic_cast<LyXImage_X const *>(image)->getPixmap();

Where image was declared as LyXImage const *.

gcc gives me a warning since I use dynamic cast without -frtti (actually
we use -fno-rtti when compiling our sources).

A possible solution for this is to have LyXImage the only base class with
a definition of the sort:

#ifdef WE_DO_X
        virtual Pixmap getImage() const;
#elif WE_DO_WINDOWS
        WINDOWS_PIXMAP getImage() const;
#endif

This way I solve the rtti problem, but it looks to me like a dirty hack.

What say you?

-- 
  Baruch Even

http://techst02.technion.ac.il/~sbaruch/   (My Site)
http://rpghost.com/jindor/                 (My brothers AD&D site)

" Learn to laugh ... it's the path to true love! " 
   - The Angel in the movie Michael


Reply via email to