dtinfo subtree dtinfo
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / src / Graphics / PixmapGraphic.hh
1 /*
2  * $XConsortium: PixmapGraphic.hh /main/5 1996/09/06 15:32:15 cde-hal $
3  *
4  * Copyright (c) 1992 HaL Computer Systems, Inc.  All rights reserved.
5  * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
6  * States.  Use of a copyright notice is precautionary only and does not
7  * imply publication or disclosure.
8  * 
9  * This software contains confidential information and trade secrets of HaL
10  * Computer Systems, Inc.  Use, disclosure, or reproduction is prohibited
11  * without the prior express written permission of HaL Computer Systems, Inc.
12  * 
13  *                         RESTRICTED RIGHTS LEGEND
14  * Use, duplication, or disclosure by the Government is subject to
15  * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
16  * Technical Data and Computer Software clause at DFARS 252.227-7013.
17  *                        HaL Computer Systems, Inc.
18  *                  1315 Dell Avenue, Campbell, CA  95008
19  * 
20  */
21
22 #include "UAS.hh"
23 // #include "Managers/GraphicsMgr.hh"
24
25 class GraphicsMgr;
26 class GraphicAgent ;
27 class GraphicsHandler ;
28 class Graphic;
29
30 #include <X11/X.h>
31 #include <X11/Intrinsic.h>
32
33 #include <DtI/GraphicsP.h>
34
35 class PixmapGraphic ;
36 // Message Classed for informing ViewportAgents about attaching and detaching
37 // their graphics 
38 class GraphicsMessage
39 {
40 public:
41   GraphicsMessage( UAS_Pointer<Graphic> &gr )
42     : f_graphic(gr)
43     {}
44
45   UAS_Pointer<Graphic> &graphic() 
46     { return f_graphic ; }
47
48 private:
49   UAS_Pointer<Graphic>  f_graphic ;
50 };
51
52 class DetachGraphic : public GraphicsMessage
53 {
54 public:
55   DetachGraphic(UAS_Pointer<Graphic> &gr,
56                 GraphicAgent *ga)
57     : GraphicsMessage(gr),
58       f_graphic_agent(ga)
59     {}
60
61   GraphicAgent *agent() { return f_graphic_agent ; }
62
63 private:
64   GraphicAgent  *f_graphic_agent ;
65 };
66
67 class ReAttachGraphic : public GraphicsMessage
68 {
69
70 public:
71   ReAttachGraphic( UAS_Pointer<Graphic> &gr)
72     : GraphicsMessage(gr)
73     {}
74 };
75
76 class DisplayGraphic
77 {
78 public:
79   DisplayGraphic( UAS_Pointer<Graphic> &g)
80     : f_graphic(g)
81     {}
82   UAS_Pointer<Graphic>  &graphic() { return f_graphic ;}
83 private:
84   UAS_Pointer<Graphic>  f_graphic ;
85 };
86
87 class PixmapGraphic : public UAS_Sender<DetachGraphic>,
88                       public UAS_Sender<ReAttachGraphic>
89 {
90 public:
91   enum PixmapFlag { NORMAL, DETACHED_PIXMAP, DEFAULT_PIXMAP, PRESERVE } ;
92
93   PixmapGraphic (Pixmap pixmap,
94                  Dimension width, Dimension height,
95                  PixmapFlag);
96
97   virtual ~PixmapGraphic();
98
99   void set_colormap( Colormap, int, Pixel *, _DtGrContext * );
100
101   virtual bool isPostScriptGraphic() const { return FALSE ; } 
102
103   // member access functions 
104   Pixmap pixmap() const
105     { return f_pixmap; }
106
107   Dimension width() const
108     { return f_width; }
109
110   Dimension height() const
111     { return f_height; }
112
113   void destroy() ;
114
115   bool is_detached() const { return f_flag == DETACHED_PIXMAP ; }
116
117   void set_type(PixmapFlag f) { f_flag = f ; }
118
119   void register_handler(GraphicsHandler *);
120
121   GraphicAgent *agent() { return f_agent; }
122   GraphicAgent *agent(GraphicAgent *agent)
123     { f_agent = agent ; return agent; }
124
125 protected:
126   // copy constructor
127   PixmapGraphic(const PixmapGraphic *);
128   
129 protected: // variables
130   Pixmap                f_pixmap;
131   Dimension             f_width;
132   Dimension             f_height;
133   PixmapFlag            f_flag ; 
134   GraphicAgent         *f_agent ;
135
136   // colormap info allocated for the above f_pixmap:
137   Colormap              f_colormap;     // containing colormap
138   int                   f_num_colors;   // num colors allocated
139   Pixel                *f_colors;       // colors allocated
140   _DtGrContext         *f_tiff_context; // colors if tiff type graphic
141
142 };
143