1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
|
#if !defined(lint) && !defined(SABER) && !defined(GCC_WALL)
static char XRNrcsid[] = "$Id: Xmisc.c,v 1.2 1997/03/30 15:33:56 jik Exp $";
#endif
/*
* xrn - an X-based NNTP news reader
*
* Copyright (c) 1988-1993, Ellen M. Sentovich and Rick L. Spickelmier.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of the University of California not
* be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. The University
* of California makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* THE UNIVERSITY OF CALIFORNIA DISCLAIMS ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR
* ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* xmisc.c: routines for handling miscellaneous x functions
*
*/
#include "copyright.h"
#include "config.h"
#include "utils.h"
#include <X11/Xos.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <X11/cursorfont.h>
#include <X11/Xaw3d/Command.h>
#include "news.h"
#include "xthelper.h"
#include "resources.h"
#include "internals.h"
#include "xrn.h"
#include "xmisc.h"
#include "busyCursor.h"
/* XRN icon */
#if SUPPORT_SILLY_CALVIN_ICON
#include "calvin.icon"
#endif
#include "xrn.icon"
static Pixmap
getpm()
{
unsigned int width, height;
unsigned char *bits;
#if SUPPORT_SILLY_CALVIN_ICON
if (app_resources.calvin) {
width = calvin_width;
height = calvin_height;
bits = calvin_bits;
} else {
#endif
width = xrn_width;
height = xrn_height;
bits = xrn_bits;
#if SUPPORT_SILLY_CALVIN_ICON
}
#endif
return XCreateBitmapFromData(XtDisplay(TopLevel), XtScreen(TopLevel)->root,
(char *) bits, width, height);
}
void
xmSetIconAndName(it)
IconType it;
{
static char *PrevName = NULL, *OldName = NULL;
static Pixmap PrevPm = None, OldPm = None;
char *name WALL(= 0);
Pixmap pm WALL(= 0);
Arg arg;
if (OldPm == None) {
XtSetArg(arg, XtNiconPixmap, &OldPm);
XtGetValues(TopLevel, &arg, 1);
PrevPm = OldPm;
}
if (app_resources.iconPixmap == None) {
app_resources.iconPixmap = getpm();
}
if (app_resources.unreadIconPixmap == None) {
app_resources.unreadIconPixmap = app_resources.iconPixmap;
}
switch (it) {
case InitIcon :
PrevPm = pm = app_resources.iconPixmap;
PrevName = name = OldName = app_resources.iconName;
break;
case UnreadIcon :
PrevPm = pm = app_resources.unreadIconPixmap;
PrevName = name = app_resources.unreadIconName;
break;
case ReadIcon :
PrevPm = pm = app_resources.iconPixmap;
PrevName = name = app_resources.iconName;
break;
case BusyIcon :
if ((pm = app_resources.busyIconPixmap) == None)
pm = OldPm;
if ((name = app_resources.busyIconName) == NULL)
name = OldName;
break;
case PrevIcon :
pm = PrevPm;
name = PrevName;
break;
}
if (OldPm != pm) {
XtSetArg(arg, XtNiconPixmap, pm);
XtSetValues(TopLevel, &arg, 1);
OldPm = pm;
}
if (name == NULL) {
name = app_resources.iconName;
}
if (OldName != name) {
XSetIconName(XtDisplay(TopLevel),XtWindow(TopLevel),name);
XFlush(XtDisplay(TopLevel));
OldName = name;
}
}
void
xmIconCreate()
{
xmSetIconAndName(InitIcon);
if (app_resources.iconGeometry != NIL(char)) {
int scr, x, y, junk;
Arg args[2];
for(scr = 0; /* yyuucchh */
XtScreen(TopLevel) != ScreenOfDisplay(XtDisplay(TopLevel), scr);
scr++);
XGeometry(XtDisplay(TopLevel), scr, app_resources.iconGeometry,
"", 0, 0, 0, 0, 0, &x, &y, &junk, &junk);
XtSetArg(args[0], XtNiconX, x);
XtSetArg(args[1], XtNiconY, y);
XtSetValues(TopLevel, args, XtNumber(args));
}
return;
}
/*
* create the normal and busy xrn cursors
*/
void xrnBusyCursor()
{
BusyCursor(TopLevel, True);
xmSetIconAndName(BusyIcon);
return;
}
void xrnUnbusyCursor()
{
UnbusyCursor(TopLevel, True);
xmSetIconAndName(PrevIcon);
return;
}
/*ARGSUSED*/
void CBbusyCursor(widget, client_data, call_data)
Widget widget;
XtPointer client_data;
XtPointer call_data;
{
xrnBusyCursor();
return;
}
/*ARGSUSED*/
void CBunbusyCursor(widget, client_data, call_data)
Widget widget;
XtPointer client_data;
XtPointer call_data;
{
xrnUnbusyCursor();
return;
}
/*
A Command widget is passed in. Its border width/shadow and related
stuff is grown so that it's larger than other buttons (so that it is
visibly the default button).
*/
void makeDefaultButton(widget)
Widget widget;
{
Dimension border_width, highlight_thickness;
XtVaGetValues(widget,
XtNborderWidth, (XtArgVal) &border_width,
XtNhighlightThickness, (XtArgVal) &highlight_thickness,
0);
border_width++;
highlight_thickness++;
XtVaSetValues(widget,
XtNborderWidth, (XtArgVal) border_width,
XtNhighlightThickness, (XtArgVal) highlight_thickness,
0);
}
|