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

FXBitmapView.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * B i t m a p V i e w W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2000,2006 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: FXBitmapView.h,v 1.8 2006/01/22 17:57:59 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXBITMAPVIEW_H
25 #define FXBITMAPVIEW_H
26 
27 #ifndef FXSCROLLAREA_H
28 #include "FXScrollArea.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 class FXBitmap;
35 
36 /// Bitmap alignment styles
37 enum {
38  BITMAPVIEW_NORMAL = 0, /// Normal mode is centered
39  BITMAPVIEW_CENTER_X = 0, /// Centered horizontally
40  BITMAPVIEW_LEFT = 0x00100000, /// Left-aligned
41  BITMAPVIEW_RIGHT = 0x00200000, /// Right-aligned
42  BITMAPVIEW_CENTER_Y = 0, /// Centered vertically
43  BITMAPVIEW_TOP = 0x00400000, /// Top-aligned
44  BITMAPVIEW_BOTTOM = 0x00800000 /// Bottom-aligned
45  };
46 
47 /**
48 * The Bitmap View widget display a scrollable view of a monochrome bitmap image;
49 * the bitmap is not owned by the bitmap frame so it must be explicitly deleted
50 * elsewhere. Thus, a single bitmap image can be displayed inside multiple bitmap
51 * view widgets.
52 */
53 class FXAPI FXBitmapView : public FXScrollArea {
55 protected:
56  FXBitmap *bitmap; // Image to view
57  FXColor onColor; // Color for on pixels
58  FXColor offColor; // Color for off pixels
59  FXint grabx; // Grab point x
60  FXint graby; // Grab point y
61 protected:
62  FXBitmapView();
63 private:
64  FXBitmapView(const FXBitmapView&);
65  FXBitmapView &operator=(const FXBitmapView&);
66 public:
67  long onPaint(FXObject*,FXSelector,void*);
68  long onMotion(FXObject*,FXSelector,void*);
69  long onRightBtnPress(FXObject*,FXSelector,void*);
70  long onRightBtnRelease(FXObject*,FXSelector,void*);
71 public:
72  enum {
73  ID_XYZ=FXScrollArea::ID_LAST,
74  ID_LAST
75  };
76 public:
77 
78  /// Construct a scroll window
79  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);
80 
81  /// Create server-side resources
82  virtual void create();
83 
84  /// Detach server-side resources
85  virtual void detach();
86 
87  /// Perform layout immediately
88  virtual void layout();
89 
90  /// Image view widget can receive focus
91  virtual bool canFocus() const;
92 
93  /// Return the width of the contents
94  virtual FXint getContentWidth();
95 
96  /// Return the height of the contents
97  virtual FXint getContentHeight();
98 
99  /// Change image
100  void setBitmap(FXBitmap* bmp);
102  /// Return image
103  FXBitmap* getBitmap() const { return bitmap; }
104 
105  /// Set on color
106  void setOnColor(FXColor clr);
108  /// Get on color
109  FXColor getOnColor() const { return onColor; }
110 
111  /// Set off color
112  void setOffColor(FXColor clr);
113 
114  /// Get off color
115  FXColor getOffColor() const { return offColor; }
116 
117  /// Set the current alignment.
118  void setAlignment(FXuint mode);
119 
120  /// Get the current alignment.
121  FXuint getAlignment() const;
122 
123  /// Save list to a stream
124  virtual void save(FXStream& store) const;
125 
126  /// Load list from a stream
127  virtual void load(FXStream& store);
128 
129  /// Destroy
130  virtual ~FXBitmapView();
131  };
132 
133 }
134 
135 #endif
A Bitmap is a rectangular array of pixels.
Definition: FXBitmap.h:64
Definition: FXWindow.h:241
unsigned int FXuint
Definition: fxdefs.h:396
FXuint FXSelector
Association key.
Definition: FXObject.h:53
Normal mode is centered.
Definition: FXBitmapView.h:41
#define FXAPI
Definition: fxdefs.h:122
Base composite.
Definition: FXComposite.h:35
#define NULL
Definition: fxdefs.h:41
FXuint FXColor
Definition: fxdefs.h:454
Top-aligned.
Definition: FXBitmapView.h:46
The Bitmap View widget display a scrollable view of a monochrome bitmap image; the bitmap is not owne...
Definition: FXBitmapView.h:60
Centered horizontally.
Definition: FXBitmapView.h:42
Bottom-aligned.
Definition: FXBitmapView.h:47
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
Centered vertically.
Definition: FXBitmapView.h:45
The scroll area widget manages a content area and a viewport area through which the content is viewed...
Definition: FXScrollArea.h:75
Left-aligned.
Definition: FXBitmapView.h:43
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
Right-aligned.
Definition: FXBitmapView.h:44
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92

Copyright © 1997-2005 Jeroen van der Zijp