dtinfo: remove register keyword
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / src / Graphics / PixmapGraphic.hh
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*
24  * $XConsortium: PixmapGraphic.hh /main/5 1996/09/06 15:32:15 cde-hal $
25  *
26  * Copyright (c) 1992 HaL Computer Systems, Inc.  All rights reserved.
27  * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
28  * States.  Use of a copyright notice is precautionary only and does not
29  * imply publication or disclosure.
30  * 
31  * This software contains confidential information and trade secrets of HaL
32  * Computer Systems, Inc.  Use, disclosure, or reproduction is prohibited
33  * without the prior express written permission of HaL Computer Systems, Inc.
34  * 
35  *                         RESTRICTED RIGHTS LEGEND
36  * Use, duplication, or disclosure by the Government is subject to
37  * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
38  * Technical Data and Computer Software clause at DFARS 252.227-7013.
39  *                        HaL Computer Systems, Inc.
40  *                  1315 Dell Avenue, Campbell, CA  95008
41  * 
42  */
43
44 #include "UAS.hh"
45 // #include "Managers/GraphicsMgr.hh"
46
47 class GraphicsMgr;
48 class GraphicAgent ;
49 class GraphicsHandler ;
50 class Graphic;
51
52 #include <X11/X.h>
53 #include <X11/Intrinsic.h>
54
55 #include <DtI/GraphicsP.h>
56
57 class PixmapGraphic ;
58 // Message Classed for informing ViewportAgents about attaching and detaching
59 // their graphics 
60 class GraphicsMessage
61 {
62 public:
63   GraphicsMessage( UAS_Pointer<Graphic> &gr )
64     : f_graphic(gr)
65     {}
66
67   UAS_Pointer<Graphic> &graphic() 
68     { return f_graphic ; }
69
70 private:
71   UAS_Pointer<Graphic>  f_graphic ;
72 };
73
74 class DetachGraphic : public GraphicsMessage
75 {
76 public:
77   DetachGraphic(UAS_Pointer<Graphic> &gr,
78                 GraphicAgent *ga)
79     : GraphicsMessage(gr),
80       f_graphic_agent(ga)
81     {}
82
83   GraphicAgent *agent() { return f_graphic_agent ; }
84
85 private:
86   GraphicAgent  *f_graphic_agent ;
87 };
88
89 class ReAttachGraphic : public GraphicsMessage
90 {
91
92 public:
93   ReAttachGraphic( UAS_Pointer<Graphic> &gr)
94     : GraphicsMessage(gr)
95     {}
96 };
97
98 class DisplayGraphic
99 {
100 public:
101   DisplayGraphic( UAS_Pointer<Graphic> &g)
102     : f_graphic(g)
103     {}
104   UAS_Pointer<Graphic>  &graphic() { return f_graphic ;}
105 private:
106   UAS_Pointer<Graphic>  f_graphic ;
107 };
108
109 class PixmapGraphic : public UAS_Sender<DetachGraphic>,
110                       public UAS_Sender<ReAttachGraphic>
111 {
112 public:
113   enum PixmapFlag { NORMAL, DETACHED_PIXMAP, DEFAULT_PIXMAP, PRESERVE } ;
114
115   PixmapGraphic (Pixmap pixmap,
116                  Dimension width, Dimension height,
117                  PixmapFlag);
118
119   virtual ~PixmapGraphic();
120
121   void set_colormap( Colormap, int, Pixel *, _DtGrContext * );
122
123   virtual bool isPostScriptGraphic() const { return FALSE ; } 
124
125   // member access functions 
126   Pixmap pixmap() const
127     { return f_pixmap; }
128
129   Dimension width() const
130     { return f_width; }
131
132   Dimension height() const
133     { return f_height; }
134
135   void destroy() ;
136
137   bool is_detached() const { return f_flag == DETACHED_PIXMAP ; }
138
139   void set_type(PixmapFlag f) { f_flag = f ; }
140
141   void register_handler(GraphicsHandler *);
142
143   GraphicAgent *agent() { return f_agent; }
144   GraphicAgent *agent(GraphicAgent *agent)
145     { f_agent = agent ; return agent; }
146
147 protected:
148   // copy constructor
149   PixmapGraphic(const PixmapGraphic *);
150   
151 protected: // variables
152   Pixmap                f_pixmap;
153   Dimension             f_width;
154   Dimension             f_height;
155   PixmapFlag            f_flag ; 
156   GraphicAgent         *f_agent ;
157
158   // colormap info allocated for the above f_pixmap:
159   Colormap              f_colormap;     // containing colormap
160   int                   f_num_colors;   // num colors allocated
161   Pixel                *f_colors;       // colors allocated
162   _DtGrContext         *f_tiff_context; // colors if tiff type graphic
163
164 };
165