static_bitmap.h

Go to the documentation of this file.
00001 #ifndef STATIC_BITMAP_CLASS
00002 #define STATIC_BITMAP_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : static_bitmap                                                     *
00007 *  Author : Chris Koeritz                                                     *
00008 *  Partially based on source code by Jorge Lodos (lodos@cigb.edu.cu)          *
00009 *                                                                             *
00010 *  Purpose:                                                                   *
00011 *                                                                             *
00012 *    Provides an MFC object for ensuring that bitmaps used as static objects  *
00013 *  retain the proper colors, even in the highly broken 256 color mode for     *
00014 *  resources.  This is done by realizing the palette for the bitmap.          *
00015 *                                                                             *
00016 *******************************************************************************
00017 * Copyright (c) 1998-$now By Author.  This program is free software; you can  *
00018 * redistribute it and/or modify it under the terms of the GNU General Public  *
00019 * License as published by the Free Software Foundation; either version 2 of   *
00020 * the License or (at your option) any later version.  This is online at:      *
00021 *     http://www.fsf.org/copyleft/gpl.html                                    *
00022 * Please send any updates to: fred@gruntose.com                               *
00023 \*****************************************************************************/
00024 
00025 #include "mfc_dll.h"
00026 
00027 #include <basis/portable.h>
00028 
00029 // forward.
00030 class bitmap;
00031 
00032 class MFC_EXTENSIONS_CLASS_STYLE static_bitmap : public CStatic
00033 {
00034 public:
00035   static_bitmap();
00036   virtual ~static_bitmap();
00037 
00038   bool valid() const;
00039     // returns true if this object seems fine.
00040 
00041   bool load(const istring &name);
00042     // loads the bitmap from a file with the "name".
00043 
00044   bool load(HINSTANCE instance, const char *resource);
00045     // loads a bitmap out of the "instance" using the "resource" id specified.
00046     // if this is a numerical resource identifier, use MAKEINTRESOURCE to
00047     // pass it in.
00048 
00049   void update();
00050     // draws the static bitmap.
00051 
00052   bool realize_palette(bool force_background);
00053     // causes the palette for the static bitmap to be realized into the
00054     // device context such that the colors are now what they should be.
00055 
00056 protected:
00057   bitmap *_dib;
00058 
00059   void paint(bool valid);
00060     // redraws the static bitmap if "valid" is true.  otherwise an X marks
00061     // the spot.
00062 
00063   // mfc monstrosities...
00064   //{{AFX_MSG(static_bitmap)
00065   afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
00066   afx_msg BOOL OnQueryNewPalette();
00067   afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
00068   //}}AFX_MSG
00069   DECLARE_MESSAGE_MAP()
00070 
00071   // forbidden.
00072   static_bitmap(const static_bitmap &);
00073   static_bitmap &operator =(static_bitmap &);
00074 };
00075 
00076 #endif
00077 

Generated on Fri Nov 21 04:29:17 2008 for HOOPLE Libraries by  doxygen 1.5.1