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