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

FXImageView.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                       I m a g e   V i e w   W i d g e t                       *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2000,2009 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (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                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 *********************************************************************************
00021 * $Id: FXImageView.h,v 1.21 2009/01/06 13:07:25 fox Exp $                       *
00022 ********************************************************************************/
00023 #ifndef FXIMAGEVIEW_H
00024 #define FXIMAGEVIEW_H
00025 
00026 #ifndef FXSCROLLAREA_H
00027 #include "FXScrollArea.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 class FXImage;
00034 
00035 
00036 /// Image alignment styles
00037 enum {
00038   IMAGEVIEW_NORMAL    = 0,              /// Normal mode is centered
00039   IMAGEVIEW_CENTER_X  = 0,              /// Centered horizontally
00040   IMAGEVIEW_LEFT      = 0x00100000,     /// Left-aligned
00041   IMAGEVIEW_RIGHT     = 0x00200000,     /// Right-aligned
00042   IMAGEVIEW_CENTER_Y  = 0,              /// Centered vertically
00043   IMAGEVIEW_TOP       = 0x00400000,     /// Top-aligned
00044   IMAGEVIEW_BOTTOM    = 0x00800000      /// Bottom-aligned
00045   };
00046 
00047 
00048 /**
00049 * The Image View widget display a scrollable view of an image.
00050 */
00051 class FXAPI FXImageView : public FXScrollArea {
00052   FXDECLARE(FXImageView)
00053 protected:
00054   FXImage *image;         // Image to view
00055   FXint    grabx;         // Grab point x
00056   FXint    graby;         // Grab point y
00057 protected:
00058   FXImageView();
00059 private:
00060   FXImageView(const FXImageView&);
00061   FXImageView &operator=(const FXImageView&);
00062 public:
00063   long onPaint(FXObject*,FXSelector,void*);
00064   long onMotion(FXObject*,FXSelector,void*);
00065   long onRightBtnPress(FXObject*,FXSelector,void*);
00066   long onRightBtnRelease(FXObject*,FXSelector,void*);
00067 public:
00068   enum {
00069     ID_XYZ=FXScrollArea::ID_LAST,
00070     ID_LAST
00071     };
00072 public:
00073 
00074   /// Construct a scroll window
00075   FXImageView(FXComposite* p,FXImage* img=NULL,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00076 
00077   /// Create server-side resources
00078   virtual void create();
00079 
00080   /// Detach server-side resources
00081   virtual void detach();
00082 
00083   /// Perform layout
00084   virtual void layout();
00085 
00086   /// Image view widget can receive focus
00087   virtual FXbool canFocus() const;
00088 
00089   /// Return the width of the contents
00090   virtual FXint getContentWidth();
00091 
00092   /// Return the height of the contents
00093   virtual FXint getContentHeight();
00094 
00095   /// Change image
00096   void setImage(FXImage* img);
00097 
00098   /// Return image
00099   FXImage* getImage() const { return image; }
00100 
00101   /// Set the current alignment.
00102   void setAlignment(FXuint mode);
00103 
00104   /// Get the current alignment.
00105   FXuint getAlignment() const;
00106 
00107   /// Save list to a stream
00108   virtual void save(FXStream& store) const;
00109 
00110   /// Load list from a stream
00111   virtual void load(FXStream& store);
00112 
00113   /// Destroy
00114   virtual ~FXImageView();
00115   };
00116 
00117 }
00118 
00119 #endif

Copyright © 1997-2009 Jeroen van der Zijp