File: multifixed.c

package info (click to toggle)
xbae 4.60.4-11
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,020 kB
  • sloc: ansic: 22,089; sh: 8,293; makefile: 522; tcl: 1
file content (186 lines) | stat: -rw-r--r-- 5,744 bytes parent folder | download | duplicates (7)
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
/*
 * AUTHOR: Jay Schmidgall <jay.schmidgall@spdbump.sungardss.com>
 *
 * $Id: multifixed.c,v 1.11 2005/03/17 21:16:48 tobiasoed Exp $
 */

#ifdef HAVE_CONFIG_H
#include <XbaeConfig.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#ifdef USE_EDITRES
#include <X11/Intrinsic.h>
#include <X11/Xmu/Editres.h>
#endif
#include <Xm/Label.h>
#include <Xbae/Matrix.h>

#define USE_RENDER_TABLE 0

static String fallback[] = {
	"Multifixed*mw.shadowType:		SHADOW_ETCHED_OUT",
	"Multifixed*mw.shadowThickness:		8",
	"Multifixed*mw.cellShadowThickness:	2",
	"Multifixed*mw.gridType:		GRID_CELL_LINE",
	"Multifixed*mw.cellShadowType:		shadow_in",
	"Multifixed*mw.visibleColumns:		2",
	"Multifixed*mw.visibleRows:		2",
	"Multifixed*mw.rows:			10",
	"Multifixed*mw.columns:			10",
	"Multifixed*mw.fixedRows:		2",
	"Multifixed*mw.fixedColumns:		2",
	"Multifixed*mw.trailingFixedRows:	2",
	"Multifixed*mw.trailingFixedColumns:	2",
	"Multifixed*mw.traverseFixedCells:	True",
	"Multifixed*mw.columnWidths:		10, 5, 10, 5, 10, 5,"
	"					10, 5, 10, 5, 10, 5",
	"Multifixed*mw.columnLabels:		Zero, One, Two, Three, Four,"
	"					Five, Six, Seven, Eight, Nine",
	"Multifixed*mw.rowLabels:		0, 1, 2, 3, 4, 5, 6, 7, 8, 9",
	#if USE_RENDER_TABLE
    "Multifixed*mw.renderTable: labels, italic, bold",
    "Multifixed*mw.renderTable.fontType:        FONT_IS_FONT",
    "Multifixed*mw.renderTable.fontName:        -*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*",
    "Multifixed*mw.renderTable.labels.fontType: FONT_IS_FONT",
    "Multifixed*mw.renderTable.labels.fontName: -*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*",
    "Multifixed*mw.renderTable.italic.fontType: FONT_IS_FONT",
    "Multifixed*mw.renderTable.italic.fontName: -*-helvetica-medium-o-*-*-10-*-*-*-*-*-*-*",
    "Multifixed*mw.renderTable.bold.fontType:   FONT_IS_FONT",
    "Multifixed*mw.renderTable.bold.fontName:   -*-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*",
    #else
    "Multifixed*mw.fontList:                    -*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*,"
    "                                           -*-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*=bold,"
    "                                           -*-helvetica-medium-o-*-*-10-*-*-*-*-*-*-*=italic",
    "Multifixed*mw.labelFont: -*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*",
    #endif
    #if 0
	"Multifixed*mw.cellShadowThickness:		1",
	"Multifixed*mw.textShadowThickness:		0",
	"Multifixed*mw.cellHighlightThickness:		0",
	"Multifixed*mw.cellMarginHeight:		0",
	"Multifixed*mw.cellMarginWidth:		1",
    #endif
	NULL
};

void
LoadMatrix(Widget w)
{
    String *cells[10];
    static String rows[10][10] = {
	{ "0,Zero", "0,One",  "0,Two",    "0,Three",  "0,Four",
	  "0,Five", "0,Six",  "0, Seven", "0, Eight", "0, Nine" },
	{ "1,Zero", "1,One",  "1,Two",    "1,Three",  "1,Four",
	  "1,Five", "1,Six",  "1, Seven", "1, Eight", "1, Nine" },
	{ "2,Zero", "2,One",  "2,Two",    "2,Three",  "2,Four",
	  "2,Five", "2,Six",  "2, Seven", "2, Eight", "2, Nine" },
	{ "3,Zero", "3,One",  "3,Two",    "3,Three",  "3,Four",
	  "3,Five", "3,Six",  "3, Seven", "3, Eight", "3, Nine" },
	{ "4,Zero", "4,One",  "4,Two",    "4,Three",  "4,Four",
	  "4,Five", "4,Six",  "4, Seven", "4, Eight", "4, Nine" },
	{ "5,Zero", "5,One",  "5,Two",    "5,Three",  "5,Four",
	  "5,Five", "5,Six",  "5, Seven", "5, Eight", "5, Nine" },
	{ "6,Zero", "6,One",  "6,Two",    "6,Three",  "6,Four",
	  "6,Five", "6,Six",  "6, Seven", "6, Eight", "6, Nine" },
	{ "7,Zero", "7,One",  "7,Two",    "7,Three",  "7,Four",
	  "7,Five", "7,Six",  "7, Seven", "7, Eight", "7, Nine" },
	{ "8,Zero", "8,One",  "8,Two",    "8,Three",  "8,Four",
	  "8,Five", "8,Six",  "8, Seven", "8, Eight", "8, Nine" },
	{ "9,Zero", "9,One",  "9,Two",    "9,Three",  "9,Four",
	  "9,Five", "9,Six",  "9, Seven", "9, Eight", "9, Nine" }
    };

    cells[0] = &rows[0][0];
    cells[1] = &rows[1][0];
    cells[2] = &rows[2][0];
    cells[3] = &rows[3][0];
    cells[4] = &rows[4][0];
    cells[5] = &rows[5][0];
    cells[6] = &rows[6][0];
    cells[7] = &rows[7][0];
    cells[8] = &rows[8][0];
    cells[9] = &rows[9][0];
    
    XtVaSetValues(w,
		  XmNcells,     cells,
		  NULL);
}

void
bold(XtPointer data)
{
    Widget mw = (Widget)data;

    static int row = 0;
    static int column = 0;
    int n_rows = XbaeMatrixNumRows(mw);
    int n_columns = XbaeMatrixNumColumns(mw);

    if (column % 2) {
            XbaeMatrixSetCellTag(mw, row, column, "italic");
    } else {
            XbaeMatrixSetCellTag(mw, row, column, NULL);
    }
    
    if (column < n_columns - 1) {
        column++;
    } else {
        column = 0;
        if (row < n_rows - 1) {
            row++;
        } else {
            row = 0;
        }
    }

    XbaeMatrixSetCellTag(mw, row, column, "bold");

    XtAppAddTimeOut(
	    XtWidgetToApplicationContext(mw), 200, (XtTimerCallbackProc)bold,
	    (XtPointer)mw);
}

int
main(int argc, char *argv[])
{
    Widget toplevel, mw;
    XtAppContext app;
    int row, column, n_rows, n_columns;
    
    toplevel = XtVaAppInitialize(&app, "Multifixed",
				 NULL, 0,
				 &argc, argv,
				 fallback,
				 NULL);
#ifdef USE_EDITRES
    XtAddEventHandler( toplevel, (EventMask)0, True,
                       _XEditResCheckMessages, NULL);
#endif

    mw = XtVaCreateManagedWidget("mw",
				 xbaeMatrixWidgetClass, toplevel,
				 NULL);

    LoadMatrix(mw);
    n_rows = XbaeMatrixNumRows(mw);
    n_columns = XbaeMatrixNumColumns(mw);

    for(row = 0; row < n_rows; row++) {
        for(column = 0; column < n_columns; column++) {
            if (column % 2) {
                XbaeMatrixSetCellTag(mw, row, column, "italic");
            }
        }
    }

    bold(mw);

    XtRealizeWidget(toplevel);
    XtAppMainLoop(app);

    /*NOTREACHED*/
        
    return 0;
}