~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/3rdparty/qmon/Xmt310/Xmt/PixelCvt.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Motif Tools Library, Version 3.1
 
3
 * $Id$
 
4
 * 
 
5
 * Written by David Flanagan.
 
6
 * Copyright (c) 1992-2001 by David Flanagan.
 
7
 * All Rights Reserved.  See the file COPYRIGHT for details.
 
8
 * This is open source software.  See the file LICENSE for details.
 
9
 * There is no warranty for this software.  See NO_WARRANTY for details.
 
10
 *
 
11
 * $Log$
 
12
 * Revision 1.1.1.1  2001/07/18 11:06:02  root
 
13
 * Initial checkin.
 
14
 *
 
15
 * Revision 1.2  2001/06/12 16:25:28  andre
 
16
 * *** empty log message ***
 
17
 *
 
18
 *
 
19
 */
 
20
 
 
21
#include <Xmt/Xmt.h>
 
22
#include <Xmt/AppResP.h>
 
23
#include <Xmt/ConvertersP.h>
 
24
#include <X11/IntrinsicP.h>
 
25
 
 
26
/*
 
27
 * A replacement for XtCvtStringToPixel that uses XmtAllocColor()
 
28
 */
 
29
/* ARGSUSED */
 
30
#if NeedFunctionPrototypes
 
31
Boolean XmtConvertStringToPixel(Display *dpy,
 
32
                                XrmValue *args, Cardinal *num_args,
 
33
                                XrmValue *from, XrmValue *to,
 
34
                                XtPointer *closure_return)
 
35
#else
 
36
Boolean XmtConvertStringToPixel(dpy, args, num_args, from, to, closure_return)
 
37
Display *dpy;
 
38
XrmValue *args;
 
39
Cardinal *num_args;
 
40
XrmValue *from;
 
41
XrmValue *to;
 
42
XtPointer *closure_return;
 
43
#endif
 
44
{
 
45
    String          str = (String)from->addr;
 
46
    Widget          rootshell = *((Widget *)args[0].addr);
 
47
    Colormap        colormap = *((Colormap *)args[1].addr);
 
48
    Visual          *visual = *((Visual **)args[2].addr);
 
49
    int             status;
 
50
    Pixel           pixel;
 
51
 
 
52
    status = XmtAllocColor(rootshell, colormap, visual, NULL, str, &pixel);
 
53
 
 
54
    if (!status)
 
55
        done(Pixel, pixel)
 
56
    else {
 
57
        XtDisplayStringConversionWarning(dpy, str, XtRPixel);
 
58
        if (status == 1)
 
59
            XmtWarningMsg("XmtConvertStringToPixel", "parse",
 
60
                          "malformed or unrecognized color name '%s'.",
 
61
                          str);
 
62
        else
 
63
            XmtWarningMsg("XmtConvertStringToPixel", "alloc",
 
64
                          "can't allocate color '%s'; colormap full.",
 
65
                          str);
 
66
        return False;
 
67
    }
 
68
}
 
69
 
 
70
/* ARGSUSED */
 
71
#if NeedFunctionPrototypes
 
72
static void FreeConvertedPixel(XtAppContext app, XrmValue *to,
 
73
                               XtPointer closure,
 
74
                               XrmValue *args, Cardinal *num_args)
 
75
#else
 
76
static void FreeConvertedPixel(app, to, closure, args, num_args)
 
77
XtAppContext app;
 
78
XrmValue *to;
 
79
XtPointer closure;
 
80
XrmValue *args;
 
81
Cardinal *num_args;
 
82
#endif
 
83
{
 
84
    Widget   rootshell = *((Widget *)args[0].addr);
 
85
    Colormap colormap = *((Colormap *)args[1].addr);
 
86
    Pixel    pixel = *((Pixel *)to->addr);
 
87
 
 
88
    XmtFreeColor(rootshell, colormap, pixel);
 
89
}
 
90
 
 
91
static XtConvertArgRec pixel_args[] = {
 
92
    {XtProcedureArg, (XtPointer)_XmtFetchRootWidget, 0},
 
93
    {XtWidgetBaseOffset,
 
94
         (XtPointer)XtOffsetOf(WidgetRec, core.colormap),
 
95
         sizeof(Colormap)},
 
96
    {XtProcedureArg, (XtPointer)_XmtFetchVisual, 0},
 
97
};
 
98
 
 
99
#if NeedFunctionPrototypes
 
100
void XmtRegisterPixelConverter(void)
 
101
#else
 
102
void XmtRegisterPixelConverter()
 
103
#endif
 
104
{
 
105
    static Boolean registered = False;
 
106
 
 
107
    if (!registered) {
 
108
        XtSetTypeConverter(XtRString, XtRPixel,
 
109
                           XmtConvertStringToPixel,
 
110
                           pixel_args, XtNumber(pixel_args),
 
111
                           XtCacheByDisplay | XtCacheRefCount,
 
112
                           FreeConvertedPixel);
 
113
        registered = True;
 
114
    }
 
115
}
 
116
 
 
117
 
 
118