Back to index

plt-scheme  4.2.1
Bitmap.h
Go to the documentation of this file.
00001 /*                                                      -*- C++ -*-
00002  *
00003  * Purpose: bitmap classes to implement pixmaps, icons, and cursors
00004  *
00005  * Authors: Markus Holzem and Julian Smart
00006  *
00007  * Copyright: (C) 2004-2009 PLT Scheme Inc.
00008  * Copyright: (C) 1995, AIAI, University of Edinburgh (Julian)
00009  * Copyright: (C) 1995, GNU (Markus)
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00024  * 02110-1301 USA.
00025  */
00026 
00027 #ifndef Bitmap_h
00028 #define Bitmap_h
00029 
00030 #ifdef __GNUG__
00031 #pragma interface
00032 #endif
00033 
00034 #ifdef Have_X_Types
00035 // easier access to X-Pixmap and X-Cursor
00036 #define GETPIXMAP(obj) (*((Pixmap*)((obj)->GetHandle())))
00037 #define GETCURSOR(obj) (*((Cursor*)((obj)->GetHandle())))
00038 #endif
00039 
00040 class wxBitmap_Xintern;
00041 class wxCursor_Xintern;
00042 
00043 class wxItem;
00044 class wxMemoryDC;
00045 
00046 class wxGLConfig;
00047 
00048 class wxBitmap : public wxObject { // bitmap representation
00049 public:
00050     wxBitmap(void);
00051     wxBitmap(char bits[], int width, int height);
00052     wxBitmap(int width, int height, Bool blackAndWhite = FALSE);
00053 #if USE_XPM
00054     wxBitmap(char **data, wxItem *anItem = NULL);
00055 #endif
00056     wxBitmap(char *name, long flags = wxBITMAP_DEFAULT, wxColour *bg = NULL);
00057     ~wxBitmap(void);
00058     // create and destroy
00059     Bool Create(int width, int height, int depth = -1);
00060     void Destroy(void);
00061     // get information about bitmap
00062     int  GetDepth(void);
00063     int  GetHeight(void);
00064     void GetHotSpot(int *x, int *y);
00065     int  GetWidth(void);
00066     // set and get colourmap
00067     wxColourMap* GetColourMap(void)
00068         { return cmap; }
00069     void SetColourMap(wxColourMap *new_cmap)
00070         { cmap = (new_cmap ? new_cmap : wxAPP_COLOURMAP); }
00071     // load and save bitmap
00072     Bool LoadFile(char *name, long flags = wxBITMAP_DEFAULT, wxColour *bg = NULL);
00073     Bool SaveFile(char *name, int type, int quality = 75, wxColourMap *cmap = NULL);
00074     // X representation
00075     virtual Bool  Ok(void) { return (Xbitmap != NULL); }
00076     virtual void* GetHandle(void); // return type Pixmap*
00077 #ifdef WX_USE_XRENDER
00078     long GetPicture(void); // return type Picture or XftDraw*
00079 #endif
00080 
00081   void SetMask(wxBitmap *bm) { loaded_mask = bm; }
00082   wxBitmap *GetMask() { return loaded_mask; }
00083 
00084   wxBitmap *GetMaskBit();
00085   void FreeMaskBit();
00086 
00087   void *GetLabelPixmap(Bool for_button = FALSE);
00088   void ReleaseLabel();
00089 
00090   void SetGLConfig(wxGLConfig *gl_cfg);
00091   wxGLConfig *GetGLConfig(void);
00092 
00093 public:
00094     wxBitmap_Xintern *Xbitmap;
00095     wxColourMap      *cmap;
00096     wxBitmap         *loaded_mask;
00097     wxBitmap         *maskBit;
00098     wxBitmap         *label_bm, *button_label_bm;
00099     wxGLConfig       *gl_cfg;
00100 
00101 public:
00102     int selectedIntoDC;
00103     wxMemoryDC *selectedTo;
00104 };
00105 
00106 class wxCursor : public wxBitmap { // cursor representation
00107 public:
00108     wxCursor(void);
00109     wxCursor(wxBitmap *bm, wxBitmap *mask, int x=0, int y=0);
00110     wxCursor(int cursor_type);
00111     ~wxCursor(void);
00112     // X representation
00113     virtual Bool  Ok(void) { return (Xcursor != NULL); }
00114     virtual void* GetHandle(void); // return type Cursor*, GetPixmap returns NULL!
00115 private:
00116     wxCursor_Xintern *Xcursor;
00117 };
00118 
00119 #endif // Bitmap_h