Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtlogin / vglogo.c
1 /* $XConsortium: vglogo.c /main/4 1995/10/27 16:17:33 rswiston $ */
2 /*                                                                      *
3  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
4  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
5  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
6  * (c) Copyright 1993, 1994 Novell, Inc.                                *
7  */
8 /************************************<+>*************************************
9  ****************************************************************************
10  **
11  **   File:        vglogo.c
12  **
13  **   Project:     HP Visual User Environment (DT)
14  **
15  **   Description: Routines to create the Corporate logo
16  **
17  **
18  **
19  **   (c) Copyright 1987, 1988, 1989 by Hewlett-Packard Company
20  **
21  **
22  **
23  ****************************************************************************
24  ************************************<+>*************************************/
25
26
27 /***************************************************************************
28  *
29  *  Includes
30  *
31  ***************************************************************************/
32
33 #include        <stdio.h>
34 #include        <X11/Intrinsic.h>
35 #include        <X11/StringDefs.h>
36 #include        <Xm/Xm.h>
37 #include        <Xm/DrawingA.h>
38 #include        <Xm/Frame.h>
39 #include        <Xm/Label.h>
40 #include    <Dt/IconFile.h>
41 #include    <Dt/Icon.h>
42
43 #include        "vg.h"
44 #include        "vglogo.h"      /* pixmap and bitmap for default Login logo   */
45 # include       "vgmsg.h"
46
47
48
49
50
51 /***************************************************************************
52  *
53  *  External declarations
54  *
55  ***************************************************************************/
56
57
58 /***************************************************************************
59  *
60  *  Procedure declarations
61  *
62  ***************************************************************************/
63
64
65 /***************************************************************************
66  *
67  *  Global variables
68  *
69  ***************************************************************************/
70
71         LogoInfo logoInfo;      /* logo resources                          */
72
73 static  XtResource logoResources[] = {
74     {"bitmapFile", "BitmapFile",
75         XtRString, sizeof(char *), XtOffset(LogoInfoPtr, bitmapFile),
76 #ifdef __osf__
77         XtRString, "DECDtlogo"                                          },
78 #else
79         XtRString, "Dtlogo"                                             },
80 #endif
81 };
82
83  
84 /***************************************************************************
85  *
86  *  MakeLogo
87  *
88  *  make DT logo
89  *
90  *  Widgets: logo, logo_pixmap
91  ***************************************************************************/
92
93 void 
94 MakeLogo( void )
95 {
96     register int i;
97
98     char        *logoFile;              /* name of logo bitmap file        */
99     
100     Pixmap      logoPixmap;             /* logo pixmap                     */
101     char        *logoName;              /* logo name                       */
102
103     int         logoWidth, logoHeight;  /* width, height of logo           */
104     Pixel       fg, bg;                 /* foreground, background colors   */
105
106     Pixmap      dsPixmap;               /* drop shadow pixmap              */
107     int         dsWidth, dsHeight;      /* width, height of drop shadow    */
108
109     Pixmap              pixmap;                 /* scratch pixmap          */
110     GC          gc;                     /* scratch GC              */
111     XGCValues   gcval;                  /* GC values               */
112     unsigned int        width, height;          /* width, height of bitmap */
113     int         x_hot, y_hot;           /* bitmap hot spot (if any)*/
114
115     
116     /*
117      *  get the user's logo preferences...
118      */
119      
120     XtGetSubresources(table, &logoInfo, "logo", "Logo",
121         logoResources, XtNumber(logoResources), NULL, 0);
122
123     /*
124      *  create the logo frame...
125      */
126
127     i = InitArg(Frame);
128         XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT); i++;
129     XtSetArg(argt[i], XmNshadowThickness, 2); i++; 
130     XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
131     XtSetArg(argt[i], XmNtopOffset, 15); i++;
132     XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_FORM); i++;
133     XtSetArg(argt[i], XmNbottomOffset, 15); i++;
134         XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
135         XtSetArg(argt[i], XmNrightOffset, 15); i++;
136     XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
137     XtSetArg(argt[i], XmNleftWidget, matteFrame); i++;
138     logo1 = XmCreateFrame(matte, "logo", argt, i); 
139     XtManageChild(logo1);
140
141
142     /*
143      *  get the colors of the frame...
144      */
145
146     XtSetArg(argt[0], XmNforeground, &fg);
147     XtSetArg(argt[1], XmNbackground, &bg);
148     XtGetValues(logo1, argt, 2);
149     
150
151     /*
152      *  create the logo pixmap...
153      */
154
155     logoFile = logoInfo.bitmapFile;
156
157 #if defined (_AIX) && defined (_POWER)
158 /*
159  * On AIX4 we have a Dtlogo.s.pm
160  */
161 # define LOGO_TYPE (LOWRES ? DtSMALL : NULL)
162 #else 
163 # define LOGO_TYPE NULL
164 #endif
165     
166     logoName = _DtGetIconFileName(DefaultScreenOfDisplay(dpyinfo.dpy), 
167         logoFile, NULL, NULL, LOGO_TYPE);
168
169     if (logoName == NULL)
170     {
171         LogError(
172                 ReadCatalog(MC_LOG_SET,MC_LOG_NO_LOGOBIT,MC_DEF_LOG_NO_LOGOBIT),
173                 logoFile);
174         logoFile = NULL;
175     }
176
177
178     /*
179      *  create the logo control...
180      */
181
182     i = InitArg(LabelG);
183     XtSetArg(argt[i], XmNmarginWidth, 0); i++;
184     XtSetArg(argt[i], XmNmarginHeight, 0); i++;
185     XtSetArg(argt[i], XmNhighlightThickness, 0); i++;
186     XtSetArg(argt[i], XmNbehavior, XmICON_LABEL); i++;
187     XtSetArg(argt[i], XmNfillMode, XmFILL_TRANSPARENT); i++;
188     XtSetArg(argt[i], XmNstring, NULL); i++;
189     if (logoName != NULL)
190     {
191         XtSetArg(argt[i], XmNpixmapForeground, fg); i++;
192         XtSetArg(argt[i], XmNpixmapBackground, bg); i++;
193         XtSetArg(argt[i], XmNimageName, logoName); i++;
194     }
195     else
196     {
197         /*
198          *  use built-in logo if no logo was not found
199          */
200      
201         logoPixmap = XCreatePixmapFromBitmapData(
202                                 dpyinfo.dpy,            /* display         */
203                                 dpyinfo.root,           /* drawable        */
204                                 (char *)dt_logo_bits,   /* data            */
205                                 dt_logo_width,          /* width           */
206                                 dt_logo_height,         /* height          */
207                                 fg,                     /* foreground      */
208                                 bg,                     /* background      */
209                                 dpyinfo.depth);         /* depth           */
210
211         logoWidth  = dt_logo_width;
212         logoHeight = dt_logo_height;
213
214         XtSetArg(argt[i], XmNpixmap, logoPixmap); i++;
215     }
216
217         logo_pixmap = _DtCreateIcon(logo1, "logo_pixmap", argt, i);
218         XtManageChild(logo_pixmap);
219
220         XtSetArg(argt[0], XmNheight,  245); /* keeps dialog a consistent height and width */
221         XtSetArg(argt[1], XmNwidth,   245);
222         XtSetValues(logo1, argt, 2);
223 }