Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXBitmapView.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                    B i t m a p   V i e w   W i d g e t                        *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2000,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXBitmapView.h,v 1.8 2006/01/22 17:57:59 fox Exp $                       *
00023 ********************************************************************************/
00024 #ifndef FXBITMAPVIEW_H
00025 #define FXBITMAPVIEW_H
00026 
00027 #ifndef FXSCROLLAREA_H
00028 #include "FXScrollArea.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 class FXBitmap;
00035 
00036 /// Bitmap alignment styles
00037 enum {
00038   BITMAPVIEW_NORMAL    = 0,              /// Normal mode is centered
00039   BITMAPVIEW_CENTER_X  = 0,              /// Centered horizontally
00040   BITMAPVIEW_LEFT      = 0x00100000,     /// Left-aligned
00041   BITMAPVIEW_RIGHT     = 0x00200000,     /// Right-aligned
00042   BITMAPVIEW_CENTER_Y  = 0,              /// Centered vertically
00043   BITMAPVIEW_TOP       = 0x00400000,     /// Top-aligned
00044   BITMAPVIEW_BOTTOM    = 0x00800000      /// Bottom-aligned
00045   };
00046 
00047 /**
00048 * The Bitmap View widget display a scrollable view of a monochrome bitmap image;
00049 * the bitmap is not owned by the bitmap frame so it must be explicitly deleted
00050 * elsewhere.  Thus, a single bitmap image can be displayed inside multiple bitmap
00051 * view widgets.
00052 */
00053 class FXAPI FXBitmapView : public FXScrollArea {
00054   FXDECLARE(FXBitmapView)
00055 protected:
00056   FXBitmap *bitmap;     // Image to view
00057   FXColor   onColor;    // Color for on pixels
00058   FXColor   offColor;   // Color for off pixels
00059   FXint     grabx;      // Grab point x
00060   FXint     graby;      // Grab point y
00061 protected:
00062   FXBitmapView();
00063 private:
00064   FXBitmapView(const FXBitmapView&);
00065   FXBitmapView &operator=(const FXBitmapView&);
00066 public:
00067   long onPaint(FXObject*,FXSelector,void*);
00068   long onMotion(FXObject*,FXSelector,void*);
00069   long onRightBtnPress(FXObject*,FXSelector,void*);
00070   long onRightBtnRelease(FXObject*,FXSelector,void*);
00071 public:
00072   enum {
00073     ID_XYZ=FXScrollArea::ID_LAST,
00074     ID_LAST
00075     };
00076 public:
00077 
00078   /// Construct a scroll window
00079   FXBitmapView(FXComposite* p,FXBitmap* bmp=NULL,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00080 
00081   /// Create server-side resources
00082   virtual void create();
00083 
00084   /// Detach server-side resources
00085   virtual void detach();
00086 
00087   /// Perform layout immediately
00088   virtual void layout();
00089 
00090   /// Image view widget can receive focus
00091   virtual bool canFocus() const;
00092 
00093   /// Return the width of the contents
00094   virtual FXint getContentWidth();
00095 
00096   /// Return the height of the contents
00097   virtual FXint getContentHeight();
00098 
00099   /// Change image
00100   void setBitmap(FXBitmap* bmp);
00101 
00102   /// Return image
00103   FXBitmap* getBitmap() const { return bitmap; }
00104 
00105   /// Set on color
00106   void setOnColor(FXColor clr);
00107 
00108   /// Get on color
00109   FXColor getOnColor() const { return onColor; }
00110 
00111   /// Set off color
00112   void setOffColor(FXColor clr);
00113 
00114   /// Get off color
00115   FXColor getOffColor() const { return offColor; }
00116 
00117   /// Set the current alignment.
00118   void setAlignment(FXuint mode);
00119 
00120   /// Get the current alignment.
00121   FXuint getAlignment() const;
00122 
00123   /// Save list to a stream
00124   virtual void save(FXStream& store) const;
00125 
00126   /// Load list from a stream
00127   virtual void load(FXStream& store);
00128 
00129   /// Destroy
00130   virtual ~FXBitmapView();
00131   };
00132 
00133 }
00134 
00135 #endif

Copyright © 1997-2005 Jeroen van der Zijp