1 /********************************************************************************
2 *                                                                               *
3 *                       I m a g e   V i e w   W i d g e t                       *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 2000,2005 by Jeroen van der Zijp.   All Rights Reserved.        *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or                 *
9 * modify it under the terms of the GNU Lesser General Public                    *
10 * License as published by the Free Software Foundation; either                  *
11 * version 2.1 of the License, or (at your option) any later version.            *
12 *                                                                               *
13 * This library is distributed in the hope that it will be useful,               *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
16 * Lesser General Public License for more details.                               *
17 *                                                                               *
18 * You should have received a copy of the GNU Lesser General Public              *
19 * License along with this library; if not, write to the Free Software           *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
21 *********************************************************************************
22 * $Id: FXImageView.h,v 1.14 2005/01/16 16:06:06 fox Exp $                       *
23 ********************************************************************************/
24 #ifndef FXIMAGEVIEW_H
25 #define FXIMAGEVIEW_H
26 
27 #ifndef FXSCROLLAREA_H
28 #include "FXScrollArea.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 class FXImage;
35 
36 
37 /// Image alignment styles
38 enum {
39   IMAGEVIEW_NORMAL    = 0,              /// Normal mode is centered
40   IMAGEVIEW_CENTER_X  = 0,              /// Centered horizontally
41   IMAGEVIEW_LEFT      = 0x00100000,     /// Left-aligned
42   IMAGEVIEW_RIGHT     = 0x00200000,     /// Right-aligned
43   IMAGEVIEW_CENTER_Y  = 0,              /// Centered vertically
44   IMAGEVIEW_TOP       = 0x00400000,     /// Top-aligned
45   IMAGEVIEW_BOTTOM    = 0x00800000      /// Bottom-aligned
46   };
47 
48 
49 /**
50 * The Image View widget display a scrollable view of an image.
51 */
52 class FXAPI FXImageView : public FXScrollArea {
53   FXDECLARE(FXImageView)
54 protected:
55   FXImage *image;         // Image to view
56   FXint    grabx;         // Grab point x
57   FXint    graby;         // Grab point y
58 protected:
59   FXImageView();
60 private:
61   FXImageView(const FXImageView&);
62   FXImageView &operator=(const FXImageView&);
63 public:
64   long onPaint(FXObject*,FXSelector,void*);
65   long onMotion(FXObject*,FXSelector,void*);
66   long onRightBtnPress(FXObject*,FXSelector,void*);
67   long onRightBtnRelease(FXObject*,FXSelector,void*);
68 public:
69   enum {
70     ID_XYZ=FXScrollArea::ID_LAST,
71     ID_LAST
72     };
73 public:
74 
75   /// Construct a scroll window
76   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);
77 
78   /// Create server-side resources
79   virtual void create();
80 
81   /// Detach server-side resources
82   virtual void detach();
83 
84   /// Perform layout
85   virtual void layout();
86 
87   /// Image view widget can receive focus
88   virtual FXbool canFocus() const;
89 
90   /// Return the width of the contents
91   virtual FXint getContentWidth();
92 
93   /// Return the height of the contents
94   virtual FXint getContentHeight();
95 
96   /// Change image
97   void setImage(FXImage* img);
98 
99   /// Return image
getImage()100   FXImage* getImage() const { return image; }
101 
102   /// Set the current alignment.
103   void setAlignment(FXuint mode);
104 
105   /// Get the current alignment.
106   FXuint getAlignment() const;
107 
108   /// Save list to a stream
109   virtual void save(FXStream& store) const;
110 
111   /// Load list from a stream
112   virtual void load(FXStream& store);
113 
114   /// Destroy
115   virtual ~FXImageView();
116   };
117 
118 }
119 
120 #endif
121