AeUtils.c++
1.45 KB
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
#include <time.h>
#include "AeUtils.h"
//
// This routine converts a font name into a font
// list. Intended to be used when reading in
// font resources. Needs the current display to
// load in the associated font structure.
//
// If an error occurs, returns NULL.
//
XmFontList
FontName2FontList (Display *display, const char * fontName)
{
XFontStruct * fontStructP;
XmFontListEntry fontListEntry;
XmFontList fontList;
// Load in the font and get a pointer to its info struct.
if ((fontStructP = XLoadQueryFont (display, fontName)) == NULL)
goto Fail;
// Create a font list entry from the font struct.
if ((fontListEntry = XmFontListEntryCreate
(XmFONTLIST_DEFAULT_TAG, XmFONT_IS_FONT, fontStructP)) == NULL)
goto Fail;
// NULL indicates to create a new font list.
fontList = XmFontListAppendEntry (NULL, fontListEntry);
return fontList;
Fail:
return NULL;
}
XmFontList
FontStruct2FontList (XFontStruct * fontStructP)
{
XmFontListEntry fontListEntry;
XmFontList fontList = NULL;
// Create a font list entry from the font struct.
if (fontListEntry = XmFontListEntryCreate (XmFONTLIST_DEFAULT_TAG, XmFONT_IS_FONT, fontStructP))
{
// NULL indicates to create a new font list.
fontList = XmFontListAppendEntry (NULL, fontListEntry);
}
return fontList;
}
long
GetClockMSecs (void)
{
#define CLOCKS_PER_MSEC (CLOCKS_PER_SEC / 1000)
return clock() / CLOCKS_PER_MSEC;
}