Codebase list libcdk-perl / 6c4c2c3
[svn-upgrade] Integrating new upstream version, libcdk-perl (5.0) Jeremiah Foster 16 years ago
319 changed file(s) with 79265 addition(s) and 23189 deletion(s). Raw diff Collapse all Expand all
+1065
-38
CHANGES less more
0 -- $Id: CHANGES,v 1.4 2003/12/10 02:11:52 tom Exp $
1
2 2003/12/10 - Thomas Dickey <dickey@herndon4.his.com>
3 ====================================================
4 + eliminate most of fixed array limits.
5 + correct logic of sv2int(), etc., broken by 2002/07/28 changes.
6 + alter matrix interface to use setCDKMatrixCells() rather than
7 setCDKMatrix(), since the latter dumps core due to an addressing
8 limitation - an 8Mb struct might be too large.
9 + update to match struct-member changes in current CDK snapshot's
10 CDKSWINDOW struct.
11 + replace complex macros except MAKE_CHAR_MATRIX with functions, fix
12 several illegal memory references reported by valgrind.
13
14 2002/07/28 - Thomas Dickey <dickey@herndon4.his.com>
15 ====================================================
16 + change version number to correspond with Exporter.pm documentation.
17 + add a MANIFEST, drop 'FILES' since it is redundant.
18 + drop BUGS and NOTES since they are obsolete.
19 + add Cdk::getVersion() method.
20 + add a null-pointer check in sv2chtype(), needed for return-value from
21 char2Chtype(). Also changed this function to have a single return
22 point.
23 + add fixpaths script, to allow examples and demos to be run easily.
24 Just run fixpaths, and it will adjust the path to 'perl' in the
25 first line of each example-script.
26
27 2001/04/21 - Thomas Dickey <dickey@herndon4.his.com>
28 ====================================================
29 + correct include-path for cdk.h (reports by Pawel Gajda
30 <pawelg@obop.com.pl> and Ron Poulton <thok@technologist.com>)
31 + correct missing Box parameter of drawCDKMenu (Pawel Gajda).
32
33 2001/01/07 - Thomas Dickey <dickey@herndon4.his.com>
34 ====================================================
35 + modify to work with perl 5.6.0
36 + fix several places where functions did not return value.
37 + modify some scripts to show nonblank character, e.g., for slider.
0 Cdk Version Change List
1 Copyright Mike Glover, 1995, 1996, 1997, 1998, 1999
2 Modifications copyright Thomas E. Dickey 1999-2005, 2006
3 -------------------------------------------------------------------------------
4
5 This file outlines all of the changes/additions from one release to another.
6
7 2006/05/07
8 + reduce the number of calls on touchwin(), which is used mainly for
9 cleanup after moving a window.
10 + improve focus in alphalist.c and fselect.c to ensure that the
11 dependent scroll widget highlights data after losing focus to the
12 entry widget (report by Harry Brueckner).
13 + add getCDKScrollCurrentItem(), setCDKScrollCurrentItem(),
14 getCDKScrollCurrentTop() and setCDKScrollCurrentTop().
15 + add getCDKFselectCurrentItem(), setCDKFselectCurrentItem(), use these
16 in fselect_ex.c to illustrate how to modify list displayed by
17 the fselect widget.
18 + add getCDKAlphalistCurrentItem(), setCDKAlphalistCurrentItem(), use
19 these in alphalist_ex.c to illustrate how to modify list displayed by
20 the alphalist widget.
21 + add copyCharList(), copyChtypeList(), lenCharList(), lenChtypeList().
22 + fix misformatted cdk_display manpage, which did not show vINT
23 and some other data properly (report by Dominik Douville-Belanger).
24 + split-out cdk_display.c to eliminate repeated logic in entry.c,
25 matrix.c and mentry.c, and implement hidden fields for the matrix
26 widget.
27 + correct box-height for marquee widget. The box parameter was
28 previously ignored; this correction will make some applications no
29 longer show a box (report by Michael White).
30 + modify logic for KEY_DC and KEY_BACKSPACE so the former only deletes
31 the current character, and the latter only deletes the previous,
32 rather than equating them. This affects alphalist, entry, mentry,
33 template (request by Harry Brueckner).
34 + suppress conversion of control characters in getcCDKObject() if the
35 character is bound to another. This was last changed in 2004/8/24
36 (report by Harry Brueckner).
37 + add check in adjustAlphalistCB() in case the list is empty (report by
38 Harry Brueckner).
39
40 2006/02/20
41 + correct makefile dependency so $(MAN_DIR) and $(INCLUDE_DIR) are
42 created before headers.sed and manpage.sed, since headers.sh
43 relies on the existence of the destination directory (reports
44 by Marek Lipovean, Marcelo Goes, also Gentoo #123374).
45
46 2005/12/30
47 + add some redundant pointer checks, e.g., to entry.c, to avoid core
48 dump if one tries building Cdk with NetBSD curses (see lib/32417).
49 + split up traverseCDKScreen() to allow customized flavors of that to
50 be written in a calling application using the pieces:
51 traverseCDKOnce(), setCDKFocusFirst() (request by Jorgen Lundman).
52 + restore assignment of selectedItem in setCDKRadioCurrentItem() which
53 was dropped in 2005/04/24 (report by Fu Steve X).
54 + modify refreshCDKScreen() to ensure that only one widget will have
55 focus, i.e., the first which currently has focus, or if none, then
56 the first visible one (report by Fu Steve X).
57 + use cleanCDKTemplate() consistently in the template widget, ensuring
58 that the editing position is updated, and that the proper length is
59 used when clearing memory (report by Fu Steve X).
60 + modify calendar, radio, scroll, selection widgets so the cursor is
61 shown at the beginning of the selected item's row for better
62 accessibility (report by Fu Steve X).
63 + add null-pointer check in setCDKViewerInfo() in case caller gives
64 too-large value for list size (report by Jorgen Lundman).
65 + improve traverseCDKScreen() by updating curobj from the
66 getCDKFocusCurrent() function (patch by Jorgen Lundman).
67 + add setCDKFocusCurrent() (patch by Jorgen Lundman).
68 + add configure script option allowing manpage section to be changed
69 from "3" to other values such as "3CDK", e.g., for Debian.
70 + modify getCDKRadioItems(), getCDKScrollItems() and
71 getCDKSelectionItems() to return just the list-size if the list
72 pointer is null.
73 + correct highlighting of selected line in CDKSelection window when
74 the window is scrolled left/right (patch by Jorgen Lundman).
75 + various manpage fixes (report by Jorgen Lundman).
76 + change manpages to use ".XX" macro to indicate aliases, to make
77 the manpage more readable.
78 + eliminate duplication between cdk_util.3 and cdk_misc.3 manpages
79 (dialogs belong in the former, for instance).
80 + modify alphalist, itemlist, radio, selection and swindow to allow
81 creating a widget with an empty list (request by Harry Brueckner).
82 + modify mentry.c case for KEY_RIGHT so one can move the cursor past
83 the end of the string to add new text (report by Harry Brueckner).
84 + modify cdk_params.c to use strtol() rather than atoi() to allow
85 command-line parameters such as -h 0xffff for the slider examples.
86 + modify gen-slider.c to use sprintf/strlen to obtain length of
87 formatted integer types since intlen() does not give correct result
88 for maximum value of unsigned type. Modify increment/decrement logic
89 to take into account unsigned types (report by Keith J Outwater).
90 + modify cli examples to exit with 255 when reporting an error rather
91 than a -1 which is generally not portable.
92 + fix several memory leaks exposed by valgrind in the example programs.
93 + add configure --disable-leaks option to look for ncurses' debug
94 function _nc_free_and_exit(), using that to help with memory leak
95 checking. This uses a new header <cdk_test.h> which will not be
96 installed, since it is used only for testing in the build tree.
97 > patches by Phuah Yee Keat:
98 + add an IsVisibleObj attribute to all CDK objects so the caller can
99 set some object to be invisible, and calling refreshCDKScreen
100 after that won't display it again, it enables one to dynamically
101 show or hide a particular widget based on user actions.
102 Note: this changes alignments in many of the structs from 5.0,
103 requiring an ABI bump.
104 + improve string length-computation in entry.c, allowing a 1-char
105 field, and also allowing movement past end of text with KEY_END.
106 + add setCDKRadioSelectedItem() and getCDKRadioSelectedItem().
107 + fix some memory leaks by adding cleanCDKObjBindings() into all of
108 the _destroyXXX() functions, modify cleanCDKObjBindings() to free
109 and null (obj)->bindingList.
110 + fix makefile for installing manpages when building outside of the
111 source directory (patch by Mike Castle).
112 + remove obsolete lsm file
113 + review/correct some functions listed in manpages but not implemented,
114 and the reverse (report by Rajat Das).
115 + add setCDKMatrixCB() (report by 'zam).
116 + update configure script (mostly fixes related to CF_XOPEN_SOURCE).
117 + update config.guess, config.sub
118
119 2005/04/24 - T.E.Dickey <dickey@his.com>
120 + bump major version to 5 (overdue).
121 + add built-in bindings for '<' and '>' to KEY_HOME and KEY_END
122 for radio.c, scroll.c, selection.c, swindow.c and viewer.c
123 (patch by Thorsten Glaser).
124 + add manpages for some of the non-widget utilities:
125 cdk_compat.3, cdk_objs.3, cdk_params.3 and cdk_util.3
126 + correct drawCDKTitle, which did not account for border-size in
127 vertical position of titles.
128 + change addCDKScrollPosition() to not set the current item to the
129 beginning of the list.
130 + add insertCDKScrollPosition(), to allow insertions before the current
131 item.
132 + add a check in scroll.c to prevent overflow if the list is empty.
133 + modify deleteCDKScrollItem() to ensure the current item is on a
134 valid position after the deletion.
135 + modify setCDKScrollPosition() to avoid scrolling if the target is
136 already on the screen.
137 + make similar simplifications to radio.c and selection.c as in scroll.c
138 + simplify and make consistent bookkeeping in scroll.c using new
139 utility functions. As a result, addCDKScrollItem() and
140 deleteCDKScrollItem() update the size of the scrollbar toggle (report
141 by Fu Steve X).
142 + improve resequence function from 2005/03/23 by preserving attributes
143 in the target chtype array.
144 + modify scroll_ex.c, binding 'a', 'i' and 'd' to add, insert and
145 delete lines respectively (adapted from example by Fu Steve X).
146 + modify makefile so that cdk_config.h (which is generated by the
147 configure script) is not removed by "make clean".
148 + modify makefile to work around limitation of Solaris make program
149 which was confused by a header dependency in a "::" line (report by
150 Fu Steve X).
151 + modify makefile and scripts for configure --srcdir (adapted from
152 patch by Mike Castle).
153
154 2005/03/23 - T.E.Dickey <dickey@his.com>
155 + modify deleteCDKScrollItem() to resequence numbers (request by Fu
156 Steve X).
157 + cleanup memory allocation in scroll.c, make addCDKScrollItem
158 reallocate the scroll widget's arrays (report by Fu Steve X).
159
160 2005/03/08 - T.E.Dickey <dickey@his.com>
161 + correct logic of deleteCDKScrollItem(), which did not preserve the
162 final null-pointer at the end of the list (report by Fu Steve X).
163 + add isCDKOBjectBind() to simply check if the given object/key
164 combination is bound, rather than invoke the bound function.
165 + modify binding.c so that all of the functions share the same logic
166 for mapping the given object to the bindable object, e.g., the entry
167 widget for alphalist and fselect composite widgets. In particular,
168 checkCDKObjectBind() and getcCDKObject() did not use the same binding
169 data.
170 + correct initialization of traverseCDKScreen(), which required two
171 tab keypresses to make the first traversal (report by Fu Steve X).
172 + update configure script checks for _XOPEN_SOURCE, etc.
173 + updated config.guess and config.sub
174 + correct prototype shown in manpage for setCDKScroll() (report by
175 Stefan Heimann).
176 + correct equivalent expressions in setCDKRadioItems() and
177 setCDKSelectionItems().
178 + correct expression in setCDKScrollItems() which caused the updated
179 window to shrink by 2 lines (report by Stefan Heimann).
180
181 2004/12/24 - T.E.Dickey <dickey@his.com>
182 ========================================
183 + correct expression in CDKCalendarField from 2004/08/31 changes, which
184 caused it to show only 6 days/week, broken by a fix for
185 demos/appointment (reports/patches by Ryan Flannery and Greg Martin).
186
187 2004/11/07 - T.E.Dickey <dickey@his.com>
188 ========================================
189 + correct top-level Makefile.in to remove libtool's auxiliary files
190 in the "make clean" rule.
191 + amend simplification of writeCharAttrib(), ensuring that attributes
192 passed in the chtype-string are not ignored (report by Benoit
193 Bidoggia).
194
195 2004/10/04 - T.E.Dickey <dickey@his.com>
196 ========================================
197 + correct logic of writeBlanks(), which did not check for malloc
198 failure and made an unnecessary call to freeChar().
199 + simplify draw.c a little by using writeCharAttrib() and
200 writeChtypeAttrib() to implement writeChar() and writeChtype().
201 + revert 2002/07/27 change that used waddchnstr() in writeChtype(),
202 since it does not render control characters (report by Mike Leib).
203 + fix an infinite loop in viewer.c when displaying control characters
204 such as form-feed.
205
206 2004/08/31 - T.E.Dickey <dickey@his.com>
207 ========================================
208 + add a simple compatibility header (cdk_compat.h), which can be
209 put in an application's include-path when compiling old applications
210 against new/old Cdk.
211 + update libtool ABI to 2.0.0 since several items are added to CDKOBJS,
212 as well as cleanup of slider- and scale-header templates.
213 + add check for ANSI compiler, needed for example with HPUX 10.20.
214 + ifdef'd out nonfunctional saveData and refreshData methods of entry
215 and itemlist widgets.
216 + moved functions for setting background color or attribute into
217 CDKOBJS.
218 + moved pre- and post-processing data into CDKOBJS, changing the
219 functions that set those per-widget into macros using cdk_objs.c
220 + modify scale and slider widgets to allow the user to directly modify
221 the value by typing over it (request by Keith Outwater).
222 + add slider widgets for types float, unsigned.
223 + add scale widgets for types double, unsigned.
224 + add script gen-scale.sh, and templates (e.g., gen-scale.c,
225 gen-scale.h) to allow easy generation of scale and slider widgets of
226 various types. Use this to replace the existing CDKSCALE, CDKFSCALE,
227 CDKSLIDER widgets (discussion with Keith Outwater).
228 + adapt fix from dialog for porting getmaxx(), etc., to systems such
229 as HPUX which do not provide these legacy definitions.
230 + remove duplicate vinstall.c from examples directory.
231 + modify install scripting to translate generated names in cdk_config.h
232 to add "CDK_" prefix to most, reducing name-pollution. These names
233 are used to allow applications to compile against the Cdk header
234 files, but are otherwise of no general interest. In particular,
235 "PACKAGE" is no longer conflicting (report by Phuah Yee Keat).
236 + add earlyExit member to CDKOBJS, using this to implement a method
237 for applications to specify whether the widget's exitType should
238 be modified after calling checkCDKObjectBind(), and what value
239 (discussion with Bernhard Walle, comparing with NetBSD variation).
240 + correct logic in calendar widget for decrementing day- and
241 month-values.
242 + modify treatment of exitType field so it is only set to vESCAPE_HIT
243 if an escape character was received. Hide most of the internal
244 details of exitType, making it available as an object value (but
245 retaining the widget field to ease upgrading old applications).
246 + implement shadow option for newCDKMarquee().
247 + rewrite activateCDKMarquee(), eliminating an infinite-loop bug
248 found in traverse_ex.c, as well as making it work properly with and
249 without box-outline.
250 + modify deleteCursesWindow() to call eraseCursesWindow(), so that
251 deleting an object will also erase it, following the various manpages
252 comment about removing the object from the screen (report by
253 Mukovoz I.S.).
254 + correct positionCDKObject() for CDKSCREEN's which do not happen to
255 be the same size/shape as stdscr.
256 + change layout of menus to account for parent window's origin
257 since subwin() since uses absolute screen position (report by "Anna"
258 w/o a return address).
259 + correct off-by-one in positionCDKObject() which prevented user from
260 reaching the right- and bottom-margins.
261 + fix a few limits on sprintf's involving strings.
262 + eliminate fixed array limit MAX_OBJECT in CDKSCREEN.
263 + use CTRL() macro consistently in preference to CONTROL().
264 + remove delwin(stdscr) from example programs since it is both unneeded
265 and nonportable.
266 + use EXIT_SUCCESS and EXIT_FAILURE consistently in example programs.
267 + remove all KEY_xxx symbols which are in X/Open curses from curdefs.h
268 + remove all ACS_xxx symbols from curdefs.h
269 + remove all A_xxx symbols from curdefs.h
270 + add/use isChar() and CharOf() macros to get rid of A_CHARTEXT usage.
271 + fix menus to allow them to scroll if there are too many entries to
272 fit on the screen.
273 + collect most uses of touchwin/refresh into new function
274 refreshCDKWindow().
275 + clear background of menu windows, in case they are drawn over another
276 widget.
277 + correct length of title in menu if more than one is placed on the
278 right side of the screen.
279 + add getcCDKBind() function, to which keys can be bound for simple
280 translation of the inputs via getcCDKObject(). Use this in
281 examples/traverse_ex.c to bind F1 to menu.
282 + eliminate mapChtype() function, since it could conflict with curses'
283 definitions. Use the given key value instead, since it is always
284 positive.
285 + use KEY_MAX in preference to MAX_BINDINGS symbol.
286 + eliminate internal use of literal backspace, DEL, tab, newline and
287 carriage-return constants, etc., by mapping them to KEY_BACKSPACE,
288 KEY_DC, KEY_ENTER, etc., in getcCDKObject().
289 + modify examples and demos to read input using getcCDKObject(), to
290 solve problems with stdscr refresh overwriting the widgets.
291 + modify matrix.c and menu.c to read input using getcCDKObject(), like
292 all of the other widgets.
293 + rewrote examples/traverse_ex.c to use menus to select the left,
294 center and right widgets used for demonstrating traversal.
295 + modify traversal to update object focus properly if a menu action
296 removes or moves the object associated with the focus.
297 + cleanup menu in traverse.c if escape character is used to cancel it.
298 + move curs_set() calls out of focus/unfocus functions, into traverse.c
299 + remove the SIGBUS/SIGSEGV handler, since it is redundant.
300 + updated configure script (CF_ADD_CFLAGS, CF_CHECK_CACHE,
301 CF_GCC_WARNINGS, CF_NCURSES_LIBS, CF_PROG_EXT, CF_WITH_DBMALLOC,
302 CF_WITH_DMALLOC, CF_WITH_LIBTOOL, CF_WITH_WARNINGS, CF_X_ATHENA,
303 CF_X_TOOLKIT).
304 + updated config.guess, config.sub
305 > patches by ewigg (Ed Wigg?) for fselect.c:
306 + add a range check to ensure that filename completion at the end of
307 the list does not reference past the end of the list.
308 + correct the value returned from filename completion (fixes in
309 2002/07/27 mistook an assignment that removed the last character
310 of the result - it is actually used to trim the "/", "@" or similar
311 character from the displayed filename).
312 + remove an unnecessary if statement.
313 > patches by Phuah Yee Keat:
314 + enable focus in mentry.c, radio.c
315 + implement unfocus in entry.c
316 + implement focus/unfocus in mentry.c, template.c
317 + add setCDKRadioCurrentItem() and getCDKRadioCurrentItem().
318 + improve entry.c: When the user types until the last character, do
319 not shift the cursor to one character beyond the end of the maximum
320 value allowed in the field, that will create an extra '.' that will
321 give the user an impression that he can still enter more characters,
322 when he actually can't.
323 + fix two core dumps with Solaris curses in scroll.c:
324 + On solaris curses, just pressing the "down" key on a scroll list
325 will coredump, on certain sizes of the scroll list. On my
326 fullscreen test, it will coredump on any number of items unless if
327 the number of items is a multiple of 5. I assume that it's because
328 that under certain conditions, the togglePos actually exceeds the
329 boundary at the end of the scroll bar. Does not happen in ncurses.
330 + On solaris curses, press 'G' will coredump.
331 Does not happen in ncurses.
332 + make wording in COPYING consistent with other fixes from 1999/05/15
333 (report by Ahmad Attia).
334
335 2003/12/10 - T.E.Dickey <dickey@his.com>
336 ========================================
337 + bump version to 4.9.11 (corresponding source from Mike Glover added
338 install.sh to tarball; no other source changes were made).
339 + rename "install.sh" to "install-sh" to work around bugs in certain
340 make-programs.
341 + allocate marker[] array in calendar dynamically. Reduce
342 corresponding array limits to reasonable values.
343 + add getCDKCalendarMarker()
344 + correct seconds in calendar's return value.
345 + eliminate fixed array limits from dialog widget.
346 + eliminate fixed array limits from label widget.
347 + eliminate fixed array limits from selection widget.
348 + eliminate fixed array limits from viewer widget.
349 + eliminate fixed array limits from buttonbox widget.
350 + eliminate fixed array limits from matrix widget. Passing around
351 1000x1000 arrays was inefficient, and caused core dumps in the Perl
352 binding for this widget.
353 + correct one of the attrbox() calls in drawCDKMatrixCell(), which used
354 a left-tee where a right-tee was needed (report by William L Davis).
355 + add setCDKMatrixCells(), redefining setCDKMatrix() as a macro to
356 call it.
357 + add cleanCDKMatrixCell().
358 + correct position for right-aligned menus, which was off by one from
359 2003/11/30 changes (report/patch by William L Davis).
360
361 2003/12/01 - T.E.Dickey <dickey@his.com>
362 ========================================
363 + correct logic in char2Chtype() for <#UL>, <#UR> and <#LR>, broken in
364 1999/06/05 (report by William L Davis).
365
366 2003/11/30 - T.E.Dickey <dickey@his.com>
367 ========================================
368 + remove borderSize parameter from alignxy().
369 + modify all widgets to account for borderSize consistently, allowing
370 one to display a widget that uses the full screen size (report by
371 Phuah Yee Keat <yk.phuah@nestac.com>).
372 + add cdk_params.c, use this to simplify cli programs and add getopt
373 processing systematically to the demos and examples.
374 + correct an off-by-one in baseName() that would return the slash
375 character in the result.
376 + add setCDKCalendarMonthsNames() and setCDKCalendarDaysNames (patch
377 by Stanislaw Bierowka <staszek@pecet.com.pl>).
378 + split-out several files from draw.c since they are wrappers for
379 widgets rather than drawing functions. Doing this reduces the
380 executable size: get_index.c, get_string.c, popup_dialog.c,
381 popup_label.c, select_file.c, view_file.c and view_info.c
382 + eliminate static MAX_LINES limit from graph-widget values.
383 + eliminate static MAX_LINES limit from widget titles.
384 + updated configure script, improved checks for curses functions.
385 + updated config.guess, config.sub
386
387 2003/11/24 - T.E.Dickey <dickey@his.com>
388 ========================================
389 + display a "processing..." message in setCDKViewerInfo while building
390 the internal data structures (request by Mike Leib).
391 + modify viewer widget to compute the total number of lines to display,
392 making it independent of the listSize parameter.
393 + modify viewer widget to accept a negative listSize parameter,
394 making it count the length of list[], ending with a null.
395 + modify viewer_ex, adding -f, -i and -l options. The -f option
396 bypasses the fselect widget, specifying the filename directly.
397 The -i option tells whether to interpret embedded markup, and
398 the -l option tells viewer_ex to load the file using an embedded
399 link.
400
401 2003/11/19 - T.E.Dickey <dickey@his.com>
402 ========================================
403 + modify searches in viewer widget to allow for overlapping partial
404 matches, e.g., if the pattern is "00A", it will find the match in
405 a line consisting of "000A". Also corrected logic to matches can
406 extend to the end of a line.
407 + add 'N' to viewer to implement reverse search.
408 + modify ':' command in viewer to start with current line number
409 rather than 0. Also adjust the size of the scale widget to allow
410 for very large line numbers, e.g., more than 5 digits.
411 + remove an obsolete limit-check in viewer widget that limited view
412 to 4996 lines, fix a few off-by-one indices.
413
414 2003/11/18 - T.E.Dickey <dickey@his.com>
415 ========================================
416 + correct viewer widget, making it interpret tabs and non-printing
417 characters for the non-interpreted file viewer case. The curses
418 library cannot display control characters in chtype's.
419 + add cleanCDKViewer().
420 + rename a few .itemCount members to .listSize for consistency.
421 + eliminate static list-size limit MAX_LINES from swindow, viewer
422 widgets. Renamed .info, .infoPos, .infoLen to .list, .listPos and
423 .listLen members to be consistent with other widgets.
424
425 2003/11/16 - T.E.Dickey <dickey@his.com>
426 ========================================
427 + suppress "." from fselect listing, since it was not useful.
428 + eliminate static list-size limit MAX_ITEMS from alphalist, fselect
429 itemlist, radio, scroll and selection widgets (request by Mike Leib).
430 + change functions that set line-drawing characters to macros, mapping
431 those to method calls in CDKOBJS.
432 + add setCDKEntryBox().
433 + add setCDKMarqueeBox() and getCDKMarqueeBox().
434 + add setCDKMatrixBox() and getCDKMatrixBox().
435 + adjust some title lines to be offset by the borderSize rather than
436 a hardcoded "1" (report by Max Mikhanosha).
437 + strip trailing newlines from text read via pipe in execCDKSwindow(),
438 lost in original cleanup (report by Max Mikhanosha
439 <max@openchat.com>).
440
441 2003/04/18 - T.E.Dickey <dickey@herndon4.his.com>
442 =================================================
443 + for variants built with ncursesw and pdcurses, name the libraries
444 "-lcdkw" and "-lcdkX" respectively.
445 + add a missing assignment to store the result in _injectCDKFScale()
446 (report by Barry Davis <bdavis@eurologic.com>).
447 + fix missing definition of mvwhline(), mvwvline() in pdcurses.
448 + add a .c.i rule in top-level makefile
449 + fix uninstall rule, was missing a line-continuation.
450 + fix several prototypes in manpages which did not match header files
451 (reported by Lucas Gonze <lucas@gonze.com>).
452 + fix a few compiler warnings, e.g., by parentheses in
453 drawCDKEntryField() and drawCDKMatrixCell().
454 + updates to configure script macros
455 + add --with-ncursesw option.
456 + add --with-XawPlus option.
457 + add --with-curses-dir option.
458 + modify CF_DISABLE_ECHO to make libtool quiet also.
459 + use AC_PROG_PATH to find libtool; show the version which is found.
460 + change sed delimiter to '%' to accommodate AFS.
461 + improve/correct CF_HEADER_PATH, CF_LIBRARY_PATH to cover special
462 cases of ncurses/ncursesw configurations.
463 + change ordering of options in CF_ADD_CFLAGS, CF_ADD_CPPFLAGS,
464 CF_INCLUDE_DIRS.
465 + workaround gcc 3.x defects in CF_ADD_INCDIR.
466
467 2002/08/09 - T.E.Dickey <dickey@herndon4.his.com>
468 =================================================
469 + fix entry, matrix, template, viewer widgets to display 8-bit input
470 characters (reported by Bernhard Walle <bernhard@bwalle.de>).
471 + modify manpage install to create links for each function name listed
472 in the NAME section.
473 + correct cursor location in dialog's radio-box, which was left on the
474 separator line (reported by Peter Farley <pjfarley3@yahoo.com>)
475
476 2002/07/27 - T.E.Dickey <dickey@herndon4.his.com>
477 =================================================
478 + several changes to make destroyCDKScreenObjects() and
479 destroyCDKScreen() actually work (needed for perlcdk):
480 + record all objects and screens created/destroyed, in cdkscreen.c
481 + reimplement destroyCDKObject() by a function _destroyCDKObject(),
482 which first does an erase for the given object, then calls the
483 destroy method, and finally frees the object.
484 + add a check in each erase-method to ensure that the object is still
485 valid.
486 + add check in setCDKGraphValues() to ensure that X and Y scales are
487 nonzero, since they are used as denominators. This makes perlcdk's
488 graph example work.
489 + add configure check for curses feature which would allow one to move
490 a subwindow, or (in the case of NetBSD curses) at least compile.
491 + add configure check and fallback for addchnstr() to accommodate
492 NetBSD's partial implementation of curses.
493 + move version information to VERSION file.
494 + add --with-libtool configure option
495 + make most wgetch() calls use the object's inputWindow via the
496 getcCDKObject() function.
497 + improve type-checking and array-limits in cdkscreen.c
498 + remove cdktype member from CDKSCREEN since it is redundant.
499 + eliminate several fixed-buffers with new function writeBlanks().
500 + interpret home/end keys in entry widget.
501 + warn about special keys such as insert which are not recognized in
502 alphalist, entry, matrix, mentry, template (it was using the low 8
503 bits of those, inserting that).
504 + rewrote/simplified dirName().
505 + rewrote/simplified baseName().
506 + eliminate fixed-size buffers in fselect.c
507 + correct a couple of places where fselect.c freed constant memory.
508 + correct an unterminated string in fselect.c tilde-expansion, and use
509 $HOME if no account name is given.
510 + simplified several functions using mvhline(), mvvline() and
511 mvaddchnstr().
512 + add vFSCALE as a valid object type in cdkscreen.c
513 + modify moveCursesWindow(), which did not work with ncurses after
514 2000/9/15 changes to use mvwin() in preference to directly modifying
515 the _begx/_begy members of WINDOW. That made position_ex not work.
516 The change was originally for NetBSD's curses implementation which
517 does not move derived windows properly anyway.
518 + simplify calls to moveCursesWindow() by moving null-pointer check
519 inside that function.
520 + change tab-expansion in char2Chtype() to expand based on the current
521 length of the string rather than always to 8 columns.
522 + correct limit-checks in stripWhiteSpace()
523 + interpret back-tab in buttonbox.c and dialog.c inject-methods for
524 symmetry with tab.
525 + corrected return-values of button, matrix, scale widgets to match
526 documentation as well as to conform with other widgets.
527 + reorganized inject methods (which may return data of different types)
528 to return the actual data in an area of the widget, and defined macros
529 to preserve source-compatibility.
530 + rewrote initCDKColor() to check if color is available before trying
531 to initialize it, and to use the terminal's actual number of colors
532 in making color pairs.
533 + use 2-digit fields in bind_ex.c for time, date.
534 + modify matrix.c to add borderSize before the column titles, to
535 match the change to box layout.
536 + modify matrix_ex.c to consistently center row-titles. Some were
537 centered, some were right- and some left-justified. The change to
538 justifyString() produced an odd effect.
539 + add functions
540 CDKVersion()
541 chtype2String().
542
543 > patches by Tim Moloney:
544 + added a setCDKxxxBackgroundAttrib() function to all the widgets.
545 This function takes a chtype. The setCDKxxxBackgroundColor() still
546 exists and converts from a character string to a chtype, but it now
547 calls the new function to eliminate duplicate code.
548 + fix minor bugs in marquee_ex and radio1_ex.
549 + fix an off-by-one error in the dialog widget when it is not drawing
550 its box. The buttons were displayed one line too high.
551 + add object type to each widget.
552 + correct _drawCDKEntry(), which did not account for whether a box was
553 used when computing layout.
554 + change moveCDKButton() from a function to a macro using
555 moveCDKObject().
556 + add functions
557 popupLabelAttrib()
558 setCDKButtonboxButtonAttrib()
559 setCDKEntryHighlight()
560
561 > integrated/adapted changes by Grant Edwards:
562 + make the destroy function in each widget a method in CDKOBJS.
563 + make the inject function in each widget a method in CDKOBJS.
564 (this was incomplete, and did not provide for different return-types)
565 + add focus, unfocus, refreshData, saveData methods and supporting
566 data to CDKOBJS (not all widgets implement these methods). See
567 entry.c, itemlist.c, selection.c for example.
568 + store a borderSize value in CDKOBJS for each widget, which is used to
569 reserve space for a box/border around each widget if the Box
570 parameter is true when creating the widget. Several related changes
571 also made, including modifying the alignxy() interface to add
572 a borderSize parameter.
573 + modify justifyString() to not subtract 1 on each side, since that
574 is generally assumed to be done to compensate for boxes drawn around
575 the text.
576 + change drawCDKItemlistField() to add a highlight parameter.
577 + change the label window to a subwin() in entry.c
578 + hide cursor while in popupLabel() function.
579 + simplified scroll.c, a little.
580 + add files
581 button.c
582 examples/radio1_ex.c
583 examples/traverse_ex.c
584 + added functions:
585 destroyCDKScreenObjects()
586 getCDKSelectionCurrent()
587 setCDKSelectionCurrent()
588 getCDKScrollCurrent()
589 setCDKScrollCurrent()
590 destroyCDKScreenObjects()
591 cmpStrChstr()
592 chstrncpy()
593 + removed these functions:
594 setCDKEntryBox()
595
596 2002/04/30 - T.E.Dickey <dickey@herndon4.his.com>
597 =================================================
598 + correct parsing of <I=xx> in char2Chtype() where "xx" contains digits
599 (patch by Robert R Landon <rl180001@exchange.DAYTONOH.NCR.com>).
600 + updated cdk.spec for RPM (patch by Vladimir Kondratiev
601 <vladimir.kondratiev@intel.com>).
602 + introduce CDKINCLUDES ifdef's so that any of the header files may
603 be included separately. Previously only <cdk.h> could be included
604 due to interdependencies among the headers.
605 + add some #undef's to cdk.h in case curses.h includes term.h producing
606 a symbol conflict (reported by Kenneth Pronovici
607 <pronovic@skyjammer.com>).
608 + miscellaneous updates to configure script, including workarounds for
609 incompatibilies in autoconf 2.5x.
610
611 2002/02/25 - T.E.Dickey <dickey@herndon4.his.com>
612 =================================================
613 + add cdk_process manpage.
614 + remove redundant description of bindCDKObject() from several manpages.
615 + add rcs identifiers to header files.
616 + add ifdef's in each header file for C++, to make the C externs link
617 properly without requiring the application to declare them (reported
618 in comp.unix.programmer newsgroup by <bigslick_2k@hotmail.com>).
619 + correct typo in template.c introduced in 2000/01/16 substitutions
620 to use macro isPlateChar() which made templates not work with
621 interspersed punctuation (reported by jiny <jiny@ynmail.com>).
622
623 2001/12/30 - T.E.Dickey <dickey@herndon4.his.com>
624 =================================================
625 + remove some redundant wrefresh() calls in various widgets.
626 + correct an uninitialized pointer in cli/cdkalphalist.c
627 + modify cli/samples/alphalist.sh to check for non-empty return from
628 the selection rather than hang attempting to find that account.
629 + remove -B option from cli/samples/alphalist.sh since it should have a
630 value, but does not.
631 + corrected some display-limits in writeChtype() and
632 writeChtypeAttrib().
633 + modify CDKreadFile() to trim newlines from file as read, making it
634 more like the original readFile(). This is needed to prevent the
635 trailing newlines loaded into label widgets from clearing the rest
636 of the line when they are drawn.
637 + add floatized-scale widget (Lutz Mueller <urc8@rz.uni-karlsruhe.de>).
638 + modify headers.sh script to remove gzip'd versions of the manpages
639 just in case some were previously installed that way, i.e., by
640 hand. The gzip'd version would be found instead of the new install.
641 (prompted by a report by Ron Poulton <thok@technologist.com>).
642 + correct typo in uninstall rule for manpages which made
643 "make installCDKHeaderFiles" remove the manpages after installing.
644
645 2001/04/21 - T.E.Dickey <dickey@herndon4.his.com>
646 =================================================
647 + add an uninstall rule.
648 + move the installed documentation to /usr/local/doc/cdk (it does not
649 belong in /usr/local/include/cdk).
650 + modify install rules so that references to header files such as cdk.h
651 are transformed to <cdk/cdk.h>, which matches the actual install
652 location (reports by Pawel Gajda <pawelg@obop.com.pl>, Carlos Alberto
653 Pereira Gomes <capgomes@usa.net> and Ron Poulton
654 <thok@technologist.com>, who found that Cdk's menu.h conflicts with
655 ncurses' menu.h when building the Perl interface).
656 + correct cli examples' callbacks, which did not return a value.
657 + update config.guess and config.sub
658 + modify CF_CURSES_LIBS to allow build with SunOS 4.x 5lib curses.
659 + split out CF_CURSES_CPPFLAGS from CF_CURSES_LIBS to allow an interim
660 check if the curses implementation is really ncurses.
661 + modify some configure script macros to work when the curses header
662 file is not <curses.h>, e.g., <ncurses.h>.
663 + modify configure script macros to avoid using changequote(), which
664 is broken in the current autoconf alpha versions, e.g., 2.49d.
665 + change configure script macros to use $CPPFLAGS consistently for
666 preprocessor options, and $CFLAG for other compiler flags.
667 + modify several configure script macros which checked for $GCC, to
668 ensure it is not actually the compiler name versus an existence
669 check.
670
671 2001/01/06 - T.E.Dickey <dickey@herndon4.his.com>
672 =================================================
673 + reverted part of 1999/6/5 change, allowing callback functions to
674 return a value. Note that this makes PROCESSFN and BINDFN use
675 the same prototype (report by Ian Eure <ieure@insynq.com>).
676 + SCO OpenServer does not define S_IFSOCK
677
678 2000/09/23 - T.E.Dickey <dickey@herndon4.his.com>
679 =================================================
680 + change literal 48's in calendar.c to '0'.
681 + eliminate nonprinting/nonspace characters using macro CTRL().
682 + integrated new examples into makefiles.
683 + use raiseCDKObject_ex.c and lowerCDKObject_ex.c to debug/fix the
684 raiseCDKObject() and lowerCDKObject() functions which shared the same
685 defect in 4.9.9 (the code did not properly update two objects, but
686 modified screenIndex of one twice).
687 + modified cli programs to work with CDKreadFile(), CDKsplitString()
688 and CDKcountStrings() since readFile() and splitString() are not
689 provided in this version.
690
691 > reviewed/integrated changes from Mike Glover's 4.9.10 (August 2000):
692 + add examples/raiseCDKObject_ex.c, examples/lowerCDKObject_ex.c
693 + add cli subdirectory
694 + modify itemlist.c to make labels one cell wider.
695 + did not use changes to cdkscreen.c (see 1999/5/15).
696 + did not use casts to unsigned char, since those are incorrect
697 (they are casting chtype's which are wider than a char).
698
699 2000/09/15 - T.E.Dickey <dickey@herndon4.his.com>
700 =================================================
701 + add/use configure check for some curses functions/macros which use
702 internals of the WINDOW struct, which is opaque on NetBSD (patch by
703 Simon Burge <simonb@wasabisystems.com>).
704 + update autoconf scripts (config.guess, config.sub, macros
705 CF_CURSES_LIBS, CF_UPPER, CF_X_ATHENA) to my 20000819 autoconf patch.
706 + revised man-pages: reorder so that functions are listed
707 alphabetically within the NAME, SYNOPSIS, DESCRIPTION sections, the
708 prototypes shown only in the SYNOPSIS section (and formatted for
709 readability), remove excess wording and convert as needed to use tbl.
710
711 2000/08/28 - T.E.Dickey <dickey@herndon4.his.com>
712 =================================================
713 + add cdk_position.3 man page.
714 + rename cdk_cdk.3 to cdk.3
715
716 2000/08/20 - T.E.Dickey <dickey@herndon4.his.com>
717 =================================================
718 + remove obsolete comments from manpages telling users to define
719 NCURSES for that library. The configure script creates cdk_config.h,
720 which has settings as needed.
721
722 2000/08/20 - T.E.Dickey <dickey@herndon4.his.com>
723 =================================================
724 + fix some array-overruns in viewer.c if it happens to load a binary
725 file.
726 + fix symbol conflict with newkey in waitCDKLabel(), as well as keycode
727 truncation in that function.
728
729 2000/06/28 - T.E.Dickey <dickey@herndon4.his.com>
730 =================================================
731 + add RPM spec-file (Wai-Sun Chia <waisun.chia@msa.dec.com>).
732 + add Linux-specific makefile rule for generating a shared library
733 (patch by Pawel Gajda <pawelg@obop.com.pl>).
734 + eliminate fixed-length lists assumed in getDirectoryContents() using
735 new function CDKgetDirectoryContents().
736 + eliminate fixed-length lists assumed in readFile() using new function
737 CDKreadFile().
738 + remove unused substring().
739 + use qsort-wrapper sortList() instead of quickSort().
740 + change configure.in to avoid having configure script check for X
741 libraries as a side-effect of adding tests for PDCurses.
742 + updates to configure script macros:
743 CF_CURSES_FUNCS, CF_FIND_LIBRARY, CF_HEADER_PATH, CF_LIBRARY_PATH,
744 CF_NCURSES_LIBS and CF_XOPEN_CURSES
745 + updated config.guess, config.sub
746
747 2000/04/09 - T.E.Dickey <dickey@clark.net>
748 ==========================================
749 + modify newwin() call in subwindow_ex.c to account for actual screen
750 size rather than assuming 25 lines (reported by Gary Funck
751 <gary@Intrepid.Com>).
752 + add CF_X_ATHENA and CF_X_TOOLKIT configure macros for --with-pdcurses
753 option, needed if the Xcurses or dependent libraries are static
754 rather than shared.
755 + correct typo in configure check for HPUX 11.x (reported by Bjorn
756 Helgaas <helgaas@rsn.hp.com>).
757
758 2000/02/18 - T.E.Dickey <dickey@clark.net>
759 ==========================================
760 + add case for HPUX 11.x use of cur_colr library (reported by
761 Bjorn Helgaas <helgaas@rsn.hp.com>).
762 + add configure option --with-pdcurses, to link with the X11 version
763 of PDCurses.
764 + eliminate quoted includes, in favor of bracketed form.
765 + ifdef'd limits.h, moving that into cdk.h with a fallback definition
766 for INT_MIN and INT_MAX.
767 + minor fixes for building with SunOS 5lib version: configure check
768 for getopt variables, correction to demos/Makefile.in
769
770 2000/01/17 - T.E.Dickey <dickey@clark.net>
771 ==========================================
772 + add lib-prefix and executable suffix checks to configure script for
773 port to OS/2 EMX.
774 + add configure check for lstat().
775
776 2000/01/16 - T.E.Dickey <dickey@clark.net>
777 ==========================================
778 + drop dependency on usleep(), using napms() which is standard with
779 SVr4 curses.
780 + rewrote mode2Char(), making it table-driven and splitting out
781 mode2Filetype() to make porting simpler, by putting ifdef's for
782 S_ISSOCK in one place only.
783 + use new freeCharList() to reduce clutter.
784 + eliminate casts of NULL, to reduce clutter.
785 + change several uses of control characters in source to use CONTROL()
786 macro.
787 + correct format of date shown in bind_ex.c
788 + correct nonstandard getcwd() usage in fselect.c
789 + change demo and example makefiles to not strip executables.
790 + modify demo/Makefile.in to work around Solaris' make program which
791 does not process ".c" rule as desired.
792
793 2000/01/08 - T.E.Dickey <dickey@clark.net>
794 ==========================================
795 + fix compiler warnings with Solaris cc.
796
797 1999/12/19 - T.E.Dickey <dickey@clark.net>
798 ==========================================
799 + update email and url for Mike Glover based on 4.9.9 version dated
800 1999/7/29.
801
802 1999/06/26 - T.E.Dickey <dickey@clark.net>
803 ==========================================
804 + add configure options --with-dbmalloc and --with-dmalloc to simplify
805 testing with those libraries.
806 + correct error in rewrite of char2Chtype which broke repeat-counts.
807
808 1999/06/05 - T.E.Dickey <dickey@clark.net>
809 ==========================================
810 + correct reference to uninitialized memory in bindCDKObject()
811 + add/use BINDFN_PROTO macro to simplify maintenance of Perl extension,
812 corrected corresponding functions to be typed void.
813 + shorten/simplify mapChtype by making it table-driven.
814 + shorten/simplify char2DisplayType by making it table-driven.
815 + replace splitString() by CDKsplitString() and CDKcountStrings() to
816 eliminate buffer-limits.
817 + simplify char2Chtype, eliminate fixed-buffer limits.
818 + prevent recursion in segvTrap.
819
820 1999/05/29 - T.E.Dickey <dickey@clark.net>
821 ==========================================
822 + remove bindFunction and bindData arrays from individual widgets
823 + make draw, erase, move methods accessed only via the CDKFUNCS table
824 in each widget.
825 + add move method for menu.c
826 + split-out positionCDKObject function from widget code.
827
828 1999/05/23 - T.E.Dickey <dickey@clark.net>
829 ==========================================
830 + remove WIN_WIDTH and related macros, use the more common getmaxx,
831 and similar macros. Provide fallback definitions for those.
832 + replace log10() call in intlen with simple recursion.
833 + add getendx() and getendy() macros.
834 + add moveCursesWindow().
835 + generate include/cdk_config.h, to simplify ifdef'ing for gcc
836 features, and to reduce clutter in the makefiles.
837 + add functions ceilCDK() and floorCDK() to eliminate dependency on
838 the math library
839 + simplified, corrected upper-limit checks in alignxy().
840 + change bindings to be dynamically allocated, part of the CDKOBJS
841 structure.
842 + correct overlap between title and percentage in drawCDKViewerInfo()
843
844 1999/05/15 - T.E.Dickey <dickey@clark.net>
845 ==========================================
846 + revised configure script, using autoconf macros which I've written
847 for other programs to check for ncurses configuration.
848 + corrected language of copyrights - Mike Glover's intent to retain
849 copyright of CDK is not served by putting a 1990 copyright attributed
850 to UC Berkeley.
851 + except for unused parameters, fix gcc compiler warnings.
852 + change prototypes to not use parameter names, since this causes
853 namespace pollution.
854 + make functions that do not have public prototypes static.
855 + add missing exit() call in fileview.c, after endCDK() call.
856 + move delwin() calls before endCDK() call in a few other examples.
857 + correct apparent bug in widgets which process a binding (such as
858 KEY_DOWN, in the alphalist and fileview.c demos). They set the
859 exitType to vESCAPE_HIT rather than the expected vEARLY_EXIT.
860 + ifdef'd out some debug code in scroll_ex.c
861 + correct a loop limit freeing mesg[] array in selection_ex.c
862 + move common object data into new struct CDKOBJS, making cdkscreen.c
863 much simpler and extensible.
864 + change erase and draw functions (called from cdkscreen.c) to
865 object pointers, so only widgets used are linked, making example
866 programs half as big.
867
868 4.9.7 -> 4.9.8 (December 1998)
869 ==========================================
870 * Changed the way key bindings worked. If the key binding exited
871 with a non-zero value then the widget would exit like the user
872 pressed the escape key. This provides more control over key
873 binding callbacks. Now the bind prototype is:
874 int function (EObjectType cdktype, void *object, void *clientData, chtype key);
875 * Reversed the order of this file. The most recent first.
876
877 4.9.6 -> 4.9.7 (December 1998)
878 ==========================================
879 * Went from static Makefiles to autoconf and configure. (finally)
880
881 4.9.2 -> 4.9.6
882 ==========================================
883 * Once again, it's a complete mystery.
884
885 4.9.1 -> 4.9.2
886 ==========================================
887 * Changed the activateCDKViewer funtion to be more compliant
888 with the rest of the activateCDKXXX functions.
889
890 4.9.0 -> 4.9.1
891 ==========================================
892 * Added the functions setCDKXXXULChar/URChar/LLChar/LRChar,
893 setCDKXXXVerticalChar, setCDKHorizontalChar, and
894 setCDKXXXBoxAttribute to each of the widgets but the menu
895 widget. These functions allow the programmer to define
896 the corner characters of the widget as well as the vertical,
897 horizontal, and attributes of the box.
898 * Added the function setCDKXXXBackgroundColor. This sets the
899 background color of the widget's window.
900 * Added makefile for the SGI
901 * Created the buttonbox widget.
902 * Added in Ctrl-N and Ctrl-P to switch between buttons on the
903 dialog box and viewer.
904 * Added the functions setCDKRadioItems and setCDKSelectionItems.
905 * Added the functions setCDKRadioTitle, setCDKSelectionTitle,
906 setCDKScrollTitle.
907
908 4.8.3 -> 4.9.0
909 ==========================================
910 * Added a parameter to the setCDKViewer function to turn on/off the
911 line X of Y in the top left corner.
912 * Removed the eraseCDKXXX in each of the drawCDKXXX functions. This
913 results in a quicker refresh and less overhead when using the
914 widgets. This should make things A LOT faster. (I suppose it's about
915 time I had complete faith in curses optimized screen refreshing. :) )
916 The side effect is that you might have to change some programs to
917 force an eraseCDKXXX/drawCDKXXX when you think the screen is garbled.
918 * Added a little bit of logic in char2Chtype when a terminal cannot
919 display color, bold will be used instead.
920 * Cleaned up the way filename completion works in the file selector.
921 You may now type in a path and hit tab and that directory tree
922 will be loaded.
923 * Added the ability to use the ~ character to refer to a users home
924 directory, in the file selector. (like csh variants)
925 * Changed the setCDKXXX functions. Made many different setCDKXXX
926 functions, one for each item being set. This reduces the overhead
927 of all the setCDKXXX functions.
928 * Drastically changed cdk.h. Split the widget definitions and
929 functions into their own header files. This makes it easier
930 to expand CDK.
931 * Added the ability to have multiple line titles on most of the widgets.
932 * Added the functions setCDKSelectionChoice/getCDKSelectionChoice to
933 set/get a single choice value from a selection list.
934 * Added the functions setCDKSelectionModes/getCDKSelectionModes to
935 set/get the ability to set some items in the selection list as
936 editable/uneditable.
937 * Added makefile for the DEC Alpha (I forget who sent me this, if
938 you want recognition, mail me again)
939 * Created a 'visual install' using some of the widgets. Try it.
940 (type in make vinstall once the library has been made)
941 * Added the ability to set the width of the widget respective to the
942 screen size. If you pass in a negative value, the widget will
943 adjust to the width of the window the widget sits in minus the
944 given value. If zero is given, then the widget will be the full
945 width of the window. This removes the need to know how wide the
946 window is when the widget is created.
947 * Changed the demos and examples makefiles. I was making things too
948 difficult. It's simpler and easier to compile these directories.
949 * Re-Purified the code. (no leaks, no UMR's, no problem... :) )
950 * Quantified the code a bit for those who complained about the
951 performance. It has been sped up; I just hope it's enough for
952 some of you speed freaks. :)
953 * Added the functions get/setCDKTemplateMin. This allows you to
954 set the minimum number of characters to type in before the
955 widget will accept the typed in value.
956 * Changed the documentation to reflect all the changes.
957
958 4.8.1 -> 4.8.2 -> 4.8.3
959 ==========================================
960 * It's a complete mystery.
961
962 4.8.0 -> 4.8.1
963 ==========================================
964 * Changed the bind prototype function from
965 void function (EObjectType cdktype, void *object, void *clientData);
966 to
967 void function (EObjectType cdktype, void *object, void *clientData, chtype key);
968 * Added scroll bars to the scrolling list, the selection list, and
969 the radio list.
970 * Modified the template widget so the new character takes on the
971 color/attributes of the plate widget.
972 * Added the function classes moveCDKXXX and positionCDKXXX.
973 * Changed the structure of the makefile and created a single makefile
974 for each platform to compile on.
975 * Added support for the delete character KEY_DC.
976
977 4.7.0 -> 4.8.0
978 ==========================================
979 * Fixed bugs documented by Miguel Marques (miguel@apex.cos.yorku.ca)
980 in the entry and mentry widgets. The bug displays itself when you
981 use vHINT or vINT display types. The vHINT actually showed the
982 numbers being typed in (which goes against the hidden element of
983 this display type) and in certain cases vINT allowed non-alpha
984 characters to be entered.
985 * Added compile support for Free BSD.
986 * Cleaned up the behavior of the entry field.
987 * Cleaned up the behavior of the scrolling list.
988 * Cleaned up the behavior of the radio list.
989 * Cleaned up the behavior of the selection list.
990 * Changed (improved) the behavior of the file selector widget.
991 * Made the activateCDKFselect behave like the other widgets.
992 * Added injectCDKFselect function.
993 * Added the calendar widget.
994 * Added the slider widget.
995 * Added the alphalist widget on the request of Luigi Rizzo.
996 (luigi@ien.unipi.it)
997 * Fixed a bug with addCDKScrollItem.
998 * Fixed segmentation fault in the rolodex demo.
999 * Changed the macros MAX, MIN, and DIFF to MAXIMUM, MINIMUM,
1000 and DIFFERENCE respectively to avoid conflicts.
1001 * Fixed errors with the alphalist and fselect widgets.
1002 * Added the link format comand for the file viewer. This allows
1003 users to 'hyper-link' text files.
1004 * Removed the use of CTRL-N.
1005 * Added the ability to load/save with the scrolling window.
1006 * Added filename completion to the file selector.
1007 * Cleaned up massive changes and errors in the documentation.
1008 * Added 'emacs-like' field editing capabilities to the entry
1009 and mentry widgets.
1010
1011 4.6.1 -> 4.7.0
1012 ==========================================
1013 * Added injectCDKXXX class of functions. This allows you to inject a
1014 single character into the widget.
1015 * Changed the activateCDKXXX to take an array of chtype to send in a
1016 set of predefined characters. This is very useful for performing
1017 automated tests of your programs.
1018 * Added functions setCDKXXXPreProcess and setCDKXXXPosProcess to
1019 perform actions before and after a character has been hit.
1020 * Made the use of CTRL-N consistent.
1021 * Fixed manual page errors.
1022 * Added the ability to cut text from the entry, mentry, and template
1023 widgets. (uses a global buffer)
1024 * Added the ability to copy text from the entry, mentry, and template
1025 widgets. (uses a global buffer)
1026 * Added the ability to paste text into the entry, mentry, and template
1027 widgets. (uses a global buffer)
1028 * Added the use of the escape key to exit a widget early.
1029 * Added the functions addCDKScroll/deleteCDKScroll to insert and
1030 delete items in an active scrolling list.
1031 * Added a parameter to the menu to specify where the menu windows
1032 were to be drawn. (top or bottom)
1033 * Added execCDKSwindow to the swindow function list. This allows the
1034 user to 'spawn' a command and direct the output to the scrolling
1035 window.
1036
1037 4.6.0 -> 4.6.1
1038 ==========================================
1039 * Removed the callback function parameter from the entry, mentry,
1040 matrix, and template widgets. Added in a function setCDKXXXCB.
1041 The XXX is the name of the widget.
1042 * Changed the viewer widget functions around. Moved activateCDKViewer
1043 to setCDKViewer. Moved manageCDKViewer to activateCDKViewer and
1044 removed the old setCDKViewer.
1045 * Added in special drawing characters.
1046 * Added in indent format to indent lines.
1047
1048 4.6.0 (January 1996)
1049 ==========================================
1050 * First pulic release of Cdk.
1051
1052 If you want to get a hold of me mail me at one of the following:
1053 glover@credit.erin.utoronto.ca
1054 mike@vexus.ca
1055
1056 The CDK Web page has several homes. They are:
1057 http://www.vexus.ca/CDK.html (official)
1058 http://www.datasoft.on.ca/~cdk (Sponsered by the nice folks at Datasoft)
1059
1060 ttfn,
1061 Mike
1062
1063 PS: There is also a Perl5 extension of this library for you Perl5 fans.
1064 Look under any CPAN site under the directory CPAN/authors/id/GLOVER.
0 -- $Id: COPYING,v 1.2 2003/12/10 22:43:22 tom Exp $
0 Modifications copyright Thomas Dickey 1999, 2000, 2001, 2002, 2003, 2004, 2005
1
2 The software and documentation are still under the same licensing are the
3 original Cdk, but noting that substantial work and enhancements have been made,
4 I've added my name as needed -TD
5
6 The original COPYING file follows (with corrections as noted in CHANGES).
17 -------------------------------------------------------------------------------
2 Copyright 1999, Mike Glover
3 Modifications copyright 1999-2002,2003 Thomas Dickey
4 All rights reserved.
8 Cdk Copying Guide
9 Copyright Mike Glover, 1995, 1996, 1997, 1998, 1999
10 -------------------------------------------------------------------------------
11 In order to copy Cdk around I have some requirements that will protect me,
12 and possibly even you. First thing, I feel I should say that this little project
13 of mine has taken quite a bit 'free' time and I have put a lot of work
14 into it. I do ask that if anyone asks you about Cdk, tell them where you got it
15 and who wrote it. If you see Cdk installed without this file on the system
16 somewhere, then assume the copy the person has is a 'corrupt' version. I will
17 not be responsible for any unfortunate results if someone else makes a personal
18 modification to the Cdk library. I will also not be responsible if for some
19 reason the installation of Cdk creates a negative effect on your machine. You
20 do have my word that there are no "Trojan horses", worms, or other security
21 worries lurking in this code. If there are I did not put them there and you
22 should remove the version of Cdk you have and go get a proper copy. I hate
23 virus writers as much as anyone else!
524
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
25 Instead of writing my own license (I'm a programmer, not a lawyer!) I'm going
26 to adapt the BSD public license on public software. If you do not agree to
27 this license then remove the Cdk distribution and we all will be happier in
28 the end. Here is the complete BSD public license in its true form, for
29 reference.
830
9 1. Redistributions of source code must retain the above copyright notice, this
10 list of conditions and the following disclaimer.
31 I will say one thing, Cdk is my copyright. I will continue to support any
32 released versions out there as long as they are in their released form. I am
33 releasing this into the "public" because I feel I have benefited from other
34 people's hard work, I'd like to chip into the pot as well. This does NOT make
35 Cdk public domain though. Cdk is still my copyright, and owned by me, I am
36 merely stating this so I don't see 40 different versions of my code floating
37 around with other people's names attached.
1138
12 2. Redistributions in binary form must reproduce the above copyright notice,
13 this list of conditions and the following disclaimer in the documentation
14 and/or other materials provided with the distribution.
39 With that ugly stuff said, I will happily take any comments or questions about
40 Cdk. Input is more than welcomed. In fact I encourage it. Feel free to mail
41 me and ask questions you think the supplied documents don't cover. If I get
42 enough I may build a FAQ to help newcomers. (We'll see how Cdk is accepted
43 though).
1544
16 3. All advertising materials mentioning features or use of this software must
17 display the following acknowledgment:
18 This product includes software developed by Mike Glover and
19 contributors.
45 For you Perl programmers, there is a Perl5 extension to Cdk. Look at your
46 closest CPAN site under authors/id/GLOVER.
2047
21 4. Neither the name of Mike Glover nor the names of contributors
22 may be used to endorse or promote products derived from this software
23 without specific prior written permission.
48 If you want to get a hold of me mail me at one of the following:
49 glover@credit.erin.utoronto.ca
50 mike@vexus.ca
2451
25 THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND ANY
26 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE FOR ANY
29 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
32 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 The CDK Web page has several homes. They are:
53 http://www.vexus.ca/CDK.html (official)
54 http://www.datasoft.on.ca/~cdk (Sponsored by the nice folks at Datasoft)
55
56 ttfn,
57 Mike
58 -------------------------------------------------------------------------------
59
60 /*
61 * Copyright (c) 1999, Mike Glover
62 * All rights reserved.
63 *
64 * Redistribution and use in source and binary forms, with or without
65 * modification, are permitted provided that the following conditions
66 * are met:
67 * 1. Redistributions of source code must retain the above copyright
68 * notice, this list of conditions and the following disclaimer.
69 * 2. Redistributions in binary form must reproduce the above copyright
70 * notice, this list of conditions and the following disclaimer in the
71 * documentation and/or other materials provided with the distribution.
72 * 3. All advertising materials mentioning features or use of this software
73 * must display the following acknowledgment:
74 * This product includes software developed by Mike Glover
75 * and contributors.
76 * 4. Neither the name of Mike Glover, nor the names of contributors
77 * may be used to endorse or promote products derived from this software
78 * without specific prior written permission.
79 *
80 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
81 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
82 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
83 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
84 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
85 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
86 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
87 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
88 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
89 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
90 * SUCH DAMAGE.
91 */
+0
-233
Cdk/Alphalist.pm less more
0 package Cdk::Alphalist;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new alphalist object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $list = Cdk::checkReq ($name, "List", $params{'List'});
19 my $height = Cdk::checkReq ($name, "Height", $params{'Height'});
20 my $width = Cdk::checkReq ($name, "Width", $params{'Width'});
21 my $label = Cdk::checkDef ($name, "Label", $params{'Label'}, "");
22 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
23 my $hBar = Cdk::checkDef ($name, "Highlight", $params{'Highlight'}, "A_REVERSE");
24 my $filler = Cdk::checkDef ($name, "Filler", $params{'Filler'}, ".");
25 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
26 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
27 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
28 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
29
30 # Create the thing.
31 $self->{'Me'} = Cdk::Alphalist::New ($title, $label, $params{'List'},
32 $height, $width, $xpos, $ypos,
33 $hBar, $filler, $box, $shadow);
34 bless $self;
35 }
36
37 #
38 # This activates the object
39 #
40 sub activate
41 {
42 my $self = shift;
43 my %params = @_;
44 my $name = "$self->{'Type'}::activate";
45
46 # Activate the object...
47 if (defined $params{'Input'})
48 {
49 $self->{'Info'} = Cdk::Alphalist::Activate ($self->{'Me'}, $params{'Input'});
50 }
51 else
52 {
53 $self->{'Info'} = Cdk::Alphalist::Activate ($self->{'Me'});
54 }
55 return ($self->{'Info'});
56 }
57
58 #
59 # This sets several parameters of the widget.
60 #
61 sub set
62 {
63 my $self = shift;
64 my %params = @_;
65 my $name = "$self->{'Type'}::set";
66
67 #
68 # Check the parameters sent in.
69 #
70 if (defined $params{'Contents'})
71 {
72 Cdk::Alphalist::SetContents ($self->{'Me'}, $params{'Contents'});
73 }
74 if (defined $params{'FillerChar'})
75 {
76 Cdk::Alphalist::SetFillerChar ($self->{'Me'}, $params{'FillerChar'});
77 }
78 if (defined $params{'Highlight'})
79 {
80 Cdk::Alphalist::SetHighlight ($self->{'Me'}, $params{'Highlight'});
81 }
82 if (defined $params{'ULChar'})
83 {
84 Cdk::Alphalist::SetULChar ($self->{'Me'}, $params{'ULChar'});
85 }
86 if (defined $params{'URChar'})
87 {
88 Cdk::Alphalist::SetURChar ($self->{'Me'}, $params{'URChar'});
89 }
90 if (defined $params{'LLChar'})
91 {
92 Cdk::Alphalist::SetLLChar ($self->{'Me'}, $params{'LLChar'});
93 }
94 if (defined $params{'LRChar'})
95 {
96 Cdk::Alphalist::SetLRChar ($self->{'Me'}, $params{'LRChar'});
97 }
98 if (defined $params{'VChar'})
99 {
100 Cdk::Alphalist::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
101 }
102 if (defined $params{'HChar'})
103 {
104 Cdk::Alphalist::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
105 }
106 if (defined $params{'BoxAttribute'})
107 {
108 Cdk::Alphalist::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
109 }
110 if (defined $params{'BGColor'})
111 {
112 Cdk::Alphalist::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
113 }
114 if (defined $params{'Box'})
115 {
116 Cdk::Alphalist::SetBox ($self->{'Me'}, $params{'Box'});
117 }
118 }
119 #
120 # This allows us to bind a key to an action.
121 #
122 sub bind
123 {
124 my $self = shift;
125 my %params = @_;
126 my $name = "$self->{'Type'}::bind";
127
128 # Set the values.
129 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
130 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
131 Cdk::Alphalist::Bind ($self->{'Me'}, $params{'Key'}, $params{'Function'});
132 }
133
134 #
135 # This allows us to set a pre-process function.
136 #
137 sub preProcess
138 {
139 my $self = shift;
140 my %params = @_;
141 my $name = "$self->{'Type'}::preProcess";
142
143 # Set the values.
144 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
145 Cdk::Alphalist::PreProcess ($self->{'Me'}, $params{'Function'});
146 }
147
148 #
149 # This allows us to set a post-process function.
150 #
151 sub postProcess
152 {
153 my $self = shift;
154 my %params = @_;
155 my $name = "$self->{'Type'}::postProcess";
156
157 # Set the values.
158 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
159 Cdk::Alphalist::PostProcess ($self->{'Me'}, $params{'Function'});
160 }
161
162 #
163 # This draws the object.
164 #
165 sub draw
166 {
167 my $self = shift;
168 my %params = @_;
169 my $name = "$self->{'Type'}::draw";
170
171 # Set the values.
172 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
173
174 # Draw the object.
175 Cdk::Alphalist::Draw ($self->{'Me'}, $box);
176 }
177
178 #
179 # This erases the object.
180 #
181 sub erase
182 {
183 my $self = shift;
184 Cdk::Alphalist::Erase ($self->{'Me'});
185 }
186
187 #
188 # This function raises the object.
189 #
190 sub raise
191 {
192 my $self = shift;
193 Cdk::Alphalist::Raise ($self->{'Me'});
194 }
195
196 #
197 # This function lowers the object.
198 #
199 sub lower
200 {
201 my $self = shift;
202 Cdk::Alphalist::Lower ($self->{'Me'});
203 }
204
205 #
206 # This function registers the object.
207 #
208 sub register
209 {
210 my $self = shift;
211 Cdk::Alphalist::Register ($self->{'Me'});
212 }
213
214 #
215 # This function unregisters the object.
216 #
217 sub unregister
218 {
219 my $self = shift;
220 Cdk::Alphalist::Unregister ($self->{'Me'});
221 }
222
223 #
224 # This function returns the pointer to the window.
225 #
226 sub getwin
227 {
228 my $self = shift;
229 Cdk::Alphalist::GetWindow ($self->{'Me'});
230 }
231
232 1;
+0
-246
Cdk/Buttonbox.pm less more
0 package Cdk::Buttonbox;
1 require "flush.pl";
2
3 @ISA = qw (Cdk);
4
5 #
6 # This creates a new Buttonbox object.
7 #
8 sub new
9 {
10 my $type = shift;
11 my %params = @_;
12 my $self = {};
13 my $name = "${type}::new";
14
15 # Retain the type of the object.
16 $self->{'Type'} = $type;
17
18 # Set up the parameters passed in.
19 my $buttons = Cdk::checkReq ($name, "Buttons", $params{'Buttons'});
20 my $rows = Cdk::checkReq ($name, "Rows", $params{'Rows'});
21 my $cols = Cdk::checkReq ($name, "Cols", $params{'Cols'});
22 my $height = Cdk::checkReq ($name, "Height", $params{'Height'});
23 my $width = Cdk::checkReq ($name, "Width", $params{'Width'});
24 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
25 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
26 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
27 my $hlight = Cdk::checkDef ($name, "Highlight", $params{'Highlight'}, "A_REVERSE");
28 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
29 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
30
31 # Create the thing.
32 $self->{'Me'} = Cdk::Buttonbox::New ($title, $params{'Buttons'},
33 $rows, $cols,
34 $height, $width,
35 $xpos, $ypos,
36 $hlight, $box, $shadow);
37 bless $self;
38 }
39
40 #
41 # This activates the object
42 #
43 sub activate
44 {
45 my $self = shift;
46 my %params = @_;
47 my $name = "$self->{'Type'}::activate";
48
49 # Activate the object...
50 if (defined $params{'Input'})
51 {
52 $self->{'Info'} = Cdk::Buttonbox::Activate ($self->{'Me'}, $params{'Input'});
53 }
54 else
55 {
56 $self->{'Info'} = Cdk::Buttonbox::Activate ($self->{'Me'});
57 }
58 return ($self->{'Info'});
59 }
60
61 #
62 # This injects a character into the widget.
63 #
64 sub inject
65 {
66 my $self = shift;
67 my %params = @_;
68 my $name = "$self->{'Type'}::inject";
69
70 # Set the values.
71 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
72
73 return (Cdk::Buttonbox::Inject ($self->{'Me'}, $character));
74 }
75
76 #
77 # This sets several parameters of the widget.
78 #
79 sub set
80 {
81 my $self = shift;
82 my %params = @_;
83 my $name = "$self->{'Type'}::set";
84
85 #
86 # Check the parameters sent in.
87 #
88 if (defined $params{'Highlight'})
89 {
90 Cdk::Buttonbox::SetHighlight ($self->{'Me'}, $params{'Highlight'});
91 }
92 if (defined $params{'ULChar'})
93 {
94 Cdk::Buttonbox::SetULChar ($self->{'Me'}, $params{'ULChar'});
95 }
96 if (defined $params{'URChar'})
97 {
98 Cdk::Buttonbox::SetURChar ($self->{'Me'}, $params{'URChar'});
99 }
100 if (defined $params{'LLChar'})
101 {
102 Cdk::Buttonbox::SetLLChar ($self->{'Me'}, $params{'LLChar'});
103 }
104 if (defined $params{'LRChar'})
105 {
106 Cdk::Buttonbox::SetLRChar ($self->{'Me'}, $params{'LRChar'});
107 }
108 if (defined $params{'VChar'})
109 {
110 Cdk::Buttonbox::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
111 }
112 if (defined $params{'HChar'})
113 {
114 Cdk::Buttonbox::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
115 }
116 if (defined $params{'BoxAttribute'})
117 {
118 Cdk::Buttonbox::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
119 }
120 if (defined $params{'BGColor'})
121 {
122 Cdk::Buttonbox::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
123 }
124 if (defined $params{'Box'})
125 {
126 Cdk::Buttonbox::SetBox ($self->{'Me'}, $params{'Box'});
127 }
128 }
129
130 #
131 # This draws the object.
132 #
133 sub draw
134 {
135 my $self = shift;
136 my %params = @_;
137 my $name = "$self->{'Type'}::draw";
138
139 # Set up the parameters passed in.
140 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
141
142 # Draw the object.
143 Cdk::Buttonbox::Draw ($self->{'Me'}, $box);
144 }
145
146 #
147 # This erases the object.
148 #
149 sub erase
150 {
151 my $self = shift;
152 Cdk::Buttonbox::Erase ($self->{'Me'});
153 }
154
155 #
156 # This allows us to bind a key to an action.
157 #
158 sub bind
159 {
160 my $self = shift;
161 my %params = @_;
162 my $name = "$self->{'Type'}::bind";
163
164 # Set up the parameters passed in.
165 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
166 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
167
168 # Bind the key to the function
169 Cdk::Buttonbox::Bind ($self->{'Me'}, $key, $function);
170 }
171
172 #
173 # This allows us to set a pre-process function.
174 #
175 sub preProcess
176 {
177 my $self = shift;
178 my %params = @_;
179 my $name = "$self->{'Type'}::preProcess";
180
181 # Set the values.
182 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
183 Cdk::Buttonbox::PreProcess ($self->{'Me'}, $params{'Function'});
184 }
185
186 #
187 # This allows us to set a post-process function.
188 #
189 sub postProcess
190 {
191 my $self = shift;
192 my %params = @_;
193 my $name = "$self->{'Type'}::postProcess";
194
195 # Set the values.
196 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
197 Cdk::Buttonbox::PostProcess ($self->{'Me'}, $params{'Function'});
198 }
199
200 #
201 # This function raises the object.
202 #
203 sub raise
204 {
205 my $self = shift;
206 Cdk::Buttonbox::Raise ($self->{'Me'});
207 }
208
209 #
210 # This function lowers the object.
211 #
212 sub lower
213 {
214 my $self = shift;
215 Cdk::Buttonbox::Lower ($self->{'Me'});
216 }
217
218 #
219 # This function registers the object.
220 #
221 sub register
222 {
223 my $self = shift;
224 Cdk::Buttonbox::Register ($self->{'Me'});
225 }
226
227 #
228 # This function unregisters the object.
229 #
230 sub unregister
231 {
232 my $self = shift;
233 Cdk::Buttonbox::Unregister ($self->{'Me'});
234 }
235
236 #
237 # This function returns the pointer to the window.
238 #
239 sub getwin
240 {
241 my $self = shift;
242 Cdk::Buttonbox::GetWindow ($self->{'Me'});
243 }
244
245 1;
+0
-280
Cdk/Calendar.pm less more
0 package Cdk::Calendar;
1
2 #
3 # This creates a new Calendar object
4 #
5 sub new
6 {
7 my $type = shift;
8 my %params = @_;
9 my $self = {};
10 my $name = "${type}::new";
11
12 # Retain the type of the object.
13 $self->{'Type'} = $type;
14
15 # Get today's date.
16 my ($today, $thisMonth, $thisYear) = (localtime(time))[3,4,5];
17 $thisMonth++;
18 $thisYear += 1900;
19
20 # Set up the parameters passed in.
21 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
22 my $day = Cdk::checkDef ($name, "Day", $params{'Day'}, $today);
23 my $month = Cdk::checkDef ($name, "Month", $params{'Month'}, $thisMonth);
24 my $year = Cdk::checkDef ($name, "Year", $params{'Year'}, $thisYear);
25 my $dAttrib = Cdk::checkDef ($name, "Dattrib", $params{'Dattrib'}, "A_NORMAL");
26 my $mAttrib = Cdk::checkDef ($name, "Mattrib", $params{'Mattrib'}, "A_NORMAL");
27 my $yAttrib = Cdk::checkDef ($name, "Yattrib", $params{'Yattrib'}, "A_NORMAL");
28 my $hlight = Cdk::checkDef ($name, "Highlight", $params{'Highlight'}, "A_REVERSE");
29 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
30 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
31 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
32 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
33
34 # Create the thing.
35 $self->{'Me'} = Cdk::Calendar::New ($title, $day, $month, $year,
36 $dAttrib, $mAttrib, $yAttrib,
37 $hlight, $xpos, $ypos, $box, $shadow);
38 bless $self;
39 }
40
41 #
42 # This activates the object.
43 #
44 sub activate
45 {
46 my $self = shift;
47 my %params = @_;
48 my $name = "$self->{'Type'}::activate";
49
50 # Activate the object...
51 if (defined $params{'Input'})
52 {
53 $self->{'Info'} = Cdk::Calendar::Activate ($self->{'Me'}, $params{'Input'});
54 }
55 else
56 {
57 $self->{'Info'} = Cdk::Calendar::Activate ($self->{'Me'});
58 }
59 return ($self->{'Info'});
60 }
61
62 #
63 # This injects a character into the widget.
64 #
65 sub inject
66 {
67 my $self = shift;
68 my %params = @_;
69 my $name = "$self->{'Type'}::inject";
70
71 # Set the values.
72 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
73
74 return (Cdk::Calendar::Inject ($self->{'Me'}, $character));
75 }
76
77 #
78 # This allows us to bind a key to an action.
79 #
80 sub bind
81 {
82 my $self = shift;
83 my %params = @_;
84 my $name = "$self->{'Type'}::bind";
85
86 # Set the values.
87 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
88 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
89 Cdk::Calendar::Bind ($self->{'Me'}, $key, $params{'Function'});
90 }
91
92 #
93 # This allows us to set a pre-process function.
94 #
95 sub preProcess
96 {
97 my $self = shift;
98 my %params = @_;
99 my $name = "$self->{'Type'}::preProcess";
100
101 # Set the values.
102 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
103 Cdk::Calendar::PreProcess ($self->{'Me'}, $params{'Function'});
104 }
105
106 #
107 # This allows us to set a post-process function.
108 #
109 sub postProcess
110 {
111 my $self = shift;
112 my %params = @_;
113 my $name = "$self->{'Type'}::postProcess";
114
115 # Set the values.
116 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
117 Cdk::Calendar::PostProcess ($self->{'Me'}, $params{'Function'});
118 }
119
120 #
121 # This draws the object.
122 #
123 sub draw
124 {
125 my $self = shift;
126 my %params = @_;
127 my $name = "$self->{'Type'}::draw";
128
129 # Set up the parameters passed in.
130 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
131
132 # Draw the object.
133 Cdk::Calendar::Draw ($self->{'Me'}, $box);
134 }
135
136 #
137 # This erases the object.
138 #
139 sub erase
140 {
141 my $self = shift;
142 Cdk::Calendar::Erase ($self->{'Me'});
143 }
144
145 #
146 # This sets the object...
147 #
148 sub set
149 {
150 my $self = shift;
151 my %params = @_;
152 my $name = "$self->{'Type'}::set";
153
154 # Get today's date.
155 my ($today, $thisMonth, $thisYear) = (localtime(time))[3,4,5];
156 $thisMonth ++;
157 $thisYear += 1900;
158
159 # Set up the parameters passed in.
160 my $day = Cdk::checkDef ($name, "Day", $params{'Day'}, $today);
161 my $month = Cdk::checkDef ($name, "Month", $params{'Month'}, $thisMonth);
162 my $year = Cdk::checkDef ($name, "Year", $params{'Year'}, $thisYear);
163 my $dAttrib = Cdk::checkDef ($name, "Dattrib", $params{'Dattrib'}, "</16/B>");
164 my $mAttrib = Cdk::checkDef ($name, "Mattrib", $params{'Mattrib'}, "</24/B>");
165 my $yAttrib = Cdk::checkDef ($name, "Yattrib", $params{'Yattrib'}, "</32/B>");
166 my $highlight = Cdk::checkDef ($name, "Highlight", $params{'Highlight'}, "</40/B>");
167 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
168
169 Cdk::Calendar::Set ($self->{'Me'}, $day, $month, $year,
170 $dAttrib, $mAttrib, $yAttrib, $box);
171 }
172
173 #
174 # This sets the calendar to a given date.
175 #
176 sub setDate
177 {
178 my $self = shift;
179 my %params = @_;
180 my $name = "$self->{'Type'}::setDate";
181
182 # Set up the parameters passed in.
183 my $day = Cdk::checkDef ($name, "Day", $params{'Day'}, -1);
184 my $month = Cdk::checkDef ($name, "Month", $params{'Month'}, -1);
185 my $year = Cdk::checkDef ($name, "Year", $params{'Year'}, -1);
186
187 Cdk::Calendar::SetDate ($self->{'Me'}, $day, $month, $year);
188 }
189
190 #
191 # This gets the current date on the given calendar.
192 #
193 sub getDate
194 {
195 my $self = shift;
196 return (Cdk::Calendar::GetDate ($self->{'Me'}));
197 }
198
199 #
200 # This sets a marker in the calendar widget.
201 #
202 sub setMarker
203 {
204 my $self = shift;
205 my %params = @_;
206 my $name = "$self->{'Type'}::setMarker";
207
208 # Set up the parameters passed in.
209 my $day = Cdk::checkReq ($name, "Day", $params{'Day'});
210 my $month = Cdk::checkReq ($name, "Month", $params{'Month'});
211 my $year = Cdk::checkReq ($name, "Year", $params{'Year'});
212 my $marker = Cdk::checkDef ($name, "Marker", $params{'Marker'}, "A_REVERSE");
213
214 Cdk::Calendar::SetMarker ($self->{'Me'}, $day, $month, $year, $marker);
215 }
216
217 #
218 # This removes a marker from the calendar widget.
219 #
220 sub removeMarker
221 {
222 my $self = shift;
223 my %params = @_;
224 my $name = "$self->{'Type'}::removeMarker";
225
226 # Set up the parameters passed in.
227 my $day = Cdk::checkReq ($name, "Day", $params{'Day'});
228 my $month = Cdk::checkReq ($name, "Month", $params{'Month'});
229 my $year = Cdk::checkReq ($name, "Year", $params{'Year'});
230
231 Cdk::Calendar::RemoveMarker ($self->{'Me'}, $day, $month, $year);
232 }
233
234 #
235 # This function raises the object.
236 #
237 sub raise
238 {
239 my $self = shift;
240 Cdk::Calendar::Raise ($self->{'Me'});
241 }
242
243 #
244 # This function lowers the object.
245 #
246 sub lower
247 {
248 my $self = shift;
249 Cdk::Calendar::Lower ($self->{'Me'});
250 }
251
252 #
253 # This function registers the object.
254 #
255 sub register
256 {
257 my $self = shift;
258 Cdk::Calendar::Register ($self->{'Me'});
259 }
260
261 #
262 # This function unregisters the object.
263 #
264 sub unregister
265 {
266 my $self = shift;
267 Cdk::Calendar::Unregister ($self->{'Me'});
268 }
269
270 #
271 # This function returns the pointer to the window.
272 #
273 sub getwin
274 {
275 my $self = shift;
276 Cdk::Calendar::GetWindow ($self->{'Me'});
277 }
278
279 1;
+0
-25
Cdk/Debug.pm less more
0 package Cdk::Debug;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Label object
6 #
7 sub DumpScreenRegList
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $mesg = Cdk::checkReq ("($name) Missing 'Message' value.", $params{'Message'});
19
20 # Call the thing.
21 Cdk::Debug::DumpScreenRegList ($params{'Message'}, $mesg);
22 }
23
24 1;
+0
-56
Cdk/Diag.pm less more
0 package Cdk::Diag;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Label object
6 #
7 sub getScreenRegList
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $mesg = Cdk::checkReq ($name, "Message", $params{'Message'});
19
20 # Call the thing.
21 Cdk::Diag::DumpScreenRegList ($mesg);
22 }
23
24 #
25 # This writes to the log file.
26 #
27 sub Log
28 {
29 my($mesgType, $widgetType, $mesg) = @_;
30
31 # If the environment flag CDKDIAG is not set then get out.
32 return if (! defined $ENV{'CDKDIAG'});
33
34 # Set up the local vars.
35 my $filename = $ENV{'CDKLOGFILE'} || "cdkdiag.log";
36 my $date = qx (date); chomp $date;
37 my $diagType = uc $ENV{'CDKDIAG'};
38
39 # Only write the output if the diagnostics tell us to.
40 if ($diagType eq "ALL" || $diagType =~ uc $widgetType)
41 {
42 # Open the file
43 open (XXX, ">>$filename");
44 select (XXX); $| = 1;
45 print XXX "\n</29>*** Diagnostic Start: Program=<$0> Time: <$date> ***\n" if ! $DIAGFLAG;
46
47 # Check the message type.
48 print XXX "</24>$mesgType - ($widgetType) $mesg\n" if ($mesgType eq "Diag");
49 print XXX "</16>$mesgType - ($widgetType) $mesg\n" if ($mesgType eq "Error");
50 close (XXX);
51 $DIAGFLAG = 1;
52 }
53 }
54
55 1;
+0
-247
Cdk/Dialog.pm less more
0 package Cdk::Dialog;
1 require "flush.pl";
2
3 @ISA = qw (Cdk);
4
5 #
6 # This creates a new Dialog object.
7 #
8 sub new
9 {
10 my $type = shift;
11 my %params = @_;
12 my $self = {};
13 my $name = "${type}::new";
14
15 # Retain the type of the object.
16 $self->{'Type'} = $type;
17
18 # Set up the parameters passed in.
19 my $mesg = Cdk::checkReq ($name, "Message", $params{'Message'});
20 my $buttons = Cdk::checkReq ($name, "Buttons", $params{'Buttons'});
21 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
22 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
23 my $hlight = Cdk::checkDef ($name, "Highlight", $params{'Highlight'}, "A_REVERSE");
24 my $sep = Cdk::checkDef ($name, "Seperator", $params{'Seperator'}, "TRUE");
25 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
26 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
27
28 # Create the thing.
29 $self->{'Me'} = Cdk::Dialog::New ($params{'Message'},
30 $params{'Buttons'},
31 $xpos, $ypos,
32 $hlight, $sep,
33 $box, $shadow);
34 bless $self;
35 }
36
37 #
38 # This activates the object
39 #
40 sub activate
41 {
42 my $self = shift;
43 my %params = @_;
44 my $name = "$self->{'Type'}::activate";
45
46 # Activate the object...
47 if (defined $params{'Input'})
48 {
49 $self->{'Info'} = Cdk::Dialog::Activate ($self->{'Me'}, $params{'Input'});
50 }
51 else
52 {
53 $self->{'Info'} = Cdk::Dialog::Activate ($self->{'Me'});
54 }
55 return ($self->{'Info'});
56 }
57
58 #
59 # This injects a character into the widget.
60 #
61 sub inject
62 {
63 my $self = shift;
64 my %params = @_;
65 my $name = "$self->{'Type'}::inject";
66
67 # Set the values.
68 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
69
70 return (Cdk::Dialog::Inject ($self->{'Me'}, $character));
71 }
72
73 #
74 # This sets several parameters of the widget.
75 #
76 sub set
77 {
78 my $self = shift;
79 my %params = @_;
80 my $name = "$self->{'Type'}::set";
81
82 #
83 # Check the parameters sent in.
84 #
85 if (defined $params{'Highlight'})
86 {
87 Cdk::Dialog::SetHighlight ($self->{'Me'}, $params{'Highlight'});
88 }
89 if (defined $params{'Separator'})
90 {
91 Cdk::Dialog::SetSeparator ($self->{'Me'}, $params{'Separator'});
92 }
93 if (defined $params{'ULChar'})
94 {
95 Cdk::Dialog::SetULChar ($self->{'Me'}, $params{'ULChar'});
96 }
97 if (defined $params{'URChar'})
98 {
99 Cdk::Dialog::SetURChar ($self->{'Me'}, $params{'URChar'});
100 }
101 if (defined $params{'LLChar'})
102 {
103 Cdk::Dialog::SetLLChar ($self->{'Me'}, $params{'LLChar'});
104 }
105 if (defined $params{'LRChar'})
106 {
107 Cdk::Dialog::SetLRChar ($self->{'Me'}, $params{'LRChar'});
108 }
109 if (defined $params{'VChar'})
110 {
111 Cdk::Dialog::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
112 }
113 if (defined $params{'HChar'})
114 {
115 Cdk::Dialog::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
116 }
117 if (defined $params{'BoxAttribute'})
118 {
119 Cdk::Dialog::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
120 }
121 if (defined $params{'BGColor'})
122 {
123 Cdk::Dialog::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
124 }
125 if (defined $params{'Box'})
126 {
127 Cdk::Dialog::SetBox ($self->{'Me'}, $params{'Box'});
128 }
129 }
130
131 #
132 # This draws the object.
133 #
134 sub draw
135 {
136 my $self = shift;
137 my %params = @_;
138 my $name = "$self->{'Type'}::draw";
139
140 # Set up the parameters passed in.
141 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
142
143 # Draw the object.
144 Cdk::Dialog::Draw ($self->{'Me'}, $box);
145 }
146
147 #
148 # This erases the object.
149 #
150 sub erase
151 {
152 my $self = shift;
153 Cdk::Dialog::Erase ($self->{'Me'});
154 }
155
156 #
157 # This allows us to bind a key to an action.
158 #
159 sub bind
160 {
161 my $self = shift;
162 my %params = @_;
163 my $name = "$self->{'Type'}::bind";
164
165 # Set up the parameters passed in.
166 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
167 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
168
169 # Bind the key to the function
170 Cdk::Dialog::Bind ($self->{'Me'}, $key, $function);
171 }
172
173 #
174 # This allows us to set a pre-process function.
175 #
176 sub preProcess
177 {
178 my $self = shift;
179 my %params = @_;
180 my $name = "$self->{'Type'}::preProcess";
181
182 # Set the values.
183 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
184 Cdk::Dialog::PreProcess ($self->{'Me'}, $params{'Function'});
185 }
186
187 #
188 # This allows us to set a post-process function.
189 #
190 sub postProcess
191 {
192 my $self = shift;
193 my %params = @_;
194 my $name = "$self->{'Type'}::postProcess";
195
196 # Set the values.
197 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
198 Cdk::Dialog::PostProcess ($self->{'Me'}, $params{'Function'});
199 }
200
201 #
202 # This function raises the object.
203 #
204 sub raise
205 {
206 my $self = shift;
207 Cdk::Dialog::Raise ($self->{'Me'});
208 }
209
210 #
211 # This function lowers the object.
212 #
213 sub lower
214 {
215 my $self = shift;
216 Cdk::Dialog::Lower ($self->{'Me'});
217 }
218
219 #
220 # This function registers the object.
221 #
222 sub register
223 {
224 my $self = shift;
225 Cdk::Dialog::Register ($self->{'Me'});
226 }
227
228 #
229 # This function unregisters the object.
230 #
231 sub unregister
232 {
233 my $self = shift;
234 Cdk::Dialog::Unregister ($self->{'Me'});
235 }
236
237 #
238 # This function returns the pointer to the window.
239 #
240 sub getwin
241 {
242 my $self = shift;
243 Cdk::Dialog::GetWindow ($self->{'Me'});
244 }
245
246 1;
+0
-279
Cdk/Entry.pm less more
0 package Cdk::Entry;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Entry object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $max = Cdk::checkReq ($name, "Max", $params{'Max'});
19 my $fWidth = Cdk::checkReq ($name, "Width", $params{'Width'});
20 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
21 my $label = Cdk::checkDef ($name, "Label", $params{'Label'}, "");
22 my $filler = Cdk::checkDef ($name, "Filler", $params{'Filler'}, ".");
23 my $min = Cdk::checkDef ($name, "Min", $params{'Min'}, 0);
24 my $dispType = Cdk::checkDef ($name, "Dtype", $params{'Dtype'}, "MIXED");
25 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
26 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
27 my $fAttr = Cdk::checkDef ($name, "Fattrib", $params{'Fattrib'}, "A_NORMAL");
28 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
29 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
30
31 # Create the thing.
32 $self->{'Me'} = Cdk::Entry::New ($title, $params{'Label'},
33 $min, $max, $fWidth,
34 $filler, $dispType,
35 $xpos, $ypos, $fAttr,
36 $box, $shadow);
37 bless $self;
38 }
39
40 #
41 # This activates the object
42 #
43 sub activate
44 {
45 my $self = shift;
46 my %params = @_;
47 my $name = "$self->{'Type'}::activate";
48
49 # Activate the object...
50 if (defined $params{'Input'})
51 {
52 $self->{'Info'} = Cdk::Entry::Activate ($self->{'Me'}, $params{'Input'});
53 }
54 else
55 {
56 $self->{'Info'} = Cdk::Entry::Activate ($self->{'Me'});
57 }
58 return ($self->{'Info'});
59 }
60
61 #
62 # This injects a character into the widget.
63 #
64 sub inject
65 {
66 my $self = shift;
67 my %params = @_;
68 my $name = "$self->{'Type'}::inject";
69
70 # Set the values.
71 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
72
73 return (Cdk::Entry::Inject ($self->{'Me'}, $character));
74 }
75
76 #
77 # This sets several parameters of the widget.
78 #
79 sub set
80 {
81 my $self = shift;
82 my %params = @_;
83 my $name = "$self->{'Type'}::set";
84
85 #
86 # Check the parameters sent in.
87 #
88 if (defined $params{'Value'})
89 {
90 Cdk::Entry::SetValue ($self->{'Me'}, $params{'Value'});
91 }
92 if (defined $params{'Min'})
93 {
94 Cdk::Entry::SetMin ($self->{'Me'}, $params{'Min'});
95 }
96 if (defined $params{'Max'})
97 {
98 Cdk::Entry::SetMax ($self->{'Me'}, $params{'Max'});
99 }
100 if (defined $params{'FillerChar'})
101 {
102 Cdk::Entry::SetFillerChar ($self->{'Me'}, $params{'FillerChar'});
103 }
104 if (defined $params{'HiddenChar'})
105 {
106 Cdk::Entry::SetHiddenChar ($self->{'Me'}, $params{'HiddenChar'});
107 }
108 if (defined $params{'ULChar'})
109 {
110 Cdk::Entry::SetULChar ($self->{'Me'}, $params{'ULChar'});
111 }
112 if (defined $params{'URChar'})
113 {
114 Cdk::Entry::SetURChar ($self->{'Me'}, $params{'URChar'});
115 }
116 if (defined $params{'LLChar'})
117 {
118 Cdk::Entry::SetLLChar ($self->{'Me'}, $params{'LLChar'});
119 }
120 if (defined $params{'LRChar'})
121 {
122 Cdk::Entry::SetLRChar ($self->{'Me'}, $params{'LRChar'});
123 }
124 if (defined $params{'VChar'})
125 {
126 Cdk::Entry::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
127 }
128 if (defined $params{'HChar'})
129 {
130 Cdk::Entry::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
131 }
132 if (defined $params{'BoxAttribute'})
133 {
134 Cdk::Entry::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
135 }
136 if (defined $params{'BGColor'})
137 {
138 Cdk::Entry::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
139 }
140 if (defined $params{'Box'})
141 {
142 Cdk::Entry::SetBox ($self->{'Me'}, $params{'Box'});
143 }
144 }
145
146 #
147 # This function allows the user to get the current value from the widget.
148 #
149 sub get
150 {
151 my $self = shift;
152 return (Cdk::Entry::Get ($self->{'Me'}));
153 }
154
155 #
156 # This allows us to bind a key to an action.
157 #
158 sub bind
159 {
160 my $self = shift;
161 my %params = @_;
162 my $name = "$self->{'Type'}::bind";
163
164 # Set the values.
165 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
166 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
167
168 Cdk::Entry::Bind ($self->{'Me'}, $params{'Key'}, $params{'Function'});
169 }
170
171 #
172 # This allows us to set a pre-process function.
173 #
174 sub preProcess
175 {
176 my $self = shift;
177 my %params = @_;
178 my $name = "$self->{'Type'}::preProcess";
179
180 # Set the values.
181 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
182 Cdk::Entry::PreProcess ($self->{'Me'}, $params{'Function'});
183 }
184
185 #
186 # This allows us to set a post-process function.
187 #
188 sub postProcess
189 {
190 my $self = shift;
191 my %params = @_;
192 my $name = "$self->{'Type'}::postProcess";
193
194 # Set the values.
195 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
196 Cdk::Entry::PostProcess ($self->{'Me'}, $params{'Function'});
197 }
198
199 #
200 # This draws the object.
201 #
202 sub draw
203 {
204 my $self = shift;
205 my %params = @_;
206 my $name = "$self->{'Type'}::draw";
207
208 # Set the values.
209 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
210
211 # Draw the object.
212 Cdk::Entry::Draw ($self->{'Me'}, $box);
213 }
214
215 #
216 # This erases the object.
217 #
218 sub erase
219 {
220 my $self = shift;
221 Cdk::Entry::Erase ($self->{'Me'});
222 }
223
224 #
225 # This cleans the info inside the entry object.
226 #
227 sub clean
228 {
229 my $self = shift;
230 Cdk::Entry::Clean ($self->{'Me'});
231 }
232
233 #
234 # This function raises the object.
235 #
236 sub raise
237 {
238 my $self = shift;
239 Cdk::Entry::Raise ($self->{'Me'});
240 }
241
242 #
243 # This function lowers the object.
244 #
245 sub lower
246 {
247 my $self = shift;
248 Cdk::Entry::Lower ($self->{'Me'});
249 }
250
251 #
252 # This function registers the object.
253 #
254 sub register
255 {
256 my $self = shift;
257 Cdk::Entry::Register ($self->{'Me'});
258 }
259
260 #
261 # This function unregisters the object.
262 #
263 sub unregister
264 {
265 my $self = shift;
266 Cdk::Entry::Unregister ($self->{'Me'});
267 }
268
269 #
270 # This function returns the pointer to the window.
271 #
272 sub getwin
273 {
274 my $self = shift;
275 Cdk::Entry::GetWindow ($self->{'Me'});
276 }
277
278 1;
+0
-272
Cdk/Fselect.pm less more
0 package Cdk::Fselect;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new file selector object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $height = Cdk::checkReq ($name, "Height", $params{'Height'});
19 my $width = Cdk::checkReq ($name, "Width", $params{'Width'});
20 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
21 my $label = Cdk::checkDef ($name, "Label", $params{'Label'}, "");
22 my $dattrib = Cdk::checkDef ($name, "Dattrib", $params{'Dattrib'}, "</B>");
23 my $fattrib = Cdk::checkDef ($name, "Fattrib", $params{'Fattrib'}, "</N>");
24 my $lattrib = Cdk::checkDef ($name, "Lattrib", $params{'Lattrib'}, "</B>");
25 my $sattrib = Cdk::checkDef ($name, "Sattrib", $params{'Sattrib'}, "</B>");
26 my $hlight = Cdk::checkDef ($name, "Highlight", $params{'Highlight'}, "A_REVERSE");
27 my $filler = Cdk::checkDef ($name, "Filler", $params{'Filler'}, ".");
28 my $fAttr = Cdk::checkDef ($name, "Fieldattr", $params{'Fieldattr'}, "A_NORMAL");
29 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
30 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
31 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
32 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
33
34 # Create the thing.
35 $self->{'Me'} = Cdk::Fselect::New ($title, $label, $height, $width,
36 $dattrib, $fattrib, $lattrib, $sattrib,
37 $hlight, $fAttr, $filler,
38 $xpos, $ypos, $box, $shadow);
39 bless $self;
40 }
41
42 #
43 # This activates the object
44 #
45 sub activate
46 {
47 my $self = shift;
48 my %params = @_;
49 my $name = "$self->{'Type'}::activate";
50
51 # Activate the object...
52 if (defined $params{'Input'})
53 {
54 $self->{'Info'} = Cdk::Fselect::Activate ($self->{'Me'}, $params{'Input'});
55 }
56 else
57 {
58 $self->{'Info'} = Cdk::Fselect::Activate ($self->{'Me'});
59 }
60 return ($self->{'Info'});
61 }
62
63 #
64 # This sets several parameters of the widget.
65 #
66 sub set
67 {
68 my $self = shift;
69 my %params = @_;
70 my $name = "$self->{'Type'}::set";
71
72 #
73 # Check the parameters sent in.
74 #
75 if (defined $params{'Directory'})
76 {
77 Cdk::Fselect::SetDirectory ($self->{'Me'}, $params{'Directory'});
78 }
79 if (defined $params{'FillerChar'})
80 {
81 Cdk::Fselect::SetFillerChar ($self->{'Me'}, $params{'FillerChar'});
82 }
83 if (defined $params{'Highlight'})
84 {
85 Cdk::Fselect::SetHighlight ($self->{'Me'}, $params{'Highlight'});
86 }
87 if (defined $params{'DirAttribute'})
88 {
89 Cdk::Fselect::SetDirAttribute ($self->{'Me'}, $params{'DirAttribute'});
90 }
91 if (defined $params{'LinkAttribute'})
92 {
93 Cdk::Fselect::SetLinkAttribute ($self->{'Me'}, $params{'LinkAttribute'});
94 }
95 if (defined $params{'FileAttribute'})
96 {
97 Cdk::Fselect::SetFileAttribute ($self->{'Me'}, $params{'FileAttribute'});
98 }
99 if (defined $params{'SocketAttribute'})
100 {
101 Cdk::Fselect::SetSocketAttribute ($self->{'Me'}, $params{'SocketAttribute'});
102 }
103 if (defined $params{'ULChar'})
104 {
105 Cdk::Fselect::SetULChar ($self->{'Me'}, $params{'ULChar'});
106 }
107 if (defined $params{'URChar'})
108 {
109 Cdk::Fselect::SetURChar ($self->{'Me'}, $params{'URChar'});
110 }
111 if (defined $params{'LLChar'})
112 {
113 Cdk::Fselect::SetLLChar ($self->{'Me'}, $params{'LLChar'});
114 }
115 if (defined $params{'LRChar'})
116 {
117 Cdk::Fselect::SetLRChar ($self->{'Me'}, $params{'LRChar'});
118 }
119 if (defined $params{'VChar'})
120 {
121 Cdk::Fselect::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
122 }
123 if (defined $params{'HChar'})
124 {
125 Cdk::Fselect::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
126 }
127 if (defined $params{'BoxAttribute'})
128 {
129 Cdk::Fselect::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
130 }
131 if (defined $params{'BGColor'})
132 {
133 Cdk::Fselect::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
134 }
135 if (defined $params{'Box'})
136 {
137 Cdk::Fselect::SetBox ($self->{'Me'}, $params{'Box'});
138 }
139 }
140 #
141 # This function allows the user to get the current value from the widget.
142 #
143 sub get
144 {
145 my $self = shift;
146 return (Cdk::Fselect::Get ($self->{'Me'}));
147 }
148
149 #
150 # This allows us to bind a key to an action.
151 #
152 sub bind
153 {
154 my $self = shift;
155 my %params = @_;
156 my $name = "$self->{'Type'}::bind";
157
158 # Set the values.
159 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
160 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
161 Cdk::Fselect::Bind ($self->{'Me'}, $params{'Key'}, $params{'Function'});
162 }
163
164 #
165 # This allows us to set a pre-process function.
166 #
167 sub preProcess
168 {
169 my $self = shift;
170 my %params = @_;
171 my $name = "$self->{'Type'}::preProcess";
172
173 # Set the values.
174 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
175 Cdk::Fselect::PreProcess ($self->{'Me'}, $params{'Function'});
176 }
177
178 #
179 # This allows us to set a post-process function.
180 #
181 sub postProcess
182 {
183 my $self = shift;
184 my %params = @_;
185 my $name = "$self->{'Type'}::postProcess";
186
187 # Set the values.
188 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
189 Cdk::Fselect::PostProcess ($self->{'Me'}, $params{'Function'});
190 }
191
192 #
193 # This draws the object.
194 #
195 sub draw
196 {
197 my $self = shift;
198 my %params = @_;
199 my $name = "$self->{'Type'}::draw";
200
201 # Set the values.
202 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
203
204 # Draw the object.
205 Cdk::Fselect::Draw ($self->{'Me'}, $box);
206 }
207
208 #
209 # This erases the object.
210 #
211 sub erase
212 {
213 my $self = shift;
214 Cdk::Fselect::Erase ($self->{'Me'});
215 }
216
217 #
218 # This cleans the info inside the entry object.
219 #
220 sub clean
221 {
222 my $self = shift;
223 Cdk::Fselect::Clean ($self->{'Me'});
224 }
225
226 #
227 # This function raises the object.
228 #
229 sub raise
230 {
231 my $self = shift;
232 Cdk::Fselect::Raise ($self->{'Me'});
233 }
234
235 #
236 # This function lowers the object.
237 #
238 sub lower
239 {
240 my $self = shift;
241 Cdk::Fselect::Lower ($self->{'Me'});
242 }
243
244 #
245 # This function registers the object.
246 #
247 sub register
248 {
249 my $self = shift;
250 Cdk::Fselect::Register ($self->{'Me'});
251 }
252
253 #
254 # This function unregisters the object.
255 #
256 sub unregister
257 {
258 my $self = shift;
259 Cdk::Fselect::Unregister ($self->{'Me'});
260 }
261
262 #
263 # This function returns the pointer to the window.
264 #
265 sub getwin
266 {
267 my $self = shift;
268 Cdk::Fselect::GetWindow ($self->{'Me'});
269 }
270
271 1;
+0
-168
Cdk/Graph.pm less more
0 # $Id: Graph.pm,v 1.2 2001/01/08 01:54:15 tom Exp $
1
2 package Cdk::Graph;
3
4 @ISA = qw (Cdk);
5
6 #
7 # This creates a new Graph object.
8 #
9 sub new
10 {
11 my $type = shift;
12 my %params = @_;
13 my $self = {};
14 my $name = "${type}::new";
15
16 # Retain the type of the object.
17 $self->{'Type'} = $type;
18
19 # Set up the parameters passed in.
20 my $xtitle = Cdk::checkReq ($name, "Xtitle", $params{'Xtitle'});
21 my $ytitle = Cdk::checkReq ($name, "ytitle", $params{'Ytitle'});
22 my $height = Cdk::checkReq ($name, "Height", $params{'Height'});
23 my $width = Cdk::checkReq ($name, "Width", $params{'Width'});
24 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
25 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
26 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
27
28 # Create the thing.
29 $self->{'Me'} = Cdk::Graph::New ($title, $xtitle, $ytitle, $height, $width, $xpos, $ypos);
30 bless $self;
31 }
32
33 #
34 # This sets several parameters of the widget.
35 #
36 sub set
37 {
38 my $self = shift;
39 my %params = @_;
40 my $name = "$self->{'Type'}::set";
41
42 #
43 # Check the parameters sent in.
44 #
45 if (defined $params{'Values'})
46 {
47 my $startAtZero = $params{'StartAtZero'} || 1;
48 Cdk::Graph::SetValues ($self->{'Me'}, $params{'Values'}, $startAtZero);
49 }
50 if (defined $params{'GraphChars'})
51 {
52 Cdk::Graph::SetCharacters ($self->{'Me'}, $params{'GraphChars'});
53 }
54 if (defined $params{'DisplayType'})
55 {
56 Cdk::Graph::SetDisplayType ($self->{'Me'}, $params{'DisplayType'});
57 }
58 if (defined $params{'ULChar'})
59 {
60 Cdk::Graph::SetULChar ($self->{'Me'}, $params{'ULChar'});
61 }
62 if (defined $params{'URChar'})
63 {
64 Cdk::Graph::SetURChar ($self->{'Me'}, $params{'URChar'});
65 }
66 if (defined $params{'LLChar'})
67 {
68 Cdk::Graph::SetLLChar ($self->{'Me'}, $params{'LLChar'});
69 }
70 if (defined $params{'LRChar'})
71 {
72 Cdk::Graph::SetLRChar ($self->{'Me'}, $params{'LRChar'});
73 }
74 if (defined $params{'VChar'})
75 {
76 Cdk::Graph::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
77 }
78 if (defined $params{'HChar'})
79 {
80 Cdk::Graph::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
81 }
82 if (defined $params{'BoxAttribute'})
83 {
84 Cdk::Graph::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
85 }
86 if (defined $params{'BGColor'})
87 {
88 Cdk::Graph::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
89 }
90 if (defined $params{'Box'})
91 {
92 Cdk::Graph::SetBox ($self->{'Me'}, $params{'Box'});
93 }
94 }
95
96 #
97 # This draws the object.
98 #
99 sub draw
100 {
101 my $self = shift;
102 my %params = @_;
103 my $name = "$self->{'Type'}::draw";
104
105 # Set up the parameters passed in.
106 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "FALSE");
107
108 # Draw the object.
109 Cdk::Graph::Draw ($self->{'Me'}, $box);
110 return 1;
111 }
112
113 #
114 # This erases the object.
115 #
116 sub erase
117 {
118 my $self = shift;
119 Cdk::Graph::Erase ($self->{'Me'});
120 }
121
122 #
123 # This function raises the object.
124 #
125 sub raise
126 {
127 my $self = shift;
128 Cdk::Graph::Raise ($self->{'Me'});
129 }
130
131 #
132 # This function lowers the object.
133 #
134 sub lower
135 {
136 my $self = shift;
137 Cdk::Graph::Lower ($self->{'Me'});
138 }
139
140 #
141 # This function registers the object.
142 #
143 sub register
144 {
145 my $self = shift;
146 Cdk::Graph::Register ($self->{'Me'});
147 }
148
149 #
150 # This function unregisters the object.
151 #
152 sub unregister
153 {
154 my $self = shift;
155 Cdk::Graph::Unregister ($self->{'Me'});
156 }
157
158 #
159 # This function returns the pointer to the window.
160 #
161 sub getwin
162 {
163 my $self = shift;
164 Cdk::Graph::GetWindow ($self->{'Me'});
165 }
166
167 1;
+0
-174
Cdk/Histogram.pm less more
0 package Cdk::Histogram;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Histogram object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $height = Cdk::checkReq ($name, "Height", $params{'Height'});
19 my $width = Cdk::checkReq ($name, "Width", $params{'Width'});
20 my $orient = Cdk::checkReq ($name, "Orient", $params{'Orient'});
21 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
22 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
23 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
24 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
25 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
26
27 # Create the thing.
28 $self->{'Me'} = Cdk::Histogram::New ($title, $height, $width, $orient,
29 $xpos, $ypos, $box, $shadow);
30 bless $self;
31 }
32
33 #
34 # This sets several parameters of the widget.
35 #
36 sub set
37 {
38 my $self = shift;
39 my %params = @_;
40 my $name = "$self->{'Type'}::set";
41
42 #
43 # Check the parameters sent in.
44 #
45 if (defined $params{'Value'})
46 {
47 Cdk::Histogram::SetValue ($self->{'Me'}, $params{'Low'}, $params{'High'}, $params{'Value'});
48 }
49 if (defined $params{'DisplayType'})
50 {
51 Cdk::Histogram::SetDisplayType ($self->{'Me'}, $params{'DisplayType'});
52 }
53 if (defined $params{'FillerChar'})
54 {
55 Cdk::Histogram::SetFillerChar ($self->{'Me'}, $params{'FillerChar'});
56 }
57 if (defined $params{'StatsPos'})
58 {
59 Cdk::Histogram::SetStatsPos ($self->{'Me'}, $params{'StatsPos'});
60 }
61 if (defined $params{'StatsAttr'})
62 {
63 Cdk::Histogram::SetStatsAttr ($self->{'Me'}, $params{'StatsAttr'});
64 }
65 if (defined $params{'ULChar'})
66 {
67 Cdk::Histogram::SetULChar ($self->{'Me'}, $params{'ULChar'});
68 }
69 if (defined $params{'URChar'})
70 {
71 Cdk::Histogram::SetURChar ($self->{'Me'}, $params{'URChar'});
72 }
73 if (defined $params{'LLChar'})
74 {
75 Cdk::Histogram::SetLLChar ($self->{'Me'}, $params{'LLChar'});
76 }
77 if (defined $params{'LRChar'})
78 {
79 Cdk::Histogram::SetLRChar ($self->{'Me'}, $params{'LRChar'});
80 }
81 if (defined $params{'VChar'})
82 {
83 Cdk::Histogram::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
84 }
85 if (defined $params{'HChar'})
86 {
87 Cdk::Histogram::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
88 }
89 if (defined $params{'BoxAttribute'})
90 {
91 Cdk::Histogram::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
92 }
93 if (defined $params{'BGColor'})
94 {
95 Cdk::Histogram::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
96 }
97 if (defined $params{'Box'})
98 {
99 Cdk::Histogram::SetBox ($self->{'Me'}, $params{'Box'});
100 }
101 }
102
103 #
104 # This draws the object.
105 #
106 sub draw
107 {
108 my $self = shift;
109 my %params = @_;
110 my $name = "$self->{'Type'}::draw";
111
112 # Set up the parameters passed in.
113 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
114
115 # Draw the object.
116 Cdk::Histogram::Draw ($self->{'Me'}, $box);
117 }
118
119 #
120 # This erases the object.
121 #
122 sub erase
123 {
124 my $self = shift;
125 Cdk::Histogram::Erase ($self->{'Me'});
126 }
127
128 #
129 # This function raises the object.
130 #
131 sub raise
132 {
133 my $self = shift;
134 Cdk::Histogram::Raise ($self->{'Me'});
135 }
136
137 #
138 # This function lowers the object.
139 #
140 sub lower
141 {
142 my $self = shift;
143 Cdk::Histogram::Lower ($self->{'Me'});
144 }
145
146 #
147 # This function registers the object.
148 #
149 sub register
150 {
151 my $self = shift;
152 Cdk::Histogram::Register ($self->{'Me'});
153 }
154
155 #
156 # This function unregisters the object.
157 #
158 sub unregister
159 {
160 my $self = shift;
161 Cdk::Histogram::Unregister ($self->{'Me'});
162 }
163
164 #
165 # This function returns the pointer to the window.
166 #
167 sub getwin
168 {
169 my $self = shift;
170 Cdk::Histogram::GetWindow ($self->{'Me'});
171 }
172
173 1;
+0
-264
Cdk/Itemlist.pm less more
0 package Cdk::Itemlist;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Itemlist object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $info = Cdk::checkReq ($name, "List", $params{'List'});
19 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
20 my $label = Cdk::checkDef ($name, "Label", $params{'Label'}, "");
21 my $default = Cdk::checkDef ($name, 'Default', $params{'Default'}, 0);
22 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
23 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
24 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
25 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
26
27 # Create the thing.
28 $self->{'Me'} = Cdk::Itemlist::New ($title, $label, $params{'List'},
29 $default, $xpos, $ypos,
30 $box, $shadow);
31 bless $self;
32 }
33
34 #
35 # This activates the object
36 #
37 sub activate
38 {
39 my $self = shift;
40 my %params = @_;
41 my $name = "$self->{'Type'}::activate";
42
43 # Activate the object...
44 if (defined $params{'Input'})
45 {
46 $self->{'Info'} = Cdk::Itemlist::Activate ($self->{'Me'}, $params{'Input'});
47 }
48 else
49 {
50 $self->{'Info'} = Cdk::Itemlist::Activate ($self->{'Me'});
51 }
52 return ($self->{'Info'});
53 }
54
55 #
56 # This injects a character into the widget.
57 #
58 sub inject
59 {
60 my $self = shift;
61 my %params = @_;
62 my $name = "$self->{'Type'}::inject";
63
64 # Set the values.
65 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
66
67 return (Cdk::Itemlist::Inject ($self->{'Me'}, $character));
68 }
69
70 #
71 # This sets several parameters of the widget.
72 #
73 sub set
74 {
75 my $self = shift;
76 my %params = @_;
77 my $name = "$self->{'Type'}::set";
78
79 #
80 # Check the parameters sent in.
81 #
82 if (defined $params{'Values'})
83 {
84 Cdk::Itemlist::SetValues ($self->{'Me'}, $params{'Values'});
85 }
86 if (defined $params{'DefaultItem'})
87 {
88 Cdk::Itemlist::SetDefaultItem ($self->{'Me'}, $params{'DefaultItem'});
89 }
90 if (defined $params{'CurrentItem'})
91 {
92 Cdk::Itemlist::SetCurrentItem ($self->{'Me'}, $params{'CurrentItem'});
93 }
94 if (defined $params{'ULChar'})
95 {
96 Cdk::Itemlist::SetULChar ($self->{'Me'}, $params{'ULChar'});
97 }
98 if (defined $params{'URChar'})
99 {
100 Cdk::Itemlist::SetURChar ($self->{'Me'}, $params{'URChar'});
101 }
102 if (defined $params{'LLChar'})
103 {
104 Cdk::Itemlist::SetLLChar ($self->{'Me'}, $params{'LLChar'});
105 }
106 if (defined $params{'LRChar'})
107 {
108 Cdk::Itemlist::SetLRChar ($self->{'Me'}, $params{'LRChar'});
109 }
110 if (defined $params{'VChar'})
111 {
112 Cdk::Itemlist::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
113 }
114 if (defined $params{'HChar'})
115 {
116 Cdk::Itemlist::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
117 }
118 if (defined $params{'BoxAttribute'})
119 {
120 Cdk::Itemlist::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
121 }
122 if (defined $params{'BGColor'})
123 {
124 Cdk::Itemlist::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
125 }
126 if (defined $params{'Box'})
127 {
128 Cdk::Itemlist::SetBox ($self->{'Me'}, $params{'Box'});
129 }
130 }
131
132 #
133 # This function allows the user to get the current value from the widget.
134 #
135 sub get
136 {
137 my $self = shift;
138 return (Cdk::Itemlist::Get ($self->{'Me'}));
139 }
140
141 #
142 # This allows us to bind a key to an action.
143 #
144 sub bind
145 {
146 my $self = shift;
147 my %params = @_;
148 my $name = "$self->{'Type'}::bind";
149
150 # Set the values.
151 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
152 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
153 Cdk::Itemlist::Bind ($self->{'Me'}, $key, $params{'Function'});
154 }
155
156 #
157 # This allows us to set a pre-process function.
158 #
159 sub preProcess
160 {
161 my $self = shift;
162 my %params = @_;
163 my $name = "$self->{'Type'}::preProcess";
164
165 # Set the values.
166 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
167 Cdk::Itemlist::PreProcess ($self->{'Me'}, $params{'Function'});
168 }
169
170 #
171 # This allows us to set a post-process function.
172 #
173 sub postProcess
174 {
175 my $self = shift;
176 my %params = @_;
177 my $name = "$self->{'Type'}::postProcess";
178
179 # Set the values.
180 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
181 Cdk::Itemlist::PostProcess ($self->{'Me'}, $params{'Function'});
182 }
183
184 #
185 # This draws the object.
186 #
187 sub draw
188 {
189 my $self = shift;
190 my %params = @_;
191 my $name = "$self->{'Type'}::draw";
192
193 # Set the values.
194 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
195
196 # Draw the object.
197 Cdk::Itemlist::Draw ($self->{'Me'}, $box);
198 }
199
200 #
201 # This erases the object.
202 #
203 sub erase
204 {
205 my $self = shift;
206 Cdk::Itemlist::Erase ($self->{'Me'});
207 }
208
209 #
210 # This cleans the info inside the entry object.
211 #
212 sub clean
213 {
214 my $self = shift;
215 Cdk::Itemlist::Clean ($self->{'Me'});
216 }
217
218 #
219 # This function raises the object.
220 #
221 sub raise
222 {
223 my $self = shift;
224 Cdk::Itemlist::Raise ($self->{'Me'});
225 }
226
227 #
228 # This function lowers the object.
229 #
230 sub lower
231 {
232 my $self = shift;
233 Cdk::Itemlist::Lower ($self->{'Me'});
234 }
235
236 #
237 # This function registers the object.
238 #
239 sub register
240 {
241 my $self = shift;
242 Cdk::Itemlist::Register ($self->{'Me'});
243 }
244
245 #
246 # This function unregisters the object.
247 #
248 sub unregister
249 {
250 my $self = shift;
251 Cdk::Itemlist::Unregister ($self->{'Me'});
252 }
253
254 #
255 # This function returns the pointer to the window.
256 #
257 sub getwin
258 {
259 my $self = shift;
260 Cdk::Itemlist::GetWindow ($self->{'Me'});
261 }
262
263 1;
+0
-176
Cdk/Label.pm less more
0 # $Id: Label.pm,v 1.2 2002/07/28 19:29:24 tom Exp $
1
2 package Cdk::Label;
3
4 @ISA = qw (Cdk);
5
6 #
7 # This creates a new Label object
8 #
9 sub new
10 {
11 my $type = shift;
12 my %params = @_;
13 my $self = {};
14 my $name = "${type}::new";
15
16 # Retain the type of the object.
17 $self->{'Type'} = $type;
18
19 # Set up the parameters passed in.
20 my $mesg = Cdk::checkReq ($name, "Message", $params{'Message'});
21 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
22 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
23 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
24 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
25
26 # Create the thing.
27 $self->{'Me'} = Cdk::Label::New ($params{'Message'}, $xpos, $ypos, $box, $shadow);
28 bless $self;
29 }
30
31 #
32 # This sets several parameters of the widget.
33 #
34 sub set
35 {
36 my $self = shift;
37 my %params = @_;
38 my $name = "$self->{'Type'}::set";
39
40 #
41 # Check the parameters sent in.
42 #
43 if (defined $params{'Message'})
44 {
45 Cdk::Label::SetMessage ($self->{'Me'}, $params{'Message'});
46 }
47 if (defined $params{'ULChar'})
48 {
49 Cdk::Label::SetULChar ($self->{'Me'}, $params{'ULChar'});
50 }
51 if (defined $params{'URChar'})
52 {
53 Cdk::Label::SetURChar ($self->{'Me'}, $params{'URChar'});
54 }
55 if (defined $params{'LLChar'})
56 {
57 Cdk::Label::SetLLChar ($self->{'Me'}, $params{'LLChar'});
58 }
59 if (defined $params{'LRChar'})
60 {
61 Cdk::Label::SetLRChar ($self->{'Me'}, $params{'LRChar'});
62 }
63 if (defined $params{'VChar'})
64 {
65 Cdk::Label::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
66 }
67 if (defined $params{'HChar'})
68 {
69 Cdk::Label::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
70 }
71 if (defined $params{'BoxAttribute'})
72 {
73 Cdk::Label::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
74 }
75 if (defined $params{'BGColor'})
76 {
77 Cdk::Label::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
78 }
79 if (defined $params{'Box'})
80 {
81 Cdk::Label::SetBox ($self->{'Me'}, $params{'Box'});
82 }
83 }
84
85 #
86 # This draws the label object.
87 #
88 sub draw
89 {
90 my $self = shift;
91 my %params = @_;
92 my $name = "$self->{'Type'}::draw";
93
94 # Set up the parameters passed in.
95 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
96
97 # Draw the object.
98 Cdk::Label::Draw ($self->{'Me'}, $box);
99 }
100
101 #
102 # This erases the object from the screen.
103 #
104 sub erase
105 {
106 my $self = shift;
107 Cdk::Label::Erase ($self->{'Me'});
108 }
109
110 #
111 # This gives the user the ability to wait until a key is hit.
112 #
113 sub wait
114 {
115 my $self = shift;
116 my %params = @_;
117 my $name = "$self->{'Type'}::wait";
118
119 # Set up the parameters passed in.
120 my $key = Cdk::checkDef ($name, "Key", $params{'Key'}, '');
121 my $code = 0;
122 if ($key ne '') {
123 $code = ord $key;
124 }
125
126 # Sit and wait.
127 Cdk::Label::Wait ($self->{'Me'}, $code);
128 }
129
130 #
131 # This function raises the object.
132 #
133 sub raise
134 {
135 my $self = shift;
136 Cdk::Label::Raise ($self->{'Me'});
137 }
138
139 #
140 # This function lowers the object.
141 #
142 sub lower
143 {
144 my $self = shift;
145 Cdk::Label::Lower ($self->{'Me'});
146 }
147
148 #
149 # This function registers the object.
150 #
151 sub register
152 {
153 my $self = shift;
154 Cdk::Label::Register ($self->{'Me'});
155 }
156
157 #
158 # This function unregisters the object.
159 #
160 sub unregister
161 {
162 my $self = shift;
163 Cdk::Label::Unregister ($self->{'Me'});
164 }
165
166 #
167 # This function returns the pointer to the window.
168 #
169 sub getwin
170 {
171 my $self = shift;
172 Cdk::Label::GetWindow ($self->{'Me'});
173 }
174
175 1;
+0
-179
Cdk/Marquee.pm less more
0 package Cdk::Marquee;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Marquee object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $width = Cdk::checkReq ($name, "Width", $params{'Width'});
19 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
20 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
21 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
22 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
23
24 # Create the thing.
25 $self->{'Me'} = Cdk::Marquee::New ($width, $xpos, $ypos, $box, $shadow);
26 bless $self;
27 }
28
29 #
30 # This activates the object
31 #
32 sub activate
33 {
34 my $self = shift;
35 my %params = @_;
36 my $name = "$self->{'Type'}::activate";
37
38 # Set the values.
39 my $message = Cdk::checkReq ($name, "Message", $params{'Message'});
40 my $delay = Cdk::checkReq ($name, "Delay", $params{'Delay'});
41 my $repeat = Cdk::checkReq ($name, "Repeat", $params{'Repeat'});
42 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
43
44 # Store the information in both the object and Perl's stack.
45 $self->{'Info'} = Cdk::Marquee::Activate ($self->{'Me'}, $params{'Message'}, $delay, $repeat, $box);
46 return ($self->{'Info'});
47 }
48
49 #
50 # This turns off the marquee.
51 #
52 sub deactivate
53 {
54 my $self = shift;
55 Cdk::Marquee::Deactivate ($self->{'Me'});
56 }
57
58 #
59 # This sets several parameters of the widget.
60 #
61 sub set
62 {
63 my $self = shift;
64 my %params = @_;
65 my $name = "$self->{'Type'}::set";
66
67 #
68 # Check the parameters sent in.
69 #
70 if (defined $params{'ULChar'})
71 {
72 Cdk::Marquee::SetULChar ($self->{'Me'}, $params{'ULChar'});
73 }
74 if (defined $params{'URChar'})
75 {
76 Cdk::Marquee::SetURChar ($self->{'Me'}, $params{'URChar'});
77 }
78 if (defined $params{'LLChar'})
79 {
80 Cdk::Marquee::SetLLChar ($self->{'Me'}, $params{'LLChar'});
81 }
82 if (defined $params{'LRChar'})
83 {
84 Cdk::Marquee::SetLRChar ($self->{'Me'}, $params{'LRChar'});
85 }
86 if (defined $params{'VChar'})
87 {
88 Cdk::Marquee::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
89 }
90 if (defined $params{'HChar'})
91 {
92 Cdk::Marquee::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
93 }
94 if (defined $params{'BoxAttribute'})
95 {
96 Cdk::Marquee::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
97 }
98 if (defined $params{'BGColor'})
99 {
100 Cdk::Marquee::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
101 }
102 if (defined $params{'Box'})
103 {
104 Cdk::Marquee::SetBox ($self->{'Me'}, $params{'Box'});
105 }
106 }
107
108 #
109 # This draws the object.
110 #
111 sub draw
112 {
113 my $self = shift;
114 my %params = @_;
115 my $name = "$self->{'Type'}::draw";
116
117 # Set up the parameters passed in.
118 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
119
120 # Draw the object.
121 Cdk::Marquee::Draw ($self->{'Me'}, $box);
122 }
123
124 #
125 # This erases the object.
126 #
127 sub erase
128 {
129 my $self = shift;
130 Cdk::Marquee::Erase ($self->{'Me'});
131 }
132
133 #
134 # This function raises the object.
135 #
136 sub raise
137 {
138 my $self = shift;
139 Cdk::Marquee::Raise ($self->{'Me'});
140 }
141
142 #
143 # This function lowers the object.
144 #
145 sub lower
146 {
147 my $self = shift;
148 Cdk::Marquee::Lower ($self->{'Me'});
149 }
150
151 #
152 # This function registers the object.
153 #
154 sub register
155 {
156 my $self = shift;
157 Cdk::Marquee::Register ($self->{'Me'});
158 }
159
160 #
161 # This function unregisters the object.
162 #
163 sub unregister
164 {
165 my $self = shift;
166 Cdk::Marquee::Unregister ($self->{'Me'});
167 }
168
169 #
170 # This function returns the pointer to the window.
171 #
172 sub getwin
173 {
174 my $self = shift;
175 Cdk::Marquee::GetWindow ($self->{'Me'});
176 }
177
178 1;
+0
-301
Cdk/Matrix.pm less more
0 package Cdk::Matrix;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Matrix object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $rowtitles = Cdk::checkReq ($name, "RowTitles", $params{'RowTitles'});
19 my $coltitles = Cdk::checkReq ($name, "ColTitles", $params{'ColTitles'});
20 my $colwidths = Cdk::checkReq ($name, "ColWidths", $params{'ColWidths'});
21 my $coltypes = Cdk::checkReq ($name, "ColTypes", $params{'ColTypes'});
22 my $vrows = Cdk::checkReq ($name, "Vrows", $params{'Vrows'});
23 my $vcols = Cdk::checkReq ($name, "Vcols", $params{'Vcols'});
24 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
25 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
26 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
27 my $rowSpace = Cdk::checkDef ($name, "RowSpace", $params{'RowSpace'}, 1);
28 my $colSpace = Cdk::checkDef ($name, "ColSpace", $params{'ColSpace'}, 1);
29 my $filler = Cdk::checkDef ($name, "Filler", $params{'Filler'}, ".");
30 my $dominant = Cdk::checkDef ($name, "Dominant", $params{'Dominant'}, "NONE");
31 my $box = Cdk::checkDef ($name, "BoxMatrix", $params{'BoxMatrix'}, "FALSE");
32 my $boxCell = Cdk::checkDef ($name, "BoxCell", $params{'BoxCell'}, "TRUE");
33 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
34
35 # Create the thing.
36 $self->{'Me'} = Cdk::Matrix::New ($title,
37 $params{'RowTitles'},
38 $params{'ColTitles'},
39 $params{'ColWidths'},
40 $params{'ColTypes'},
41 $vrows, $vcols,
42 $xpos, $ypos,
43 $rowSpace, $colSpace,
44 $filler, $dominant,
45 $boxCell, $box, $shadow);
46 bless $self;
47 }
48
49 #
50 # This activates the object
51 #
52 sub activate
53 {
54 my $self = shift;
55 my %params = @_;
56 my $name = "$self->{'Type'}::activate";
57
58 # Activate the matrix.
59 return (Cdk::Matrix::Activate ($self->{'Me'}));
60 }
61
62 #
63 # This injects a character into the widget.
64 #
65 sub inject
66 {
67 my $self = shift;
68 my %params = @_;
69 my $name = "$self->{'Type'}::inject";
70
71 # Set the values.
72 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
73
74 return (Cdk::Matrix::Inject ($self->{'Me'}, $character));
75 }
76
77 #
78 # This sets several parameters of the widget.
79 #
80 sub set
81 {
82 my $self = shift;
83 my %params = @_;
84 my $name = "$self->{'Type'}::set";
85
86 #
87 # Check the parameters sent in.
88 #
89 if (defined $params{'Values'})
90 {
91 Cdk::Matrix::Set ($self->{'Me'}, $params{'Values'});
92 }
93 if (defined $params{'Cell'})
94 {
95 Cdk::Matrix::SetCell ($self->{'Me'}, $params{'Row'}, $params{'Col'}, $params{'Value'});
96 }
97 if (defined $params{'ULChar'})
98 {
99 Cdk::Matrix::SetULChar ($self->{'Me'}, $params{'ULChar'});
100 }
101 if (defined $params{'URChar'})
102 {
103 Cdk::Matrix::SetURChar ($self->{'Me'}, $params{'URChar'});
104 }
105 if (defined $params{'LLChar'})
106 {
107 Cdk::Matrix::SetLLChar ($self->{'Me'}, $params{'LLChar'});
108 }
109 if (defined $params{'LRChar'})
110 {
111 Cdk::Matrix::SetLRChar ($self->{'Me'}, $params{'LRChar'});
112 }
113 if (defined $params{'VChar'})
114 {
115 Cdk::Matrix::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
116 }
117 if (defined $params{'HChar'})
118 {
119 Cdk::Matrix::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
120 }
121 if (defined $params{'BoxAttribute'})
122 {
123 Cdk::Matrix::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
124 }
125 if (defined $params{'BGColor'})
126 {
127 Cdk::Matrix::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
128 }
129 if (defined $params{'Box'})
130 {
131 Cdk::Matrix::SetBox ($self->{'Me'}, $params{'Box'});
132 }
133 }
134
135 #
136 # These get several parameters of the widget.
137 #
138 sub getCell
139 {
140 my $self = shift;
141 my %params = @_;
142 my $name = "$self->{'Type'}::getCell";
143
144 Cdk::Matrix::GetCell ($self->{'Me'}, $params{'Row'}, $params{'Col'});
145 }
146 sub getCol
147 {
148 my $self = shift;
149 my %params = @_;
150 my $name = "$self->{'Type'}::getCol";
151
152 Cdk::Matrix::GetCol ($self->{'Me'});
153 }
154 sub getRow
155 {
156 my $self = shift;
157 my %params = @_;
158 my $name = "$self->{'Type'}::getRow";
159
160 Cdk::Matrix::GetRow ($self->{'Me'});
161 }
162
163 #
164 # This allows the user to clean the matrices cell values.
165 #
166 sub clean
167 {
168 my $self = shift;
169 my $name = "$self->{'Type'}::clean";
170 Cdk::Matrix::Clean ($self->{'Me'});
171 }
172
173 #
174 # This allows the user to dump the matrices cell values.
175 #
176 sub dump
177 {
178 my $self = shift;
179 my %params = @_;
180 my $name = "$self->{'Type'}::flush";
181 my $title = $params{'Title'} || "No Title";
182
183 # Call the function that does this.
184 Cdk::Matrix::Dump ($self->{'Me'}, $title);
185 }
186
187 #
188 # This draws the object.
189 #
190 sub draw
191 {
192 my $self = shift;
193 my %params = @_;
194 my $name = "$self->{'Type'}::draw";
195
196 # Set up the parameters passed in.
197 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
198
199 # Draw the object.
200 Cdk::Matrix::Draw ($self->{'Me'}, $box);
201 }
202
203 #
204 # This erases the object.
205 #
206 sub erase
207 {
208 my $self = shift;
209 Cdk::Matrix::Erase ($self->{'Me'});
210 }
211
212 #
213 # This function raises the object.
214 #
215 sub raise
216 {
217 my $self = shift;
218 Cdk::Matrix::Raise ($self->{'Me'});
219 }
220
221 #
222 # This function lowers the object.
223 #
224 sub lower
225 {
226 my $self = shift;
227 Cdk::Matrix::Lower ($self->{'Me'});
228 }
229
230 #
231 # This function registers the object.
232 #
233 sub register
234 {
235 my $self = shift;
236 Cdk::Matrix::Register ($self->{'Me'});
237 }
238
239 #
240 # This function unregisters the object.
241 #
242 sub unregister
243 {
244 my $self = shift;
245 Cdk::Matrix::Unregister ($self->{'Me'});
246 }
247
248 #
249 # This function returns the pointer to the window.
250 #
251 sub getwin
252 {
253 my $self = shift;
254 Cdk::Matrix::GetWindow ($self->{'Me'});
255 }
256
257 #
258 # This allows us to set a pre-process function.
259 #
260 sub preProcess
261 {
262 my $self = shift;
263 my %params = @_;
264 my $name = "$self->{'Type'}::preProcess";
265
266 # Set the values.
267 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
268 Cdk::Matrix::PreProcess ($self->{'Me'}, $params{'Function'});
269 }
270
271 #
272 # This allows us to set a post-process function.
273 #
274 sub postProcess
275 {
276 my $self = shift;
277 my %params = @_;
278 my $name = "$self->{'Type'}::postProcess";
279
280 # Set the values.
281 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
282 Cdk::Matrix::PostProcess ($self->{'Me'}, $params{'Function'});
283 }
284
285 #
286 # This allows us to bind a key to an action.
287 #
288 sub bind
289 {
290 my $self = shift;
291 my %params = @_;
292 my $name = "$self->{'Type'}::bind";
293
294 # Set the values.
295 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
296 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
297
298 Cdk::Matrix::Bind ($self->{'Me'}, $params{'Key'}, $params{'Function'});
299 }
300 1;
+0
-225
Cdk/Mentry.pm less more
0 package Cdk::Mentry;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Mentry object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $fWidth = Cdk::checkReq ($name, "Width", $params{'Width'});
19 my $physical = Cdk::checkReq ($name, "Prows", $params{'Prows'});
20 my $logical = Cdk::checkReq ($name, "Lrows", $params{'Lrows'});
21 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
22 my $label = Cdk::checkDef ($name, "Label", $params{'Label'}, "");
23 my $min = Cdk::checkDef ($name, "Min", $params{'Min'}, 0);
24 my $dispType = Cdk::checkDef ($name, "Dtype", $params{'Dtype'}, "MIXED");
25 my $filler = Cdk::checkDef ($name, "Filler", $params{'Filler'}, ".");
26 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
27 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
28 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
29 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
30
31 # Create the thing.
32 $self->{'Me'} = Cdk::Mentry::New ($title, $label, $min,
33 $physical, $logical, $fWidth,
34 $dispType, $filler,
35 $xpos, $ypos,
36 $fieldattr, $box, $shadow);
37 bless $self;
38 }
39
40 #
41 # This activates the object
42 #
43 sub activate
44 {
45 my $self = shift;
46 my %params = @_;
47 my $name = "$self->{'Type'}::activate";
48
49 # Activate the object...
50 if (defined $params{'Input'})
51 {
52 $self->{'Info'} = Cdk::Mentry::Activate ($self->{'Me'}, $params{'Input'});
53 }
54 else
55 {
56 $self->{'Info'} = Cdk::Mentry::Activate ($self->{'Me'});
57 }
58 return ($self->{'Info'});
59 }
60
61 #
62 # This injects a character into the widget.
63 #
64 sub inject
65 {
66 my $self = shift;
67 my %params = @_;
68 my $name = "$self->{'Type'}::inject";
69
70 # Set the values.
71 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
72
73 return (Cdk::Mentry::Inject ($self->{'Me'}, $character));
74 }
75
76 #
77 # This sets several parameters of the widget.
78 #
79 sub set
80 {
81 my $self = shift;
82 my %params = @_;
83 my $name = "$self->{'Type'}::set";
84
85 #
86 # Check the parameters sent in.
87 #
88 if (defined $params{'Value'})
89 {
90 Cdk::Mentry::SetValue ($self->{'Me'}, $params{'Value'});
91 }
92 if (defined $params{'Min'})
93 {
94 Cdk::Mentry::SetMin ($self->{'Me'}, $params{'Min'});
95 }
96 if (defined $params{'FillerChar'})
97 {
98 Cdk::Mentry::SetFillerChar ($self->{'Me'}, $params{'FillerChar'});
99 }
100 if (defined $params{'ULChar'})
101 {
102 Cdk::Mentry::SetULChar ($self->{'Me'}, $params{'ULChar'});
103 }
104 if (defined $params{'URChar'})
105 {
106 Cdk::Mentry::SetURChar ($self->{'Me'}, $params{'URChar'});
107 }
108 if (defined $params{'LLChar'})
109 {
110 Cdk::Mentry::SetLLChar ($self->{'Me'}, $params{'LLChar'});
111 }
112 if (defined $params{'LRChar'})
113 {
114 Cdk::Mentry::SetLRChar ($self->{'Me'}, $params{'LRChar'});
115 }
116 if (defined $params{'VChar'})
117 {
118 Cdk::Mentry::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
119 }
120 if (defined $params{'HChar'})
121 {
122 Cdk::Mentry::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
123 }
124 if (defined $params{'BoxAttribute'})
125 {
126 Cdk::Mentry::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
127 }
128 if (defined $params{'BGColor'})
129 {
130 Cdk::Mentry::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
131 }
132 if (defined $params{'Box'})
133 {
134 Cdk::Mentry::SetBox ($self->{'Me'}, $params{'Box'});
135 }
136 }
137
138 #
139 # This function allows the user to get the current value from the widget.
140 #
141 sub get
142 {
143 my $self = shift;
144 return (Cdk::Mentry::Get ($self->{'Me'}));
145 }
146
147 #
148 # This allows us to bind a key to an action.
149 #
150 sub bind
151 {
152 my $self = shift;
153 my %params = @_;
154 my $name = "$self->{'Type'}::bind";
155
156 # Set the values.
157 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
158 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
159 Cdk::Mentry::Bind ($self->{'Me'}, $key, $params{'Function'});
160 }
161
162 #
163 # This allows us to set a pre-process function.
164 #
165 sub preProcess
166 {
167 my $self = shift;
168 my %params = @_;
169 my $name = "$self->{'Type'}::preProcess";
170
171 # Set the values.
172 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
173 Cdk::Mentry::PreProcess ($self->{'Me'}, $params{'Function'});
174 }
175
176 #
177 # This allows us to set a post-process function.
178 #
179 sub postProcess
180 {
181 my $self = shift;
182 my %params = @_;
183 my $name = "$self->{'Type'}::postProcess";
184
185 # Set the values.
186 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
187 Cdk::Mentry::PostProcess ($self->{'Me'}, $params{'Function'});
188 }
189
190 #
191 # This draws the object.
192 #
193 sub draw
194 {
195 my $self = shift;
196 my %params = @_;
197 my $name = "$self->{'Type'}::draw";
198
199 # Set up the parameters passed in.
200 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
201
202 # Draw the object.
203 Cdk::Mentry::Draw ($self->{'Me'}, $box);
204 }
205
206 #
207 # This erases the object.
208 #
209 sub erase
210 {
211 my $self = shift;
212 Cdk::Mentry::Erase ($self->{'Me'});
213 }
214
215 #
216 # This cleans the information inside the object.
217 #
218 sub clean
219 {
220 my $self = shift;
221 Cdk::Mentry::Clean ($self->{'Me'});
222 }
223
224 1;
+0
-173
Cdk/Menu.pm less more
0 package Cdk::Menu;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Menu object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $menuList = Cdk::checkReq ($name, "Menulist", $params{'Menulist'});
19 my $menuLoc = Cdk::checkReq ($name, "Menuloc", $params{'Menuloc'});
20 my $menuPos = Cdk::checkDef ($name, "Menupos", $params{'Menupos'}, "TOP");
21 my $titleAttr = Cdk::checkDef ($name, "Tattrib", $params{'Tattrib'}, "A_REVERSE");
22 my $subTitleAttr = Cdk::checkDef ($name, "SubTattrib", $params{'SubTattrib'}, "A_REVERSE");
23
24 # Create the thing.
25 $self->{'Me'} = Cdk::Menu::New ($params{'Menulist'},
26 $params{'Menuloc'},
27 $titleAttr, $subTitleAttr, $menuPos);
28 bless $self;
29 }
30
31 #
32 # This activates the object
33 #
34 sub activate
35 {
36 my $self = shift;
37 my %params = @_;
38 my $name = "$self->{'Type'}::activate";
39 my $itemPicked;
40
41 # Activatate the menu
42 if (defined $params{'Input'})
43 {
44 $itemPicked = Cdk::Menu::Activate ($self->{'Me'}, $params{'Input'});
45 }
46 else
47 {
48 $itemPicked = Cdk::Menu::Activate ($self->{'Me'});
49 }
50
51 return if !defined $itemPicked;
52
53 $self->{'Info'} = $itemPicked;
54
55 # Create the menu and submenu item values and return them.
56 my $menuItem = int($itemPicked / 100);
57 my $submenuItem = ($itemPicked % 100) + 1;
58
59 # Return the two values.
60 return (($menuItem, $submenuItem, $itemPicked));
61 }
62
63 #
64 # This injects a character into the widget.
65 #
66 sub inject
67 {
68 my $self = shift;
69 my %params = @_;
70 my $name = "$self->{'Type'}::inject";
71
72 # Set the values.
73 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
74
75 return (Cdk::Menu::Inject ($self->{'Me'}, $character));
76 }
77
78 #
79 # This sets several parameters of the widget.
80 #
81 sub set
82 {
83 my $self = shift;
84 my %params = @_;
85 my $name = "$self->{'Type'}::set";
86
87 #
88 # Check the parameters sent in.
89 #
90 if (defined $params{'CurrentItem'})
91 {
92 Cdk::Menu::SetCurrentItem ($self->{'Me'}, $params{'CurrentItem'});
93 }
94 if (defined $params{'TitleHighlight'})
95 {
96 Cdk::Menu::SetTitleHighlight ($self->{'Me'}, $params{'TitleHighlight'});
97 }
98 if (defined $params{'SubTitleHighlight'})
99 {
100 Cdk::Menu::SetSubTitleHighlight ($self->{'Me'}, $params{'SubTitleHighlight'});
101 }
102 if (defined $params{'BGColor'})
103 {
104 Cdk::Menu::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
105 }
106 }
107 #
108 # This draws the object.
109 #
110 sub draw
111 {
112 my $self = shift;
113 my %params = @_;
114 my $name = "$self->{'Type'}::draw";
115
116 # Draw the object.
117 Cdk::Menu::Draw ($self->{'Me'});
118 }
119
120 #
121 # This erases the object.
122 #
123 sub erase
124 {
125 my $self = shift;
126 Cdk::Menu::Erase ($self->{'Me'});
127 }
128
129 #
130 # This allows us to bind a key to an action.
131 #
132 sub bind
133 {
134 my $self = shift;
135 my %params = @_;
136 my $name = "$self->{'Type'}::bind";
137
138 # Set the values.
139 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
140 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
141 Cdk::Menu::Bind ($self->{'Me'}, $params{'Key'}, $params{'Function'});
142 }
143
144 #
145 # This allows us to set a pre-process function.
146 #
147 sub preProcess
148 {
149 my $self = shift;
150 my %params = @_;
151 my $name = "$self->{'Type'}::preProcess";
152
153 # Set the values.
154 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
155 Cdk::Menu::PreProcess ($self->{'Me'}, $params{'Function'});
156 }
157
158 #
159 # This allows us to set a post-process function.
160 #
161 sub postProcess
162 {
163 my $self = shift;
164 my %params = @_;
165 my $name = "$self->{'Type'}::postProcess";
166
167 # Set the values.
168 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
169 Cdk::Menu::PostProcess ($self->{'Me'}, $params{'Function'});
170 }
171
172 1;
+0
-256
Cdk/Radio.pm less more
0 package Cdk::Radio;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Radio object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $list = Cdk::checkReq ($name, "List", $params{'List'});
19 my $height = Cdk::checkReq ($name, "Height", $params{'Height'});
20 my $width = Cdk::checkReq ($name, "Width", $params{'Width'});
21 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
22 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
23 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
24 my $spos = Cdk::checkDef ($name, "Spos", $params{'Spos'}, "NONE");
25 my $choice = Cdk::checkDef ($name, "Choice", $params{'Choice'}, "X");
26 my $default = Cdk::checkDef ($name, "Default", $params{'Default'}, 0);
27 my $hlight = Cdk::checkDef ($name, "Highlight", $params{'Highlight'}, "A_REVERSE");
28 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
29 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
30
31 # Create the thing.
32 $self->{'Me'} = Cdk::Radio::New ($title, $params{'List'},
33 $height, $width,
34 $xpos, $ypos, $spos,
35 $choice, $default, $hlight,
36 $box, $shadow);
37 bless $self;
38 }
39
40 #
41 # This activates the object
42 #
43 sub activate
44 {
45 my $self = shift;
46 my %params = @_;
47 my $name = "$self->{'Type'}::activate";
48
49 # Activate the object...
50 if (defined $params{'Input'})
51 {
52 $self->{'Info'} = Cdk::Radio::Activate ($self->{'Me'}, $params{'Input'});
53 }
54 else
55 {
56 $self->{'Info'} = Cdk::Radio::Activate ($self->{'Me'});
57 }
58 return ($self->{'Info'});
59 }
60
61 #
62 # This injects a character into the widget.
63 #
64 sub inject
65 {
66 my $self = shift;
67 my %params = @_;
68 my $name = "$self->{'Type'}::inject";
69
70 # Set the values.
71 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
72
73 return (Cdk::Radio::Inject ($self->{'Me'}, $character));
74 }
75
76 #
77 # This allows us to bind a key to an action.
78 #
79 sub bind
80 {
81 my $self = shift;
82 my %params = @_;
83 my $name = "$self->{'Type'}::bind";
84
85 # Set the values.
86 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
87 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
88 Cdk::Radio::Bind ($self->{'Me'}, $key, $params{'Function'});
89 }
90
91 #
92 # This allows us to set a pre-process function.
93 #
94 sub preProcess
95 {
96 my $self = shift;
97 my %params = @_;
98 my $name = "$self->{'Type'}::preProcess";
99
100 # Set the values.
101 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
102 Cdk::Radio::PreProcess ($self->{'Me'}, $params{'Function'});
103 }
104
105 #
106 # This allows us to set a post-process function.
107 #
108 sub postProcess
109 {
110 my $self = shift;
111 my %params = @_;
112 my $name = "$self->{'Type'}::postProcess";
113
114 # Set the values.
115 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
116 Cdk::Radio::PostProcess ($self->{'Me'}, $params{'Function'});
117 }
118
119 #
120 # This sets several parameters of the widget.
121 #
122 sub set
123 {
124 my $self = shift;
125 my %params = @_;
126 my $name = "$self->{'Type'}::set";
127
128 #
129 # Check the parameters sent in.
130 #
131 if (defined $params{'Highlight'})
132 {
133 Cdk::Radio::SetHighlight ($self->{'Me'}, $params{'Highlight'});
134 }
135 if (defined $params{'Choice'})
136 {
137 Cdk::Radio::SetChoiceCharacter ($self->{'Me'}, $params{'Choice'});
138 }
139 if (defined $params{'LeftBrace'})
140 {
141 Cdk::Radio::SetLeftBrace ($self->{'Me'}, $params{'LeftBrace'});
142 }
143 if (defined $params{'RightBrace'})
144 {
145 Cdk::Radio::SetRightBrace ($self->{'Me'}, $params{'RightBrace'});
146 }
147 if (defined $params{'ULChar'})
148 {
149 Cdk::Radio::SetULChar ($self->{'Me'}, $params{'ULChar'});
150 }
151 if (defined $params{'URChar'})
152 {
153 Cdk::Radio::SetURChar ($self->{'Me'}, $params{'URChar'});
154 }
155 if (defined $params{'LLChar'})
156 {
157 Cdk::Radio::SetLLChar ($self->{'Me'}, $params{'LLChar'});
158 }
159 if (defined $params{'LRChar'})
160 {
161 Cdk::Radio::SetLRChar ($self->{'Me'}, $params{'LRChar'});
162 }
163 if (defined $params{'VChar'})
164 {
165 Cdk::Radio::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
166 }
167 if (defined $params{'HChar'})
168 {
169 Cdk::Radio::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
170 }
171 if (defined $params{'BoxAttribute'})
172 {
173 Cdk::Radio::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
174 }
175 if (defined $params{'BGColor'})
176 {
177 Cdk::Radio::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
178 }
179 if (defined $params{'Box'})
180 {
181 Cdk::Radio::SetBox ($self->{'Me'}, $params{'Box'});
182 }
183 }
184
185 #
186 # This draws the object.
187 #
188 sub draw
189 {
190 my $self = shift;
191 my %params = @_;
192 my $name = "$self->{'Type'}::draw";
193
194 # Set up the parameters passed in.
195 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
196
197 # Draw the object.
198 Cdk::Radio::Draw ($self->{'Me'}, $box);
199 }
200
201 #
202 # This erases the object.
203 #
204 sub erase
205 {
206 my $self = shift;
207 Cdk::Radio::Erase ($self->{'Me'});
208 }
209
210 #
211 # This function raises the object.
212 #
213 sub raise
214 {
215 my $self = shift;
216 Cdk::Radio::Raise ($self->{'Me'});
217 }
218
219 #
220 # This function lowers the object.
221 #
222 sub lower
223 {
224 my $self = shift;
225 Cdk::Radio::Lower ($self->{'Me'});
226 }
227
228 #
229 # This function registers the object.
230 #
231 sub register
232 {
233 my $self = shift;
234 Cdk::Radio::Register ($self->{'Me'});
235 }
236
237 #
238 # This function unregisters the object.
239 #
240 sub unregister
241 {
242 my $self = shift;
243 Cdk::Radio::Unregister ($self->{'Me'});
244 }
245
246 #
247 # This function returns the pointer to the window.
248 #
249 sub getwin
250 {
251 my $self = shift;
252 Cdk::Radio::GetWindow ($self->{'Me'});
253 }
254
255 1;
+0
-248
Cdk/Scale.pm less more
0 package Cdk::Scale;
1
2 #
3 # This creates a new Scale object
4 #
5 sub new
6 {
7 my $type = shift;
8 my %params = @_;
9 my $self = {};
10 my $name = "${type}::new";
11 my $numWidth = length ($params{'High'}) + 2;
12
13 # Retain the type of the object.
14 $self->{'Type'} = $type;
15
16 # Set up the parameters passed in.
17 my $low = Cdk::checkReq ($name, "Low", $params{'Low'});
18 my $high = Cdk::checkReq ($name, "High", $params{'High'});
19 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
20 my $label = Cdk::checkDef ($name, "Label", $params{'Label'}, "");
21 my $width = Cdk::checkDef ($name, "Width", $params{'Width'}, $numWidth);
22 my $inc = Cdk::checkDef ($name, "Inc", $params{'Inc'}, 1);
23 my $fastInc = Cdk::checkDef ($name, "Fastinc", $params{'Fastinc'}, 5);
24 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
25 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
26 my $start = Cdk::checkDef ($name, "Start", $params{'Start'}, $params{'Low'});
27 my $fAttr = Cdk::checkDef ($name, "Fattrib", $params{'Fattrib'}, "A_NORMAL");
28 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
29 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
30
31 # Create the thing.
32 $self->{'Me'} = Cdk::Scale::New ($title, $label,
33 $start, $low,
34 $high, $inc, $fastInc,
35 $width, $xpos, $ypos,
36 $fAttr, $box, $shadow);
37 bless $self;
38 }
39
40 #
41 # This activates the object.
42 #
43 sub activate
44 {
45 my $self = shift;
46 my %params = @_;
47 my $name = "$self->{'Type'}::activate";
48
49 # Activate the object...
50 if (defined $params{'Input'})
51 {
52 $self->{'Info'} = Cdk::Scale::Activate ($self->{'Me'}, $params{'Input'});
53 }
54 else
55 {
56 $self->{'Info'} = Cdk::Scale::Activate ($self->{'Me'});
57 }
58 return ($self->{'Info'});
59 }
60
61 #
62 # This injects a character into the widget.
63 #
64 sub inject
65 {
66 my $self = shift;
67 my %params = @_;
68 my $name = "$self->{'Type'}::inject";
69
70 # Set the values.
71 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
72
73 return (Cdk::Scale::Inject ($self->{'Me'}, $character));
74 }
75
76 #
77 # This allows us to bind a key to an action.
78 #
79 sub bind
80 {
81 my $self = shift;
82 my %params = @_;
83 my $name = "$self->{'Type'}::bind";
84
85 # Set the values.
86 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
87 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
88 Cdk::Scale::Bind ($self->{'Me'}, $key, $params{'Function'});
89 }
90
91 #
92 # This allows us to set a pre-process function.
93 #
94 sub preProcess
95 {
96 my $self = shift;
97 my %params = @_;
98 my $name = "$self->{'Type'}::preProcess";
99
100 # Set the values.
101 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
102 Cdk::Scale::PreProcess ($self->{'Me'}, $params{'Function'});
103 }
104
105 #
106 # This allows us to set a post-process function.
107 #
108 sub postProcess
109 {
110 my $self = shift;
111 my %params = @_;
112 my $name = "$self->{'Type'}::postProcess";
113
114 # Set the values.
115 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
116 Cdk::Scale::PostProcess ($self->{'Me'}, $params{'Function'});
117 }
118
119 #
120 # This draws the object.
121 #
122 sub draw
123 {
124 my $self = shift;
125 my %params = @_;
126 my $name = "$self->{'Type'}::draw";
127
128 # Set up the parameters passed in.
129 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
130
131 # Draw the object.
132 Cdk::Scale::Draw ($self->{'Me'}, $box);
133 }
134
135 #
136 # This erases the object.
137 #
138 sub erase
139 {
140 my $self = shift;
141 Cdk::Scale::Erase ($self->{'Me'});
142 }
143
144 #
145 # This sets several parameters of the widget.
146 #
147 sub set
148 {
149 my $self = shift;
150 my %params = @_;
151 my $name = "$self->{'Type'}::set";
152
153 #
154 # Check the parameters sent in.
155 #
156 if (defined $params{'Value'})
157 {
158 Cdk::Scale::SetValue ($self->{'Me'}, $params{'Value'});
159 }
160 if (defined $params{'Low'})
161 {
162 Cdk::Scale::SetLowHigh ($self->{'Me'}, $params{'Low'}, $params{'High'});
163 }
164 if (defined $params{'ULChar'})
165 {
166 Cdk::Scale::SetULChar ($self->{'Me'}, $params{'ULChar'});
167 }
168 if (defined $params{'URChar'})
169 {
170 Cdk::Scale::SetURChar ($self->{'Me'}, $params{'URChar'});
171 }
172 if (defined $params{'LLChar'})
173 {
174 Cdk::Scale::SetLLChar ($self->{'Me'}, $params{'LLChar'});
175 }
176 if (defined $params{'LRChar'})
177 {
178 Cdk::Scale::SetLRChar ($self->{'Me'}, $params{'LRChar'});
179 }
180 if (defined $params{'VChar'})
181 {
182 Cdk::Scale::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
183 }
184 if (defined $params{'HChar'})
185 {
186 Cdk::Scale::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
187 }
188 if (defined $params{'BoxAttribute'})
189 {
190 Cdk::Scale::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
191 }
192 if (defined $params{'BGColor'})
193 {
194 Cdk::Scale::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
195 }
196 if (defined $params{'Box'})
197 {
198 Cdk::Scale::SetBox ($self->{'Me'}, $params{'Box'});
199 }
200 }
201
202 #
203 # This function raises the object.
204 #
205 sub raise
206 {
207 my $self = shift;
208 Cdk::Scale::Raise ($self->{'Me'});
209 }
210
211 #
212 # This function lowers the object.
213 #
214 sub lower
215 {
216 my $self = shift;
217 Cdk::Scale::Lower ($self->{'Me'});
218 }
219
220 #
221 # This function registers the object.
222 #
223 sub register
224 {
225 my $self = shift;
226 Cdk::Scale::Register ($self->{'Me'});
227 }
228
229 #
230 # This function unregisters the object.
231 #
232 sub unregister
233 {
234 my $self = shift;
235 Cdk::Scale::Unregister ($self->{'Me'});
236 }
237
238 #
239 # This function returns the pointer to the window.
240 #
241 sub getwin
242 {
243 my $self = shift;
244 Cdk::Scale::GetWindow ($self->{'Me'});
245 }
246
247 1;
+0
-285
Cdk/Scroll.pm less more
0 package Cdk::Scroll;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Scroll object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $list = Cdk::checkReq ($name, "List", $params{'List'});
19 my $height = Cdk::checkReq ($name, "Height", $params{'Height'});
20 my $width = Cdk::checkReq ($name, "Width", $params{'Width'});
21 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
22 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
23 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
24 my $spos = Cdk::checkDef ($name, "Spos", $params{'Spos'}, "NONE");
25 my $numbers = Cdk::checkDef ($name, "Numbers", $params{'Numbers'}, "FALSE");
26 my $hlight = Cdk::checkDef ($name, "Highlight", $params{'Highlight'}, "A_REVERSE");
27 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
28 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
29
30 # Create the thing.
31 $self->{'Me'} = Cdk::Scroll::New ($title, $params{'List'},
32 $height, $width,
33 $xpos, $ypos, $spos,
34 $numbers, $hlight,
35 $box, $shadow);
36 bless $self;
37 }
38
39 #
40 # This activates the object
41 #
42 sub activate
43 {
44 my $self = shift;
45 my %params = @_;
46 my $name = "$self->{'Type'}::activate";
47
48 # Activate the object...
49 if (defined $params{'Input'})
50 {
51 $self->{'Info'} = Cdk::Scroll::Activate ($self->{'Me'}, $params{'Input'});
52 }
53 else
54 {
55 $self->{'Info'} = Cdk::Scroll::Activate ($self->{'Me'});
56 }
57 return ($self->{'Info'});
58 }
59
60 #
61 # This injects a character into the widget.
62 #
63 sub inject
64 {
65 my $self = shift;
66 my %params = @_;
67 my $name = "$self->{'Type'}::inject";
68
69 # Set the values.
70 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
71
72 return (Cdk::Scroll::Inject ($self->{'Me'}, $character));
73 }
74
75 #
76 # This adds a line to the scrolling list.
77 #
78 sub add
79 {
80 my $self = shift;
81 my %params = @_;
82 my $name = "$self->{'Type'}::add";
83
84 # Set the values.
85 my $item = Cdk::checkReq ($name, "Item", $params{'Item'});
86 Cdk::Scroll::Add ($self->{'Me'}, $item);
87 }
88
89 #
90 # This deletes a line from the scrolling list.
91 #
92 sub delete
93 {
94 my $self = shift;
95 my %params = @_;
96 my $name = "$self->{'Type'}::delete";
97
98 # Set the values.
99 my $position = Cdk::checkReq ($name, "Position", $params{'Position'});
100 Cdk::Scroll::Delete ($self->{'Me'}, $position);
101 }
102
103 #
104 # This allows us to bind a key to an action.
105 #
106 sub bind
107 {
108 my $self = shift;
109 my %params = @_;
110 my $name = "$self->{'Type'}::bind";
111
112 # Set the values.
113 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
114 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
115 Cdk::Scroll::Bind ($self->{'Me'}, $key, $params{'Function'});
116 }
117
118 #
119 # This allows us to set a pre-process function.
120 #
121 sub preProcess
122 {
123 my $self = shift;
124 my %params = @_;
125 my $name = "$self->{'Type'}::preProcess";
126
127 # Set the values.
128 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
129 Cdk::Scroll::PreProcess ($self->{'Me'}, $params{'Function'});
130 }
131
132 #
133 # This allows us to set a post-process function.
134 #
135 sub postProcess
136 {
137 my $self = shift;
138 my %params = @_;
139 my $name = "$self->{'Type'}::postProcess";
140
141 # Set the values.
142 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
143 Cdk::Scroll::PostProcess ($self->{'Me'}, $params{'Function'});
144 }
145
146 #
147 # This draws the object.
148 #
149 sub draw
150 {
151 my $self = shift;
152 my %params = @_;
153 my $name = "$self->{'Type'}::draw";
154
155 # Set up the parameters passed in.
156 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
157
158 # Draw the object.
159 Cdk::Scroll::Draw ($self->{'Me'}, $box);
160 }
161
162 #
163 # This sets several parameters of the widget.
164 #
165 sub set
166 {
167 my $self = shift;
168 my %params = @_;
169 my $name = "$self->{'Type'}::set";
170
171 #
172 # Check the parameters sent in.
173 #
174 if (defined $params{'Items'})
175 {
176 Cdk::Scroll::SetItems ($self->{'Me'}, $params{'Items'});
177 }
178 if (defined $params{'Highlight'})
179 {
180 Cdk::Scroll::SetHighlight ($self->{'Me'}, $params{'Highlight'});
181 }
182 if (defined $params{'ULChar'})
183 {
184 Cdk::Scroll::SetULChar ($self->{'Me'}, $params{'ULChar'});
185 }
186 if (defined $params{'URChar'})
187 {
188 Cdk::Scroll::SetURChar ($self->{'Me'}, $params{'URChar'});
189 }
190 if (defined $params{'LLChar'})
191 {
192 Cdk::Scroll::SetLLChar ($self->{'Me'}, $params{'LLChar'});
193 }
194 if (defined $params{'LRChar'})
195 {
196 Cdk::Scroll::SetLRChar ($self->{'Me'}, $params{'LRChar'});
197 }
198 if (defined $params{'VChar'})
199 {
200 Cdk::Scroll::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
201 }
202 if (defined $params{'HChar'})
203 {
204 Cdk::Scroll::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
205 }
206 if (defined $params{'BoxAttribute'})
207 {
208 Cdk::Scroll::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
209 }
210 if (defined $params{'BGColor'})
211 {
212 Cdk::Scroll::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
213 }
214 if (defined $params{'Box'})
215 {
216 Cdk::Scroll::SetBox ($self->{'Me'}, $params{'Box'});
217 }
218 }
219
220 #
221 # This erases the object.
222 #
223 sub erase
224 {
225 my $self = shift;
226 Cdk::Scroll::Erase ($self->{'Me'});
227 }
228
229 #
230 # This function raises the object.
231 #
232 sub raise
233 {
234 my $self = shift;
235 Cdk::Scroll::Raise ($self->{'Me'});
236 }
237
238 #
239 # This function lowers the object.
240 #
241 sub lower
242 {
243 my $self = shift;
244 Cdk::Scroll::Lower ($self->{'Me'});
245 }
246
247 #
248 # This function registers the object.
249 #
250 sub register
251 {
252 my $self = shift;
253 Cdk::Scroll::Register ($self->{'Me'});
254 }
255
256 #
257 # This function unregisters the object.
258 #
259 sub unregister
260 {
261 my $self = shift;
262 Cdk::Scroll::Unregister ($self->{'Me'});
263 }
264
265 #
266 # This function returns the pointer to the window.
267 #
268 sub getwin
269 {
270 my $self = shift;
271 Cdk::Scroll::GetWindow ($self->{'Me'});
272 }
273
274 #
275 # This function returns the size of the scrolling list and the
276 # currently highlighted item.
277 #
278 sub info
279 {
280 my $self = shift;
281 return Cdk::Scroll::Info ($self->{'Me'});
282 }
283
284 1;
+0
-269
Cdk/Selection.pm less more
0 package Cdk::Selection;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Selection object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $list = Cdk::checkReq ($name, "List", $params{'List'});
19 my $choices = Cdk::checkReq ($name, "Choices", $params{'Choices'});
20 my $height = Cdk::checkReq ($name, "Height", $params{'Height'});
21 my $width = Cdk::checkReq ($name, "Width", $params{'Width'});
22 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
23 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
24 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
25 my $spos = Cdk::checkDef ($name, "Spos", $params{'Spos'}, "NONE");
26 my $hlight = Cdk::checkDef ($name, "Highlight", $params{'Highlight'}, "A_REVERSE");
27 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
28 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
29
30 # Create the thing.
31 $self->{'Me'} = Cdk::Selection::New ($title,
32 $params{'List'},
33 $params{'Choices'},
34 $height, $width, $xpos, $ypos, $spos,
35 $hlight, $box, $shadow);
36 bless $self;
37 }
38
39 #
40 # This activates the object
41 #
42 sub activate
43 {
44 my $self = shift;
45 my %params = @_;
46 my $name = "$self->{'Type'}::activate";
47 my @choices = ();
48
49 # Activate the object...
50 if (defined $params{'Input'})
51 {
52 @choices = Cdk::Selection::Activate ($self->{'Me'}, $params{'Input'});
53 }
54 else
55 {
56 @choices = Cdk::Selection::Activate ($self->{'Me'});
57 }
58
59 if (! defined $choices[0])
60 {
61 return;
62 }
63 else
64 {
65 $self->{'Info'} = \@choices;
66 return @choices;
67 }
68 }
69
70 #
71 # This injects a character into the widget.
72 #
73 sub inject
74 {
75 my $self = shift;
76 my %params = @_;
77 my $name = "$self->{'Type'}::inject";
78
79 # Set the values.
80 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
81
82 return (Cdk::Selection::Inject ($self->{'Me'}, $character));
83 }
84
85 #
86 # This allows us to bind a key to an action.
87 #
88 sub bind
89 {
90 my $self = shift;
91 my %params = @_;
92 my $name = "$self->{'Type'}::bind";
93
94 # Set the values.
95 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
96 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
97 Cdk::Selection::Bind ($self->{'Me'}, $key, $params{'Function'});
98 }
99
100 #
101 # This allows us to set a pre-process function.
102 #
103 sub preProcess
104 {
105 my $self = shift;
106 my %params = @_;
107 my $name = "$self->{'Type'}::preProcess";
108
109 # Set the values.
110 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
111 Cdk::Selection::PreProcess ($self->{'Me'}, $params{'Function'});
112 }
113
114 #
115 # This allows us to set a post-process function.
116 #
117 sub postProcess
118 {
119 my $self = shift;
120 my %params = @_;
121 my $name = "$self->{'Type'}::postProcess";
122
123 # Set the values.
124 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
125 Cdk::Selection::PostProcess ($self->{'Me'}, $params{'Function'});
126 }
127
128 #
129 # This sets several parameters of the widget.
130 #
131 sub set
132 {
133 my $self = shift;
134 my %params = @_;
135 my $name = "$self->{'Type'}::set";
136
137 #
138 # Check the parameters sent in.
139 #
140 if (defined $params{'Highlight'})
141 {
142 Cdk::Selection::SetHighlight ($self->{'Me'}, $params{'Highlight'});
143 }
144 if (defined $params{'Choices'})
145 {
146 Cdk::Selection::SetChoices ($self->{'Me'}, $params{'Choices'});
147 }
148 if (defined $params{'Choice'})
149 {
150 Cdk::Selection::SetChoice ($self->{'Me'}, $params{'Choice'}, $params{'Index'});
151 }
152 if (defined $params{'Modes'})
153 {
154 Cdk::Selection::SetModes ($self->{'Me'}, $params{'Modes'});
155 }
156 if (defined $params{'Mode'})
157 {
158 Cdk::Selection::SetMode ($self->{'Me'}, $params{'Mode'}, $params{'Index'});
159 }
160 if (defined $params{'ULChar'})
161 {
162 Cdk::Selection::SetULChar ($self->{'Me'}, $params{'ULChar'});
163 }
164 if (defined $params{'URChar'})
165 {
166 Cdk::Selection::SetURChar ($self->{'Me'}, $params{'URChar'});
167 }
168 if (defined $params{'LLChar'})
169 {
170 Cdk::Selection::SetLLChar ($self->{'Me'}, $params{'LLChar'});
171 }
172 if (defined $params{'LRChar'})
173 {
174 Cdk::Selection::SetLRChar ($self->{'Me'}, $params{'LRChar'});
175 }
176 if (defined $params{'VChar'})
177 {
178 Cdk::Selection::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
179 }
180 if (defined $params{'HChar'})
181 {
182 Cdk::Selection::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
183 }
184 if (defined $params{'BoxAttribute'})
185 {
186 Cdk::Selection::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
187 }
188 if (defined $params{'BGColor'})
189 {
190 Cdk::Selection::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
191 }
192 if (defined $params{'Box'})
193 {
194 Cdk::Selection::SetBox ($self->{'Me'}, $params{'Box'});
195 }
196 }
197
198 #
199 # This draws the object.
200 #
201 sub draw
202 {
203 my $self = shift;
204 my %params = @_;
205 my $name = "$self->{'Type'}::draw";
206
207 # Set up the parameters passed in.
208 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
209
210 # Draw the object.
211 Cdk::Selection::Draw ($self->{'Me'}, $box);
212 }
213
214 #
215 # This erases the object.
216 #
217 sub erase
218 {
219 my $self = shift;
220 Cdk::Selection::Erase ($self->{'Me'});
221 }
222
223 #
224 # This function raises the object.
225 #
226 sub raise
227 {
228 my $self = shift;
229 Cdk::Selection::Raise ($self->{'Me'});
230 }
231
232 #
233 # This function lowers the object.
234 #
235 sub lower
236 {
237 my $self = shift;
238 Cdk::Selection::Lower ($self->{'Me'});
239 }
240
241 #
242 # This function registers the object.
243 #
244 sub register
245 {
246 my $self = shift;
247 Cdk::Selection::Register ($self->{'Me'});
248 }
249
250 #
251 # This function unregisters the object.
252 #
253 sub unregister
254 {
255 my $self = shift;
256 Cdk::Selection::Unregister ($self->{'Me'});
257 }
258
259 #
260 # This function returns the pointer to the window.
261 #
262 sub getwin
263 {
264 my $self = shift;
265 Cdk::Selection::GetWindow ($self->{'Me'});
266 }
267
268 1;
+0
-247
Cdk/Slider.pm less more
0 package Cdk::Slider;
1
2 #
3 # This creates a new Slider object
4 #
5 sub new
6 {
7 my $type = shift;
8 my %params = @_;
9 my $self = {};
10 my $name = "${type}::new";
11
12 # Retain the type of the object.
13 $self->{'Type'} = $type;
14
15 # Set up the parameters passed in.
16 my $low = Cdk::checkReq ($name, "Low", $params{'Low'});
17 my $high = Cdk::checkReq ($name, "High", $params{'High'});
18 my $width = Cdk::checkReq ($name, "Width", $params{'Width'});
19 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
20 my $label = Cdk::checkDef ($name, "Label", $params{'Label'}, "");
21 my $inc = Cdk::checkDef ($name, "Inc", $params{'Inc'}, 1);
22 my $fastInc = Cdk::checkDef ($name, "Fastinc", $params{'Fastinc'}, 5);
23 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
24 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
25 my $start = Cdk::checkDef ($name, "Start", $params{'Start'}, $params{'Low'});
26 my $filler = Cdk::checkDef ($name, "Filler", $params{'Filler'}, "</R> ");
27 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
28 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
29
30 # Create the thing.
31 $self->{'Me'} = Cdk::Slider::New ($title, $label,
32 $start, $low, $high,
33 $inc, $fastInc,
34 $width, $xpos, $ypos,
35 $filler, $box, $shadow);
36 bless $self;
37 }
38
39 #
40 # This activates the object.
41 #
42 sub activate
43 {
44 my $self = shift;
45 my %params = @_;
46 my $name = "$self->{'Type'}::activate";
47
48 # Activate the object...
49 if (defined $params{'Input'})
50 {
51 $self->{'Info'} = Cdk::Slider::Activate ($self->{'Me'}, $params{'Input'});
52 }
53 else
54 {
55 $self->{'Info'} = Cdk::Slider::Activate ($self->{'Me'});
56 }
57 return $self->{'Info'};
58 }
59
60 #
61 # This injects a character into the widget.
62 #
63 sub inject
64 {
65 my $self = shift;
66 my %params = @_;
67 my $name = "$self->{'Type'}::inject";
68
69 # Set the values.
70 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
71
72 return Cdk::Slider::Inject ($self->{'Me'}, $character);
73 }
74
75 #
76 # This allows us to bind a key to an action.
77 #
78 sub bind
79 {
80 my $self = shift;
81 my %params = @_;
82 my $name = "$self->{'Type'}::bind";
83
84 # Set the values.
85 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
86 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
87 Cdk::Slider::Bind ($self->{'Me'}, $key, $params{'Function'});
88 }
89
90 #
91 # This allows us to set a pre-process function.
92 #
93 sub preProcess
94 {
95 my $self = shift;
96 my %params = @_;
97 my $name = "$self->{'Type'}::preProcess";
98
99 # Set the values.
100 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
101 Cdk::Slider::PreProcess ($self->{'Me'}, $params{'Function'});
102 }
103
104 #
105 # This allows us to set a post-process function.
106 #
107 sub postProcess
108 {
109 my $self = shift;
110 my %params = @_;
111 my $name = "$self->{'Type'}::postProcess";
112
113 # Set the values.
114 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
115 Cdk::Slider::PostProcess ($self->{'Me'}, $params{'Function'});
116 }
117
118 #
119 # This draws the object.
120 #
121 sub draw
122 {
123 my $self = shift;
124 my %params = @_;
125 my $name = "$self->{'Type'}::draw";
126
127 # Set up the parameters passed in.
128 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
129
130 # Draw the object.
131 Cdk::Slider::Draw ($self->{'Me'}, $box);
132 }
133
134 #
135 # This erases the object.
136 #
137 sub erase
138 {
139 my $self = shift;
140 Cdk::Slider::Erase ($self->{'Me'});
141 }
142
143 #
144 # This sets several parameters of the widget.
145 #
146 sub set
147 {
148 my $self = shift;
149 my %params = @_;
150 my $name = "$self->{'Type'}::set";
151
152 #
153 # Check the parameters sent in.
154 #
155 if (defined $params{'Value'})
156 {
157 Cdk::Slider::SetValue ($self->{'Me'}, $params{'Value'});
158 }
159 if (defined $params{'Low'})
160 {
161 Cdk::Slider::SetLowHigh ($self->{'Me'}, $params{'Low'}, $params{'High'});
162 }
163 if (defined $params{'ULChar'})
164 {
165 Cdk::Slider::SetULChar ($self->{'Me'}, $params{'ULChar'});
166 }
167 if (defined $params{'URChar'})
168 {
169 Cdk::Slider::SetURChar ($self->{'Me'}, $params{'URChar'});
170 }
171 if (defined $params{'LLChar'})
172 {
173 Cdk::Slider::SetLLChar ($self->{'Me'}, $params{'LLChar'});
174 }
175 if (defined $params{'LRChar'})
176 {
177 Cdk::Slider::SetLRChar ($self->{'Me'}, $params{'LRChar'});
178 }
179 if (defined $params{'VChar'})
180 {
181 Cdk::Slider::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
182 }
183 if (defined $params{'HChar'})
184 {
185 Cdk::Slider::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
186 }
187 if (defined $params{'BoxAttribute'})
188 {
189 Cdk::Slider::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
190 }
191 if (defined $params{'BGColor'})
192 {
193 Cdk::Slider::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
194 }
195 if (defined $params{'Box'})
196 {
197 Cdk::Slider::SetBox ($self->{'Me'}, $params{'Box'});
198 }
199 }
200
201 #
202 # This function raises the object.
203 #
204 sub raise
205 {
206 my $self = shift;
207 Cdk::Slider::Raise ($self->{'Me'});
208 }
209
210 #
211 # This function lowers the object.
212 #
213 sub lower
214 {
215 my $self = shift;
216 Cdk::Slider::Lower ($self->{'Me'});
217 }
218
219 #
220 # This function registers the object.
221 #
222 sub register
223 {
224 my $self = shift;
225 Cdk::Slider::Register ($self->{'Me'});
226 }
227
228 #
229 # This function unregisters the object.
230 #
231 sub unregister
232 {
233 my $self = shift;
234 Cdk::Slider::Unregister ($self->{'Me'});
235 }
236
237 #
238 # This function returns the pointer to the window.
239 #
240 sub getwin
241 {
242 my $self = shift;
243 Cdk::Slider::GetWindow ($self->{'Me'});
244 }
245
246 1;
+0
-349
Cdk/Swindow.pm less more
0 package Cdk::Swindow;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Swindow object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $lines = Cdk::checkReq ($name, "Lines", $params{'Lines'});
19 my $height = Cdk::checkReq ($name, "Height", $params{'Height'});
20 my $width = Cdk::checkReq ($name, "Width", $params{'Width'});
21 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
22 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
23 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
24 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
25 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
26
27 # Create the thing.
28 $self->{'Me'} = Cdk::Swindow::New ($title, $lines,
29 $height, $width,
30 $xpos, $ypos,
31 $box, $shadow);
32 bless $self;
33 }
34
35 #
36 # This activates the object
37 #
38 sub activate
39 {
40 my $self = shift;
41 my %params = @_;
42 my $name = "$self->{'Type'}::activate";
43
44 # Activate the object...
45 if (defined $params{'Input'})
46 {
47 $self->{'Info'} = Cdk::Swindow::Activate ($self->{'Me'}, $params{'Input'});
48 }
49 else
50 {
51 $self->{'Info'} = Cdk::Swindow::Activate ($self->{'Me'});
52 }
53 return ($self->{'Info'});
54 }
55
56 #
57 # This injects a character into the widget.
58 #
59 sub inject
60 {
61 my $self = shift;
62 my %params = @_;
63 my $name = "$self->{'Type'}::inject";
64
65 # Set the values.
66 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
67
68 return (Cdk::Swindow::Inject ($self->{'Me'}, $character));
69 }
70
71 #
72 # This allows us to bind a key to an action.
73 #
74 sub bind
75 {
76 my $self = shift;
77 my %params = @_;
78 my $name = "$self->{'Type'}::bind";
79
80 # Set the values.
81 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
82 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
83 Cdk::Swindow::Bind ($self->{'Me'}, $key, $params{'Function'});
84 }
85
86 #
87 # This allows us to set a pre-process function.
88 #
89 sub preProcess
90 {
91 my $self = shift;
92 my %params = @_;
93 my $name = "$self->{'Type'}::preProcess";
94
95 # Set the values.
96 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
97 Cdk::Swindow::PreProcess ($self->{'Me'}, $params{'Function'});
98 }
99
100 #
101 # This allows us to set a post-process function.
102 #
103 sub postProcess
104 {
105 my $self = shift;
106 my %params = @_;
107 my $name = "$self->{'Type'}::postProcess";
108
109 # Set the values.
110 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
111 Cdk::Swindow::PostProcess ($self->{'Me'}, $params{'Function'});
112 }
113
114 #
115 # This sets several parameters of the widget.
116 #
117 sub set
118 {
119 my $self = shift;
120 my %params = @_;
121 my $name = "$self->{'Type'}::set";
122
123 #
124 # Check the parameters sent in.
125 #
126 if (defined $params{'Contents'})
127 {
128 Cdk::Swindow::SetContents ($self->{'Me'}, $params{'Contents'});
129 }
130 if (defined $params{'ULChar'})
131 {
132 Cdk::Swindow::SetULChar ($self->{'Me'}, $params{'ULChar'});
133 }
134 if (defined $params{'URChar'})
135 {
136 Cdk::Swindow::SetURChar ($self->{'Me'}, $params{'URChar'});
137 }
138 if (defined $params{'LLChar'})
139 {
140 Cdk::Swindow::SetLLChar ($self->{'Me'}, $params{'LLChar'});
141 }
142 if (defined $params{'LRChar'})
143 {
144 Cdk::Swindow::SetLRChar ($self->{'Me'}, $params{'LRChar'});
145 }
146 if (defined $params{'VChar'})
147 {
148 Cdk::Swindow::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
149 }
150 if (defined $params{'HChar'})
151 {
152 Cdk::Swindow::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
153 }
154 if (defined $params{'BoxAttribute'})
155 {
156 Cdk::Swindow::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
157 }
158 if (defined $params{'BGColor'})
159 {
160 Cdk::Swindow::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
161 }
162 if (defined $params{'Box'})
163 {
164 Cdk::Swindow::SetBox ($self->{'Me'}, $params{'Box'});
165 }
166 }
167
168 #
169 # This adds a line into the scrolling window.
170 #
171 sub addline
172 {
173 my $self = shift;
174 my %params = @_;
175 my $name = "$self->{'Type'}::addline";
176
177 # Set up the parameters passed in.
178 my $info = Cdk::checkReq ($name, "Info", $params{'Info'});
179 my $position = Cdk::checkDef ($name, "Position", $params{'Position'}, "BOTTOM");
180
181 Cdk::Swindow::Addline ($self->{'Me'}, $info, $position);
182 }
183
184 #
185 # This allows the user to spawn a command via a scrolling window.
186 #
187 sub exec
188 {
189 my $self = shift;
190 my %params = @_;
191 my $name = "$self->{'Type'}::addline";
192
193 # Set up the parameters passed in.
194 my $command = Cdk::checkReq ($name, "Command", $params{'Command'});
195 my $position = Cdk::checkDef ($name, "Position", $params{'Position'}, "BOTTOM");
196
197 return Cdk::Swindow::Exec ($self->{'Me'}, $command, $position);
198 }
199
200 #
201 # This trims the scrolling window.
202 #
203 sub trim
204 {
205 my $self = shift;
206 my %params = @_;
207 my $name = "$self->{'Type'}::trim";
208
209 # Set up the parameters passed in.
210 my $start = Cdk::checkReq ($name, "Start", $params{'Start'});
211 my $finish = Cdk::checkReq ($name, "Finish", $params{'Finish'});
212
213 Cdk::Swindow::Trim ($self->{'Me'}, $start, $finish);
214 }
215
216 #
217 # This cleans the info from the window.
218 #
219 sub clean
220 {
221 my $self = shift;
222 my %params = @_;
223 my $name = "$self->{'Type'}::clean";
224
225 Cdk::Swindow::Clean ($self->{'Me'});
226 }
227
228 #
229 # This saves the information in the swindow to a file.
230 #
231 sub save
232 {
233 my $self = shift;
234 my %params = @_;
235 my $name = "$self->{'Type'}::save";
236
237 Cdk::Swindow::Save ($self->{'Me'});
238 }
239
240 #
241 # This loads information into the swindow from a file.
242 #
243 sub load
244 {
245 my $self = shift;
246 my %params = @_;
247 my $name = "$self->{'Type'}::load";
248
249 Cdk::Swindow::Load ($self->{'Me'});
250 }
251
252 #
253 # This saves the information in the swindow to the given file.
254 #
255 sub dump
256 {
257 my $self = shift;
258 my %params = @_;
259 my $name = "$self->{'Type'}::dump";
260
261 my $filename = Cdk::checkReq ($name, "Filename", $params{'Filename'});
262
263 Cdk::Swindow::Dump ($self->{'Me'}, $filename);
264 }
265
266 #
267 # This returns the information from the scrolling window.
268 #
269 sub get
270 {
271 my $self = shift;
272 my %params = @_;
273 my $name = "$self->{'Type'}::get";
274
275 return (Cdk::Swindow::Get ($self->{'Me'}));
276 }
277
278 #
279 # This draws the object.
280 #
281 sub draw
282 {
283 my $self = shift;
284 my %params = @_;
285 my $name = "$self->{'Type'}::draw";
286
287 # Set up the parameters passed in.
288 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
289
290 # Draw the object.
291 Cdk::Swindow::Draw ($self->{'Me'}, $box);
292 }
293
294 #
295 # This erases the object.
296 #
297 sub erase
298 {
299 my $self = shift;
300 Cdk::Swindow::Erase ($self->{'Me'});
301 }
302
303 #
304 # This function raises the object.
305 #
306 sub raise
307 {
308 my $self = shift;
309 Cdk::Swindow::Raise ($self->{'Me'});
310 }
311
312 #
313 # This function lowers the object.
314 #
315 sub lower
316 {
317 my $self = shift;
318 Cdk::Swindow::Lower ($self->{'Me'});
319 }
320
321 #
322 # This function registers the object.
323 #
324 sub register
325 {
326 my $self = shift;
327 Cdk::Swindow::Register ($self->{'Me'});
328 }
329
330 #
331 # This function unregisters the object.
332 #
333 sub unregister
334 {
335 my $self = shift;
336 Cdk::Swindow::Unregister ($self->{'Me'});
337 }
338
339 #
340 # This function returns the pointer to the window.
341 #
342 sub getwin
343 {
344 my $self = shift;
345 Cdk::Swindow::GetWindow ($self->{'Me'});
346 }
347
348 1;
+0
-270
Cdk/Template.pm less more
0 package Cdk::Template;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Template object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $plate = Cdk::checkReq ($name, "Plate", $params{'Plate'});
19 my $overlay = Cdk::checkReq ($name, "Overlay", $params{'Overlay'});
20 my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
21 my $label = Cdk::checkDef ($name, "Label", $params{'Label'}, "");
22 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
23 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
24 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
25 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
26
27 # Create the thing.
28 $self->{'Me'} = Cdk::Template::New ($title, $label,
29 $plate, $overlay,
30 $xpos, $ypos,
31 $box, $shadow);
32 bless $self;
33 }
34
35 #
36 # This activates the object
37 #
38 sub activate
39 {
40 my $self = shift;
41 my %params = @_;
42 my $name = "$self->{'Type'}::activate";
43
44 # Activate the object...
45 if (defined $params{'Input'})
46 {
47 $self->{'Info'} = Cdk::Template::Activate ($self->{'Me'}, $params{'Input'});
48 }
49 else
50 {
51 $self->{'Info'} = Cdk::Template::Activate ($self->{'Me'});
52 }
53 return ($self->{'Info'});
54 }
55
56 #
57 # This injects a character into the widget.
58 #
59 sub inject
60 {
61 my $self = shift;
62 my %params = @_;
63 my $name = "$self->{'Type'}::inject";
64
65 # Set the values.
66 my $character = Cdk::checkReq ($name, "Input", $params{'Input'});
67
68 return (Cdk::Template::Inject ($self->{'Me'}, $character));
69 }
70
71 #
72 # This sets several parameters of the widget.
73 #
74 sub set
75 {
76 my $self = shift;
77 my %params = @_;
78 my $name = "$self->{'Type'}::set";
79
80 #
81 # Check the parameters sent in.
82 #
83 if (defined $params{'Value'})
84 {
85 Cdk::Template::SetValue ($self->{'Me'}, $params{'Value'});
86 }
87 if (defined $params{'Min'})
88 {
89 Cdk::Template::SetMin ($self->{'Me'}, $params{'Min'});
90 }
91 if (defined $params{'ULChar'})
92 {
93 Cdk::Template::SetULChar ($self->{'Me'}, $params{'ULChar'});
94 }
95 if (defined $params{'URChar'})
96 {
97 Cdk::Template::SetURChar ($self->{'Me'}, $params{'URChar'});
98 }
99 if (defined $params{'LLChar'})
100 {
101 Cdk::Template::SetLLChar ($self->{'Me'}, $params{'LLChar'});
102 }
103 if (defined $params{'LRChar'})
104 {
105 Cdk::Template::SetLRChar ($self->{'Me'}, $params{'LRChar'});
106 }
107 if (defined $params{'VChar'})
108 {
109 Cdk::Template::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
110 }
111 if (defined $params{'HChar'})
112 {
113 Cdk::Template::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
114 }
115 if (defined $params{'BoxAttribute'})
116 {
117 Cdk::Template::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
118 }
119 if (defined $params{'BGColor'})
120 {
121 Cdk::Template::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
122 }
123 if (defined $params{'Box'})
124 {
125 Cdk::Template::SetBox ($self->{'Me'}, $params{'Box'});
126 }
127 }
128
129 #
130 # This function allows the user to get the current value from the widget.
131 #
132 sub get
133 {
134 my $self = shift;
135 return (Cdk::Template::Get ($self->{'Me'}));
136 }
137
138 #
139 # This binds a given key to a given function.
140 #
141 sub bind
142 {
143 my $self = shift;
144 my %params = @_;
145 my $name = "$self->{'Type'}::bind";
146
147 # Set the values.
148 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
149 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
150 Cdk::Template::Bind ($self->{'Me'}, $key, $params{'Function'});
151 }
152
153 #
154 # This allows us to set a pre-process function.
155 #
156 sub preProcess
157 {
158 my $self = shift;
159 my %params = @_;
160 my $name = "$self->{'Type'}::preProcess";
161
162 # Set the values.
163 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
164 Cdk::Template::PreProcess ($self->{'Me'}, $params{'Function'});
165 }
166
167 #
168 # This allows us to set a post-process function.
169 #
170 sub postProcess
171 {
172 my $self = shift;
173 my %params = @_;
174 my $name = "$self->{'Type'}::postProcess";
175
176 # Set the values.
177 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
178 Cdk::Template::PostProcess ($self->{'Me'}, $params{'Function'});
179 }
180
181 #
182 # This draws the object.
183 #
184 sub draw
185 {
186 my $self = shift;
187 my %params = @_;
188 my $name = "$self->{'Type'}::draw";
189
190 # Set the values.
191 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
192
193 # Draw the object.
194 Cdk::Template::Draw ($self->{'Me'}, $box);
195 }
196
197 #
198 # This erases the object.
199 #
200 sub erase
201 {
202 my $self = shift;
203 Cdk::Template::Erase ($self->{'Me'});
204 }
205
206 #
207 # This cleans the template info field.
208 #
209 sub clean
210 {
211 my $self = shift;
212 Cdk::Template::Clean ($self->{'Me'});
213 }
214
215 #
216 # This mixes the results with the overlay
217 #
218 sub mix
219 {
220 my $self = shift;
221 Cdk::Template::Mix ($self->{'Me'});
222 }
223
224 #
225 # This function raises the object.
226 #
227 sub raise
228 {
229 my $self = shift;
230 Cdk::Template::Raise ($self->{'Me'});
231 }
232
233 #
234 # This function lowers the object.
235 #
236 sub lower
237 {
238 my $self = shift;
239 Cdk::Template::Lower ($self->{'Me'});
240 }
241
242 #
243 # This function registers the object.
244 #
245 sub register
246 {
247 my $self = shift;
248 Cdk::Template::Register ($self->{'Me'});
249 }
250
251 #
252 # This function unregisters the object.
253 #
254 sub unregister
255 {
256 my $self = shift;
257 Cdk::Template::Unregister ($self->{'Me'});
258 }
259
260 #
261 # This function returns the pointer to the window.
262 #
263 sub getwin
264 {
265 my $self = shift;
266 Cdk::Template::GetWindow ($self->{'Me'});
267 }
268
269 1;
+0
-202
Cdk/Viewer.pm less more
0 package Cdk::Viewer;
1
2 @ISA = qw (Cdk);
3
4 #
5 # This creates a new Viewer object.
6 #
7 sub new
8 {
9 my $type = shift;
10 my %params = @_;
11 my $self = {};
12 my $name = "${type}::new";
13
14 # Retain the type of the object.
15 $self->{'Type'} = $type;
16
17 # Set up the parameters passed in.
18 my $buttons = Cdk::checkReq ($name, "Buttons", $params{'Buttons'});
19 my $height = Cdk::checkReq ($name, "Height", $params{'Height'});
20 my $width = Cdk::checkReq ($name, "Width", $params{'Width'});
21 my $hlight = Cdk::checkDef ($name, "Highlight", $params{'Highlight'}, "A_REVERSE");
22 my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
23 my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
24 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
25 my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
26
27 # Create the thing.
28 $self->{'Me'} = Cdk::Viewer::New ($params{'Buttons'},
29 $height, $width, $hlight,
30 $xpos, $ypos,
31 $box, $shadow);
32 bless $self;
33 }
34
35 #
36 # This activates the viewer.
37 #
38 sub activate
39 {
40 my $self = shift;
41 my %params = @_;
42 my $name = "$self->{'Type'}::activate";
43
44 # Activate the object...
45 $self->{'Info'} = Cdk::Viewer::Activate ($self->{'Me'});
46 return ($self->{'Info'});
47 }
48
49 #
50 # This sets several parameters of the widget.
51 #
52 sub set
53 {
54 my $self = shift;
55 my %params = @_;
56 my $name = "$self->{'Type'}::set";
57
58 #
59 # Check the parameters sent in.
60 #
61 if (defined $params{'Info'})
62 {
63 my $interpret = $params{'Interpret'} || 1;
64 Cdk::Viewer::SetInfo ($self->{'Me'}, $params{'Info'}, $interpret);
65 }
66 if (defined $params{'Title'})
67 {
68 Cdk::Viewer::SetTitle ($self->{'Me'}, $params{'Title'});
69 }
70 if (defined $params{'Highlight'})
71 {
72 Cdk::Viewer::SetHighlight ($self->{'Me'}, $params{'Highlight'});
73 }
74 if (defined $params{'InfoLine'})
75 {
76 Cdk::Viewer::SetInfoLine ($self->{'Me'}, $params{'InfoLine'});
77 }
78 if (defined $params{'ULChar'})
79 {
80 Cdk::Viewer::SetULChar ($self->{'Me'}, $params{'ULChar'});
81 }
82 if (defined $params{'URChar'})
83 {
84 Cdk::Viewer::SetURChar ($self->{'Me'}, $params{'URChar'});
85 }
86 if (defined $params{'LLChar'})
87 {
88 Cdk::Viewer::SetLLChar ($self->{'Me'}, $params{'LLChar'});
89 }
90 if (defined $params{'LRChar'})
91 {
92 Cdk::Viewer::SetLRChar ($self->{'Me'}, $params{'LRChar'});
93 }
94 if (defined $params{'VChar'})
95 {
96 Cdk::Viewer::SetVerticalChar ($self->{'Me'}, $params{'VChar'});
97 }
98 if (defined $params{'HChar'})
99 {
100 Cdk::Viewer::SetHorizontalChar ($self->{'Me'}, $params{'HChar'});
101 }
102 if (defined $params{'BoxAttribute'})
103 {
104 Cdk::Viewer::SetBoxAttribute ($self->{'Me'}, $params{'BoxAttribute'});
105 }
106 if (defined $params{'BGColor'})
107 {
108 Cdk::Viewer::SetBackgroundColor ($self->{'Me'}, $params{'BGColor'});
109 }
110 if (defined $params{'Box'})
111 {
112 Cdk::Viewer::SetBox ($self->{'Me'}, $params{'Box'});
113 }
114 }
115
116 #
117 # This draws the object.
118 #
119 sub draw
120 {
121 my $self = shift;
122 my %params = @_;
123 my $name = "$self->{'Type'}::draw";
124
125 # Set up the parameters passed in.
126 my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
127
128 # Draw the object.
129 Cdk::Viewer::Draw ($self->{'Me'}, $box);
130 }
131
132 #
133 # This erases the object.
134 #
135 sub erase
136 {
137 my $self = shift;
138 Cdk::Viewer::Erase ($self->{'Me'});
139 }
140
141 #
142 # This allows us to bind a key to an action.
143 #
144 sub bind
145 {
146 my $self = shift;
147 my %params = @_;
148 my $name = "$self->{'Type'}::bind";
149
150 # Set the values.
151 my $key = Cdk::checkReq ($name, "Key", $params{'Key'});
152 my $function = Cdk::checkReq ($name, "Function", $params{'Function'});
153 Cdk::Entry::Bind ($self->{'Me'}, $key, $params{'Function'});
154 }
155
156 #
157 # This function raises the object.
158 #
159 sub raise
160 {
161 my $self = shift;
162 Cdk::Viewer::Raise ($self->{'Me'});
163 }
164
165 #
166 # This function lowers the object.
167 #
168 sub lower
169 {
170 my $self = shift;
171 Cdk::Viewer::Lower ($self->{'Me'});
172 }
173
174 #
175 # This function registers the object.
176 #
177 sub register
178 {
179 my $self = shift;
180 Cdk::Viewer::Register ($self->{'Me'});
181 }
182
183 #
184 # This function unregisters the object.
185 #
186 sub unregister
187 {
188 my $self = shift;
189 Cdk::Viewer::Unregister ($self->{'Me'});
190 }
191
192 #
193 # This function returns the pointer to the window.
194 #
195 sub getwin
196 {
197 my $self = shift;
198 Cdk::Viewer::GetWindow ($self->{'Me'});
199 }
200
201 1;
+0
-213
Cdk.pm less more
0 # $Id: Cdk.pm,v 1.5 2002/07/28 18:44:16 tom Exp $
1
2 package Cdk;
3
4 use Exporter ();
5 use DynaLoader ();
6 use AutoLoader ();
7
8 @ISA = qw(Exporter DynaLoader);
9
10 # Force input buffering off.
11 select (STDIN); $| = 1 ;
12
13 # Set the version.
14 $VERSION = "4.09010"; # must be a floating-point number
15
16 # Set the diag flag off.
17 $DIAGFLAG = 0;
18
19 # Items to export into callers' namespace by default. Note: do not export
20 # names by default without a very good reason. Use EXPORT_OK instead.
21 # Do not simply export all your public functions/methods/constants.
22 @EXPORT = qw (VERSION checkDef checkReq popupLabel popupDialog);
23
24 sub AUTOLOAD {
25 # This AUTOLOAD is used to 'autoload' constants from the constant()
26 # XS function. If a constant is not found then control is passed
27 # to the AUTOLOAD in AutoLoader.
28
29 my $constname;
30 ($constname = $AUTOLOAD) =~ s/.*:://;
31 my $val = constant($constname, @_ ? $_[0] : 0);
32 if ($! != 0) {
33 if ($! =~ /Invalid/) {
34 $AutoLoader::AUTOLOAD = $AUTOLOAD;
35 goto &AutoLoader::AUTOLOAD;
36 }
37 else {
38 die "Your vendor has not defined Cdk macro $constname";
39 }
40 }
41 eval "sub $AUTOLOAD { $val }";
42 goto &$AUTOLOAD;
43 }
44
45 bootstrap Cdk;
46
47 #
48 # This draws a string on the given/or not window.
49 #
50 sub drawMesg
51 {
52 my $type = shift;
53 my %params = @_;
54 my $name = "${type}::new";
55 my ($mesg, $xpos, $ypos, $attrib, $window);
56
57 # Retain the type of the object.
58 $self->{'Type'} = $type;
59
60 # Set up the parameters passed in.
61 $mesg = Cdk::checkReq ($name, "Message", $params{'Message'});
62 $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, Cdk::CENTER());
63 $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, Cdk::CENTER());
64 $attrib = Cdk::checkDef ($name, "Attrib", $params{'Attrib'}, Cdk::A_NORMAL());
65 $align = Cdk::checkDef ($name, "Align", $params{'Align'}, Cdk::HORIZONTAL());
66
67 # If they passed an object, dereference its window and draw on it.
68 if ($params{'Object'})
69 {
70 $window = $params{'Object'}->getWindow();
71 }
72 else
73 {
74 $window = Cdk::getCdkWindow();
75 }
76
77 # Start drawing.
78 Cdk::DrawMesg ($window, $mesg, $xpos, $ypos, $attrib, $align);
79 }
80
81 #
82 # This checks if a value has been given a value, if not, then it gives it one.
83 #
84 sub checkDef
85 {
86 my ($type, $name, $value, $def) = @_;
87
88 # Check if it is defined.
89 if (!defined $value)
90 {
91 Cdk::Diag::Log ("Diag", $type, "Default parameter $name being set to default value <$def>");
92 return ($def);
93 }
94 else
95 {
96 Cdk::Diag::Log ("Diag", $type, "Default parameter $name being set to value <$def>");
97 return ($value);
98 }
99 }
100
101 #
102 # This checks if a value has been given a value. If not it reports an error.
103 #
104 sub checkReq
105 {
106 my ($type, $name, $value) = @_;
107
108 # Check if it is defined.
109 if (! defined $value)
110 {
111 # Close the Cdk screen and shut down curses.
112 Cdk::end();
113
114 # Report the error.
115 Cdk::Diag::Log ("Error", $type, "Required parameter $name has no value.");
116
117 # Get out.
118 exit (1);
119 }
120 else
121 {
122 # Report the info.
123 Cdk::Diag::Log ("Diag", $type, "Required parameter $name being set to <$value>");
124 return ($value);
125 }
126 }
127
128 #
129 # This pops up a label.
130 #
131 sub popupLabel
132 {
133 my $mesg = shift;
134
135 my $popup = new Cdk::Label ("Message" => $mesg);
136 $popup->draw();
137 $popup->wait();
138 }
139
140 #
141 # This pops up a question on the screen.
142 #
143 sub popupDialog
144 {
145 my ($mesg, $buttons) = @_;
146
147 my $popup = new Cdk::Dialog ('Message' => $mesg, 'Buttons' => $buttons);
148 return $popup->activate();
149 }
150
151 #
152 # This function takes a scalar and returns a list with elements in the
153 # list to the given width.
154 #
155 sub scalar2List
156 {
157 my ($scalar, $elementLen) = @_;
158 my $tempLine = "";
159 my $lineLen = 0;
160 my @info = ();
161 my $x = 0;
162
163 # Break the scalar into a list.
164 $_ = $scalar;
165 my @wordList = split;
166
167 # Put each scalar back into an array of $elementLen length or more.
168 for ($x=0; $x <= $#wordList; $x++)
169 {
170 $lineLen += length ($wordList[$x]);
171 $tempLine .= "$wordList[$x] ";
172
173 if ($lineLen >= $elementLen)
174 {
175 push (@info, $tempLine);
176 $tempLine = "";
177 $lineLen = 0;
178 }
179 }
180 push (@info, $tempLine);
181 return @info;
182 }
183
184 #
185 # Load the object modules.
186 #
187 use Cdk::Alphalist;
188 use Cdk::Buttonbox;
189 use Cdk::Calendar;
190 use Cdk::Diag;
191 use Cdk::Dialog;
192 use Cdk::Entry;
193 use Cdk::Fselect;
194 use Cdk::Graph;
195 use Cdk::Histogram;
196 use Cdk::Itemlist;
197 use Cdk::Label;
198 use Cdk::Marquee;
199 use Cdk::Matrix;
200 use Cdk::Mentry;
201 use Cdk::Menu;
202 use Cdk::Radio;
203 use Cdk::Scale;
204 use Cdk::Scroll;
205 use Cdk::Selection;
206 use Cdk::Slider;
207 use Cdk::Swindow;
208 use Cdk::Template;
209 use Cdk::Viewer;
210
211 1;
212 __END__
+0
-7507
Cdk.xs less more
0 /*
1 * $Author: tom $
2 * $Date: 2003/12/10 20:40:41 $
3 * $Revision: 1.18 $
4 */
5
6 #include <EXTERN.h>
7 #include <perl.h>
8 #include <XSUB.h>
9
10 #define CDK_PERL_EXT
11 #include <cdk/cdk.h>
12
13 /* Prior to perl5.005, the PL_ prefix wasn't used for things such
14 as PL_rs. Define the PL_ macros that we use if necessary. */
15
16 #include <patchlevel.h> /* This is perl's patchlevel.h */
17
18 #if PATCHLEVEL < 5
19 #define PL_na na
20 #define PL_sv_undef sv_undef
21 #endif
22
23 static char * checkChtypeKey(chtype key);
24 static chtype sv2chtype(SV *sv);
25 static int sv2dtype(SV * sv);
26 static int sv2int(SV *sv);
27
28 CDKSCREEN * GCDKSCREEN = (CDKSCREEN *)NULL;
29 WINDOW * GCWINDOW = (WINDOW *)NULL;
30
31 /* this would be a function, except the menu widget relies on a fixed array */
32 #define MAKE_MENU_MATRIX(START,INPUT,NEWARRAY,ARRAYSIZE,ARRAYLEN) \
33 do { \
34 AV *array = (AV *)SvRV((INPUT)); \
35 int x, y; \
36 \
37 (ARRAYLEN) = av_len (array); \
38 \
39 for (x = 0; x <= (ARRAYLEN); x++) \
40 { \
41 SV *name = *av_fetch(array,x,FALSE); \
42 AV *subArray = (AV *)SvRV(name); \
43 int subLen = av_len (subArray); \
44 (ARRAYSIZE)[x+(START)] = subLen + 1; \
45 \
46 for (y=0; y <= subLen; y++) \
47 { \
48 SV *sv = *av_fetch(subArray,y,FALSE); \
49 (NEWARRAY)[x+(START)][y+(START)] = copyChar((char *)SvPV(sv,PL_na)); \
50 } \
51 } \
52 (ARRAYLEN)++; \
53 } while (0)
54
55 static void make_int_array(int start, SV* input, int **dest, int *destlen)
56 {
57 AV *src = (AV *)SvRV(input);
58 int length = av_len(src) + 1;
59 int x;
60
61 if ((*dest = (int *)calloc(length + 2, sizeof(int *))) == 0)
62 {
63 croak("make_int_array(%d)", length + 2);
64 }
65 for (x=0; x < length; x++)
66 {
67 SV *foo = *av_fetch(src, x, FALSE);
68 (*dest)[x + start] = sv2int (foo);
69 }
70 *destlen = length;
71 }
72 #define MAKE_INT_ARRAY(START, INPUT, DEST, LEN) \
73 make_int_array(START, INPUT, &DEST, &LEN)
74
75 static void make_dtype_array(int start, SV *input, int **dest, int *destlen)
76 {
77 AV *src = (AV *)SvRV(input);
78 int length = av_len(src) + 1;
79 int x;
80
81 if ((*dest = (int *)calloc(length + 2, sizeof(int *))) == 0)
82 {
83 croak("make_dtype_array(%d)", length + 2);
84 }
85 for (x=0; x < length; x++)
86 {
87 SV *foo = *av_fetch(src, x, FALSE);
88 (*dest)[x + start] = sv2dtype (foo);
89 }
90 *destlen = length;
91 }
92 #define MAKE_DTYPE_ARRAY(START, INPUT, DEST, LEN) \
93 make_dtype_array(START, INPUT, &DEST, &LEN)
94
95 static void make_chtype_array(int start, SV *input, chtype **dest, int *destlen)
96 {
97 AV *src = (AV *)SvRV(input);
98 int length = av_len(src) + 1;
99 int x;
100
101 if ((*dest = (chtype *)calloc(length + 2, sizeof(chtype *))) == 0)
102 {
103 croak("make_chtype_array(%d)", length + 2);
104 }
105 for (x=0; x < length; x++)
106 {
107 SV *foo = *av_fetch(src, x, FALSE);
108 (*dest)[x + start] = sv2chtype (foo);
109 }
110 *destlen = length;
111 }
112 #define MAKE_CHTYPE_ARRAY(START, INPUT, DEST, LEN) \
113 make_chtype_array(START, INPUT, &DEST, &LEN)
114
115 static void make_char_array(int start, SV *input, char ***dest, int *destlen)
116 {
117 AV *src = (AV *)SvRV(input);
118 int length = av_len(src) + 1;
119 int x;
120
121 if ((*dest = (char **)calloc(length + 2, sizeof(char *))) == 0)
122 {
123 croak("make_char_array(%d)", length + 2);
124 }
125 for (x=0; x < length; x++)
126 {
127 SV *foo = *av_fetch(src, x, FALSE);
128 (*dest)[x + start] = copyChar((char *)SvPV(foo,PL_na));
129 }
130 *destlen = length;
131 }
132 #define MAKE_CHAR_ARRAY(START, INPUT, DEST, LEN) \
133 make_char_array(START, INPUT, &DEST, &LEN)
134
135 static void make_title(SV * input, char **dest)
136 {
137 char *data;
138
139 if (SvROK(input) && SvTYPE(SvRV(input)) == SVt_PVAV)
140 {
141 AV *src = (AV *)SvRV(input);
142 int len = av_len(src) + 1;
143 int x;
144 int length = 2;
145
146 for (x=0; x < len; x++)
147 {
148 SV *foo = *av_fetch(src, x, FALSE);
149 data = (char *)SvPV(foo,PL_na);
150 length += strlen(data) + 1;
151 }
152 *dest = malloc(length);
153 if (*dest == 0)
154 croak("make_title");
155
156 **dest = '\0';
157 for (x=0; x < len; x++)
158 {
159 SV *foo = *av_fetch(src, x, FALSE);
160 data = (char *)SvPV(foo,PL_na);
161 if (x != 0)
162 strcat(*dest, "\n");
163 strcat(*dest, data);
164 }
165 }
166 else
167 {
168 data = (char *)SvPV(input,PL_na);
169 *dest = malloc(strlen(data) + 1);
170 if (*dest == 0)
171 croak("make_title");
172 strcpy (*dest, data);
173 }
174 }
175 #define MAKE_TITLE(INPUT, DEST) \
176 make_title(INPUT, &DEST)
177
178 /*
179 * The callback callback to run Perl callback routines. Are you confused???
180 */
181 int PerlBindCB (EObjectType cdktype, void *object, void *data, chtype input)
182 {
183 dSP ;
184
185 SV *foo = (SV*)data;
186 int returnValueCount, returnValue;
187 char *chtypeKey, temp[10];
188
189 ENTER;
190 SAVETMPS;
191 PUSHMARK (sp);
192
193 /* Check which key input is... */
194 chtypeKey = checkChtypeKey (input);
195 if (chtypeKey == (char *)NULL)
196 {
197 sprintf (temp, "%c", (char)input);
198 XPUSHs (sv_2mortal(newSVpv(temp, 1)));
199 }
200 else
201 {
202 XPUSHs (sv_2mortal(newSVpv(chtypeKey, strlen(chtypeKey))));
203 }
204 PUTBACK ;
205
206 /* Call the perl subroutine. */
207 returnValueCount = perl_call_sv (foo, G_SCALAR);
208
209 SPAGAIN;
210
211 /* Check the number of values returned from this function. */
212 if (returnValueCount == 0)
213 {
214 /* They didn't return anything, let them continue. */
215 PUTBACK;
216 FREETMPS;
217 LEAVE;
218 return 1;
219 }
220
221 /* They returned something, lets find out what it is. */
222 returnValue = POPi;
223
224 PUTBACK;
225 FREETMPS;
226 LEAVE;
227 return 1;
228 }
229
230 /*
231 * The callback callback to run Perl callback routines. Are you confused???
232 */
233 int PerlProcessCB (EObjectType cdktype, void *object, void *data, chtype input)
234 {
235 dSP ;
236
237 SV *foo = (SV*)data;
238 int returnValueCount, returnValue;
239 char *chtypeKey, temp[10];
240
241 ENTER;
242 SAVETMPS;
243 PUSHMARK (sp);
244
245 /* Check which key input is... */
246 chtypeKey = checkChtypeKey (input);
247 if (chtypeKey == (char *)NULL)
248 {
249 sprintf (temp, "%c", (char)input);
250 XPUSHs (sv_2mortal(newSVpv(temp, 1)));
251 }
252 else
253 {
254 XPUSHs (sv_2mortal(newSVpv(chtypeKey, strlen(chtypeKey))));
255 }
256 PUTBACK ;
257
258 /* Call the perl subroutine. */
259 returnValueCount = perl_call_sv (foo, G_SCALAR);
260
261 SPAGAIN;
262
263 /* Check the number of values returned from this function. */
264 if (returnValueCount == 0)
265 {
266 /* They didn't return anything, let them continue. */
267 PUTBACK;
268 FREETMPS;
269 LEAVE;
270 return 1;
271 }
272
273 /* They returned something, lets find out what it is. */
274 returnValue = POPi;
275
276 PUTBACK;
277 FREETMPS;
278 LEAVE;
279 return returnValue;
280 }
281
282 void checkCdkInit(void)
283 {
284 if (GCDKSCREEN == (CDKSCREEN *)NULL)
285 {
286 croak ("Cdk has not been initialized.\n");
287 }
288 }
289
290 static char *
291 checkChtypeKey(chtype key)
292 {
293 char *result = 0;
294
295 if (key == KEY_UP)
296 result = "KEY_UP";
297 else if (key == KEY_DOWN)
298 result = "KEY_DOWN";
299 else if (key == KEY_LEFT)
300 result = "KEY_LEFT";
301 else if (key == KEY_RIGHT)
302 result = "KEY_RIGHT";
303 else if (key == KEY_NPAGE)
304 result = "KEY_NPAGE";
305 else if (key == KEY_PPAGE)
306 result = "KEY_PPAGE";
307 else if (key == KEY_END)
308 result = "KEY_END";
309 else if (key == KEY_HOME)
310 result = "KEY_HOME";
311 else if (key == KEY_BACKSPACE)
312 result = "KEY_BACKSPACE";
313 else if (key == DELETE)
314 result = "KEY_DELETE";
315 else if (key == KEY_ESC)
316 result = "KEY_ESC";
317
318 return result;
319 }
320
321 static int
322 sv2integer(SV *sv, int invalid)
323 {
324 char *from = SvPV(sv,PL_na);
325 char mark;
326 int result;
327
328 if (sscanf(from, "%d%c", &result, &mark) != 1)
329 {
330 result = invalid;
331 }
332 return result;
333 }
334
335 static chtype
336 sv2chtype(SV *sv)
337 {
338 bool found = FALSE;
339 chtype result = 0;
340
341 if (SvPOK(sv))
342 {
343 char *name = SvPV(sv,PL_na);
344 chtype *fillerChtype;
345 int j1, j2;
346
347 found = TRUE;
348 if (strEQ(name, "ACS_BTEE"))
349 result = ACS_BTEE;
350 else if (strEQ(name, "ACS_HLINE"))
351 result = ACS_HLINE;
352 else if (strEQ(name, "ACS_LLCORNER"))
353 result = ACS_LLCORNER;
354 else if (strEQ(name, "ACS_LRCORNER"))
355 result = ACS_LRCORNER;
356 else if (strEQ(name, "ACS_LTEE"))
357 result = ACS_LTEE;
358 else if (strEQ(name, "ACS_PLUS"))
359 result = ACS_PLUS;
360 else if (strEQ(name, "ACS_RTEE"))
361 result = ACS_RTEE;
362 else if (strEQ(name, "ACS_TTEE"))
363 result = ACS_TTEE;
364 else if (strEQ(name, "ACS_ULCORNER"))
365 result = ACS_ULCORNER;
366 else if (strEQ(name, "ACS_URCORNER"))
367 result = ACS_URCORNER;
368 else if (strEQ(name, "ACS_VLINE"))
369 result = ACS_VLINE;
370 else if (strEQ(name, "A_ALTCHARSET"))
371 result = A_ALTCHARSET;
372 else if (strEQ(name, "A_ATTRIBUTES"))
373 result = A_ATTRIBUTES;
374 else if (strEQ(name, "A_BLINK"))
375 result = A_BLINK;
376 else if (strEQ(name, "A_BOLD"))
377 result = A_BOLD;
378 else if (strEQ(name, "A_CHARTEXT"))
379 result = A_CHARTEXT;
380 else if (strEQ(name, "A_COLOR"))
381 result = A_COLOR;
382 else if (strEQ(name, "A_DIM"))
383 result = A_DIM;
384 else if (strEQ(name, "A_INVIS"))
385 result = A_INVIS;
386 else if (strEQ(name, "A_NORMAL"))
387 result = A_NORMAL;
388 else if (strEQ(name, "A_PROTECT"))
389 result = A_PROTECT;
390 else if (strEQ(name, "A_REVERSE"))
391 result = A_REVERSE;
392 else if (strEQ(name, "A_STANDOUT"))
393 result = A_STANDOUT;
394 else if (strEQ(name, "A_UNDERLINE"))
395 result = A_UNDERLINE;
396 else if (strEQ(name, "CDK_COPY"))
397 result = CDK_COPY;
398 else if (strEQ(name, "CDK_CUT"))
399 result = CDK_CUT;
400 else if (strEQ(name, "CDK_ERASE"))
401 result = CDK_ERASE;
402 else if (strEQ(name, "CDK_PASTE"))
403 result = CDK_PASTE;
404 else if (strEQ(name, "CDK_REFRESH"))
405 result = CDK_REFRESH;
406 #ifdef COLOR
407 else if (strEQ(name, "COLOR_BLACK"))
408 result = COLOR_BLACK;
409 else if (strEQ(name, "COLOR_BLUE"))
410 result = COLOR_BLUE;
411 else if (strEQ(name, "COLOR_CYAN"))
412 result = COLOR_CYAN;
413 else if (strEQ(name, "COLOR_GREEN"))
414 result = COLOR_GREEN;
415 else if (strEQ(name, "COLOR_MAGENTA"))
416 result = COLOR_MAGENTA;
417 else if (strEQ(name, "COLOR_RED"))
418 result = COLOR_RED;
419 else if (strEQ(name, "COLOR_WHITE"))
420 result = COLOR_WHITE;
421 else if (strEQ(name, "COLOR_YELLOW"))
422 result = COLOR_YELLOW;
423 #endif
424 else if (strEQ(name, "DELETE"))
425 result = DELETE;
426 else if (strEQ(name, "KEY_A1"))
427 result = KEY_A1;
428 else if (strEQ(name, "KEY_A3"))
429 result = KEY_A3;
430 else if (strEQ(name, "KEY_B2"))
431 result = KEY_B2;
432 else if (strEQ(name, "KEY_BACKSPACE"))
433 result = KEY_BACKSPACE;
434 else if (strEQ(name, "KEY_BEG"))
435 result = KEY_BEG;
436 else if (strEQ(name, "KEY_BREAK"))
437 result = KEY_BREAK;
438 else if (strEQ(name, "KEY_BTAB"))
439 result = KEY_BTAB;
440 else if (strEQ(name, "KEY_C1"))
441 result = KEY_C1;
442 else if (strEQ(name, "KEY_C3"))
443 result = KEY_C3;
444 else if (strEQ(name, "KEY_CANCEL"))
445 result = KEY_CANCEL;
446 else if (strEQ(name, "KEY_CATAB"))
447 result = KEY_CATAB;
448 else if (strEQ(name, "KEY_CLEAR"))
449 result = KEY_CLEAR;
450 else if (strEQ(name, "KEY_CLOSE"))
451 result = KEY_CLOSE;
452 else if (strEQ(name, "KEY_COMMAND"))
453 result = KEY_COMMAND;
454 else if (strEQ(name, "KEY_COPY"))
455 result = KEY_COPY;
456 else if (strEQ(name, "KEY_CREATE"))
457 result = KEY_CREATE;
458 else if (strEQ(name, "KEY_CTAB"))
459 result = KEY_CTAB;
460 else if (strEQ(name, "KEY_DC"))
461 result = KEY_DC;
462 else if (strEQ(name, "KEY_DL"))
463 result = KEY_DL;
464 else if (strEQ(name, "KEY_DOWN"))
465 result = KEY_DOWN;
466 else if (strEQ(name, "KEY_EIC"))
467 result = KEY_EIC;
468 else if (strEQ(name, "KEY_END"))
469 result = KEY_END;
470 else if (strEQ(name, "KEY_ENTER"))
471 result = KEY_ENTER;
472 else if (strEQ(name, "KEY_EOL"))
473 result = KEY_EOL;
474 else if (strEQ(name, "KEY_EOS"))
475 result = KEY_EOS;
476 else if (strEQ(name, "KEY_ESC"))
477 result = KEY_ESC;
478 else if (strEQ(name, "KEY_EXIT"))
479 result = KEY_EXIT;
480 else if (strEQ(name, "KEY_F0"))
481 result = KEY_F0;
482 else if (strEQ(name, "KEY_F1"))
483 result = KEY_F1;
484 else if (strEQ(name, "KEY_F10"))
485 result = KEY_F10;
486 else if (strEQ(name, "KEY_F11"))
487 result = KEY_F11;
488 else if (strEQ(name, "KEY_F12"))
489 result = KEY_F12;
490 else if (strEQ(name, "KEY_F2"))
491 result = KEY_F2;
492 else if (strEQ(name, "KEY_F3"))
493 result = KEY_F3;
494 else if (strEQ(name, "KEY_F4"))
495 result = KEY_F4;
496 else if (strEQ(name, "KEY_F5"))
497 result = KEY_F5;
498 else if (strEQ(name, "KEY_F6"))
499 result = KEY_F6;
500 else if (strEQ(name, "KEY_F7"))
501 result = KEY_F7;
502 else if (strEQ(name, "KEY_FIND"))
503 result = KEY_FIND;
504 else if (strEQ(name, "KEY_HELP"))
505 result = KEY_HELP;
506 else if (strEQ(name, "KEY_HOME"))
507 result = KEY_HOME;
508 else if (strEQ(name, "KEY_IC"))
509 result = KEY_IC;
510 else if (strEQ(name, "KEY_IL"))
511 result = KEY_IL;
512 else if (strEQ(name, "KEY_LEFT"))
513 result = KEY_LEFT;
514 else if (strEQ(name, "KEY_LL"))
515 result = KEY_LL;
516 else if (strEQ(name, "KEY_MARK"))
517 result = KEY_MARK;
518 else if (strEQ(name, "KEY_MAX"))
519 result = KEY_MAX;
520 else if (strEQ(name, "KEY_MESSAGE"))
521 result = KEY_MESSAGE;
522 else if (strEQ(name, "KEY_MIN"))
523 result = KEY_MIN;
524 else if (strEQ(name, "KEY_MOVE"))
525 result = KEY_MOVE;
526 else if (strEQ(name, "KEY_NPAGE"))
527 result = KEY_NPAGE;
528 else if (strEQ(name, "KEY_OPEN"))
529 result = KEY_OPEN;
530 else if (strEQ(name, "KEY_OPTIONS"))
531 result = KEY_OPTIONS;
532 else if (strEQ(name, "KEY_PPAGE"))
533 result = KEY_PPAGE;
534 else if (strEQ(name, "KEY_PREVIOUS"))
535 result = KEY_PREVIOUS;
536 else if (strEQ(name, "KEY_PRINT"))
537 result = KEY_PRINT;
538 else if (strEQ(name, "KEY_REDO"))
539 result = KEY_REDO;
540 else if (strEQ(name, "KEY_REFERENCE"))
541 result = KEY_REFERENCE;
542 else if (strEQ(name, "KEY_REFRESH"))
543 result = KEY_REFRESH;
544 else if (strEQ(name, "KEY_REPLACE"))
545 result = KEY_REPLACE;
546 else if (strEQ(name, "KEY_RESET"))
547 result = KEY_RESET;
548 else if (strEQ(name, "KEY_RESTART"))
549 result = KEY_RESTART;
550 else if (strEQ(name, "KEY_RESUME"))
551 result = KEY_RESUME;
552 else if (strEQ(name, "KEY_RETURN"))
553 result = KEY_RETURN;
554 else if (strEQ(name, "KEY_RIGHT"))
555 result = KEY_RIGHT;
556 else if (strEQ(name, "KEY_SAVE"))
557 result = KEY_SAVE;
558 else if (strEQ(name, "KEY_SBEG"))
559 result = KEY_SBEG;
560 else if (strEQ(name, "KEY_SCANCEL"))
561 result = KEY_SCANCEL;
562 else if (strEQ(name, "KEY_SCOMMAND"))
563 result = KEY_SCOMMAND;
564 else if (strEQ(name, "KEY_SCOPY"))
565 result = KEY_SCOPY;
566 else if (strEQ(name, "KEY_SCREATE"))
567 result = KEY_SCREATE;
568 else if (strEQ(name, "KEY_SDC"))
569 result = KEY_SDC;
570 else if (strEQ(name, "KEY_SDL"))
571 result = KEY_SDL;
572 else if (strEQ(name, "KEY_SELECT"))
573 result = KEY_SELECT;
574 else if (strEQ(name, "KEY_SEND"))
575 result = KEY_SEND;
576 else if (strEQ(name, "KEY_SEOL"))
577 result = KEY_SEOL;
578 else if (strEQ(name, "KEY_SEXIT"))
579 result = KEY_SEXIT;
580 else if (strEQ(name, "KEY_SF"))
581 result = KEY_SF;
582 else if (strEQ(name, "KEY_SFIND"))
583 result = KEY_SFIND;
584 else if (strEQ(name, "KEY_SHELP"))
585 result = KEY_SHELP;
586 else if (strEQ(name, "KEY_SHOME"))
587 result = KEY_SHOME;
588 else if (strEQ(name, "KEY_SIC"))
589 result = KEY_SIC;
590 else if (strEQ(name, "KEY_SLEFT"))
591 result = KEY_SLEFT;
592 else if (strEQ(name, "KEY_SMESSAGE"))
593 result = KEY_SMESSAGE;
594 else if (strEQ(name, "KEY_SMOVE"))
595 result = KEY_SMOVE;
596 else if (strEQ(name, "KEY_SNEXT"))
597 result = KEY_SNEXT;
598 else if (strEQ(name, "KEY_SOPTIONS"))
599 result = KEY_SOPTIONS;
600 else if (strEQ(name, "KEY_SPREVIOUS"))
601 result = KEY_SPREVIOUS;
602 else if (strEQ(name, "KEY_SPRINT"))
603 result = KEY_SPRINT;
604 else if (strEQ(name, "KEY_SR"))
605 result = KEY_SR;
606 else if (strEQ(name, "KEY_SREDO"))
607 result = KEY_SREDO;
608 else if (strEQ(name, "KEY_SREPLACE"))
609 result = KEY_SREPLACE;
610 else if (strEQ(name, "KEY_SRESET"))
611 result = KEY_SRESET;
612 else if (strEQ(name, "KEY_SRIGHT"))
613 result = KEY_SRIGHT;
614 else if (strEQ(name, "KEY_SRSUME"))
615 result = KEY_SRSUME;
616 else if (strEQ(name, "KEY_SSAVE"))
617 result = KEY_SSAVE;
618 else if (strEQ(name, "KEY_SSUSPEND"))
619 result = KEY_SSUSPEND;
620 else if (strEQ(name, "KEY_STAB"))
621 result = KEY_STAB;
622 else if (strEQ(name, "KEY_SUNDO"))
623 result = KEY_SUNDO;
624 else if (strEQ(name, "KEY_SUSPEND"))
625 result = KEY_SUSPEND;
626 else if (strEQ(name, "KEY_TAB"))
627 result = KEY_TAB;
628 else if (strEQ(name, "KEY_UNDO"))
629 result = KEY_UNDO;
630 else if (strEQ(name, "KEY_UP"))
631 result = KEY_UP;
632 else if (strEQ(name, "SPACE"))
633 result = SPACE;
634 else if (strEQ(name, "TAB"))
635 result = TAB;
636 /* Else they used a format of </X> to specify a chtype. */
637 else if ((fillerChtype = char2Chtype (name, &j1, &j2)) != 0) {
638 result = fillerChtype[0];
639 freeChtype (fillerChtype);
640 }
641 else
642 found = FALSE;
643 }
644 if (!found)
645 {
646 result = (chtype)sv2integer(sv, 0);
647 }
648 return result;
649 }
650
651 static int
652 sv2dtype(SV * sv)
653 {
654 bool found = FALSE;
655 int result = vINVALID;
656
657 if (SvPOK(sv))
658 {
659 char *name = SvPV(sv,PL_na);
660
661 found = TRUE;
662 if (strEQ (name, "CHAR"))
663 result = vCHAR;
664 else if (strEQ (name, "HCHAR"))
665 result = vHCHAR;
666 else if (strEQ (name, "INT"))
667 result = vINT;
668 else if (strEQ (name, "HINT"))
669 result = vHINT;
670 else if (strEQ (name, "MIXED"))
671 result = vMIXED;
672 else if (strEQ (name, "HMIXED"))
673 result = vHMIXED;
674 else if (strEQ (name, "UCHAR"))
675 result = vUCHAR;
676 else if (strEQ (name, "LCHAR"))
677 result = vLCHAR;
678 else if (strEQ (name, "UHCHAR"))
679 result = vUHCHAR;
680 else if (strEQ (name, "LHCHAR"))
681 result = vLHCHAR;
682 else if (strEQ (name, "UMIXED"))
683 result = vUMIXED;
684 else if (strEQ (name, "LMIXED"))
685 result = vLMIXED;
686 else if (strEQ (name, "UHMIXED"))
687 result = vUHMIXED;
688 else if (strEQ (name, "LHMIXED"))
689 result = vLHMIXED;
690 else if (strEQ (name, "VIEWONLY"))
691 result = vVIEWONLY;
692 else if (strEQ (name, "NONE"))
693 result = vNONE;
694 else if (strEQ (name, "PERCENT"))
695 result = vPERCENT;
696 else if (strEQ (name, "REAL"))
697 result = vREAL;
698 else if (strEQ (name, "PLOT"))
699 result = vPLOT;
700 else if (strEQ (name, "LINE"))
701 result = vLINE;
702 else
703 found = FALSE;
704 }
705 if (!found)
706 {
707 result = sv2integer(sv, vINVALID);
708 }
709 return result;
710 }
711
712 static int
713 sv2int(SV *sv)
714 {
715 bool found = FALSE;
716 int result = 0;
717
718 if (SvPOK(sv))
719 {
720 char *name = SvPV(sv,PL_na);
721
722 found = TRUE;
723 if (strEQ(name, "BOTTOM"))
724 result = BOTTOM;
725 else if (strEQ(name, "CENTER"))
726 result = CENTER;
727 else if (strEQ(name, "COL"))
728 result = COL;
729 else if (strEQ(name, "FALSE"))
730 result = FALSE;
731 else if (strEQ(name, "FULL"))
732 result = FULL;
733 else if (strEQ(name, "HORIZONTAL"))
734 result = HORIZONTAL;
735 else if (strEQ(name, "LEFT"))
736 result = LEFT;
737 else if (strEQ(name, "NONE"))
738 result = NONE;
739 else if (strEQ(name, "NONUMBERS"))
740 result = NONUMBERS;
741 else if (strEQ(name, "NUMBERS"))
742 result = NUMBERS;
743 else if (strEQ(name, "RIGHT"))
744 result = RIGHT;
745 else if (strEQ(name, "ROW"))
746 result = ROW;
747 else if (strEQ(name, "TRUE"))
748 result = TRUE;
749 else if (strEQ(name, "TOP"))
750 result = TOP;
751 else if (strEQ(name, "VERTICAL"))
752 result = VERTICAL;
753 else
754 found = FALSE;
755 }
756 if (!found)
757 {
758 result = sv2integer(sv, 0);
759 }
760 return result;
761 }
762
763 static char *
764 sv2CharPtr(SV *inp)
765 {
766 char *name = (char *)SvPV(inp,PL_na);
767 return (name);
768 }
769
770 static int
771 not_here(char *s)
772 {
773 croak("%s not implemented on this architecture", s);
774 return -1;
775 }
776
777 static double
778 constant(char *name, int arg)
779 {
780 errno = 0;
781 switch (*name) {
782 case 'A':
783 break;
784 case 'B':
785 break;
786 case 'C':
787 break;
788 case 'D':
789 break;
790 case 'E':
791 break;
792 case 'F':
793 break;
794 case 'G':
795 break;
796 case 'H':
797 break;
798 case 'I':
799 break;
800 case 'J':
801 break;
802 case 'K':
803 break;
804 case 'L':
805 break;
806 case 'M':
807 break;
808 case 'N':
809 break;
810 case 'O':
811 break;
812 case 'P':
813 break;
814 case 'Q':
815 break;
816 case 'R':
817 break;
818 case 'S':
819 break;
820 case 'T':
821 break;
822 case 'U':
823 break;
824 case 'V':
825 break;
826 case 'W':
827 break;
828 case 'X':
829 break;
830 case 'Y':
831 break;
832 case 'Z':
833 break;
834 }
835 errno = EINVAL;
836 return 0;
837
838 not_there:
839 errno = ENOENT;
840 return 0;
841 }
842
843 MODULE = Cdk PACKAGE = Cdk
844
845 char *
846 getVersion()
847 CODE:
848 {
849 RETVAL = CDKVersion();
850 }
851 OUTPUT:
852 RETVAL
853
854 double
855 constant(name,arg)
856 char * name
857 int arg
858
859 void
860 Beep()
861 CODE:
862 {
863 Beep();
864 }
865
866 CDKSCREEN *
867 init()
868 CODE:
869 {
870 GCWINDOW = initscr();
871 GCDKSCREEN = initCDKScreen (GCWINDOW);
872
873 /* Start the colors. */
874 initCDKColor();
875
876 RETVAL = GCDKSCREEN;
877 }
878 OUTPUT:
879 RETVAL
880
881 long
882 getColor(pair)
883 int pair
884 CODE:
885 {
886 RETVAL = COLOR_PAIR(pair);
887 }
888
889 void
890 end()
891 CODE:
892 {
893 /* Kill the main screen. */
894 destroyCDKScreen (GCDKSCREEN);
895
896 /* Remove the curses window. */
897 delwin (GCWINDOW);
898
899 /* Shut down curses. */
900 endCDK();
901 kill (0, 2);
902 }
903
904 CDKSCREEN *
905 getCdkScreen()
906 CODE:
907 {
908 RETVAL = GCDKSCREEN;
909 }
910 OUTPUT:
911 RETVAL
912
913 void
914 getCdkScreenDim()
915 PPCODE:
916 {
917 XPUSHs (sv_2mortal(newSViv(GCDKSCREEN->window->_maxy)));
918 XPUSHs (sv_2mortal(newSViv(GCDKSCREEN->window->_maxx)));
919 }
920
921 WINDOW *
922 getCdkWindow()
923 CODE:
924 {
925 RETVAL = GCDKSCREEN->window;
926 }
927
928
929 void
930 refreshCdkScreen()
931 CODE:
932 {
933 refreshCDKScreen (GCDKSCREEN);
934 }
935
936 void
937 eraseCdkScreen()
938 CODE:
939 {
940 eraseCDKScreen (GCDKSCREEN);
941 }
942
943 void
944 destroyCdkScreen()
945 CODE:
946 {
947 destroyCDKScreen(GCDKSCREEN);
948 }
949
950 void
951 DrawMesg(window,mesg,attrib=A_NORMAL,xpos=CENTER,ypos=CENTER,align=HORIZONTAL)
952 WINDOW * window
953 char * mesg
954 chtype attrib = sv2chtype ($arg);
955 int xpos = sv2int ($arg);
956 int ypos = sv2int ($arg);
957 int align = sv2int ($arg);
958 CODE:
959 {
960 int mesgLen = strlen (mesg);
961
962 writeChar (window, xpos, ypos, mesg, align, 0, mesgLen);
963 }
964
965 chtype
966 getch()
967
968 void
969 raw()
970
971 void
972 noraw()
973
974 PROTOTYPES: DISABLE
975
976 MODULE = Cdk PACKAGE = Cdk::Label
977
978 CDKLABEL *
979 New(mesg,xPos=CENTER,yPos=CENTER,box=TRUE,shadow=FALSE)
980 SV * mesg
981 int xPos = sv2int ($arg);
982 int yPos = sv2int ($arg);
983 int box = sv2int ($arg);
984 int shadow = sv2int ($arg);
985 CODE:
986 {
987 CDKLABEL * widget = (CDKLABEL *)NULL;
988 char ** message;
989 int messageLines;
990
991 checkCdkInit();
992
993 MAKE_CHAR_ARRAY (0, mesg, message, messageLines);
994
995 widget = newCDKLabel (GCDKSCREEN, xPos, yPos,
996 message, messageLines,
997 box, shadow);
998 free (message);
999
1000 /* Check the return value. */
1001 if (widget == (CDKLABEL *)NULL)
1002 {
1003 croak ("Cdk::Label Could not create widget. Is the window too small?\n");
1004 }
1005 else
1006 {
1007 RETVAL = widget;
1008 }
1009 }
1010 OUTPUT:
1011 RETVAL
1012
1013 void
1014 SetMessage(object,mesg)
1015 CDKLABEL * object
1016 SV * mesg
1017 CODE:
1018 {
1019 char ** message;
1020 int messageLines;
1021
1022 MAKE_CHAR_ARRAY (0, mesg, message, messageLines);
1023 setCDKLabelMessage (object, message, messageLines);
1024 free (message);
1025 }
1026
1027 void
1028 SetBox(object,box=TRUE)
1029 CDKLABEL * object
1030 int box = sv2int ($arg);
1031 CODE:
1032 {
1033 setCDKLabelBox (object,box);
1034 }
1035
1036 void
1037 SetULChar(object,character=ACS_ULCORNER)
1038 CDKLABEL * object
1039 chtype character = sv2chtype ($arg);
1040 CODE:
1041 {
1042 setCDKLabelULChar (object,character);
1043 }
1044
1045 void
1046 SetURChar(object,character=ACS_URCORNER)
1047 CDKLABEL * object
1048 chtype character = sv2chtype ($arg);
1049 CODE:
1050 {
1051 setCDKLabelURChar (object,character);
1052 }
1053
1054 void
1055 SetLLChar(object,character=ACS_LLCORNER)
1056 CDKLABEL * object
1057 chtype character = sv2chtype ($arg);
1058 CODE:
1059 {
1060 setCDKLabelLLChar (object,character);
1061 }
1062
1063 void
1064 SetLRChar(object,character=ACS_LRCORNER)
1065 CDKLABEL * object
1066 chtype character = sv2chtype ($arg);
1067 CODE:
1068 {
1069 setCDKLabelLRChar (object,character);
1070 }
1071
1072 void
1073 SetVerticalChar(object,character=ACS_VLINE)
1074 CDKLABEL * object
1075 chtype character = sv2chtype ($arg);
1076 CODE:
1077 {
1078 setCDKLabelVerticalChar (object,character);
1079 }
1080
1081 void
1082 SetHorizontalChar(object,character=ACS_HLINE)
1083 CDKLABEL * object
1084 chtype character = sv2chtype ($arg);
1085 CODE:
1086 {
1087 setCDKLabelHorizontalChar (object,character);
1088 }
1089
1090 void
1091 SetBoxAttribute(object,character=ACS_HLINE)
1092 CDKLABEL * object
1093 chtype character = sv2chtype ($arg);
1094 CODE:
1095 {
1096 setCDKLabelBoxAttribute (object,character);
1097 }
1098
1099 void
1100 SetBackgroundColor(object,color)
1101 CDKLABEL * object
1102 char * color
1103 CODE:
1104 {
1105 setCDKLabelBackgroundColor (object,color);
1106 }
1107
1108 void
1109 Draw(object,Box=TRUE)
1110 CDKLABEL * object
1111 int Box = sv2int ($arg);
1112 CODE:
1113 {
1114 drawCDKLabel (object, Box);
1115 }
1116
1117 void
1118 Erase(object)
1119 CDKLABEL * object
1120 CODE:
1121 {
1122 eraseCDKLabel(object);
1123 }
1124
1125 char
1126 Wait(object, key=0)
1127 CDKLABEL * object
1128 chtype key = sv2chtype ($arg);
1129 CODE:
1130 {
1131 RETVAL = waitCDKLabel (object, key);
1132 }
1133 OUTPUT:
1134 RETVAL
1135
1136 void
1137 Register(object)
1138 CDKLABEL * object
1139 CODE:
1140 {
1141 registerCDKObject (GCDKSCREEN, vLABEL, object);
1142 }
1143
1144 void
1145 Unregister(object)
1146 CDKLABEL * object
1147 CODE:
1148 {
1149 unregisterCDKObject (vLABEL, object);
1150 }
1151
1152 void
1153 Raise(object)
1154 CDKLABEL * object
1155 CODE:
1156 {
1157 raiseCDKObject (vLABEL, object);
1158 }
1159
1160 void
1161 Lower(object)
1162 CDKLABEL * object
1163 CODE:
1164 {
1165 lowerCDKObject (vLABEL, object);
1166 }
1167
1168 WINDOW *
1169 GetWindow(object)
1170 CDKLABEL * object
1171 CODE:
1172 {
1173 RETVAL = object->win;
1174 }
1175 OUTPUT:
1176 RETVAL
1177
1178 MODULE = Cdk PACKAGE = Cdk::Dialog
1179
1180 CDKDIALOG *
1181 New(message,buttons,xPos=CENTER,yPos=CENTER,highlight=A_REVERSE,seperator=TRUE,Box=TRUE,shadow=FALSE)
1182 SV * message
1183 SV * buttons
1184 int xPos = sv2int ($arg);
1185 int yPos = sv2int ($arg);
1186 chtype highlight = sv2chtype ($arg);
1187 int seperator = sv2int ($arg);
1188 int Box = sv2int ($arg);
1189 int shadow = sv2int ($arg);
1190 CODE:
1191 {
1192 CDKDIALOG * dialogWidget = (CDKDIALOG *)NULL;
1193 char ** Message;
1194 char ** Buttons;
1195 int buttonCount;
1196 int rowCount;
1197
1198 checkCdkInit();
1199
1200 MAKE_CHAR_ARRAY (0, message, Message, rowCount);
1201 MAKE_CHAR_ARRAY (0, buttons, Buttons, buttonCount);
1202
1203 dialogWidget = newCDKDialog (GCDKSCREEN,xPos,yPos,
1204 Message,rowCount,
1205 Buttons,buttonCount,
1206 highlight,seperator,
1207 Box,shadow);
1208 free (Message);
1209 free (Buttons);
1210
1211 /* Check the return type. */
1212 if (dialogWidget == (CDKDIALOG *)NULL)
1213 {
1214 croak ("Cdk::Dialog Could not create widget. Is the window too small?\n");
1215 }
1216 else
1217 {
1218 RETVAL = dialogWidget;
1219 }
1220 }
1221 OUTPUT:
1222 RETVAL
1223
1224 int
1225 Activate(object,...)
1226 CDKDIALOG * object
1227 CODE:
1228 {
1229 chtype * Keys;
1230 int arrayLen;
1231 int value;
1232
1233 if (items > 1)
1234 {
1235 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
1236 value = activateCDKDialog (object, Keys);
1237 free (Keys);
1238 }
1239 else
1240 {
1241 value = activateCDKDialog (object, NULL);
1242 }
1243
1244 if (object->exitType == vEARLY_EXIT ||
1245 object->exitType == vESCAPE_HIT)
1246 {
1247 XSRETURN_UNDEF;
1248 }
1249 RETVAL = value;
1250 }
1251 OUTPUT:
1252 RETVAL
1253
1254 int
1255 Inject(object,key)
1256 CDKDIALOG * object
1257 chtype key = sv2chtype ($arg);
1258 CODE:
1259 {
1260 int selection = injectCDKDialog (object,key);
1261 if (selection == -1)
1262 {
1263 XSRETURN_UNDEF;
1264 }
1265 RETVAL = selection;
1266 }
1267 OUTPUT:
1268 RETVAL
1269
1270 void
1271 Bind(object,key,functionRef)
1272 CDKDIALOG * object
1273 chtype key = sv2chtype ($arg);
1274 SV * functionRef
1275 CODE:
1276 {
1277 SV *function = newSVsv (functionRef);
1278 bindCDKObject (vDIALOG, object, key, PerlBindCB, function);
1279 }
1280
1281 int
1282 PreProcess(object,functionRef)
1283 CDKDIALOG * object
1284 SV * functionRef
1285 CODE:
1286 {
1287 SV *function = newSVsv (functionRef);
1288 setCDKDialogPreProcess (object, PerlProcessCB, function);
1289 }
1290 OUTPUT:
1291 RETVAL
1292
1293 int
1294 PostProcess(object,functionRef)
1295 CDKDIALOG * object
1296 SV * functionRef
1297 CODE:
1298 {
1299 SV *function = newSVsv (functionRef);
1300 setCDKDialogPostProcess (object, PerlProcessCB, function);
1301 }
1302 OUTPUT:
1303 RETVAL
1304
1305 void
1306 Draw(object,Box=TRUE)
1307 CDKDIALOG * object
1308 int Box = sv2int ($arg);
1309 CODE:
1310 {
1311 drawCDKDialog (object,Box);
1312 }
1313
1314 void
1315 Erase(object)
1316 CDKDIALOG * object
1317 CODE:
1318 {
1319 eraseCDKDialog (object);
1320 }
1321
1322 void
1323 SetHighlight(object,highlight=A_REVERSE)
1324 CDKDIALOG * object
1325 chtype highlight = sv2chtype ($arg);
1326 CODE:
1327 {
1328 setCDKDialogHighlight (object,highlight);
1329 }
1330
1331 void
1332 SetSeparator(object,separator=TRUE)
1333 CDKDIALOG * object
1334 int separator
1335 CODE:
1336 {
1337 setCDKDialogSeparator (object,separator);
1338 }
1339
1340 void
1341 SetBox(object,box=TRUE)
1342 CDKDIALOG * object
1343 int box = sv2int ($arg);
1344 CODE:
1345 {
1346 setCDKDialogBox (object,box);
1347 }
1348
1349 void
1350 SetULChar(object,character=ACS_ULCORNER)
1351 CDKDIALOG * object
1352 chtype character = sv2chtype ($arg);
1353 CODE:
1354 {
1355 setCDKDialogULChar (object,character);
1356 }
1357
1358 void
1359 SetURChar(object,character=ACS_URCORNER)
1360 CDKDIALOG * object
1361 chtype character = sv2chtype ($arg);
1362 CODE:
1363 {
1364 setCDKDialogURChar (object,character);
1365 }
1366
1367 void
1368 SetLLChar(object,character=ACS_LLCORNER)
1369 CDKDIALOG * object
1370 chtype character = sv2chtype ($arg);
1371 CODE:
1372 {
1373 setCDKDialogLLChar (object,character);
1374 }
1375
1376 void
1377 SetLRChar(object,character=ACS_LRCORNER)
1378 CDKDIALOG * object
1379 chtype character = sv2chtype ($arg);
1380 CODE:
1381 {
1382 setCDKDialogLRChar (object,character);
1383 }
1384
1385 void
1386 SetVerticalChar(object,character=ACS_VLINE)
1387 CDKDIALOG * object
1388 chtype character = sv2chtype ($arg);
1389 CODE:
1390 {
1391 setCDKDialogVerticalChar (object,character);
1392 }
1393
1394 void
1395 SetHorizontalChar(object,character=ACS_HLINE)
1396 CDKDIALOG * object
1397 chtype character = sv2chtype ($arg);
1398 CODE:
1399 {
1400 setCDKDialogHorizontalChar (object,character);
1401 }
1402
1403 void
1404 SetBoxAttribute(object,character=ACS_HLINE)
1405 CDKDIALOG * object
1406 chtype character = sv2chtype ($arg);
1407 CODE:
1408 {
1409 setCDKDialogBoxAttribute (object,character);
1410 }
1411
1412 void
1413 SetBackgroundColor(object,color)
1414 CDKDIALOG * object
1415 char * color
1416 CODE:
1417 {
1418 setCDKDialogBackgroundColor (object,color);
1419 }
1420
1421 void
1422 Register(object)
1423 CDKDIALOG * object
1424 CODE:
1425 {
1426 registerCDKObject (GCDKSCREEN, vDIALOG, object);
1427 }
1428
1429 void
1430 Unregister(object)
1431 CDKDIALOG * object
1432 CODE:
1433 {
1434 unregisterCDKObject (vDIALOG, object);
1435 }
1436
1437 void
1438 Raise(object)
1439 CDKDIALOG * object
1440 CODE:
1441 {
1442 raiseCDKObject (vDIALOG, object);
1443 }
1444
1445 void
1446 Lower(object)
1447 CDKDIALOG * object
1448 CODE:
1449 {
1450 lowerCDKObject (vDIALOG, object);
1451 }
1452
1453 WINDOW *
1454 GetWindow(object)
1455 CDKDIALOG * object
1456 CODE:
1457 {
1458 RETVAL = object->win;
1459 }
1460 OUTPUT:
1461 RETVAL
1462
1463 MODULE = Cdk PACKAGE = Cdk::Scroll
1464
1465 CDKSCROLL *
1466 New (title,mesg,height,width,xPos=CENTER,yPos=CENTER,sPos=RIGHT,numbers=TRUE,highlight=A_REVERSE,Box=TRUE,shadow=FALSE)
1467 SV * title
1468 SV * mesg
1469 int height
1470 int width
1471 int xPos = sv2int ($arg);
1472 int yPos = sv2int ($arg);
1473 int sPos = sv2int ($arg);
1474 int numbers = sv2int ($arg);
1475 chtype highlight = sv2chtype ($arg);
1476 int Box = sv2int ($arg);
1477 int shadow = sv2int ($arg);
1478 CODE:
1479 {
1480 CDKSCROLL * scrollWidget = 0;
1481 char ** Message;
1482 char * Title;
1483 int mesglen;
1484
1485 checkCdkInit();
1486
1487 MAKE_CHAR_ARRAY(0, mesg, Message, mesglen);
1488 MAKE_TITLE (title,Title);
1489
1490 scrollWidget = newCDKScroll (GCDKSCREEN, xPos, yPos, sPos,
1491 height, width,
1492 Title, Message, mesglen,
1493 numbers, highlight,
1494 Box, shadow);
1495 free (Message);
1496 free (Title);
1497
1498 /* Check the return type. */
1499 if (scrollWidget == (CDKSCROLL *)NULL)
1500 {
1501 croak ("Cdk::Scroll Could not create widget. Is the window too small?\n");
1502 }
1503 else
1504 {
1505 RETVAL = scrollWidget;
1506 }
1507 }
1508 OUTPUT:
1509 RETVAL
1510
1511 int
1512 Activate(object,...)
1513 CDKSCROLL * object
1514 CODE:
1515 {
1516 chtype * Keys;
1517 int arrayLen;
1518 int value;
1519
1520 if (items > 1)
1521 {
1522 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
1523 value = activateCDKScroll (object, Keys);
1524 free (Keys);
1525 }
1526 else
1527 {
1528 value = activateCDKScroll (object, NULL);
1529 }
1530
1531 if (object->exitType == vEARLY_EXIT ||
1532 object->exitType == vESCAPE_HIT)
1533 {
1534 XSRETURN_UNDEF;
1535 }
1536 RETVAL = value;
1537 }
1538 OUTPUT:
1539 RETVAL
1540
1541 int
1542 Inject(object,key)
1543 CDKSCROLL * object
1544 chtype key = sv2chtype ($arg);
1545 CODE:
1546 {
1547 int selection = injectCDKScroll (object,key);
1548 if (selection == -1)
1549 {
1550 XSRETURN_UNDEF;
1551 }
1552 RETVAL = selection;
1553 }
1554 OUTPUT:
1555 RETVAL
1556
1557 void
1558 Add(object,line)
1559 CDKSCROLL * object
1560 char * line
1561 CODE:
1562 {
1563 addCDKScrollItem (object,line);
1564 }
1565
1566 void
1567 Delete(object,position)
1568 CDKSCROLL * object
1569 int position = sv2int ($arg);
1570 CODE:
1571 {
1572 deleteCDKScrollItem (object,position);
1573 }
1574
1575 void
1576 Bind(object,key,functionRef)
1577 CDKSCROLL * object
1578 chtype key = sv2chtype ($arg);
1579 SV * functionRef
1580 CODE:
1581 {
1582 SV *function = newSVsv (functionRef);
1583 bindCDKObject (vSCROLL, object, key, PerlBindCB, function);
1584 }
1585
1586 int
1587 PreProcess(object,functionRef)
1588 CDKSCROLL * object
1589 SV * functionRef
1590 CODE:
1591 {
1592 SV *function = newSVsv (functionRef);
1593 setCDKScrollPreProcess (object, PerlProcessCB, function);
1594 }
1595 OUTPUT:
1596 RETVAL
1597
1598 int
1599 PostProcess(object,functionRef)
1600 CDKSCROLL * object
1601 SV * functionRef
1602 CODE:
1603 {
1604 SV *function = newSVsv (functionRef);
1605 setCDKScrollPostProcess (object, PerlProcessCB, function);
1606 }
1607 OUTPUT:
1608 RETVAL
1609
1610 void
1611 Draw(object,Box=TRUE)
1612 CDKSCROLL * object
1613 int Box = sv2int ($arg);
1614 CODE:
1615 {
1616 drawCDKScroll (object,Box);
1617 }
1618
1619 void
1620 Erase(object)
1621 CDKSCROLL * object
1622 CODE:
1623 {
1624 eraseCDKScroll(object);
1625 }
1626
1627 void
1628 Info(object)
1629 CDKSCROLL * object
1630 PPCODE:
1631 {
1632 int currentItem = object->currentItem;
1633 int size = object->listSize;
1634
1635 XPUSHs (sv_2mortal (newSViv(size)));
1636 XPUSHs (sv_2mortal (newSViv(currentItem)));
1637 }
1638
1639 void
1640 SetItems(object,items,numbers=FALSE)
1641 CDKSCROLL * object
1642 SV * items
1643 int numbers = sv2int ($arg);
1644 CODE:
1645 {
1646 char ** Items;
1647 int itemLength;
1648
1649 MAKE_CHAR_ARRAY(0, items, Items, itemLength);
1650 setCDKScrollItems (object, Items, itemLength, numbers);
1651 free (Items);
1652 }
1653
1654 void
1655 SetHighlight(object,highlight)
1656 CDKSCROLL * object
1657 chtype highlight = sv2chtype ($arg);
1658 CODE:
1659 {
1660 setCDKScrollHighlight (object,highlight);
1661 }
1662
1663 void
1664 SetBox(object,box=TRUE)
1665 CDKSCROLL * object
1666 int box = sv2int ($arg);
1667 CODE:
1668 {
1669 setCDKScrollBox (object,box);
1670 }
1671
1672 void
1673 SetULChar(object,character=ACS_ULCORNER)
1674 CDKSCROLL * object
1675 chtype character = sv2chtype ($arg);
1676 CODE:
1677 {
1678 setCDKScrollULChar (object,character);
1679 }
1680
1681 void
1682 SetURChar(object,character=ACS_URCORNER)
1683 CDKSCROLL * object
1684 chtype character = sv2chtype ($arg);
1685 CODE:
1686 {
1687 setCDKScrollURChar (object,character);
1688 }
1689
1690 void
1691 SetLLChar(object,character=ACS_LLCORNER)
1692 CDKSCROLL * object
1693 chtype character = sv2chtype ($arg);
1694 CODE:
1695 {
1696 setCDKScrollLLChar (object,character);
1697 }
1698
1699 void
1700 SetLRChar(object,character=ACS_LRCORNER)
1701 CDKSCROLL * object
1702 chtype character = sv2chtype ($arg);
1703 CODE:
1704 {
1705 setCDKScrollLRChar (object,character);
1706 }
1707
1708 void
1709 SetVerticalChar(object,character=ACS_VLINE)
1710 CDKSCROLL * object
1711 chtype character = sv2chtype ($arg);
1712 CODE:
1713 {
1714 setCDKScrollVerticalChar (object,character);
1715 }
1716
1717 void
1718 SetHorizontalChar(object,character=ACS_HLINE)
1719 CDKSCROLL * object
1720 chtype character = sv2chtype ($arg);
1721 CODE:
1722 {
1723 setCDKScrollHorizontalChar (object,character);
1724 }
1725
1726 void
1727 SetBoxAttribute(object,character=ACS_HLINE)
1728 CDKSCROLL * object
1729 chtype character = sv2chtype ($arg);
1730 CODE:
1731 {
1732 setCDKScrollBoxAttribute (object,character);
1733 }
1734
1735 void
1736 SetBackgroundColor(object,color)
1737 CDKSCROLL * object
1738 char * color
1739 CODE:
1740 {
1741 setCDKScrollBackgroundColor (object,color);
1742 }
1743
1744 void
1745 Register(object)
1746 CDKSCROLL * object
1747 CODE:
1748 {
1749 registerCDKObject (GCDKSCREEN, vSCROLL, object);
1750 }
1751
1752 void
1753 Unregister(object)
1754 CDKSCROLL * object
1755 CODE:
1756 {
1757 unregisterCDKObject (vSCROLL, object);
1758 }
1759
1760 void
1761 Raise(object)
1762 CDKSCROLL * object
1763 CODE:
1764 {
1765 raiseCDKObject (vSCROLL, object);
1766 }
1767
1768 void
1769 Lower(object)
1770 CDKSCROLL * object
1771 CODE:
1772 {
1773 lowerCDKObject (vSCROLL, object);
1774 }
1775
1776 WINDOW *
1777 GetWindow(object)
1778 CDKSCROLL * object
1779 CODE:
1780 {
1781 RETVAL = object->win;
1782 }
1783 OUTPUT:
1784 RETVAL
1785
1786 MODULE = Cdk PACKAGE = Cdk::Scale
1787
1788 CDKSCALE *
1789 New(title,label,start,low,high,inc,fastinc,fieldwidth,xPos=CENTER,yPos=CENTER,fieldattr=A_NORMAL,Box=TRUE,shadow=FALSE)
1790 SV * title
1791 char * label
1792 int start
1793 int low
1794 int high
1795 int inc
1796 int fastinc
1797 int fieldwidth
1798 int xPos = sv2int ($arg);
1799 int yPos = sv2int ($arg);
1800 chtype fieldattr = sv2chtype ($arg);
1801 int Box = sv2int ($arg);
1802 int shadow = sv2int ($arg);
1803 CODE:
1804 {
1805 CDKSCALE * scaleWidget = (CDKSCALE *)NULL;
1806 char * Title;
1807
1808 checkCdkInit();
1809
1810 MAKE_TITLE (title,Title);
1811
1812 scaleWidget = newCDKScale (GCDKSCREEN,xPos,yPos,
1813 Title,label,
1814 fieldattr,fieldwidth,
1815 start,low,high,inc,fastinc,
1816 Box,shadow);
1817 free (Title);
1818
1819 /* Check the return type. */
1820 if (scaleWidget == (CDKSCALE *)NULL)
1821 {
1822 croak ("Cdk::Scale Could not create widget. Is the window too small?\n");
1823 }
1824 else
1825 {
1826 RETVAL = scaleWidget;
1827 }
1828 }
1829 OUTPUT:
1830 RETVAL
1831
1832 int
1833 Activate(object,...)
1834 CDKSCALE * object
1835 CODE:
1836 {
1837 chtype * Keys;
1838 int arrayLen;
1839 int value;
1840
1841 if (items > 1)
1842 {
1843 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
1844 value = activateCDKScale (object, Keys);
1845 free (Keys);
1846 }
1847 else
1848 {
1849 value = activateCDKScale (object, NULL);
1850 }
1851
1852 if (object->exitType == vESCAPE_HIT ||
1853 object->exitType == vEARLY_EXIT)
1854 {
1855 XSRETURN_UNDEF;
1856 }
1857 RETVAL = value;
1858 }
1859 OUTPUT:
1860 RETVAL
1861
1862 int
1863 Inject(object,key)
1864 CDKSCALE * object
1865 chtype key = sv2chtype ($arg);
1866 CODE:
1867 {
1868 int value = injectCDKScale (object,key);
1869 if (object->exitType == vESCAPE_HIT ||
1870 object->exitType == vEARLY_EXIT)
1871 {
1872 XSRETURN_UNDEF;
1873 }
1874 RETVAL = value;
1875 }
1876 OUTPUT:
1877 RETVAL
1878
1879 void
1880 Bind(object,key,functionRef)
1881 CDKSCALE * object
1882 chtype key = sv2chtype ($arg);
1883 SV * functionRef
1884 CODE:
1885 {
1886 SV *function = newSVsv (functionRef);
1887 bindCDKObject (vSCALE, object, key, PerlBindCB, function);
1888 }
1889
1890 int
1891 PreProcess(object,functionRef)
1892 CDKSCALE * object
1893 SV * functionRef
1894 CODE:
1895 {
1896 SV *function = newSVsv (functionRef);
1897 setCDKScalePreProcess (object, PerlProcessCB, function);
1898 }
1899 OUTPUT:
1900 RETVAL
1901
1902 int
1903 PostProcess(object,functionRef)
1904 CDKSCALE * object
1905 SV * functionRef
1906 CODE:
1907 {
1908 SV *function = newSVsv (functionRef);
1909 setCDKScalePostProcess (object, PerlProcessCB, function);
1910 }
1911 OUTPUT:
1912 RETVAL
1913
1914 void
1915 Draw(object,Box=TRUE)
1916 CDKSCALE * object
1917 int Box = sv2int ($arg);
1918 CODE:
1919 {
1920 drawCDKScale (object,Box);
1921 }
1922
1923 void
1924 Erase(object)
1925 CDKSCALE * object
1926 CODE:
1927 {
1928 eraseCDKScale(object);
1929 }
1930
1931 void
1932 SetValue(object,value)
1933 CDKSCALE * object
1934 int value
1935 CODE:
1936 {
1937 setCDKScaleValue (object,value);
1938 }
1939
1940 void
1941 SetLowHigh(object,low,high)
1942 CDKSCALE * object
1943 int low
1944 int high
1945 CODE:
1946 {
1947 setCDKScaleLowHigh (object,low,high);
1948 }
1949
1950 void
1951 SetBox(object,box=TRUE)
1952 CDKSCALE * object
1953 int box = sv2int ($arg);
1954 CODE:
1955 {
1956 setCDKScaleBox (object,box);
1957 }
1958
1959 void
1960 SetULChar(object,character=ACS_ULCORNER)
1961 CDKSCALE * object
1962 chtype character = sv2chtype ($arg);
1963 CODE:
1964 {
1965 setCDKScaleULChar (object,character);
1966 }
1967
1968 void
1969 SetURChar(object,character=ACS_URCORNER)
1970 CDKSCALE * object
1971 chtype character = sv2chtype ($arg);
1972 CODE:
1973 {
1974 setCDKScaleURChar (object,character);
1975 }
1976
1977 void
1978 SetLLChar(object,character=ACS_LLCORNER)
1979 CDKSCALE * object
1980 chtype character = sv2chtype ($arg);
1981 CODE:
1982 {
1983 setCDKScaleLLChar (object,character);
1984 }
1985
1986 void
1987 SetLRChar(object,character=ACS_LRCORNER)
1988 CDKSCALE * object
1989 chtype character = sv2chtype ($arg);
1990 CODE:
1991 {
1992 setCDKScaleLRChar (object,character);
1993 }
1994
1995 void
1996 SetVerticalChar(object,character=ACS_VLINE)
1997 CDKSCALE * object
1998 chtype character = sv2chtype ($arg);
1999 CODE:
2000 {
2001 setCDKScaleVerticalChar (object,character);
2002 }
2003
2004 void
2005 SetHorizontalChar(object,character=ACS_HLINE)
2006 CDKSCALE * object
2007 chtype character = sv2chtype ($arg);
2008 CODE:
2009 {
2010 setCDKScaleHorizontalChar (object,character);
2011 }
2012
2013 void
2014 SetBoxAttribute(object,character=ACS_HLINE)
2015 CDKSCALE * object
2016 chtype character = sv2chtype ($arg);
2017 CODE:
2018 {
2019 setCDKScaleBoxAttribute (object,character);
2020 }
2021
2022 void
2023 SetBackgroundColor(object,color)
2024 CDKSCALE * object
2025 char * color
2026 CODE:
2027 {
2028 setCDKScaleBackgroundColor (object,color);
2029 }
2030
2031 void
2032 Register(object)
2033 CDKSCALE * object
2034 CODE:
2035 {
2036 registerCDKObject (GCDKSCREEN, vSCALE, object);
2037 }
2038
2039 void
2040 Unregister(object)
2041 CDKSCALE * object
2042 CODE:
2043 {
2044 unregisterCDKObject (vSCALE, object);
2045 }
2046
2047 void
2048 Raise(object)
2049 CDKSCALE * object
2050 CODE:
2051 {
2052 raiseCDKObject (vSCALE, object);
2053 }
2054
2055 void
2056 Lower(object)
2057 CDKSCALE * object
2058 CODE:
2059 {
2060 lowerCDKObject (vSCALE, object);
2061 }
2062
2063 WINDOW *
2064 GetWindow(object)
2065 CDKSCALE * object
2066 CODE:
2067 {
2068 RETVAL = object->win;
2069 }
2070 OUTPUT:
2071 RETVAL
2072
2073 MODULE = Cdk PACKAGE = Cdk::Histogram
2074
2075 CDKHISTOGRAM *
2076 New(title,height,width,orient=HORIZONTAL,xPos=CENTER,yPos=CENTER,Box=TRUE,shadow=FALSE)
2077 SV * title
2078 int height
2079 int width
2080 int orient = sv2int ($arg);
2081 int xPos = sv2int ($arg);
2082 int yPos = sv2int ($arg);
2083 int Box = sv2int ($arg);
2084 int shadow = sv2int ($arg);
2085 CODE:
2086 {
2087 CDKHISTOGRAM * histWidget = (CDKHISTOGRAM *)NULL;
2088 char * Title;
2089
2090 checkCdkInit();
2091
2092 MAKE_TITLE (title,Title);
2093
2094 histWidget = newCDKHistogram (GCDKSCREEN,xPos,yPos,height,width,orient,Title,Box,shadow);
2095
2096 free (Title);
2097
2098 /* Check the return type. */
2099 if (histWidget == (CDKHISTOGRAM *)NULL)
2100 {
2101 croak ("Cdk::Histogram Could not create widget. Is the window too small?\n");
2102 }
2103 else
2104 {
2105 RETVAL = histWidget;
2106 }
2107 }
2108 OUTPUT:
2109 RETVAL
2110
2111 void
2112 SetDisplayType(object,value="vPERCENT")
2113 CDKHISTOGRAM * object
2114 char * value
2115 CODE:
2116 {
2117 EHistogramDisplayType displayType = vPERCENT;
2118
2119 /* Set the stats type. */
2120 if (strEQ (value, "PERCENT"))
2121 displayType = vPERCENT;
2122 if (strEQ (value, "FRACTION"))
2123 displayType = vFRACTION;
2124 if (strEQ (value, "REAL"))
2125 displayType = vREAL;
2126 if (strEQ (value, "NONE"))
2127 displayType = vNONE;
2128
2129 setCDKHistogramDisplayType (object,displayType);
2130 }
2131
2132 void
2133 SetValue(object,value,low,high)
2134 CDKHISTOGRAM * object
2135 int value
2136 int low
2137 int high
2138 CODE:
2139 {
2140 setCDKHistogramValue (object,value,low,high);
2141 }
2142
2143 void
2144 SetFillerChar(object,value)
2145 CDKHISTOGRAM * object
2146 chtype value = sv2chtype ($arg);
2147 CODE:
2148 {
2149 setCDKHistogramFillerChar (object,value);
2150 }
2151
2152 void
2153 SetStatsPos(object,value)
2154 CDKHISTOGRAM * object
2155 int value = sv2int ($arg);
2156 CODE:
2157 {
2158 setCDKHistogramStatsPos (object,value);
2159 }
2160
2161 void
2162 SetStatsAttr(object,value)
2163 CDKHISTOGRAM * object
2164 chtype value = sv2chtype ($arg);
2165 CODE:
2166 {
2167 setCDKHistogramStatsAttr (object,value);
2168 }
2169
2170 void
2171 SetBox(object,box=TRUE)
2172 CDKHISTOGRAM * object
2173 int box = sv2int ($arg);
2174 CODE:
2175 {
2176 setCDKHistogramBox (object,box);
2177 }
2178
2179 void
2180 SetULChar(object,character=ACS_ULCORNER)
2181 CDKHISTOGRAM * object
2182 chtype character = sv2chtype ($arg);
2183 CODE:
2184 {
2185 setCDKHistogramULChar (object,character);
2186 }
2187
2188 void
2189 SetURChar(object,character=ACS_URCORNER)
2190 CDKHISTOGRAM * object
2191 chtype character = sv2chtype ($arg);
2192 CODE:
2193 {
2194 setCDKHistogramURChar (object,character);
2195 }
2196
2197 void
2198 SetLLChar(object,character=ACS_LLCORNER)
2199 CDKHISTOGRAM * object
2200 chtype character = sv2chtype ($arg);
2201 CODE:
2202 {
2203 setCDKHistogramLLChar (object,character);
2204 }
2205
2206 void
2207 SetLRChar(object,character=ACS_LRCORNER)
2208 CDKHISTOGRAM * object
2209 chtype character = sv2chtype ($arg);
2210 CODE:
2211 {
2212 setCDKHistogramLRChar (object,character);
2213 }
2214
2215 void
2216 SetVerticalChar(object,character=ACS_VLINE)
2217 CDKHISTOGRAM * object
2218 chtype character = sv2chtype ($arg);
2219 CODE:
2220 {
2221 setCDKHistogramVerticalChar (object,character);
2222 }
2223
2224 void
2225 SetHorizontalChar(object,character=ACS_HLINE)
2226 CDKHISTOGRAM * object
2227 chtype character = sv2chtype ($arg);
2228 CODE:
2229 {
2230 setCDKHistogramHorizontalChar (object,character);
2231 }
2232
2233 void
2234 SetBoxAttribute(object,character=ACS_HLINE)
2235 CDKHISTOGRAM * object
2236 chtype character = sv2chtype ($arg);
2237 CODE:
2238 {
2239 setCDKHistogramBoxAttribute (object,character);
2240 }
2241
2242 void
2243 SetBackgroundColor(object,color)
2244 CDKHISTOGRAM * object
2245 char * color
2246 CODE:
2247 {
2248 setCDKHistogramBackgroundColor (object,color);
2249 }
2250
2251 void
2252 Draw(object,Box=TRUE)
2253 CDKHISTOGRAM * object
2254 int Box = sv2int ($arg);
2255 CODE:
2256 {
2257 drawCDKHistogram (object,Box);
2258 }
2259
2260 void
2261 Erase(object)
2262 CDKHISTOGRAM * object
2263 CODE:
2264 {
2265 eraseCDKHistogram (object);
2266 }
2267
2268 void
2269 Register(object)
2270 CDKHISTOGRAM * object
2271 CODE:
2272 {
2273 registerCDKObject (GCDKSCREEN, vHISTOGRAM, object);
2274 }
2275
2276 void
2277 Unregister(object)
2278 CDKHISTOGRAM * object
2279 CODE:
2280 {
2281 unregisterCDKObject (vHISTOGRAM, object);
2282 }
2283
2284 void
2285 Raise(object)
2286 CDKHISTOGRAM * object
2287 CODE:
2288 {
2289 raiseCDKObject (vHISTOGRAM, object);
2290 }
2291
2292 void
2293 Lower(object)
2294 CDKHISTOGRAM * object
2295 CODE:
2296 {
2297 lowerCDKObject (vHISTOGRAM, object);
2298 }
2299
2300 WINDOW *
2301 GetWindow(object)
2302 CDKHISTOGRAM * object
2303 CODE:
2304 {
2305 RETVAL = object->win;
2306 }
2307 OUTPUT:
2308 RETVAL
2309
2310 MODULE = Cdk PACKAGE = Cdk::Menu
2311
2312 CDKMENU *
2313 New(menulist, menuloc, titleattr=A_REVERSE, subtitleattr=A_REVERSE, menuPos=TOP)
2314 SV * menulist
2315 SV * menuloc
2316 chtype titleattr = sv2chtype ($arg);
2317 chtype subtitleattr = sv2chtype ($arg);
2318 int menuPos = sv2int ($arg);
2319 CODE:
2320 {
2321 char * menuList[MAX_MENU_ITEMS][MAX_SUB_ITEMS];
2322 int subSize[MAX_SUB_ITEMS];
2323 int * menuLoc;
2324 int menulen;
2325 int loclen;
2326
2327 checkCdkInit();
2328
2329 MAKE_MENU_MATRIX(0, menulist, menuList, subSize, menulen);
2330
2331 MAKE_INT_ARRAY (0, menuloc, menuLoc, loclen);
2332 if (menulen != loclen)
2333 {
2334 croak ("Cdk::Menu The menu list and menu location arrays are not the same size.");
2335 }
2336 RETVAL = newCDKMenu (GCDKSCREEN,menuList,menulen,subSize,menuLoc,menuPos,titleattr,subtitleattr);
2337
2338 free (menuLoc);
2339 }
2340 OUTPUT:
2341 RETVAL
2342
2343 int
2344 Activate(object,...)
2345 CDKMENU * object
2346 CODE:
2347 {
2348 chtype * Keys;
2349 int arrayLen;
2350 int value;
2351
2352 if (items > 1)
2353 {
2354 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
2355 value = activateCDKMenu (object, Keys);
2356 free (Keys);
2357 }
2358 else
2359 {
2360 value = activateCDKMenu (object, NULL);
2361 }
2362
2363 if (object->exitType == vEARLY_EXIT ||
2364 object->exitType == vESCAPE_HIT)
2365 {
2366 XSRETURN_UNDEF;
2367 }
2368 RETVAL = value;
2369 }
2370 OUTPUT:
2371 RETVAL
2372
2373 int
2374 Inject(object,key)
2375 CDKMENU * object
2376 chtype key = sv2chtype ($arg);
2377 CODE:
2378 {
2379 int selection = injectCDKMenu (object,key);
2380 if (selection == -1)
2381 {
2382 XSRETURN_UNDEF;
2383 }
2384 RETVAL = selection;
2385 }
2386 OUTPUT:
2387 RETVAL
2388
2389 void
2390 Bind(object,key,functionRef)
2391 CDKMENU * object
2392 chtype key = sv2chtype ($arg);
2393 SV * functionRef
2394 CODE:
2395 {
2396 SV *function = newSVsv (functionRef);
2397 bindCDKObject (vMENU, object, key, PerlBindCB, function);
2398 }
2399
2400 int
2401 PreProcess(object,functionRef)
2402 CDKMENU * object
2403 SV * functionRef
2404 CODE:
2405 {
2406 SV *function = newSVsv (functionRef);
2407 setCDKMenuPreProcess (object, PerlProcessCB, function);
2408 }
2409 OUTPUT:
2410 RETVAL
2411
2412 int
2413 PostProcess(object,functionRef)
2414 CDKMENU * object
2415 SV * functionRef
2416 CODE:
2417 {
2418 SV *function = newSVsv (functionRef);
2419 setCDKMenuPostProcess (object, PerlProcessCB, function);
2420 }
2421 OUTPUT:
2422 RETVAL
2423
2424 void
2425 Draw(object)
2426 CDKMENU * object
2427 int Box = sv2int ($arg);
2428 CODE:
2429 {
2430 drawCDKMenu (object, Box);
2431 }
2432
2433 void
2434 Erase(object)
2435 CDKMENU * object
2436 CODE:
2437 {
2438 eraseCDKMenu (object);
2439 }
2440
2441 void
2442 SetCurrentItem(object,menuitem,submenuitem)
2443 CDKMENU * object
2444 int menuitem
2445 int submenuitem
2446 CODE:
2447 {
2448 setCDKMenuCurrentItem(object,menuitem,submenuitem);
2449 }
2450
2451 void
2452 SetTitleHighlight(object,value)
2453 CDKMENU * object
2454 chtype value
2455 CODE:
2456 {
2457 setCDKMenuTitleHighlight (object,value);
2458 }
2459
2460 void
2461 SetSubTitleHighlight(object,value)
2462 CDKMENU * object
2463 chtype value
2464 CODE:
2465 {
2466 setCDKMenuSubTitleHighlight (object,value);
2467 }
2468
2469 void
2470 SetBackgroundColor(object,value)
2471 CDKMENU * object
2472 char * value
2473 CODE:
2474 {
2475 setCDKMenuBackgroundColor (object,value);
2476 }
2477
2478 void
2479 Register(object)
2480 CDKMENU * object
2481 CODE:
2482 {
2483 registerCDKObject (GCDKSCREEN, vMENU, object);
2484 }
2485
2486 void
2487 Unregister(object)
2488 CDKMENU * object
2489 CODE:
2490 {
2491 unregisterCDKObject (vMENU, object);
2492 }
2493
2494 void
2495 Raise(object)
2496 CDKMENU * object
2497 CODE:
2498 {
2499 raiseCDKObject (vMENU, object);
2500 }
2501
2502 void
2503 Lower(object)
2504 CDKMENU * object
2505 CODE:
2506 {
2507 lowerCDKObject (vMENU, object);
2508 }
2509
2510 MODULE = Cdk PACKAGE = Cdk::Entry
2511
2512 CDKENTRY *
2513 New(title,label,min,max,fieldWidth,filler=".",disptype=vMIXED,xPos=CENTER,yPos=CENTER,fieldattr=A_NORMAL,Box=TRUE,shadow=FALSE)
2514 SV * title
2515 char * label
2516 int min
2517 int max
2518 int fieldWidth
2519 chtype filler = sv2chtype ($arg);
2520 EDisplayType disptype = sv2dtype ($arg);
2521 int xPos = sv2int ($arg);
2522 int yPos = sv2int ($arg);
2523 chtype fieldattr = sv2chtype ($arg);
2524 int Box = sv2int ($arg);
2525 int shadow = sv2int ($arg);
2526 CODE:
2527 {
2528 CDKENTRY * entryWidget = (CDKENTRY *)NULL;
2529 char * Title;
2530
2531 checkCdkInit();
2532
2533 MAKE_TITLE (title,Title);
2534
2535 entryWidget = newCDKEntry (GCDKSCREEN,xPos,yPos,
2536 Title,label,
2537 fieldattr,filler,disptype,
2538 fieldWidth,min,max,
2539 Box,shadow);
2540 free (Title);
2541
2542 /* Check the return type. */
2543 if (entryWidget == (CDKENTRY *)NULL)
2544 {
2545 croak ("Cdk::Entry Could not create widget. Is the window too small?\n");
2546 }
2547 else
2548 {
2549 RETVAL = entryWidget;
2550 }
2551 }
2552 OUTPUT:
2553 RETVAL
2554
2555 char *
2556 Activate(object,...)
2557 CDKENTRY * object
2558 CODE:
2559 {
2560 chtype * Keys;
2561 int arrayLen;
2562 char * value;
2563
2564 if (items > 1)
2565 {
2566 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
2567 value = activateCDKEntry (object, Keys);
2568 free (Keys);
2569 }
2570 else
2571 {
2572 value = activateCDKEntry (object, NULL);
2573 }
2574
2575 if (object->exitType != vNORMAL)
2576 {
2577 XSRETURN_UNDEF;
2578 }
2579 RETVAL = value;
2580 }
2581 OUTPUT:
2582 RETVAL
2583
2584 char *
2585 Inject(object,key)
2586 CDKENTRY * object
2587 chtype key = sv2chtype ($arg);
2588 CODE:
2589 {
2590 char *value = injectCDKEntry (object,key);
2591 if (object->exitType == vESCAPE_HIT ||
2592 object->exitType == vEARLY_EXIT)
2593 {
2594 XSRETURN_UNDEF;
2595 }
2596 RETVAL = value;
2597 }
2598 OUTPUT:
2599 RETVAL
2600
2601 void
2602 Bind(object,key,functionRef)
2603 CDKENTRY * object
2604 chtype key = sv2chtype ($arg);
2605 SV * functionRef
2606 CODE:
2607 {
2608 SV *function = newSVsv(functionRef);
2609 bindCDKObject (vENTRY, object, key, PerlBindCB, function);
2610 }
2611
2612 int
2613 PreProcess(object,functionRef)
2614 CDKENTRY * object
2615 SV * functionRef
2616 CODE:
2617 {
2618 SV *function = newSVsv (functionRef);
2619 setCDKEntryPreProcess (object, PerlProcessCB, function);
2620 }
2621 OUTPUT:
2622 RETVAL
2623
2624 int
2625 PostProcess(object,functionRef)
2626 CDKENTRY * object
2627 SV * functionRef
2628 CODE:
2629 {
2630 SV *function = newSVsv (functionRef);
2631 setCDKEntryPostProcess (object, PerlProcessCB, function);
2632 }
2633 OUTPUT:
2634 RETVAL
2635
2636 void
2637 Draw(object,Box=TRUE)
2638 CDKENTRY * object
2639 int Box = sv2int ($arg);
2640 CODE:
2641 {
2642 drawCDKEntry (object, Box);
2643 }
2644
2645 void
2646 Erase(object)
2647 CDKENTRY * object
2648 CODE:
2649 {
2650 eraseCDKEntry (object);
2651 }
2652
2653 void
2654 SetValue(object,value)
2655 CDKENTRY * object
2656 char * value
2657 CODE:
2658 {
2659 setCDKEntryValue (object, value);
2660 }
2661
2662 void
2663 SetMin(object,value)
2664 CDKENTRY * object
2665 int value
2666 CODE:
2667 {
2668 setCDKEntryMin (object, value);
2669 }
2670
2671 void
2672 SetMax(object,value)
2673 CDKENTRY * object
2674 int value
2675 CODE:
2676 {
2677 setCDKEntryMax (object, value);
2678 }
2679
2680 void
2681 SetFillerChar(object,value)
2682 CDKENTRY * object
2683 chtype value = sv2chtype ($arg);
2684 CODE:
2685 {
2686 setCDKEntryFillerChar (object, value);
2687 }
2688
2689 void
2690 SetHiddenChar(object,value)
2691 CDKENTRY * object
2692 chtype value = sv2chtype ($arg);
2693 CODE:
2694 {
2695 setCDKEntryHiddenChar (object, value);
2696 }
2697
2698 void
2699 SetBox(object,box=TRUE)
2700 CDKENTRY * object
2701 int box = sv2int ($arg);
2702 CODE:
2703 {
2704 setCDKEntryBox (object,box);
2705 }
2706
2707 void
2708 SetULChar(object,character=ACS_ULCORNER)
2709 CDKENTRY * object
2710 chtype character = sv2chtype ($arg);
2711 CODE:
2712 {
2713 setCDKEntryULChar (object,character);
2714 }
2715
2716 void
2717 SetURChar(object,character=ACS_URCORNER)
2718 CDKENTRY * object
2719 chtype character = sv2chtype ($arg);
2720 CODE:
2721 {
2722 setCDKEntryURChar (object,character);
2723 }
2724
2725 void
2726 SetLLChar(object,character=ACS_LLCORNER)
2727 CDKENTRY * object
2728 chtype character = sv2chtype ($arg);
2729 CODE:
2730 {
2731 setCDKEntryLLChar (object,character);
2732 }
2733
2734 void
2735 SetLRChar(object,character=ACS_LRCORNER)
2736 CDKENTRY * object
2737 chtype character = sv2chtype ($arg);
2738 CODE:
2739 {
2740 setCDKEntryLRChar (object,character);
2741 }
2742
2743 void
2744 SetVerticalChar(object,character=ACS_VLINE)
2745 CDKENTRY * object
2746 chtype character = sv2chtype ($arg);
2747 CODE:
2748 {
2749 setCDKEntryVerticalChar (object,character);
2750 }
2751
2752 void
2753 SetHorizontalChar(object,character=ACS_HLINE)
2754 CDKENTRY * object
2755 chtype character = sv2chtype ($arg);
2756 CODE:
2757 {
2758 setCDKEntryHorizontalChar (object,character);
2759 }
2760
2761 void
2762 SetBoxAttribute(object,character=ACS_HLINE)
2763 CDKENTRY * object
2764 chtype character = sv2chtype ($arg);
2765 CODE:
2766 {
2767 setCDKEntryBoxAttribute (object,character);
2768 }
2769
2770 void
2771 SetBackgroundColor(object,color)
2772 CDKENTRY * object
2773 char * color
2774 CODE:
2775 {
2776 setCDKEntryBackgroundColor (object,color);
2777 }
2778
2779 char *
2780 Get(object)
2781 CDKENTRY * object
2782 CODE:
2783 {
2784 RETVAL = getCDKEntryValue (object);
2785 }
2786 OUTPUT:
2787 RETVAL
2788
2789 void
2790 Clean(object)
2791 CDKENTRY * object
2792 CODE:
2793 {
2794 cleanCDKEntry (object);
2795 }
2796
2797 void
2798 Register(object)
2799 CDKENTRY * object
2800 CODE:
2801 {
2802 registerCDKObject (GCDKSCREEN, vENTRY, object);
2803 }
2804
2805 void
2806 Unregister(object)
2807 CDKENTRY * object
2808 CODE:
2809 {
2810 unregisterCDKObject (vENTRY, object);
2811 }
2812
2813 void
2814 Raise(object)
2815 CDKENTRY * object
2816 CODE:
2817 {
2818 raiseCDKObject (vENTRY, object);
2819 }
2820
2821 void
2822 Lower(object)
2823 CDKENTRY * object
2824 CODE:
2825 {
2826 lowerCDKObject (vENTRY, object);
2827 }
2828
2829 WINDOW *
2830 GetWindow(object)
2831 CDKENTRY * object
2832 CODE:
2833 {
2834 RETVAL = object->win;
2835 }
2836 OUTPUT:
2837 RETVAL
2838
2839 MODULE = Cdk PACKAGE = Cdk::Mentry
2840
2841 CDKMENTRY *
2842 New(title,label,min,physical,logical,fieldWidth,disptype=vMIXED,filler=".",xPos=CENTER,yPos=CENTER,fieldattr=A_NORMAL,Box=TRUE,shadow=FALSE)
2843 SV * title
2844 char * label
2845 int min
2846 int physical
2847 int logical
2848 int fieldWidth
2849 EDisplayType disptype = sv2dtype ($arg);
2850 chtype filler = sv2chtype ($arg);
2851 int xPos = sv2int ($arg);
2852 int yPos = sv2int ($arg);
2853 chtype fieldattr = sv2chtype ($arg);
2854 int Box = sv2int ($arg);
2855 int shadow = sv2int ($arg);
2856 CODE:
2857 {
2858 CDKMENTRY * mentryWidget = (CDKMENTRY *)NULL;
2859 char * Title;
2860
2861 checkCdkInit();
2862
2863 MAKE_TITLE (title,Title);
2864
2865 mentryWidget = newCDKMentry (GCDKSCREEN,xPos,yPos,
2866 Title,label,
2867 fieldattr,filler,
2868 disptype,fieldWidth,
2869 physical,logical,min,
2870 Box,shadow);
2871 free (Title);
2872
2873 /* Check the return type. */
2874 if (mentryWidget == (CDKMENTRY *)NULL)
2875 {
2876 croak ("Cdk::Mentry Could not create widget. Is the window too small?\n");
2877 }
2878 else
2879 {
2880 RETVAL = mentryWidget;
2881 }
2882 }
2883 OUTPUT:
2884 RETVAL
2885
2886 char *
2887 Activate(object,...)
2888 CDKMENTRY * object
2889 CODE:
2890 {
2891 chtype * Keys;
2892 int arrayLen;
2893 char * value;
2894
2895 if (items > 1)
2896 {
2897 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
2898 value = activateCDKMentry (object, Keys);
2899 free (Keys);
2900 }
2901 else
2902 {
2903 value = activateCDKMentry (object, NULL);
2904 }
2905
2906 if (object->exitType == vEARLY_EXIT ||
2907 object->exitType == vESCAPE_HIT)
2908 {
2909 XSRETURN_UNDEF;
2910 }
2911 RETVAL = value;
2912 }
2913 OUTPUT:
2914 RETVAL
2915
2916 char *
2917 Inject(object,key)
2918 CDKMENTRY * object
2919 chtype key = sv2chtype ($arg);
2920 CODE:
2921 {
2922 char *value = injectCDKMentry (object,key);
2923 if (object->exitType == vESCAPE_HIT ||
2924 object->exitType == vEARLY_EXIT)
2925 {
2926 XSRETURN_UNDEF;
2927 }
2928 RETVAL = value;
2929 }
2930 OUTPUT:
2931 RETVAL
2932
2933 void
2934 Bind(object,key,functionRef)
2935 CDKMENTRY * object
2936 chtype key = sv2chtype ($arg);
2937 SV * functionRef
2938 CODE:
2939 {
2940 SV *function = newSVsv (functionRef);
2941 bindCDKObject (vMENTRY, object, key, PerlBindCB, function);
2942 }
2943
2944 int
2945 PreProcess(object,functionRef)
2946 CDKMENTRY * object
2947 SV * functionRef
2948 CODE:
2949 {
2950 SV *function = newSVsv (functionRef);
2951 setCDKMentryPreProcess (object, PerlProcessCB, function);
2952 }
2953 OUTPUT:
2954 RETVAL
2955
2956 int
2957 PostProcess(object,functionRef)
2958 CDKMENTRY * object
2959 SV * functionRef
2960 CODE:
2961 {
2962 SV *function = newSVsv (functionRef);
2963 setCDKMentryPostProcess (object, PerlProcessCB, function);
2964 }
2965 OUTPUT:
2966 RETVAL
2967
2968 void
2969 Draw(object,Box=TRUE)
2970 CDKMENTRY * object
2971 int Box = sv2int ($arg);
2972 CODE:
2973 {
2974 drawCDKMentry (object,Box);
2975 }
2976
2977 void
2978 Erase(object)
2979 CDKMENTRY * object
2980 CODE:
2981 {
2982 eraseCDKMentry (object);
2983 }
2984
2985 void
2986 SetValue(object,value)
2987 CDKMENTRY * object
2988 char * value
2989 CODE:
2990 {
2991 setCDKMentryValue (object,value);
2992 }
2993
2994 void
2995 SetMin(object,value)
2996 CDKMENTRY * object
2997 int value
2998 CODE:
2999 {
3000 int min = value;
3001
3002 if (value < 0)
3003 {
3004 min = object->min;
3005 }
3006
3007 setCDKMentryMin (object,min);
3008 }
3009
3010 void
3011 SetFillerChar(object,value)
3012 CDKMENTRY * object
3013 chtype value = sv2chtype ($arg);
3014 CODE:
3015 {
3016 setCDKMentryFillerChar (object,value);
3017 }
3018
3019 void
3020 SetBox(object,box=TRUE)
3021 CDKMENTRY * object
3022 int box = sv2int ($arg);
3023 CODE:
3024 {
3025 setCDKMentryBox (object,box);
3026 }
3027
3028 void
3029 SetULChar(object,character=ACS_ULCORNER)
3030 CDKMENTRY * object
3031 chtype character = sv2chtype ($arg);
3032 CODE:
3033 {
3034 setCDKMentryULChar (object,character);
3035 }
3036
3037 void
3038 SetURChar(object,character=ACS_URCORNER)
3039 CDKMENTRY * object
3040 chtype character = sv2chtype ($arg);
3041 CODE:
3042 {
3043 setCDKMentryURChar (object,character);
3044 }
3045
3046 void
3047 SetLLChar(object,character=ACS_LLCORNER)
3048 CDKMENTRY * object
3049 chtype character = sv2chtype ($arg);
3050 CODE:
3051 {
3052 setCDKMentryLLChar (object,character);
3053 }
3054
3055 void
3056 SetLRChar(object,character=ACS_LRCORNER)
3057 CDKMENTRY * object
3058 chtype character = sv2chtype ($arg);
3059 CODE:
3060 {
3061 setCDKMentryLRChar (object,character);
3062 }
3063
3064 void
3065 SetVerticalChar(object,character=ACS_VLINE)
3066 CDKMENTRY * object
3067 chtype character = sv2chtype ($arg);
3068 CODE:
3069 {
3070 setCDKMentryVerticalChar (object,character);
3071 }
3072
3073 void
3074 SetHorizontalChar(object,character=ACS_HLINE)
3075 CDKMENTRY * object
3076 chtype character = sv2chtype ($arg);
3077 CODE:
3078 {
3079 setCDKMentryHorizontalChar (object,character);
3080 }
3081
3082 void
3083 SetBoxAttribute(object,character=ACS_HLINE)
3084 CDKMENTRY * object
3085 chtype character = sv2chtype ($arg);
3086 CODE:
3087 {
3088 setCDKMentryBoxAttribute (object,character);
3089 }
3090
3091 void
3092 SetBackgroundColor(object,color)
3093 CDKMENTRY * object
3094 char * color
3095 CODE:
3096 {
3097 setCDKMentryBackgroundColor (object,color);
3098 }
3099
3100 char *
3101 Get(object)
3102 CDKMENTRY * object
3103 CODE:
3104 {
3105 RETVAL = object->info;
3106 }
3107 OUTPUT:
3108 RETVAL
3109
3110 void
3111 Clean(object)
3112 CDKMENTRY * object
3113 CODE:
3114 {
3115 cleanCDKMentry (object);
3116 }
3117
3118 void
3119 Register(object)
3120 CDKMENTRY * object
3121 CODE:
3122 {
3123 registerCDKObject (GCDKSCREEN, vMENTRY, object);
3124 }
3125
3126 void
3127 Unregister(object)
3128 CDKMENTRY * object
3129 CODE:
3130 {
3131 unregisterCDKObject (vMENTRY, object);
3132 }
3133
3134 void
3135 Raise(object)
3136 CDKMENTRY * object
3137 CODE:
3138 {
3139 raiseCDKObject (vMENTRY, object);
3140 }
3141
3142 void
3143 Lower(object)
3144 CDKMENTRY * object
3145 CODE:
3146 {
3147 lowerCDKObject (vMENTRY, object);
3148 }
3149
3150 WINDOW *
3151 GetWindow(object)
3152 CDKMENTRY * object
3153 CODE:
3154 {
3155 RETVAL = object->win;
3156 }
3157 OUTPUT:
3158 RETVAL
3159
3160 MODULE = Cdk PACKAGE = Cdk::Matrix
3161
3162 CDKMATRIX *
3163 New(title,rowtitles,coltitles,colwidths,coltypes,vrows,vcols,xPos=CENTER,yPos=CENTER,rowspace=1,colspace=1,filler=".",dominant=NONE,boxMatrix=FALSE,boxCell=TRUE,shadow=FALSE)
3164 SV * title
3165 SV * rowtitles
3166 SV * coltitles
3167 SV * colwidths
3168 SV * coltypes
3169 int vrows
3170 int vcols
3171 int xPos = sv2int ($arg);
3172 int yPos = sv2int ($arg);
3173 int rowspace
3174 int colspace
3175 chtype filler = sv2chtype ($arg);
3176 int dominant = sv2int ($arg);
3177 int boxMatrix = sv2int ($arg);
3178 int boxCell = sv2int ($arg);
3179 int shadow = sv2int ($arg);
3180 CODE:
3181 {
3182 CDKMATRIX * matrixWidget = (CDKMATRIX *)NULL;
3183 char ** colTitles;
3184 char ** rowTitles;
3185 char * Title;
3186 int * colWidths;
3187 int * colTypes;
3188 int rows, cols, widths, dtype;
3189
3190 checkCdkInit();
3191
3192 /* Make the arrays. */
3193 MAKE_CHAR_ARRAY (1, rowtitles, rowTitles, rows);
3194 MAKE_CHAR_ARRAY (1, coltitles, colTitles, cols);
3195 MAKE_INT_ARRAY (1, colwidths, colWidths, widths);
3196 MAKE_DTYPE_ARRAY (1, coltypes, colTypes, dtype);
3197 MAKE_TITLE (title,Title);
3198
3199 /* Now check them... */
3200 if (cols != widths)
3201 {
3202 croak ("Cdk::Matrix The col title array size is not the same as the widths array size.");
3203 }
3204 if (cols != dtype)
3205 {
3206 croak ("Cdk::Matrix The col title array size is not the same as the column value array size.");
3207 }
3208 if (vrows > rows || vcols > cols)
3209 {
3210 croak ("Cdk::Matrix The virtual matrix size is larger then the physical size.");
3211 }
3212
3213 /* OK, everything is ok. Lets make the matrix. */
3214 matrixWidget = newCDKMatrix (GCDKSCREEN,
3215 xPos, yPos,
3216 rows, cols,
3217 vrows, vcols,
3218 Title, rowTitles,
3219 colTitles,
3220 colWidths, colTypes,
3221 rowspace, colspace, filler,
3222 dominant,
3223 boxMatrix, boxCell, shadow);
3224
3225 /* Check the return type. */
3226 if (matrixWidget == (CDKMATRIX *)NULL)
3227 {
3228 croak ("Cdk::Matrix Could not create widget. Is the window too small?\n");
3229 }
3230 else
3231 {
3232 RETVAL = matrixWidget;
3233 }
3234 free (colTitles);
3235 free (rowTitles);
3236 free (colWidths);
3237 free (colTypes);
3238 free (Title);
3239 }
3240 OUTPUT:
3241 RETVAL
3242
3243 void
3244 Activate(object,...)
3245 CDKMATRIX * object
3246 PPCODE:
3247 {
3248 AV * cellInfo = newAV();
3249 chtype * Keys;
3250 int x, y, value, arrayLen;
3251
3252 if (items > 1)
3253 {
3254 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
3255 value = activateCDKMatrix (object, Keys);
3256 free (Keys);
3257 }
3258 else
3259 {
3260 value = activateCDKMatrix (object, NULL);
3261 }
3262
3263 /* Check the exit status. */
3264 if (object->exitType == vESCAPE_HIT ||
3265 object->exitType == vEARLY_EXIT)
3266 {
3267 XSRETURN_UNDEF;
3268 }
3269
3270 /* Take the info from the matrix and make an array out of it. */
3271 for (x=1; x <= object->rows; x++)
3272 {
3273 AV * av = newAV();
3274
3275 for (y=1; y <= object->cols; y++)
3276 {
3277 char *data = object->info[CELL_INDEX(object,x,y)];
3278 av_push (av, newSVpv (data, strlen (data)));
3279 }
3280
3281 av_push (cellInfo, newRV((SV *)av));
3282 }
3283
3284 /* Push the values on the return stack. */
3285 XPUSHs (sv_2mortal(newSViv(object->rows)));
3286 XPUSHs (sv_2mortal(newSViv(object->cols)));
3287 XPUSHs (sv_2mortal(newRV((SV*)cellInfo)));
3288 }
3289
3290 int
3291 Inject(object,key)
3292 CDKMATRIX * object
3293 chtype key = sv2chtype ($arg);
3294 CODE:
3295 {
3296 int selection = injectCDKMatrix (object,key);
3297 if (selection == -1)
3298 {
3299 XSRETURN_UNDEF;
3300 }
3301 RETVAL = selection;
3302 }
3303 OUTPUT:
3304 RETVAL
3305
3306 void
3307 Bind(object,key,functionRef)
3308 CDKMATRIX * object
3309 chtype key = sv2chtype ($arg);
3310 SV * functionRef
3311 CODE:
3312 {
3313 SV *function = newSVsv (functionRef);
3314 bindCDKObject (vMATRIX, object, key, PerlBindCB, function);
3315 }
3316
3317 int
3318 PreProcess(object,functionRef)
3319 CDKMATRIX * object
3320 SV * functionRef
3321 CODE:
3322 {
3323 SV *function = newSVsv (functionRef);
3324 setCDKMatrixPreProcess (object, PerlProcessCB, function);
3325 }
3326 OUTPUT:
3327 RETVAL
3328
3329 int
3330 PostProcess(object,functionRef)
3331 CDKMATRIX * object
3332 SV * functionRef
3333 CODE:
3334 {
3335 SV *function = newSVsv (functionRef);
3336 setCDKMatrixPostProcess (object, PerlProcessCB, function);
3337 }
3338 OUTPUT:
3339 RETVAL
3340
3341 void
3342 GetDim(object)
3343 CDKMATRIX * object
3344 PPCODE:
3345 {
3346 XPUSHs (sv_2mortal(newSViv(object->rows)));
3347 XPUSHs (sv_2mortal(newSViv(object->cols)));
3348 }
3349
3350 void
3351 Draw(object,Box=TRUE)
3352 CDKMATRIX * object
3353 int Box = sv2int ($arg);
3354 CODE:
3355 {
3356 drawCDKMatrix (object,Box);
3357 }
3358
3359 void
3360 Erase(object)
3361 CDKMATRIX * object
3362 CODE:
3363 {
3364 eraseCDKMatrix (object);
3365 }
3366
3367 void
3368 Set(object,info)
3369 CDKMATRIX * object
3370 SV * info
3371 CODE:
3372 {
3373 char ** Info;
3374 int * subSize;
3375 int matrixlen;
3376 int width = 1;
3377
3378 AV *array = (AV *)SvRV(info);
3379 int x, y;
3380
3381 matrixlen = av_len (array) + 1;
3382 subSize = (int *)calloc(matrixlen + 2, sizeof(int));
3383
3384 if (subSize != 0)
3385 {
3386 for (x = 1; x <= matrixlen; x++)
3387 {
3388 SV *name = *av_fetch(array, x - 1, FALSE);
3389 AV *subArray = (AV *)SvRV(name);
3390 int subLen = av_len (subArray) + 1;
3391 width = MAXIMUM(width, subLen);
3392 }
3393 Info = (char **)calloc((width + 1) * (matrixlen + 1), sizeof(char *));
3394
3395 if (Info != 0)
3396 {
3397 for (x = 1; x <= matrixlen; x++)
3398 {
3399 SV *name = *av_fetch(array, x - 1, FALSE);
3400 AV *subArray = (AV *)SvRV(name);
3401 int subLen = av_len (subArray) + 1;
3402 subSize[x] = subLen;
3403
3404 for (y=1; y <= subLen; y++)
3405 {
3406 SV *sv = *av_fetch(subArray, y - 1, FALSE);
3407 Info[x * (matrixlen + 1) + y] = copyChar((char *)SvPV(sv,PL_na));
3408 }
3409 }
3410
3411 setCDKMatrixCells (object, Info, matrixlen, width, subSize);
3412
3413 free (Info);
3414 }
3415 free (subSize);
3416 }
3417 }
3418
3419 void
3420 SetCell(object,row,col,value)
3421 CDKMATRIX * object
3422 int row
3423 int col
3424 char * value
3425 CODE:
3426 {
3427 setCDKMatrixCell (object,row,col,value);
3428 }
3429
3430 char *
3431 GetCell(object,row,col)
3432 CDKMATRIX * object
3433 int row
3434 int col
3435 CODE:
3436 {
3437 RETVAL = getCDKMatrixCell (object,row,col);
3438 }
3439 OUTPUT:
3440 RETVAL
3441
3442 int
3443 GetRow(object)
3444 CDKMATRIX * object
3445 CODE:
3446 {
3447 RETVAL = getCDKMatrixRow (object);
3448 }
3449 OUTPUT:
3450 RETVAL
3451
3452 int
3453 GetCol(object)
3454 CDKMATRIX * object
3455 CODE:
3456 {
3457 RETVAL = getCDKMatrixCol (object);
3458 }
3459 OUTPUT:
3460 RETVAL
3461
3462 void
3463 SetBoxAttribute(object,box=TRUE)
3464 CDKMATRIX * object
3465 int box = sv2int ($arg);
3466 CODE:
3467 {
3468 setCDKMatrixBoxAttribute (object,box);
3469 }
3470
3471 void
3472 SetULChar(object,character=ACS_ULCORNER)
3473 CDKMATRIX * object
3474 chtype character = sv2chtype ($arg);
3475 CODE:
3476 {
3477 setCDKMatrixULChar (object,character);
3478 }
3479
3480 void
3481 SetURChar(object,character=ACS_URCORNER)
3482 CDKMATRIX * object
3483 chtype character = sv2chtype ($arg);
3484 CODE:
3485 {
3486 setCDKMatrixURChar (object,character);
3487 }
3488
3489 void
3490 SetLLChar(object,character=ACS_LLCORNER)
3491 CDKMATRIX * object
3492 chtype character = sv2chtype ($arg);
3493 CODE:
3494 {
3495 setCDKMatrixLLChar (object,character);
3496 }
3497
3498 void
3499 SetLRChar(object,character=ACS_LRCORNER)
3500 CDKMATRIX * object
3501 chtype character = sv2chtype ($arg);
3502 CODE:
3503 {
3504 setCDKMatrixLRChar (object,character);
3505 }
3506
3507 void
3508 SetVerticalChar(object,character=ACS_VLINE)
3509 CDKMATRIX * object
3510 chtype character = sv2chtype ($arg);
3511 CODE:
3512 {
3513 setCDKMatrixVerticalChar (object,character);
3514 }
3515
3516 void
3517 SetHorizontalChar(object,character=ACS_HLINE)
3518 CDKMATRIX * object
3519 chtype character = sv2chtype ($arg);
3520 CODE:
3521 {
3522 setCDKMatrixHorizontalChar (object,character);
3523 }
3524
3525 void
3526 SetBackgroundColor(object,color)
3527 CDKMATRIX * object
3528 char * color
3529 CODE:
3530 {
3531 setCDKMatrixBackgroundColor (object,color);
3532 }
3533
3534 void
3535 Clean(object)
3536 CDKMATRIX * object
3537 CODE:
3538 {
3539 cleanCDKMatrix (object);
3540 }
3541
3542 void
3543 Raise(object)
3544 CDKMATRIX * object
3545 CODE:
3546 {
3547 raiseCDKObject (vMATRIX, object);
3548 }
3549
3550 void
3551 Lower(object)
3552 CDKMATRIX * object
3553 CODE:
3554 {
3555 lowerCDKObject (vMATRIX, object);
3556 }
3557
3558 WINDOW *
3559 GetWindow(object)
3560 CDKMATRIX * object
3561 CODE:
3562 {
3563 RETVAL = object->win;
3564 }
3565 OUTPUT:
3566 RETVAL
3567
3568 void
3569 Register(object)
3570 CDKMATRIX * object
3571 CODE:
3572 {
3573 registerCDKObject (GCDKSCREEN, vMATRIX, object);
3574 }
3575
3576 void
3577 Unregister(object)
3578 CDKMATRIX * object
3579 CODE:
3580 {
3581 unregisterCDKObject (vMATRIX, object);
3582 }
3583
3584 MODULE = Cdk PACKAGE = Cdk::Marquee
3585
3586 CDKMARQUEE *
3587 New(width,xPos=CENTER,yPos=CENTER,box=TRUE,shadow=FALSE)
3588 int width
3589 int xPos = sv2int ($arg);
3590 int yPos = sv2int ($arg);
3591 int box = sv2int ($arg);
3592 int shadow = sv2int ($arg);
3593 CODE:
3594 {
3595 CDKMARQUEE * marqueeWidget = (CDKMARQUEE *)NULL;
3596
3597 checkCdkInit();
3598
3599 marqueeWidget = newCDKMarquee (GCDKSCREEN,xPos,yPos,width,box,shadow);
3600
3601 /* Check the return type. */
3602 if (marqueeWidget == (CDKMARQUEE *)NULL)
3603 {
3604 croak ("Cdk::Marquee Could not create widget. Is the window too small?\n");
3605 }
3606 else
3607 {
3608 RETVAL = marqueeWidget;
3609 }
3610 }
3611 OUTPUT:
3612 RETVAL
3613
3614 int
3615 Activate(object,message,delay,repeat,Box=TRUE)
3616 CDKMARQUEE * object
3617 char * message
3618 int delay
3619 int repeat
3620 int Box = sv2int ($arg);
3621 CODE:
3622 {
3623 RETVAL = activateCDKMarquee (object,message,delay,repeat,Box);
3624 }
3625 OUTPUT:
3626 RETVAL
3627
3628 void
3629 Deactivate(object)
3630 CDKMARQUEE * object
3631 CODE:
3632 {
3633 deactivateCDKMarquee (object);
3634 }
3635
3636 void
3637 SetBoxAttribute(object,box=TRUE)
3638 CDKMARQUEE * object
3639 int box = sv2int ($arg);
3640 CODE:
3641 {
3642 setCDKMarqueeBoxAttribute (object,box);
3643 }
3644
3645 void
3646 SetULChar(object,character=ACS_ULCORNER)
3647 CDKMARQUEE * object
3648 chtype character = sv2chtype ($arg);
3649 CODE:
3650 {
3651 setCDKMarqueeULChar (object,character);
3652 }
3653
3654 void
3655 SetURChar(object,character=ACS_URCORNER)
3656 CDKMARQUEE * object
3657 chtype character = sv2chtype ($arg);
3658 CODE:
3659 {
3660 setCDKMarqueeURChar (object,character);
3661 }
3662
3663 void
3664 SetLLChar(object,character=ACS_LLCORNER)
3665 CDKMARQUEE * object
3666 chtype character = sv2chtype ($arg);
3667 CODE:
3668 {
3669 setCDKMarqueeLLChar (object,character);
3670 }
3671
3672 void
3673 SetLRChar(object,character=ACS_LRCORNER)
3674 CDKMARQUEE * object
3675 chtype character = sv2chtype ($arg);
3676 CODE:
3677 {
3678 setCDKMarqueeLRChar (object,character);
3679 }
3680
3681 void
3682 SetVerticalChar(object,character=ACS_VLINE)
3683 CDKMARQUEE * object
3684 chtype character = sv2chtype ($arg);
3685 CODE:
3686 {
3687 setCDKMarqueeVerticalChar (object,character);
3688 }
3689
3690 void
3691 SetHorizontalChar(object,character=ACS_HLINE)
3692 CDKMARQUEE * object
3693 chtype character = sv2chtype ($arg);
3694 CODE:
3695 {
3696 setCDKMarqueeHorizontalChar (object,character);
3697 }
3698
3699 void
3700 SetBackgroundColor(object,color)
3701 CDKMARQUEE * object
3702 char * color
3703 CODE:
3704 {
3705 setCDKMarqueeBackgroundColor (object,color);
3706 }
3707
3708 void
3709 Bind(object,key,functionRef)
3710 CDKMARQUEE * object
3711 chtype key = sv2chtype ($arg);
3712 SV * functionRef
3713 CODE:
3714 {
3715 SV *function = newSVsv (functionRef);
3716 bindCDKObject (vMARQUEE, object, key, PerlBindCB, function);
3717 }
3718
3719 void
3720 Draw(object,Box=TRUE)
3721 CDKMARQUEE * object
3722 int Box = sv2int ($arg);
3723 CODE:
3724 {
3725 drawCDKMarquee (object,Box);
3726 }
3727
3728 void
3729 Erase(object)
3730 CDKMARQUEE * object
3731 CODE:
3732 {
3733 eraseCDKMarquee (object);
3734 }
3735
3736 void
3737 Register(object)
3738 CDKMARQUEE * object
3739 CODE:
3740 {
3741 registerCDKObject (GCDKSCREEN, vMARQUEE, object);
3742 }
3743
3744 void
3745 Unregister(object)
3746 CDKMARQUEE * object
3747 CODE:
3748 {
3749 unregisterCDKObject (vMARQUEE, object);
3750 }
3751
3752 void
3753 Raise(object)
3754 CDKMARQUEE * object
3755 CODE:
3756 {
3757 raiseCDKObject (vMARQUEE, object);
3758 }
3759
3760 void
3761 Lower(object)
3762 CDKMARQUEE * object
3763 CODE:
3764 {
3765 lowerCDKObject (vMARQUEE, object);
3766 }
3767
3768 WINDOW *
3769 GetWindow(object)
3770 CDKMARQUEE * object
3771 CODE:
3772 {
3773 RETVAL = object->win;
3774 }
3775 OUTPUT:
3776 RETVAL
3777
3778 MODULE = Cdk PACKAGE = Cdk::Selection
3779
3780 CDKSELECTION *
3781 New(title,list,choices,height,width,xPos=CENTER,yPos=CENTER,sPos=RIGHT,highlight=A_REVERSE,Box=TRUE,shadow=FALSE)
3782 SV * title
3783 SV * list
3784 SV * choices
3785 int height
3786 int width
3787 int xPos = sv2int ($arg);
3788 int yPos = sv2int ($arg);
3789 int sPos = sv2int ($arg);
3790 chtype highlight = sv2chtype ($arg);
3791 int Box = sv2int ($arg);
3792 int shadow = sv2int ($arg);
3793 CODE:
3794 {
3795 CDKSELECTION * selectionWidget = (CDKSELECTION *)NULL;
3796 char ** List;
3797 char ** Choices;
3798 char * Title;
3799 int listSize, choiceSize;
3800
3801 checkCdkInit();
3802
3803 MAKE_CHAR_ARRAY(0, list, List, listSize);
3804 MAKE_CHAR_ARRAY(0, choices, Choices, choiceSize);
3805 MAKE_TITLE (title,Title);
3806
3807 selectionWidget = newCDKSelection (GCDKSCREEN, xPos, yPos, sPos,
3808 height, width,
3809 Title, List, listSize,
3810 Choices, choiceSize,
3811 highlight, Box, shadow);
3812 free (List);
3813 free (Choices);
3814 free (Title);
3815
3816 /* Check the return type. */
3817 if (selectionWidget == (CDKSELECTION *)NULL)
3818 {
3819 croak ("Cdk::Selection Could not create widget. Is the window too small?\n");
3820 }
3821 else
3822 {
3823 RETVAL = selectionWidget;
3824 }
3825 }
3826 OUTPUT:
3827 RETVAL
3828
3829 void
3830 Activate(object,...)
3831 CDKSELECTION * object
3832 PPCODE:
3833 {
3834 chtype * Keys;
3835 int arrayLen;
3836 int value, x;
3837
3838 if (items > 1)
3839 {
3840 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
3841 value = activateCDKSelection (object, Keys);
3842 free (Keys);
3843 }
3844 else
3845 {
3846 value = activateCDKSelection (object, NULL);
3847 }
3848
3849 if (object->exitType == vEARLY_EXIT ||
3850 object->exitType == vESCAPE_HIT)
3851 {
3852 XSRETURN_UNDEF;
3853 }
3854
3855 /* Push the values on the return stack. */
3856 for (x=0; x < object->listSize ; x++)
3857 {
3858 XPUSHs (sv_2mortal(newSViv(object->selections[x])));
3859 }
3860 }
3861
3862 int
3863 Inject(object,key)
3864 CDKSELECTION * object
3865 chtype key = sv2chtype ($arg);
3866 CODE:
3867 {
3868 int selection = injectCDKSelection (object,key);
3869 if (selection == -1)
3870 {
3871 XSRETURN_UNDEF;
3872 }
3873 RETVAL = selection;
3874 }
3875 OUTPUT:
3876 RETVAL
3877
3878 void
3879 Bind(object,key,functionRef)
3880 CDKSELECTION * object
3881 chtype key = sv2chtype ($arg);
3882 SV * functionRef
3883 CODE:
3884 {
3885 SV *function = newSVsv (functionRef);
3886 bindCDKObject (vSELECTION, object, key, PerlBindCB, function);
3887 }
3888
3889 int
3890 PreProcess(object,functionRef)
3891 CDKSELECTION * object
3892 SV * functionRef
3893 CODE:
3894 {
3895 SV *function = newSVsv (functionRef);
3896 setCDKSelectionPreProcess (object, PerlProcessCB, function);
3897 }
3898 OUTPUT:
3899 RETVAL
3900
3901 int
3902 PostProcess(object,functionRef)
3903 CDKSELECTION * object
3904 SV * functionRef
3905 CODE:
3906 {
3907 SV *function = newSVsv (functionRef);
3908 setCDKSelectionPostProcess (object, PerlProcessCB, function);
3909 }
3910 OUTPUT:
3911 RETVAL
3912
3913 void
3914 Draw(object,Box=TRUE)
3915 CDKSELECTION * object
3916 int Box = sv2int ($arg);
3917 CODE:
3918 {
3919 drawCDKSelection (object,Box);
3920 }
3921
3922 void
3923 Erase(object)
3924 CDKSELECTION * object
3925 CODE:
3926 {
3927 eraseCDKSelection (object);
3928 }
3929
3930 void
3931 SetHighlight(object,highlight)
3932 CDKSELECTION * object
3933 chtype highlight = sv2chtype ($arg);
3934 CODE:
3935 {
3936 setCDKSelectionHighlight (object,highlight);
3937 }
3938
3939 void
3940 SetChoices(object,choices)
3941 CDKSELECTION * object
3942 SV * choices
3943 CODE:
3944 {
3945 int * defaultChoices;
3946 int choiceLength;
3947
3948 MAKE_INT_ARRAY (0, choices, defaultChoices, choiceLength);
3949 setCDKSelectionChoices (object,defaultChoices);
3950 free (defaultChoices);
3951 }
3952
3953 void
3954 SetChoice(object,choice,index)
3955 CDKSELECTION * object
3956 int choice
3957 int index
3958 CODE:
3959 {
3960 setCDKSelectionChoice (object,index,choice);
3961 }
3962
3963 void
3964 SetModes(object,modes)
3965 CDKSELECTION * object
3966 SV * modes
3967 CODE:
3968 {
3969 int * Modes;
3970 int modeLength;
3971
3972 MAKE_INT_ARRAY (0, modes, Modes, modeLength);
3973 setCDKSelectionModes (object,Modes);
3974 free (Modes);
3975 }
3976
3977 void
3978 SetMode(object,mode,index)
3979 CDKSELECTION * object
3980 int mode
3981 int index
3982 CODE:
3983 {
3984 setCDKSelectionMode (object,index,mode);
3985 }
3986
3987 void
3988 SetBox(object,box=TRUE)
3989 CDKSELECTION * object
3990 int box = sv2int ($arg);
3991 CODE:
3992 {
3993 setCDKSelectionBox (object,box);
3994 }
3995
3996 void
3997 SetULChar(object,character=ACS_ULCORNER)
3998 CDKSELECTION * object
3999 chtype character = sv2chtype ($arg);
4000 CODE:
4001 {
4002 setCDKSelectionULChar (object,character);
4003 }
4004
4005 void
4006 SetURChar(object,character=ACS_URCORNER)
4007 CDKSELECTION * object
4008 chtype character = sv2chtype ($arg);
4009 CODE:
4010 {
4011 setCDKSelectionURChar (object,character);
4012 }
4013
4014 void
4015 SetLLChar(object,character=ACS_LLCORNER)
4016 CDKSELECTION * object
4017 chtype character = sv2chtype ($arg);
4018 CODE:
4019 {
4020 setCDKSelectionLLChar (object,character);
4021 }
4022
4023 void
4024 SetLRChar(object,character=ACS_LRCORNER)
4025 CDKSELECTION * object
4026 chtype character = sv2chtype ($arg);
4027 CODE:
4028 {
4029 setCDKSelectionLRChar (object,character);
4030 }
4031
4032 void
4033 SetVerticalChar(object,character=ACS_VLINE)
4034 CDKSELECTION * object
4035 chtype character = sv2chtype ($arg);
4036 CODE:
4037 {
4038 setCDKSelectionVerticalChar (object,character);
4039 }
4040
4041 void
4042 SetHorizontalChar(object,character=ACS_HLINE)
4043 CDKSELECTION * object
4044 chtype character = sv2chtype ($arg);
4045 CODE:
4046 {
4047 setCDKSelectionHorizontalChar (object,character);
4048 }
4049
4050 void
4051 SetBoxAttribute(object,character=ACS_HLINE)
4052 CDKSELECTION * object
4053 chtype character = sv2chtype ($arg);
4054 CODE:
4055 {
4056 setCDKSelectionBoxAttribute (object,character);
4057 }
4058
4059 void
4060 SetBackgroundColor(object,color)
4061 CDKSELECTION * object
4062 char * color
4063 CODE:
4064 {
4065 setCDKSelectionBackgroundColor (object,color);
4066 }
4067
4068 void
4069 Register(object)
4070 CDKSELECTION * object
4071 CODE:
4072 {
4073 registerCDKObject (GCDKSCREEN, vSELECTION, object);
4074 }
4075
4076 void
4077 Unregister(object)
4078 CDKSELECTION * object
4079 CODE:
4080 {
4081 unregisterCDKObject (vSELECTION, object);
4082 }
4083
4084 void
4085 Raise(object)
4086 CDKSELECTION * object
4087 CODE:
4088 {
4089 raiseCDKObject (vSELECTION, object);
4090 }
4091
4092 void
4093 Lower(object)
4094 CDKSELECTION * object
4095 CODE:
4096 {
4097 lowerCDKObject (vSELECTION, object);
4098 }
4099
4100 WINDOW *
4101 GetWindow(object)
4102 CDKSELECTION * object
4103 CODE:
4104 {
4105 RETVAL = object->win;
4106 }
4107 OUTPUT:
4108 RETVAL
4109
4110 MODULE = Cdk PACKAGE = Cdk::Viewer
4111
4112 CDKVIEWER *
4113 New(buttons,height,width,buttonHighlight=A_REVERSE,xpos=CENTER,ypos=CENTER,Box=TRUE,shadow=FALSE)
4114 SV * buttons
4115 int height
4116 int width
4117 chtype buttonHighlight = sv2chtype ($arg);
4118 int xpos = sv2int ($arg);
4119 int ypos = sv2int ($arg);
4120 int Box = sv2int ($arg);
4121 int shadow = sv2int ($arg);
4122 CODE:
4123 {
4124 CDKVIEWER * viewerWidget = (CDKVIEWER *)NULL;
4125 char ** Buttons;
4126 int buttonCount;
4127
4128 checkCdkInit();
4129
4130 MAKE_CHAR_ARRAY (0, buttons, Buttons, buttonCount);
4131
4132 viewerWidget = newCDKViewer (GCDKSCREEN, xpos, ypos,
4133 height, width,
4134 Buttons, buttonCount,
4135 buttonHighlight, Box, shadow);
4136 free (Buttons);
4137
4138 /* Check the return type. */
4139 if (viewerWidget == (CDKVIEWER *)NULL)
4140 {
4141 croak ("Cdk::Viewer Could not create widget. Is the window too small?\n");
4142 }
4143 else
4144 {
4145 RETVAL = viewerWidget;
4146 }
4147 }
4148 OUTPUT:
4149 RETVAL
4150
4151 int
4152 Activate(object)
4153 CDKVIEWER * object
4154 CODE:
4155 {
4156 int value = activateCDKViewer (object, (chtype *)NULL);
4157
4158 if (object->exitType == vEARLY_EXIT ||
4159 object->exitType == vESCAPE_HIT)
4160 {
4161 XSRETURN_UNDEF;
4162 }
4163 RETVAL = value;
4164 }
4165 OUTPUT:
4166 RETVAL
4167
4168 void
4169 SetInfo(object,info,interpret=TRUE)
4170 CDKVIEWER * object
4171 SV * info
4172 int interpret = sv2int ($arg);
4173 CODE:
4174 {
4175 char ** Info;
4176 int infolen;
4177
4178 MAKE_CHAR_ARRAY(0, info, Info, infolen);
4179 setCDKViewerInfo (object, Info, infolen, interpret);
4180 free (Info);
4181 }
4182
4183 void
4184 SetTitle(object,value)
4185 CDKVIEWER * object
4186 char * value
4187 CODE:
4188 {
4189 setCDKViewerTitle (object,value);
4190 }
4191
4192 void
4193 SetHighlight(object,value)
4194 CDKVIEWER * object
4195 chtype value
4196 CODE:
4197 {
4198 setCDKViewerHighlight (object,value);
4199 }
4200
4201 void
4202 SetInfoLine(object,value)
4203 CDKVIEWER * object
4204 int value
4205 CODE:
4206 {
4207 setCDKViewerInfoLine (object,value);
4208 }
4209
4210 void
4211 SetBox(object,box=TRUE)
4212 CDKVIEWER * object
4213 int box = sv2int ($arg);
4214 CODE:
4215 {
4216 setCDKViewerBox (object,box);
4217 }
4218
4219 void
4220 SetULChar(object,character=ACS_ULCORNER)
4221 CDKVIEWER * object
4222 chtype character = sv2chtype ($arg);
4223 CODE:
4224 {
4225 setCDKViewerULChar (object,character);
4226 }
4227
4228 void
4229 SetURChar(object,character=ACS_URCORNER)
4230 CDKVIEWER * object
4231 chtype character = sv2chtype ($arg);
4232 CODE:
4233 {
4234 setCDKViewerURChar (object,character);
4235 }
4236
4237 void
4238 SetLLChar(object,character=ACS_LLCORNER)
4239 CDKVIEWER * object
4240 chtype character = sv2chtype ($arg);
4241 CODE:
4242 {
4243 setCDKViewerLLChar (object,character);
4244 }
4245
4246 void
4247 SetLRChar(object,character=ACS_LRCORNER)
4248 CDKVIEWER * object
4249 chtype character = sv2chtype ($arg);
4250 CODE:
4251 {
4252 setCDKViewerLRChar (object,character);
4253 }
4254
4255 void
4256 SetVerticalChar(object,character=ACS_VLINE)
4257 CDKVIEWER * object
4258 chtype character = sv2chtype ($arg);
4259 CODE:
4260 {
4261 setCDKViewerVerticalChar (object,character);
4262 }
4263
4264 void
4265 SetHorizontalChar(object,character=ACS_HLINE)
4266 CDKVIEWER * object
4267 chtype character = sv2chtype ($arg);
4268 CODE:
4269 {
4270 setCDKViewerHorizontalChar (object,character);
4271 }
4272
4273 void
4274 SetBoxAttribute(object,character=ACS_HLINE)
4275 CDKVIEWER * object
4276 chtype character = sv2chtype ($arg);
4277 CODE:
4278 {
4279 setCDKViewerBoxAttribute (object,character);
4280 }
4281
4282 void
4283 SetBackgroundColor(object,color)
4284 CDKVIEWER * object
4285 char * color
4286 CODE:
4287 {
4288 setCDKViewerBackgroundColor (object,color);
4289 }
4290
4291 void
4292 Bind(object,key,functionRef)
4293 CDKVIEWER * object
4294 chtype key = sv2chtype ($arg);
4295 SV * functionRef
4296 CODE:
4297 {
4298 SV *function = newSVsv (functionRef);
4299 bindCDKObject (vVIEWER, object, key, PerlBindCB, function);
4300 }
4301
4302 void
4303 Draw(object,Box=TRUE)
4304 CDKVIEWER * object
4305 int Box = sv2int ($arg);
4306 CODE:
4307 {
4308 drawCDKViewer (object,Box);
4309 }
4310
4311 void
4312 Erase(object)
4313 CDKVIEWER * object
4314 CODE:
4315 {
4316 eraseCDKViewer (object);
4317 }
4318
4319 void
4320 Register(object)
4321 CDKVIEWER * object
4322 CODE:
4323 {
4324 registerCDKObject (GCDKSCREEN, vVIEWER, object);
4325 }
4326
4327 void
4328 Unregister(object)
4329 CDKVIEWER * object
4330 CODE:
4331 {
4332 unregisterCDKObject (vVIEWER, object);
4333 }
4334
4335 void
4336 Raise(object)
4337 CDKVIEWER * object
4338 CODE:
4339 {
4340 raiseCDKObject (vVIEWER, object);
4341 }
4342
4343 void
4344 Lower(object)
4345 CDKVIEWER * object
4346 CODE:
4347 {
4348 lowerCDKObject (vVIEWER, object);
4349 }
4350
4351 WINDOW *
4352 GetWindow(object)
4353 CDKVIEWER * object
4354 CODE:
4355 {
4356 RETVAL = object->win;
4357 }
4358 OUTPUT:
4359 RETVAL
4360
4361 MODULE = Cdk PACKAGE = Cdk::Graph
4362
4363 CDKGRAPH *
4364 New(title,xtitle,ytitle,height,width,xpos=CENTER,ypos=CENTER)
4365 SV * title
4366 char * xtitle
4367 char * ytitle
4368 int height
4369 int width
4370 int xpos = sv2int ($arg);
4371 int ypos = sv2int ($arg);
4372 CODE:
4373 {
4374 CDKGRAPH * graphWidget = (CDKGRAPH *)NULL;
4375 char * Title;
4376
4377 checkCdkInit();
4378
4379 MAKE_TITLE (title,Title);
4380
4381 graphWidget = newCDKGraph (GCDKSCREEN,xpos,ypos,height,width,Title,xtitle,ytitle);
4382
4383 free (Title);
4384
4385 /* Check the return type. */
4386 if (graphWidget == (CDKGRAPH *)NULL)
4387 {
4388 croak ("Cdk::Graph Could not create widget. Is the window too small?\n");
4389 }
4390 else
4391 {
4392 RETVAL = graphWidget;
4393 }
4394 }
4395 OUTPUT:
4396 RETVAL
4397
4398 int
4399 SetValues(object,values,startAtZero=TRUE)
4400 CDKGRAPH * object
4401 SV * values
4402 int startAtZero = sv2int ($arg);
4403 CODE:
4404 {
4405 int * Values;
4406 int valueCount;
4407
4408 MAKE_INT_ARRAY (0, values, Values, valueCount);
4409 RETVAL = setCDKGraphValues (object,Values,valueCount,startAtZero);
4410 free (Values);
4411 }
4412 OUTPUT:
4413 RETVAL
4414
4415 void
4416 SetCharacters(object,value)
4417 CDKGRAPH * object
4418 char * value
4419 CODE:
4420 {
4421 setCDKGraphCharacters (object,value);
4422 }
4423
4424 void
4425 SetDisplayType(object,value)
4426 CDKGRAPH * object
4427 char * value
4428 CODE:
4429 {
4430 EGraphDisplayType displayType = vLINE;
4431
4432 if (strEQ (value, "PLOT"))
4433 {
4434 displayType = vPLOT;
4435 }
4436
4437 setCDKGraphDisplayType (object,displayType);
4438 }
4439
4440 void
4441 SetBox(object,box=FALSE)
4442 CDKGRAPH * object
4443 int box = sv2int ($arg);
4444 CODE:
4445 {
4446 setCDKGraphBox (object,box);
4447 }
4448
4449 void
4450 SetULChar(object,character=ACS_ULCORNER)
4451 CDKGRAPH * object
4452 chtype character = sv2chtype ($arg);
4453 CODE:
4454 {
4455 setCDKGraphULChar (object,character);
4456 }
4457
4458 void
4459 SetURChar(object,character=ACS_URCORNER)
4460 CDKGRAPH * object
4461 chtype character = sv2chtype ($arg);
4462 CODE:
4463 {
4464 setCDKGraphURChar (object,character);
4465 }
4466
4467 void
4468 SetLLChar(object,character=ACS_LLCORNER)
4469 CDKGRAPH * object
4470 chtype character = sv2chtype ($arg);
4471 CODE:
4472 {
4473 setCDKGraphLLChar (object,character);
4474 }
4475
4476 void
4477 SetLRChar(object,character=ACS_LRCORNER)
4478 CDKGRAPH * object
4479 chtype character = sv2chtype ($arg);
4480 CODE:
4481 {
4482 setCDKGraphLRChar (object,character);
4483 }
4484
4485 void
4486 SetVerticalChar(object,character=ACS_VLINE)
4487 CDKGRAPH * object
4488 chtype character = sv2chtype ($arg);
4489 CODE:
4490 {
4491 setCDKGraphVerticalChar (object,character);
4492 }
4493
4494 void
4495 SetHorizontalChar(object,character=ACS_HLINE)
4496 CDKGRAPH * object
4497 chtype character = sv2chtype ($arg);
4498 CODE:
4499 {
4500 setCDKGraphHorizontalChar (object,character);
4501 }
4502
4503 void
4504 SetBoxAttribute(object,character=ACS_HLINE)
4505 CDKGRAPH * object
4506 chtype character = sv2chtype ($arg);
4507 CODE:
4508 {
4509 setCDKGraphBoxAttribute (object,character);
4510 }
4511
4512 void
4513 SetBackgroundColor(object,color)
4514 CDKGRAPH * object
4515 char * color
4516 CODE:
4517 {
4518 setCDKGraphBackgroundColor (object,color);
4519 }
4520
4521 void
4522 Draw(object,Box=FALSE)
4523 CDKGRAPH * object
4524 int Box = sv2int ($arg);
4525 CODE:
4526 {
4527 drawCDKGraph (object,Box);
4528 }
4529
4530 void
4531 Erase(object)
4532 CDKGRAPH * object
4533 CODE:
4534 {
4535 eraseCDKGraph (object);
4536 }
4537
4538 void
4539 Register(object)
4540 CDKGRAPH * object
4541 CODE:
4542 {
4543 registerCDKObject (GCDKSCREEN, vGRAPH, object);
4544 }
4545
4546 void
4547 Unregister(object)
4548 CDKGRAPH * object
4549 CODE:
4550 {
4551 unregisterCDKObject (vGRAPH, object);
4552 }
4553
4554 void
4555 Raise(object)
4556 CDKGRAPH * object
4557 CODE:
4558 {
4559 raiseCDKObject (vGRAPH, object);
4560 }
4561
4562 void
4563 Lower(object)
4564 CDKGRAPH * object
4565 CODE:
4566 {
4567 lowerCDKObject (vGRAPH, object);
4568 }
4569
4570 WINDOW *
4571 GetWindow(object)
4572 CDKGRAPH * object
4573 CODE:
4574 {
4575 RETVAL = object->win;
4576 }
4577 OUTPUT:
4578 RETVAL
4579
4580 MODULE = Cdk PACKAGE = Cdk::Radio
4581
4582 CDKRADIO *
4583 New(title,list,height,width,xPos=CENTER,yPos=CENTER,sPos=RIGHT,choice="X",defaultItem=0,highlight=A_REVERSE,Box=TRUE,shadow=FALSE)
4584 SV * title
4585 SV * list
4586 int height
4587 int width
4588 int xPos = sv2int ($arg);
4589 int yPos = sv2int ($arg);
4590 int sPos = sv2int ($arg);
4591 chtype choice = sv2chtype ($arg);
4592 int defaultItem
4593 chtype highlight = sv2chtype ($arg);
4594 int Box = sv2int ($arg);
4595 int shadow = sv2int ($arg);
4596 CODE:
4597 {
4598 CDKRADIO * radioWidget = (CDKRADIO *)NULL;
4599 char ** List;
4600 char * Title;
4601 int listlen;
4602
4603 MAKE_CHAR_ARRAY(0, list, List, listlen);
4604 MAKE_TITLE (title,Title);
4605
4606 radioWidget = newCDKRadio (GCDKSCREEN,xPos,yPos,sPos,
4607 height,width,Title,
4608 List,listlen,
4609 choice,defaultItem,
4610 highlight,Box,shadow);
4611 free (List);
4612 free (Title);
4613
4614 /* Check the return type. */
4615 if (radioWidget == (CDKRADIO *)NULL)
4616 {
4617 croak ("Cdk::Radio Could not create widget. Is the window too small?\n");
4618 }
4619 else
4620 {
4621 RETVAL = radioWidget;
4622 }
4623 }
4624 OUTPUT:
4625 RETVAL
4626
4627 int
4628 Activate(object,...)
4629 CDKRADIO * object
4630 CODE:
4631 {
4632 chtype * Keys;
4633 int arrayLen;
4634 int value;
4635
4636 if (items > 1)
4637 {
4638 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
4639 value = activateCDKRadio (object, Keys);
4640 free (Keys);
4641 }
4642 else
4643 {
4644 value = activateCDKRadio (object, NULL);
4645 }
4646
4647 if (object->exitType == vEARLY_EXIT ||
4648 object->exitType == vESCAPE_HIT)
4649 {
4650 XSRETURN_UNDEF;
4651 }
4652 RETVAL = value;
4653 }
4654 OUTPUT:
4655 RETVAL
4656
4657 int
4658 Inject(object,key)
4659 CDKRADIO * object
4660 chtype key = sv2chtype ($arg);
4661 CODE:
4662 {
4663 int selection = injectCDKRadio (object,key);
4664 if (selection == -1)
4665 {
4666 XSRETURN_UNDEF;
4667 }
4668 RETVAL = selection;
4669 }
4670 OUTPUT:
4671 RETVAL
4672
4673 void
4674 Bind(object,key,functionRef)
4675 CDKRADIO * object
4676 chtype key = sv2chtype ($arg);
4677 SV * functionRef
4678 CODE:
4679 {
4680 SV *function = newSVsv (functionRef);
4681 bindCDKObject (vRADIO, object, key, PerlBindCB, function);
4682 }
4683
4684 int
4685 PreProcess(object,functionRef)
4686 CDKRADIO * object
4687 SV * functionRef
4688 CODE:
4689 {
4690 SV *function = newSVsv (functionRef);
4691 setCDKRadioPreProcess (object, PerlProcessCB, function);
4692 }
4693 OUTPUT:
4694 RETVAL
4695
4696 int
4697 PostProcess(object,functionRef)
4698 CDKRADIO * object
4699 SV * functionRef
4700 CODE:
4701 {
4702 SV *function = newSVsv (functionRef);
4703 setCDKRadioPostProcess (object, PerlProcessCB, function);
4704 }
4705 OUTPUT:
4706 RETVAL
4707
4708 void
4709 Draw(object,Box=TRUE)
4710 CDKRADIO * object
4711 int Box = sv2int ($arg);
4712 CODE:
4713 {
4714 drawCDKRadio (object,Box);
4715 }
4716
4717 void
4718 Erase(object)
4719 CDKRADIO * object
4720 CODE:
4721 {
4722 eraseCDKRadio (object);
4723 }
4724
4725 void
4726 SetHighlight(object,highlight)
4727 CDKRADIO * object
4728 chtype highlight = sv2chtype ($arg);
4729 CODE:
4730 {
4731 setCDKRadioHighlight (object,highlight);
4732 }
4733
4734 void
4735 SetChoiceCharacter(object,value)
4736 CDKRADIO * object
4737 chtype value = sv2chtype ($arg);
4738 CODE:
4739 {
4740 setCDKRadioChoiceCharacter (object,value);
4741 }
4742
4743 void
4744 SetLeftBrace(object,value)
4745 CDKRADIO * object
4746 chtype value = sv2chtype ($arg);
4747 CODE:
4748 {
4749 setCDKRadioLeftBrace (object,value);
4750 }
4751
4752 void
4753 SetRightBrace(object,value)
4754 CDKRADIO * object
4755 chtype value = sv2chtype ($arg);
4756 CODE:
4757 {
4758 setCDKRadioRightBrace (object,value);
4759 }
4760
4761 void
4762 SetBox(object,box=TRUE)
4763 CDKRADIO * object
4764 int box = sv2int ($arg);
4765 CODE:
4766 {
4767 setCDKRadioBox (object,box);
4768 }
4769
4770 void
4771 SetULChar(object,character=ACS_ULCORNER)
4772 CDKRADIO * object
4773 chtype character = sv2chtype ($arg);
4774 CODE:
4775 {
4776 setCDKRadioULChar (object,character);
4777 }
4778
4779 void
4780 SetURChar(object,character=ACS_URCORNER)
4781 CDKRADIO * object
4782 chtype character = sv2chtype ($arg);
4783 CODE:
4784 {
4785 setCDKRadioURChar (object,character);
4786 }
4787
4788 void
4789 SetLLChar(object,character=ACS_LLCORNER)
4790 CDKRADIO * object
4791 chtype character = sv2chtype ($arg);
4792 CODE:
4793 {
4794 setCDKRadioLLChar (object,character);
4795 }
4796
4797 void
4798 SetLRChar(object,character=ACS_LRCORNER)
4799 CDKRADIO * object
4800 chtype character = sv2chtype ($arg);
4801 CODE:
4802 {
4803 setCDKRadioLRChar (object,character);
4804 }
4805
4806 void
4807 SetVerticalChar(object,character=ACS_VLINE)
4808 CDKRADIO * object
4809 chtype character = sv2chtype ($arg);
4810 CODE:
4811 {
4812 setCDKRadioVerticalChar (object,character);
4813 }
4814
4815 void
4816 SetHorizontalChar(object,character=ACS_HLINE)
4817 CDKRADIO * object
4818 chtype character = sv2chtype ($arg);
4819 CODE:
4820 {
4821 setCDKRadioHorizontalChar (object,character);
4822 }
4823
4824 void
4825 SetBoxAttribute(object,character=ACS_HLINE)
4826 CDKRADIO * object
4827 chtype character = sv2chtype ($arg);
4828 CODE:
4829 {
4830 setCDKRadioBoxAttribute (object,character);
4831 }
4832
4833 void
4834 SetBackgroundColor(object,color)
4835 CDKRADIO * object
4836 char * color
4837 CODE:
4838 {
4839 setCDKRadioBackgroundColor (object,color);
4840 }
4841
4842 void
4843 Register(object)
4844 CDKRADIO * object
4845 CODE:
4846 {
4847 registerCDKObject (GCDKSCREEN, vRADIO, object);
4848 }
4849
4850 void
4851 Unregister(object)
4852 CDKRADIO * object
4853 CODE:
4854 {
4855 unregisterCDKObject (vRADIO, object);
4856 }
4857
4858 void
4859 Raise(object)
4860 CDKRADIO * object
4861 CODE:
4862 {
4863 raiseCDKObject (vRADIO, object);
4864 }
4865
4866 void
4867 Lower(object)
4868 CDKRADIO * object
4869 CODE:
4870 {
4871 lowerCDKObject (vRADIO, object);
4872 }
4873
4874 WINDOW *
4875 GetWindow(object)
4876 CDKRADIO * object
4877 CODE:
4878 {
4879 RETVAL = object->win;
4880 }
4881 OUTPUT:
4882 RETVAL
4883
4884 MODULE = Cdk PACKAGE = Cdk::Template
4885
4886 CDKTEMPLATE *
4887 New(title,label,plate,overlay,xpos=CENTER,ypos=CENTER,Box=TRUE,shadow=FALSE)
4888 SV * title
4889 char * label
4890 char * plate
4891 char * overlay
4892 int xpos = sv2int ($arg);
4893 int ypos = sv2int ($arg);
4894 int Box = sv2int ($arg);
4895 int shadow = sv2int ($arg);
4896 CODE:
4897 {
4898 CDKTEMPLATE * templateWidget = (CDKTEMPLATE *)NULL;
4899 char * Title;
4900
4901 checkCdkInit();
4902
4903 MAKE_TITLE (title,Title);
4904
4905 templateWidget = newCDKTemplate (GCDKSCREEN,xpos,ypos,
4906 Title,label,
4907 plate,overlay,
4908 Box,shadow);
4909 free (Title);
4910
4911 /* Check the return type. */
4912 if (templateWidget == (CDKTEMPLATE *)NULL)
4913 {
4914 croak ("Cdk::Template Could not create widget. Is the window too small?\n");
4915 }
4916 else
4917 {
4918 RETVAL = templateWidget;
4919 }
4920 }
4921 OUTPUT:
4922 RETVAL
4923
4924 char *
4925 Activate(object,...)
4926 CDKTEMPLATE * object
4927 CODE:
4928 {
4929 chtype * Keys;
4930 int arrayLen;
4931 char *value;
4932
4933 if (items > 1)
4934 {
4935 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
4936 value = activateCDKTemplate (object, Keys);
4937 free (Keys);
4938 }
4939 else
4940 {
4941 value = activateCDKTemplate (object, NULL);
4942 }
4943
4944 if (object->exitType == vEARLY_EXIT ||
4945 object->exitType == vESCAPE_HIT)
4946 {
4947 XSRETURN_UNDEF;
4948 }
4949 RETVAL = value;
4950 }
4951 OUTPUT:
4952 RETVAL
4953
4954 char *
4955 Inject(object,key)
4956 CDKTEMPLATE * object
4957 chtype key = sv2chtype ($arg);
4958 CODE:
4959 {
4960 char *value = injectCDKTemplate (object,key);
4961 if (object->exitType == vESCAPE_HIT ||
4962 object->exitType == vEARLY_EXIT)
4963 {
4964 XSRETURN_UNDEF;
4965 }
4966 RETVAL = value;
4967 }
4968 OUTPUT:
4969 RETVAL
4970
4971 void
4972 Bind(object,key,functionRef)
4973 CDKTEMPLATE * object
4974 chtype key = sv2chtype ($arg);
4975 SV * functionRef
4976 CODE:
4977 {
4978 SV *function = newSVsv (functionRef);
4979 bindCDKObject (vTEMPLATE, object, key, PerlBindCB, function);
4980 }
4981
4982 int
4983 PreProcess(object,functionRef)
4984 CDKTEMPLATE * object
4985 SV * functionRef
4986 CODE:
4987 {
4988 SV *function = newSVsv (functionRef);
4989 setCDKTemplatePreProcess (object, PerlProcessCB, function);
4990 }
4991 OUTPUT:
4992 RETVAL
4993
4994 int
4995 PostProcess(object,functionRef)
4996 CDKTEMPLATE * object
4997 SV * functionRef
4998 CODE:
4999 {
5000 SV *function = newSVsv (functionRef);
5001 setCDKTemplatePostProcess (object, PerlProcessCB, function);
5002 }
5003 OUTPUT:
5004 RETVAL
5005
5006 char *
5007 Mix(object)
5008 CDKTEMPLATE * object
5009 CODE:
5010 {
5011 RETVAL = mixCDKTemplate (object);
5012 }
5013 OUTPUT:
5014 RETVAL
5015
5016 void
5017 Draw(object,Box=TRUE)
5018 CDKTEMPLATE * object
5019 int Box = sv2int ($arg);
5020 CODE:
5021 {
5022 drawCDKTemplate (object, Box);
5023 }
5024
5025 void
5026 Erase(object)
5027 CDKTEMPLATE * object
5028 CODE:
5029 {
5030 eraseCDKTemplate (object);
5031 }
5032
5033 void
5034 SetValue(object,value)
5035 CDKTEMPLATE * object
5036 char * value
5037 CODE:
5038 {
5039 setCDKTemplateValue (object,value);
5040 }
5041
5042 void
5043 SetMin(object,value)
5044 CDKTEMPLATE * object
5045 int value
5046 CODE:
5047 {
5048 setCDKTemplateMin (object,value);
5049 }
5050
5051 void
5052 SetBox(object,box=TRUE)
5053 CDKTEMPLATE * object
5054 int box = sv2int ($arg);
5055 CODE:
5056 {
5057 setCDKTemplateBox (object,box);
5058 }
5059
5060 void
5061 SetULChar(object,character=ACS_ULCORNER)
5062 CDKTEMPLATE * object
5063 chtype character = sv2chtype ($arg);
5064 CODE:
5065 {
5066 setCDKTemplateULChar (object,character);
5067 }
5068
5069 void
5070 SetURChar(object,character=ACS_URCORNER)
5071 CDKTEMPLATE * object
5072 chtype character = sv2chtype ($arg);
5073 CODE:
5074 {
5075 setCDKTemplateURChar (object,character);
5076 }
5077
5078 void
5079 SetLLChar(object,character=ACS_LLCORNER)
5080 CDKTEMPLATE * object
5081 chtype character = sv2chtype ($arg);
5082 CODE:
5083 {
5084 setCDKTemplateLLChar (object,character);
5085 }
5086
5087 void
5088 SetLRChar(object,character=ACS_LRCORNER)
5089 CDKTEMPLATE * object
5090 chtype character = sv2chtype ($arg);
5091 CODE:
5092 {
5093 setCDKTemplateLRChar (object,character);
5094 }
5095
5096 void
5097 SetVerticalChar(object,character=ACS_VLINE)
5098 CDKTEMPLATE * object
5099 chtype character = sv2chtype ($arg);
5100 CODE:
5101 {
5102 setCDKTemplateVerticalChar (object,character);
5103 }
5104
5105 void
5106 SetHorizontalChar(object,character=ACS_HLINE)
5107 CDKTEMPLATE * object
5108 chtype character = sv2chtype ($arg);
5109 CODE:
5110 {
5111 setCDKTemplateHorizontalChar (object,character);
5112 }
5113
5114 void
5115 SetBoxAttribute(object,character=ACS_HLINE)
5116 CDKTEMPLATE * object
5117 chtype character = sv2chtype ($arg);
5118 CODE:
5119 {
5120 setCDKTemplateBoxAttribute (object,character);
5121 }
5122
5123 void
5124 SetBackgroundColor(object,color)
5125 CDKTEMPLATE * object
5126 char * color
5127 CODE:
5128 {
5129 setCDKTemplateBackgroundColor (object,color);
5130 }
5131
5132 char *
5133 Get(object)
5134 CDKTEMPLATE * object
5135 CODE:
5136 {
5137 RETVAL = object->info;
5138 }
5139 OUTPUT:
5140 RETVAL
5141
5142 void
5143 Clean(object)
5144 CDKTEMPLATE * object
5145 CODE:
5146 {
5147 cleanCDKTemplate (object);
5148 }
5149
5150 void
5151 Register(object)
5152 CDKTEMPLATE * object
5153 CODE:
5154 {
5155 registerCDKObject (GCDKSCREEN, vTEMPLATE, object);
5156 }
5157
5158 void
5159 Unregister(object)
5160 CDKTEMPLATE * object
5161 CODE:
5162 {
5163 unregisterCDKObject (vTEMPLATE, object);
5164 }
5165
5166 void
5167 Raise(object)
5168 CDKTEMPLATE * object
5169 CODE:
5170 {
5171 raiseCDKObject (vTEMPLATE, object);
5172 }
5173
5174 void
5175 Lower(object)
5176 CDKTEMPLATE * object
5177 CODE:
5178 {
5179 lowerCDKObject (vTEMPLATE, object);
5180 }
5181
5182 WINDOW *
5183 GetWindow(object)
5184 CDKTEMPLATE * object
5185 CODE:
5186 {
5187 RETVAL = object->win;
5188 }
5189 OUTPUT:
5190 RETVAL
5191
5192 MODULE = Cdk PACKAGE = Cdk::Swindow
5193 CDKSWINDOW *
5194 New(title,savelines,height,width,xpos=CENTER,ypos=CENTER,box=TRUE,shadow=FALSE)
5195 SV * title
5196 int savelines
5197 int height
5198 int width
5199 int xpos = sv2int ($arg);
5200 int ypos = sv2int ($arg);
5201 int box = sv2int ($arg);
5202 int shadow = sv2int ($arg);
5203 CODE:
5204 {
5205 CDKSWINDOW * swindowWidget = (CDKSWINDOW *)NULL;
5206 char * Title;
5207
5208 MAKE_TITLE (title,Title);
5209
5210 swindowWidget = newCDKSwindow (GCDKSCREEN,xpos,ypos,
5211 height,width,
5212 Title,savelines,
5213 box,shadow);
5214 free (Title);
5215
5216 /* Check the return type. */
5217 if (swindowWidget == (CDKSWINDOW *)NULL)
5218 {
5219 croak ("Cdk::Swindow Could not create widget. Is the window too small?\n");
5220 }
5221 else
5222 {
5223 RETVAL = swindowWidget;
5224 }
5225 }
5226 OUTPUT:
5227 RETVAL
5228
5229 void
5230 Activate(object,...)
5231 CDKSWINDOW * object
5232 CODE:
5233 {
5234 chtype * Keys;
5235 int arrayLen;
5236
5237 if (items > 1)
5238 {
5239 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
5240 activateCDKSwindow (object, Keys);
5241 free (Keys);
5242 }
5243 else
5244 {
5245 activateCDKSwindow (object, NULL);
5246 }
5247 }
5248
5249 int
5250 Inject(object,key)
5251 CDKSWINDOW * object
5252 chtype key = sv2chtype ($arg);
5253 CODE:
5254 {
5255 int selection = injectCDKSwindow (object,key);
5256 if (selection == -1)
5257 {
5258 XSRETURN_UNDEF;
5259 }
5260 RETVAL = selection;
5261 }
5262 OUTPUT:
5263 RETVAL
5264
5265 void
5266 Bind(object,key,functionRef)
5267 CDKSWINDOW * object
5268 chtype key = sv2chtype ($arg);
5269 SV * functionRef
5270 CODE:
5271 {
5272 SV *function = newSVsv (functionRef);
5273 bindCDKObject (vSWINDOW, object, key, PerlBindCB, function);
5274 }
5275
5276 int
5277 PreProcess(object,functionRef)
5278 CDKSWINDOW * object
5279 SV * functionRef
5280 CODE:
5281 {
5282 SV *function = newSVsv (functionRef);
5283 setCDKSwindowPreProcess (object, PerlProcessCB, function);
5284 }
5285 OUTPUT:
5286 RETVAL
5287
5288 int
5289 PostProcess(object,functionRef)
5290 CDKSWINDOW * object
5291 SV * functionRef
5292 CODE:
5293 {
5294 SV *function = newSVsv (functionRef);
5295 setCDKSwindowPostProcess (object, PerlProcessCB, function);
5296 }
5297 OUTPUT:
5298 RETVAL
5299
5300 void
5301 SetContents(object,info)
5302 CDKSWINDOW * object
5303 SV * info
5304 CODE:
5305 {
5306 char ** Loginfo;
5307 int infolen;
5308
5309 MAKE_CHAR_ARRAY(0, info, Loginfo, infolen);
5310 setCDKSwindowContents (object, Loginfo, infolen);
5311 free (Loginfo);
5312 }
5313
5314 void
5315 SetBox(object,box=TRUE)
5316 CDKSWINDOW * object
5317 int box = sv2int ($arg);
5318 CODE:
5319 {
5320 setCDKSwindowBox (object,box);
5321 }
5322
5323 void
5324 SetULChar(object,character=ACS_ULCORNER)
5325 CDKSWINDOW * object
5326 chtype character = sv2chtype ($arg);
5327 CODE:
5328 {
5329 setCDKSwindowULChar (object,character);
5330 }
5331
5332 void
5333 SetURChar(object,character=ACS_URCORNER)
5334 CDKSWINDOW * object
5335 chtype character = sv2chtype ($arg);
5336 CODE:
5337 {
5338 setCDKSwindowURChar (object,character);
5339 }
5340
5341 void
5342 SetLLChar(object,character=ACS_LLCORNER)
5343 CDKSWINDOW * object
5344 chtype character = sv2chtype ($arg);
5345 CODE:
5346 {
5347 setCDKSwindowLLChar (object,character);
5348 }
5349
5350 void
5351 SetLRChar(object,character=ACS_LRCORNER)
5352 CDKSWINDOW * object
5353 chtype character = sv2chtype ($arg);
5354 CODE:
5355 {
5356 setCDKSwindowLRChar (object,character);
5357 }
5358
5359 void
5360 SetVerticalChar(object,character=ACS_VLINE)
5361 CDKSWINDOW * object
5362 chtype character = sv2chtype ($arg);
5363 CODE:
5364 {
5365 setCDKSwindowVerticalChar (object,character);
5366 }
5367
5368 void
5369 SetHorizontalChar(object,character=ACS_HLINE)
5370 CDKSWINDOW * object
5371 chtype character = sv2chtype ($arg);
5372 CODE:
5373 {
5374 setCDKSwindowHorizontalChar (object,character);
5375 }
5376
5377 void
5378 SetBoxAttribute(object,character=ACS_HLINE)
5379 CDKSWINDOW * object
5380 chtype character = sv2chtype ($arg);
5381 CODE:
5382 {
5383 setCDKSwindowBoxAttribute (object,character);
5384 }
5385
5386 void
5387 SetBackgroundColor(object,color)
5388 CDKSWINDOW * object
5389 char * color
5390 CODE:
5391 {
5392 setCDKSwindowBackgroundColor (object,color);
5393 }
5394
5395 void
5396 Addline(object,info,insertpos)
5397 CDKSWINDOW * object
5398 char * info
5399 int insertpos = sv2int ($arg);
5400 CODE:
5401 {
5402 addCDKSwindow (object, info, insertpos);
5403 }
5404
5405 void
5406 Trim(object,start,finish)
5407 CDKSWINDOW * object
5408 int start = sv2int ($arg);
5409 int finish = sv2int ($arg);
5410 CODE:
5411 {
5412 trimCDKSwindow (object, start, finish);
5413 }
5414
5415 int
5416 Exec(object,command,insertPos=BOTTOM)
5417 CDKSWINDOW * object
5418 char * command
5419 int insertPos = sv2int ($arg);
5420 CODE:
5421 {
5422 RETVAL = execCDKSwindow (object, command, insertPos);
5423 }
5424 OUTPUT:
5425 RETVAL
5426
5427 void
5428 Get(object)
5429 CDKSWINDOW * object
5430 PPCODE:
5431 {
5432 int x;
5433 char *temp;
5434
5435 /* Push each item onto the stack. */
5436 for (x=0; x < object->listSize ; x++)
5437 {
5438 /* We need to convert from chtype to char */
5439 temp = chtype2Char (object->list[x]);
5440
5441 /* Push it on the stack. */
5442 XPUSHs (sv_2mortal(newSVpv(temp, strlen(temp))));
5443 freeChar (temp);
5444 }
5445 }
5446
5447 void
5448 Save(object)
5449 CDKSWINDOW * object
5450 CODE:
5451 {
5452 saveCDKSwindowInformation (object);
5453 }
5454
5455 void
5456 Load(object)
5457 CDKSWINDOW * object
5458 CODE:
5459 {
5460 loadCDKSwindowInformation (object);
5461 }
5462
5463 int
5464 Dump(object,filename)
5465 CDKSWINDOW * object
5466 char * filename
5467 CODE:
5468 {
5469 RETVAL = dumpCDKSwindow (object, filename);
5470 }
5471 OUTPUT:
5472 RETVAL
5473
5474 void
5475 Draw(object,Box=TRUE)
5476 CDKSWINDOW * object
5477 int Box = sv2int ($arg);
5478 CODE:
5479 {
5480 drawCDKSwindow (object, Box);
5481 }
5482
5483 void
5484 Erase(object)
5485 CDKSWINDOW * object
5486 CODE:
5487 {
5488 eraseCDKSwindow (object);
5489 }
5490
5491 void
5492 Clean(object)
5493 CDKSWINDOW * object
5494 CODE:
5495 {
5496 cleanCDKSwindow (object);
5497 }
5498
5499 void
5500 Register(object)
5501 CDKSWINDOW * object
5502 CODE:
5503 {
5504 registerCDKObject (GCDKSCREEN, vSWINDOW, object);
5505 }
5506
5507 void
5508 Unregister(object)
5509 CDKSWINDOW * object
5510 CODE:
5511 {
5512 unregisterCDKObject (vSWINDOW, object);
5513 }
5514
5515 void
5516 Raise(object)
5517 CDKSWINDOW * object
5518 CODE:
5519 {
5520 raiseCDKObject (vSWINDOW, object);
5521 }
5522
5523 void
5524 Lower(object)
5525 CDKSWINDOW * object
5526 CODE:
5527 {
5528 lowerCDKObject (vSWINDOW, object);
5529 }
5530
5531 WINDOW *
5532 GetWindow(object)
5533 CDKSWINDOW * object
5534 CODE:
5535 {
5536 RETVAL = object->win;
5537 }
5538 OUTPUT:
5539 RETVAL
5540
5541 MODULE = Cdk PACKAGE = Cdk::Itemlist
5542 CDKITEMLIST *
5543 New(title,label,itemlist,defaultItem=0,xpos=CENTER,ypos=CENTER,box=TRUE,shadow=FALSE)
5544 SV * title
5545 char * label
5546 SV * itemlist
5547 int defaultItem
5548 int xpos = sv2int ($arg);
5549 int ypos = sv2int ($arg);
5550 int box = sv2int ($arg);
5551 int shadow = sv2int ($arg);
5552 CODE:
5553 {
5554 CDKITEMLIST * itemlistWidget = (CDKITEMLIST *)NULL;
5555 char * Title;
5556 char ** Itemlist;
5557 int itemLength;
5558
5559 checkCdkInit();
5560
5561 MAKE_CHAR_ARRAY (0, itemlist, Itemlist, itemLength);
5562 MAKE_TITLE (title,Title);
5563
5564 itemlistWidget = newCDKItemlist (GCDKSCREEN,xpos,ypos,
5565 Title,label,
5566 Itemlist,itemLength,
5567 defaultItem,box,shadow);
5568 free (Itemlist);
5569 free (Title);
5570
5571 /* Check the return type. */
5572 if (itemlistWidget == (CDKITEMLIST *)NULL)
5573 {
5574 croak ("Cdk::Itemlist Could not create widget. Is the window too small?\n");
5575 }
5576 else
5577 {
5578 RETVAL = itemlistWidget;
5579 }
5580 }
5581 OUTPUT:
5582 RETVAL
5583
5584 int
5585 Activate(object,...)
5586 CDKITEMLIST * object
5587 CODE:
5588 {
5589 chtype * Keys;
5590 int arrayLen;
5591 int value;
5592
5593 if (items > 1)
5594 {
5595 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
5596 value = activateCDKItemlist (object, Keys);
5597 free (Keys);
5598 }
5599 else
5600 {
5601 value = activateCDKItemlist (object, NULL);
5602 }
5603
5604 if (object->exitType == vEARLY_EXIT ||
5605 object->exitType == vESCAPE_HIT)
5606 {
5607 XSRETURN_UNDEF;
5608 }
5609 RETVAL = value;
5610 }
5611 OUTPUT:
5612 RETVAL
5613
5614 int
5615 Inject(object,key)
5616 CDKITEMLIST * object
5617 chtype key = sv2chtype ($arg);
5618 CODE:
5619 {
5620 int selection = injectCDKItemlist (object,key);
5621 if (selection == -1)
5622 {
5623 XSRETURN_UNDEF;
5624 }
5625 RETVAL = selection;
5626 }
5627 OUTPUT:
5628 RETVAL
5629
5630 void
5631 Bind(object,key,functionRef)
5632 CDKITEMLIST * object
5633 chtype key = sv2chtype ($arg);
5634 SV * functionRef
5635 CODE:
5636 {
5637 SV *function = newSVsv (functionRef);
5638 bindCDKObject (vITEMLIST, object, key, PerlBindCB, function);
5639 }
5640
5641 int
5642 PreProcess(object,functionRef)
5643 CDKITEMLIST * object
5644 SV * functionRef
5645 CODE:
5646 {
5647 SV *function = newSVsv (functionRef);
5648 setCDKItemlistPreProcess (object, PerlProcessCB, function);
5649 }
5650 OUTPUT:
5651 RETVAL
5652
5653 int
5654 PostProcess(object,functionRef)
5655 CDKITEMLIST * object
5656 SV * functionRef
5657 CODE:
5658 {
5659 SV *function = newSVsv (functionRef);
5660 setCDKItemlistPostProcess (object, PerlProcessCB, function);
5661 }
5662 OUTPUT:
5663 RETVAL
5664
5665 void
5666 SetValues(object,values)
5667 CDKITEMLIST * object
5668 SV * values
5669 CODE:
5670 {
5671 char ** Values;
5672 int valueLength;
5673
5674 MAKE_CHAR_ARRAY(0, values, Values, valueLength);
5675 setCDKItemlistValues (object, Values, valueLength, object->defaultItem);
5676 free (Values);
5677 }
5678
5679 void
5680 SetDefaultItem(object,value)
5681 CDKITEMLIST * object
5682 int value
5683 CODE:
5684 {
5685 setCDKItemlistDefaultItem (object,value);
5686 }
5687
5688 void
5689 SetCurrentItem(object,value)
5690 CDKITEMLIST * object
5691 int value
5692 CODE:
5693 {
5694 setCDKItemlistCurrentItem (object,value);
5695 }
5696
5697 void
5698 SetBox(object,box=TRUE)
5699 CDKITEMLIST * object
5700 int box = sv2int ($arg);
5701 CODE:
5702 {
5703 setCDKItemlistBox (object,box);
5704 }
5705
5706 void
5707 SetULChar(object,character=ACS_ULCORNER)
5708 CDKITEMLIST * object
5709 chtype character = sv2chtype ($arg);
5710 CODE:
5711 {
5712 setCDKItemlistULChar (object,character);
5713 }
5714
5715 void
5716 SetURChar(object,character=ACS_URCORNER)
5717 CDKITEMLIST * object
5718 chtype character = sv2chtype ($arg);
5719 CODE:
5720 {
5721 setCDKItemlistURChar (object,character);
5722 }
5723
5724 void
5725 SetLLChar(object,character=ACS_LLCORNER)
5726 CDKITEMLIST * object
5727 chtype character = sv2chtype ($arg);
5728 CODE:
5729 {
5730 setCDKItemlistLLChar (object,character);
5731 }
5732
5733 void
5734 SetLRChar(object,character=ACS_LRCORNER)
5735 CDKITEMLIST * object
5736 chtype character = sv2chtype ($arg);
5737 CODE:
5738 {
5739 setCDKItemlistLRChar (object,character);
5740 }
5741
5742 void
5743 SetVerticalChar(object,character=ACS_VLINE)
5744 CDKITEMLIST * object
5745 chtype character = sv2chtype ($arg);
5746 CODE:
5747 {
5748 setCDKItemlistVerticalChar (object,character);
5749 }
5750
5751 void
5752 SetHorizontalChar(object,character=ACS_HLINE)
5753 CDKITEMLIST * object
5754 chtype character = sv2chtype ($arg);
5755 CODE:
5756 {
5757 setCDKItemlistHorizontalChar (object,character);
5758 }
5759
5760 void
5761 SetBoxAttribute(object,character=ACS_HLINE)
5762 CDKITEMLIST * object
5763 chtype character = sv2chtype ($arg);
5764 CODE:
5765 {
5766 setCDKItemlistBoxAttribute (object,character);
5767 }
5768
5769 void
5770 SetBackgroundColor(object,color)
5771 CDKITEMLIST * object
5772 char * color
5773 CODE:
5774 {
5775 setCDKItemlistBackgroundColor (object,color);
5776 }
5777
5778 char *
5779 Get(object)
5780 CDKITEMLIST * object
5781 CODE:
5782 {
5783 RETVAL = chtype2Char (object->item[object->currentItem]);
5784 }
5785 OUTPUT:
5786 RETVAL
5787
5788 void
5789 Draw(object,Box=TRUE)
5790 CDKITEMLIST * object
5791 int Box = sv2int ($arg);
5792 CODE:
5793 {
5794 drawCDKItemlist (object,Box);
5795 }
5796
5797 void
5798 Erase(object)
5799 CDKITEMLIST * object
5800 CODE:
5801 {
5802 eraseCDKItemlist (object);
5803 }
5804
5805 void
5806 Register(object)
5807 CDKITEMLIST * object
5808 CODE:
5809 {
5810 registerCDKObject (GCDKSCREEN,vITEMLIST,object);
5811 }
5812
5813 void
5814 Unregister(object)
5815 CDKITEMLIST * object
5816 CODE:
5817 {
5818 unregisterCDKObject (vITEMLIST, object);
5819 }
5820
5821 void
5822 Raise(object)
5823 CDKITEMLIST * object
5824 CODE:
5825 {
5826 raiseCDKObject (vITEMLIST, object);
5827 }
5828
5829 void
5830 Lower(object)
5831 CDKITEMLIST * object
5832 CODE:
5833 {
5834 lowerCDKObject (vITEMLIST, object);
5835 }
5836
5837 WINDOW *
5838 GetWindow(object)
5839 CDKITEMLIST * object
5840 CODE:
5841 {
5842 RETVAL = object->win;
5843 }
5844 OUTPUT:
5845 RETVAL
5846
5847 MODULE = Cdk PACKAGE = Cdk::Fselect
5848 CDKFSELECT *
5849 New(title,label,height,width,dAttrib="</N>",fAttrib="</N>",lAttrib="</N>",sAttrib="</N>",highlight="</R>",fieldAttribute=A_NORMAL,filler=".",xPos=CENTER,yPos=CENTER,box=TRUE,shadow=FALSE)
5850 SV * title
5851 char * label
5852 int height
5853 int width
5854 char * dAttrib
5855 char * fAttrib
5856 char * lAttrib
5857 char * sAttrib
5858 chtype highlight = sv2chtype ($arg);
5859 chtype fieldAttribute = sv2chtype ($arg);
5860 chtype filler = sv2chtype ($arg);
5861 int xPos = sv2int ($arg);
5862 int yPos = sv2int ($arg);
5863 int box = sv2int ($arg);
5864 int shadow = sv2int ($arg);
5865 CODE:
5866 {
5867 CDKFSELECT * fselectWidget = (CDKFSELECT *)NULL;
5868 char * Title;
5869
5870 checkCdkInit();
5871
5872 MAKE_TITLE (title,Title);
5873
5874 fselectWidget = newCDKFselect (GCDKSCREEN,xPos,yPos,
5875 height,width,
5876 Title,label,
5877 fieldAttribute,filler,highlight,
5878 dAttrib,fAttrib,lAttrib,sAttrib,
5879 box,shadow);
5880 free (Title);
5881
5882 /* Check the return type. */
5883 if (fselectWidget == (CDKFSELECT *)NULL)
5884 {
5885 croak ("Cdk::Fselect Could not create widget. Is the window too small?\n");
5886 }
5887 else
5888 {
5889 RETVAL = fselectWidget;
5890 }
5891 }
5892 OUTPUT:
5893 RETVAL
5894
5895 char *
5896 Activate(object,...)
5897 CDKFSELECT * object
5898 CODE:
5899 {
5900 chtype * Keys;
5901 int arrayLen;
5902 char *value;
5903
5904 if (items > 1)
5905 {
5906 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
5907 value = activateCDKFselect (object, Keys);
5908 free (Keys);
5909 }
5910 else
5911 {
5912 value = activateCDKFselect (object, NULL);
5913 }
5914
5915 if (object->exitType == vEARLY_EXIT ||
5916 object->exitType == vESCAPE_HIT)
5917 {
5918 XSRETURN_UNDEF;
5919 }
5920 RETVAL = value;
5921 }
5922 OUTPUT:
5923 RETVAL
5924
5925 char *
5926 Inject(object,key)
5927 CDKFSELECT * object
5928 chtype key = sv2chtype ($arg);
5929 CODE:
5930 {
5931 char *value = injectCDKFselect (object,key);
5932 if (object->exitType == vESCAPE_HIT ||
5933 object->exitType == vEARLY_EXIT)
5934 {
5935 XSRETURN_UNDEF;
5936 }
5937 RETVAL = value;
5938 }
5939 OUTPUT:
5940 RETVAL
5941
5942 void
5943 SetDirectory(object,value)
5944 CDKFSELECT * object
5945 char * value
5946 CODE:
5947 {
5948 setCDKFselectDirectory (object,value);
5949 }
5950
5951 void
5952 SetFillerChar(object,value)
5953 CDKFSELECT * object
5954 chtype value
5955 CODE:
5956 {
5957 setCDKFselectFillerChar (object,value);
5958 }
5959
5960 void
5961 SetHighlight(object,value)
5962 CDKFSELECT * object
5963 chtype value
5964 CODE:
5965 {
5966 setCDKFselectHighlight (object,value);
5967 }
5968
5969 void
5970 SetDirAttribute(object,value)
5971 CDKFSELECT * object
5972 char * value
5973 CODE:
5974 {
5975 setCDKFselectDirAttribute (object,value);
5976 }
5977
5978 void
5979 SetLinkAttribute(object,value)
5980 CDKFSELECT * object
5981 char * value
5982 CODE:
5983 {
5984 setCDKFselectLinkAttribute (object,value);
5985 }
5986
5987 void
5988 SetFileAttribute(object,value)
5989 CDKFSELECT * object
5990 char * value
5991 CODE:
5992 {
5993 setCDKFselectFileAttribute (object,value);
5994 }
5995
5996 void
5997 SetSocketkAttribute(object,value)
5998 CDKFSELECT * object
5999 char * value
6000 CODE:
6001 {
6002 setCDKFselectSocketAttribute (object,value);
6003 }
6004
6005 void
6006 SetBox(object,box=TRUE)
6007 CDKFSELECT * object
6008 int box = sv2int ($arg);
6009 CODE:
6010 {
6011 setCDKFselectBox (object,box);
6012 }
6013
6014 void
6015 SetULChar(object,character=ACS_ULCORNER)
6016 CDKFSELECT * object
6017 chtype character = sv2chtype ($arg);
6018 CODE:
6019 {
6020 setCDKFselectULChar (object,character);
6021 }
6022
6023 void
6024 SetURChar(object,character=ACS_URCORNER)
6025 CDKFSELECT * object
6026 chtype character = sv2chtype ($arg);
6027 CODE:
6028 {
6029 setCDKFselectURChar (object,character);
6030 }
6031
6032 void
6033 SetLLChar(object,character=ACS_LLCORNER)
6034 CDKFSELECT * object
6035 chtype character = sv2chtype ($arg);
6036 CODE:
6037 {
6038 setCDKFselectLLChar (object,character);
6039 }
6040
6041 void
6042 SetLRChar(object,character=ACS_LRCORNER)
6043 CDKFSELECT * object
6044 chtype character = sv2chtype ($arg);
6045 CODE:
6046 {
6047 setCDKFselectLRChar (object,character);
6048 }
6049
6050 void
6051 SetVerticalChar(object,character=ACS_VLINE)
6052 CDKFSELECT * object
6053 chtype character = sv2chtype ($arg);
6054 CODE:
6055 {
6056 setCDKFselectVerticalChar (object,character);
6057 }
6058
6059 void
6060 SetHorizontalChar(object,character=ACS_HLINE)
6061 CDKFSELECT * object
6062 chtype character = sv2chtype ($arg);
6063 CODE:
6064 {
6065 setCDKFselectHorizontalChar (object,character);
6066 }
6067
6068 void
6069 SetBoxAttribute(object,character=ACS_HLINE)
6070 CDKFSELECT * object
6071 chtype character = sv2chtype ($arg);
6072 CODE:
6073 {
6074 setCDKFselectBoxAttribute (object,character);
6075 }
6076
6077 void
6078 SetBackgroundColor(object,color)
6079 CDKFSELECT * object
6080 char * color
6081 CODE:
6082 {
6083 setCDKFselectBackgroundColor (object,color);
6084 }
6085
6086 void
6087 Bind(object,key,functionRef)
6088 CDKFSELECT * object
6089 chtype key = sv2chtype ($arg);
6090 SV * functionRef
6091 CODE:
6092 {
6093 SV *function = newSVsv (functionRef);
6094 bindCDKObject (vFSELECT, object, key, PerlBindCB, function);
6095 }
6096
6097 int
6098 PreProcess(object,functionRef)
6099 CDKFSELECT * object
6100 SV * functionRef
6101 CODE:
6102 {
6103 SV *function = newSVsv (functionRef);
6104 setCDKFselectPreProcess (object, PerlProcessCB, function);
6105 }
6106 OUTPUT:
6107 RETVAL
6108
6109 int
6110 PostProcess(object,functionRef)
6111 CDKFSELECT * object
6112 SV * functionRef
6113 CODE:
6114 {
6115 SV *function = newSVsv (functionRef);
6116 setCDKFselectPostProcess (object, PerlProcessCB, function);
6117 }
6118 OUTPUT:
6119 RETVAL
6120
6121 void
6122 Draw(object,Box=TRUE)
6123 CDKFSELECT * object
6124 int Box = sv2int ($arg);
6125 CODE:
6126 {
6127 drawCDKFselect (object,Box);
6128 }
6129
6130 void
6131 Erase(object)
6132 CDKFSELECT * object
6133 CODE:
6134 {
6135 eraseCDKFselect (object);
6136 }
6137
6138 void
6139 Register(object)
6140 CDKFSELECT * object
6141 CODE:
6142 {
6143 registerCDKObject (GCDKSCREEN,vFSELECT,object);
6144 }
6145
6146 void
6147 Unregister(object)
6148 CDKFSELECT * object
6149 CODE:
6150 {
6151 unregisterCDKObject (vFSELECT, object);
6152 }
6153
6154 void
6155 Raise(object)
6156 CDKFSELECT * object
6157 CODE:
6158 {
6159 raiseCDKObject (vFSELECT, object);
6160 }
6161
6162 void
6163 Lower(object)
6164 CDKFSELECT * object
6165 CODE:
6166 {
6167 lowerCDKObject (vFSELECT, object);
6168 }
6169
6170 WINDOW *
6171 GetWindow(object)
6172 CDKFSELECT * object
6173 CODE:
6174 {
6175 RETVAL = object->win;
6176 }
6177 OUTPUT:
6178 RETVAL
6179
6180 MODULE = Cdk PACKAGE = Cdk::Slider
6181 CDKSLIDER *
6182 New(title,label,start,low,high,inc,fastInc,fieldWidth,xPos,yPos,filler,Box,shadow)
6183 SV * title
6184 char * label
6185 int start
6186 int low
6187 int high
6188 int inc
6189 int fastInc
6190 int fieldWidth
6191 int xPos = sv2int ($arg);
6192 int yPos = sv2int ($arg);
6193 chtype filler = sv2chtype ($arg);
6194 int Box = sv2int ($arg);
6195 int shadow = sv2int ($arg);
6196 CODE:
6197 {
6198 CDKSLIDER * sliderWidget = (CDKSLIDER *)NULL;
6199 char * Title;
6200
6201 checkCdkInit();
6202
6203 MAKE_TITLE (title,Title);
6204
6205 sliderWidget = newCDKSlider (GCDKSCREEN,
6206 xPos,yPos,
6207 Title, label,
6208 filler,fieldWidth,
6209 start,low,high,
6210 inc,fastInc,
6211 Box,shadow);
6212 free (Title);
6213
6214 /* Check the return type. */
6215 if (sliderWidget == (CDKSLIDER *)NULL)
6216 {
6217 croak ("Cdk::Slider Could not create widget. Is the window too small?\n");
6218 }
6219 else
6220 {
6221 RETVAL = sliderWidget;
6222 }
6223 }
6224 OUTPUT:
6225 RETVAL
6226
6227 int
6228 Activate(object,...)
6229 CDKSLIDER * object
6230 CODE:
6231 {
6232 chtype * Keys;
6233 int arrayLen;
6234 int value;
6235
6236 if (items > 1)
6237 {
6238 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
6239 value = activateCDKSlider (object, Keys);
6240 free (Keys);
6241 }
6242 else
6243 {
6244 value = activateCDKSlider (object, (chtype *)NULL);
6245 }
6246
6247 if (object->exitType == vEARLY_EXIT ||
6248 object->exitType == vESCAPE_HIT)
6249 {
6250 XSRETURN_UNDEF;
6251 }
6252 RETVAL = value;
6253 }
6254 OUTPUT:
6255 RETVAL
6256
6257 int
6258 Inject(object,key)
6259 CDKSLIDER * object
6260 chtype key = sv2chtype ($arg);
6261 CODE:
6262 {
6263 int value = injectCDKSlider (object,key);
6264 if (object->exitType == vESCAPE_HIT ||
6265 object->exitType == vEARLY_EXIT)
6266 {
6267 XSRETURN_UNDEF;
6268 }
6269 RETVAL = value;
6270 }
6271 OUTPUT:
6272 RETVAL
6273
6274 void
6275 SetValue(object,value)
6276 CDKSLIDER* object
6277 int value
6278 CODE:
6279 {
6280 setCDKSliderValue (object,value);
6281 }
6282
6283 void
6284 SetLowHigh(object,low,high)
6285 CDKSLIDER * object
6286 int low
6287 int high
6288 CODE:
6289 {
6290 setCDKSliderLowHigh (object,low,high);
6291 }
6292
6293 void
6294 SetBox(object,box=TRUE)
6295 CDKSLIDER * object
6296 int box = sv2int ($arg);
6297 CODE:
6298 {
6299 setCDKSliderBox (object,box);
6300 }
6301
6302 void
6303 SetULChar(object,character=ACS_ULCORNER)
6304 CDKSLIDER * object
6305 chtype character = sv2chtype ($arg);
6306 CODE:
6307 {
6308 setCDKSliderULChar (object,character);
6309 }
6310
6311 void
6312 SetURChar(object,character=ACS_URCORNER)
6313 CDKSLIDER * object
6314 chtype character = sv2chtype ($arg);
6315 CODE:
6316 {
6317 setCDKSliderURChar (object,character);
6318 }
6319
6320 void
6321 SetLLChar(object,character=ACS_LLCORNER)
6322 CDKSLIDER * object
6323 chtype character = sv2chtype ($arg);
6324 CODE:
6325 {
6326 setCDKSliderLLChar (object,character);
6327 }
6328
6329 void
6330 SetLRChar(object,character=ACS_LRCORNER)
6331 CDKSLIDER * object
6332 chtype character = sv2chtype ($arg);
6333 CODE:
6334 {
6335 setCDKSliderLRChar (object,character);
6336 }
6337
6338 void
6339 SetVerticalChar(object,character=ACS_VLINE)
6340 CDKSLIDER * object
6341 chtype character = sv2chtype ($arg);
6342 CODE:
6343 {
6344 setCDKSliderVerticalChar (object,character);
6345 }
6346
6347 void
6348 SetHorizontalChar(object,character=ACS_HLINE)
6349 CDKSLIDER * object
6350 chtype character = sv2chtype ($arg);
6351 CODE:
6352 {
6353 setCDKSliderHorizontalChar (object,character);
6354 }
6355
6356 void
6357 SetBoxAttribute(object,character=ACS_HLINE)
6358 CDKSLIDER * object
6359 chtype character = sv2chtype ($arg);
6360 CODE:
6361 {
6362 setCDKSliderBoxAttribute (object,character);
6363 }
6364
6365 void
6366 SetBackgroundColor(object,color)
6367 CDKSLIDER * object
6368 char * color
6369 CODE:
6370 {
6371 setCDKSliderBackgroundColor (object,color);
6372 }
6373
6374 void
6375 Bind(object,key,functionRef)
6376 CDKSLIDER * object
6377 chtype key = sv2chtype ($arg);
6378 SV * functionRef
6379 CODE:
6380 {
6381 SV *function = newSVsv (functionRef);
6382 bindCDKObject (vSLIDER, object, key, PerlBindCB, function);
6383 }
6384
6385 int
6386 PreProcess(object,functionRef)
6387 CDKSLIDER * object
6388 SV * functionRef
6389 CODE:
6390 {
6391 SV *function = newSVsv (functionRef);
6392 setCDKSliderPreProcess (object, PerlProcessCB, function);
6393 }
6394 OUTPUT:
6395 RETVAL
6396
6397 int
6398 PostProcess(object,functionRef)
6399 CDKSLIDER * object
6400 SV * functionRef
6401 CODE:
6402 {
6403 SV *function = newSVsv (functionRef);
6404 setCDKSliderPostProcess (object, PerlProcessCB, function);
6405 }
6406 OUTPUT:
6407 RETVAL
6408
6409 void
6410 Draw(object,Box=TRUE)
6411 CDKSLIDER * object
6412 int Box = sv2int ($arg);
6413 CODE:
6414 {
6415 drawCDKSlider (object,Box);
6416 }
6417
6418 void
6419 Erase(object)
6420 CDKSLIDER * object
6421 CODE:
6422 {
6423 eraseCDKSlider (object);
6424 }
6425
6426 void
6427 Register(object)
6428 CDKSLIDER * object
6429 CODE:
6430 {
6431 registerCDKObject (GCDKSCREEN,vSLIDER,object);
6432 }
6433
6434 void
6435 Unregister(object)
6436 CDKSLIDER * object
6437 CODE:
6438 {
6439 unregisterCDKObject (vSLIDER, object);
6440 }
6441
6442 void
6443 Raise(object)
6444 CDKSLIDER * object
6445 CODE:
6446 {
6447 raiseCDKObject (vSLIDER, object);
6448 }
6449
6450 void
6451 Lower(object)
6452 CDKSLIDER * object
6453 CODE:
6454 {
6455 lowerCDKObject (vSLIDER, object);
6456 }
6457
6458 WINDOW *
6459 GetWindow(object)
6460 CDKSLIDER * object
6461 CODE:
6462 {
6463 RETVAL = object->win;
6464 }
6465 OUTPUT:
6466 RETVAL
6467
6468 MODULE = Cdk PACKAGE = Cdk::Alphalist
6469 CDKALPHALIST *
6470 New(title,label,list,height,width,xPos,yPos,highlight,filler,box,shadow)
6471 SV * title
6472 char * label
6473 SV * list
6474 int height
6475 int width
6476 chtype highlight = sv2chtype ($arg);
6477 chtype filler = sv2chtype ($arg);
6478 int xPos = sv2int ($arg);
6479 int yPos = sv2int ($arg);
6480 int box = sv2int ($arg);
6481 int shadow = sv2int ($arg);
6482 CODE:
6483 {
6484 CDKALPHALIST * alphalistWidget = (CDKALPHALIST *)NULL;
6485 char ** List;
6486 char * Title;
6487 int listSize;
6488
6489 checkCdkInit();
6490
6491 MAKE_CHAR_ARRAY(0, list, List, listSize);
6492 MAKE_TITLE (title,Title);
6493
6494 alphalistWidget = newCDKAlphalist (GCDKSCREEN,xPos,yPos,
6495 height,width,
6496 Title,label,
6497 List,listSize,
6498 filler,highlight,
6499 box,shadow);
6500 free (List);
6501 free (Title);
6502
6503 /* Check the return type. */
6504 if (alphalistWidget == (CDKALPHALIST *)NULL)
6505 {
6506 croak ("Cdk::Alphalist Could not create widget. Is the window too small?\n");
6507 }
6508 else
6509 {
6510 RETVAL = alphalistWidget;
6511 }
6512 }
6513 OUTPUT:
6514 RETVAL
6515
6516 void
6517 Activate(object,...)
6518 CDKALPHALIST * object
6519 PPCODE:
6520 {
6521 SV *sv = (SV *)&PL_sv_undef;
6522 chtype * Keys;
6523 int arrayLen;
6524 char *value;
6525
6526 if (items > 1)
6527 {
6528 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
6529 value = activateCDKAlphalist (object, Keys);
6530 free (Keys);
6531 }
6532 else
6533 {
6534 value = activateCDKAlphalist (object, NULL);
6535 }
6536
6537 if (object->exitType == vNORMAL)
6538 {
6539 sv = newSVpv (value, strlen (value));
6540 }
6541 XPUSHs (sv);
6542 }
6543
6544 char *
6545 Inject(object,key)
6546 CDKALPHALIST * object
6547 chtype key = sv2chtype ($arg);
6548 CODE:
6549 {
6550 char *value = injectCDKAlphalist (object,key);
6551 if (object->exitType == vESCAPE_HIT ||
6552 object->exitType == vEARLY_EXIT)
6553 {
6554 XSRETURN_UNDEF;
6555 }
6556 RETVAL = value;
6557 }
6558 OUTPUT:
6559 RETVAL
6560
6561 void
6562 SetContents(object,list)
6563 CDKALPHALIST* object
6564 SV * list
6565 CODE:
6566 {
6567 char ** List;
6568 int listSize;
6569
6570 MAKE_CHAR_ARRAY(0, list, List, listSize);
6571 setCDKAlphalistContents (object, List, listSize);
6572 free (List);
6573 }
6574
6575 void
6576 SetFillerChar(object,fille)
6577 CDKALPHALIST* object
6578 chtype filler = sv2chtype ($arg);
6579 CODE:
6580 {
6581 setCDKAlphalistFillerChar (object,filler);
6582 }
6583
6584 void
6585 SetHighlight(object,highlight)
6586 CDKALPHALIST* object
6587 chtype filler = sv2chtype ($arg);
6588 CODE:
6589 {
6590 setCDKAlphalistHighlight (object,filler);
6591 }
6592
6593 void
6594 SetBox(object,box=TRUE)
6595 CDKALPHALIST * object
6596 int box = sv2int ($arg);
6597 CODE:
6598 {
6599 setCDKAlphalistBox (object,box);
6600 }
6601
6602 void
6603 SetULChar(object,character=ACS_ULCORNER)
6604 CDKALPHALIST * object
6605 chtype character = sv2chtype ($arg);
6606 CODE:
6607 {
6608 setCDKAlphalistULChar (object,character);
6609 }
6610
6611 void
6612 SetURChar(object,character=ACS_URCORNER)
6613 CDKALPHALIST * object
6614 chtype character = sv2chtype ($arg);
6615 CODE:
6616 {
6617 setCDKAlphalistURChar (object,character);
6618 }
6619
6620 void
6621 SetLLChar(object,character=ACS_LLCORNER)
6622 CDKALPHALIST * object
6623 chtype character = sv2chtype ($arg);
6624 CODE:
6625 {
6626 setCDKAlphalistLLChar (object,character);
6627 }
6628
6629 void
6630 SetLRChar(object,character=ACS_LRCORNER)
6631 CDKALPHALIST * object
6632 chtype character = sv2chtype ($arg);
6633 CODE:
6634 {
6635 setCDKAlphalistLRChar (object,character);
6636 }
6637
6638 void
6639 SetVerticalChar(object,character=ACS_VLINE)
6640 CDKALPHALIST * object
6641 chtype character = sv2chtype ($arg);
6642 CODE:
6643 {
6644 setCDKAlphalistVerticalChar (object,character);
6645 }
6646
6647 void
6648 SetHorizontalChar(object,character=ACS_HLINE)
6649 CDKALPHALIST * object
6650 chtype character = sv2chtype ($arg);
6651 CODE:
6652 {
6653 setCDKAlphalistHorizontalChar (object,character);
6654 }
6655
6656 void
6657 SetBoxAttribute(object,character=ACS_HLINE)
6658 CDKALPHALIST * object
6659 chtype character = sv2chtype ($arg);
6660 CODE:
6661 {
6662 setCDKAlphalistBoxAttribute (object,character);
6663 }
6664
6665 void
6666 SetBackgroundColor(object,color)
6667 CDKALPHALIST * object
6668 char * color
6669 CODE:
6670 {
6671 setCDKAlphalistBackgroundColor (object,color);
6672 }
6673
6674 char *
6675 Get(object)
6676 CDKALPHALIST * object
6677 CODE:
6678 {
6679 RETVAL = object->entryField->info;
6680 }
6681 OUTPUT:
6682 RETVAL
6683
6684 void
6685 Bind(object,key,functionRef)
6686 CDKALPHALIST * object
6687 chtype key = sv2chtype ($arg);
6688 SV * functionRef
6689 CODE:
6690 {
6691 SV *function = newSVsv (functionRef);
6692 bindCDKObject (vALPHALIST, object, key, PerlBindCB, function);
6693 }
6694
6695 int
6696 PreProcess(object,functionRef)
6697 CDKALPHALIST * object
6698 SV * functionRef
6699 CODE:
6700 {
6701 SV *function = newSVsv (functionRef);
6702 setCDKAlphalistPreProcess (object, PerlProcessCB, function);
6703 }
6704 OUTPUT:
6705 RETVAL
6706
6707 int
6708 PostProcess(object,functionRef)
6709 CDKALPHALIST * object
6710 SV * functionRef
6711 CODE:
6712 {
6713 SV *function = newSVsv (functionRef);
6714 setCDKAlphalistPostProcess (object, PerlProcessCB, function);
6715 }
6716 OUTPUT:
6717 RETVAL
6718
6719 void
6720 Draw(object,Box=TRUE)
6721 CDKALPHALIST * object
6722 int Box = sv2int ($arg);
6723 CODE:
6724 {
6725 drawCDKAlphalist (object,Box);
6726 }
6727
6728 void
6729 Erase(object)
6730 CDKALPHALIST * object
6731 CODE:
6732 {
6733 eraseCDKAlphalist (object);
6734 }
6735
6736 void
6737 Register(object)
6738 CDKALPHALIST * object
6739 CODE:
6740 {
6741 registerCDKObject (GCDKSCREEN,vALPHALIST,object);
6742 }
6743
6744 void
6745 Unregister(object)
6746 CDKALPHALIST * object
6747 CODE:
6748 {
6749 unregisterCDKObject (vALPHALIST, object);
6750 }
6751
6752 void
6753 Raise(object)
6754 CDKALPHALIST * object
6755 CODE:
6756 {
6757 raiseCDKObject (vALPHALIST, object);
6758 }
6759
6760 void
6761 Lower(object)
6762 CDKALPHALIST * object
6763 CODE:
6764 {
6765 lowerCDKObject (vALPHALIST, object);
6766 }
6767
6768 WINDOW *
6769 GetWindow(object)
6770 CDKALPHALIST * object
6771 CODE:
6772 {
6773 RETVAL = object->win;
6774 }
6775 OUTPUT:
6776 RETVAL
6777
6778 MODULE = Cdk PACKAGE = Cdk::Calendar
6779
6780 CDKCALENDAR *
6781 New(title,day,month,year,dayAttrib,monthAttrib,yearAttrib,highlight,xPos=CENTER,yPos=CENTER,Box=TRUE,shadow=FALSE)
6782 SV * title
6783 int day
6784 int month
6785 int year
6786 chtype dayAttrib = sv2chtype ($arg);
6787 chtype monthAttrib = sv2chtype ($arg);
6788 chtype yearAttrib = sv2chtype ($arg);
6789 chtype highlight = sv2chtype ($arg);
6790 int xPos = sv2int ($arg);
6791 int yPos = sv2int ($arg);
6792 int Box = sv2int ($arg);
6793 int shadow = sv2int ($arg);
6794 CODE:
6795 {
6796 CDKCALENDAR * calendarWidget = (CDKCALENDAR *)NULL;
6797 char * Title;
6798
6799 checkCdkInit();
6800
6801 MAKE_TITLE (title,Title);
6802
6803 calendarWidget = newCDKCalendar (GCDKSCREEN,xPos,yPos,Title,
6804 day,month,year,
6805 dayAttrib,monthAttrib,yearAttrib,
6806 highlight,Box,shadow);
6807 free (Title);
6808
6809 /* Check the return type. */
6810 if (calendarWidget == (CDKCALENDAR *)NULL)
6811 {
6812 croak ("Cdk::Calendar Could not create widget. Is the window too small?\n");
6813 }
6814 else
6815 {
6816 RETVAL = calendarWidget;
6817 }
6818 }
6819 OUTPUT:
6820 RETVAL
6821
6822 void
6823 Activate(object,...)
6824 CDKCALENDAR * object
6825 PPCODE:
6826 {
6827 chtype * Keys;
6828 int arrayLen;
6829
6830 if (items > 1)
6831 {
6832 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
6833 activateCDKCalendar (object, Keys);
6834 free (Keys);
6835 }
6836 else
6837 {
6838 activateCDKCalendar (object, NULL);
6839 }
6840
6841 if (object->exitType == vEARLY_EXIT ||
6842 object->exitType == vESCAPE_HIT)
6843 {
6844 XSRETURN_UNDEF;
6845 }
6846
6847 XPUSHs (sv_2mortal(newSViv(object->day)));
6848 XPUSHs (sv_2mortal(newSViv(object->month)));
6849 XPUSHs (sv_2mortal(newSViv(object->year)));
6850 }
6851
6852 void
6853 Inject(object,key)
6854 CDKCALENDAR * object
6855 chtype key = sv2chtype ($arg);
6856 PPCODE:
6857 {
6858 if (object->exitType == vESCAPE_HIT ||
6859 object->exitType == vEARLY_EXIT)
6860 {
6861 XSRETURN_UNDEF;
6862 }
6863
6864 XPUSHs (sv_2mortal(newSViv(object->day)));
6865 XPUSHs (sv_2mortal(newSViv(object->month)));
6866 XPUSHs (sv_2mortal(newSViv(object->year)));
6867 }
6868
6869 void
6870 SetDate(object,day,month,year)
6871 CDKCALENDAR * object
6872 int day
6873 int month
6874 int year
6875 CODE:
6876 {
6877 setCDKCalendarDate (object,day,month,year);
6878 }
6879
6880 void
6881 GetDate(object)
6882 CDKCALENDAR * object
6883 PPCODE:
6884 {
6885 XPUSHs (sv_2mortal(newSViv(object->day)));
6886 XPUSHs (sv_2mortal(newSViv(object->month)));
6887 XPUSHs (sv_2mortal(newSViv(object->year)));
6888 }
6889
6890 void
6891 SetMarker(object,day,month,year,marker)
6892 CDKCALENDAR * object
6893 int day
6894 int month
6895 int year
6896 chtype marker = sv2chtype ($arg);
6897 CODE:
6898 {
6899 setCDKCalendarMarker (object,day,month,year,marker);
6900 }
6901
6902 void
6903 RemoveMarker(object,day,month,year)
6904 CDKCALENDAR * object
6905 int day
6906 int month
6907 int year
6908 CODE:
6909 {
6910 removeCDKCalendarMarker (object,day,month,year);
6911 }
6912
6913 void
6914 SetDayAttribute(object,attribute)
6915 CDKCALENDAR * object
6916 chtype attribute = sv2chtype ($arg);
6917 CODE:
6918 {
6919 setCDKCalendarDayAttribute (object, attribute);
6920 }
6921
6922 void
6923 Bind(object,key,functionRef)
6924 CDKCALENDAR * object
6925 chtype key = sv2chtype ($arg);
6926 SV * functionRef
6927 CODE:
6928 {
6929 SV *function = newSVsv (functionRef);
6930 bindCDKObject (vCALENDAR, object, key, PerlBindCB, function);
6931 }
6932
6933 int
6934 PreProcess(object,functionRef)
6935 CDKCALENDAR * object
6936 SV * functionRef
6937 CODE:
6938 {
6939 SV *function = newSVsv (functionRef);
6940 setCDKCalendarPreProcess (object, PerlProcessCB, function);
6941 }
6942 OUTPUT:
6943 RETVAL
6944
6945 int
6946 PostProcess(object,functionRef)
6947 CDKCALENDAR * object
6948 SV * functionRef
6949 CODE:
6950 {
6951 SV *function = newSVsv (functionRef);
6952 setCDKCalendarPostProcess (object, PerlProcessCB, function);
6953 }
6954 OUTPUT:
6955 RETVAL
6956
6957 void
6958 Draw(object,Box=TRUE)
6959 CDKCALENDAR * object
6960 int Box = sv2int ($arg);
6961 CODE:
6962 {
6963 drawCDKCalendar (object,Box);
6964 }
6965
6966 void
6967 Erase(object)
6968 CDKCALENDAR * object
6969 CODE:
6970 {
6971 eraseCDKCalendar(object);
6972 }
6973
6974 void
6975 Set(object,year,month,day,yearAttrib,monthAttrib,dayAttrib,highlight,Box)
6976 CDKCALENDAR * object
6977 int day
6978 int month
6979 int year
6980 chtype dayAttrib = sv2chtype ($arg);
6981 chtype monthAttrib = sv2chtype ($arg);
6982 chtype yearAttrib = sv2chtype ($arg);
6983 chtype highlight = sv2chtype ($arg);
6984 int Box = sv2int ($arg);
6985 CODE:
6986 {
6987 setCDKCalendar (object,day,month,year,yearAttrib,monthAttrib,dayAttrib,highlight,Box);
6988 }
6989
6990 void
6991 Register(object)
6992 CDKCALENDAR * object
6993 CODE:
6994 {
6995 registerCDKObject (GCDKSCREEN, vCALENDAR, object);
6996 }
6997
6998 void
6999 Unregister(object)
7000 CDKCALENDAR * object
7001 CODE:
7002 {
7003 unregisterCDKObject (vCALENDAR, object);
7004 }
7005
7006 void
7007 Raise(object)
7008 CDKCALENDAR * object
7009 CODE:
7010 {
7011 raiseCDKObject (vCALENDAR, object);
7012 }
7013
7014 void
7015 Lower(object)
7016 CDKCALENDAR * object
7017 CODE:
7018 {
7019 lowerCDKObject (vCALENDAR, object);
7020 }
7021
7022 WINDOW *
7023 GetWindow(object)
7024 CDKCALENDAR * object
7025 CODE:
7026 {
7027 RETVAL = object->win;
7028 }
7029 OUTPUT:
7030 RETVAL
7031
7032 MODULE = Cdk PACKAGE = Cdk::Buttonbox
7033
7034 CDKBUTTONBOX *
7035 New(title,buttons,rows,cols,height,width,xPos=CENTER,yPos=CENTER,highlight=A_REVERSE,Box=TRUE,shadow=FALSE)
7036 SV * title
7037 SV * buttons
7038 int rows
7039 int cols
7040 int height
7041 int width
7042 int xPos = sv2int ($arg);
7043 int yPos = sv2int ($arg);
7044 chtype highlight = sv2chtype ($arg);
7045 int Box = sv2int ($arg);
7046 int shadow = sv2int ($arg);
7047 CODE:
7048 {
7049 CDKBUTTONBOX * widget = (CDKBUTTONBOX *)NULL;
7050 char ** Buttons;
7051 char * Title;
7052 int buttonCount;
7053
7054 checkCdkInit();
7055
7056 MAKE_CHAR_ARRAY (0, buttons, Buttons, buttonCount);
7057 MAKE_TITLE (title,Title);
7058
7059 widget = newCDKButtonbox (GCDKSCREEN, xPos, yPos,
7060 height, width, Title,
7061 rows, cols,
7062 Buttons, buttonCount,
7063 highlight, Box, shadow);
7064 free (Buttons);
7065 free (Title);
7066
7067 /* Check the return type. */
7068 if (widget == (CDKBUTTONBOX *)NULL)
7069 {
7070 croak ("Cdk::Buttonbox Could not create widget. Is the window too small?\n");
7071 }
7072 else
7073 {
7074 RETVAL = widget;
7075 }
7076 }
7077 OUTPUT:
7078 RETVAL
7079
7080 int
7081 Activate(object,...)
7082 CDKBUTTONBOX * object
7083 CODE:
7084 {
7085 chtype * Keys;
7086 int arrayLen;
7087 int value;
7088
7089 if (items > 1)
7090 {
7091 MAKE_CHTYPE_ARRAY(0, ST(1), Keys, arrayLen);
7092 value = activateCDKButtonbox (object, Keys);
7093 free (Keys);
7094 }
7095 else
7096 {
7097 value = activateCDKButtonbox (object, NULL);
7098 }
7099
7100 if (object->exitType == vEARLY_EXIT ||
7101 object->exitType == vESCAPE_HIT)
7102 {
7103 XSRETURN_UNDEF;
7104 }
7105 RETVAL = value;
7106 }
7107 OUTPUT:
7108 RETVAL
7109
7110 int
7111 Inject(object,key)
7112 CDKBUTTONBOX * object
7113 chtype key = sv2chtype ($arg);
7114 CODE:
7115 {
7116 int selection = injectCDKButtonbox (object,key);
7117 if (selection == -1)
7118 {
7119 XSRETURN_UNDEF;
7120 }
7121 RETVAL = selection;
7122 }
7123 OUTPUT:
7124 RETVAL
7125
7126 void
7127 Bind(object,key,functionRef)
7128 CDKBUTTONBOX * object
7129 chtype key = sv2chtype ($arg);
7130 SV * functionRef
7131 CODE:
7132 {
7133 SV *function = newSVsv (functionRef);
7134 bindCDKObject (vBUTTONBOX, object, key, PerlBindCB, function);
7135 }
7136
7137 int
7138 PreProcess(object,functionRef)
7139 CDKBUTTONBOX * object
7140 SV * functionRef
7141 CODE:
7142 {
7143 SV *function = newSVsv (functionRef);
7144 setCDKButtonboxPreProcess (object, PerlProcessCB, function);
7145 }
7146 OUTPUT:
7147 RETVAL
7148
7149 int
7150 PostProcess(object,functionRef)
7151 CDKBUTTONBOX * object
7152 SV * functionRef
7153 CODE:
7154 {
7155 SV *function = newSVsv (functionRef);
7156 setCDKButtonboxPostProcess (object, PerlProcessCB, function);
7157 }
7158 OUTPUT:
7159 RETVAL
7160
7161 void
7162 Draw(object,Box=TRUE)
7163 CDKBUTTONBOX * object
7164 int Box = sv2int ($arg);
7165 CODE:
7166 {
7167 drawCDKButtonbox (object,Box);
7168 }
7169
7170 void
7171 Erase(object)
7172 CDKBUTTONBOX * object
7173 CODE:
7174 {
7175 eraseCDKButtonbox (object);
7176 }
7177
7178 void
7179 SetHighlight(object,highlight=A_REVERSE)
7180 CDKBUTTONBOX * object
7181 chtype highlight = sv2chtype ($arg);
7182 CODE:
7183 {
7184 setCDKButtonboxHighlight (object,highlight);
7185 }
7186
7187 void
7188 SetBox(object,box=TRUE)
7189 CDKBUTTONBOX * object
7190 int box = sv2int ($arg);
7191 CODE:
7192 {
7193 setCDKButtonboxBox (object,box);
7194 }
7195
7196 void
7197 SetULChar(object,character=ACS_ULCORNER)
7198 CDKBUTTONBOX * object
7199 chtype character = sv2chtype ($arg);
7200 CODE:
7201 {
7202 setCDKButtonboxULChar (object,character);
7203 }
7204
7205 void
7206 SetURChar(object,character=ACS_URCORNER)
7207 CDKBUTTONBOX * object
7208 chtype character = sv2chtype ($arg);
7209 CODE:
7210 {
7211 setCDKButtonboxURChar (object,character);
7212 }
7213
7214 void
7215 SetLLChar(object,character=ACS_LLCORNER)
7216 CDKBUTTONBOX * object
7217 chtype character = sv2chtype ($arg);
7218 CODE:
7219 {
7220 setCDKButtonboxLLChar (object,character);
7221 }
7222
7223 void
7224 SetLRChar(object,character=ACS_LRCORNER)
7225 CDKBUTTONBOX * object
7226 chtype character = sv2chtype ($arg);
7227 CODE:
7228 {
7229 setCDKButtonboxLRChar (object,character);
7230 }
7231
7232 void
7233 SetVerticalChar(object,character=ACS_VLINE)
7234 CDKBUTTONBOX * object
7235 chtype character = sv2chtype ($arg);
7236 CODE:
7237 {
7238 setCDKButtonboxVerticalChar (object,character);
7239 }
7240
7241 void
7242 SetHorizontalChar(object,character=ACS_HLINE)
7243 CDKBUTTONBOX * object
7244 chtype character = sv2chtype ($arg);
7245 CODE:
7246 {
7247 setCDKButtonboxHorizontalChar (object,character);
7248 }
7249
7250 void
7251 SetBoxAttribute(object,character=ACS_HLINE)
7252 CDKBUTTONBOX * object
7253 chtype character = sv2chtype ($arg);
7254 CODE:
7255 {
7256 setCDKButtonboxBoxAttribute (object,character);
7257 }
7258
7259 void
7260 SetBackgroundColor(object,color)
7261 CDKBUTTONBOX * object
7262 char * color
7263 CODE:
7264 {
7265 setCDKButtonboxBackgroundColor (object,color);
7266 }
7267
7268 void
7269 Register(object)
7270 CDKBUTTONBOX * object
7271 CODE:
7272 {
7273 registerCDKObject (GCDKSCREEN, vBUTTONBOX, object);
7274 }
7275
7276 void
7277 Unregister(object)
7278 CDKBUTTONBOX * object
7279 CODE:
7280 {
7281 unregisterCDKObject (vBUTTONBOX, object);
7282 }
7283
7284 void
7285 Raise(object)
7286 CDKBUTTONBOX * object
7287 CODE:
7288 {
7289 raiseCDKObject (vBUTTONBOX, object);
7290 }
7291
7292 void
7293 Lower(object)
7294 CDKBUTTONBOX * object
7295 CODE:
7296 {
7297 lowerCDKObject (vBUTTONBOX, object);
7298 }
7299
7300 WINDOW *
7301 GetWindow(object)
7302 CDKBUTTONBOX * object
7303 CODE:
7304 {
7305 RETVAL = object->win;
7306 }
7307 OUTPUT:
7308 RETVAL
7309
7310 MODULE = Cdk PACKAGE = CDKLABELPtr PREFIX = cdk_
7311 void
7312 cdk_DESTROY(object)
7313 CDKLABEL * object
7314 CODE:
7315 {
7316 destroyCDKLabel (object);
7317 }
7318
7319 MODULE = Cdk PACKAGE = CDKBUTTONBOXPtr PREFIX = cdk_
7320 void
7321 cdk_DESTROY(object)
7322 CDKBUTTONBOX * object
7323 CODE:
7324 {
7325 destroyCDKButtonbox (object);
7326 }
7327
7328 MODULE = Cdk PACKAGE = CDKDIALOGPtr PREFIX = cdk_
7329 void
7330 cdk_DESTROY(object)
7331 CDKDIALOG * object
7332 CODE:
7333 {
7334 destroyCDKDialog (object);
7335 }
7336
7337 MODULE = Cdk PACKAGE = CDKENTRYPtr PREFIX = cdk_
7338 void
7339 cdk_DESTROY(object)
7340 CDKENTRY * object
7341 CODE:
7342 {
7343 destroyCDKEntry (object);
7344 }
7345
7346 MODULE = Cdk PACKAGE = CDKSCROLLPtr PREFIX = cdk_
7347 void
7348 cdk_DESTROY(object)
7349 CDKSCROLL * object
7350 CODE:
7351 {
7352 destroyCDKScroll (object);
7353 }
7354
7355 MODULE = Cdk PACKAGE = CDKSCALEPtr PREFIX = cdk_
7356 void
7357 cdk_DESTROY(object)
7358 CDKSCALE * object
7359 CODE:
7360 {
7361 destroyCDKScale (object);
7362 }
7363
7364 MODULE = Cdk PACKAGE = CDKHISTOGRAMPtr PREFIX = cdk_
7365 void
7366 cdk_DESTROY(object)
7367 CDKHISTOGRAM * object
7368 CODE:
7369 {
7370 destroyCDKHistogram (object);
7371 }
7372
7373 MODULE = Cdk PACKAGE = CDKMENUPtr PREFIX = cdk_
7374 void
7375 cdk_DESTROY(object)
7376 CDKMENU * object
7377 CODE:
7378 {
7379 destroyCDKMenu (object);
7380 }
7381
7382 MODULE = Cdk PACKAGE = CDKMENTRYPtr PREFIX = cdk_
7383 void
7384 cdk_DESTROY(object)
7385 CDKMENTRY * object
7386 CODE:
7387 {
7388 destroyCDKMentry (object);
7389 }
7390
7391 MODULE = Cdk PACKAGE = CDKMATRIXPtr PREFIX = cdk_
7392 void
7393 cdk_DESTROY(object)
7394 CDKMATRIX * object
7395 CODE:
7396 {
7397 destroyCDKMatrix (object);
7398 }
7399
7400 MODULE = Cdk PACKAGE = CDKMARQUEEPtr PREFIX = cdk_
7401 void
7402 cdk_DESTROY(object)
7403 CDKMARQUEE * object
7404 CODE:
7405 {
7406 destroyCDKMarquee (object);
7407 }
7408
7409 MODULE = Cdk PACKAGE = CDKSELECTIONPtr PREFIX = cdk_
7410 void
7411 cdk_DESTROY(object)
7412 CDKSELECTION * object
7413 CODE:
7414 {
7415 destroyCDKSelection (object);
7416 }
7417
7418 MODULE = Cdk PACKAGE = CDKVIEWERPtr PREFIX = cdk_
7419 void
7420 cdk_DESTROY(object)
7421 CDKVIEWER * object
7422 CODE:
7423 {
7424 destroyCDKViewer (object);
7425 }
7426
7427 MODULE = Cdk PACKAGE = CDKGRAPHPtr PREFIX = cdk_
7428 void
7429 cdk_DESTROY(object)
7430 CDKGRAPH * object
7431 CODE:
7432 {
7433 destroyCDKGraph (object);
7434 }
7435
7436 MODULE = Cdk PACKAGE = CDKRADIOPtr PREFIX = cdk_
7437 void
7438 cdk_DESTROY(object)
7439 CDKRADIO * object
7440 CODE:
7441 {
7442 destroyCDKRadio (object);
7443 }
7444
7445 MODULE = Cdk PACKAGE = CDKTEMPLATEPtr PREFIX = cdk_
7446 void
7447 cdk_DESTROY(object)
7448 CDKTEMPLATE * object
7449 CODE:
7450 {
7451 destroyCDKTemplate (object);
7452 }
7453
7454 MODULE = Cdk PACKAGE = CDKSWINDOWPtr PREFIX = cdk_
7455 void
7456 cdk_DESTROY(object)
7457 CDKSWINDOW * object
7458 CODE:
7459 {
7460 destroyCDKSwindow (object);
7461 }
7462
7463 MODULE = Cdk PACKAGE = CDKITEMLISTPtr PREFIX = cdk_
7464 void
7465 cdk_DESTROY(object)
7466 CDKITEMLIST * object
7467 CODE:
7468 {
7469 destroyCDKItemlist (object);
7470 }
7471
7472 MODULE = Cdk PACKAGE = CDKFSELECTPtr PREFIX = cdk_
7473 void
7474 cdk_DESTROY(object)
7475 CDKFSELECT * object
7476 CODE:
7477 {
7478 destroyCDKFselect (object);
7479 }
7480
7481 MODULE = Cdk PACKAGE = CDKSLIDERPtr PREFIX = cdk_
7482 void
7483 cdk_DESTROY(object)
7484 CDKSLIDER * object
7485 CODE:
7486 {
7487 destroyCDKSlider (object);
7488 }
7489
7490 MODULE = Cdk PACKAGE = CDKALPHALISTPtr PREFIX = cdk_
7491 void
7492 cdk_DESTROY(object)
7493 CDKALPHALIST * object
7494 CODE:
7495 {
7496 destroyCDKAlphalist (object);
7497 }
7498
7499 MODULE = Cdk PACKAGE = CDKCALENDARPtr PREFIX = cdk_
7500 void
7501 cdk_DESTROY(object)
7502 CDKCALENDAR * object
7503 CODE:
7504 {
7505 destroyCDKCalendar (object);
7506 }
0 Cdk New Widget Guide
1 Copyright Mike Glover, 1995, 1996, 1997, 1998, 1999
2 -------------------------------------------------------------------------------
3
4 If you want to create a new widget for Cdk, and want it in the standard
5 dist of Cdk, you will have to follow some requisites that I have. I state
6 these because Cdk has been worked on for quite some time and I finally
7 got it to a state where the functions calls are somewhat consistent. Any new
8 widgets should adhere to this. The requirements are as follows:
9
10 * The function names should be like:
11 newCDKXXX, destroyCDKXXX, setCDKXXX, drawCDKXX,...
12 Any widgets with functions not in this format should be 'private'.
13 If this is not the case one of three things will happen:
14 1) The widget will not get accepted
15 2) I will mail you back asking you to follow the standards.
16 3) I will do it myself. (HIGHLY unlikely)
17
18 * The first parameter of the newCDKXXX function should be of type
19 CDKSCREEN.
20 * If applicable, the next two parameters should be xpos and ypos in
21 that order.
22 * If applicable, the next two parameters should be the height and
23 width of the widget.
24 * If the widget has a title, the next parameter should be a char *
25 for the title.
26 * If the widget has a label, the next parameter should be a char *
27 for the label.
28 * The last two parameters of the newCDKXXX function should be:
29 Boolean box, Boolean shadow if the parameters apply.
30 * The drawCDKXXX function should only have the pointer to the object and
31 a Boolean box as it's parameters. (in that order)
32 * The first parameters of any other function relating to the widget
33 should be a pointer to the widget type. ie: CDKRADIO *, CDKFSELECT *...
34 * A destroyCDKXXX function has to be provided as well as a drawCDKXXX
35 function.
36 * Try to contain anything specific to the widget in a single file. This
37 keeps the overhead of misc. files from floating around.
38 * Create a standalone header file which includes cdk.h if needed.
39
40 If you follow the guidelines, then the files you need to change to sew the new
41 widget into Cdk, are:
42
43 cdkscreen.c So this widget will get refreshed on a refreshCDKScreen
44 function call.
45 binding.c To allow key bindings for the widget. If it is possible
46 to have key bindings I stress that this be incorporated.
47 cdk.h To add in the function def's to the header file. (ie:
48 include the newly created header file.)
49 Makefile Add in the new widget files.
50
51 If you have done all of this then what I need from you is the following:
52
53 * A diff of all the files from the dist. that you modified. Use
54 patch, I prefer it. If you haven't got it, get it and use it. It makes
55 life easy.
56 * A copy of the new widget file.
57 * tar this up and send it to me at
58 glover@credit.erin.utoronto.ca or at mike@vexus.ca
59 I will mail you back when I get it and I will tell you if everything is
60 OK or not.
61
62 I hate to be such a nit pick, but if we follow the above standards, Cdk will
63 evolve into a very nice library, with a lot of really nice widgets.
64
65 If you want to get a hold of me mail me at one of the following:
66 glover@credit.erin.utoronto.ca
67 mike@vexus.ca
68
69 The CDK Web page has several homes. They are:
70 http://www.vexus.ca/CDK.html (official)
71 http://www.datasoft.on.ca/~cdk (Sponsored by the nice folks at Datasoft)
72
73
74 ttfn,
75 Mike
0 Cdk Installation Guide
1 -------------------------------------------------------------------------------
2
3 Cdk should build/work on any Unix system running SVr4 curses or X/Open curses.
4
5 The original INSTALL notes follow:
6
7 -------------------------------------------------------------------------------
8 Copyright Mike Glover, 1995, 1996, 1997, 1998, 1999
9 -------------------------------------------------------------------------------
10
11 General
12 -------
13 This document details how to build and install the Cdk library. The first thing
14 you should know is what compile options you may require. I have had the
15 fortunate luck of being able to compile this library on the following
16 platforms:
17 * Sun/OS 4.1.*
18 * Solaris 2.3/2.4/2.5/2.5.1/2.6
19 * AIX 3.2.* (and even AIX 4.1 but there is no mention of this in the
20 makefile. Sorry.)
21 * HPUX 9.* (and even HPUX 10.* but there is no mention of this in the
22 makefile. Sorry.)
23 * Linux (all sorts Slackware, BSD, and Redhat)
24
25 Building
26 --------
27 To build the library cd into the Cdk distribution directory and follow
28 the following steps:
29
30 1) Run configure. This will create a Makefile with a default
31 install directory root of /usr/local. If you want to
32 change the default install directory use the --prefix
33 command line argument on configure. For example, if you
34 want to install under /export/local instead, run the command:
35 ./configure --prefix="/export/local"
36
37 2) Type make. This will make the library, the example binaries
38 and the demonstration binaries.
39
40 3) Type make install. This will install the CDK distribution. Look
41 at step 1 if you want to install other than /usr/local.
42
43 4) Start to play. :)
44
45 If you want to get a hold of me mail me at one of the following:
46 glover@credit.erin.utoronto.ca
47 mike@vexus.ca
48
49 The CDK Web page has several homes. They are:
50 http://www.vexus.ca/CDK.html (official)
51 http://www.datasoft.on.ca/~cdk (Sponsered by the nice folks at Datasoft)
52
53 ttfn,
54 Mike
+0
-106
MANIFEST less more
0 MANIFEST for cdk-perl-20031210, version t031210
1 --------------------------------------------------------------------------------
2 MANIFEST this file
3 CHANGES changelog for Perl/Cdk
4 COPYING copyright notice
5 Cdk.pm perl module for Cdk
6 Cdk.xs perl interface to Cdk
7 Makefile.PL perl makefile template
8 README overview (read this first)
9 fixpaths script to fix pathnames of perl in perl-scripts
10 typemap mapping between Perl and C parameter types
11 Cdk subdirectory
12 Cdk/Alphalist.pm Cdk::Alphalist package
13 Cdk/Buttonbox.pm Cdk::Buttonbox package
14 Cdk/Calendar.pm Cdk::Calendar package
15 Cdk/Debug.pm Cdk::Debug package
16 Cdk/Diag.pm Cdk::Diag package
17 Cdk/Dialog.pm Cdk::Dialog package
18 Cdk/Entry.pm Cdk::Entry package
19 Cdk/Fselect.pm Cdk::Fselect package
20 Cdk/Graph.pm Cdk::Graph package
21 Cdk/Histogram.pm Cdk::Histogram package
22 Cdk/Itemlist.pm Cdk::Itemlist package
23 Cdk/Label.pm Cdk::Label package
24 Cdk/Marquee.pm Cdk::Marquee package
25 Cdk/Matrix.pm Cdk::Matrix package
26 Cdk/Mentry.pm Cdk::Mentry package
27 Cdk/Menu.pm Cdk::Menu package
28 Cdk/Radio.pm Cdk::Radio package
29 Cdk/Scale.pm Cdk::Scale package
30 Cdk/Scroll.pm Cdk::Scroll package
31 Cdk/Selection.pm Cdk::Selection package
32 Cdk/Slider.pm Cdk::Slider package
33 Cdk/Swindow.pm Cdk::Swindow package
34 Cdk/Template.pm Cdk::Template package
35 Cdk/Viewer.pm Cdk::Viewer package
36 demos subdirectory
37 demos/async Demonstrates how to manipulate defined widgets asynchronously.
38 demos/bday Demonstrates how to use the calendar widget.
39 demos/perlbug Rips off Larry's utils/perlbug program.
40 demos/pkgInfo Basic Solaris package install/remove program.
41 demos/pwdInfo Basic password file browser.
42 demos/rolodex Comprehensive personal rolodex.
43 demos/workman A workman database editor
44 examples subdirectory
45 examples/alphalist Demonstrates the alphalist widget.
46 examples/bind Demonstrates how to use the bind function.
47 examples/buttonbox Demonstrates the buttonbox widget.
48 examples/calendar Demonstrates the calendar widget.
49 examples/dialog Demonstrates the dialog widget.
50 examples/entry Demonstrates the entry widget.
51 examples/fselect Demonstrates the file selector widget.
52 examples/graph Demonstrates the graph widget.
53 examples/histogram Demonstrates the histogram widget.
54 examples/itemlist Demonstrates the itemlist widget.
55 examples/label Demonstrates the label widget.
56 examples/marquee Demonstrates the marquee widget.
57 examples/matrix Demonstrates the matrix widget.
58 examples/mentry Demonstrates the mentry widget.
59 examples/menu Demonstrates the menu widget.
60 examples/postProcess Demonstrates how to use the post-process capabilities.
61 examples/preProcess Demonstrates how to use the pre-process capabilities.
62 examples/radio Demonstrates the radio-button widget.
63 examples/scale Demonstrates the scale widget.
64 examples/scroll Demonstrates the scroll widget.
65 examples/selection Demonstrates the selection widget.
66 examples/slider Demonstrates the slider widget.
67 examples/swindow Demonstrates the scrolling window widget.
68 examples/template Demonstrates the template widget.
69 examples/viewer Demonstrates the viewer widget.
70 fulldemo subdirectory
71 fulldemo/cdkdemo combines all of the widgets via pulldown-menus
72 fulldemo/help subdirectory
73 fulldemo/help/alphalist.help description of alphalist-widget
74 fulldemo/help/binding.help description of binding-widget
75 fulldemo/help/bugs.help known bugs in Perl+Cdk
76 fulldemo/help/calendar.help description of calendar-widget
77 fulldemo/help/charfile.help using line-drawing graphics in Perl+Cdk
78 fulldemo/help/colors.help how to use color in Perl+Cdk
79 fulldemo/help/concepts.help concepts & terminology used in Perl+Cdk
80 fulldemo/help/debug.help comments on debugging Perl+Cdk
81 fulldemo/help/dialog.help description of dialog-widget
82 fulldemo/help/display.help notes on display-options
83 fulldemo/help/entry.help description of entry-widget
84 fulldemo/help/fselect.help description of fselect-widget
85 fulldemo/help/future.help wishlist/future development
86 fulldemo/help/general.help general comments on Perl+Cdk
87 fulldemo/help/graph.help description of graph-widget
88 fulldemo/help/histogram.help description of histogram-widget
89 fulldemo/help/itemlist.help description of itemlist-widget
90 fulldemo/help/label.help description of label-widget
91 fulldemo/help/marquee.help description of marquee-widget
92 fulldemo/help/matrix.help description of matrix-widget
93 fulldemo/help/mentry.help description of mentry-widget
94 fulldemo/help/menu.help description of menu-widget
95 fulldemo/help/postprocess.help description of postprocess-widget
96 fulldemo/help/preprocess.help description of preprocess-widget
97 fulldemo/help/radio.help description of radio-widget
98 fulldemo/help/scale.help description of scale-widget
99 fulldemo/help/scroll.help description of scroll-widget
100 fulldemo/help/selection.help description of selection-widget
101 fulldemo/help/slider.help description of slider-widget
102 fulldemo/help/special.help special keywords used in Cdk's viewer
103 fulldemo/help/swindow.help description of swindow-widget
104 fulldemo/help/template.help description of template-widget
105 fulldemo/help/viewer.help description of viewer-widget
+0
-101
MANIFEST.bak less more
0 MANIFEST for cdk-perl-20020728, version t020728
1
2 MANIFEST this file
3 CHANGES changelog for Perl/Cdk
4 COPYING copyright notice
5 Cdk.pm perl module for Cdk
6 Cdk.xs perl interface to Cdk
7 Makefile.PL perl makefile template
8 README overview (read this first)
9 fixpaths script to fix pathnames of perl in perl-scripts
10 typemap mapping between Perl and C parameter types
11 Cdk/Alphalist.pm Cdk::Alphalist package
12 Cdk/Buttonbox.pm Cdk::Buttonbox package
13 Cdk/Calendar.pm Cdk::Calendar package
14 Cdk/Debug.pm Cdk::Debug package
15 Cdk/Diag.pm Cdk::Diag package
16 Cdk/Dialog.pm Cdk::Dialog package
17 Cdk/Entry.pm Cdk::Entry package
18 Cdk/Fselect.pm Cdk::Fselect package
19 Cdk/Graph.pm Cdk::Graph package
20 Cdk/Histogram.pm Cdk::Histogram package
21 Cdk/Itemlist.pm Cdk::Itemlist package
22 Cdk/Label.pm Cdk::Label package
23 Cdk/Marquee.pm Cdk::Marquee package
24 Cdk/Matrix.pm Cdk::Matrix package
25 Cdk/Mentry.pm Cdk::Mentry package
26 Cdk/Menu.pm Cdk::Menu package
27 Cdk/Radio.pm Cdk::Radio package
28 Cdk/Scale.pm Cdk::Scale package
29 Cdk/Scroll.pm Cdk::Scroll package
30 Cdk/Selection.pm Cdk::Selection package
31 Cdk/Slider.pm Cdk::Slider package
32 Cdk/Swindow.pm Cdk::Swindow package
33 Cdk/Template.pm Cdk::Template package
34 Cdk/Viewer.pm Cdk::Viewer package
35 demos/async Demonstrates how to manipulate defined widgets asynchronously.
36 demos/bday Demonstrates how to use the calendar widget.
37 demos/perlbug Rips off Larry's utils/perlbug program.
38 demos/pkgInfo Basic Solaris package install/remove program.
39 demos/pwdInfo Basic password file browser.
40 demos/rolodex Comprehensive personal rolodex.
41 demos/workman A workman database editor
42 examples/alphalist Demonstrates the alphalist widget.
43 examples/bind Demonstrates how to use the bind function.
44 examples/buttonbox Demonstrates the buttonbox widget.
45 examples/calendar Demonstrates the calendar widget.
46 examples/dialog Demonstrates the dialog widget.
47 examples/entry Demonstrates the entry widget.
48 examples/fselect Demonstrates the file selector widget.
49 examples/graph Demonstrates the graph widget.
50 examples/histogram Demonstrates the histogram widget.
51 examples/itemlist Demonstrates the itemlist widget.
52 examples/label Demonstrates the label widget.
53 examples/marquee Demonstrates the marquee widget.
54 examples/matrix Demonstrates the matrix widget.
55 examples/mentry Demonstrates the mentry widget.
56 examples/menu Demonstrates the menu widget.
57 examples/postProcess Demonstrates how to use the post-process capabilities.
58 examples/preProcess Demonstrates how to use the pre-process capabilities.
59 examples/radio Demonstrates the radio-button widget.
60 examples/scale Demonstrates the scale widget.
61 examples/scroll Demonstrates the scroll widget.
62 examples/selection Demonstrates the selection widget.
63 examples/slider Demonstrates the slider widget.
64 examples/swindow Demonstrates the scrolling window widget.
65 examples/template Demonstrates the template widget.
66 examples/viewer Demonstrates the viewer widget.
67 fulldemo/cdkdemo combines all of the widgets via pulldown-menus
68 fulldemo/help/alphalist.help description of alphalist-widget
69 fulldemo/help/binding.help description of binding-widget
70 fulldemo/help/bugs.help known bugs in Perl+Cdk
71 fulldemo/help/calendar.help description of calendar-widget
72 fulldemo/help/charfile.help using line-drawing graphics in Perl+Cdk
73 fulldemo/help/colors.help how to use color in Perl+Cdk
74 fulldemo/help/concepts.help concepts & terminology used in Perl+Cdk
75 fulldemo/help/debug.help comments on debugging Perl+Cdk
76 fulldemo/help/dialog.help description of dialog-widget
77 fulldemo/help/display.help notes on display-options
78 fulldemo/help/entry.help description of entry-widget
79 fulldemo/help/fselect.help description of fselect-widget
80 fulldemo/help/future.help wishlist/future development
81 fulldemo/help/general.help general comments on Perl+Cdk
82 fulldemo/help/graph.help description of graph-widget
83 fulldemo/help/histogram.help description of histogram-widget
84 fulldemo/help/itemlist.help description of itemlist-widget
85 fulldemo/help/label.help description of label-widget
86 fulldemo/help/marquee.help description of marquee-widget
87 fulldemo/help/matrix.help description of matrix-widget
88 fulldemo/help/mentry.help description of mentry-widget
89 fulldemo/help/menu.help description of menu-widget
90 fulldemo/help/postprocess.help description of postprocess-widget
91 fulldemo/help/preprocess.help description of preprocess-widget
92 fulldemo/help/radio.help description of radio-widget
93 fulldemo/help/scale.help description of scale-widget
94 fulldemo/help/scroll.help description of scroll-widget
95 fulldemo/help/selection.help description of selection-widget
96 fulldemo/help/slider.help description of slider-widget
97 fulldemo/help/special.help special keywords used in Cdk's viewer
98 fulldemo/help/swindow.help description of swindow-widget
99 fulldemo/help/template.help description of template-widget
100 fulldemo/help/viewer.help description of viewer-widget
+0
-19
Makefile.PL less more
0 #
1 # $Author: tom $
2 # $Date: 2002/07/28 19:09:50 $
3 # $Revision: 1.6 $
4 #
5 use ExtUtils::MakeMaker;
6
7 #
8 # See README and Perl's MakeMaker.pm for guidance in modifying the
9 # LIBS and INC strings.
10 #
11
12 WriteMakefile(
13 'NAME' => 'Cdk',
14 'VERSION' => '4.09010',
15 'LIBS' => ['-L/usr/local/lib -lcdk -lcurses'],
16 'INC' => '-I/usr/include/ncurses -I/usr/local/include/cdk',
17 'clean' => {FILES => 'Makefile.old'},
18 );
0 # $Id: Makefile.in,v 1.74 2006/04/17 23:13:49 tom Exp $
1 #
2 # Copyright 2001-2005,2006 Thomas Dickey
3 # Copyright 1999, Mike Glover
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # 3. All advertising materials mentioning features or use of this software
15 # must display the following acknowledgment:
16 # This product includes software developed by Mike Glover
17 # and contributors.
18 # 4. Neither the name of Mike Glover, nor the names of contributors
19 # may be used to endorse or promote products derived from this software
20 # without specific prior written permission.
21 #
22 # THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
23 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 # ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
26 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 # SUCH DAMAGE.
33 #
34 SHELL = /bin/sh
35 @SET_MAKE@
36 MAKE_RECUR = @cf_cv_makeflags@ prefix=$(prefix)
37
38 LIB_ROOTNAME = @LIB_ROOTNAME@
39 LIB_SUFFIX = @LIB_SUFFIX@
40
41 VERSION_MAJOR = @VERSION_MAJOR@
42 VERSION_MINOR = @VERSION_MINOR@
43 VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
44 CDKLIB = @LIB_PREFIX@@LIB_ROOTNAME@$(LIB_SUFFIX)
45 CDKSHLIB = @LIB_PREFIX@@LIB_ROOTNAME@.so.$(VERSION)
46 SONAME = @LIB_PREFIX@@LIB_ROOTNAME@.so.$(VERSION_MAJOR)
47
48 prefix = @prefix@
49 exec_prefix = @exec_prefix@
50
51 srcdir = @srcdir@
52 VPATH = $(srcdir)
53
54 x = @EXEEXT@
55 o = .@OBJEXT@
56 a = @LIB_SUFFIX@
57
58 DESTDIR =
59 includedir = $(DESTDIR)@includedir@
60 libdir = $(DESTDIR)@libdir@
61 mandir = $(DESTDIR)@mandir@
62
63 DOCUMENT_DIR = @prefix@/doc/cdk
64 INCLUDE_DIR = $(includedir)/cdk
65 LIB_DIR = $(libdir)
66 MAN_DIR = $(mandir)/man@MAN_DIR@
67 MANSECT = @MANSECT@
68
69 CC = @CC@
70 CPP = @CPP@
71 AR = @AR@
72 RANLIB = @LIB_PREP@
73 RM = rm -f
74
75 LIBS = @LIBS@
76
77 CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@
78 CPPFLAGS = @DEFS@ -I./include -I$(srcdir)/include @CPPFLAGS@
79
80 LDFLAGS = @LDFLAGS@
81
82 LIBTOOL = @LIBTOOL@ @ECHO_LT@
83 LIBTOOL_CLEAN = @LIB_CLEAN@
84 LIBTOOL_COMPILE = @LIB_COMPILE@
85 LIBTOOL_CREATE = @LIB_CREATE@
86 LIBTOOL_LINK = @LIB_LINK@
87 LIBTOOL_INSTALL = @LIB_INSTALL@
88 LIBTOOL_UNINSTALL = @LIB_UNINSTALL@
89
90 INSTALL = @INSTALL@
91 INSTALL_PROGRAM = $(LIBTOOL_INSTALL) @INSTALL_PROGRAM@
92 INSTALL_DATA = @INSTALL_DATA@
93 INSTALL_LIB = $(LIBTOOL_INSTALL) $(INSTALL_DATA)
94 UNINSTALL_LIB = $(LIBTOOL_UNINSTALL) $(RM)
95
96 .SUFFIXES: .c .o .os .i
97
98 DEFAULT = $(CDKLIB)
99
100 default :: $(DEFAULT)
101
102 #
103 # Create the file lists.
104 #
105 AUTO_HDR = \
106 include/dscale.h \
107 include/fscale.h \
108 include/fslider.h \
109 include/scale.h \
110 include/slider.h \
111 include/uscale.h \
112 include/uslider.h
113
114 AUTO_SRC = \
115 dscale.c \
116 fscale.c \
117 fslider.c \
118 scale.c \
119 slider.c \
120 uscale.c \
121 uslider.c
122
123 AUTO_MAN = \
124 man/cdk_dscale.3 \
125 man/cdk_fscale.3 \
126 man/cdk_fslider.3 \
127 man/cdk_scale.3 \
128 man/cdk_slider.3 \
129 man/cdk_uscale.3 \
130 man/cdk_uslider.3
131
132 MY_HDR = \
133 include/cdk_config.h \
134 $(AUTO_HDR)
135
136 CDKHDR = \
137 alphalist.h \
138 binding.h \
139 button.h \
140 buttonbox.h \
141 calendar.h \
142 cdk.h \
143 cdk_compat.h \
144 cdk_objs.h \
145 cdk_params.h \
146 cdk_util.h \
147 cdk_version.h \
148 cdkscreen.h \
149 curdefs.h \
150 dialog.h \
151 draw.h \
152 entry.h \
153 fselect.h \
154 graph.h \
155 histogram.h \
156 itemlist.h \
157 label.h \
158 marquee.h \
159 matrix.h \
160 mentry.h \
161 menu.h \
162 radio.h \
163 scroll.h \
164 selection.h \
165 swindow.h \
166 template.h \
167 traverse.h \
168 viewer.h
169
170 CDKSRC = \
171 $(AUTO_SRC) \
172 alphalist.c \
173 binding.c \
174 button.c \
175 buttonbox.c \
176 calendar.c \
177 cdk.c \
178 cdk_compat.c \
179 cdk_display.c \
180 cdk_objs.c \
181 cdk_params.c \
182 cdkscreen.c \
183 debug.c \
184 dialog.c \
185 draw.c \
186 entry.c \
187 fselect.c \
188 get_index.c \
189 get_string.c \
190 graph.c \
191 histogram.c \
192 itemlist.c \
193 label.c \
194 marquee.c \
195 matrix.c \
196 mentry.c \
197 menu.c \
198 popup_dialog.c \
199 popup_label.c \
200 position.c \
201 radio.c \
202 scroll.c \
203 selection.c \
204 swindow.c \
205 select_file.c \
206 template.c \
207 traverse.c \
208 version.c \
209 view_file.c \
210 view_info.c \
211 viewer.c
212
213 CDKMAN = \
214 cdk.3 \
215 cdk_alphalist.3 \
216 cdk_binding.3 \
217 cdk_button.3 \
218 cdk_buttonbox.3 \
219 cdk_calendar.3 \
220 cdk_compat.3 \
221 cdk_dialog.3 \
222 cdk_display.3 \
223 cdk_draw.3 \
224 cdk_entry.3 \
225 cdk_fscale.3 \
226 cdk_fselect.3 \
227 cdk_graph.3 \
228 cdk_histogram.3 \
229 cdk_itemlist.3 \
230 cdk_label.3 \
231 cdk_marquee.3 \
232 cdk_matrix.3 \
233 cdk_mentry.3 \
234 cdk_menu.3 \
235 cdk_misc.3 \
236 cdk_objs.3 \
237 cdk_params.3 \
238 cdk_position.3 \
239 cdk_process.3 \
240 cdk_radio.3 \
241 cdk_scale.3 \
242 cdk_screen.3 \
243 cdk_scroll.3 \
244 cdk_selection.3 \
245 cdk_swindow.3 \
246 cdk_template.3 \
247 cdk_traverse.3 \
248 cdk_util.3 \
249 cdk_viewer.3
250
251 CDKREADME = EXPANDING NOTES TODO COPYING INSTALL README
252
253 OBJECTS = $(CDKSRC:.c=.o)
254 CDKSHOBJS = $(CDKSRC:.c=.os)
255 LIB_OBJECT = @LIB_OBJECT@
256
257 all sources :: $(AUTO_SRC)
258
259 $(OBJECTS) : include/cdk_config.h
260
261 #
262 # Standard library directive.
263 #
264 all cdklib :: $(DEFAULT)
265
266 $(CDKLIB) :: $(OBJECTS)
267 @echo creating $@; $(LIBTOOL_CREATE) $@ $(LIB_OBJECT)
268 @$(RANLIB) $@
269
270 cdkshlib $(CDKSHLIB) :: $(CDKSHOBJS)
271 gcc -shared -Wl,-soname=$(SONAME) $(LDFLAGS) -o $(CDKSHLIB) $(CDKSHOBJS)
272
273 #
274 # Make the examples directory.
275 #
276 all examples ::
277 cd examples && $(MAKE) $(MAKE_RECUR)
278
279 #
280 # Make the demos directory.
281 #
282 all demos ::
283 cd demos && $(MAKE) $(MAKE_RECUR)
284
285 #
286 # Make the cli directory.
287 #
288 all cli ::
289 cd cli && $(MAKE) $(MAKE_RECUR)
290
291 #
292 # Make the generated manpages.
293 #
294 all manpages :: $(AUTO_MAN)
295
296 # Order of install-targets should match the order of uninstalls. Put the
297 # documentation first, then the headers, and finally the library:
298 # (un)installCDKReadme
299 # (un)installCDKManPages
300 # (un)installCDKHeaderFiles
301 # (un)installCDKLibrary
302
303 #
304 # This installs the informational readme files.
305 #
306 install \
307 installCDKReadme :: $(DOCUMENT_DIR)
308 @echo "Installing CDK Readme files in $(DOCUMENT_DIR)..."
309 @for i in $(CDKREADME); do \
310 echo " ... $$i"; \
311 $(INSTALL_DATA) $(srcdir)/$$i $(DOCUMENT_DIR)/$$i; \
312 done
313
314 uninstall \
315 uninstallCDKReadme ::
316 @echo "Uninstalling CDK Readme files from $(DOCUMENT_DIR)..."
317 @- for i in $(CDKREADME); do \
318 $(RM) $(DOCUMENT_DIR)/$$i; \
319 done
320
321 #
322 # This installs the CDK man pages.
323 #
324 install \
325 installCDKManPages :: $(INCLUDE_DIR) headers.sed $(MAN_DIR) manpage.sed $(AUTO_MAN)
326 @echo "Installing the CDK man pages in $(MAN_DIR) ..."
327 @for i in $(AUTO_MAN); do \
328 $(SHELL) $(srcdir)/headers.sh \
329 -x "$(INSTALL_DATA)" \
330 -d $(MAN_DIR) \
331 -s . \
332 -t $(MANSECT) \
333 -e manpage.sed $$i; \
334 $(SHELL) $(srcdir)/manlinks.sh installing $(srcdir) $(MAN_DIR) $(MANSECT) $$i; \
335 done
336 @for i in $(CDKMAN); do \
337 $(SHELL) $(srcdir)/headers.sh \
338 -x "$(INSTALL_DATA)" \
339 -d $(MAN_DIR) \
340 -s . \
341 -t $(MANSECT) \
342 -e manpage.sed $(srcdir)/man/$$i; \
343 $(SHELL) $(srcdir)/manlinks.sh installing $(srcdir) $(MAN_DIR) $(MANSECT) $(srcdir)/man/$$i; \
344 done
345
346 uninstall \
347 uninstallCDKManPages ::
348 @echo "Uninstalling the CDK man pages from $(MAN_DIR) ..."
349 @- for i in $(AUTO_MAN); do \
350 $(SHELL) $(srcdir)/manlinks.sh removing $(srcdir) $(MAN_DIR) $(MANSECT) $(srcdir)/$$i; \
351 done
352 @- for i in $(CDKMAN); do \
353 $(SHELL) $(srcdir)/manlinks.sh removing $(srcdir) $(MAN_DIR) $(MANSECT) $(srcdir)/man/$$i; \
354 done
355
356 #
357 # This installs the header files.
358 #
359 install \
360 installCDKHeaderFiles :: $(INCLUDE_DIR) headers.sed $(MY_HDR)
361 @echo "Installing CDK header files in $(INCLUDE_DIR)..."
362 $(SHELL) $(srcdir)/headers.sh -x "$(INSTALL_DATA)" -d $(INCLUDE_DIR) -s $(srcdir) $(MY_HDR)
363 @for i in $(CDKHDR); do \
364 $(SHELL) $(srcdir)/headers.sh -x "$(INSTALL_DATA)" -d $(INCLUDE_DIR) -s $(srcdir) include/$$i; \
365 done
366
367 uninstall \
368 uninstallCDKHeaderFiles ::
369 @echo "Uninstalling CDK header files from $(INCLUDE_DIR)..."
370 @- for i in $(MY_HDR); do \
371 $(RM) $(INCLUDE_DIR)/`basename $$i`; \
372 done
373 @- for i in $(CDKHDR); do \
374 $(RM) $(INCLUDE_DIR)/$$i; \
375 done
376
377 #
378 # This installs the CDK library.
379 #
380 install \
381 installCDKLibrary :: $(LIB_DIR) $(CDKLIB)
382 @echo "Installing CDK library"
383 @$(INSTALL_LIB) $(CDKLIB) $(LIB_DIR)/$(CDKLIB)
384
385 uninstall \
386 uninstallCDKLibrary ::
387 @echo "Uninstalling CDK library"
388 @- $(UNINSTALL_LIB) $(LIB_DIR)/$(CDKLIB)
389
390 #
391 # This installs the CDK shared library. The rules are for an RPM spec, and
392 # not of general interest.
393 #
394 installCDKSHLibrary :: $(LIB_DIR) $(CDKSHLIB)
395 @echo "Installing CDK library"
396 @echo " $(INSTALL_DATA) $(CDKSHLIB) $(LIB_DIR)"
397 @$(INSTALL_DATA) $(CDKSHLIB) $(LIB_DIR)
398 @echo " ln -sf $(CDKSHLIB) $(LIB_DIR)/@LIB_PREFIX@@LIB_ROOTNAME@.so"
399 @ln -sf $(CDKSHLIB) $(LIB_DIR)/@LIB_PREFIX@@LIB_ROOTNAME@.so
400
401 uninstall \
402 uninstallCDKSHLibrary ::
403 @- $(RM) $(LIB_DIR)/@LIB_PREFIX@@LIB_ROOTNAME@.so
404 @- $(RM) $(LIB_DIR)/$(CDKSHLIB)
405
406 headers.sed : $(srcdir)/headers.sh
407 $(SHELL) $(srcdir)/headers.sh -p CDK -c include/cdk_config.h -d $(INCLUDE_DIR) -s $(srcdir)/include -i -s include -i
408
409 manpage.sed :
410 @echo "creating $@"
411 @echo "s/(3)/($(MANSECT))/g" >$@
412 @echo "/^\.TH/s/\<3\>/$(MANSECT)/" >>$@
413
414 @MAKE_LOWER_TAGS@tags :
415 @MAKE_LOWER_TAGS@ ctags *.[ch] */*.[ch]
416
417 @MAKE_LOWER_TAGS@TAGS :
418 @MAKE_LOWER_TAGS@ etags *.[ch] */*.[ch]
419
420 #
421 # Clean up after ourselves...
422 #
423 clean ::
424 @- $(RM) -r autom4te.cache
425 - $(LIBTOOL_CLEAN) $(RM) $(LIB_OBJECT) $(CDKLIB)
426 - $(RM) *.i *.os $(CDKSHLIB)
427 - $(RM) headers.sed manpage.sed core tags *~
428 $(RM) $(AUTO_HDR)
429 $(RM) $(AUTO_SRC)
430 $(RM) $(AUTO_MAN)
431
432 realclean :: clean
433 cd examples && $(MAKE) $(MAKE_RECUR) clean
434 cd demos && $(MAKE) $(MAKE_RECUR) clean
435 cd cli && $(MAKE) $(MAKE_RECUR) clean
436
437 #
438 # Use this to clean the distribution.
439 #
440 distclean :: realclean
441 $(RM) config.cache config.log config.status
442 cd examples && $(RM) Makefile
443 cd demos && $(RM) Makefile
444 cd cli && $(RM) Makefile
445 $(RM) include/cdk_config.h
446 $(RM) include/cdk_version.h
447 $(RM) Makefile
448 @- $(SHELL) -c 'if test "$(srcdir)" != . ; then \
449 rmdir examples; \
450 rmdir demos; \
451 rmdir cli; \
452 rmdir include; \
453 fi'
454
455 #
456 # Standard .c to .o compile line.
457 #
458 .c.o:
459 @RULE_CC@
460 @ECHO_CC@$(LIBTOOL_COMPILE) $(CC) $(CFLAGS) $(CPPFLAGS) -c $<
461
462 .c.i:
463 @RULE_CC@
464 @ECHO_CC@$(CPP) $(CPPFLAGS) -E -C $< >$@
465
466 .c.os:
467 @RULE_CC@
468 @ECHO_CC@$(CC) $(CFLAGS) $(CPPFLAGS) -c -fPIC $< -o $@
469
470 man \
471 $(DOCUMENT_DIR) \
472 $(INCLUDE_DIR) \
473 $(LIB_DIR) \
474 $(MAN_DIR) : ; $(srcdir)/mkdirs.sh $@
475
476 #
477 # Files generated from templates:
478 #
479 GEN_SCALE = $(SHELL) $(srcdir)/gen-scale.sh
480
481 SCALE_H = $(srcdir)/include/gen-scale.h
482 SCALE_C = $(srcdir)/gen-scale.c
483 SCALE_M = $(srcdir)/man/gen-scale.3
484
485 MKDIR_MAN = test -d man || mkdir man
486
487 include/dscale.h : $(SCALE_H)
488 $(GEN_SCALE) DSCALE DScale Double double $(SCALE_H) >$@
489 dscale.c : $(SCALE_C) $(AUTO_HDR)
490 $(GEN_SCALE) DSCALE DScale Double double $(SCALE_C) >$@
491 man/cdk_dscale.3 : $(SCALE_M) man
492 -$(MKDIR_MAN)
493 $(GEN_SCALE) DSCALE DScale Double double $(SCALE_M) >$@
494
495 include/fscale.h : $(SCALE_H)
496 $(GEN_SCALE) FSCALE FScale Float float $(SCALE_H) >$@
497 fscale.c : $(SCALE_C) $(AUTO_HDR)
498 $(GEN_SCALE) FSCALE FScale Float float $(SCALE_C) >$@
499 man/cdk_fscale.3 : $(SCALE_M) man
500 -$(MKDIR_MAN)
501 $(GEN_SCALE) FSCALE FScale Float float $(SCALE_M) >$@
502
503 include/scale.h : $(SCALE_H)
504 $(GEN_SCALE) SCALE Scale Int int $(SCALE_H) >$@
505 scale.c : $(SCALE_C) $(AUTO_HDR)
506 $(GEN_SCALE) SCALE Scale Int int $(SCALE_C) >$@
507 man/cdk_scale.3 : $(SCALE_M) man
508 -$(MKDIR_MAN)
509 $(GEN_SCALE) SCALE Scale Int int $(SCALE_M) >$@
510
511 include/uscale.h : $(SCALE_H)
512 $(GEN_SCALE) USCALE UScale Unsigned unsigned $(SCALE_H) >$@
513 uscale.c : $(SCALE_C) $(AUTO_HDR)
514 $(GEN_SCALE) USCALE UScale Unsigned unsigned $(SCALE_C) >$@
515 man/cdk_uscale.3 : $(SCALE_M) man
516 -$(MKDIR_MAN)
517 $(GEN_SCALE) USCALE UScale Unsigned unsigned $(SCALE_M) >$@
518
519 SLIDER_H = $(srcdir)/include/gen-slider.h
520 SLIDER_C = $(srcdir)/gen-slider.c
521 SLIDER_M = $(srcdir)/man/gen-slider.3
522
523 include/fslider.h : $(SLIDER_H)
524 $(GEN_SCALE) FSLIDER FSlider Float float $(SLIDER_H) >$@
525 fslider.c : $(SLIDER_C) $(AUTO_HDR)
526 $(GEN_SCALE) FSLIDER FSlider Float float $(SLIDER_C) >$@
527 man/cdk_fslider.3 : $(SLIDER_M) man
528 -$(MKDIR_MAN)
529 $(GEN_SCALE) FSLIDER FSlider Float float $(SLIDER_M) >$@
530
531 include/slider.h : $(SLIDER_H)
532 $(GEN_SCALE) SLIDER Slider Int int $(SLIDER_H) >$@
533 slider.c : $(SLIDER_C) $(AUTO_HDR)
534 $(GEN_SCALE) SLIDER Slider Int int $(SLIDER_C) >$@
535 man/cdk_slider.3 : $(SLIDER_M) man
536 -$(MKDIR_MAN)
537 $(GEN_SCALE) SLIDER Slider Int int $(SLIDER_M) >$@
538
539 include/uslider.h : $(SLIDER_H)
540 $(GEN_SCALE) USLIDER USlider Unsigned unsigned $(SLIDER_H) >$@
541 uslider.c : $(SLIDER_C) $(AUTO_HDR)
542 $(GEN_SCALE) USLIDER USlider Unsigned unsigned $(SLIDER_C) >$@
543 man/cdk_uslider.3 : $(SLIDER_M) man
544 -$(MKDIR_MAN)
545 $(GEN_SCALE) USLIDER USlider Unsigned unsigned $(SLIDER_M) >$@
0 Cdk Notes
1 Copyright Mike Glover, 1995, 1996, 1997, 1998, 1999
2 -------------------------------------------------------------------------------
3
4 This document states some of the testing and history of the Cdk widget set.
5
6 Cdk has gone through a major facelift since I first created it, and it's
7 current look I like enough to release and attach my name to. :) I have made sure
8 to remain as consistent as possible with function parameter positions, names,
9 purposes, and what-not. I hope I have been, if not mail me tell me what you
10 find inconsistent and I may change it. I say may because I don't want to kill
11 anyone's code if I can help it. That is why I waited so long before releasing
12 Cdk. I wanted it to be as stable as possible before sending it out into the
13 world. I think it's stable, and hopefully so will you. There are a few things
14 worth noting before continuing.
15
16 Cdk has gone through some fairly rigorous testing, but since I did the testing
17 it may not be complete. I have complied the code with Purify (TM) and
18 Centerline's Testcenter (TM) and both say my code is clean. There are no
19 memory leaks, and the only problems exist in the curses library. If you use the
20 Ncurses library, it has been cleaned. Of course I am not the best to ask. The
21 only reason why I can say this is because I asked the Ncurses author. I don't
22 know how clean it is. I will assume very clean.
23
24 But since I may not be able to see the forest for the trees, I'm willing to
25 bet that bugs still do exist, and you folks will find them. If you do find bugs
26 read the BUGS document supplied with this release to find out what to do.
27
28 I do not plan on changing the interface to Cdk, so any code developed in it now
29 should pass the test of time. The only changes I can see are bug fixes and new
30 widgets. Lets hope this wish of mine remains true...
31
32 There is an examples directory available which demonstrates all of the widgets
33 and some extra concepts, it's a great place to tool around in before banging
34 away at your own code.
35
36 If you want to get a hold of me mail me at one of the following:
37 glover@credit.erin.utoronto.ca
38 mike@vexus.ca
39
40 The CDK Web page has several homes. They are:
41 http://www.vexus.ca/CDK.html (official)
42 http://www.datasoft.on.ca/~cdk (Sponsered by the nice folks at Datasoft)
43
44 Have fun. :)
45
46 ttfn,
47 Mike
+136
-40
README less more
0 -- $Id: README,v 1.4 2003/12/10 22:42:38 tom Exp $
0 -- $Id: README,v 1.6 2006/05/07 23:19:21 tom Exp $
1 -------------------------------------------------------------------------------
12
2 Cdk Perl5 Extension,
3 Mike Glover, Copyright 1995-1999
4 Thomas Dickey modifications copyright 1999-2002, 2003
3 Copyright Thomas Dickey 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
54
6 ------------------------------------------------------------------------------
5 This is a modified/enhanced version of Cdk. The original README contents are
6 given below.
77
8 This is the Perl5 extension to the Cdk library written by Mike Glover.
9 See MANIFEST for a list of files provided with this extension.
10 See COPYING for the licensing terms for this package.
11 See
8 This version of Cdk is found at
9
1210 http://invisible-island.net/cdk/
1311 ftp://invisible-island.net/cdk/
14 for the current version of this package.
1512
16 How to build/install:
17 ---------------------
13 The intent of the modifications is to preserve nominal compatibility with the
14 original Cdk, while fixing bugs and design limitations. Some macros such as
15 ObjOf() have been introduced to move details out of individual widgets into
16 common functionality (see the cdk_objs.h header). In addition, fixed array
17 limits have been removed, using new functions in some instances which do not
18 have the fixed limits.
1819
19 1. Make sure that Cdk (the C library libcdk and its header files) are
20 installed. Normally those are
21 /usr/local/include/cdk/cdk.h (and other files)
22 /usr/local/lib/libcdk.a (and perhaps a shared-library)
20 Converting a program which uses the original Cdk is done by wrapping the widget
21 pointers in ObjOf() for struct members which have been moved into the CDKOBJS
22 struct. This is not a one-way conversion (for many applications), since a
23 header cdk_compat.h defines ObjOf() and a few obsolete functions which may be
24 used by older programs. By wrapping the widget pointers as needed in ObjOf(),
25 one may compile the same source against the old/new versions of Cdk to check
26 that the application is correctly upgraded.
2327
24 2. Modify Makefile.PL as needed to tell the compiler where to find the Cdk
25 library and header files. In particular, these values may require change:
28 Once converted, there are additional functions and widgets provided by the
29 new version of Cdk. Bugs should (as noted on the webpage) be reported to me.
2630
27 * LIBS tells the compiler where to find the Cdk and curses libraries. Just
28 change the -L paths to reflect what is on your system. Leave the -lcdk
29 and -lcurses. You may have to change -lcurses to -lncurses, for
30 instance.
31 -------------------------------------------------------------------------------
32 Cdk Readme Guide
33 Copyright Mike Glover, 1995, 1996, 1997, 1998, 1999
34 -------------------------------------------------------------------------------
3135
32 * INC tells the compiler where to find the header files. Just change the
33 -I paths to reflect what is on your system.
36 Overview:
37 ---------
38 Cdk stands for 'Curses Development Kit' and it currently contains 21 ready
39 to use widgets which facilitate the speedy development of full screen
40 curses programs. This little project of mine started as a test to see how
41 compatible my Linux machine was to other UNIX breeds. While doing this I
42 discovered Ncurses, and played with it. These widgets are the result of
43 over a years worth of playing. The current complement of widgets are:
3444
35 3. If your version of perl supports dynamic loading, it is simple to
36 add new packages. Run these commands
37 perl Makefile.PL
38 make install
39 to generate a makefile for your configuration, build and install the
40 extension. (The process of building perl with statically loaded extensions
41 is more complicated).
45 Widget Type Quick Description
46 ===========================================================================
47 Alphalist Allows a user to select from a list of words, with
48 the ability to narrow the search list by typing in a
49 few characters of the desired word.
50 Buttonbox This creates a multiple button widget.
51 Calendar Creates a little simple calendar widget.
52 Dialog Prompts the user with a message, and the user
53 can pick an answer from the buttons provided.
54 Entry Allows the user to enter various types of information.
55 File Selector A file selector built from Cdk base widgets. This
56 example shows how to create more complicated widgets
57 using the Cdk widget library.
58 Graph Draws a graph.
59 Histogram Draws a histogram.
60 Item List Creates a pop up field which allows the user to select
61 one of several choices in a small field. Very useful
62 for things like days of the week or month names.
63 Label Displays messages in a pop up box, or the label can be
64 considered part of the screen.
65 Marquee Displays a message in a scrolling marquee.
66 Matrix Creates a complex matrix with lots of options.
67 Menu Creates a pull-down menu interface.
68 Multiple Line Entry A multiple line entry field. Very useful
69 for long fields. (like a description
70 field)
71 Radio List Creates a radio button list.
72 Scale Creates a numeric scale. Used for allowing a user to
73 pick a numeric value and restrict them to a range of
74 values.
75 Scrolling List Creates a scrolling list/menu list.
76 Scrolling Window Creates a scrolling log file viewer. Can add
77 information into the window while its running.
78 A good widget for displaying the progress of
79 something. (akin to a console window)
80 Selection List Creates a multiple option selection list.
81 Slider Akin to the scale widget, this widget provides a
82 visual slide bar to represent the numeric value.
83 Template Creates a entry field with character sensitive
84 positions. Used for pre-formatted fields like
85 dates and phone numbers.
86 Viewer This is a file/information viewer. Very useful
87 when you need to display loads of information.
88 ===========================================================================
4289
43 Testing the Cdk extension:
44 --------------------------
90 Each widget has the ability to display color, or other character attributes.
91 Cdk comes with a attribute/color format command set which allows a programmer
92 to add colors and characters attributes simply.
4593
46 There are several examples in the subdirectories of this package:
94 The code has been cleaned using both Purify(TM) and Sun's Testcenter(TM),
95 so it is as clean as a babies butt. :) Any leaks I have seen are in the curses
96 libraries; there is nothing I can do about that, sorry. There should be no
97 memory leaks within the code, it shouldn't core dump, and it shouldn't do
98 anything unexpected. Unfortunately this probably is not the case. If you do
99 see something like this tell me after you read the BUGS file.
47100
48 demo
49 contains a few simple application programs.
50 examples
51 contains scripts which demonstrate each widget separately.
52 fulldemo
53 combines all of the widgets into a menu-driven application.
101 Distribution:
102 -------------
103 This distribution has a full complement of manual pages, so any specifics to
104 the widgets will not be addressed in this read me. If you want to get right in
105 there, nroff the cdk.3 file in the man directory. It is the starting point
106 for all the manual pages.
107
108 There are some other files to look at if you want to get anywhere. They are:
109
110 INSTALL - This will show you how to build Cdk and install it on your system.
111 If there are any personal modifications that you think may be
112 needed, read this file. In fact read it regardless. :)
113
114 COPYING - The legal stuff to protect my butt and all of the hard work that I
115 have put into this library.
116
117 EXPANDING - You feel creative enough to add a widget, here are my requirements
118 that you have to follow to make the integration of a new widget
119 seamless.
120
121 BUGS - What to do when you find a bug. It also lists all of the bugs found,
122 who found them, who fixed them, and when they were fixed. If you think
123 you have found a bug look at this file. If you do not think you have
124 the most up to date version of Cdk, go get it and try to replicate the
125 problem. Then look at the BUGS file again. If it is NOT there, then you
126 can mail me notifying me of a possible bug. I will try my hardest to get
127 back to you, but I have a pretty busy schedule so don't expect an instant
128 reply. This file will also explain how I would like any bug fixes sent to
129 me.
130
131 NOTES - Misc babblings of myself somewhat related to this distribution.
132
133 TODO - A list of things I plan to do in the future. (sleep)
134
135 CHANGES - A list of changes from one release to another.
136
137 If you want to get a hold of me mail me at one of the following:
138 glover@credit.erin.utoronto.ca
139 mike@vexus.ca
140
141 The CDK Web page has several homes. They are:
142 http://www.vexus.ca/CDK.html (official)
143 http://www.datasoft.on.ca/~cdk (Sponsored by the nice folks at Datasoft)
144
145 ttfn,
146 Mike
147
148 PS: There is also a Perl5 extension of this library for you Perl5 fans.
149 Look under any CPAN site under the directory CPAN/authors/id/GLOVER.
0 Cdk To-Do List
1 Copyright Mike Glover, 1995, 1996, 1997, 1998, 1999
2 ------------------------------------------------------------------------------
3
4 There are a few things that I am either currently working on, or going to
5 work on in the near future. They are:
6
7 * Add more functions to the drawing routines. (yadda, yadda, yadda...)
8 * Working on a tree widget...
9 * Working on a tab list widget...
10 * I would like to be able to have a captive shell widget. This
11 would allow you to start a subshell and have the user interact
12 with a spawned command via the captive shell. This would allow
13 you to spawn an interactive command through the widget. If any
14 one knows how to do this, please mail me. Maybe we'll work this
15 through. (I WOULD LOVE TO ADD THIS, IF ANYONE HAS ANY IDEAS
16 PLEASE MAIL ME)
17 * I am thinking about adding an X windows element to Cdk using
18 the Xforms library, because it seems to have roughly the same
19 widgets as I do. The plan is to have a simple environment variable
20 which tells the program what you want curses/X windows. We'll
21 see how this goes.
22 * I am going to (in the next revision), make the Cdk library more
23 X like with the ability to set/get attributes of the widgets via
24 functions. The proposed method is something like :
25
26 value = CdkEntryGetXXX (widget)
27 CdkEntrySetXXX (widget, value)
28
29 Where XXX is a property of the widget. It would be nice to create
30 a singlar widget type (CdkWidget) and to have generic functions
31 set/get the properties. (this is all being thought of to phase
32 in the X/Cdk idea mentioned above.)
33 * I'm also working on fixing the way the default callback function
34 for the widget editing functions is called. (i know this is brief,
35 but it's there more to remind me of an idea which was spurred on by
36 someone else's suggestion.)
37 * Version 5 should have the ability to properly attach widgets
38 together via constraints, positioning within forms, etc... The
39 next inception should make it simpler to create home-grown widgets.
40 (Version 5 may also only support Ncurses because I'm losing a lot
41 of functionality by being backward compatible.)
42
43 If you want to get a hold of me mail me at one of the following:
44 glover@credit.erin.utoronto.ca
45 mike@vexus.ca
46
47 The CDK Web page has several homes. They are:
48 http://www.vexus.ca/CDK.html (official)
49 http://www.datasoft.on.ca/~cdk (Sponsored by the nice folks at Datasoft)
50
51 ttfn,
52 Mike
0 4:0:3 5.0 20060507
0 dnl $Id: aclocal.m4,v 1.31 2005/12/26 22:21:49 tom Exp $
1 dnl macros used for CDK configure script
2 dnl -- T.E.Dickey
3 dnl ---------------------------------------------------------------------------
4 dnl ---------------------------------------------------------------------------
5 dnl CF_AC_PREREQ version: 2 updated: 1997/09/06 13:24:56
6 dnl ------------
7 dnl Conditionally generate script according to whether we're using the release
8 dnl version of autoconf, or a patched version (using the ternary component as
9 dnl the patch-version).
10 define(CF_AC_PREREQ,
11 [CF_PREREQ_COMPARE(
12 AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)),
13 AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])), [$1], [$2], [$3])])dnl
14 dnl ---------------------------------------------------------------------------
15 dnl CF_ADD_CFLAGS version: 7 updated: 2004/04/25 17:48:30
16 dnl -------------
17 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
18 dnl The second parameter if given makes this macro verbose.
19 dnl
20 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
21 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
22 dnl confused by the quotes (which require backslashes to keep them usable).
23 AC_DEFUN([CF_ADD_CFLAGS],
24 [
25 cf_fix_cppflags=no
26 cf_new_cflags=
27 cf_new_cppflags=
28 cf_new_extra_cppflags=
29
30 for cf_add_cflags in $1
31 do
32 case $cf_fix_cppflags in
33 no)
34 case $cf_add_cflags in #(vi
35 -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
36 case $cf_add_cflags in
37 -D*)
38 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
39
40 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
41 && test -z "${cf_tst_cflags}" \
42 && cf_fix_cppflags=yes
43
44 if test $cf_fix_cppflags = yes ; then
45 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
46 continue
47 elif test "${cf_tst_cflags}" = "\"'" ; then
48 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
49 continue
50 fi
51 ;;
52 esac
53 case "$CPPFLAGS" in
54 *$cf_add_cflags) #(vi
55 ;;
56 *) #(vi
57 cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
58 ;;
59 esac
60 ;;
61 *)
62 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
63 ;;
64 esac
65 ;;
66 yes)
67 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
68
69 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
70
71 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
72 && test -z "${cf_tst_cflags}" \
73 && cf_fix_cppflags=no
74 ;;
75 esac
76 done
77
78 if test -n "$cf_new_cflags" ; then
79 ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
80 CFLAGS="$CFLAGS $cf_new_cflags"
81 fi
82
83 if test -n "$cf_new_cppflags" ; then
84 ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
85 CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
86 fi
87
88 if test -n "$cf_new_extra_cppflags" ; then
89 ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
90 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
91 fi
92
93 AC_SUBST(EXTRA_CPPFLAGS)
94
95 ])dnl
96 dnl ---------------------------------------------------------------------------
97 dnl CF_ADD_INCDIR version: 4 updated: 2002/12/21 14:25:52
98 dnl -------------
99 dnl Add an include-directory to $CPPFLAGS. Don't add /usr/include, since it's
100 dnl redundant. We don't normally need to add -I/usr/local/include for gcc,
101 dnl but old versions (and some misinstalled ones) need that. To make things
102 dnl worse, gcc 3.x gives error messages if -I/usr/local/include is added to
103 dnl the include-path).
104 AC_DEFUN([CF_ADD_INCDIR],
105 [
106 for cf_add_incdir in $1
107 do
108 while true
109 do
110 case $cf_add_incdir in
111 /usr/include) # (vi
112 ;;
113 /usr/local/include) # (vi
114 if test "$GCC" = yes
115 then
116 cf_save_CPPFLAGS="$CPPFLAGS"
117 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
118 AC_TRY_COMPILE([#include <stdio.h>],
119 [printf("Hello")],
120 [],
121 [CPPFLAGS="$cf_save_CPPFLAGS"])
122 fi
123 ;;
124 *) # (vi
125 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
126 ;;
127 esac
128 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
129 test "$cf_top_incdir" = "$cf_add_incdir" && break
130 cf_add_incdir="$cf_top_incdir"
131 done
132 done
133 ])dnl
134 dnl ---------------------------------------------------------------------------
135 dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
136 dnl ----------------
137 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
138 dnl in the sharutils 4.2 distribution.
139 AC_DEFUN([CF_ANSI_CC_CHECK],
140 [
141 AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
142 cf_cv_ansi_cc=no
143 cf_save_CFLAGS="$CFLAGS"
144 cf_save_CPPFLAGS="$CPPFLAGS"
145 # Don't try gcc -ansi; that turns off useful extensions and
146 # breaks some systems' header files.
147 # AIX -qlanglvl=ansi
148 # Ultrix and OSF/1 -std1
149 # HP-UX -Aa -D_HPUX_SOURCE
150 # SVR4 -Xc
151 # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
152 for cf_arg in "-DCC_HAS_PROTOS" \
153 "" \
154 -qlanglvl=ansi \
155 -std1 \
156 -Ae \
157 "-Aa -D_HPUX_SOURCE" \
158 -Xc
159 do
160 CF_ADD_CFLAGS($cf_arg)
161 AC_TRY_COMPILE(
162 [
163 #ifndef CC_HAS_PROTOS
164 #if !defined(__STDC__) || (__STDC__ != 1)
165 choke me
166 #endif
167 #endif
168 ],[
169 int test (int i, double x);
170 struct s1 {int (*f) (int a);};
171 struct s2 {int (*f) (double a);};],
172 [cf_cv_ansi_cc="$cf_arg"; break])
173 done
174 CFLAGS="$cf_save_CFLAGS"
175 CPPFLAGS="$cf_save_CPPFLAGS"
176 ])
177
178 if test "$cf_cv_ansi_cc" != "no"; then
179 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
180 CF_ADD_CFLAGS($cf_cv_ansi_cc)
181 else
182 AC_DEFINE(CC_HAS_PROTOS)
183 fi
184 fi
185 ])dnl
186 dnl ---------------------------------------------------------------------------
187 dnl CF_ANSI_CC_REQD version: 3 updated: 1997/09/06 13:40:44
188 dnl ---------------
189 dnl For programs that must use an ANSI compiler, obtain compiler options that
190 dnl will make it recognize prototypes. We'll do preprocessor checks in other
191 dnl macros, since tools such as unproto can fake prototypes, but only part of
192 dnl the preprocessor.
193 AC_DEFUN([CF_ANSI_CC_REQD],
194 [AC_REQUIRE([CF_ANSI_CC_CHECK])
195 if test "$cf_cv_ansi_cc" = "no"; then
196 AC_ERROR(
197 [Your compiler does not appear to recognize prototypes.
198 You have the following choices:
199 a. adjust your compiler options
200 b. get an up-to-date compiler
201 c. use a wrapper such as unproto])
202 fi
203 ])dnl
204 dnl ---------------------------------------------------------------------------
205 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
206 dnl --------------
207 dnl Allow user to disable a normally-on option.
208 AC_DEFUN([CF_ARG_DISABLE],
209 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
210 dnl ---------------------------------------------------------------------------
211 dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
212 dnl -------------
213 dnl Allow user to enable a normally-off option.
214 AC_DEFUN([CF_ARG_ENABLE],
215 [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
216 dnl ---------------------------------------------------------------------------
217 dnl CF_ARG_OPTION version: 3 updated: 1997/10/18 14:42:41
218 dnl -------------
219 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
220 dnl values.
221 dnl
222 dnl Parameters:
223 dnl $1 = option name
224 dnl $2 = help-string
225 dnl $3 = action to perform if option is not default
226 dnl $4 = action if perform if option is default
227 dnl $5 = default option value (either 'yes' or 'no')
228 AC_DEFUN([CF_ARG_OPTION],
229 [AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes)
230 if test "$enableval" != "$5" ; then
231 ifelse($3,,[ :]dnl
232 ,[ $3]) ifelse($4,,,[
233 else
234 $4])
235 fi],[enableval=$5 ifelse($4,,,[
236 $4
237 ])dnl
238 ])])dnl
239 dnl ---------------------------------------------------------------------------
240 dnl CF_CHECK_CACHE version: 10 updated: 2004/05/23 13:03:31
241 dnl --------------
242 dnl Check if we're accidentally using a cache from a different machine.
243 dnl Derive the system name, as a check for reusing the autoconf cache.
244 dnl
245 dnl If we've packaged config.guess and config.sub, run that (since it does a
246 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
247 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
248 dnl which is useful in cross-compiles.
249 dnl
250 dnl Note: we would use $ac_config_sub, but that is one of the places where
251 dnl autoconf 2.5x broke compatibility with autoconf 2.13
252 AC_DEFUN([CF_CHECK_CACHE],
253 [
254 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
255 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
256 system_name="$host_os"
257 else
258 system_name="`(uname -s -r) 2>/dev/null`"
259 if test -z "$system_name" ; then
260 system_name="`(hostname) 2>/dev/null`"
261 fi
262 fi
263 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
264 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
265
266 test -z "$system_name" && system_name="$cf_cv_system_name"
267 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
268
269 if test ".$system_name" != ".$cf_cv_system_name" ; then
270 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
271 AC_ERROR("Please remove config.cache and try again.")
272 fi
273 ])dnl
274 dnl ---------------------------------------------------------------------------
275 dnl CF_CHECK_CFLAGS version: 2 updated: 2001/12/30 19:09:58
276 dnl ---------------
277 dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
278 dnl a build-configuration such as imake. These have the pitfall that they
279 dnl often contain compiler-specific options which we cannot use, mixed with
280 dnl preprocessor options that we usually can.
281 AC_DEFUN([CF_CHECK_CFLAGS],
282 [
283 CF_VERBOSE(checking additions to CFLAGS)
284 cf_check_cflags="$CFLAGS"
285 cf_check_cppflags="$CPPFLAGS"
286 CF_ADD_CFLAGS($1,yes)
287 if test "$cf_check_cflags" != "$CFLAGS" ; then
288 AC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
289 [CF_VERBOSE(test-compile failed. Undoing change to \$CFLAGS)
290 if test "$cf_check_cppflags" != "$CPPFLAGS" ; then
291 CF_VERBOSE(but keeping change to \$CPPFLAGS)
292 fi
293 CFLAGS="$cf_check_flags"])
294 fi
295 ])dnl
296 dnl ---------------------------------------------------------------------------
297 dnl CF_CURSES_CHTYPE version: 6 updated: 2003/11/06 19:59:57
298 dnl ----------------
299 dnl Test if curses defines 'chtype' (usually a 'long' type for SysV curses).
300 AC_DEFUN([CF_CURSES_CHTYPE],
301 [
302 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
303 AC_CACHE_CHECK(for chtype typedef,cf_cv_chtype_decl,[
304 AC_TRY_COMPILE([#include <${cf_cv_ncurses_header-curses.h}>],
305 [chtype foo],
306 [cf_cv_chtype_decl=yes],
307 [cf_cv_chtype_decl=no])])
308 if test $cf_cv_chtype_decl = yes ; then
309 AC_DEFINE(HAVE_TYPE_CHTYPE)
310 AC_CACHE_CHECK(if chtype is scalar or struct,cf_cv_chtype_type,[
311 AC_TRY_COMPILE([#include <${cf_cv_ncurses_header-curses.h}>],
312 [chtype foo; long x = foo],
313 [cf_cv_chtype_type=scalar],
314 [cf_cv_chtype_type=struct])])
315 if test $cf_cv_chtype_type = scalar ; then
316 AC_DEFINE(TYPE_CHTYPE_IS_SCALAR)
317 fi
318 fi
319 ])dnl
320 dnl ---------------------------------------------------------------------------
321 dnl CF_CURSES_CPPFLAGS version: 7 updated: 2003/06/06 00:48:41
322 dnl ------------------
323 dnl Look for the curses headers.
324 AC_DEFUN([CF_CURSES_CPPFLAGS],[
325
326 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
327 cf_cv_curses_incdir=no
328 case $host_os in #(vi
329 hpux10.*|hpux11.*) #(vi
330 test -d /usr/include/curses_colr && \
331 cf_cv_curses_incdir="-I/usr/include/curses_colr"
332 ;;
333 sunos3*|sunos4*)
334 test -d /usr/5lib && \
335 test -d /usr/5include && \
336 cf_cv_curses_incdir="-I/usr/5include"
337 ;;
338 esac
339 ])
340 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$cf_cv_curses_incdir $CPPFLAGS"
341
342 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
343 cf_cv_ncurses_header=none
344 for cf_header in \
345 curses.h \
346 ncurses.h \
347 ncurses/curses.h \
348 ncurses/ncurses.h
349 do
350 AC_TRY_COMPILE([#include <${cf_header}>],
351 [initscr(); tgoto("?", 0,0)],
352 [cf_cv_ncurses_header=$cf_header; break],[])
353 done
354 ])
355
356 if test "$cf_cv_ncurses_header" = none ; then
357 AC_MSG_ERROR(No curses header-files found)
358 fi
359
360 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
361 AC_CHECK_HEADERS($cf_cv_ncurses_header)
362
363 ])dnl
364 dnl ---------------------------------------------------------------------------
365 dnl CF_CURSES_FUNCS version: 12 updated: 2003/11/06 19:59:57
366 dnl ---------------
367 dnl Curses-functions are a little complicated, since a lot of them are macros.
368 AC_DEFUN([CF_CURSES_FUNCS],
369 [
370 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
371 AC_REQUIRE([CF_XOPEN_CURSES])
372 AC_REQUIRE([CF_CURSES_TERM_H])
373 for cf_func in $1
374 do
375 CF_UPPER(cf_tr_func,$cf_func)
376 AC_MSG_CHECKING(for ${cf_func})
377 CF_MSG_LOG(${cf_func})
378 AC_CACHE_VAL(cf_cv_func_$cf_func,[
379 eval cf_result='$ac_cv_func_'$cf_func
380 if test ".$cf_result" != ".no"; then
381 AC_TRY_LINK([
382 #ifdef HAVE_XCURSES
383 #include <xcurses.h>
384 char * XCursesProgramName = "test";
385 #else
386 #include <${cf_cv_ncurses_header-curses.h}>
387 #if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
388 #include <ncursesw/term.h>
389 #else
390 #if defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
391 #include <ncurses/term.h>
392 #else
393 #ifdef HAVE_TERM_H
394 #include <term.h>
395 #endif
396 #endif
397 #endif
398 #endif],
399 [
400 #ifndef ${cf_func}
401 long foo = (long)(&${cf_func});
402 exit(foo == 0);
403 #endif
404 ],
405 [cf_result=yes],
406 [cf_result=no])
407 fi
408 eval 'cf_cv_func_'$cf_func'=$cf_result'
409 ])
410 # use the computed/retrieved cache-value:
411 eval 'cf_result=$cf_cv_func_'$cf_func
412 AC_MSG_RESULT($cf_result)
413 if test $cf_result != no; then
414 AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
415 fi
416 done
417 ])dnl
418 dnl ---------------------------------------------------------------------------
419 dnl CF_CURSES_LIBS version: 23 updated: 2003/11/06 19:59:57
420 dnl --------------
421 dnl Look for the curses libraries. Older curses implementations may require
422 dnl termcap/termlib to be linked as well. Call CF_CURSES_CPPFLAGS first.
423 AC_DEFUN([CF_CURSES_LIBS],[
424
425 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
426 AC_MSG_CHECKING(if we have identified curses libraries)
427 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
428 [initscr(); tgoto("?", 0,0)],
429 cf_result=yes,
430 cf_result=no)
431 AC_MSG_RESULT($cf_result)
432
433 if test "$cf_result" = no ; then
434 case $host_os in #(vi
435 freebsd*) #(vi
436 AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
437 ;;
438 hpux10.*|hpux11.*) #(vi
439 AC_CHECK_LIB(cur_colr,initscr,[
440 LIBS="-lcur_colr $LIBS"
441 ac_cv_func_initscr=yes
442 ],[
443 AC_CHECK_LIB(Hcurses,initscr,[
444 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
445 LIBS="-lHcurses $LIBS"
446 CPPFLAGS="-D__HP_CURSES -D_HP_CURSES $CPPFLAGS"
447 ac_cv_func_initscr=yes
448 ])])
449 ;;
450 linux*) # Suse Linux does not follow /usr/lib convention
451 LIBS="$LIBS -L/lib"
452 ;;
453 sunos3*|sunos4*)
454 test -d /usr/5lib && \
455 LIBS="$LIBS -L/usr/5lib -lcurses -ltermcap"
456 ac_cv_func_initscr=yes
457 ;;
458 esac
459
460 if test ".$ac_cv_func_initscr" != .yes ; then
461 cf_save_LIBS="$LIBS"
462 cf_term_lib=""
463 cf_curs_lib=""
464
465 if test ".${cf_cv_ncurses_version-no}" != .no
466 then
467 cf_check_list="ncurses curses cursesX"
468 else
469 cf_check_list="cursesX curses ncurses"
470 fi
471
472 # Check for library containing tgoto. Do this before curses library
473 # because it may be needed to link the test-case for initscr.
474 AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
475 for cf_term_lib in $cf_check_list termcap termlib unknown
476 do
477 AC_CHECK_LIB($cf_term_lib,tgoto,[break])
478 done
479 ])
480
481 # Check for library containing initscr
482 test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
483 for cf_curs_lib in $cf_check_list xcurses jcurses unknown
484 do
485 AC_CHECK_LIB($cf_curs_lib,initscr,[break])
486 done
487 test $cf_curs_lib = unknown && AC_ERROR(no curses library found)
488
489 LIBS="-l$cf_curs_lib $cf_save_LIBS"
490 if test "$cf_term_lib" = unknown ; then
491 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
492 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
493 [initscr()],
494 [cf_result=yes],
495 [cf_result=no])
496 AC_MSG_RESULT($cf_result)
497 test $cf_result = no && AC_ERROR(Cannot link curses library)
498 elif test "$cf_curs_lib" = "$cf_term_lib" ; then
499 :
500 elif test "$cf_term_lib" != predefined ; then
501 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
502 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
503 [initscr(); tgoto((char *)0, 0, 0);],
504 [cf_result=no],
505 [
506 LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
507 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
508 [initscr()],
509 [cf_result=yes],
510 [cf_result=error])
511 ])
512 AC_MSG_RESULT($cf_result)
513 fi
514 fi
515 fi
516
517 ])dnl
518 dnl ---------------------------------------------------------------------------
519 dnl CF_CURSES_SETBEGYX version: 1 updated: 2002/07/22 22:38:19
520 dnl ------------------
521 dnl See if we can define a function to set a window's beginning y/x coordinates.
522 AC_DEFUN([CF_CURSES_SETBEGYX],[
523 AC_MSG_CHECKING(how to define setbegyx)
524 cf_result=ERR
525 for cf_check in \
526 '((win)->_begy = (y), (win)->_begx = (x), OK)'
527 do
528 AC_TRY_COMPILE([
529 #include <${cf_cv_ncurses_header-curses.h}>
530 ],[
531 WINDOW *win = 0;
532 #define setbegyx(win,y,x) $cf_check
533 setbegyx(win, 2, 3);
534 ],[cf_result=$cf_check; break])
535 done
536 AC_MSG_RESULT("$cf_result")
537 AC_DEFINE_UNQUOTED(setbegyx(win,y,x),$cf_result)
538 ])dnl
539 dnl ---------------------------------------------------------------------------
540 dnl CF_CURSES_TERM_H version: 6 updated: 2003/11/06 19:59:57
541 dnl ----------------
542 dnl SVr4 curses should have term.h as well (where it puts the definitions of
543 dnl the low-level interface). This may not be true in old/broken implementations,
544 dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
545 dnl running with Solaris 2.5.1).
546 AC_DEFUN([CF_CURSES_TERM_H],
547 [
548 AC_CACHE_CHECK(for term.h, cf_cv_term_header,[
549
550 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
551 # If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
552 # for <term.h> if we do not find the variant.
553 for cf_header in \
554 `echo ${cf_cv_ncurses_header-curses.h} | sed -e 's%/.*%/%'`term.h \
555 term.h
556 do
557 AC_TRY_COMPILE([
558 #include <${cf_cv_ncurses_header-curses.h}>
559 #include <${cf_header}>],
560 [WINDOW *x],
561 [cf_cv_term_header=$cf_header
562 break],
563 [cf_cv_term_header=no])
564 done
565 ])
566
567 case $cf_cv_term_header in #(vi
568 term.h) #(vi
569 AC_DEFINE(HAVE_TERM_H)
570 ;;
571 ncurses/term.h)
572 AC_DEFINE(HAVE_NCURSES_TERM_H)
573 ;;
574 ncursesw/term.h)
575 AC_DEFINE(HAVE_NCURSESW_TERM_H)
576 ;;
577 esac
578 ])dnl
579 dnl ---------------------------------------------------------------------------
580 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
581 dnl ----------
582 dnl "dirname" is not portable, so we fake it with a shell script.
583 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
584 dnl ---------------------------------------------------------------------------
585 dnl CF_DISABLE_ECHO version: 10 updated: 2003/04/17 22:27:11
586 dnl ---------------
587 dnl You can always use "make -n" to see the actual options, but it's hard to
588 dnl pick out/analyze warning messages when the compile-line is long.
589 dnl
590 dnl Sets:
591 dnl ECHO_LT - symbol to control if libtool is verbose
592 dnl ECHO_LD - symbol to prefix "cc -o" lines
593 dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
594 dnl SHOW_CC - symbol to put before explicit "cc -c" lines
595 dnl ECHO_CC - symbol to put before any "cc" line
596 dnl
597 AC_DEFUN([CF_DISABLE_ECHO],[
598 AC_MSG_CHECKING(if you want to see long compiling messages)
599 CF_ARG_DISABLE(echo,
600 [ --disable-echo display "compiling" commands],
601 [
602 ECHO_LT='--silent'
603 ECHO_LD='@echo linking [$]@;'
604 RULE_CC=' @echo compiling [$]<'
605 SHOW_CC=' @echo compiling [$]@'
606 ECHO_CC='@'
607 ],[
608 ECHO_LT=''
609 ECHO_LD=''
610 RULE_CC='# compiling'
611 SHOW_CC='# compiling'
612 ECHO_CC=''
613 ])
614 AC_MSG_RESULT($enableval)
615 AC_SUBST(ECHO_LT)
616 AC_SUBST(ECHO_LD)
617 AC_SUBST(RULE_CC)
618 AC_SUBST(SHOW_CC)
619 AC_SUBST(ECHO_CC)
620 ])dnl
621 dnl ---------------------------------------------------------------------------
622 dnl CF_FIND_LIBRARY version: 8 updated: 2004/11/23 20:14:58
623 dnl ---------------
624 dnl Look for a non-standard library, given parameters for AC_TRY_LINK. We
625 dnl prefer a standard location, and use -L options only if we do not find the
626 dnl library in the standard library location(s).
627 dnl $1 = library name
628 dnl $2 = library class, usually the same as library name
629 dnl $3 = includes
630 dnl $4 = code fragment to compile/link
631 dnl $5 = corresponding function-name
632 dnl $6 = flag, nonnull if failure should not cause an error-exit
633 dnl
634 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
635 dnl to use a -L option.
636 AC_DEFUN([CF_FIND_LIBRARY],
637 [
638 eval 'cf_cv_have_lib_'$1'=no'
639 cf_libdir=""
640 AC_CHECK_FUNC($5,
641 eval 'cf_cv_have_lib_'$1'=yes',[
642 cf_save_LIBS="$LIBS"
643 AC_MSG_CHECKING(for $5 in -l$1)
644 LIBS="-l$1 $LIBS"
645 AC_TRY_LINK([$3],[$4],
646 [AC_MSG_RESULT(yes)
647 eval 'cf_cv_have_lib_'$1'=yes'
648 ],
649 [AC_MSG_RESULT(no)
650 CF_LIBRARY_PATH(cf_search,$2)
651 for cf_libdir in $cf_search
652 do
653 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
654 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
655 AC_TRY_LINK([$3],[$4],
656 [AC_MSG_RESULT(yes)
657 eval 'cf_cv_have_lib_'$1'=yes'
658 break],
659 [AC_MSG_RESULT(no)
660 LIBS="$cf_save_LIBS"])
661 done
662 ])
663 ])
664 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
665 ifelse($6,,[
666 if test $cf_found_library = no ; then
667 AC_ERROR(Cannot link $1 library)
668 fi
669 ])
670 ])dnl
671 dnl ---------------------------------------------------------------------------
672 dnl CF_FUNC_LSTAT version: 2 updated: 1997/09/07 13:00:21
673 dnl -------------
674 dnl A conventional existence-check for 'lstat' won't work with the Linux
675 dnl version of gcc 2.7.0, since the symbol is defined only within <sys/stat.h>
676 dnl as an inline function.
677 dnl
678 dnl So much for portability.
679 AC_DEFUN([CF_FUNC_LSTAT],
680 [
681 AC_MSG_CHECKING(for lstat)
682 AC_CACHE_VAL(ac_cv_func_lstat,[
683 AC_TRY_LINK([
684 #include <sys/types.h>
685 #include <sys/stat.h>],
686 [lstat(".", (struct stat *)0)],
687 [ac_cv_func_lstat=yes],
688 [ac_cv_func_lstat=no])
689 ])
690 AC_MSG_RESULT($ac_cv_func_lstat )
691 if test $ac_cv_func_lstat = yes; then
692 AC_DEFINE(HAVE_LSTAT)
693 fi
694 ])dnl
695 dnl ---------------------------------------------------------------------------
696 dnl CF_GCC_ATTRIBUTES version: 10 updated: 2005/05/28 13:16:28
697 dnl -----------------
698 dnl Test for availability of useful gcc __attribute__ directives to quiet
699 dnl compiler warnings. Though useful, not all are supported -- and contrary
700 dnl to documentation, unrecognized directives cause older compilers to barf.
701 AC_DEFUN([CF_GCC_ATTRIBUTES],
702 [
703 if test "$GCC" = yes
704 then
705 cat > conftest.i <<EOF
706 #ifndef GCC_PRINTF
707 #define GCC_PRINTF 0
708 #endif
709 #ifndef GCC_SCANF
710 #define GCC_SCANF 0
711 #endif
712 #ifndef GCC_NORETURN
713 #define GCC_NORETURN /* nothing */
714 #endif
715 #ifndef GCC_UNUSED
716 #define GCC_UNUSED /* nothing */
717 #endif
718 EOF
719 if test "$GCC" = yes
720 then
721 AC_CHECKING([for $CC __attribute__ directives])
722 cat > conftest.$ac_ext <<EOF
723 #line __oline__ "configure"
724 #include "confdefs.h"
725 #include "conftest.h"
726 #include "conftest.i"
727 #if GCC_PRINTF
728 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
729 #else
730 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
731 #endif
732 #if GCC_SCANF
733 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
734 #else
735 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
736 #endif
737 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
738 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
739 extern void foo(void) GCC_NORETURN;
740 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
741 EOF
742 for cf_attribute in scanf printf unused noreturn
743 do
744 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
745 cf_directive="__attribute__(($cf_attribute))"
746 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
747 case $cf_attribute in
748 scanf|printf)
749 cat >conftest.h <<EOF
750 #define GCC_$cf_ATTRIBUTE 1
751 EOF
752 ;;
753 *)
754 cat >conftest.h <<EOF
755 #define GCC_$cf_ATTRIBUTE $cf_directive
756 EOF
757 ;;
758 esac
759 if AC_TRY_EVAL(ac_compile); then
760 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
761 cat conftest.h >>confdefs.h
762 fi
763 done
764 else
765 fgrep define conftest.i >>confdefs.h
766 fi
767 rm -rf conftest*
768 fi
769 ])dnl
770 dnl ---------------------------------------------------------------------------
771 dnl CF_GCC_VERSION version: 4 updated: 2005/08/27 09:53:42
772 dnl --------------
773 dnl Find version of gcc
774 AC_DEFUN([CF_GCC_VERSION],[
775 AC_REQUIRE([AC_PROG_CC])
776 GCC_VERSION=none
777 if test "$GCC" = yes ; then
778 AC_MSG_CHECKING(version of $CC)
779 GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
780 test -z "$GCC_VERSION" && GCC_VERSION=unknown
781 AC_MSG_RESULT($GCC_VERSION)
782 fi
783 ])dnl
784 dnl ---------------------------------------------------------------------------
785 dnl CF_GCC_WARNINGS version: 20 updated: 2005/08/06 18:37:29
786 dnl ---------------
787 dnl Check if the compiler supports useful warning options. There's a few that
788 dnl we don't use, simply because they're too noisy:
789 dnl
790 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
791 dnl -Wredundant-decls (system headers make this too noisy)
792 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
793 dnl -Wwrite-strings (too noisy, but should review occasionally). This
794 dnl is enabled for ncurses using "--enable-const".
795 dnl -pedantic
796 dnl
797 dnl Parameter:
798 dnl $1 is an optional list of gcc warning flags that a particular
799 dnl application might want to use, e.g., "no-unused" for
800 dnl -Wno-unused
801 dnl Special:
802 dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
803 dnl
804 AC_DEFUN([CF_GCC_WARNINGS],
805 [
806 AC_REQUIRE([CF_GCC_VERSION])
807 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
808
809 cat > conftest.$ac_ext <<EOF
810 #line __oline__ "configure"
811 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
812 EOF
813
814 if test "$INTEL_COMPILER" = yes
815 then
816 # The "-wdXXX" options suppress warnings:
817 # remark #1419: external declaration in primary source file
818 # remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
819 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
820 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
821 # remark #193: zero used for undefined preprocessing identifier
822 # remark #593: variable "curs_sb_left_arrow" was set but never used
823 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
824 # remark #869: parameter "tw" was never referenced
825 # remark #981: operands are evaluated in unspecified order
826 # warning #269: invalid format string conversion
827
828 AC_CHECKING([for $CC warning options])
829 cf_save_CFLAGS="$CFLAGS"
830 EXTRA_CFLAGS="-Wall"
831 for cf_opt in $1 \
832 wd1419 \
833 wd1682 \
834 wd1683 \
835 wd1684 \
836 wd193 \
837 wd279 \
838 wd593 \
839 wd810 \
840 wd869 \
841 wd981
842 do
843 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
844 if AC_TRY_EVAL(ac_compile); then
845 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
846 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
847 fi
848 done
849 CFLAGS="$cf_save_CFLAGS"
850
851 elif test "$GCC" = yes
852 then
853 AC_CHECKING([for $CC warning options])
854 cf_save_CFLAGS="$CFLAGS"
855 EXTRA_CFLAGS="-W -Wall"
856 cf_warn_CONST=""
857 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
858 for cf_opt in \
859 Wbad-function-cast \
860 Wcast-align \
861 Wcast-qual \
862 Winline \
863 Wmissing-declarations \
864 Wmissing-prototypes \
865 Wnested-externs \
866 Wpointer-arith \
867 Wshadow \
868 Wstrict-prototypes \
869 Wundef $cf_warn_CONST $1
870 do
871 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
872 if AC_TRY_EVAL(ac_compile); then
873 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
874 case $cf_opt in #(vi
875 Wcast-qual) #(vi
876 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
877 ;;
878 Winline) #(vi
879 case $GCC_VERSION in
880 3.3*)
881 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
882 continue;;
883 esac
884 ;;
885 esac
886 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
887 fi
888 done
889 CFLAGS="$cf_save_CFLAGS"
890 fi
891 rm -f conftest*
892
893 AC_SUBST(EXTRA_CFLAGS)
894 ])dnl
895 dnl ---------------------------------------------------------------------------
896 dnl CF_GETOPT_HEADER version: 2 updated: 2000/02/19 01:46:34
897 dnl ----------------
898 dnl Check for getopt's variables which are commonly defined in stdlib.h or
899 dnl (nonstandard) in getopt.h
900 AC_DEFUN([CF_GETOPT_HEADER],
901 [
902 AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
903 cf_cv_getopt_header=none
904 for cf_header in stdio.h stdlib.h getopt.h
905 do
906 AC_TRY_COMPILE([
907 #include <$cf_header>],
908 [int x = optind; char *y = optarg],
909 [cf_cv_getopt_header=$cf_header
910 break])
911 done
912 ])
913 case $cf_cv_getopt_header in #(vi
914 getopt.h) #(vi
915 AC_DEFINE(HAVE_GETOPT_H)
916 AC_DEFINE(HAVE_GETOPT_HEADER)
917 ;;
918 stdlib.h) #(vi
919 AC_DEFINE(HAVE_STDLIB_H)
920 AC_DEFINE(HAVE_GETOPT_HEADER)
921 ;;
922 esac
923 ])dnl
924 dnl ---------------------------------------------------------------------------
925 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
926 dnl -------------
927 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
928 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
929 dnl (or misfeature) of glibc2, which breaks portability of many applications,
930 dnl since it is interwoven with GNU extensions.
931 dnl
932 dnl Well, yes we could work around it...
933 AC_DEFUN([CF_GNU_SOURCE],
934 [
935 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
936 AC_TRY_COMPILE([#include <sys/types.h>],[
937 #ifndef _XOPEN_SOURCE
938 make an error
939 #endif],
940 [cf_cv_gnu_source=no],
941 [cf_save="$CPPFLAGS"
942 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
943 AC_TRY_COMPILE([#include <sys/types.h>],[
944 #ifdef _XOPEN_SOURCE
945 make an error
946 #endif],
947 [cf_cv_gnu_source=no],
948 [cf_cv_gnu_source=yes])
949 CPPFLAGS="$cf_save"
950 ])
951 ])
952 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
953 ])dnl
954 dnl ---------------------------------------------------------------------------
955 dnl CF_HEADER_PATH version: 8 updated: 2002/11/10 14:46:59
956 dnl --------------
957 dnl Construct a search-list for a nonstandard header-file
958 AC_DEFUN([CF_HEADER_PATH],
959 [CF_SUBDIR_PATH($1,$2,include)
960 test "$includedir" != NONE && \
961 test "$includedir" != "/usr/include" && \
962 test -d "$includedir" && {
963 test -d $includedir && $1="[$]$1 $includedir"
964 test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
965 }
966
967 test "$oldincludedir" != NONE && \
968 test "$oldincludedir" != "/usr/include" && \
969 test -d "$oldincludedir" && {
970 test -d $oldincludedir && $1="[$]$1 $oldincludedir"
971 test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
972 }
973
974 ])dnl
975 dnl ---------------------------------------------------------------------------
976 dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
977 dnl ---------------
978 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
979 AC_DEFUN([CF_HELP_MESSAGE],
980 [AC_DIVERT_HELP([$1])dnl
981 ])dnl
982 dnl ---------------------------------------------------------------------------
983 dnl CF_INCLUDE_DIRS version: 4 updated: 2002/12/01 00:12:15
984 dnl ---------------
985 dnl Construct the list of include-options according to whether we're building
986 dnl in the source directory or using '--srcdir=DIR' option. If we're building
987 dnl with gcc, don't append the includedir if it happens to be /usr/include,
988 dnl since that usually breaks gcc's shadow-includes.
989 AC_DEFUN([CF_INCLUDE_DIRS],
990 [
991 CPPFLAGS="-I. -I../include $CPPFLAGS"
992 if test "$srcdir" != "."; then
993 CPPFLAGS="-I\$(srcdir)/../include $CPPFLAGS"
994 fi
995 if test "$GCC" != yes; then
996 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
997 elif test "$includedir" != "/usr/include"; then
998 if test "$includedir" = '${prefix}/include' ; then
999 if test $prefix != /usr ; then
1000 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
1001 fi
1002 else
1003 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
1004 fi
1005 fi
1006 AC_SUBST(CPPFLAGS)
1007 ])dnl
1008 dnl ---------------------------------------------------------------------------
1009 dnl CF_INCLUDE_PATH version: 4 updated: 2001/04/15 21:21:45
1010 dnl ---------------
1011 dnl Adds to the include-path
1012 dnl
1013 dnl Autoconf 1.11 should have provided a way to add include path options to
1014 dnl the cpp-tests.
1015 dnl
1016 AC_DEFUN([CF_INCLUDE_PATH],
1017 [
1018 for cf_path in $1
1019 do
1020 cf_result="no"
1021 AC_MSG_CHECKING(for directory $cf_path)
1022 if test -d $cf_path
1023 then
1024 INCLUDES="$INCLUDES -I$cf_path"
1025 ac_cpp="${ac_cpp} -I$cf_path"
1026 CFLAGS="$CFLAGS -I$cf_path"
1027 cf_result="yes"
1028 case $cf_path in
1029 /usr/include|/usr/include/*)
1030 ;;
1031 *)
1032 CF_DIRNAME(cf_temp,$cf_path)
1033 case $cf_temp in
1034 */include)
1035 INCLUDES="$INCLUDES -I$cf_temp"
1036 ac_cpp="${ac_cpp} -I$cf_temp"
1037 CFLAGS="$CFLAGS -I$cf_temp"
1038 ;;
1039 esac
1040 esac
1041 fi
1042 AC_MSG_RESULT($cf_result)
1043 done
1044 ])dnl
1045 dnl ---------------------------------------------------------------------------
1046 dnl CF_INTEL_COMPILER version: 3 updated: 2005/08/06 18:37:29
1047 dnl -----------------
1048 dnl Check if the given compiler is really the Intel compiler for Linux. It
1049 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1050 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1051 dnl
1052 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1053 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
1054 dnl the wrappers for gcc and g++ warnings.
1055 dnl
1056 dnl $1 = GCC (default) or GXX
1057 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1058 dnl $3 = CFLAGS (default) or CXXFLAGS
1059 AC_DEFUN([CF_INTEL_COMPILER],[
1060 ifelse($2,,INTEL_COMPILER,[$2])=no
1061
1062 if test "$ifelse($1,,[$1],GCC)" = yes ; then
1063 case $host_os in
1064 linux*|gnu*)
1065 AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler)
1066 cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])"
1067 ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc"
1068 AC_TRY_COMPILE([],[
1069 #ifdef __INTEL_COMPILER
1070 #else
1071 make an error
1072 #endif
1073 ],[ifelse($2,,INTEL_COMPILER,[$2])=yes
1074 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
1075 ],[])
1076 ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
1077 AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
1078 ;;
1079 esac
1080 fi
1081 ])dnl
1082 dnl ---------------------------------------------------------------------------
1083 dnl CF_LIBRARY_PATH version: 7 updated: 2002/11/10 14:46:59
1084 dnl ---------------
1085 dnl Construct a search-list for a nonstandard library-file
1086 AC_DEFUN([CF_LIBRARY_PATH],
1087 [CF_SUBDIR_PATH($1,$2,lib)])dnl
1088 dnl ---------------------------------------------------------------------------
1089 dnl CF_LIB_PREFIX version: 7 updated: 2001/01/12 01:23:48
1090 dnl -------------
1091 dnl Compute the library-prefix for the given host system
1092 dnl $1 = variable to set
1093 AC_DEFUN([CF_LIB_PREFIX],
1094 [
1095 case $cf_cv_system_name in
1096 OS/2*) LIB_PREFIX='' ;;
1097 os2*) LIB_PREFIX='' ;;
1098 *) LIB_PREFIX='lib' ;;
1099 esac
1100 ifelse($1,,,[$1=$LIB_PREFIX])
1101 AC_SUBST(LIB_PREFIX)
1102 ])dnl
1103 dnl ---------------------------------------------------------------------------
1104 dnl CF_LOCALE version: 4 updated: 2003/02/16 08:16:04
1105 dnl ---------
1106 dnl Check if we have setlocale() and its header, <locale.h>
1107 dnl The optional parameter $1 tells what to do if we do have locale support.
1108 AC_DEFUN([CF_LOCALE],
1109 [
1110 AC_MSG_CHECKING(for setlocale())
1111 AC_CACHE_VAL(cf_cv_locale,[
1112 AC_TRY_LINK([#include <locale.h>],
1113 [setlocale(LC_ALL, "")],
1114 [cf_cv_locale=yes],
1115 [cf_cv_locale=no])
1116 ])
1117 AC_MSG_RESULT($cf_cv_locale)
1118 test $cf_cv_locale = yes && { ifelse($1,,AC_DEFINE(LOCALE),[$1]) }
1119 ])dnl
1120 dnl ---------------------------------------------------------------------------
1121 dnl CF_MAKEFLAGS version: 9 updated: 2001/12/30 18:17:27
1122 dnl ------------
1123 dnl Some 'make' programs support $(MAKEFLAGS), some $(MFLAGS), to pass 'make'
1124 dnl options to lower-levels. It's very useful for "make -n" -- if we have it.
1125 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
1126 dnl $(MAKEFLAGS) variable incompatible because it adds the assignments :-)
1127 AC_DEFUN([CF_MAKEFLAGS],
1128 [
1129 AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
1130 cf_cv_makeflags=''
1131 for cf_option in '-$(MAKEFLAGS)' '$(MFLAGS)'
1132 do
1133 cat >cf_makeflags.tmp <<CF_EOF
1134 SHELL = /bin/sh
1135 all :
1136 @ echo '.$cf_option'
1137 CF_EOF
1138 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null`
1139 case "$cf_result" in
1140 .*k)
1141 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
1142 case "$cf_result" in
1143 .*CC=*) cf_cv_makeflags=
1144 ;;
1145 *) cf_cv_makeflags=$cf_option
1146 ;;
1147 esac
1148 break
1149 ;;
1150 *) echo no match "$cf_result"
1151 ;;
1152 esac
1153 done
1154 rm -f cf_makeflags.tmp
1155 ])
1156
1157 AC_SUBST(cf_cv_makeflags)
1158 ])dnl
1159 dnl ---------------------------------------------------------------------------
1160 dnl CF_MAKE_TAGS version: 2 updated: 2000/10/04 09:18:40
1161 dnl ------------
1162 dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have
1163 dnl a monocase filesystem.
1164 AC_DEFUN([CF_MAKE_TAGS],[
1165 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1166 AC_CHECK_PROG(MAKE_LOWER_TAGS, ctags, yes, no)
1167
1168 if test "$cf_cv_mixedcase" = yes ; then
1169 AC_CHECK_PROG(MAKE_UPPER_TAGS, etags, yes, no)
1170 else
1171 MAKE_UPPER_TAGS=no
1172 fi
1173
1174 if test "$MAKE_UPPER_TAGS" = yes ; then
1175 MAKE_UPPER_TAGS=
1176 else
1177 MAKE_UPPER_TAGS="#"
1178 fi
1179 AC_SUBST(MAKE_UPPER_TAGS)
1180
1181 if test "$MAKE_LOWER_TAGS" = yes ; then
1182 MAKE_LOWER_TAGS=
1183 else
1184 MAKE_LOWER_TAGS="#"
1185 fi
1186 AC_SUBST(MAKE_LOWER_TAGS)
1187 ])dnl
1188 dnl ---------------------------------------------------------------------------
1189 dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
1190 dnl ----------------------
1191 dnl Check if the file-system supports mixed-case filenames. If we're able to
1192 dnl create a lowercase name and see it as uppercase, it doesn't support that.
1193 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1194 [
1195 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1196 if test "$cross_compiling" = yes ; then
1197 case $target_alias in #(vi
1198 *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
1199 cf_cv_mixedcase=no
1200 ;;
1201 *)
1202 cf_cv_mixedcase=yes
1203 ;;
1204 esac
1205 else
1206 rm -f conftest CONFTEST
1207 echo test >conftest
1208 if test -f CONFTEST ; then
1209 cf_cv_mixedcase=no
1210 else
1211 cf_cv_mixedcase=yes
1212 fi
1213 rm -f conftest CONFTEST
1214 fi
1215 ])
1216 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
1217 ])dnl
1218 dnl ---------------------------------------------------------------------------
1219 dnl CF_MSG_LOG version: 3 updated: 1997/09/07 14:05:52
1220 dnl ----------
1221 dnl Write a debug message to config.log, along with the line number in the
1222 dnl configure script.
1223 AC_DEFUN([CF_MSG_LOG],[
1224 echo "(line __oline__) testing $* ..." 1>&AC_FD_CC
1225 ])dnl
1226 dnl ---------------------------------------------------------------------------
1227 dnl CF_NCURSES_CC_CHECK version: 3 updated: 2003/01/12 18:59:28
1228 dnl -------------------
1229 dnl Check if we can compile with ncurses' header file
1230 dnl $1 is the cache variable to set
1231 dnl $2 is the header-file to include
1232 dnl $3 is the root name (ncurses or ncursesw)
1233 AC_DEFUN([CF_NCURSES_CC_CHECK],[
1234 AC_TRY_COMPILE([
1235 ]ifelse($3,ncursesw,[
1236 #define _XOPEN_SOURCE_EXTENDED
1237 #undef HAVE_LIBUTF8_H /* in case we used CF_UTF8_LIB */
1238 #define HAVE_LIBUTF8_H /* to force ncurses' header file to use cchar_t */
1239 ])[
1240 #include <$2>],[
1241 #ifdef NCURSES_VERSION
1242 ]ifelse($3,ncursesw,[
1243 #ifndef WACS_BSSB
1244 make an error
1245 #endif
1246 ])[
1247 printf("%s\n", NCURSES_VERSION);
1248 #else
1249 #ifdef __NCURSES_H
1250 printf("old\n");
1251 #else
1252 make an error
1253 #endif
1254 #endif
1255 ]
1256 ,[$1=$cf_header]
1257 ,[$1=no])
1258 ])dnl
1259 dnl ---------------------------------------------------------------------------
1260 dnl CF_NCURSES_CPPFLAGS version: 17 updated: 2003/11/06 19:59:57
1261 dnl -------------------
1262 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
1263 dnl the CPPFLAGS variable so we can include its header.
1264 dnl
1265 dnl The header files may be installed as either curses.h, or ncurses.h (would
1266 dnl be obsolete, except that some packagers prefer this name to distinguish it
1267 dnl from a "native" curses implementation). If not installed for overwrite,
1268 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
1269 dnl /usr/include/ncurses), but someone may have installed overwriting the
1270 dnl vendor's curses. Only very old versions (pre-1.9.2d, the first autoconf'd
1271 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
1272 dnl the header.
1273 dnl
1274 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
1275 dnl is already in the include-path, don't even bother with this, since we cannot
1276 dnl easily determine which file it is. In this case, it has to be <curses.h>.
1277 dnl
1278 dnl The optional parameter gives the root name of the library, in case it is
1279 dnl not installed as the default curses library. That is how the
1280 dnl wide-character version of ncurses is installed.
1281 AC_DEFUN([CF_NCURSES_CPPFLAGS],
1282 [AC_REQUIRE([CF_WITH_CURSES_DIR])
1283
1284 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
1285 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
1286
1287 test -n "$cf_cv_curses_dir" && \
1288 test "$cf_cv_curses_dir" != "no" && \
1289 CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS"
1290
1291 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
1292 cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
1293 ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
1294 for cf_header in $cf_header_list
1295 do
1296 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
1297 test "$cf_cv_ncurses_h" != no && break
1298 done
1299 ])
1300
1301 if test "$cf_cv_ncurses_h" != no ; then
1302 cf_cv_ncurses_header=$cf_cv_ncurses_h
1303 else
1304 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
1305 test -n "$verbose" && echo
1306 CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
1307 test -n "$verbose" && echo search path $cf_search
1308 cf_save2_CPPFLAGS="$CPPFLAGS"
1309 for cf_incdir in $cf_search
1310 do
1311 CF_ADD_INCDIR($cf_incdir)
1312 for cf_header in \
1313 ncurses.h \
1314 curses.h
1315 do
1316 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
1317 if test "$cf_cv_ncurses_h2" != no ; then
1318 cf_cv_ncurses_h2=$cf_incdir/$cf_header
1319 test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&AC_FD_MSG
1320 break
1321 fi
1322 test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
1323 done
1324 CPPFLAGS="$cf_save2_CPPFLAGS"
1325 test "$cf_cv_ncurses_h2" != no && break
1326 done
1327 test "$cf_cv_ncurses_h2" = no && AC_ERROR(not found)
1328 ])
1329
1330 CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
1331 cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
1332 if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
1333 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
1334 fi
1335 CF_ADD_INCDIR($cf_1st_incdir)
1336
1337 fi
1338
1339 AC_DEFINE(NCURSES)
1340
1341 case $cf_cv_ncurses_header in # (vi
1342 *ncurses.h)
1343 AC_DEFINE(HAVE_NCURSES_H)
1344 ;;
1345 esac
1346
1347 case $cf_cv_ncurses_header in # (vi
1348 ncurses/curses.h|ncurses/ncurses.h)
1349 AC_DEFINE(HAVE_NCURSES_NCURSES_H)
1350 ;;
1351 ncursesw/curses.h|ncursesw/ncurses.h)
1352 AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
1353 ;;
1354 esac
1355
1356 CF_NCURSES_VERSION
1357 ])dnl
1358 dnl ---------------------------------------------------------------------------
1359 dnl CF_NCURSES_LIBS version: 12 updated: 2004/04/27 16:26:05
1360 dnl ---------------
1361 dnl Look for the ncurses library. This is a little complicated on Linux,
1362 dnl because it may be linked with the gpm (general purpose mouse) library.
1363 dnl Some distributions have gpm linked with (bsd) curses, which makes it
1364 dnl unusable with ncurses. However, we don't want to link with gpm unless
1365 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
1366 dnl and the linker will record a dependency.
1367 dnl
1368 dnl The optional parameter gives the root name of the library, in case it is
1369 dnl not installed as the default curses library. That is how the
1370 dnl wide-character version of ncurses is installed.
1371 AC_DEFUN([CF_NCURSES_LIBS],
1372 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
1373
1374 cf_nculib_root=ifelse($1,,ncurses,$1)
1375 # This works, except for the special case where we find gpm, but
1376 # ncurses is in a nonstandard location via $LIBS, and we really want
1377 # to link gpm.
1378 cf_ncurses_LIBS=""
1379 cf_ncurses_SAVE="$LIBS"
1380 AC_CHECK_LIB(gpm,Gpm_Open,
1381 [AC_CHECK_LIB(gpm,initscr,
1382 [LIBS="$cf_ncurses_SAVE"],
1383 [cf_ncurses_LIBS="-lgpm"])])
1384
1385 case $host_os in #(vi
1386 freebsd*)
1387 # This is only necessary if you are linking against an obsolete
1388 # version of ncurses (but it should do no harm, since it's static).
1389 if test "$cf_nculib_root" = ncurses ; then
1390 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
1391 fi
1392 ;;
1393 esac
1394
1395 LIBS="$cf_ncurses_LIBS $LIBS"
1396
1397 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
1398 then
1399 LIBS="-L$cf_cv_curses_dir/lib -l$cf_nculib_root $LIBS"
1400 else
1401 CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
1402 [#include <${cf_cv_ncurses_header-curses.h}>],
1403 [initscr()],
1404 initscr)
1405 fi
1406
1407 if test -n "$cf_ncurses_LIBS" ; then
1408 AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
1409 cf_ncurses_SAVE="$LIBS"
1410 for p in $cf_ncurses_LIBS ; do
1411 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
1412 if test "$q" != "$LIBS" ; then
1413 LIBS="$q"
1414 fi
1415 done
1416 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1417 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
1418 [AC_MSG_RESULT(yes)],
1419 [AC_MSG_RESULT(no)
1420 LIBS="$cf_ncurses_SAVE"])
1421 fi
1422
1423 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
1424 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1425 ])dnl
1426 dnl ---------------------------------------------------------------------------
1427 dnl CF_NCURSES_VERSION version: 11 updated: 2003/11/06 19:59:57
1428 dnl ------------------
1429 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
1430 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS. We don't use
1431 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
1432 AC_DEFUN([CF_NCURSES_VERSION],
1433 [
1434 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1435 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
1436 cf_cv_ncurses_version=no
1437 cf_tempfile=out$$
1438 rm -f $cf_tempfile
1439 AC_TRY_RUN([
1440 #include <${cf_cv_ncurses_header-curses.h}>
1441 #include <stdio.h>
1442 int main()
1443 {
1444 FILE *fp = fopen("$cf_tempfile", "w");
1445 #ifdef NCURSES_VERSION
1446 # ifdef NCURSES_VERSION_PATCH
1447 fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
1448 # else
1449 fprintf(fp, "%s\n", NCURSES_VERSION);
1450 # endif
1451 #else
1452 # ifdef __NCURSES_H
1453 fprintf(fp, "old\n");
1454 # else
1455 make an error
1456 # endif
1457 #endif
1458 exit(0);
1459 }],[
1460 cf_cv_ncurses_version=`cat $cf_tempfile`],,[
1461
1462 # This will not work if the preprocessor splits the line after the
1463 # Autoconf token. The 'unproto' program does that.
1464 cat > conftest.$ac_ext <<EOF
1465 #include <${cf_cv_ncurses_header-curses.h}>
1466 #undef Autoconf
1467 #ifdef NCURSES_VERSION
1468 Autoconf NCURSES_VERSION
1469 #else
1470 #ifdef __NCURSES_H
1471 Autoconf "old"
1472 #endif
1473 ;
1474 #endif
1475 EOF
1476 cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
1477 AC_TRY_EVAL(cf_try)
1478 if test -f conftest.out ; then
1479 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
1480 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
1481 rm -f conftest.out
1482 fi
1483 ])
1484 rm -f $cf_tempfile
1485 ])
1486 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
1487 ])dnl
1488 dnl ---------------------------------------------------------------------------
1489 dnl CF_PATH_SYNTAX version: 9 updated: 2002/09/17 23:03:38
1490 dnl --------------
1491 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
1492 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1493 dnl result begins with 'NONE'. This is necessary to work around autoconf's
1494 dnl delayed evaluation of those symbols.
1495 AC_DEFUN([CF_PATH_SYNTAX],[
1496 case ".[$]$1" in #(vi
1497 .\[$]\(*\)*|.\'*\'*) #(vi
1498 ;;
1499 ..|./*|.\\*) #(vi
1500 ;;
1501 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
1502 ;;
1503 .\[$]{*prefix}*) #(vi
1504 eval $1="[$]$1"
1505 case ".[$]$1" in #(vi
1506 .NONE/*)
1507 $1=`echo [$]$1 | sed -e s%NONE%$ac_default_prefix%`
1508 ;;
1509 esac
1510 ;; #(vi
1511 .NONE/*)
1512 $1=`echo [$]$1 | sed -e s%NONE%$ac_default_prefix%`
1513 ;;
1514 *)
1515 ifelse($2,,[AC_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1516 ;;
1517 esac
1518 ])dnl
1519 dnl ---------------------------------------------------------------------------
1520 dnl CF_PDCURSES_X11 version: 6 updated: 2002/10/27 18:21:42
1521 dnl ---------------
1522 dnl Configure for PDCurses' X11 library
1523 AC_DEFUN([CF_PDCURSES_X11],[
1524 AC_REQUIRE([CF_X_ATHENA])
1525 LDFLAGS="$LDFLAGS $X_LIBS"
1526 CF_CHECK_CFLAGS($X_CFLAGS)
1527 AC_CHECK_LIB(X11,XOpenDisplay,
1528 [LIBS="-lX11 $LIBS"],,
1529 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
1530 AC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[
1531 LIBS="-lXCurses $LIBS"
1532 AC_TRY_LINK([
1533 #include <xcurses.h>
1534 char *XCursesProgramName = "test";
1535 ],[XCursesExit();],
1536 [cf_cv_lib_XCurses=yes],
1537 [cf_cv_lib_XCurses=no])
1538 ])
1539 if test $cf_cv_lib_XCurses = yes ; then
1540 AC_DEFINE(UNIX)
1541 AC_DEFINE(XCURSES)
1542 AC_DEFINE(HAVE_XCURSES)
1543 else
1544 AC_ERROR(Cannot link with XCurses)
1545 fi
1546 ])dnl
1547 dnl ---------------------------------------------------------------------------
1548 dnl CF_POSIX_C_SOURCE version: 6 updated: 2005/07/14 20:25:10
1549 dnl -----------------
1550 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1551 dnl
1552 dnl POSIX.1-1990 _POSIX_SOURCE
1553 dnl POSIX.1-1990 and _POSIX_SOURCE and
1554 dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
1555 dnl Bindings Option
1556 dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
1557 dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
1558 dnl X/Open 2000 _POSIX_C_SOURCE=200112L
1559 dnl
1560 dnl Parameters:
1561 dnl $1 is the nominal value for _POSIX_C_SOURCE
1562 AC_DEFUN([CF_POSIX_C_SOURCE],
1563 [
1564 cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
1565
1566 cf_save_CFLAGS="$CFLAGS"
1567 cf_save_CPPFLAGS="$CPPFLAGS"
1568
1569 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1570 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1571
1572 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1573 CF_MSG_LOG(if the symbol is already defined go no further)
1574 AC_TRY_COMPILE([#include <sys/types.h>],[
1575 #ifndef _POSIX_C_SOURCE
1576 make an error
1577 #endif],
1578 [cf_cv_posix_c_source=no],
1579 [cf_want_posix_source=no
1580 case .$cf_POSIX_C_SOURCE in #(vi
1581 .[[12]]??*) #(vi
1582 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1583 ;;
1584 .2) #(vi
1585 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1586 cf_want_posix_source=yes
1587 ;;
1588 .*)
1589 cf_want_posix_source=yes
1590 ;;
1591 esac
1592 if test "$cf_want_posix_source" = yes ; then
1593 AC_TRY_COMPILE([#include <sys/types.h>],[
1594 #ifdef _POSIX_SOURCE
1595 make an error
1596 #endif],[],
1597 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1598 fi
1599 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1600 CFLAGS="$cf_trim_CFLAGS"
1601 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
1602 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1603 AC_TRY_COMPILE([#include <sys/types.h>],[
1604 #ifndef _POSIX_C_SOURCE
1605 make an error
1606 #endif],,
1607 [cf_cv_posix_c_source=no])
1608 CFLAGS="$cf_save_CFLAGS"
1609 CPPFLAGS="$cf_save_CPPFLAGS"
1610 ])
1611 ])
1612
1613 if test "$cf_cv_posix_c_source" != no ; then
1614 CFLAGS="$cf_trim_CFLAGS"
1615 CPPFLAGS="$cf_trim_CPPFLAGS"
1616 if test "$cf_cv_cc_u_d_options" = yes ; then
1617 cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \
1618 sed -e 's/-D/-U/g' -e 's/=[[^ ]]*//g'`
1619 CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source"
1620 fi
1621 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
1622 fi
1623
1624 ])dnl
1625 dnl ---------------------------------------------------------------------------
1626 dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
1627 dnl --------------
1628 dnl Check if C (preprocessor) -U and -D options are processed in the order
1629 dnl given rather than by type of option. Some compilers insist on apply all
1630 dnl of the -U options after all of the -D options. Others allow mixing them,
1631 dnl and may predefine symbols that conflict with those we define.
1632 AC_DEFUN([CF_PROG_CC_U_D],
1633 [
1634 AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
1635 cf_save_CPPFLAGS="$CPPFLAGS"
1636 CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
1637 AC_TRY_COMPILE([],[
1638 #ifndef U_D_OPTIONS
1639 make an undefined-error
1640 #endif
1641 #ifdef D_U_OPTIONS
1642 make a defined-error
1643 #endif
1644 ],[
1645 cf_cv_cc_u_d_options=yes],[
1646 cf_cv_cc_u_d_options=no])
1647 CPPFLAGS="$cf_save_CPPFLAGS"
1648 ])
1649 ])dnl
1650 dnl ---------------------------------------------------------------------------
1651 dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
1652 dnl -----------
1653 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
1654 AC_DEFUN([CF_PROG_EXT],
1655 [
1656 AC_REQUIRE([CF_CHECK_CACHE])
1657 case $cf_cv_system_name in
1658 os2*)
1659 CFLAGS="$CFLAGS -Zmt"
1660 CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
1661 CXXFLAGS="$CXXFLAGS -Zmt"
1662 # autoconf's macro sets -Zexe and suffix both, which conflict:w
1663 LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
1664 ac_cv_exeext=.exe
1665 ;;
1666 esac
1667
1668 AC_EXEEXT
1669 AC_OBJEXT
1670
1671 PROG_EXT="$EXEEXT"
1672 AC_SUBST(PROG_EXT)
1673 test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
1674 ])dnl
1675 dnl ---------------------------------------------------------------------------
1676 dnl CF_REMOVE_DEFINE version: 2 updated: 2005/07/09 16:12:18
1677 dnl ----------------
1678 dnl Remove all -U and -D options that refer to the given symbol from a list
1679 dnl of C compiler options. This works around the problem that not all
1680 dnl compilers process -U and -D options from left-to-right, so a -U option
1681 dnl cannot be used to cancel the effect of a preceding -D option.
1682 dnl
1683 dnl $1 = target (which could be the same as the source variable)
1684 dnl $2 = source (including '$')
1685 dnl $3 = symbol to remove
1686 define([CF_REMOVE_DEFINE],
1687 [
1688 # remove $3 symbol from $2
1689 $1=`echo "$2" | \
1690 sed -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[[ ]]/ /g' \
1691 -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[$]//g'`
1692 ])dnl
1693 dnl ---------------------------------------------------------------------------
1694 dnl CF_SUBDIR_PATH version: 3 updated: 2002/12/29 18:30:46
1695 dnl --------------
1696 dnl Construct a search-list for a nonstandard header/lib-file
1697 dnl $1 = the variable to return as result
1698 dnl $2 = the package name
1699 dnl $3 = the subdirectory, e.g., bin, include or lib
1700 AC_DEFUN([CF_SUBDIR_PATH],
1701 [$1=""
1702
1703 test -d [$]HOME && {
1704 test -n "$verbose" && echo " ... testing $3-directories under [$]HOME"
1705 test -d [$]HOME/$3 && $1="[$]$1 [$]HOME/$3"
1706 test -d [$]HOME/$3/$2 && $1="[$]$1 [$]HOME/$3/$2"
1707 test -d [$]HOME/$3/$2/$3 && $1="[$]$1 [$]HOME/$3/$2/$3"
1708 }
1709
1710 # For other stuff under the home directory, it should be sufficient to put
1711 # a symbolic link for $HOME/$2 to the actual package location:
1712 test -d [$]HOME/$2 && {
1713 test -n "$verbose" && echo " ... testing $3-directories under [$]HOME/$2"
1714 test -d [$]HOME/$2/$3 && $1="[$]$1 [$]HOME/$2/$3"
1715 test -d [$]HOME/$2/$3/$2 && $1="[$]$1 [$]HOME/$2/$3/$2"
1716 }
1717
1718 test "$prefix" != /usr/local && \
1719 test -d /usr/local && {
1720 test -n "$verbose" && echo " ... testing $3-directories under /usr/local"
1721 test -d /usr/local/$3 && $1="[$]$1 /usr/local/$3"
1722 test -d /usr/local/$3/$2 && $1="[$]$1 /usr/local/$3/$2"
1723 test -d /usr/local/$3/$2/$3 && $1="[$]$1 /usr/local/$3/$2/$3"
1724 test -d /usr/local/$2/$3 && $1="[$]$1 /usr/local/$2/$3"
1725 test -d /usr/local/$2/$3/$2 && $1="[$]$1 /usr/local/$2/$3/$2"
1726 }
1727
1728 test "$prefix" != NONE && \
1729 test -d $prefix && {
1730 test -n "$verbose" && echo " ... testing $3-directories under $prefix"
1731 test -d $prefix/$3 && $1="[$]$1 $prefix/$3"
1732 test -d $prefix/$3/$2 && $1="[$]$1 $prefix/$3/$2"
1733 test -d $prefix/$3/$2/$3 && $1="[$]$1 $prefix/$3/$2/$3"
1734 test -d $prefix/$2/$3 && $1="[$]$1 $prefix/$2/$3"
1735 test -d $prefix/$2/$3/$2 && $1="[$]$1 $prefix/$2/$3/$2"
1736 }
1737
1738 test "$prefix" != /opt && \
1739 test -d /opt && {
1740 test -n "$verbose" && echo " ... testing $3-directories under /opt"
1741 test -d /opt/$3 && $1="[$]$1 /opt/$3"
1742 test -d /opt/$3/$2 && $1="[$]$1 /opt/$3/$2"
1743 test -d /opt/$3/$2/$3 && $1="[$]$1 /opt/$3/$2/$3"
1744 test -d /opt/$2/$3 && $1="[$]$1 /opt/$2/$3"
1745 test -d /opt/$2/$3/$2 && $1="[$]$1 /opt/$2/$3/$2"
1746 }
1747
1748 test "$prefix" != /usr && \
1749 test -d /usr && {
1750 test -n "$verbose" && echo " ... testing $3-directories under /usr"
1751 test -d /usr/$3 && $1="[$]$1 /usr/$3"
1752 test -d /usr/$3/$2 && $1="[$]$1 /usr/$3/$2"
1753 test -d /usr/$3/$2/$3 && $1="[$]$1 /usr/$3/$2/$3"
1754 test -d /usr/$2/$3 && $1="[$]$1 /usr/$2/$3"
1755 }
1756 ])dnl
1757 dnl ---------------------------------------------------------------------------
1758 dnl CF_SUBST version: 2 updated: 1997/09/06 23:41:28
1759 dnl --------
1760 dnl Shorthand macro for substituting things that the user may override
1761 dnl with an environment variable.
1762 dnl
1763 dnl $1 = long/descriptive name
1764 dnl $2 = environment variable
1765 dnl $3 = default value
1766 AC_DEFUN([CF_SUBST],
1767 [AC_CACHE_VAL(cf_cv_subst_$2,[
1768 AC_MSG_CHECKING(for $1 (symbol $2))
1769 test -z "[$]$2" && $2=$3
1770 AC_MSG_RESULT([$]$2)
1771 AC_SUBST($2)
1772 cf_cv_subst_$2=[$]$2])
1773 $2=${cf_cv_subst_$2}
1774 ])dnl
1775 dnl ---------------------------------------------------------------------------
1776 dnl CF_SYSTYPE version: 3 updated: 2001/02/03 00:14:59
1777 dnl ----------
1778 dnl Derive the system-type (our main clue to the method of building shared
1779 dnl libraries).
1780 AC_DEFUN([CF_SYSTYPE],
1781 [
1782 AC_MSG_CHECKING(for system type)
1783 AC_CACHE_VAL(cf_cv_systype,[
1784 AC_ARG_WITH(system-type,
1785 [ --with-system-type=XXX test: override derived host system-type],
1786 [cf_cv_systype=$withval],
1787 [
1788 cf_cv_systype="`(uname -s || hostname || echo unknown) 2>/dev/null |sed -e s'/[[:\/.-]]/_/'g | sed 1q`"
1789 if test -z "$cf_cv_systype"; then cf_cv_systype=unknown;fi
1790 ])])
1791 AC_MSG_RESULT($cf_cv_systype)
1792 ])dnl
1793 dnl ---------------------------------------------------------------------------
1794 dnl CF_SYS_NAME version: 2 updated: 1997/08/28 23:57:55
1795 dnl -----------
1796 dnl Derive the system name, as a check for reusing the autoconf cache
1797 AC_DEFUN([CF_SYS_NAME],
1798 [
1799 SYS_NAME=`(uname -s -r || uname -a || hostname) 2>/dev/null | sed 1q`
1800 test -z "$SYS_NAME" && SYS_NAME=unknown
1801 AC_DEFINE_UNQUOTED(SYS_NAME,"$SYS_NAME")
1802
1803 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$SYS_NAME"])
1804
1805 if test ".$SYS_NAME" != ".$cf_cv_system_name" ; then
1806 AC_MSG_RESULT("Cached system name does not agree with actual")
1807 AC_ERROR("Please remove config.cache and try again.")
1808 fi])
1809 dnl ---------------------------------------------------------------------------
1810 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1811 dnl --------
1812 dnl Make an uppercase version of a variable
1813 dnl $1=uppercase($2)
1814 AC_DEFUN([CF_UPPER],
1815 [
1816 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1817 ])dnl
1818 dnl ---------------------------------------------------------------------------
1819 dnl CF_UTF8_LIB version: 4 updated: 2003/03/01 18:36:42
1820 dnl -----------
1821 dnl Check for multibyte support, and if not found, utf8 compatibility library
1822 AC_DEFUN([CF_UTF8_LIB],
1823 [
1824 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
1825 cf_save_LIBS="$LIBS"
1826 AC_TRY_LINK([
1827 #include <stdlib.h>],[putwc(0,0);],
1828 [cf_cv_utf8_lib=yes],
1829 [LIBS="-lutf8 $LIBS"
1830 AC_TRY_LINK([
1831 #include <libutf8.h>],[putwc(0,0);],
1832 [cf_cv_utf8_lib=add-on],
1833 [cf_cv_utf8_lib=no])
1834 LIBS="$cf_save_LIBS"
1835 ])])
1836
1837 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
1838 # ncurses/ncursesw:
1839 if test "$cf_cv_utf8_lib" = "add-on" ; then
1840 AC_DEFINE(HAVE_LIBUTF8_H)
1841 LIBS="-lutf8 $LIBS"
1842 fi
1843 ])dnl
1844 dnl ---------------------------------------------------------------------------
1845 dnl CF_VERBOSE version: 2 updated: 1997/09/05 10:45:14
1846 dnl ----------
1847 dnl Use AC_VERBOSE w/o the warnings
1848 AC_DEFUN([CF_VERBOSE],
1849 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
1850 ])dnl
1851 dnl ---------------------------------------------------------------------------
1852 dnl CF_VERSION_INFO version: 3 updated: 2003/11/22 12:22:45
1853 dnl ---------------
1854 dnl Define several useful symbols derived from the VERSION file. A separate
1855 dnl file is preferred to embedding the version numbers in various scripts.
1856 dnl (automake is a textbook-example of why the latter is a bad idea, but there
1857 dnl are others).
1858 dnl
1859 dnl The file contents are:
1860 dnl libtool-version release-version patch-version
1861 dnl or
1862 dnl release-version
1863 dnl where
1864 dnl libtool-version (see ?) consists of 3 integers separated by '.'
1865 dnl release-version consists of a major version and minor version
1866 dnl separated by '.', optionally followed by a patch-version
1867 dnl separated by '-'. The minor version need not be an
1868 dnl integer (but it is preferred).
1869 dnl patch-version is an integer in the form yyyymmdd, so ifdef's and
1870 dnl scripts can easily compare versions.
1871 dnl
1872 dnl If libtool is used, the first form is required, since CF_WITH_LIBTOOL
1873 dnl simply extracts the first field using 'cut -f1'.
1874 AC_DEFUN([CF_VERSION_INFO],
1875 [
1876 if test -f $srcdir/VERSION ; then
1877 AC_MSG_CHECKING(for package version)
1878
1879 # if there are not enough fields, cut returns the last one...
1880 cf_field1=`sed -e '2,$d' $srcdir/VERSION|cut -f1`
1881 cf_field2=`sed -e '2,$d' $srcdir/VERSION|cut -f2`
1882 cf_field3=`sed -e '2,$d' $srcdir/VERSION|cut -f3`
1883
1884 # this is how CF_BUNDLED_INTL uses $VERSION:
1885 VERSION="$cf_field1"
1886
1887 VERSION_MAJOR=`echo "$cf_field2" | sed -e 's/\..*//'`
1888 test -z "$VERSION_MAJOR" && AC_MSG_ERROR(missing major-version)
1889
1890 VERSION_MINOR=`echo "$cf_field2" | sed -e 's/^[[^.]]*\.//' -e 's/-.*//'`
1891 test -z "$VERSION_MINOR" && AC_MSG_ERROR(missing minor-version)
1892
1893 AC_MSG_RESULT(${VERSION_MAJOR}.${VERSION_MINOR})
1894
1895 AC_MSG_CHECKING(for package patch date)
1896 VERSION_PATCH=`echo "$cf_field3" | sed -e 's/^[[^-]]*-//'`
1897 case .$VERSION_PATCH in
1898 .)
1899 AC_MSG_ERROR(missing patch-date $VERSION_PATCH)
1900 ;;
1901 .[[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]])
1902 ;;
1903 *)
1904 AC_MSG_ERROR(illegal patch-date $VERSION_PATCH)
1905 ;;
1906 esac
1907 AC_MSG_RESULT($VERSION_PATCH)
1908 else
1909 AC_MSG_ERROR(did not find $srcdir/VERSION)
1910 fi
1911
1912 # show the actual data that we have for versions:
1913 CF_VERBOSE(VERSION $VERSION)
1914 CF_VERBOSE(VERSION_MAJOR $VERSION_MAJOR)
1915 CF_VERBOSE(VERSION_MINOR $VERSION_MINOR)
1916 CF_VERBOSE(VERSION_PATCH $VERSION_PATCH)
1917
1918 AC_SUBST(VERSION)
1919 AC_SUBST(VERSION_MAJOR)
1920 AC_SUBST(VERSION_MINOR)
1921 AC_SUBST(VERSION_PATCH)
1922
1923 dnl if a package name is given, define its corresponding version info. We
1924 dnl need the package name to ensure that the defined symbols are unique.
1925 ifelse($1,,,[
1926 PACKAGE=$1
1927 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
1928 AC_SUBST(PACKAGE)
1929 CF_UPPER(cf_PACKAGE,$PACKAGE)
1930 AC_DEFINE_UNQUOTED(${cf_PACKAGE}_VERSION,"${VERSION_MAJOR}.${VERSION_MINOR}")
1931 AC_DEFINE_UNQUOTED(${cf_PACKAGE}_PATCHDATE,${VERSION_PATCH})
1932 ])
1933 ])dnl
1934 dnl ---------------------------------------------------------------------------
1935 dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
1936 dnl ------------------
1937 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
1938 dnl libraries.
1939 AC_DEFUN([CF_WITH_CURSES_DIR],[
1940 AC_ARG_WITH(curses-dir,
1941 [ --with-curses-dir=DIR directory in which (n)curses is installed],
1942 [CF_PATH_SYNTAX(withval)
1943 cf_cv_curses_dir=$withval],
1944 [cf_cv_curses_dir=no])
1945 ])dnl
1946 dnl ---------------------------------------------------------------------------
1947 dnl CF_WITH_DBMALLOC version: 4 updated: 2004/02/28 05:49:27
1948 dnl ----------------
1949 dnl Configure-option for dbmalloc. The optional parameter is used to override
1950 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1951 AC_DEFUN([CF_WITH_DBMALLOC],[
1952 AC_MSG_CHECKING(if you want to link with dbmalloc for testing)
1953 AC_ARG_WITH(dbmalloc,
1954 [ --with-dbmalloc use Conor Cahill's dbmalloc library],
1955 [with_dbmalloc=$withval],
1956 [with_dbmalloc=no])
1957 AC_MSG_RESULT($with_dbmalloc)
1958 if test "$with_dbmalloc" = yes ; then
1959 AC_CHECK_HEADER(dbmalloc.h,
1960 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse($1,,[],[,$1]))])
1961 fi
1962 ])dnl
1963 dnl ---------------------------------------------------------------------------
1964 dnl CF_WITH_DMALLOC version: 4 updated: 2004/02/28 05:49:27
1965 dnl ---------------
1966 dnl Configure-option for dmalloc. The optional parameter is used to override
1967 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1968 AC_DEFUN([CF_WITH_DMALLOC],[
1969 AC_MSG_CHECKING(if you want to link with dmalloc for testing)
1970 AC_ARG_WITH(dmalloc,
1971 [ --with-dmalloc use Gray Watson's dmalloc library],
1972 [with_dmalloc=$withval],
1973 [with_dmalloc=no])
1974 AC_MSG_RESULT($with_dmalloc)
1975 if test "$with_dmalloc" = yes ; then
1976 AC_CHECK_HEADER(dmalloc.h,
1977 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse($1,,[],[,$1]))])
1978 fi
1979 ])dnl
1980 dnl ---------------------------------------------------------------------------
1981 dnl CF_WITH_LIBTOOL version: 9 updated: 2004/01/16 14:55:37
1982 dnl ---------------
1983 dnl Provide a configure option to incorporate libtool. Define several useful
1984 dnl symbols for the makefile rules.
1985 dnl
1986 dnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses
1987 dnl macros from libtool.m4 which is in the aclocal directory of automake.
1988 dnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro.
1989 dnl But that still does not work properly since the macro is expanded outside
1990 dnl the CF_WITH_LIBTOOL macro:
1991 dnl
1992 dnl #!/bin/sh
1993 dnl ACLOCAL=`aclocal --print-ac-dir`
1994 dnl if test -z "$ACLOCAL" ; then
1995 dnl echo cannot find aclocal directory
1996 dnl exit 1
1997 dnl elif test ! -f $ACLOCAL/libtool.m4 ; then
1998 dnl echo cannot find libtool.m4 file
1999 dnl exit 1
2000 dnl fi
2001 dnl
2002 dnl LOCAL=aclocal.m4
2003 dnl ORIG=aclocal.m4.orig
2004 dnl
2005 dnl trap "mv $ORIG $LOCAL" 0 1 2 5 15
2006 dnl rm -f $ORIG
2007 dnl mv $LOCAL $ORIG
2008 dnl
2009 dnl # sed the LIBTOOL= assignment to omit the current directory?
2010 dnl sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL
2011 dnl cat $ORIG >>$LOCAL
2012 dnl
2013 dnl autoconf-257 $*
2014 dnl
2015 AC_DEFUN([CF_WITH_LIBTOOL],
2016 [
2017 ifdef([AC_PROG_LIBTOOL],,[
2018 LIBTOOL=
2019 ])
2020 # common library maintenance symbols that are convenient for libtool scripts:
2021 LIB_CREATE='$(AR) -cr'
2022 LIB_OBJECT='$(OBJECTS)'
2023 LIB_SUFFIX=.a
2024 LIB_PREP="$RANLIB"
2025
2026 # symbols used to prop libtool up to enable it to determine what it should be
2027 # doing:
2028 LIB_CLEAN=
2029 LIB_COMPILE=
2030 LIB_LINK=
2031 LIB_INSTALL=
2032 LIB_UNINSTALL=
2033
2034 AC_MSG_CHECKING(if you want to build libraries with libtool)
2035 AC_ARG_WITH(libtool,
2036 [ --with-libtool generate libraries with libtool],
2037 [with_libtool=$withval],
2038 [with_libtool=no])
2039 AC_MSG_RESULT($with_libtool)
2040 if test "$with_libtool" != "no"; then
2041 ifdef([AC_PROG_LIBTOOL],[
2042 # missing_content_AC_PROG_LIBTOOL{{
2043 AC_PROG_LIBTOOL
2044 # missing_content_AC_PROG_LIBTOOL}}
2045 ],[
2046 if test "$with_libtool" != "yes" ; then
2047 CF_PATH_SYNTAX(with_libtool)
2048 LIBTOOL=$with_libtool
2049 else
2050 AC_PATH_PROG(LIBTOOL,libtool)
2051 fi
2052 if test -z "$LIBTOOL" ; then
2053 AC_MSG_ERROR(Cannot find libtool)
2054 fi
2055 ])dnl
2056 LIB_CREATE='$(LIBTOOL) --mode=link $(CC) -rpath $(DESTDIR)$(libdir) -version-info `cut -f1 $(srcdir)/VERSION` -o'
2057 LIB_OBJECT='$(OBJECTS:.o=.lo)'
2058 LIB_SUFFIX=.la
2059 LIB_CLEAN='$(LIBTOOL) --mode=clean'
2060 LIB_COMPILE='$(LIBTOOL) --mode=compile'
2061 LIB_LINK='$(LIBTOOL) --mode=link'
2062 LIB_INSTALL='$(LIBTOOL) --mode=install'
2063 LIB_UNINSTALL='$(LIBTOOL) --mode=uninstall'
2064 LIB_PREP=:
2065
2066 # Show the version of libtool
2067 AC_MSG_CHECKING(version of libtool)
2068
2069 # Save the version in a cache variable - this is not entirely a good
2070 # thing, but the version string from libtool is very ugly, and for
2071 # bug reports it might be useful to have the original string.
2072 cf_cv_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '2,$d' -e 's/([[^)]]*)//g' -e 's/^[[^1-9]]*//' -e 's/[[^0-9.]].*//'`
2073 AC_MSG_RESULT($cf_cv_libtool_version)
2074 if test -z "$cf_cv_libtool_version" ; then
2075 AC_MSG_ERROR(This is not libtool)
2076 fi
2077
2078 # special hack to add --tag option for C++ compiler
2079 case $cf_cv_libtool_version in
2080 1.[[5-9]]*|[[2-9]]*)
2081 LIBTOOL_CXX="$LIBTOOL --tag=CXX"
2082 ;;
2083 *)
2084 LIBTOOL_CXX="$LIBTOOL"
2085 ;;
2086 esac
2087 else
2088 LIBTOOL=""
2089 LIBTOOL_CXX=""
2090 fi
2091
2092 test -z "$LIBTOOL" && ECHO_LT=
2093
2094 AC_SUBST(LIBTOOL)
2095 AC_SUBST(LIBTOOL_CXX)
2096
2097 AC_SUBST(LIB_CREATE)
2098 AC_SUBST(LIB_OBJECT)
2099 AC_SUBST(LIB_SUFFIX)
2100 AC_SUBST(LIB_PREP)
2101
2102 AC_SUBST(LIB_CLEAN)
2103 AC_SUBST(LIB_COMPILE)
2104 AC_SUBST(LIB_LINK)
2105 AC_SUBST(LIB_INSTALL)
2106 AC_SUBST(LIB_UNINSTALL)
2107
2108 ])dnl
2109 dnl ---------------------------------------------------------------------------
2110 dnl CF_WITH_NC_ALLOC_H version: 2 updated: 2005/12/26 17:09:34
2111 dnl ------------------
2112 dnl Applications that use ncurses can provide better leak-checking if they
2113 dnl call ncurses' functions to free its memory on exit. That is normally not
2114 dnl configured (--disable-leaks), but is useful in a debugging library.
2115 dnl
2116 dnl Use this after checking for ncurses/ncursesw libraries.
2117 AC_DEFUN([CF_WITH_NC_ALLOC_H],
2118 [
2119 case $LIBS in #(vi
2120 *ncurses*)
2121
2122 AC_MSG_CHECKING(if you want to check for memory leaks)
2123 cf_disable_leaks=no
2124 AC_ARG_ENABLE(leaks,
2125 [ --disable-leaks test: suppress permanent memory-leaks],
2126 [test "$enableval" = no && cf_disable_leaks=yes])
2127 AC_MSG_RESULT($cf_disable_leaks)
2128
2129 if test "$cf_disable_leaks" = yes ; then
2130 AC_DEFINE(NO_LEAKS)
2131 AC_CHECK_HEADERS(nc_alloc.h)
2132 AC_CHECK_FUNCS(_nc_free_and_exit)
2133 fi
2134 ;;
2135 esac
2136 ])dnl
2137 dnl ---------------------------------------------------------------------------
2138 dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
2139 dnl ----------------
2140 dnl Combine the checks for gcc features into a configure-script option
2141 dnl
2142 dnl Parameters:
2143 dnl $1 - see CF_GCC_WARNINGS
2144 AC_DEFUN([CF_WITH_WARNINGS],
2145 [
2146 if ( test "$GCC" = yes || test "$GXX" = yes )
2147 then
2148 AC_MSG_CHECKING(if you want to check for gcc warnings)
2149 AC_ARG_WITH(warnings,
2150 [ --with-warnings test: turn on gcc warnings],
2151 [cf_opt_with_warnings=$withval],
2152 [cf_opt_with_warnings=no])
2153 AC_MSG_RESULT($cf_opt_with_warnings)
2154 if test "$cf_opt_with_warnings" != no ; then
2155 CF_GCC_ATTRIBUTES
2156 CF_GCC_WARNINGS([$1])
2157 fi
2158 fi
2159 ])dnl
2160 dnl ---------------------------------------------------------------------------
2161 dnl CF_XOPEN_CURSES version: 8 updated: 2003/11/07 19:47:46
2162 dnl ---------------
2163 dnl Test if we should define X/Open source for curses, needed on Digital Unix
2164 dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
2165 dnl
2166 dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
2167 dnl as getbegy(). The latter is better design, but the former is standard.
2168 AC_DEFUN([CF_XOPEN_CURSES],
2169 [
2170 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2171 AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
2172 AC_TRY_LINK([
2173 #include <stdlib.h>
2174 #include <${cf_cv_ncurses_header-curses.h}>],[
2175 long x = winnstr(stdscr, "", 0);
2176 int x1, y1;
2177 getbegyx(stdscr, y1, x1)],
2178 [cf_cv_need_xopen_extension=no],
2179 [AC_TRY_LINK([
2180 #define _XOPEN_SOURCE_EXTENDED
2181 #include <stdlib.h>
2182 #include <${cf_cv_ncurses_header-curses.h}>],[
2183 long x = winnstr(stdscr, "", 0);
2184 int x1, y1;
2185 getbegyx(stdscr, y1, x1)],
2186 [cf_cv_need_xopen_extension=yes],
2187 [cf_cv_need_xopen_extension=unknown])])])
2188 test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
2189 ])dnl
2190 dnl ---------------------------------------------------------------------------
2191 dnl CF_XOPEN_SOURCE version: 23 updated: 2005/10/15 16:39:05
2192 dnl ---------------
2193 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
2194 dnl or adapt to the vendor's definitions to get equivalent functionality.
2195 dnl
2196 dnl Parameters:
2197 dnl $1 is the nominal value for _XOPEN_SOURCE
2198 dnl $2 is the nominal value for _POSIX_C_SOURCE
2199 AC_DEFUN([CF_XOPEN_SOURCE],[
2200
2201 AC_REQUIRE([CF_PROG_CC_U_D])
2202
2203 cf_XOPEN_SOURCE=ifelse($1,,500,$1)
2204 cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
2205
2206 case $host_os in #(vi
2207 aix[[45]]*) #(vi
2208 CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
2209 ;;
2210 freebsd*) #(vi
2211 # 5.x headers associate
2212 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
2213 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
2214 cf_POSIX_C_SOURCE=200112L
2215 cf_XOPEN_SOURCE=600
2216 CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2217 ;;
2218 hpux*) #(vi
2219 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
2220 ;;
2221 irix[[56]].*) #(vi
2222 CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
2223 ;;
2224 linux*|gnu*) #(vi
2225 CF_GNU_SOURCE
2226 ;;
2227 mirbsd*) #(vi
2228 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
2229 ;;
2230 netbsd*) #(vi
2231 # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
2232 ;;
2233 openbsd*) #(vi
2234 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
2235 ;;
2236 osf[[45]]*) #(vi
2237 CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
2238 ;;
2239 nto-qnx*) #(vi
2240 CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE"
2241 ;;
2242 sco*) #(vi
2243 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
2244 ;;
2245 solaris*) #(vi
2246 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
2247 ;;
2248 *)
2249 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
2250 AC_TRY_COMPILE([#include <sys/types.h>],[
2251 #ifndef _XOPEN_SOURCE
2252 make an error
2253 #endif],
2254 [cf_cv_xopen_source=no],
2255 [cf_save="$CPPFLAGS"
2256 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2257 AC_TRY_COMPILE([#include <sys/types.h>],[
2258 #ifdef _XOPEN_SOURCE
2259 make an error
2260 #endif],
2261 [cf_cv_xopen_source=no],
2262 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
2263 CPPFLAGS="$cf_save"
2264 ])
2265 ])
2266 if test "$cf_cv_xopen_source" != no ; then
2267 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
2268 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
2269 test "$cf_cv_cc_u_d_options" = yes && \
2270 CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
2271 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source"
2272 fi
2273 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
2274 ;;
2275 esac
2276 ])
2277 dnl ---------------------------------------------------------------------------
2278 dnl CF_X_ATHENA version: 12 updated: 2004/06/15 21:14:41
2279 dnl -----------
2280 dnl Check for Xaw (Athena) libraries
2281 dnl
2282 dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
2283 AC_DEFUN([CF_X_ATHENA],
2284 [AC_REQUIRE([CF_X_TOOLKIT])
2285 cf_x_athena=${cf_x_athena-Xaw}
2286
2287 AC_MSG_CHECKING(if you want to link with Xaw 3d library)
2288 withval=
2289 AC_ARG_WITH(Xaw3d,
2290 [ --with-Xaw3d link with Xaw 3d library])
2291 if test "$withval" = yes ; then
2292 cf_x_athena=Xaw3d
2293 AC_MSG_RESULT(yes)
2294 else
2295 AC_MSG_RESULT(no)
2296 fi
2297
2298 AC_MSG_CHECKING(if you want to link with neXT Athena library)
2299 withval=
2300 AC_ARG_WITH(neXtaw,
2301 [ --with-neXtaw link with neXT Athena library])
2302 if test "$withval" = yes ; then
2303 cf_x_athena=neXtaw
2304 AC_MSG_RESULT(yes)
2305 else
2306 AC_MSG_RESULT(no)
2307 fi
2308
2309 AC_MSG_CHECKING(if you want to link with Athena-Plus library)
2310 withval=
2311 AC_ARG_WITH(XawPlus,
2312 [ --with-XawPlus link with Athena-Plus library])
2313 if test "$withval" = yes ; then
2314 cf_x_athena=XawPlus
2315 AC_MSG_RESULT(yes)
2316 else
2317 AC_MSG_RESULT(no)
2318 fi
2319
2320 AC_CHECK_LIB(Xext,XextCreateExtension,
2321 [LIBS="-lXext $LIBS"])
2322
2323 cf_x_athena_lib=""
2324
2325 CF_X_ATHENA_CPPFLAGS($cf_x_athena)
2326 CF_X_ATHENA_LIBS($cf_x_athena)
2327 ])dnl
2328 dnl ---------------------------------------------------------------------------
2329 dnl CF_X_ATHENA_CPPFLAGS version: 2 updated: 2002/10/09 20:00:37
2330 dnl --------------------
2331 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
2332 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
2333 AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
2334 [
2335 cf_x_athena_root=ifelse($1,,Xaw,$1)
2336 cf_x_athena_include=""
2337
2338 for cf_path in default \
2339 /usr/contrib/X11R6 \
2340 /usr/contrib/X11R5 \
2341 /usr/lib/X11R5 \
2342 /usr/local
2343 do
2344 if test -z "$cf_x_athena_include" ; then
2345 cf_save="$CPPFLAGS"
2346 cf_test=X11/$cf_x_athena_root/SimpleMenu.h
2347 if test $cf_path != default ; then
2348 CPPFLAGS="-I$cf_path/include $cf_save"
2349 AC_MSG_CHECKING(for $cf_test in $cf_path)
2350 else
2351 AC_MSG_CHECKING(for $cf_test)
2352 fi
2353 AC_TRY_COMPILE([
2354 #include <X11/Intrinsic.h>
2355 #include <$cf_test>],[],
2356 [cf_result=yes],
2357 [cf_result=no])
2358 AC_MSG_RESULT($cf_result)
2359 if test "$cf_result" = yes ; then
2360 cf_x_athena_include=$cf_path
2361 break
2362 else
2363 CPPFLAGS="$cf_save"
2364 fi
2365 fi
2366 done
2367
2368 if test -z "$cf_x_athena_include" ; then
2369 AC_MSG_WARN(
2370 [Unable to successfully find Athena header files with test program])
2371 elif test "$cf_x_athena_include" != default ; then
2372 CPPFLAGS="$CPPFLAGS -I$cf_x_athena_include"
2373 fi
2374 ])
2375 dnl ---------------------------------------------------------------------------
2376 dnl CF_X_ATHENA_LIBS version: 3 updated: 2003/02/16 15:24:54
2377 dnl ----------------
2378 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
2379 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
2380 AC_DEFUN([CF_X_ATHENA_LIBS],
2381 [AC_REQUIRE([CF_X_TOOLKIT])
2382 cf_x_athena_root=ifelse($1,,Xaw,$1)
2383 cf_x_athena_lib=""
2384
2385 for cf_path in default \
2386 /usr/contrib/X11R6 \
2387 /usr/contrib/X11R5 \
2388 /usr/lib/X11R5 \
2389 /usr/local
2390 do
2391 for cf_lib in \
2392 "-l$cf_x_athena_root -lXmu" \
2393 "-l$cf_x_athena_root -lXpm -lXmu" \
2394 "-l${cf_x_athena_root}_s -lXmu_s"
2395 do
2396 if test -z "$cf_x_athena_lib" ; then
2397 cf_save="$LIBS"
2398 cf_test=XawSimpleMenuAddGlobalActions
2399 if test $cf_path != default ; then
2400 LIBS="-L$cf_path/lib $cf_lib $LIBS"
2401 AC_MSG_CHECKING(for $cf_lib in $cf_path)
2402 else
2403 LIBS="$cf_lib $LIBS"
2404 AC_MSG_CHECKING(for $cf_test in $cf_lib)
2405 fi
2406 cf_SAVE="$LIBS"
2407 LIBS="$X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
2408 AC_TRY_LINK([],[$cf_test()],
2409 [cf_result=yes],
2410 [cf_result=no])
2411 AC_MSG_RESULT($cf_result)
2412 if test "$cf_result" = yes ; then
2413 cf_x_athena_lib="$cf_lib"
2414 LIBS="$cf_SAVE"
2415 break
2416 else
2417 LIBS="$cf_save"
2418 fi
2419 fi
2420 done
2421 done
2422
2423 if test -z "$cf_x_athena_lib" ; then
2424 AC_ERROR(
2425 [Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
2426 fi
2427
2428 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
2429 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
2430 ])
2431 dnl ---------------------------------------------------------------------------
2432 dnl CF_X_TOOLKIT version: 10 updated: 2004/04/25 15:37:17
2433 dnl ------------
2434 dnl Check for X Toolkit libraries
2435 dnl
2436 AC_DEFUN([CF_X_TOOLKIT],
2437 [
2438 AC_REQUIRE([AC_PATH_XTRA])
2439 AC_REQUIRE([CF_CHECK_CACHE])
2440
2441 # SYSTEM_NAME=`echo "$cf_cv_system_name"|tr ' ' -`
2442
2443 cf_have_X_LIBS=no
2444
2445 LDFLAGS="$X_LIBS $LDFLAGS"
2446 CF_CHECK_CFLAGS($X_CFLAGS)
2447
2448 AC_CHECK_FUNC(XOpenDisplay,,[
2449 AC_CHECK_LIB(X11,XOpenDisplay,
2450 [LIBS="-lX11 $LIBS"],,
2451 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
2452
2453 AC_CHECK_FUNC(XtAppInitialize,,[
2454 AC_CHECK_LIB(Xt, XtAppInitialize,
2455 [AC_DEFINE(HAVE_LIBXT)
2456 cf_have_X_LIBS=Xt
2457 LIBS="-lXt $X_PRE_LIBS $LIBS"],,
2458 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
2459
2460 if test $cf_have_X_LIBS = no ; then
2461 AC_WARN(
2462 [Unable to successfully link X Toolkit library (-lXt) with
2463 test program. You will have to check and add the proper libraries by hand
2464 to makefile.])
2465 fi
2466 ])dnl
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/04 10:42:58 $
5 * $Revision: 1.102 $
6 */
7
8 /*
9 * Declare file local prototypes.
10 */
11 static BINDFN_PROTO (adjustAlphalistCB);
12 static BINDFN_PROTO (completeWordCB);
13 static int preProcessEntryField (EObjectType cdktype, void *object, void *clientData, chtype input);
14 static int createList (CDKALPHALIST *alphalist, char **list, int listSize);
15
16 DeclareSetXXchar (static, _setMy);
17 DeclareCDKObjects (ALPHALIST, Alphalist, _setMy, String);
18
19 /*
20 * This creates the alphalist widget.
21 */
22 CDKALPHALIST *newCDKAlphalist (CDKSCREEN *cdkscreen,
23 int xplace,
24 int yplace,
25 int height,
26 int width,
27 char *title,
28 char *label,
29 char **list,
30 int listSize,
31 chtype fillerChar,
32 chtype highlight,
33 boolean Box,
34 boolean shadow)
35 {
36 CDKALPHALIST *alphalist = 0;
37 chtype *chtypeLabel = 0;
38 int parentWidth = getmaxx (cdkscreen->window);
39 int parentHeight = getmaxy (cdkscreen->window);
40 int boxWidth = width;
41 int boxHeight = height;
42 int xpos = xplace;
43 int ypos = yplace;
44 int tempWidth = 0;
45 int tempHeight = 0;
46 int labelLen = 0;
47 int x, junk2;
48
49 static const struct { int from; int to; } bindings[] = {
50 { CDK_BACKCHAR, KEY_PPAGE },
51 { CDK_FORCHAR, KEY_NPAGE },
52 };
53
54 if ((alphalist = newCDKObject (CDKALPHALIST, &my_funcs)) == 0
55 || !createList (alphalist, list, listSize))
56 {
57 destroyCDKObject (alphalist);
58 return (0);
59 }
60
61 setCDKAlphalistBox (alphalist, Box);
62
63 /*
64 * If the height is a negative value, the height will
65 * be ROWS-height, otherwise, the height will be the
66 * given height.
67 */
68 boxHeight = setWidgetDimension (parentHeight, height, 0);
69
70 /*
71 * If the width is a negative value, the width will
72 * be COLS-width, otherwise, the width will be the
73 * given width.
74 */
75 boxWidth = setWidgetDimension (parentWidth, width, 0);
76
77 /* Translate the label char *pointer to a chtype pointer. */
78 if (label != 0)
79 {
80 chtypeLabel = char2Chtype (label, &labelLen, &junk2);
81 freeChtype (chtypeLabel);
82 }
83
84 /* Rejustify the x and y positions if we need to. */
85 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
86
87 /* Make the file selector window. */
88 alphalist->win = newwin (boxHeight, boxWidth, ypos, xpos);
89
90 if (alphalist->win == 0)
91 {
92 destroyCDKObject (alphalist);
93 return (0);
94 }
95 keypad (alphalist->win, TRUE);
96
97 /* Set some variables. */
98 ScreenOf (alphalist) = cdkscreen;
99 alphalist->parent = cdkscreen->window;
100 alphalist->highlight = highlight;
101 alphalist->fillerChar = fillerChar;
102 alphalist->boxHeight = boxHeight;
103 alphalist->boxWidth = boxWidth;
104 initExitType (alphalist);
105 alphalist->shadow = shadow;
106 alphalist->shadowWin = 0;
107
108 /* Do we want a shadow? */
109 if (shadow)
110 {
111 alphalist->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
112 }
113
114 /* Create the entry field. */
115 tempWidth = (isFullWidth (width)
116 ? FULL
117 : boxWidth - 2 - labelLen);
118 alphalist->entryField = newCDKEntry (cdkscreen,
119 getbegx (alphalist->win),
120 getbegy (alphalist->win),
121 title, label,
122 A_NORMAL, fillerChar,
123 vMIXED, tempWidth, 0, 512,
124 Box, FALSE);
125 if (alphalist->entryField == 0)
126 {
127 destroyCDKObject (alphalist);
128 return (0);
129 }
130 setCDKEntryLLChar (alphalist->entryField, ACS_LTEE);
131 setCDKEntryLRChar (alphalist->entryField, ACS_RTEE);
132
133 /* Set the key bindings for the entry field. */
134 bindCDKObject (vENTRY, alphalist->entryField, KEY_UP, adjustAlphalistCB, alphalist);
135 bindCDKObject (vENTRY, alphalist->entryField, KEY_DOWN, adjustAlphalistCB, alphalist);
136 bindCDKObject (vENTRY, alphalist->entryField, KEY_NPAGE, adjustAlphalistCB, alphalist);
137 bindCDKObject (vENTRY, alphalist->entryField, KEY_PPAGE, adjustAlphalistCB, alphalist);
138 bindCDKObject (vENTRY, alphalist->entryField, KEY_TAB, completeWordCB, alphalist);
139
140 /* Set up the post-process function for the entry field. */
141 setCDKEntryPreProcess (alphalist->entryField, preProcessEntryField, alphalist);
142
143 /*
144 * Create the scrolling list. It overlaps the entry field by one line if
145 * we are using box-borders.
146 */
147 tempHeight = getmaxy (alphalist->entryField->win) - BorderOf (alphalist);
148 tempWidth = (isFullWidth (width)
149 ? FULL
150 : boxWidth - 1);
151 alphalist->scrollField = newCDKScroll (cdkscreen,
152 getbegx (alphalist->win),
153 getbegy (alphalist->entryField->win)
154 + tempHeight,
155 RIGHT,
156 boxHeight - tempHeight,
157 tempWidth,
158 0, list, listSize,
159 NONUMBERS, A_REVERSE,
160 Box, FALSE);
161 setCDKScrollULChar (alphalist->scrollField, ACS_LTEE);
162 setCDKScrollURChar (alphalist->scrollField, ACS_RTEE);
163
164 /* Setup the key bindings. */
165 for (x = 0; x < (int) SIZEOF (bindings); ++x)
166 bindCDKObject (vALPHALIST, alphalist, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to);
167
168 registerCDKObject (cdkscreen, vALPHALIST, alphalist);
169
170 return (alphalist);
171 }
172
173 /*
174 * This erases the file selector from the screen.
175 */
176 static void _eraseCDKAlphalist (CDKOBJS *object)
177 {
178 if (validCDKObject (object))
179 {
180 CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
181
182 eraseCDKScroll (alphalist->scrollField);
183 eraseCDKEntry (alphalist->entryField);
184
185 eraseCursesWindow (alphalist->shadowWin);
186 eraseCursesWindow (alphalist->win);
187 }
188 }
189
190 /*
191 * This moves the alphalist field to the given location.
192 */
193 static void _moveCDKAlphalist (CDKOBJS *object,
194 int xplace,
195 int yplace,
196 boolean relative,
197 boolean refresh_flag)
198 {
199 CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
200
201 int currentX = getbegx (alphalist->win);
202 int currentY = getbegy (alphalist->win);
203 int xpos = xplace;
204 int ypos = yplace;
205 int xdiff = 0;
206 int ydiff = 0;
207
208 /*
209 * If this is a relative move, then we will adjust where we want
210 * to move to.
211 */
212 if (relative)
213 {
214 xpos = getbegx (alphalist->win) + xplace;
215 ypos = getbegy (alphalist->win) + yplace;
216 }
217
218 /* Adjust the window if we need to. */
219 alignxy (WindowOf (alphalist), &xpos, &ypos, alphalist->boxWidth, alphalist->boxHeight);
220
221 /* Get the difference. */
222 xdiff = currentX - xpos;
223 ydiff = currentY - ypos;
224
225 /* Move the window to the new location. */
226 moveCursesWindow (alphalist->win, -xdiff, -ydiff);
227 moveCursesWindow (alphalist->shadowWin, -xdiff, -ydiff);
228
229 /* Move the sub-widgets. */
230 moveCDKEntry (alphalist->entryField, xplace, yplace, relative, FALSE);
231 moveCDKScroll (alphalist->scrollField, xplace, yplace, relative, FALSE);
232
233 /* Touch the windows so they 'move'. */
234 refreshCDKWindow (WindowOf (alphalist));
235
236 /* Redraw the window, if they asked for it. */
237 if (refresh_flag)
238 {
239 drawCDKAlphalist (alphalist, ObjOf (alphalist)->box);
240 }
241 }
242
243 /*
244 * The alphalist's focus resides in the entry widget. But the scroll widget
245 * will not draw items highlighted unless it has focus. Temporarily adjust the
246 * focus of the scroll widget when drawing on it to get the right highlighting.
247 */
248 #define SaveFocus(widget) \
249 boolean save = HasFocusObj (ObjOf (widget->scrollField)); \
250 HasFocusObj (ObjOf (widget->scrollField)) = \
251 HasFocusObj (ObjOf (widget->entryField))
252
253 #define RestoreFocus(widget) \
254 HasFocusObj (ObjOf (widget->scrollField)) = save
255
256 static void drawMyScroller (CDKALPHALIST *widget)
257 {
258 SaveFocus (widget);
259 drawCDKScroll (widget->scrollField, ObjOf (widget->scrollField)->box);
260 RestoreFocus (widget);
261 }
262
263 static void injectMyScroller (CDKALPHALIST *widget, chtype key)
264 {
265 SaveFocus (widget);
266 injectCDKScroll (widget->scrollField, key);
267 RestoreFocus (widget);
268 }
269
270 /*
271 * This draws the file selector widget.
272 */
273 static void _drawCDKAlphalist (CDKOBJS *obj, boolean Box GCC_UNUSED)
274 {
275 CDKALPHALIST *alphalist = (CDKALPHALIST *)obj;
276
277 /* Does this widget have a shadow? */
278 if (alphalist->shadowWin != 0)
279 {
280 drawShadow (alphalist->shadowWin);
281 }
282
283 /* Draw in the entry field. */
284 drawCDKEntry (alphalist->entryField, ObjOf (alphalist->entryField)->box);
285
286 /* Draw in the scroll field. */
287 drawMyScroller (alphalist);
288 }
289
290 /*
291 * This activates the file selector.
292 */
293 char *activateCDKAlphalist (CDKALPHALIST *alphalist, chtype *actions)
294 {
295 char *ret = 0;
296
297 /* Draw the widget. */
298 drawCDKAlphalist (alphalist, ObjOf (alphalist)->box);
299
300 /* Activate the widget. */
301 ret = activateCDKEntry (alphalist->entryField, actions);
302
303 /* Copy the exit type from the entry field. */
304 copyExitType (alphalist, alphalist->entryField);
305
306 /* Determine the exit status. */
307 if (alphalist->exitType != vEARLY_EXIT)
308 {
309 return ret;
310 }
311 return 0;
312 }
313
314 /*
315 * This injects a single character into the alphalist.
316 */
317 static int _injectCDKAlphalist (CDKOBJS *object, chtype input)
318 {
319 CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
320 char *ret = unknownString;
321
322 /* Draw the widget. */
323 drawCDKAlphalist (alphalist, ObjOf (alphalist)->box);
324
325 /* Inject a character into the widget. */
326 ret = injectCDKEntry (alphalist->entryField, input);
327
328 /* Copy the exit type from the entry field. */
329 copyExitType (alphalist, alphalist->entryField);
330
331 /* Determine the exit status. */
332 if (alphalist->exitType == vEARLY_EXIT)
333 ret = unknownString;
334
335 ResultOf (alphalist).valueString = ret;
336 return (ret != unknownString);
337 }
338
339 /*
340 * This sets multiple attributes of the widget.
341 */
342 void setCDKAlphalist (CDKALPHALIST *alphalist,
343 char **list,
344 int listSize,
345 chtype fillerChar,
346 chtype highlight,
347 boolean Box)
348 {
349 setCDKAlphalistContents (alphalist, list, listSize);
350 setCDKAlphalistFillerChar (alphalist, fillerChar);
351 setCDKAlphalistHighlight (alphalist, highlight);
352 setCDKAlphalistBox (alphalist, Box);
353 }
354
355 /*
356 * This function sets the information inside the file selector.
357 */
358 void setCDKAlphalistContents (CDKALPHALIST *widget, char **list, int listSize)
359 {
360 CDKSCROLL *scrollp = widget->scrollField;
361 CDKENTRY *entry = widget->entryField;
362
363 if (!createList (widget, list, listSize))
364 return;
365
366 /* Set the information in the scrolling list. */
367 setCDKScroll (scrollp,
368 widget->list,
369 widget->listSize,
370 NONUMBERS,
371 scrollp->highlight,
372 ObjOf (scrollp)->box);
373
374 /* Clean out the entry field. */
375 setCDKAlphalistCurrentItem (widget, 0);
376 cleanCDKEntry (entry);
377
378 /* Redraw the widget. */
379 eraseCDKAlphalist (widget);
380 drawCDKAlphalist (widget, ObjOf (widget)->box);
381 }
382
383 /*
384 * This returns the contents of the widget.
385 */
386 char **getCDKAlphalistContents (CDKALPHALIST *widget, int *size)
387 {
388 (*size) = widget->listSize;
389 return widget->list;
390 }
391
392 /*
393 * Get/set the current position in the scroll-widget.
394 */
395 int getCDKAlphalistCurrentItem (CDKALPHALIST *widget)
396 {
397 return getCDKScrollCurrent (widget->scrollField);
398 }
399
400 void setCDKAlphalistCurrentItem (CDKALPHALIST *widget, int item)
401 {
402 if (widget->listSize != 0)
403 {
404 setCDKScrollCurrent (widget->scrollField, item);
405 setCDKEntryValue (widget->entryField,
406 widget->list[getCDKScrollCurrentItem(widget->scrollField)]);
407 }
408 }
409
410 /*
411 * This sets the filler character of the entry field of the alphalist.
412 */
413 void setCDKAlphalistFillerChar (CDKALPHALIST *alphalist, chtype fillerCharacter)
414 {
415 CDKENTRY *entry = (CDKENTRY *)alphalist->entryField;
416
417 alphalist->fillerChar = fillerCharacter;
418
419 setCDKEntryFillerChar (entry, fillerCharacter);
420 }
421 chtype getCDKAlphalistFillerChar (CDKALPHALIST *alphalist)
422 {
423 return alphalist->fillerChar;
424 }
425
426 /*
427 * This sets the highlight bar attributes.
428 */
429 void setCDKAlphalistHighlight (CDKALPHALIST *alphalist, chtype highlight)
430 {
431 alphalist->highlight = highlight;
432 }
433 chtype getCDKAlphalistHighlight (CDKALPHALIST *alphalist)
434 {
435 return alphalist->highlight;
436 }
437
438 /*
439 * This sets whether or not the widget will be drawn with a box.
440 */
441 void setCDKAlphalistBox (CDKALPHALIST *alphalist, boolean Box)
442 {
443 ObjOf (alphalist)->box = Box;
444 ObjOf (alphalist)->borderSize = Box ? 1 : 0;
445 }
446
447 boolean getCDKAlphalistBox (CDKALPHALIST *alphalist)
448 {
449 return ObjOf (alphalist)->box;
450 }
451
452 /*
453 * These functions set the drawing characters of the widget.
454 */
455 static void _setMyULchar (CDKOBJS *object, chtype character)
456 {
457 CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
458
459 setCDKEntryULChar (alphalist->entryField, character);
460 }
461 static void _setMyURchar (CDKOBJS *object, chtype character)
462 {
463 CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
464
465 setCDKEntryURChar (alphalist->entryField, character);
466 }
467 static void _setMyLLchar (CDKOBJS *object, chtype character)
468 {
469 CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
470
471 setCDKScrollLLChar (alphalist->scrollField, character);
472 }
473 static void _setMyLRchar (CDKOBJS *object, chtype character)
474 {
475 CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
476
477 setCDKScrollLRChar (alphalist->scrollField, character);
478 }
479 static void _setMyVTchar (CDKOBJS *object, chtype character)
480 {
481 CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
482
483 setCDKEntryVerticalChar (alphalist->entryField, character);
484 setCDKScrollVerticalChar (alphalist->scrollField, character);
485 }
486 static void _setMyHZchar (CDKOBJS *object, chtype character)
487 {
488 CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
489
490 setCDKEntryHorizontalChar (alphalist->entryField, character);
491 setCDKScrollHorizontalChar (alphalist->scrollField, character);
492 }
493 static void _setMyBXattr (CDKOBJS *object, chtype character)
494 {
495 CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
496
497 setCDKEntryBoxAttribute (alphalist->entryField, character);
498 setCDKScrollBoxAttribute (alphalist->scrollField, character);
499 }
500
501 /*
502 * This sets the background attribute of the widget.
503 */
504 static void _setBKattrAlphalist (CDKOBJS *obj, chtype attrib)
505 {
506 CDKALPHALIST *alphalist = (CDKALPHALIST *)obj;
507
508 setCDKEntryBackgroundAttrib (alphalist->entryField, attrib);
509 setCDKScrollBackgroundAttrib (alphalist->scrollField, attrib);
510 }
511
512 static void destroyInfo (CDKALPHALIST *widget)
513 {
514 CDKfreeStrings (widget->list);
515 widget->list = 0;
516
517 widget->listSize = 0;
518 }
519
520 /*
521 * This destroys the file selector.
522 */
523 static void _destroyCDKAlphalist (CDKOBJS *object)
524 {
525 if (object != 0)
526 {
527 CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
528
529 destroyInfo (alphalist);
530
531 /* Clean the key bindings. */
532 cleanCDKObjectBindings (vALPHALIST, alphalist);
533
534 destroyCDKEntry (alphalist->entryField);
535 destroyCDKScroll (alphalist->scrollField);
536
537 /* Free up the window pointers. */
538 deleteCursesWindow (alphalist->shadowWin);
539 deleteCursesWindow (alphalist->win);
540
541 /* Unregister the object. */
542 unregisterCDKObject (vALPHALIST, alphalist);
543 }
544 }
545
546 /*
547 * This function sets the pre-process function.
548 */
549 void setCDKAlphalistPreProcess (CDKALPHALIST *alphalist,
550 PROCESSFN callback,
551 void *data)
552 {
553 setCDKEntryPreProcess (alphalist->entryField, callback, data);
554 }
555
556 /*
557 * This function sets the post-process function.
558 */
559 void setCDKAlphalistPostProcess (CDKALPHALIST *alphalist,
560 PROCESSFN callback,
561 void *data)
562 {
563 setCDKEntryPostProcess (alphalist->entryField, callback, data);
564 }
565
566 /*
567 * Start of callback functions.
568 */
569 static int adjustAlphalistCB (EObjectType objectType GCC_UNUSED,
570 void *object GCC_UNUSED,
571 void *clientData,
572 chtype key)
573 {
574 CDKALPHALIST *alphalist = (CDKALPHALIST *)clientData;
575 CDKSCROLL *scrollp = alphalist->scrollField;
576 CDKENTRY *entry = alphalist->entryField;
577 char *current = 0;
578
579 if (scrollp->listSize > 0)
580 {
581 /* Adjust the scrolling list. */
582 injectMyScroller (alphalist, key);
583
584 /* Set the value in the entry field. */
585 current = chtype2Char (scrollp->item[scrollp->currentItem]);
586 setCDKEntryValue (entry, current);
587 drawCDKEntry (entry, ObjOf (entry)->box);
588 freeChar (current);
589 return (TRUE);
590 }
591 Beep ();
592 return (FALSE);
593 }
594
595 /*
596 * This is the heart-beat of the widget.
597 */
598 static int preProcessEntryField (EObjectType cdktype GCC_UNUSED,
599 void *object GCC_UNUSED,
600 void *clientData,
601 chtype input)
602 {
603 CDKALPHALIST *alphalist = (CDKALPHALIST *)clientData;
604 CDKSCROLL *scrollp = alphalist->scrollField;
605 CDKENTRY *entry = alphalist->entryField;
606 int infoLen = ((entry->info != 0)
607 ? (int)strlen (entry->info)
608 : 0);
609 int result = 1;
610 bool empty = FALSE;
611
612 /* Make sure the entry field isn't empty. */
613 if (entry->info == 0)
614 {
615 empty = TRUE;
616 }
617 else if (isCDKObjectBind (ObjTypeOf (alphalist), ObjOf (alphalist), input))
618 {
619 result = 1; /* don't try to use this key in editing */
620 }
621 else if ((isChar (input) &&
622 (isalnum (CharOf (input)) ||
623 ispunct (input))) ||
624 input == KEY_BACKSPACE ||
625 input == KEY_DC)
626 {
627 int Index, difference, absoluteDifference, x;
628 int currPos = (entry->screenCol + entry->leftChar);
629 char *pattern = malloc (infoLen + 2);
630
631 if (pattern != 0)
632 {
633 strcpy (pattern, entry->info);
634
635 if (input == KEY_BACKSPACE || input == KEY_DC)
636 {
637 if (input == KEY_BACKSPACE)
638 --currPos;
639 if (currPos >= 0)
640 strcpy (pattern + currPos, entry->info + currPos + 1);
641 }
642 else
643 {
644 pattern[currPos] = (char)input;
645 strcpy (pattern + currPos + 1, entry->info + currPos);
646 }
647 }
648
649 if (pattern == 0)
650 {
651 Beep ();
652 }
653 else if (strlen (pattern) == 0)
654 {
655 empty = TRUE;
656 }
657 else if ((Index = searchList (alphalist->list, alphalist->listSize, pattern)) >= 0)
658 {
659 difference = Index - scrollp->currentItem;
660 absoluteDifference = abs (difference);
661
662 /*
663 * If the difference is less than zero, then move up.
664 * Otherwise move down.
665 *
666 * If the difference is greater than 10 jump to the new
667 * index position. Otherwise provide the nice scroll.
668 */
669 if (absoluteDifference <= 10)
670 {
671 for (x = 0; x < absoluteDifference; x++)
672 {
673 injectMyScroller (alphalist,
674 ((difference <= 0)
675 ? KEY_UP
676 : KEY_DOWN));
677 }
678 }
679 else
680 {
681 setCDKScrollPosition (scrollp, Index);
682 }
683 drawMyScroller (alphalist);
684 }
685 else
686 {
687 Beep ();
688 result = 0;
689 }
690
691 if (pattern != 0)
692 free (pattern);
693 }
694
695 if (empty)
696 {
697 setCDKScrollPosition (scrollp, 0);
698 drawMyScroller (alphalist);
699 }
700 return result;
701 }
702
703 /*
704 * This tries to complete the word in the entry field.
705 */
706 static int completeWordCB (EObjectType objectType GCC_UNUSED,
707 void *object GCC_UNUSED,
708 void *clientData,
709 chtype key GCC_UNUSED)
710 {
711 CDKALPHALIST *alphalist = (CDKALPHALIST *)clientData;
712 CDKENTRY *entry = (CDKENTRY*)alphalist->entryField;
713 CDKSCROLL *scrollp = 0;
714 int currentIndex = 0;
715 int wordLength = 0;
716 int selected = -1;
717 int altCount = 0;
718 int height = 0;
719 int match = 0;
720 int Index = 0;
721 int ret = 0;
722 int x = 0;
723 char **altWords = 0;
724 unsigned used = 0;
725
726 if (entry->info == 0)
727 {
728 Beep ();
729 return (TRUE);
730 }
731 wordLength = (int)strlen (entry->info);
732
733 /* If the word length is equal to zero, just leave. */
734 if (wordLength == 0)
735 {
736 Beep ();
737 return (TRUE);
738 }
739
740 /* Look for a unique word match. */
741 Index = searchList (alphalist->list, alphalist->listSize, entry->info);
742
743 /* If the index is less than zero, return we didn't find a match. */
744 if (Index < 0)
745 {
746 Beep ();
747 return (TRUE);
748 }
749
750 /* Did we find the last word in the list? */
751 if (Index == alphalist->listSize - 1)
752 {
753 setCDKEntryValue (entry, alphalist->list[Index]);
754 drawCDKEntry (entry, ObjOf (entry)->box);
755 return (TRUE);
756 }
757
758 /* Ok, we found a match, is the next item similar? */
759 ret = strncmp (alphalist->list[Index + 1], entry->info, wordLength);
760 if (ret == 0)
761 {
762 currentIndex = Index;
763 altCount = 0;
764 height = 0;
765 match = 0;
766 selected = -1;
767
768 /* Start looking for alternate words. */
769 /* FIXME: bsearch would be more suitable */
770 while ((currentIndex < alphalist->listSize)
771 && (strncmp (alphalist->list[currentIndex],
772 entry->info,
773 wordLength) == 0))
774 {
775 used = CDKallocStrings (&altWords,
776 alphalist->list[currentIndex++],
777 altCount++,
778 used);
779 }
780
781 /* Determine the height of the scrolling list. */
782 height = (altCount < 8 ? altCount + 3 : 11);
783
784 /* Create a scrolling list of close matches. */
785 scrollp = newCDKScroll (entry->obj.screen,
786 CENTER, CENTER, RIGHT, height, -30,
787 "<C></B/5>Possible Matches.",
788 altWords, altCount, NUMBERS,
789 A_REVERSE, TRUE, FALSE);
790
791 /* Allow them to select a close match. */
792 match = activateCDKScroll (scrollp, 0);
793 selected = scrollp->currentItem;
794
795 /* Check how they exited the list. */
796 if (scrollp->exitType == vESCAPE_HIT)
797 {
798 /* Destroy the scrolling list. */
799 destroyCDKScroll (scrollp);
800
801 /* Clean up. */
802 CDKfreeStrings (altWords);
803
804 /* Beep at the user. */
805 Beep ();
806
807 /* Redraw the alphalist and return. */
808 drawCDKAlphalist (alphalist, ObjOf (alphalist)->box);
809 return (TRUE);
810 }
811
812 /* Destroy the scrolling list. */
813 destroyCDKScroll (scrollp);
814
815 /* Set the entry field to the selected value. */
816 setCDKEntry (entry,
817 altWords[match],
818 entry->min,
819 entry->max,
820 ObjOf (entry)->box);
821
822 /* Move the highlight bar down to the selected value. */
823 for (x = 0; x < selected; x++)
824 {
825 injectMyScroller (alphalist, KEY_DOWN);
826 }
827
828 /* Clean up. */
829 CDKfreeStrings (altWords);
830
831 /* Redraw the alphalist. */
832 drawCDKAlphalist (alphalist, ObjOf (alphalist)->box);
833 }
834 else
835 {
836 /* Set the entry field with the found item. */
837 setCDKEntry (entry,
838 alphalist->list[Index],
839 entry->min,
840 entry->max,
841 ObjOf (entry)->box);
842 drawCDKEntry (entry, ObjOf (entry)->box);
843 }
844 return (TRUE);
845 }
846
847 static int createList (CDKALPHALIST *alphalist, char **list, int listSize)
848 {
849 int status = 0;
850
851 if (listSize > 0)
852 {
853 char **newlist = typeCallocN (char *, listSize + 1);
854
855 if (newlist != 0)
856 {
857 int x;
858
859 /*
860 * We'll sort the list before we use it. It would have been better to
861 * declare list[] const and only modify the copy, but there may be
862 * clients that rely on the old behavior.
863 */
864 sortList (list, listSize);
865
866 /* Copy in the new information. */
867 status = 1;
868 for (x = 0; x < listSize; x++)
869 {
870 if ((newlist[x] = copyChar (list[x])) == 0)
871 {
872 status = 0;
873 break;
874 }
875 }
876 if (status)
877 {
878 destroyInfo (alphalist);
879 alphalist->listSize = listSize;
880 alphalist->list = newlist;
881 }
882 else
883 {
884 CDKfreeStrings (newlist);
885 }
886 }
887 }
888 else
889 {
890 destroyInfo (alphalist);
891 status = TRUE;
892 }
893 return status;
894 }
895
896 static void _focusCDKAlphalist (CDKOBJS *object)
897 {
898 CDKALPHALIST *widget = (CDKALPHALIST *)object;
899
900 FocusObj (ObjOf (widget->entryField));
901 }
902
903 static void _unfocusCDKAlphalist (CDKOBJS *object)
904 {
905 CDKALPHALIST *widget = (CDKALPHALIST *)object;
906
907 UnfocusObj (ObjOf (widget->entryField));
908 }
909
910 dummyRefreshData (Alphalist)
911
912 dummySaveData (Alphalist)
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/04/06 19:59:29 $
5 * $Revision: 1.54 $
6 *
7 * Notes:
8 *
9 * The cdktype parameter passed to bindCDKObject, etc., is redundant since
10 * the object parameter also has the same information. For compatibility
11 * just use it for a sanity check.
12 */
13
14 #ifndef KEY_MAX
15 #define KEY_MAX 512
16 #endif
17
18 static CDKOBJS *bindableObject (EObjectType * cdktype, void *object)
19 {
20 CDKOBJS *obj = (CDKOBJS *)object;
21
22 if (obj != 0 && *cdktype == ObjTypeOf (obj))
23 {
24 if (*cdktype == vFSELECT)
25 {
26 *cdktype = vENTRY;
27 object = ((CDKFSELECT *)object)->entryField;
28 }
29 else if (*cdktype == vALPHALIST)
30 {
31 *cdktype = vENTRY;
32 object = ((CDKALPHALIST *)object)->entryField;
33 }
34 }
35 else
36 {
37 object = 0;
38 }
39 return (CDKOBJS *)object;
40 }
41
42 /*
43 * This inserts a binding.
44 */
45 void bindCDKObject (EObjectType cdktype,
46 void *object,
47 chtype key,
48 BINDFN function,
49 void *data)
50 {
51 CDKOBJS *obj = bindableObject (&cdktype, object);
52
53 if ((key < KEY_MAX) && obj != 0)
54 {
55 if (key != 0 && (unsigned)key >= obj->bindingCount)
56 {
57 unsigned next = (key + 1);
58
59 if (obj->bindingList != 0)
60 obj->bindingList = typeReallocN (CDKBINDING, obj->bindingList, next);
61 else
62 obj->bindingList = typeMallocN (CDKBINDING, next);
63
64 memset (&(obj->bindingList[obj->bindingCount]), 0,
65 (next - obj->bindingCount) * sizeof (CDKBINDING));
66 obj->bindingCount = next;
67 }
68
69 if (obj->bindingList != 0)
70 {
71 obj->bindingList[key].bindFunction = function;
72 obj->bindingList[key].bindData = data;
73 }
74 }
75 }
76
77 /*
78 * This removes a binding on an object.
79 */
80 void unbindCDKObject (EObjectType cdktype, void *object, chtype key)
81 {
82 CDKOBJS *obj = bindableObject (&cdktype, object);
83
84 if (obj != 0 && ((unsigned)key < obj->bindingCount))
85 {
86 obj->bindingList[key].bindFunction = 0;
87 obj->bindingList[key].bindData = 0;
88 }
89 }
90
91 /*
92 * This removes all the bindings for the given objects.
93 */
94 void cleanCDKObjectBindings (EObjectType cdktype, void *object)
95 {
96 CDKOBJS *obj = bindableObject (&cdktype, object);
97
98 if (obj != 0 && obj->bindingList != 0)
99 {
100 unsigned x;
101
102 for (x = 0; x < obj->bindingCount; x++)
103 {
104 (obj)->bindingList[x].bindFunction = 0;
105 (obj)->bindingList[x].bindData = 0;
106 }
107 freeAndNull ((obj)->bindingList);
108 }
109 }
110
111 /*
112 * This checks to see if the binding for the key exists:
113 * If it does then it runs the command and returns its value, normally TRUE.
114 * If it doesn't it returns a FALSE. This way we can 'overwrite' coded
115 * bindings.
116 */
117 int checkCDKObjectBind (EObjectType cdktype, void *object, chtype key)
118 {
119 CDKOBJS *obj = bindableObject (&cdktype, object);
120
121 if (obj != 0 && ((unsigned)key < obj->bindingCount))
122 {
123 if ((obj)->bindingList[key].bindFunction != 0)
124 {
125 BINDFN function = obj->bindingList[key].bindFunction;
126 void *data = obj->bindingList[key].bindData;
127
128 return function (cdktype, object, data, key);
129 }
130 }
131 return (FALSE);
132 }
133
134 /*
135 * This checks to see if the binding for the key exists.
136 */
137 bool isCDKObjectBind (EObjectType cdktype, void *object, chtype key)
138 {
139 bool result = FALSE;
140 CDKOBJS *obj = bindableObject (&cdktype, object);
141
142 if (obj != 0 && ((unsigned)key < obj->bindingCount))
143 {
144 if ((obj)->bindingList[key].bindFunction != 0)
145 result = TRUE;
146 }
147 return (result);
148 }
149
150 /*
151 * This is a dummy function used to ensure that the constant for mapping has
152 * a distinct address.
153 */
154 int getcCDKBind (EObjectType cdktype GCC_UNUSED,
155 void *object GCC_UNUSED,
156 void *clientData GCC_UNUSED,
157 chtype input GCC_UNUSED)
158 {
159 return 0;
160 }
161
162 /*
163 * Read from the input window, filtering keycodes as needed.
164 */
165 int getcCDKObject (CDKOBJS *obj)
166 {
167 EObjectType cdktype = ObjTypeOf (obj);
168 CDKOBJS *test = bindableObject (&cdktype, obj);
169 int result = wgetch (InputWindowOf (obj));
170
171 if (result >= 0
172 && test != 0
173 && (unsigned)result < test->bindingCount
174 && test->bindingList[result].bindFunction == getcCDKBind)
175 {
176 result = (int)(long)test->bindingList[result].bindData;
177 }
178 else if (test == 0
179 || (unsigned)result > test->bindingCount
180 || test->bindingList[result].bindFunction == 0)
181 {
182 switch (result)
183 {
184 case '\r':
185 case '\n':
186 result = KEY_ENTER;
187 break;
188 case '\t':
189 result = KEY_TAB;
190 break;
191 case DELETE:
192 result = KEY_DC;
193 break;
194 case '\b': /* same as CTRL('H'), for ASCII */
195 result = KEY_BACKSPACE;
196 break;
197 case CDK_BEGOFLINE:
198 result = KEY_HOME;
199 break;
200 case CDK_ENDOFLINE:
201 result = KEY_END;
202 break;
203 case CDK_FORCHAR:
204 result = KEY_RIGHT;
205 break;
206 case CDK_BACKCHAR:
207 result = KEY_LEFT;
208 break;
209 case CDK_NEXT:
210 result = KEY_TAB;
211 break;
212 case CDK_PREV:
213 result = KEY_BTAB;
214 break;
215 }
216 }
217 return result;
218 }
219
220 /*
221 * Use this function rather than getcCDKObject(), since we can extend it to
222 * handle wide-characters.
223 */
224 int getchCDKObject (CDKOBJS *obj, boolean *functionKey)
225 {
226 int key = getcCDKObject (obj);
227 *functionKey = (key >= KEY_MIN && key <= KEY_MAX);
228 return key;
229 }
0 #include <cdk_int.h>
1 #include "button.h"
2 #include <limits.h>
3
4 /*
5 * $Author: tom $
6 * $Date: 2006/05/05 00:27:45 $
7 * $Revision: 1.32 $
8 */
9
10 DeclareCDKObjects (BUTTON, Button, setCdk, Int);
11
12 /*
13 * This creates a button widget.
14 */
15 CDKBUTTON *newCDKButton (CDKSCREEN * cdkscreen, int xplace, int yplace, char
16 *text, tButtonCallback callback, boolean Box,
17 boolean shadow)
18 {
19 /* Maintain the button information. */
20 CDKBUTTON *button = 0;
21 int parentWidth = getmaxx (cdkscreen->window);
22 int parentHeight = getmaxy (cdkscreen->window);
23 int boxWidth = 0;
24 int boxHeight;
25 int xpos = xplace;
26 int ypos = yplace;
27
28 if ((button = newCDKObject(CDKBUTTON, &my_funcs)) == 0)
29 return (0);
30
31 setCDKButtonBox (button, Box);
32 boxHeight = 1 + 2 * BorderOf(button);
33
34 /* Translate the char * to a chtype. */
35 button->info = char2Chtype (text, &button->infoLen, &button->infoPos);
36 boxWidth = MAXIMUM (boxWidth, button->infoLen) + 2 * BorderOf(button);
37
38 /* Create the string alignments. */
39 button->infoPos = justifyString (boxWidth - 2 * BorderOf(button),
40 button->infoLen, button->infoPos);
41
42 /*
43 * Make sure we didn't extend beyond the dimensions of the window.
44 */
45 boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth);
46 boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight);
47
48 /* Rejustify the x and y positions if we need to. */
49 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
50
51 /* Create the button. */
52 ScreenOf (button) = cdkscreen;
53 ObjOf (button)->fn = &my_funcs;
54 button->parent = cdkscreen->window;
55 button->win = newwin (boxHeight, boxWidth, ypos, xpos);
56 button->shadowWin = (WINDOW *) NULL;
57 button->xpos = xpos;
58 button->ypos = ypos;
59 button->boxWidth = boxWidth;
60 button->boxHeight = boxHeight;
61 button->callback = callback;
62 ObjOf (button)->inputWindow = button->win;
63 ObjOf (button)->acceptsFocus = TRUE;
64 initExitType(button);
65 button->shadow = shadow;
66
67 /* Is the window NULL? */
68 if (button->win == (WINDOW *) NULL)
69 {
70 destroyCDKObject (button);
71 return (0);
72 }
73
74 keypad (button->win, TRUE);
75
76 /* If a shadow was requested, then create the shadow window. */
77 if (shadow)
78 button->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
79
80 /* Register this baby. */
81 registerCDKObject (cdkscreen, vBUTTON, button);
82
83 /* Return the button pointer. */
84 return (button);
85 }
86
87 /*
88 * This was added for the builder.
89 */
90 int activateCDKButton (CDKBUTTON * button, chtype * actions)
91 {
92 chtype input = 0;
93 boolean functionKey;
94 int ret;
95
96 drawCDKButton (button, ObjOf (button)->box);
97
98 if (actions == 0)
99 {
100 for (;;)
101 {
102 input = getchCDKObject (ObjOf(button), &functionKey);
103
104 /* Inject the character into the widget. */
105 ret = injectCDKButton(button, input);
106 if (button->exitType != vEARLY_EXIT)
107 {
108 return ret;
109 }
110 }
111 }
112 else
113 {
114 int length = chlen (actions);
115 int x = 0;
116
117 /* Inject each character one at a time. */
118 for (x=0; x < length; x++)
119 {
120 ret = injectCDKButton(button, actions[x]);
121 if (button->exitType != vEARLY_EXIT)
122 {
123 return ret;
124 }
125 }
126 }
127
128 /* Set the exit type and exit. */
129 setExitType(button, 0);
130 return -1;
131 }
132
133 /*
134 * This sets multiple attributes of the widget.
135 */
136 void setCDKButton (CDKBUTTON * button, char *mesg, boolean Box)
137 {
138 setCDKButtonMessage (button, mesg);
139 setCDKButtonBox (button, Box);
140 }
141
142 /*
143 * This sets the information within the button.
144 */
145 void setCDKButtonMessage (CDKBUTTON * button, char *info)
146 {
147 /* Clean out the old message. */
148 freeChtype (button->info);
149 button->infoPos = 0;
150 button->infoLen = 0;
151
152 /* Copy in the new message. */
153
154 button->info = char2Chtype (info, &button->infoLen, &button->infoPos);
155 button->infoPos = justifyString (button->boxWidth - 2 * BorderOf(button),
156 button->infoLen, button->infoPos);
157
158 /* Redraw the button widget. */
159 eraseCDKButton (button);
160 drawCDKButton (button, ObjOf (button)->box);
161 }
162
163 chtype *getCDKButtonMessage (CDKBUTTON * button)
164 {
165 return button->info;
166 }
167
168 /*
169 * This sets the box flag for the button widget.
170 */
171 void setCDKButtonBox (CDKBUTTON * button, boolean Box)
172 {
173 ObjOf (button)->box = Box;
174 ObjOf (button)->borderSize = Box ? 1 : 0;
175 }
176
177 boolean getCDKButtonBox (CDKBUTTON * button)
178 {
179 return ObjOf (button)->box;
180 }
181
182 /*
183 * This sets the background attribute of the widget.
184 */
185 static void _setBKattrButton (CDKOBJS * object, chtype attrib)
186 {
187 if (object != 0)
188 {
189 CDKBUTTON *widget = (CDKBUTTON *) object;
190
191 wbkgd (widget->win, attrib);
192 }
193 }
194
195 static void drawCDKButtonText (CDKBUTTON * button)
196 {
197 int boxWidth = button->boxWidth;
198 int i;
199
200 /* Draw in the message. */
201
202 for (i = 0; i < boxWidth - 2 * BorderOf(button); i++)
203 {
204 chtype c;
205 int pos = button->infoPos;
206 int len = button->infoLen;
207
208 if (i >= pos && (i - pos) < len)
209 c = button->info[i - pos];
210 else
211 c = ' ';
212
213 if (HasFocusObj (button))
214 {
215 c = A_REVERSE | CharOf(c);
216 }
217
218 mvwaddch (button->win, BorderOf(button), i + BorderOf(button), c);
219 }
220 }
221
222 /*
223 * This draws the button widget.
224 */
225 static void _drawCDKButton (CDKOBJS * object, boolean Box GCC_UNUSED)
226 {
227 CDKBUTTON *button = (CDKBUTTON *) object;
228
229 /* Is there a shadow? */
230 if (button->shadowWin != (WINDOW *) NULL)
231 {
232 drawShadow (button->shadowWin);
233 }
234
235 /* Box the widget if asked. */
236 if (ObjOf (button)->box)
237 {
238 drawObjBox (button->win, ObjOf(button));
239 }
240 drawCDKButtonText (button);
241 wrefresh (button->win);
242 }
243
244 /*
245 * This erases the button widget.
246 */
247 static void _eraseCDKButton (CDKOBJS * object)
248 {
249 if (validCDKObject (object))
250 {
251 CDKBUTTON *button = (CDKBUTTON *) object;
252
253 eraseCursesWindow (button->win);
254 eraseCursesWindow (button->shadowWin);
255 }
256 }
257
258 /*
259 * This moves the button field to the given location.
260 */
261 static void _moveCDKButton (CDKOBJS *object,
262 int xplace,
263 int yplace,
264 boolean relative,
265 boolean refresh_flag)
266 {
267 CDKBUTTON *button = (CDKBUTTON *) object;
268 int currentX = getbegx (button->win);
269 int currentY = getbegy (button->win);
270 int xpos = xplace;
271 int ypos = yplace;
272 int xdiff = 0;
273 int ydiff = 0;
274
275 /*
276 * If this is a relative move, then we will adjust where we want
277 * to move to.
278 */
279 if (relative)
280 {
281 xpos = getbegx (button->win) + xplace;
282 ypos = getbegy (button->win) + yplace;
283 }
284
285 /* Adjust the window if we need to. */
286 alignxy (WindowOf (button), &xpos, &ypos, button->boxWidth,
287 button->boxHeight);
288
289 /* Get the difference. */
290 xdiff = currentX - xpos;
291 ydiff = currentY - ypos;
292
293 /* Move the window to the new location. */
294 moveCursesWindow(button->win, -xdiff, -ydiff);
295 moveCursesWindow(button->shadowWin, -xdiff, -ydiff);
296
297 /* Touch the windows so they 'move'. */
298 refreshCDKWindow (WindowOf (button));
299
300 /* Redraw the window, if they asked for it. */
301 if (refresh_flag)
302 {
303 drawCDKButton (button, ObjOf (button)->box);
304 }
305 }
306
307 /*
308 * This allows the user to use the cursor keys to adjust the
309 * position of the widget.
310 */
311 void positionCDKButton (CDKBUTTON * button)
312 {
313 /* Declare some variables. */
314 int origX = getbegx (button->win);
315 int origY = getbegy (button->win);
316 chtype key = (chtype) 0;
317 boolean functionKey;
318
319 /* Let them move the widget around until they hit return. */
320 while (key != KEY_ENTER)
321 {
322 key = getchCDKObject (ObjOf(button), &functionKey);
323 if (key == KEY_UP || key == '8')
324 {
325 if (getbegy (button->win) > 0)
326 {
327 moveCDKButton (button, 0, -1, TRUE, TRUE);
328 }
329 else
330 {
331 Beep ();
332 }
333 }
334 else if (key == KEY_DOWN || key == '2')
335 {
336 if (getbegy (button->win) + getmaxy (button->win) <
337 getmaxy (WindowOf (button)) - 1)
338 {
339 moveCDKButton (button, 0, 1, TRUE, TRUE);
340 }
341 else
342 {
343 Beep ();
344 }
345 }
346 else if (key == KEY_LEFT || key == '4')
347 {
348 if (getbegx (button->win) > 0)
349 {
350 moveCDKButton (button, -1, 0, TRUE, TRUE);
351 }
352 else
353 {
354 Beep ();
355 }
356 }
357 else if (key == KEY_RIGHT || key == '6')
358 {
359 if (getbegx (button->win) + getmaxx (button->win) < getmaxx
360 (WindowOf (button)) - 1)
361 {
362 moveCDKButton (button, 1, 0, TRUE, TRUE);
363 }
364 else
365 {
366 Beep ();
367 }
368 }
369 else if (key == '7')
370 {
371 if (getbegy (button->win) > 0 && getbegx (button->win) > 0)
372 {
373 moveCDKButton (button, -1, -1, TRUE, TRUE);
374 }
375 else
376 {
377 Beep ();
378 }
379 }
380 else if (key == '9')
381 {
382 if (getbegx (button->win) + getmaxx (button->win) < getmaxx
383 (WindowOf (button)) - 1 &&
384 getbegy (button->win) > 0)
385 {
386 moveCDKButton (button, 1, -1, TRUE, TRUE);
387 }
388 else
389 {
390 Beep ();
391 }
392 }
393 else if (key == '1')
394 {
395 if (getbegx (button->win) > 0 && getbegx (button->win) +
396 getmaxx (button->win) < getmaxx (WindowOf (button)) - 1)
397 {
398 moveCDKButton (button, -1, 1, TRUE, TRUE);
399 }
400 else
401 {
402 Beep ();
403 }
404 }
405 else if (key == '3')
406 {
407 if (getbegx (button->win) + getmaxx (button->win) <
408 getmaxx (WindowOf (button)) - 1
409 && getbegy (button->win) + getmaxy (button->win) <
410 getmaxy (WindowOf (button)) - 1)
411 {
412 moveCDKButton (button, 1, 1, TRUE, TRUE);
413 }
414 else
415 {
416 Beep ();
417 }
418 }
419 else if (key == '5')
420 {
421 moveCDKButton (button, CENTER, CENTER, FALSE, TRUE);
422 }
423 else if (key == 't')
424 {
425 moveCDKButton (button, getbegx (button->win), TOP, FALSE, TRUE);
426 }
427 else if (key == 'b')
428 {
429 moveCDKButton (button, getbegx (button->win), BOTTOM, FALSE, TRUE);
430 }
431 else if (key == 'l')
432 {
433 moveCDKButton (button, LEFT, getbegy (button->win), FALSE, TRUE);
434 }
435 else if (key == 'r')
436 {
437 moveCDKButton (button, RIGHT, getbegy (button->win), FALSE, TRUE);
438 }
439 else if (key == 'c')
440 {
441 moveCDKButton (button, CENTER, getbegy (button->win), FALSE, TRUE);
442 }
443 else if (key == 'C')
444 {
445 moveCDKButton (button, getbegx (button->win), CENTER, FALSE, TRUE);
446 }
447 else if (key == CDK_REFRESH)
448 {
449 eraseCDKScreen (ScreenOf (button));
450 refreshCDKScreen (ScreenOf (button));
451 }
452 else if (key == KEY_ESC)
453 {
454 moveCDKButton (button, origX, origY, FALSE, TRUE);
455 }
456 else if (key != KEY_ENTER)
457 {
458 Beep ();
459 }
460 }
461 }
462
463 /*
464 * This destroys the button object pointer.
465 */
466 static void _destroyCDKButton (CDKOBJS * object)
467 {
468 if (object != 0)
469 {
470 CDKBUTTON *button = (CDKBUTTON *) object;
471
472 /* Free up the character pointers. */
473 freeChtype (button->info);
474
475 /* Free up the window pointers. */
476 deleteCursesWindow (button->shadowWin);
477 deleteCursesWindow (button->win);
478
479 /* Clean the key bindings. */
480 cleanCDKObjectBindings (vBUTTON, button);
481
482 /* Unregister the object. */
483 unregisterCDKObject (vBUTTON, button);
484 }
485 }
486
487 /*
488 * This injects a single character into the widget.
489 */
490 static int _injectCDKButton (CDKOBJS * object, chtype input)
491 {
492 CDKBUTTON *button = (CDKBUTTON *) object;
493 int ret = unknownInt;
494 bool complete = FALSE;
495
496 setExitType(button, 0);
497
498 /* Check a predefined binding. */
499 if (checkCDKObjectBind (vBUTTON, button, input) != 0)
500 {
501 checkEarlyExit(button);
502 complete = TRUE;
503 }
504 else
505 {
506 switch (input)
507 {
508 case KEY_ESC :
509 setExitType(button, input);
510 complete = TRUE;
511 break;
512
513 case KEY_ENTER: case SPACE:
514 if (button->callback)
515 button->callback (button);
516 setExitType(button, KEY_ENTER);
517 ret = 0;
518 complete = TRUE;
519 break;
520
521 case CDK_REFRESH:
522 eraseCDKScreen (ScreenOf (button));
523 refreshCDKScreen (ScreenOf (button));
524 break;
525
526 default:
527 Beep ();
528 break;
529 }
530 }
531
532 if (!complete) {
533 setExitType(button, 0);
534 }
535
536 ResultOf(button).valueInt = ret;
537 return (ret != unknownInt);
538 }
539
540 static void _focusCDKButton (CDKOBJS * object)
541 {
542 CDKBUTTON *button = (CDKBUTTON *) object;
543
544 drawCDKButtonText (button);
545 wrefresh (button->win);
546 }
547
548 static void _unfocusCDKButton (CDKOBJS * object)
549 {
550 CDKBUTTON *button = (CDKBUTTON *) object;
551
552 drawCDKButtonText (button);
553 wrefresh (button->win);
554 }
555
556 dummyRefreshData(Button)
557
558 dummySaveData(Button)
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:45 $
5 * $Revision: 1.62 $
6 */
7
8 DeclareCDKObjects(BUTTONBOX, Buttonbox, setCdk, Int);
9
10 /*
11 * This returns a CDK buttonbox widget pointer.
12 */
13 CDKBUTTONBOX *newCDKButtonbox (CDKSCREEN *cdkscreen, int xPos, int yPos, int height, int width, char *title, int rows, int cols, char **buttons, int buttonCount, chtype highlight, boolean Box, boolean shadow)
14 {
15 CDKBUTTONBOX *buttonbox = 0;
16 int parentWidth = getmaxx(cdkscreen->window);
17 int parentHeight = getmaxy(cdkscreen->window);
18 int boxWidth = 0;
19 int boxHeight = 0;
20 int maxColWidth = INT_MIN;
21 int colWidth = 0;
22 int xpos = xPos;
23 int ypos = yPos;
24 int currentButton = 0;
25 int x, y, junk;
26
27 if (buttonCount <= 0
28 || (buttonbox = newCDKObject(CDKBUTTONBOX, &my_funcs)) == 0
29 || (buttonbox->button = typeCallocN(chtype *, buttonCount + 1)) == 0
30 || (buttonbox->buttonLen = typeCallocN(int, buttonCount + 1)) == 0
31 || (buttonbox->buttonPos = typeCallocN(int, buttonCount + 1)) == 0
32 || (buttonbox->columnWidths = typeCallocN(int, buttonCount + 1)) == 0)
33 {
34 destroyCDKObject (buttonbox);
35 return (0);
36 }
37
38 setCDKButtonboxBox (buttonbox, Box);
39
40 /* Set some default values for the widget. */
41 buttonbox->rowAdjust = 0;
42 buttonbox->colAdjust = 0;
43
44 /*
45 * If the height is a negative value, the height will
46 * be ROWS-height, otherwise, the height will be the
47 * given height.
48 */
49 boxHeight = setWidgetDimension (parentHeight, height, rows + 1);
50
51 /*
52 * If the width is a negative value, the width will
53 * be COLS-width, otherwise, the width will be the
54 * given width.
55 */
56 boxWidth = setWidgetDimension (parentWidth, width, 0);
57
58 boxWidth = setCdkTitle(ObjOf(buttonbox), title, boxWidth);
59
60 /* Translate the buttons char * to a chtype * */
61 for (x = 0; x < buttonCount; x++)
62 {
63 buttonbox->button[x] = char2Chtype (buttons[x], &buttonbox->buttonLen[x], &junk);
64 }
65
66 /* Set the button positions. */
67 for (x=0; x < cols; x++)
68 {
69 maxColWidth = INT_MIN;
70
71 /* Look for the widest item in this column. */
72 for (y=0; y < rows; y++)
73 {
74 if (currentButton < buttonCount)
75 {
76 maxColWidth = MAXIMUM (buttonbox->buttonLen[currentButton], maxColWidth);
77 currentButton++;
78 }
79 }
80
81 /* Keep the maximum column width for this column. */
82 buttonbox->columnWidths[x] = maxColWidth;
83 colWidth += maxColWidth;
84 }
85 boxWidth++;
86
87 /*
88 * Make sure we didn't extend beyond the dimensions of the window.
89 */
90 boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth);
91 boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight);
92
93 /* Now we have to readjust the x and y positions. */
94 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
95
96 /* Set up the buttonbox box attributes. */
97 ScreenOf(buttonbox) = cdkscreen;
98 buttonbox->parent = cdkscreen->window;
99 buttonbox->win = newwin (boxHeight, boxWidth, ypos, xpos);
100 buttonbox->shadowWin = 0;
101 buttonbox->buttonCount = buttonCount;
102 buttonbox->currentButton = 0;
103 buttonbox->rows = rows;
104 buttonbox->cols = (buttonCount < cols ? buttonCount : cols);
105 buttonbox->boxHeight = boxHeight;
106 buttonbox->boxWidth = boxWidth;
107 buttonbox->highlight = highlight;
108 initExitType(buttonbox);
109 ObjOf(buttonbox)->acceptsFocus = TRUE;
110 ObjOf(buttonbox)->inputWindow = buttonbox->win;
111 buttonbox->shadow = shadow;
112 buttonbox->ButtonAttrib = A_NORMAL;
113
114 /* Set up the row adjustment. */
115 if (boxHeight - rows - TitleLinesOf(buttonbox) > 0)
116 {
117 buttonbox->rowAdjust = (int)((boxHeight - rows - TitleLinesOf(buttonbox)) / buttonbox->rows);
118 }
119
120 /* Set the col adjustment. */
121 if (boxWidth - colWidth > 0)
122 {
123 buttonbox->colAdjust = (int)((boxWidth-colWidth) / buttonbox->cols)-1;
124 }
125
126 /* If we couldn't create the window, we should return a null value. */
127 if (buttonbox->win == 0)
128 {
129 destroyCDKObject (buttonbox);
130 return (0);
131 }
132 keypad (buttonbox->win, TRUE);
133
134 /* Was there a shadow? */
135 if (shadow)
136 {
137 buttonbox->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
138 }
139
140 /* Register this baby. */
141 registerCDKObject (cdkscreen, vBUTTONBOX, buttonbox);
142
143 /* Return the buttonbox box pointer. */
144 return (buttonbox);
145 }
146
147 /*
148 * This activates the widget.
149 */
150 int activateCDKButtonbox (CDKBUTTONBOX *buttonbox, chtype *actions)
151 {
152 chtype input = 0;
153 boolean functionKey;
154 int ret;
155
156 /* Draw the buttonbox box. */
157 drawCDKButtonbox (buttonbox, ObjOf(buttonbox)->box);
158
159 if (actions == 0)
160 {
161 for (;;)
162 {
163 input = getchCDKObject (ObjOf(buttonbox), &functionKey);
164
165 /* Inject the character into the widget. */
166 ret = injectCDKButtonbox (buttonbox, input);
167 if (buttonbox->exitType != vEARLY_EXIT)
168 {
169 return ret;
170 }
171 }
172 }
173 else
174 {
175 int length = chlen (actions);
176 int x = 0;
177
178 /* Inject each character one at a time. */
179 for (x=0; x < length; x++)
180 {
181 ret = injectCDKButtonbox (buttonbox, actions[x]);
182 if (buttonbox->exitType != vEARLY_EXIT)
183 {
184 return ret;
185 }
186 }
187 }
188
189 /* Set the exit type and exit. */
190 setExitType(buttonbox, 0);
191 return -1;
192 }
193
194 /*
195 * This injects a single character into the widget.
196 */
197 static int _injectCDKButtonbox (CDKOBJS *object, chtype input)
198 {
199 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)object;
200 int firstButton = 0;
201 int lastButton = buttonbox->buttonCount - 1;
202 int ppReturn = 1;
203 int ret = unknownInt;
204 bool complete = FALSE;
205
206 /* Set the exit type. */
207 setExitType(buttonbox, 0);
208
209 /* Check if there is a pre-process function to be called. */
210 if (PreProcessFuncOf(buttonbox) != 0)
211 {
212 ppReturn = PreProcessFuncOf(buttonbox) (vBUTTONBOX, buttonbox, PreProcessDataOf(buttonbox), input);
213 }
214
215 /* Should we continue? */
216 if (ppReturn != 0)
217 {
218 /* Check for a key binding. */
219 if (checkCDKObjectBind (vBUTTONBOX, buttonbox, input) != 0)
220 {
221 checkEarlyExit(buttonbox);
222 complete = TRUE;
223 }
224 else
225 {
226 switch (input)
227 {
228 case KEY_LEFT : case KEY_BTAB : case KEY_BACKSPACE :
229 if ((buttonbox->currentButton-buttonbox->rows) < firstButton)
230 {
231 buttonbox->currentButton = lastButton;
232 }
233 else
234 {
235 buttonbox->currentButton -= buttonbox->rows;
236 }
237 break;
238
239 case KEY_RIGHT : case KEY_TAB : case SPACE :
240 if ((buttonbox->currentButton + buttonbox->rows) > lastButton)
241 {
242 buttonbox->currentButton = firstButton;
243 }
244 else
245 {
246 buttonbox->currentButton += buttonbox->rows;
247 }
248 break;
249
250 case KEY_UP :
251 if ((buttonbox->currentButton-1) < firstButton)
252 {
253 buttonbox->currentButton = lastButton;
254 }
255 else
256 {
257 buttonbox->currentButton--;
258 }
259 break;
260
261 case KEY_DOWN :
262 if ((buttonbox->currentButton + 1) > lastButton)
263 {
264 buttonbox->currentButton = firstButton;
265 }
266 else
267 {
268 buttonbox->currentButton++;
269 }
270 break;
271
272 case CDK_REFRESH :
273 eraseCDKScreen (ScreenOf(buttonbox));
274 refreshCDKScreen (ScreenOf(buttonbox));
275 break;
276
277 case KEY_ESC :
278 setExitType(buttonbox, input);
279 complete = TRUE;
280 break;
281
282 case KEY_ENTER :
283 setExitType(buttonbox, input);
284 ret = buttonbox->currentButton;
285 complete = TRUE;
286 break;
287
288 default :
289 break;
290 }
291 }
292
293 /* Should we call a post-process? */
294 if (!complete && (PostProcessFuncOf(buttonbox) != 0))
295 {
296 PostProcessFuncOf(buttonbox) (vBUTTONBOX, buttonbox, PostProcessDataOf(buttonbox), input);
297 }
298 }
299
300 if (!complete) {
301 drawCDKButtonboxButtons (buttonbox);
302 setExitType(buttonbox, 0);
303 }
304
305 ResultOf(buttonbox).valueInt = ret;
306 return (ret != unknownInt);
307 }
308
309 /*
310 * This sets multiple attributes of the widget.
311 */
312 void setCDKButtonbox (CDKBUTTONBOX *buttonbox, chtype highlight, boolean Box)
313 {
314 setCDKButtonboxHighlight (buttonbox, highlight);
315 setCDKButtonboxBox (buttonbox, Box);
316 }
317
318 /*
319 * This sets the highlight attribute for the buttonboxs.
320 */
321 void setCDKButtonboxHighlight (CDKBUTTONBOX *buttonbox, chtype highlight)
322 {
323 buttonbox->highlight = highlight;
324 }
325 chtype getCDKButtonboxHighlight (CDKBUTTONBOX *buttonbox)
326 {
327 return (chtype)buttonbox->highlight;
328 }
329
330 /*
331 * This sets the box attribute of the widget.
332 */
333 void setCDKButtonboxBox (CDKBUTTONBOX *buttonbox, boolean Box)
334 {
335 ObjOf(buttonbox)->box = Box;
336 ObjOf(buttonbox)->borderSize = Box ? 1 : 0;
337 }
338 boolean getCDKButtonboxBox (CDKBUTTONBOX *buttonbox)
339 {
340 return ObjOf(buttonbox)->box;
341 }
342
343 /*
344 * This sets the background attribute of the widget.
345 */
346 static void _setBKattrButtonbox (CDKOBJS *object, chtype attrib)
347 {
348 if (object != 0)
349 {
350 CDKBUTTONBOX *widget = (CDKBUTTONBOX *) object;
351
352 wbkgd (widget->win, attrib);
353 }
354 }
355
356 /*
357 * This draws the buttonbox box widget.
358 */
359 static void _drawCDKButtonbox (CDKOBJS *object, boolean Box)
360 {
361 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)object;
362
363 /* Is there a shadow? */
364 if (buttonbox->shadowWin != 0)
365 {
366 drawShadow (buttonbox->shadowWin);
367 }
368
369 /* Box the widget if they asked. */
370 if (Box)
371 {
372 drawObjBox (buttonbox->win, ObjOf(buttonbox));
373 }
374
375 /* Draw in the title if there is one. */
376 drawCdkTitle (buttonbox->win, object);
377
378 /* Draw in the buttons. */
379 drawCDKButtonboxButtons (buttonbox);
380 }
381
382 /*
383 * This draws the buttons on the button box widget.
384 */
385 void drawCDKButtonboxButtons (CDKBUTTONBOX *buttonbox)
386 {
387 int row = TitleLinesOf(buttonbox) + 1;
388 int col = (int)(buttonbox->colAdjust / 2);
389 int currentButton = 0;
390 int x, y;
391 int cur_row = -1;
392 int cur_col = -1;
393
394 /* Draw the buttons. */
395 while (currentButton < buttonbox->buttonCount)
396 {
397 for (x=0; x < buttonbox->cols; x++)
398 {
399 row = TitleLinesOf(buttonbox) + BorderOf(buttonbox);
400
401 for (y=0; y < buttonbox->rows; y++)
402 {
403 chtype attr = buttonbox->ButtonAttrib;
404 if (currentButton == buttonbox->currentButton)
405 {
406 attr = buttonbox->highlight,
407 cur_row = row;
408 cur_col = col;
409 }
410 writeChtypeAttrib (buttonbox->win,
411 col, row,
412 buttonbox->button[currentButton],
413 attr,
414 HORIZONTAL, 0,
415 buttonbox->buttonLen[currentButton]);
416 row += (1 + buttonbox->rowAdjust);
417 currentButton++;
418 }
419 col += buttonbox->columnWidths[x] + buttonbox->colAdjust + BorderOf(buttonbox);
420 }
421 }
422 if (cur_row >= 0 && cur_col >= 0)
423 wmove(buttonbox->win, cur_row, cur_col);
424 wrefresh (buttonbox->win);
425 }
426
427 /*
428 * This erases the buttonbox box from the screen.
429 */
430 static void _eraseCDKButtonbox (CDKOBJS *object)
431 {
432 if (validCDKObject (object))
433 {
434 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)object;
435
436 eraseCursesWindow (buttonbox->win);
437 eraseCursesWindow (buttonbox->shadowWin);
438 }
439 }
440
441 /*
442 * This moves the buttonbox box to a new screen location.
443 */
444 static void _moveCDKButtonbox (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag)
445 {
446 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)object;
447 int currentX = getbegx(buttonbox->win);
448 int currentY = getbegy(buttonbox->win);
449 int xpos = xplace;
450 int ypos = yplace;
451 int xdiff = 0;
452 int ydiff = 0;
453
454 /*
455 * If this is a relative move, then we will adjust where we want
456 * to move to.
457 */
458 if (relative)
459 {
460 xpos = getbegx(buttonbox->win) + xplace;
461 ypos = getbegy(buttonbox->win) + yplace;
462 }
463
464 /* Adjust the window if we need to. */
465 alignxy (WindowOf(buttonbox), &xpos, &ypos, buttonbox->boxWidth, buttonbox->boxHeight);
466
467 /* Get the difference. */
468 xdiff = currentX - xpos;
469 ydiff = currentY - ypos;
470
471 /* Move the window to the new location. */
472 moveCursesWindow(buttonbox->win, -xdiff, -ydiff);
473 moveCursesWindow(buttonbox->shadowWin, -xdiff, -ydiff);
474
475 /* Touch the windows so they 'move'. */
476 refreshCDKWindow (WindowOf(buttonbox));
477
478 /* Redraw the window, if they asked for it. */
479 if (refresh_flag)
480 {
481 drawCDKButtonbox (buttonbox, ObjOf(buttonbox)->box);
482 }
483 }
484
485 /*
486 * This destroys the widget and all the memory associated with it.
487 */
488 static void _destroyCDKButtonbox (CDKOBJS *object)
489 {
490 if (object != 0)
491 {
492 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)object;
493
494 cleanCdkTitle (object);
495 CDKfreeChtypes (buttonbox->button);
496 freeChecked (buttonbox->buttonLen);
497 freeChecked (buttonbox->buttonPos);
498 freeChecked (buttonbox->columnWidths);
499
500 /* Delete the windows. */
501 deleteCursesWindow (buttonbox->shadowWin);
502 deleteCursesWindow (buttonbox->win);
503
504 /* Clean the key bindings. */
505 cleanCDKObjectBindings (vBUTTONBOX, buttonbox);
506
507 /* Unregister this object. */
508 unregisterCDKObject (vBUTTONBOX, buttonbox);
509 }
510 }
511
512 /*
513 *
514 */
515 void setCDKButtonboxCurrentButton (CDKBUTTONBOX * buttonbox, int button)
516 {
517 if ((button >= 0) && (button < buttonbox->buttonCount))
518 {
519 buttonbox->currentButton = button;
520 }
521 }
522 int getCDKButtonboxCurrentButton (CDKBUTTONBOX * buttonbox)
523 {
524 return buttonbox->currentButton;
525 }
526 int getCDKButtonboxButtonCount (CDKBUTTONBOX * buttonbox)
527 {
528 return buttonbox->buttonCount;
529 }
530
531 static void _focusCDKButtonbox (CDKOBJS * object)
532 {
533 CDKBUTTONBOX *widget = (CDKBUTTONBOX *)object;
534
535 drawCDKButtonbox (widget, ObjOf(widget)->box);
536 }
537
538 static void _unfocusCDKButtonbox (CDKOBJS * object)
539 {
540 CDKBUTTONBOX *widget = (CDKBUTTONBOX *)object;
541
542 drawCDKButtonbox (widget, ObjOf(widget)->box);
543 }
544
545 dummyRefreshData(Buttonbox)
546
547 dummySaveData(Buttonbox)
0 #include "cdkscreen.h"
1
2 CDKScreen::CDKScreen()
3 {
4 cursesWin = initscr();
5 cdkscreen = initCDKScreen(cursesWin);
6 // Now, set up color.
7 initCDKColor();
8 }
9
10 CDKScreen::~CDKScreen()
11 {
12 destroyCDKScreen(cdkscreen);
13 endCDK();
14 }
15
16 CDKSCREEN *CDKScreen::screen(void)
17 {
18 return cdkscreen;
19 }
20
21 void CDKScreen::refreshscr(void)
22 {
23 refreshCDKScreen(cdkscreen);
24 }
25
26 void CDKScreen::erasescr(void)
27 {
28 eraseCDKScreen(cdkscreen);
29 }
30
0 #ifndef CDKSCREEN_H
1 #define CDK_SCREEN_H
2
3 extern "C"
4 {
5 #include <cdk.h>
6 }
7
8 class CDKScreen
9 {
10 // The window which curses uses.
11 WINDOW *cursesWin;
12 // The CDKSCREEN struct assigned to this object.
13 CDKSCREEN *cdkscreen;
14 public:
15 // Constructor.
16 CDKScreen();
17 // Deconstructor.
18 ~CDKScreen();
19 // Return a pointer to the CDKScreen structure.
20 CDKSCREEN *screen(void);
21 // Refresh the screen.
22 // Note, this function is renamed to avoid clashing with the refresh() macro.
23 void refreshscr(void);
24 // Erase, but don't destroy, all widgets.
25 // Note, this function is renamed to avoid clashing with the erase() macro.
26 void erasescr(void);
27 };
28
29 #endif
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:45 $
5 * $Revision: 1.84 $
6 */
7
8 #define YEAR2INDEX(year) (((year) >= 1900) ? ((year) - 1900) : (year))
9
10 /*
11 * Declare file local variables.
12 */
13 static char *monthsOfTheYear[] = {
14 "NULL",
15 "January",
16 "February",
17 "March",
18 "April",
19 "May",
20 "June",
21 "July",
22 "August",
23 "September",
24 "October",
25 "November",
26 "December"
27 };
28
29 static int daysOfTheMonth[] = {
30 -1,
31 31,
32 28,
33 31,
34 30,
35 31,
36 30,
37 31,
38 31,
39 30,
40 31,
41 30,
42 31
43 };
44
45 /*
46 * Declare file local prototypes.
47 */
48 static int getMonthLength (int year, int month);
49 static int getMonthStartWeekday (int year, int month);
50 static time_t getCurrentTime (CDKCALENDAR *calendar);
51 static void verifyCalendarDate (CDKCALENDAR *calendar);
52 static void incrementCalendarDay (CDKCALENDAR *calendar, int adjust);
53 static void decrementCalendarDay (CDKCALENDAR *calendar, int adjust);
54 static void incrementCalendarMonth (CDKCALENDAR *calendar, int adjust);
55 static void decrementCalendarMonth (CDKCALENDAR *calendar, int adjust);
56 static void incrementCalendarYear (CDKCALENDAR *calendar, int adjust);
57 static void decrementCalendarYear (CDKCALENDAR *calendar, int adjust);
58 static void drawCDKCalendarField (CDKCALENDAR *calendar);
59
60 DeclareCDKObjects(CALENDAR, Calendar, setCdk, Int);
61
62 /*
63 * This creates a calendar widget.
64 */
65 CDKCALENDAR *newCDKCalendar(CDKSCREEN *cdkscreen, int xplace, int yplace, char *title, int day, int month, int year, chtype dayAttrib, chtype monthAttrib, chtype yearAttrib, chtype highlight, boolean Box, boolean shadow)
66 {
67 /* Maintain the calendar information. */
68 CDKCALENDAR *calendar = 0;
69 int parentWidth = getmaxx(cdkscreen->window);
70 int parentHeight = getmaxy(cdkscreen->window);
71 int boxWidth = 24;
72 int boxHeight = 11;
73 int xpos = xplace;
74 int ypos = yplace;
75 int x;
76 struct tm *dateInfo;
77 time_t clck;
78 char *dayname = "Su Mo Tu We Th Fr Sa";
79
80 static const struct { int from; int to; } bindings[] = {
81 { 'T', KEY_HOME },
82 { 't', KEY_HOME },
83 { 'n', KEY_NPAGE },
84 { CDK_FORCHAR, KEY_NPAGE },
85 { 'p', KEY_PPAGE },
86 { CDK_BACKCHAR, KEY_PPAGE },
87 };
88
89 if ((calendar = newCDKObject(CDKCALENDAR, &my_funcs)) == 0)
90 return (0);
91
92 setCDKCalendarBox (calendar, Box);
93
94 boxWidth = setCdkTitle(ObjOf(calendar), title, boxWidth);
95
96 boxHeight += TitleLinesOf(calendar);
97
98 /*
99 * Make sure we didn't extend beyond the dimensions of the window.
100 */
101 boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth);
102 boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight);
103
104 /* Rejustify the x and y positions if we need to. */
105 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
106
107 /* Create the calendar window. */
108 calendar->win = newwin (boxHeight, boxWidth, ypos, xpos);
109
110 /* Is the window null? */
111 if (calendar->win == 0)
112 {
113 destroyCDKObject (calendar);
114 return (0);
115 }
116 keypad (calendar->win, TRUE);
117
118 /* Set some variables. */
119 calendar->xOffset = (boxWidth - 20) / 2;
120 calendar->fieldWidth = boxWidth - 2 * (1 + BorderOf(calendar));
121
122 /* Set months and days names */
123 for (x=0; x < MAX_MONTHS; x++)
124 {
125 calendar->MonthName[x] = copyChar(monthsOfTheYear[x]);
126 }
127 calendar->DayName = copyChar(dayname);
128
129 /* Set the rest of the widget values. */
130 ScreenOf(calendar) = cdkscreen;
131 calendar->parent = cdkscreen->window;
132 calendar->shadowWin = 0;
133 calendar->xpos = xpos;
134 calendar->ypos = ypos;
135 calendar->boxWidth = boxWidth;
136 calendar->boxHeight = boxHeight;
137 calendar->day = day;
138 calendar->month = month;
139 calendar->year = year;
140 calendar->dayAttrib = dayAttrib;
141 calendar->monthAttrib = monthAttrib;
142 calendar->yearAttrib = yearAttrib;
143 calendar->highlight = highlight;
144 calendar->width = boxWidth;
145 initExitType(calendar);
146 ObjOf(calendar)->acceptsFocus = TRUE;
147 ObjOf(calendar)->inputWindow = calendar->win;
148 calendar->shadow = shadow;
149
150 calendar->labelWin = subwin (calendar->win,
151 1, calendar->fieldWidth,
152 ypos + TitleLinesOf(calendar) + 1,
153 xpos + 1 + BorderOf(calendar));
154 if (calendar->labelWin == 0)
155 {
156 destroyCDKObject (calendar);
157 return (0);
158 }
159
160 calendar->fieldWin = subwin (calendar->win,
161 7, 20,
162 ypos + TitleLinesOf(calendar) + 3,
163 xpos + calendar->xOffset);
164 if (calendar->fieldWin == 0)
165 {
166 destroyCDKObject (calendar);
167 return (0);
168 }
169
170 setCDKCalendarBox (calendar, Box);
171
172 calendar->marker = typeCallocN(chtype, CALENDAR_LIMIT);
173 if (calendar->marker == 0)
174 {
175 destroyCDKObject (calendar);
176 return (0);
177 }
178
179 /* If the day/month/year values were 0, then use today's date. */
180 if ((calendar->day == 0) && (calendar->month == 0) && (calendar->year == 0))
181 {
182 time (&clck);
183 dateInfo = localtime (&clck);
184
185 calendar->day = dateInfo->tm_mday;
186 calendar->month = dateInfo->tm_mon + 1;
187 calendar->year = dateInfo->tm_year + 1900;
188 }
189
190 /* Verify the dates provided. */
191 verifyCalendarDate (calendar);
192
193 /* Determine which day the month starts on. */
194 calendar->weekDay = getMonthStartWeekday (calendar->year, calendar->month);
195
196 /* If a shadow was requested, then create the shadow window. */
197 if (shadow)
198 {
199 calendar->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
200 }
201
202 /* Setup the key bindings. */
203 for (x = 0; x < (int) SIZEOF(bindings); ++x)
204 bindCDKObject (vCALENDAR, calendar, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to);
205
206 registerCDKObject (cdkscreen, vCALENDAR, calendar);
207
208 return (calendar);
209 }
210
211 /*
212 * This function lets the user play with this widget.
213 */
214 time_t activateCDKCalendar (CDKCALENDAR *calendar, chtype *actions)
215 {
216 chtype input = 0;
217 boolean functionKey;
218 time_t ret = -1;
219
220 /* Draw the widget. */
221 drawCDKCalendar (calendar, ObjOf(calendar)->box);
222
223 if (actions == 0)
224 {
225 for (;;)
226 {
227 input = getchCDKObject (ObjOf(calendar), &functionKey);
228
229 /* Inject the character into the widget. */
230 ret = injectCDKCalendar (calendar, input);
231 if (calendar->exitType != vEARLY_EXIT)
232 {
233 return ret;
234 }
235 }
236 }
237 else
238 {
239 int length = chlen (actions);
240 int x =0;
241
242 /* Inject each character one at a time. */
243 for (x=0; x < length; x++)
244 {
245 ret = injectCDKCalendar (calendar, actions[x]);
246 if (calendar->exitType != vEARLY_EXIT)
247 {
248 return ret;
249 }
250 }
251 }
252 return ret;
253 }
254
255 /*
256 * This injects a single character into the widget.
257 */
258 static int _injectCDKCalendar (CDKOBJS *object, chtype input)
259 {
260 CDKCALENDAR *calendar = (CDKCALENDAR *)object;
261 /* Declare local variables. */
262 int ppReturn = 1;
263 int ret = unknownInt;
264 bool complete = FALSE;
265
266 /* Set the exit type. */
267 setExitType(calendar, 0);
268
269 /* Refresh the calendar field. */
270 drawCDKCalendarField (calendar);
271
272 /* Check if there is a pre-process function to be called. */
273 if (PreProcessFuncOf(calendar) != 0)
274 {
275 /* Call the pre-process function. */
276 ppReturn = PreProcessFuncOf(calendar) (vCALENDAR, calendar, PreProcessDataOf(calendar), input);
277 }
278
279 /* Should we continue? */
280 if (ppReturn != 0)
281 {
282 /* Check a predefined binding. */
283 if (checkCDKObjectBind (vCALENDAR, calendar, input) != 0)
284 {
285 checkEarlyExit(calendar);
286 complete = TRUE;
287 }
288 else
289 {
290 switch (input)
291 {
292 case KEY_UP :
293 decrementCalendarDay (calendar, 7);
294 break;
295
296 case KEY_DOWN :
297 incrementCalendarDay (calendar, 7);
298 break;
299
300 case KEY_LEFT :
301 decrementCalendarDay (calendar, 1);
302 break;
303
304 case KEY_RIGHT :
305 incrementCalendarDay (calendar, 1);
306 break;
307
308 case KEY_NPAGE :
309 incrementCalendarMonth (calendar, 1);
310 break;
311
312 case 'N' :
313 incrementCalendarMonth (calendar, 6);
314 break;
315
316 case KEY_PPAGE :
317 decrementCalendarMonth (calendar, 1);
318 break;
319
320 case 'P' :
321 decrementCalendarMonth (calendar, 6);
322 break;
323
324 case '-' :
325 decrementCalendarYear (calendar, 1);
326 break;
327
328 case '+' :
329 incrementCalendarYear (calendar, 1);
330 break;
331
332 case KEY_HOME:
333 setCDKCalendarDate (calendar, -1, -1, -1);
334 break;
335
336 case KEY_ESC :
337 setExitType(calendar, input);
338 complete = TRUE;
339 break;
340
341 case KEY_TAB : case KEY_ENTER :
342 setExitType(calendar, input);
343 ret = getCurrentTime (calendar);
344 complete = TRUE;
345 break;
346
347 case CDK_REFRESH :
348 eraseCDKScreen (ScreenOf(calendar));
349 refreshCDKScreen (ScreenOf(calendar));
350 break;
351 }
352 }
353
354 /* Should we do a post-process? */
355 if (!complete && (PostProcessFuncOf(calendar) != 0))
356 {
357 PostProcessFuncOf(calendar) (vCALENDAR, calendar, PostProcessDataOf(calendar), input);
358 }
359 }
360
361 if (!complete) {
362 setExitType(calendar, 0);
363 }
364
365 ResultOf(calendar).valueInt = ret;
366 return (ret != unknownInt);
367 }
368
369 /*
370 * This moves the calendar field to the given location.
371 */
372 static void _moveCDKCalendar (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag)
373 {
374 CDKCALENDAR *calendar = (CDKCALENDAR *)object;
375 /* Declare local variables. */
376 int currentX = getbegx(calendar->win);
377 int currentY = getbegy(calendar->win);
378 int xpos = xplace;
379 int ypos = yplace;
380 int xdiff = 0;
381 int ydiff = 0;
382
383 /*
384 * If this is a relative move, then we will adjust where we want
385 * to move to.
386 */
387 if (relative)
388 {
389 xpos = getbegx(calendar->win) + xplace;
390 ypos = getbegy(calendar->win) + yplace;
391 }
392
393 /* Adjust the window if we need to. */
394 alignxy (WindowOf(calendar), &xpos, &ypos, calendar->boxWidth, calendar->boxHeight);
395
396 /* Get the difference. */
397 xdiff = currentX - xpos;
398 ydiff = currentY - ypos;
399
400 /* Move the window to the new location. */
401 moveCursesWindow(calendar->win, -xdiff, -ydiff);
402 moveCursesWindow(calendar->fieldWin, -xdiff, -ydiff);
403 moveCursesWindow(calendar->labelWin, -xdiff, -ydiff);
404 moveCursesWindow(calendar->shadowWin, -xdiff, -ydiff);
405
406 /* Touch the windows so they 'move'. */
407 refreshCDKWindow (WindowOf(calendar));
408
409 /* Redraw the window, if they asked for it. */
410 if (refresh_flag)
411 {
412 drawCDKCalendar (calendar, ObjOf(calendar)->box);
413 }
414 }
415
416 /*
417 * This draws the calendar widget.
418 */
419 static void _drawCDKCalendar (CDKOBJS *object, boolean Box)
420 {
421 CDKCALENDAR *calendar = (CDKCALENDAR *)object;
422 int headerLen = (int)strlen (calendar->DayName);
423
424 /* Is there a shadow? */
425 if (calendar->shadowWin != 0)
426 {
427 drawShadow (calendar->shadowWin);
428 }
429
430 /* Box the widget if asked. */
431 if (Box)
432 {
433 drawObjBox (calendar->win, ObjOf(calendar));
434 }
435
436 drawCdkTitle (calendar->win, object);
437
438 /* Draw in the day-of-the-week header. */
439 writeChar (calendar->win,
440 calendar->xOffset, TitleLinesOf(calendar) + 2,
441 calendar->DayName, HORIZONTAL, 0, headerLen);
442
443 wrefresh (calendar->win);
444
445 drawCDKCalendarField (calendar);
446 }
447
448 /*
449 * This draws the month field.
450 */
451 static void drawCDKCalendarField (CDKCALENDAR *calendar)
452 {
453 /* Declare local variables. */
454 char *monthName = calendar->MonthName[calendar->month];
455 int monthLength = getMonthLength (calendar->year, calendar->month);
456 int yearIndex = YEAR2INDEX(calendar->year);
457 int yearLen = 0;
458 int day = 1;
459 int x, y;
460 int save_y = -1, save_x = -1;
461 char temp[10];
462
463 for (x = 1; x <= 6; x++)
464 {
465 for (y = (x == 1) ? calendar->weekDay : 0; y < 7; y++)
466 {
467 if (day <= monthLength)
468 {
469 int ypos = y * 3;
470 int xpos = x;
471
472 chtype marker = calendar->dayAttrib;
473
474 sprintf(temp, "%02d", day);
475
476 if (calendar->day == day)
477 {
478 marker = calendar->highlight;
479 save_y = xpos + getbegy(calendar->fieldWin) - getbegy(InputWindowOf(calendar));
480 save_x = 1;
481 }
482 else
483 {
484 marker |= getCDKCalendarMarker(calendar, day, calendar->month, yearIndex);
485 }
486 writeCharAttrib (calendar->fieldWin, ypos, xpos,
487 temp, marker, HORIZONTAL, 0, 2);
488 }
489 day++;
490 }
491 }
492 wrefresh (calendar->fieldWin);
493
494 /* Draw the month in. */
495 if (calendar->labelWin != 0)
496 {
497 sprintf (temp, "%s %d,", monthName, calendar->day);
498 writeChar (calendar->labelWin, 0, 0,
499 temp, HORIZONTAL, 0, strlen(temp));
500 wclrtoeol (calendar->labelWin);
501
502 /* Draw the year in. */
503 sprintf (temp, "%d", calendar->year);
504 yearLen = (int)strlen (temp);
505 writeChar (calendar->labelWin,
506 calendar->fieldWidth - yearLen, 0,
507 temp, HORIZONTAL, 0, yearLen);
508
509 wmove (calendar->labelWin, 0, 0);
510 wrefresh (calendar->labelWin);
511 } else if (save_y >= 0) {
512 wmove (InputWindowOf(calendar), save_y, save_x);
513 wrefresh (InputWindowOf(calendar));
514 }
515 }
516
517 /*
518 * This sets multiple attributes of the widget.
519 */
520 void setCDKCalendar (CDKCALENDAR *calendar, int day, int month, int year, chtype dayAttrib, chtype monthAttrib, chtype yearAttrib, chtype highlight, boolean Box)
521 {
522 setCDKCalendarDate (calendar, day, month, year);
523 setCDKCalendarDayAttribute (calendar, dayAttrib);
524 setCDKCalendarMonthAttribute (calendar, monthAttrib);
525 setCDKCalendarYearAttribute (calendar, yearAttrib);
526 setCDKCalendarHighlight (calendar, highlight);
527 setCDKCalendarBox (calendar, Box);
528 }
529
530 /*
531 * This sets the date and some attributes.
532 */
533 void setCDKCalendarDate (CDKCALENDAR *calendar, int day, int month, int year)
534 {
535 /* Declare local variables. */
536 struct tm *dateInfo;
537 time_t clck;
538
539 /*
540 * Get the current dates and set the default values for
541 * the day/month/year values for the calendar.
542 */
543 time (&clck);
544 dateInfo = localtime (&clck);
545
546 /* Set the date elements if we need too. */
547 calendar->day = (day == -1 ? dateInfo->tm_mday : day);
548 calendar->month = (month == -1 ? dateInfo->tm_mon + 1 : month);
549 calendar->year = (year == -1 ? dateInfo->tm_year + 1900 : year);
550
551 /* Verify the date information. */
552 verifyCalendarDate (calendar);
553
554 /* Get the start of the current month. */
555 calendar->weekDay = getMonthStartWeekday (calendar->year, calendar->month);
556 }
557
558 /*
559 * This returns the current date on the calendar.
560 */
561 void getCDKCalendarDate (CDKCALENDAR *calendar, int *day, int *month, int *year)
562 {
563 (*day) = calendar->day;
564 (*month) = calendar->month;
565 (*year) = calendar->year;
566 }
567
568 /*
569 * This sets the attribute of the days in the calendar.
570 */
571 void setCDKCalendarDayAttribute (CDKCALENDAR *calendar, chtype attribute)
572 {
573 calendar->dayAttrib = attribute;
574 }
575 chtype getCDKCalendarDayAttribute (CDKCALENDAR *calendar)
576 {
577 return calendar->dayAttrib;
578 }
579
580 /*
581 * This sets the attribute of the month names in the calendar.
582 */
583 void setCDKCalendarMonthAttribute (CDKCALENDAR *calendar, chtype attribute)
584 {
585 calendar->monthAttrib = attribute;
586 }
587 chtype getCDKCalendarMonthAttribute (CDKCALENDAR *calendar)
588 {
589 return calendar->monthAttrib;
590 }
591
592 /*
593 * This sets the attribute of the year in the calendar.
594 */
595 void setCDKCalendarYearAttribute (CDKCALENDAR *calendar, chtype attribute)
596 {
597 calendar->yearAttrib = attribute;
598 }
599 chtype getCDKCalendarYearAttribute (CDKCALENDAR *calendar)
600 {
601 return calendar->yearAttrib;
602 }
603
604 /*
605 * This sets the attribute of the highlight box.
606 */
607 void setCDKCalendarHighlight (CDKCALENDAR *calendar, chtype highlight)
608 {
609 calendar->highlight = highlight;
610 }
611 chtype getCDKCalendarHighlight (CDKCALENDAR *calendar)
612 {
613 return calendar->highlight;
614 }
615
616 /*
617 * This sets the box attibute of the widget.
618 */
619 void setCDKCalendarBox (CDKCALENDAR *calendar, boolean Box)
620 {
621 ObjOf(calendar)->box = Box;
622 ObjOf(calendar)->borderSize = Box ? 1 : 0;
623 }
624 boolean getCDKCalendarBox (CDKCALENDAR *calendar)
625 {
626 return ObjOf(calendar)->box;
627 }
628
629 /*
630 * This sets the background attribute of the widget.
631 */
632 static void _setBKattrCalendar (CDKOBJS *object, chtype attrib)
633 {
634 if (object != 0)
635 {
636 CDKCALENDAR *widget = (CDKCALENDAR *) object;
637
638 wbkgd (widget->win, attrib);
639 wbkgd (widget->fieldWin, attrib);
640 if (widget->labelWin != 0)
641 {
642 wbkgd (widget->labelWin, attrib);
643 }
644 }
645 }
646
647 /*
648 * This erases the calendar widget.
649 */
650 static void _eraseCDKCalendar (CDKOBJS *object)
651 {
652 if (validCDKObject (object))
653 {
654 CDKCALENDAR *calendar = (CDKCALENDAR *)object;
655
656 eraseCursesWindow (calendar->labelWin);
657 eraseCursesWindow (calendar->fieldWin);
658 eraseCursesWindow (calendar->win);
659 eraseCursesWindow (calendar->shadowWin);
660 }
661 }
662
663 /*
664 * This destroys the calendar object pointer.
665 */
666 static void _destroyCDKCalendar (CDKOBJS *object)
667 {
668 if (object != 0)
669 {
670 CDKCALENDAR *calendar = (CDKCALENDAR *)object;
671 int x;
672
673 cleanCdkTitle (object);
674
675 freeChar(calendar->DayName);
676
677 for (x=0; x < MAX_MONTHS; x++)
678 {
679 freeChar(calendar->MonthName[x]);
680 }
681
682 freeChecked(calendar->marker);
683
684 /* Free up the window pointers. */
685 deleteCursesWindow (calendar->labelWin);
686 deleteCursesWindow (calendar->fieldWin);
687 deleteCursesWindow (calendar->shadowWin);
688 deleteCursesWindow (calendar->win);
689
690 /* Clean the key bindings. */
691 cleanCDKObjectBindings (vCALENDAR, calendar);
692
693 /* Unregister the object. */
694 unregisterCDKObject (vCALENDAR, calendar);
695 }
696 }
697
698 /*
699 * This sets a marker on the calendar.
700 */
701 void setCDKCalendarMarker (CDKCALENDAR *calendar, int day, int month, int year, chtype marker)
702 {
703 int yearIndex = YEAR2INDEX(year);
704 chtype oldmarker = getCDKCalendarMarker(calendar, day, month, year);
705
706 /* Check to see if a marker has not already been set. */
707 if (oldmarker != 0)
708 {
709 CALENDAR_CELL(calendar,day,month,yearIndex) = oldmarker | A_BLINK;
710 }
711 else
712 {
713 CALENDAR_CELL(calendar,day,month,yearIndex) = marker;
714 }
715 }
716 chtype getCDKCalendarMarker (CDKCALENDAR *calendar, int day, int month, int year)
717 {
718 int result = 0;
719
720 year = YEAR2INDEX(year);
721 if (calendar->marker != 0)
722 result = CALENDAR_CELL(calendar, day, month, year);
723 return result;
724 }
725
726 /*
727 * This sets a marker on the calendar.
728 */
729 void removeCDKCalendarMarker (CDKCALENDAR *calendar, int day, int month, int year)
730 {
731 int yearIndex = YEAR2INDEX(year);
732 CALENDAR_CELL(calendar,day,month,yearIndex) = 0;
733 }
734
735 /*
736 * This function sets the month name.
737 */
738 void setCDKCalendarMonthsNames (CDKCALENDAR *calendar, char **months)
739 {
740 int x;
741
742 for (x=1; x < MAX_MONTHS; x++)
743 {
744 freeChar(calendar->MonthName[x]);
745 calendar->MonthName[x] = copyChar(months[x]);
746 }
747 }
748
749 /*
750 * This function sets the days name.
751 */
752 void setCDKCalendarDaysNames (CDKCALENDAR *calendar, char *days)
753 {
754 freeChar(calendar->DayName);
755 calendar->DayName = copyChar(days);
756 }
757
758 /*
759 * This makes sure that the dates provided exist.
760 */
761 static void verifyCalendarDate (CDKCALENDAR *calendar)
762 {
763 int monthLength;
764
765 /* Make sure the given year is not less than 1900. */
766 if (calendar->year < 1900)
767 {
768 calendar->year = 1900;
769 }
770
771 /* Make sure the month is within range. */
772 if (calendar->month > 12)
773 {
774 calendar->month = 12;
775 }
776 if (calendar->month < 1)
777 {
778 calendar->month = 1;
779 }
780
781 /* Make sure the day given is within range of the month. */
782 monthLength = getMonthLength (calendar->year, calendar->month);
783 if (calendar->day < 1)
784 {
785 calendar->day = 1;
786 }
787 if (calendar->day > monthLength)
788 {
789 calendar->day = monthLength;
790 }
791 }
792
793 /*
794 * This returns what day of the week the month starts on.
795 */
796 static int getMonthStartWeekday (int year, int month)
797 {
798 struct tm Date;
799
800 /* Set the tm structure correctly. */
801 Date.tm_sec = 0;
802 Date.tm_min = 0;
803 Date.tm_hour = 10;
804 Date.tm_mday = 1;
805 Date.tm_mon = month - 1;
806 Date.tm_year = YEAR2INDEX(year);
807 Date.tm_isdst = 1;
808
809 /* Call the mktime function to fill in the holes. */
810 if (mktime (&Date) == (time_t)-1)
811 {
812 return 0;
813 }
814 return Date.tm_wday;
815 }
816
817 /*
818 * This function returns a 1 if it's a leap year and 0 if it's not.
819 */
820 static int isLeapYear (int year)
821 {
822 if (year % 4 == 0 ||
823 year % 4 == 0)
824 {
825 return 1;
826 }
827 return 0;
828 }
829
830 /*
831 * This increments the current day by the given value.
832 */
833 static void incrementCalendarDay (CDKCALENDAR *calendar, int adjust)
834 {
835 int monthLength = getMonthLength (calendar->year, calendar->month);
836
837 /* Make sure we adjust the day correctly. */
838 if (adjust + calendar->day > monthLength)
839 {
840 /* Have to increment the month by one. */
841 calendar->day = calendar->day + adjust - monthLength;
842 incrementCalendarMonth (calendar, 1);
843 }
844 else
845 {
846 calendar->day += adjust;
847 drawCDKCalendarField (calendar);
848 }
849 }
850
851 /*
852 * This decrments the current day by the given value.
853 */
854 static void decrementCalendarDay (CDKCALENDAR *calendar, int adjust)
855 {
856 int monthLength;
857
858 /* Make sure we adjust the day correctly. */
859 if (calendar->day - adjust < 1)
860 {
861 /* Set the day according to the length of the month. */
862 if (calendar->month == 1)
863 {
864 /* Make sure we aren't going past the year limit. */
865 if (calendar->year == 1900)
866 {
867 char *mesg[] = {"<C></U>Error", "Can not go past the year 1900"};
868 Beep();
869 popupLabel (ScreenOf(calendar), mesg, 2);
870 return;
871 }
872 monthLength = getMonthLength (calendar->year - 1, 12);
873 }
874 else
875 {
876 monthLength = getMonthLength (calendar->year, calendar->month - 1);
877 }
878
879 calendar->day = monthLength - (adjust - calendar->day);
880
881 /* Have to decrement the month by one. */
882 decrementCalendarMonth (calendar, 1);
883 }
884 else
885 {
886 calendar->day -= adjust;
887 drawCDKCalendarField (calendar);
888 }
889 }
890
891 /*
892 * This increments the current month by the given value.
893 */
894 static void incrementCalendarMonth (CDKCALENDAR *calendar, int adjust)
895 {
896 int monthLength;
897
898 /* Are we at the end of the year. */
899 if (calendar->month + adjust > 12)
900 {
901 calendar->month = (calendar->month + adjust) - 12;
902 calendar->year++;
903 }
904 else
905 {
906 calendar->month += adjust;
907 }
908
909 /* Get the length of the current month. */
910 monthLength = getMonthLength (calendar->year, calendar->month);
911 if (calendar->day > monthLength)
912 {
913 calendar->day = monthLength;
914 }
915
916 /* Get the start of the current month. */
917 calendar->weekDay = getMonthStartWeekday (calendar->year, calendar->month);
918
919 /* Redraw the calendar. */
920 eraseCDKCalendar (calendar);
921 drawCDKCalendar (calendar, ObjOf(calendar)->box);
922 }
923
924 /*
925 * This decrements the current month by the given value.
926 */
927 static void decrementCalendarMonth (CDKCALENDAR *calendar, int adjust)
928 {
929 int monthLength;
930
931 /* Are we at the end of the year. */
932 if (calendar->month <= adjust)
933 {
934 if (calendar->year == 1900)
935 {
936 char *mesg[] = {"<C></U>Error", "Can not go past the year 1900"};
937 Beep();
938 popupLabel (ScreenOf(calendar), mesg, 2);
939 return;
940 }
941 else
942 {
943 calendar->month = 13 - adjust;
944 calendar->year--;
945 }
946 }
947 else
948 {
949 calendar->month -= adjust;
950 }
951
952 /* Get the length of the current month. */
953 monthLength = getMonthLength (calendar->year, calendar->month);
954 if (calendar->day > monthLength)
955 {
956 calendar->day = monthLength;
957 }
958
959 /* Get the start of the current month. */
960 calendar->weekDay = getMonthStartWeekday (calendar->year, calendar->month);
961
962 /* Redraw the calendar. */
963 eraseCDKCalendar (calendar);
964 drawCDKCalendar (calendar, ObjOf(calendar)->box);
965 }
966
967 /*
968 * This increments the current year by the given value.
969 */
970 static void incrementCalendarYear (CDKCALENDAR *calendar, int adjust)
971 {
972 /* Increment the year. */
973 calendar->year += adjust;
974
975 /* If we are in Feb make sure we don't trip into voidness. */
976 if (calendar->month == 2)
977 {
978 int monthLength = getMonthLength (calendar->year, calendar->month);
979 if (calendar->day > monthLength)
980 {
981 calendar->day = monthLength;
982 }
983 }
984
985 /* Get the start of the current month. */
986 calendar->weekDay = getMonthStartWeekday (calendar->year, calendar->month);
987
988 /* Redraw the calendar. */
989 eraseCDKCalendar (calendar);
990 drawCDKCalendar (calendar, ObjOf(calendar)->box);
991 }
992
993 /*
994 * This decrements the current year by the given value.
995 */
996 static void decrementCalendarYear (CDKCALENDAR *calendar, int adjust)
997 {
998 /* Make sure we don't go out of bounds. */
999 if (calendar->year - adjust < 1900)
1000 {
1001 char *mesg[] = {"<C></U>Error", "Can not go past the year 1900"};
1002 Beep();
1003 popupLabel (ScreenOf(calendar), mesg, 2);
1004 return;
1005 }
1006
1007 /* Decrement the year. */
1008 calendar->year -= adjust;
1009
1010 /* If we are in Feb make sure we don't trip into voidness. */
1011 if (calendar->month == 2)
1012 {
1013 int monthLength = getMonthLength (calendar->year, calendar->month);
1014 if (calendar->day > monthLength)
1015 {
1016 calendar->day = monthLength;
1017 }
1018 }
1019
1020 /* Get the start of the current month. */
1021 calendar->weekDay = getMonthStartWeekday (calendar->year, calendar->month);
1022
1023 /* Redraw the calendar. */
1024 eraseCDKCalendar (calendar);
1025 drawCDKCalendar (calendar, ObjOf(calendar)->box);
1026 }
1027
1028 /*
1029 * This returns the length of the current month.
1030 */
1031 static int getMonthLength (int year, int month)
1032 {
1033 int monthLength = daysOfTheMonth[month];
1034
1035 if (month == 2)
1036 {
1037 monthLength += isLeapYear (year);
1038 }
1039 return monthLength;
1040 }
1041
1042 /*
1043 * This returns what day of the week the month starts on.
1044 */
1045 static time_t getCurrentTime (CDKCALENDAR *calendar)
1046 {
1047 struct tm Date, *dateInfo;
1048 time_t clck;
1049
1050 /* Determine the current time and determine if we are in DST. */
1051 time (&clck);
1052 dateInfo = localtime (&clck);
1053
1054 /* Set the tm structure correctly. */
1055 Date.tm_sec = 0;
1056 Date.tm_min = 0;
1057 Date.tm_hour = 0;
1058 Date.tm_mday = calendar->day;
1059 Date.tm_mon = calendar->month - 1;
1060 Date.tm_year = YEAR2INDEX(calendar->year);
1061 Date.tm_isdst = dateInfo->tm_isdst;
1062
1063 /* Call the mktime function to fill in the holes. */
1064 return mktime (&Date);
1065 }
1066
1067 static void _focusCDKCalendar(CDKOBJS *object)
1068 {
1069 CDKCALENDAR *widget = (CDKCALENDAR *)object;
1070
1071 drawCDKFScale (widget, ObjOf(widget)->box);
1072 }
1073
1074 static void _unfocusCDKCalendar(CDKOBJS *object)
1075 {
1076 CDKCALENDAR *widget = (CDKCALENDAR *)object;
1077
1078 drawCDKFScale (widget, ObjOf(widget)->box);
1079 }
1080
1081 dummyRefreshData(Calendar)
1082
1083 dummySaveData(Calendar)
+1509
-0
cdk.c less more
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/04/23 00:01:26 $
5 * $Revision: 1.204 $
6 */
7
8 #define L_MARKER '<'
9 #define R_MARKER '>'
10
11 char *GPasteBuffer = 0;
12
13 /*
14 * This beeps then flushes the stdout stream.
15 */
16 void Beep (void)
17 {
18 beep ();
19 fflush (stdout);
20 }
21
22 /*
23 * This sets a string to the given character.
24 */
25 void cleanChar (char *s, int len, char character)
26 {
27 if (s != 0)
28 {
29 int x;
30 for (x = 0; x < len; x++)
31 {
32 s[x] = character;
33 }
34 s[--x] = '\0';
35 }
36 }
37
38 void cleanChtype (chtype *s, int len, chtype character)
39 {
40 if (s != 0)
41 {
42 int x;
43 for (x = 0; x < len; x++)
44 {
45 s[x] = character;
46 }
47 s[--x] = '\0';
48 }
49 }
50
51 /*
52 * This takes an x and y position and realigns the values iff they sent in
53 * values like CENTER, LEFT, RIGHT, ...
54 */
55 void alignxy (WINDOW *window, int *xpos, int *ypos, int boxWidth, int boxHeight)
56 {
57 int first, gap, last;
58
59 first = getbegx (window);
60 last = getmaxx (window);
61 if ((gap = (last - boxWidth)) < 0)
62 gap = 0;
63 last = first + gap;
64
65 switch (*xpos)
66 {
67 case LEFT:
68 (*xpos) = first;
69 break;
70 case RIGHT:
71 (*xpos) = first + gap;
72 break;
73 case CENTER:
74 (*xpos) = first + (gap / 2);
75 break;
76 default:
77 if ((*xpos) > last)
78 (*xpos) = last;
79 else if ((*xpos) < first)
80 (*xpos) = first;
81 break;
82 }
83
84 first = getbegy (window);
85 last = getmaxy (window);
86 if ((gap = (last - boxHeight)) < 0)
87 gap = 0;
88 last = first + gap;
89
90 switch (*ypos)
91 {
92 case TOP:
93 (*ypos) = first;
94 break;
95 case BOTTOM:
96 (*ypos) = first + gap;
97 break;
98 case CENTER:
99 (*ypos) = first + (gap / 2);
100 break;
101 default:
102 if ((*ypos) > last)
103 {
104 (*ypos) = last;
105 }
106 else if ((*ypos) < first)
107 {
108 (*ypos) = first;
109 }
110 break;
111 }
112 }
113
114 /*
115 * This takes a string, a field width and a justification type
116 * and returns the adjustment to make, to fill
117 * the justification requirement.
118 */
119 int justifyString (int boxWidth, int mesgLength, int justify)
120 {
121 /*
122 * Make sure the message isn't longer than the width.
123 * If it is, return 0.
124 */
125 if (mesgLength >= boxWidth)
126 return (0);
127
128 /* Try to justify the message. */
129 if (justify == LEFT)
130 return (0);
131
132 if (justify == RIGHT)
133 return boxWidth - mesgLength;
134
135 if (justify == CENTER)
136 return ((int)((boxWidth - mesgLength) / 2));
137
138 return (justify);
139 }
140
141 /*
142 * This frees a string if it is not null. This is a safety
143 * measure. Some compilers let you free a null string. I
144 * don't like that idea.
145 */
146 void freeChar (char *string)
147 {
148 freeChecked (string);
149 }
150
151 void freeChtype (chtype *string)
152 {
153 freeChecked (string);
154 }
155
156 /*
157 * Corresponding list freeing (does not free the list pointer).
158 */
159 void freeCharList (char **list, unsigned size)
160 {
161 if (list != 0)
162 {
163 while (size-- != 0)
164 {
165 freeChar (list[size]);
166 list[size] = 0;
167 }
168 }
169 }
170
171 void freeChtypeList (chtype **list, unsigned size)
172 {
173 if (list != 0)
174 {
175 while (size-- != 0)
176 {
177 freeChtype (list[size]);
178 list[size] = 0;
179 }
180 }
181 }
182
183 /*
184 * This performs a safe copy of a string. This means it adds the null
185 * terminator on the end of the string, like strdup().
186 */
187 char *copyChar (char *original)
188 {
189 char *newstring = 0;
190
191 if (original != 0)
192 {
193 if ((newstring = typeMallocN (char, strlen (original) + 1)) != 0)
194 strcpy (newstring, original);
195 }
196 return (newstring);
197 }
198
199 chtype *copyChtype (chtype *original)
200 {
201 chtype *newstring = 0;
202
203 if (original != 0)
204 {
205 int len = chlen (original);
206 int x;
207
208 if ((newstring = typeMallocN (chtype, len + 4)) != 0)
209 {
210 for (x = 0; x < len; x++)
211 {
212 newstring[x] = original[x];
213 }
214 newstring[len] = '\0';
215 newstring[len + 1] = '\0';
216 }
217 else
218 {
219 newstring = original;
220 }
221
222 }
223 return (newstring);
224 }
225
226 /*
227 * Copy the given lists.
228 */
229 char **copyCharList (char **list)
230 {
231 unsigned size = lenCharList (list) + 1;
232 char **result = typeMallocN (char *, size);
233
234 if (result != 0)
235 {
236 unsigned n;
237 for (n = 0; n < size; ++n)
238 result[n] = copyChar (list[n]);
239 }
240 return result;
241 }
242
243 chtype **copyChtypeList (chtype **list)
244 {
245 unsigned size = lenChtypeList (list) + 1;
246 chtype **result = typeMallocN (chtype *, size);
247
248 if (result != 0)
249 {
250 while (size-- != 0)
251 {
252 freeChtype (list[size]);
253 list[size] = 0;
254 }
255 }
256 return result;
257 }
258
259 /*
260 * Return the length of the given lists.
261 */
262 int lenCharList (char **list)
263 {
264 int result = 0;
265 if (list != 0)
266 {
267 while (*list++ != 0)
268 ++result;
269 }
270 return result;
271 }
272
273 int lenChtypeList (chtype **list)
274 {
275 int result = 0;
276 if (list != 0)
277 {
278 while (*list++ != 0)
279 ++result;
280 }
281 return result;
282 }
283
284 /*
285 * This reads a file and sticks it into the char *** provided.
286 */
287 int CDKreadFile (char *filename, char ***array)
288 {
289 FILE *fd;
290 char temp[BUFSIZ];
291 unsigned lines = 0;
292 unsigned used = 0;
293
294 /* Can we open the file? */
295 if ((fd = fopen (filename, "r")) == 0)
296 {
297 return (-1);
298 }
299
300 while ((fgets (temp, sizeof (temp), fd) != 0))
301 {
302 size_t len = strlen (temp);
303 if (len != 0 && temp[len - 1] == '\n')
304 temp[--len] = '\0';
305 used = CDKallocStrings (array, temp, lines++, used);
306 }
307 fclose (fd);
308
309 return (lines);
310 }
311
312 #define DigitOf(c) ((c)-'0')
313
314 static int encodeAttribute (char *string, int from, chtype *mask)
315 {
316 int pair = 0;
317
318 *mask = 0;
319 switch (string[from + 1])
320 {
321 case 'B':
322 *mask = A_BOLD;
323 break;
324 case 'D':
325 *mask = A_DIM;
326 break;
327 case 'K':
328 *mask = A_BLINK;
329 break;
330 case 'R':
331 *mask = A_REVERSE;
332 break;
333 case 'S':
334 *mask = A_STANDOUT;
335 break;
336 case 'U':
337 *mask = A_UNDERLINE;
338 break;
339 }
340
341 if (*mask != 0)
342 {
343 from++;
344 }
345 else if (isdigit (CharOf (string[from + 1])) &&
346 isdigit (CharOf (string[from + 2])))
347 {
348 #ifdef HAVE_START_COLOR
349 pair = DigitOf (string[from + 1]) * 10 + DigitOf (string[from + 2]);
350 *mask = COLOR_PAIR (pair);
351 #else
352 *mask = A_BOLD;
353 #endif
354 from += 2;
355 }
356 else if (isdigit (CharOf (string[from + 1])))
357 {
358 #ifdef HAVE_START_COLOR
359 pair = DigitOf (string[from + 1]);
360 *mask = COLOR_PAIR (pair);
361 #else
362 *mask = A_BOLD;
363 #endif
364 from++;
365 }
366 return from;
367 }
368
369 /*
370 * The reverse of encodeAttribute()
371 * Well almost. If attributes such as bold and underline are combined in
372 * the same string, we do not necessarily reconstruct them in the same order.
373 * Also, alignment markers and tabs are lost.
374 */
375 static unsigned decodeAttribute (char *string,
376 unsigned from,
377 chtype oldattr,
378 chtype newattr)
379 {
380 /* *INDENT-OFF* */
381 static const struct {
382 int code;
383 chtype mask;
384 } table[] = {
385 { 'B', A_BOLD },
386 { 'D', A_DIM },
387 { 'K', A_BLINK },
388 { 'R', A_REVERSE },
389 { 'S', A_STANDOUT },
390 { 'U', A_UNDERLINE },
391 };
392 /* *INDENT-ON* */
393
394 char temp[80];
395 char *result = (string != 0) ? string : temp;
396 char *base = result;
397 chtype tmpattr = oldattr & A_ATTRIBUTES;
398
399 newattr &= A_ATTRIBUTES;
400 if (tmpattr != newattr)
401 {
402 while (tmpattr != newattr)
403 {
404 unsigned n;
405 bool found = FALSE;
406
407 for (n = 0; n < sizeof (table) / sizeof (table[0]); ++n)
408 {
409 if ((table[n].mask & tmpattr) != (table[n].mask & newattr))
410 {
411 found = TRUE;
412 *result++ = L_MARKER;
413 if (table[n].mask & tmpattr)
414 {
415 *result++ = '!';
416 tmpattr &= ~(table[n].mask);
417 }
418 else
419 {
420 *result++ = '/';
421 tmpattr |= (table[n].mask);
422 }
423 *result++ = table[n].code;
424 break;
425 }
426 }
427 #ifdef HAVE_START_COLOR
428 if ((tmpattr & A_COLOR) != (newattr & A_COLOR))
429 {
430 int oldpair = PAIR_NUMBER (tmpattr);
431 int newpair = PAIR_NUMBER (newattr);
432 if (!found)
433 {
434 found = TRUE;
435 *result++ = L_MARKER;
436 }
437 if (newpair == 0)
438 {
439 *result++ = '!';
440 sprintf (result, "%d", oldpair);
441 }
442 else
443 {
444 *result++ = '/';
445 sprintf (result, "%d", newpair);
446 }
447 result += strlen (result);
448 tmpattr &= ~A_COLOR;
449 newattr &= ~A_COLOR;
450 }
451 #endif
452 if (found)
453 *result++ = R_MARKER;
454 else
455 break;
456 }
457 }
458
459 return from + (result - base);
460 }
461
462 /*
463 * This function takes a character string, full of format markers
464 * and translates them into a chtype * array. This is better suited
465 * to curses, because curses uses chtype almost exclusively
466 */
467 chtype *char2Chtype (char *string, int *to, int *align)
468 {
469 chtype *result = 0;
470 chtype attrib;
471 chtype lastChar;
472 chtype mask;
473 int adjust;
474 int from;
475 int insideMarker;
476 int len;
477 int pass;
478 int start;
479 int used;
480 int x;
481
482 (*to) = 0;
483 *align = LEFT;
484
485 if (string != 0 && *string != 0)
486 {
487 len = (int)strlen (string);
488 used = 0;
489 /*
490 * We make two passes because we may have indents and tabs to expand, and
491 * do not know in advance how large the result will be.
492 */
493 for (pass = 0; pass < 2; pass++)
494 {
495 if (pass != 0)
496 {
497 if ((result = typeMallocN (chtype, used + 2)) == 0)
498 {
499 used = 0;
500 break;
501 }
502 }
503 adjust = 0;
504 attrib = A_NORMAL;
505 lastChar = 0;
506 start = 0;
507 used = 0;
508 x = 3;
509
510 /* Look for an alignment marker. */
511 if (*string == L_MARKER)
512 {
513 if (string[1] == 'C' && string[2] == R_MARKER)
514 {
515 (*align) = CENTER;
516 start = 3;
517 }
518 else if (string[1] == 'R' && string[2] == R_MARKER)
519 {
520 (*align) = RIGHT;
521 start = 3;
522 }
523 else if (string[1] == 'L' && string[2] == R_MARKER)
524 {
525 start = 3;
526 }
527 else if (string[1] == 'B' && string[2] == '=')
528 {
529 /* Set the item index value in the string. */
530 if (result != 0)
531 {
532 result[0] = ' ';
533 result[1] = ' ';
534 result[2] = ' ';
535 }
536
537 /* Pull out the bullet marker. */
538 while (string[x] != R_MARKER && string[x] != 0)
539 {
540 if (result != 0)
541 result[x] = string[x] | A_BOLD;
542 x++;
543 }
544 adjust = 1;
545
546 /* Set the alignment variables. */
547 start = x;
548 used = x;
549 }
550 else if (string[1] == 'I' && string[2] == '=')
551 {
552 from = 2;
553 x = 0;
554
555 while (string[++from] != R_MARKER && string[from] != 0)
556 {
557 if (isdigit (CharOf (string[from])))
558 {
559 adjust = (adjust * 10) + DigitOf (string[from]);
560 x++;
561 }
562 }
563
564 start = x + 4;
565 }
566 }
567
568 while (adjust-- > 0)
569 {
570 if (result != 0)
571 result[used] = ' ';
572 used++;
573 }
574
575 /* Set the format marker boolean to false. */
576 insideMarker = FALSE;
577
578 /* Start parsing the character string. */
579 for (from = start; from < len; from++)
580 {
581 /* Are we inside a format marker? */
582 if (!insideMarker)
583 {
584 if (string[from] == L_MARKER
585 && (string[from + 1] == '/'
586 || string[from + 1] == '!'
587 || string[from + 1] == '#'))
588 {
589 insideMarker = TRUE;
590 }
591 else if (string[from] == '\\' && string[from + 1] == L_MARKER)
592 {
593 from++;
594 if (result != 0)
595 result[used] = CharOf (string[from]) | attrib;
596 used++;
597 from++;
598 }
599 else if (string[from] == '\t')
600 {
601 do
602 {
603 if (result != 0)
604 result[used] = ' ';
605 used++;
606 }
607 while (used & 7);
608 }
609 else
610 {
611 if (result != 0)
612 result[used] = CharOf (string[from]) | attrib;
613 used++;
614 }
615 }
616 else
617 {
618 switch (string[from])
619 {
620 case R_MARKER:
621 insideMarker = 0;
622 break;
623 case '#':
624 {
625 lastChar = 0;
626 switch (string[from + 2])
627 {
628 case 'L':
629 switch (string[from + 1])
630 {
631 case 'L':
632 lastChar = ACS_LLCORNER;
633 break;
634 case 'U':
635 lastChar = ACS_ULCORNER;
636 break;
637 case 'H':
638 lastChar = ACS_HLINE;
639 break;
640 case 'V':
641 lastChar = ACS_VLINE;
642 break;
643 case 'P':
644 lastChar = ACS_PLUS;
645 break;
646 }
647 break;
648 case 'R':
649 switch (string[from + 1])
650 {
651 case 'L':
652 lastChar = ACS_LRCORNER;
653 break;
654 case 'U':
655 lastChar = ACS_URCORNER;
656 break;
657 }
658 break;
659 case 'T':
660 switch (string[from + 1])
661 {
662 case 'T':
663 lastChar = ACS_TTEE;
664 break;
665 case 'R':
666 lastChar = ACS_RTEE;
667 break;
668 case 'L':
669 lastChar = ACS_LTEE;
670 break;
671 case 'B':
672 lastChar = ACS_BTEE;
673 break;
674 }
675 break;
676 case 'A':
677 switch (string[from + 1])
678 {
679 case 'L':
680 lastChar = ACS_LARROW;
681 break;
682 case 'R':
683 lastChar = ACS_RARROW;
684 break;
685 case 'U':
686 lastChar = ACS_UARROW;
687 break;
688 case 'D':
689 lastChar = ACS_DARROW;
690 break;
691 }
692 break;
693 default:
694 if (string[from + 1] == 'D' &&
695 string[from + 2] == 'I')
696 lastChar = ACS_DIAMOND;
697 else if (string[from + 1] == 'C' &&
698 string[from + 2] == 'B')
699 lastChar = ACS_CKBOARD;
700 else if (string[from + 1] == 'D' &&
701 string[from + 2] == 'G')
702 lastChar = ACS_DEGREE;
703 else if (string[from + 1] == 'P' &&
704 string[from + 2] == 'M')
705 lastChar = ACS_PLMINUS;
706 else if (string[from + 1] == 'B' &&
707 string[from + 2] == 'U')
708 lastChar = ACS_BULLET;
709 else if (string[from + 1] == 'S' &&
710 string[from + 2] == '1')
711 lastChar = ACS_S1;
712 else if (string[from + 1] == 'S' &&
713 string[from + 2] == '9')
714 lastChar = ACS_S9;
715 }
716
717 if (lastChar != 0)
718 {
719 adjust = 1;
720 from += 2;
721
722 if (string[from + 1] == '(')
723 /* Check for a possible numeric modifier. */
724 {
725 from++;
726 adjust = 0;
727
728 while (string[++from] != ')' && string[from] != 0)
729 {
730 if (isdigit (CharOf (string[from])))
731 {
732 adjust = (adjust * 10) + DigitOf (string[from]);
733 }
734 }
735 }
736 }
737 for (x = 0; x < adjust; x++)
738 {
739 if (result != 0)
740 result[used] = lastChar | attrib;
741 used++;
742 }
743 break;
744 }
745 case '/':
746 from = encodeAttribute (string, from, &mask);
747 attrib = attrib | mask;
748 break;
749 case '!':
750 from = encodeAttribute (string, from, &mask);
751 attrib = attrib & ~mask;
752 break;
753 }
754 }
755 }
756
757 if (result != 0)
758 {
759 result[used] = 0;
760 result[used + 1] = 0;
761 }
762
763 /*
764 * If there are no characters, put the attribute into the
765 * the first character of the array.
766 */
767 if (used == 0
768 && result != 0)
769 {
770 result[0] = attrib;
771 }
772 }
773 *to = used;
774 }
775 else
776 {
777 /*
778 * Try always to return something; otherwise lists of chtype strings
779 * would get a spurious null pointer whenever there is a blank line,
780 * and CDKfreeChtypes() would fail to free the whole list.
781 */
782 result = typeCallocN (chtype, 1);
783 }
784 return result;
785 }
786
787 /*
788 * This determines the length of a chtype string
789 */
790 int chlen (chtype *string)
791 {
792 int result = 0;
793
794 if (string != 0)
795 {
796 while (string[result] != 0)
797 result++;
798 }
799
800 return (result);
801 }
802
803 /*
804 * Compare a regular string to a chtype string
805 */
806 int cmpStrChstr (char *str, chtype *chstr)
807 {
808 int r = 0;
809
810 if (!str && !chstr)
811 return 0;
812 if (!str)
813 return 1;
814 if (!chstr)
815 return -1;
816
817 while (!r && *str && *chstr)
818 {
819 r = *str - CharOf (*chstr);
820 ++str;
821 ++chstr;
822 }
823
824 if (r)
825 return r;
826 else if (!*str)
827 return -1;
828 else if (!*chstr)
829 return 1;
830 return 0;
831 }
832
833 void chstrncpy (char *dest, chtype *src, int maxcount)
834 {
835 int i = 0;
836
837 while (i < maxcount && *src)
838 *dest++ = CharOf (*src++);
839
840 *dest = '\0';
841 }
842
843 /*
844 * This returns a pointer to char * of a chtype *
845 * Formatting codes are omitted.
846 */
847 char *chtype2Char (chtype *string)
848 {
849 char *newstring = 0;
850
851 if (string != 0)
852 {
853 int len = chlen (string);
854 int x;
855
856 if ((newstring = typeMallocN (char, len + 1)) != 0)
857 {
858 for (x = 0; x < len; x++)
859 {
860 newstring[x] = (char)CharOf (string[x]);
861 }
862 newstring[len] = '\0';
863 }
864 }
865 return (newstring);
866 }
867
868 /*
869 * This returns a pointer to char * of a chtype *
870 * Formatting codes are embedded.
871 */
872 char *chtype2String (chtype *string)
873 {
874 char *newstring = 0;
875
876 if (string != 0)
877 {
878 int pass;
879 int len = chlen (string);
880
881 for (pass = 0; pass < 2; ++pass)
882 {
883 int x;
884 unsigned need = 0;
885
886 for (x = 0; x < len; ++x)
887 {
888 need = decodeAttribute (newstring, need,
889 (x > 0) ? string[x - 1] : 0,
890 string[x]);
891 if (newstring != 0)
892 newstring[need] = CharOf (string[x]);
893 ++need;
894 }
895 if (pass)
896 newstring[need] = 0;
897 ++need;
898 if (!pass)
899 {
900 if ((newstring = typeMallocN (char, need)) == 0)
901 break;
902 }
903 }
904 }
905 return (newstring);
906 }
907
908 static int comparSort (const void *a, const void *b)
909 {
910 return strcmp (*(const char *const *)a, (*(const char *const *)b));
911 }
912
913 void sortList (char **list, int length)
914 {
915 if (length > 1)
916 qsort (list, (unsigned)length, sizeof (list[0]), comparSort);
917 }
918
919 /*
920 * This strips white space from the given string.
921 */
922 void stripWhiteSpace (EStripType stripType, char *string)
923 {
924 /* Declare local variables. */
925 unsigned stringLength = 0;
926 unsigned alphaChar = 0;
927 unsigned x;
928
929 /* Make sure the string is not null. */
930 if (string != 0
931 && (stringLength = strlen (string)) != 0)
932 {
933 /* Strip leading whitespace */
934 if (stripType == vFRONT || stripType == vBOTH)
935 {
936 /* Find the first non-whitespace character. */
937 while (string[alphaChar] == ' ' || string[alphaChar] == '\t')
938 {
939 alphaChar++;
940 }
941
942 for (x = alphaChar; x <= stringLength; ++x)
943 string[x - alphaChar] = string[x];
944 }
945
946 /* Strip trailing whitespace */
947 if (stripType == vBACK || stripType == vBOTH)
948 {
949 stringLength = strlen (string);
950 while (stringLength-- != 0 &&
951 (string[stringLength] == ' ' ||
952 string[stringLength] == '\t'))
953 {
954 string[stringLength] = '\0';
955 }
956 }
957 }
958 }
959
960 static unsigned countChar (char *string, int separator)
961 {
962 unsigned result = 0;
963 int ch;
964
965 while ((ch = *string++) != 0)
966 {
967 if (ch == separator)
968 result++;
969 }
970 return result;
971 }
972
973 /*
974 * Split a string into a list of strings.
975 */
976 char **CDKsplitString (char *string, int separator)
977 {
978 char **result = 0;
979 char *first;
980 char *temp;
981 unsigned item;
982 unsigned need;
983
984 if (string != 0 && *string != 0)
985 {
986 need = countChar (string, separator) + 2;
987 if ((result = typeMallocN (char *, need)) != 0)
988 {
989 item = 0;
990 first = string;
991 for (;;)
992 {
993 while (*string != 0 && *string != separator)
994 string++;
995
996 need = string - first;
997 if ((temp = typeMallocN (char, need + 1)) == 0)
998 break;
999
1000 memcpy (temp, first, need);
1001 temp[need] = 0;
1002 result[item++] = temp;
1003
1004 if (*string++ == 0)
1005 break;
1006 first = string;
1007 }
1008 result[item] = 0;
1009 }
1010 }
1011 return result;
1012 }
1013
1014 /*
1015 * Add a new string to a list. Keep a null pointer on the end so we can use
1016 * CDKfreeStrings() to deallocate the whole list.
1017 */
1018 unsigned CDKallocStrings (char ***list, char *item, unsigned length, unsigned used)
1019 {
1020 unsigned need = 1;
1021
1022 while (need < length + 2)
1023 need *= 2;
1024 if (need > used)
1025 {
1026 used = need;
1027 if (*list == 0)
1028 {
1029 *list = typeMallocN (char *, used);
1030 }
1031 else
1032 {
1033 *list = typeReallocN (char *, *list, used);
1034 }
1035 }
1036 (*list)[length++] = copyChar (item);
1037 (*list)[length] = 0;
1038 return used;
1039 }
1040
1041 /*
1042 * Count the number of items in a list of strings.
1043 */
1044 unsigned CDKcountStrings (char **list)
1045 {
1046 unsigned result = 0;
1047 if (list != 0)
1048 {
1049 while (*list++ != 0)
1050 result++;
1051 }
1052 return result;
1053 }
1054
1055 /*
1056 * Free a list of strings, terminated by a null pointer.
1057 */
1058 void CDKfreeStrings (char **list)
1059 {
1060 if (list != 0)
1061 {
1062 void *base = (void *)list;
1063 while (*list != 0)
1064 free (*list++);
1065 free (base);
1066 }
1067 }
1068
1069 /*
1070 * Free a list of chtype-strings, terminated by a null pointer.
1071 */
1072 void CDKfreeChtypes (chtype **list)
1073 {
1074 if (list != 0)
1075 {
1076 void *base = (void *)list;
1077 while (*list != 0)
1078 {
1079 freeChtype (*list++);
1080 }
1081 free (base);
1082 }
1083 }
1084
1085 int mode2Filetype (mode_t mode)
1086 {
1087 /* *INDENT-OFF* */
1088 static const struct {
1089 mode_t mode;
1090 char code;
1091 } table[] = {
1092 #ifdef S_IFBLK
1093 { S_IFBLK, 'b' }, /* Block device */
1094 #endif
1095 { S_IFCHR, 'c' }, /* Character device */
1096 { S_IFDIR, 'd' }, /* Directory */
1097 { S_IFREG, '-' }, /* Regular file */
1098 #ifdef S_IFLNK
1099 { S_IFLNK, 'l' }, /* Socket */
1100 #endif
1101 #ifdef S_IFSOCK
1102 { S_IFSOCK, '@' }, /* Socket */
1103 #endif
1104 { S_IFIFO, '&' }, /* Pipe */
1105 };
1106 /* *INDENT-ON* */
1107
1108 int filetype = '?';
1109 unsigned n;
1110
1111 for (n = 0; n < sizeof (table) / sizeof (table[0]); n++)
1112 {
1113 if ((mode & S_IFMT) == table[n].mode)
1114 {
1115 filetype = table[n].code;
1116 break;
1117 }
1118 }
1119
1120 return filetype;
1121
1122 }
1123
1124 /*
1125 * This function takes a mode_t type and creates a string represntation
1126 * of the permission mode.
1127 */
1128 int mode2Char (char *string, mode_t mode)
1129 {
1130 /* *INDENT-OFF* */
1131 static struct {
1132 mode_t mask;
1133 unsigned col;
1134 char flag;
1135 } table[] = {
1136 { S_IRUSR, 1, 'r' },
1137 { S_IWUSR, 2, 'w' },
1138 { S_IXUSR, 3, 'x' },
1139 { S_IRGRP, 4, 'r' },
1140 { S_IWGRP, 5, 'w' },
1141 { S_IXGRP, 6, 'x' },
1142 { S_IROTH, 7, 'r' },
1143 { S_IWOTH, 8, 'w' },
1144 { S_IXOTH, 9, 'x' },
1145 { S_ISUID, 3, 's' },
1146 { S_ISGID, 6, 's' },
1147 #ifdef S_ISVTX
1148 { S_ISVTX, 9, 't' },
1149 #endif
1150 };
1151 /* *INDENT-ON* */
1152
1153 /* Declare local variables. */
1154 int permissions = 0;
1155 int filetype = mode2Filetype (mode);
1156 unsigned n;
1157
1158 /* Clean the string. */
1159 cleanChar (string, 11, '-');
1160 string[11] = '\0';
1161
1162 if (filetype == '?')
1163 return -1;
1164
1165 for (n = 0; n < sizeof (table) / sizeof (table[0]); n++)
1166 {
1167 if ((mode & table[n].mask) != 0)
1168 {
1169 string[table[n].col] = table[n].flag;
1170 permissions |= table[n].mask;
1171 }
1172 }
1173
1174 /* Check for unusual permissions. */
1175 if (((mode & S_IXUSR) == 0) &&
1176 ((mode & S_IXGRP) == 0) &&
1177 ((mode & S_IXOTH) == 0) &&
1178 (mode & S_ISUID) != 0)
1179 {
1180 string[3] = 'S';
1181 }
1182
1183 return permissions;
1184 }
1185
1186 /*
1187 * This returns the length of the integer.
1188 */
1189 int intlen (int value)
1190 {
1191 if (value < 0)
1192 return 1 + intlen (-value);
1193 else if (value >= 10)
1194 return 1 + intlen (value / 10);
1195 return 1;
1196 }
1197
1198 /*
1199 * This opens the current directory and reads the contents.
1200 */
1201 int CDKgetDirectoryContents (char *directory, char ***list)
1202 {
1203 /* Declare local variables. */
1204 struct dirent *dirStruct;
1205 int counter = 0;
1206 DIR *dp;
1207 unsigned used = 0;
1208
1209 /* Open the directory. */
1210 dp = opendir (directory);
1211
1212 /* Could we open the directory? */
1213 if (dp == 0)
1214 {
1215 return -1;
1216 }
1217
1218 /* Read the directory. */
1219 while ((dirStruct = readdir (dp)) != 0)
1220 {
1221 if (strcmp (dirStruct->d_name, "."))
1222 used = CDKallocStrings (list, dirStruct->d_name, counter++, used);
1223 }
1224
1225 /* Close the directory. */
1226 closedir (dp);
1227
1228 /* Sort the info. */
1229 sortList (*list, counter);
1230
1231 /* Return the number of files in the directory. */
1232 return counter;
1233 }
1234
1235 /*
1236 * This looks for a subset of a word in the given list.
1237 */
1238 int searchList (char **list, int listSize, char *pattern)
1239 {
1240 /* Declare local variables. */
1241 unsigned len;
1242 int Index = -1;
1243 int x, ret;
1244
1245 /* Make sure the pattern isn't null. */
1246 if (pattern != 0)
1247 {
1248 len = strlen (pattern);
1249
1250 /* Cycle through the list looking for the word. */
1251 for (x = 0; x < listSize; x++)
1252 {
1253 /* Do a string compare. */
1254 ret = strncmp (list[x], pattern, len);
1255
1256 /*
1257 * If 'ret' is less than 0, then the current word is alphabetically
1258 * less than the provided word. At this point we will set the index
1259 * to the current position. If 'ret' is greater than 0, then the
1260 * current word is alphabetically greater than the given word. We
1261 * should return with index, which might contain the last best match.
1262 * If they are equal, then we've found it.
1263 */
1264 if (ret < 0)
1265 {
1266 Index = ret;
1267 }
1268 else
1269 {
1270 if (ret == 0)
1271 Index = x;
1272 break;
1273 }
1274 }
1275 }
1276 return Index;
1277 }
1278
1279 /*
1280 * This function checks to see if a link has been requested.
1281 */
1282 int checkForLink (char *line, char *filename)
1283 {
1284 int len = 0;
1285 int fPos = 0;
1286 int x = 3;
1287
1288 /* Make sure the line isn't null. */
1289 if (line == 0)
1290 {
1291 return -1;
1292 }
1293 len = (int)strlen (line);
1294
1295 /* Strip out the filename. */
1296 if (line[0] == L_MARKER && line[1] == 'F' && line[2] == '=')
1297 {
1298 /* Strip out the filename. */
1299 while (x < len)
1300 {
1301 if (line[x] == R_MARKER)
1302 {
1303 break;
1304 }
1305 if (fPos < CDK_PATHMAX)
1306 filename[fPos++] = line[x];
1307 ++x;
1308 }
1309 }
1310 filename[fPos] = '\0';
1311 return (fPos != 0);
1312 }
1313
1314 /*
1315 * Returns the filename portion of the given pathname, i.e., after the last
1316 * slash.
1317 */
1318 char *baseName (char *pathname)
1319 {
1320 char *base = 0;
1321 unsigned pathLen;
1322 unsigned x;
1323
1324 if (pathname != 0
1325 && *pathname != '\0'
1326 && (base = copyChar (pathname)) != 0)
1327 {
1328 if ((pathLen = strlen (pathname)) != 0)
1329 {
1330 for (x = pathLen - 1; x != 0; --x)
1331 {
1332 /* Find the last '/' in the pathname. */
1333 if (pathname[x] == '/')
1334 {
1335 strcpy (base, pathname + x + 1);
1336 break;
1337 }
1338 }
1339 }
1340 }
1341 return base;
1342 }
1343
1344 /*
1345 * Returns the directory for the given pathname, i.e., the part before the
1346 * last slash.
1347 */
1348 char *dirName (char *pathname)
1349 {
1350 char *dir = 0;
1351 unsigned pathLen;
1352 unsigned x;
1353
1354 /* Check if the string is null. */
1355 if (pathname != 0
1356 && (dir = copyChar (pathname)) != 0
1357 && (pathLen = strlen (pathname)) != 0)
1358 {
1359 x = pathLen;
1360 while ((dir[x] != '/') && (x > 0))
1361 {
1362 dir[x--] = '\0';
1363 }
1364 }
1365
1366 return dir;
1367 }
1368
1369 /*
1370 * If the dimension is a negative value, the dimension will be the full
1371 * height/width of the parent window - the value of the dimension. Otherwise,
1372 * the dimension will be the given value.
1373 */
1374 int setWidgetDimension (int parentDim, int proposedDim, int adjustment)
1375 {
1376 int dimension = 0;
1377
1378 /* If the user passed in FULL, return the parent's size. */
1379 if ((proposedDim == FULL) || (proposedDim == 0))
1380 {
1381 dimension = parentDim;
1382 }
1383 else
1384 {
1385 /* If they gave a positive value, return it. */
1386 if (proposedDim >= 0)
1387 {
1388 if (proposedDim >= parentDim)
1389 dimension = parentDim;
1390 else
1391 dimension = (proposedDim + adjustment);
1392 }
1393 else
1394 {
1395 /*
1396 * If they gave a negative value, then return the
1397 * dimension of the parent plus the value given.
1398 */
1399 dimension = parentDim + proposedDim;
1400
1401 /* Just to make sure. */
1402 if (dimension < 0)
1403 dimension = parentDim;
1404 }
1405 }
1406 return dimension;
1407 }
1408
1409 /*
1410 * This safely erases a given window.
1411 */
1412 void eraseCursesWindow (WINDOW *window)
1413 {
1414 if (window != 0)
1415 {
1416 werase (window);
1417 wrefresh (window);
1418 }
1419 }
1420
1421 /*
1422 * This safely deletes a given window.
1423 */
1424 void deleteCursesWindow (WINDOW *window)
1425 {
1426 if (window != 0)
1427 {
1428 eraseCursesWindow (window);
1429 delwin (window);
1430 }
1431 }
1432
1433 /*
1434 * This moves a given window (if we're able to set the window's beginning).
1435 * We do not use mvwin(), because it does (usually) not move subwindows.
1436 */
1437 void moveCursesWindow (WINDOW *window, int xdiff, int ydiff)
1438 {
1439 if (window != 0)
1440 {
1441 int xpos, ypos;
1442
1443 getbegyx (window, ypos, xpos);
1444 if (setbegyx (window, ypos, xpos) != ERR)
1445 {
1446 xpos += xdiff;
1447 ypos += ydiff;
1448 werase (window);
1449 (void)setbegyx (window, ypos, xpos);
1450 }
1451 else
1452 {
1453 Beep ();
1454 }
1455 }
1456 }
1457
1458 /*
1459 * Return an integer like 'floor()', which returns a double.
1460 */
1461 int floorCDK (double value)
1462 {
1463 int result = (int)value;
1464 if (result > value) /* e.g., value < 0.0 and value is not an integer */
1465 result--;
1466 return result;
1467 }
1468
1469 /*
1470 * Return an integer like 'ceil()', which returns a double.
1471 */
1472 int ceilCDK (double value)
1473 {
1474 return -floorCDK (-value);
1475 }
1476
1477 /*
1478 * Compatibility for different versions of curses.
1479 */
1480 #if !(defined(HAVE_GETBEGX) && defined(HAVE_GETBEGY))
1481 int getbegx (WINDOW *win)
1482 {
1483 int y, x;
1484 getbegyx (win, y, x);
1485 return x;
1486 }
1487 int getbegy (WINDOW *win)
1488 {
1489 int y, x;
1490 getbegyx (win, y, x);
1491 return y;
1492 }
1493 #endif
1494
1495 #if !(defined(HAVE_GETMAXX) && defined(HAVE_GETMAXY))
1496 int getmaxx (WINDOW *win)
1497 {
1498 int y, x;
1499 getmaxyx (win, y, x);
1500 return x;
1501 }
1502 int getmaxy (WINDOW *win)
1503 {
1504 int y, x;
1505 getmaxyx (win, y, x);
1506 return y;
1507 }
1508 #endif
0 # $Id: cdk.spec,v 1.15 2005/12/30 02:06:06 tom Exp $
1 # Note that this is NOT a relocatable package
2 %define ver 5.0
3 %define subver 20051230
4 %define rel 1
5 %define prefix /usr
6
7 Summary: A Curses Development Library (ncurses-based widgets)
8 Name: cdk
9 Version: %ver
10 Release: %rel
11 Copyright: BSD
12 Group: Applications/Libraries
13 Source: ftp://invisible-island.com/cdk/cdk.tar.gz
14 BuildRoot: /tmp/cdk-%{ver}-root
15 Packager: Squidster <squidster@msa.dec.com>
16 Requires: ncurses
17
18
19 %description
20 A Curses Development Library (ncurses-based widgets)
21
22 %changelog
23
24 %prep
25 %setup -n %{name}-%{ver}-%{subver}
26
27 %build
28 CFLAGS="${RPM_OPT_FLAGS}"
29 CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix
30 make DOCUMENT_DIR=/usr/share/doc/cdk
31
32 %install
33 rm -rf $RPM_BUILD_ROOT
34
35 make DESTDIR=$RPM_BUILD_ROOT DOCUMENT_DIR=$RPM_BUILD_ROOT/usr/share/doc/cdk install
36
37 %clean
38 rm -rf $RPM_BUILD_ROOT
39
40 %post
41
42 %postun
43
44 %files
45 %defattr(-, root, root)
46 %doc BUGS EXPANDING NOTES TODO COPYING INSTALL README
47 %{prefix}/include/cdk/*.h
48 %{prefix}/lib/lib*.a
49 %{prefix}/man/man3/*
50
0 /*
1 * $Id: cdk_compat.c,v 1.5 2005/12/28 21:43:35 tom Exp $
2 * These are functions that are obsolete, but provided as a porting aid.
3 * The obsolete functions use fixed limits, and inconsistent data handling.
4 */
5 #include "cdk_compat.h"
6
7 /*
8 * This opens the current directory and reads the contents.
9 */
10 int getDirectoryContents (char *directory, char **list, int maxListSize)
11 {
12 char **temp = 0;
13 int counter = CDKgetDirectoryContents (directory, &temp);
14 int n;
15
16 for (n = 0; n < counter && n < maxListSize; ++n)
17 {
18 list[n] = copyChar (temp[n]);
19 }
20 CDKfreeStrings (temp);
21
22 return counter;
23 }
24
25 /*
26 * This reads a file and sticks it into the char ** provided.
27 */
28 int readFile (char *filename, char **array, int maxlines)
29 {
30 char **temp = 0;
31 int lines = CDKreadFile (filename, &temp);
32 int n;
33
34 for (n = 0; n < maxlines; ++n)
35 {
36 if (n < lines)
37 {
38 array[n] = copyChar (temp[n]);
39 }
40 else
41 {
42 array[n] = copyChar ("");
43 break;
44 }
45 }
46 CDKfreeStrings (temp);
47
48 return (lines);
49 }
50
51 /*
52 * This splits a string into X parts given the split character.
53 */
54 int splitString (char *string, char **items, char splitChar)
55 {
56 char **temp = CDKsplitString (string, splitChar);
57 int chunks = 0;
58
59 for (chunks = 0; chunks < MAX_LINES && temp[chunks] != 0; ++chunks)
60 {
61 items[chunks] = copyChar (temp[chunks]);
62 }
63 CDKfreeStrings (temp);
64
65 return chunks;
66 }
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/04/18 00:06:07 $
5 * $Revision: 1.3 $
6 */
7
8 /*
9 * Given a character pointer, returns the equivalent display type.
10 */
11 EDisplayType char2DisplayType (char *string)
12 {
13 /* *INDENT-OFF* */
14 static const struct {
15 const char *name;
16 EDisplayType code;
17 } table[] = {
18 { "CHAR", vCHAR },
19 { "HCHAR", vHCHAR },
20 { "INT", vINT },
21 { "HINT", vHINT },
22 { "UCHAR", vUCHAR },
23 { "LCHAR", vLCHAR },
24 { "UHCHAR", vUHCHAR },
25 { "LHCHAR", vLHCHAR },
26 { "MIXED", vMIXED },
27 { "HMIXED", vHMIXED },
28 { "UMIXED", vUMIXED },
29 { "LMIXED", vLMIXED },
30 { "UHMIXED", vUHMIXED },
31 { "LHMIXED", vLHMIXED },
32 { "VIEWONLY", vVIEWONLY },
33 { 0, vINVALID },
34 };
35 /* *INDENT-ON* */
36
37 if (string != 0)
38 {
39 int n;
40 for (n = 0; table[n].name != 0; n++)
41 {
42 if (!strcmp (string, table[n].name))
43 return table[n].code;
44 }
45 }
46 return (EDisplayType) vINVALID;
47 }
48
49 /*
50 * Tell if a display type is "hidden"
51 */
52 boolean isHiddenDisplayType (EDisplayType type)
53 {
54 boolean result = FALSE;
55
56 switch (type)
57 {
58 case vHCHAR:
59 case vHINT:
60 case vHMIXED:
61 case vLHCHAR:
62 case vLHMIXED:
63 case vUHCHAR:
64 case vUHMIXED:
65 result = TRUE;
66 break;
67 case vCHAR:
68 case vINT:
69 case vINVALID:
70 case vLCHAR:
71 case vLMIXED:
72 case vMIXED:
73 case vUCHAR:
74 case vUMIXED:
75 case vVIEWONLY:
76 result = FALSE;
77 break;
78 }
79 return result;
80 }
81
82 /*
83 * Given a character input, check if it is allowed by the display type,
84 * and return the character to apply to the display, or ERR if not.
85 */
86 int filterByDisplayType (EDisplayType type, chtype input)
87 {
88 int result = CharOf (input);
89
90 if (!isChar (input))
91 {
92 result = ERR;
93 }
94 else if ((type == vINT ||
95 type == vHINT) &&
96 !isdigit (CharOf (result)))
97 {
98 result = ERR;
99 }
100 else if ((type == vCHAR ||
101 type == vUCHAR ||
102 type == vLCHAR ||
103 type == vUHCHAR ||
104 type == vLHCHAR) &&
105 isdigit (CharOf (result)))
106 {
107 result = ERR;
108 }
109 else if (type == vVIEWONLY)
110 {
111 result = ERR;
112 }
113 else if ((type == vUCHAR ||
114 type == vUHCHAR ||
115 type == vUMIXED ||
116 type == vUHMIXED) &&
117 isalpha (CharOf (result)))
118 {
119 result = toupper (result);
120 }
121 else if ((type == vLCHAR ||
122 type == vLHCHAR ||
123 type == vLMIXED ||
124 type == vLHMIXED) &&
125 isalpha (CharOf (result)))
126 {
127 result = tolower (result);
128 }
129 return result;
130 }
0 #include <cdk_int.h>
1
2 /*
3 * Default method-functions for CDK objects.
4 *
5 * $Author: tom $
6 * $Date: 2005/04/15 22:08:58 $
7 * $Revision: 1.12 $
8 */
9
10 /*
11 * Set the object's upper-left-corner line-drawing character.
12 */
13 void setCdkULchar (CDKOBJS *obj, chtype ch)
14 {
15 obj->ULChar = ch;
16 }
17
18 /*
19 * Set the object's upper-right-corner line-drawing character.
20 */
21 void setCdkURchar (CDKOBJS *obj, chtype ch)
22 {
23 obj->URChar = ch;
24 }
25
26 /*
27 * Set the object's lower-left-corner line-drawing character.
28 */
29 void setCdkLLchar (CDKOBJS *obj, chtype ch)
30 {
31 obj->LLChar = ch;
32 }
33
34 /*
35 * Set the object's upper-right-corner line-drawing character.
36 */
37 void setCdkLRchar (CDKOBJS *obj, chtype ch)
38 {
39 obj->LRChar = ch;
40 }
41
42 /*
43 * Set the object's horizontal line-drawing character.
44 */
45 void setCdkHZchar (CDKOBJS *obj, chtype ch)
46 {
47 obj->HZChar = ch;
48 }
49
50 /*
51 * Set the object's vertical line-drawing character.
52 */
53 void setCdkVTchar (CDKOBJS *obj, chtype ch)
54 {
55 obj->VTChar = ch;
56 }
57
58 /*
59 * Set the object's box-attributes.
60 */
61 void setCdkBXattr (CDKOBJS *obj, chtype ch)
62 {
63 obj->BXAttr = ch;
64 }
65
66 /*
67 * This sets the background color of the widget.
68 */
69 void setCDKObjectBackgroundColor (CDKOBJS *obj, char *color)
70 {
71 chtype *holder = 0;
72 int junk1, junk2;
73
74 /* Make sure the color isn't null. */
75 if (color == 0)
76 {
77 return;
78 }
79
80 /* Convert the value of the environment variable to a chtype. */
81 holder = char2Chtype (color, &junk1, &junk2);
82
83 /* Set the widget's background color. */
84 SetBackAttrObj(obj, holder[0]);
85
86 /* Clean up. */
87 freeChtype (holder);
88 }
89
90 /*
91 * Set the widget's title.
92 */
93 int setCdkTitle (CDKOBJS *obj, char *title, int boxWidth)
94 {
95 if (obj != 0)
96 {
97 cleanCdkTitle (obj);
98
99 if (title != 0)
100 {
101 chtype *holder;
102 char **temp = 0;
103 int titleWidth;
104 int x;
105 int len;
106 int align;
107 int maxWidth = 0;
108
109 /* We need to split the title on \n. */
110 temp = CDKsplitString (title, '\n');
111 obj->titleLines = CDKcountStrings (temp);
112
113 obj->title = typeCallocN (chtype *, obj->titleLines + 1);
114 obj->titlePos = typeCallocN (int, obj->titleLines + 1);
115 obj->titleLen = typeCallocN (int, obj->titleLines + 1);
116
117 if (boxWidth >= 0)
118 {
119 /* We need to determine the widest title line. */
120 for (x = 0; x < obj->titleLines; x++)
121 {
122 holder = char2Chtype (temp[x], &len, &align);
123 maxWidth = MAXIMUM (maxWidth, len);
124 freeChtype (holder);
125 }
126 boxWidth = MAXIMUM (boxWidth, maxWidth + 2 * obj->borderSize);
127 }
128 else
129 {
130 boxWidth = -(boxWidth - 1);
131 }
132
133 /* For each line in the title, convert from char * to chtype * */
134 titleWidth = boxWidth - (2 * obj->borderSize);
135 for (x = 0; x < obj->titleLines; x++)
136 {
137 obj->title[x] = char2Chtype (temp[x], &obj->titleLen[x],
138 &obj->titlePos[x]);
139 obj->titlePos[x] = justifyString (titleWidth, obj->titleLen[x],
140 obj->titlePos[x]);
141 }
142 CDKfreeStrings (temp);
143 }
144 }
145 return boxWidth;
146 }
147
148 /*
149 * Draw the widget's title.
150 */
151 void drawCdkTitle (WINDOW *win, CDKOBJS *obj)
152 {
153 if (obj != 0)
154 {
155 int x;
156
157 for (x = 0; x < obj->titleLines; x++)
158 {
159 writeChtype (win,
160 obj->titlePos[x] + obj->borderSize,
161 x + obj->borderSize,
162 obj->title[x],
163 HORIZONTAL, 0,
164 obj->titleLen[x]);
165 }
166 }
167 }
168
169 /*
170 * Remove storage for the widget's title.
171 */
172 void cleanCdkTitle (CDKOBJS *obj)
173 {
174 if (obj != 0)
175 {
176 CDKfreeChtypes (obj->title);
177 obj->title = 0;
178
179 freeAndNull (obj->titlePos);
180 freeAndNull (obj->titleLen);
181
182 obj->titleLines = 0;
183 }
184 }
185
186 /*
187 * Set data for preprocessing.
188 */
189 void setCDKObjectPreProcess (CDKOBJS *obj, PROCESSFN fn, void *data)
190 {
191 obj->preProcessFunction = fn;
192 obj->preProcessData = data;
193 }
194
195 /*
196 * Set data for postprocessing.
197 */
198 void setCDKObjectPostProcess (CDKOBJS *obj, PROCESSFN fn, void *data)
199 {
200 obj->postProcessFunction = fn;
201 obj->postProcessData = data;
202 }
203
204 /*
205 * Set the object's exit-type based on the input.
206 * The .exitType field should have been part of the CDKOBJS struct, but it
207 * is used too pervasively in older applications to move (yet).
208 */
209 void setCdkExitType (CDKOBJS *obj, EExitType *type, chtype ch)
210 {
211 switch (ch)
212 {
213 case KEY_ESC:
214 *type = vESCAPE_HIT;
215 break;
216 case KEY_TAB:
217 case KEY_ENTER:
218 *type = vNORMAL;
219 break;
220 case 0:
221 *type = vEARLY_EXIT;
222 break;
223 }
224 /* make the result available via ExitTypeOf(obj) */
225 obj->exitType = *type;
226 }
0 #include <cdk_int.h>
1
2 /*
3 * Useful functions for command-line parsing.
4 *
5 * $Author: tom $
6 * $Date: 2005/12/27 19:52:30 $
7 * $Revision: 1.6 $
8 */
9
10 #define OPTION_ON ((char *)1)
11 #define OPTION_OFF ((char *)0)
12
13 static void usage (char **argv,
14 CDK_PARAMS * params,
15 char *options)
16 {
17 int n;
18 char *str;
19
20 fprintf (stderr, "Usage: %s [options]\n\nOptions:\n", baseName (argv[0]));
21
22 for (n = 1; n < MAX_CDK_PARAMS; ++n)
23 {
24 if (n != ':'
25 && (str = strchr (options, n)) != 0)
26 {
27 int value = (str[1] == ':');
28 fprintf (stderr, " -%c", n);
29 if (value)
30 {
31 fprintf (stderr, " (%s)\n",
32 (params->allParams[n]
33 ? params->allParams[n]
34 : "not set"));
35 }
36 else
37 {
38 fprintf (stderr, " (%s)\n",
39 (params->allParams[n]
40 ? "set"
41 : "not set"));
42 }
43 }
44 }
45 exit (EXIT_FAILURE);
46 }
47
48 static int CDKparseSize (char *string, int fullSize)
49 {
50 int result;
51 if (strcmp (string, "FULL") == 0)
52 {
53 result = fullSize;
54 }
55 else
56 {
57 result = strtol (string, (char **)0, 0);
58 }
59 return result;
60 }
61
62 /*
63 * Parse the string as one of CDK's positioning keywords, or an actual
64 * position.
65 */
66 int CDKparsePosition (char *string)
67 {
68 int result;
69
70 if (string == 0)
71 {
72 result = NONE;
73 }
74 else if (strcmp (string, "TOP") == 0)
75 {
76 result = TOP;
77 }
78 else if (strcmp (string, "BOTTOM") == 0)
79 {
80 result = BOTTOM;
81 }
82 else if (strcmp (string, "LEFT") == 0)
83 {
84 result = LEFT;
85 }
86 else if (strcmp (string, "RIGHT") == 0)
87 {
88 result = RIGHT;
89 }
90 else if (strcmp (string, "CENTER") == 0)
91 {
92 result = CENTER;
93 }
94 else
95 {
96 result = strtol (string, (char **)0, 0);
97 }
98 return result;
99 }
100
101 /*
102 * Parse the given argc/argv command-line, with the options passed to
103 * getopt()'s 3rd parameter.
104 */
105 void CDKparseParams (int argc,
106 char **argv,
107 CDK_PARAMS * params,
108 char *options)
109 {
110 int code;
111 char *str;
112
113 memset (params, 0, sizeof (*params));
114 params->Box = TRUE;
115
116 while ((code = getopt (argc, argv, options)) != EOF)
117 {
118 if (code == '?' || (str = strchr (options, code)) == 0)
119 {
120 usage (argv, params, options);
121 }
122 else
123 {
124 params->allParams[code] = OPTION_ON;
125 if (str[1] == ':')
126 {
127 params->allParams[code] = optarg;
128 }
129 switch (code)
130 {
131 case 'W':
132 params->wValue = CDKparseSize (optarg, FULL);
133 break;
134
135 case 'H':
136 params->hValue = CDKparseSize (optarg, FULL);
137 break;
138
139 case 'X':
140 params->xValue = CDKparsePosition (optarg);
141 break;
142
143 case 'Y':
144 params->yValue = CDKparsePosition (optarg);
145 break;
146
147 case 'N':
148 params->Box = FALSE;
149 break;
150
151 case 'S':
152 params->Shadow = TRUE;
153 break;
154 }
155 }
156 }
157 }
158
159 /*
160 * Retrieve a numeric option-value, default=0.
161 */
162 int CDKparamNumber (CDK_PARAMS * params, int option)
163 {
164 return CDKparamNumber2 (params, option, 0);
165 }
166
167 /*
168 * Retrieve a numeric option-value, given default.
169 */
170 int CDKparamNumber2 (CDK_PARAMS * params, int option, int missing)
171 {
172 return CDKparamValue (params, option, missing);
173 }
174
175 /*
176 * Retrieve the string value of an option, default=0.
177 */
178 char *CDKparamString (CDK_PARAMS * params, int option)
179 {
180 return CDKparamString2 (params, option, 0);
181 }
182
183 /*
184 * Retrieve the string value of an option, with default for missing value.
185 */
186 char *CDKparamString2 (CDK_PARAMS * params, int option, char *missing)
187 {
188 char *value = ((option > 0 && option < MAX_CDK_PARAMS)
189 ? params->allParams[option]
190 : 0);
191 if (value == 0)
192 value = missing;
193 return value;
194 }
195
196 /*
197 * Retrieve an integer (or boolean) option value from the parsed command-line.
198 * (prefer: CDKparamNumber).
199 */
200 int CDKparamValue (CDK_PARAMS * params, int option, int missing)
201 {
202 int result;
203 char *value = CDKparamString (params, option);
204
205 if (value == 0)
206 {
207 result = missing;
208 }
209 else if (strchr (CDK_CLI_PARAMS, option) != 0)
210 {
211 switch (option)
212 {
213 case 'H':
214 result = params->hValue;
215 break;
216 case 'W':
217 result = params->wValue;
218 break;
219 case 'X':
220 result = params->xValue;
221 break;
222 case 'Y':
223 result = params->yValue;
224 break;
225 case 'N':
226 result = params->Box;
227 break;
228 case 'S':
229 result = params->Shadow;
230 break;
231 default:
232 result = missing;
233 break;
234 }
235 }
236 else if (value == OPTION_ON)
237 {
238 result = 1;
239 }
240 else
241 {
242 result = strtol (value, (char **)0, 0);
243 }
244
245 return result;
246 }
0 #include <cdk_int.h>
1
2 #ifdef HAVE_SETLOCALE
3 #include <locale.h>
4 #endif
5
6 /*
7 * $Author: tom $
8 * $Date: 2005/12/29 20:51:17 $
9 * $Revision: 1.87 $
10 */
11
12 typedef struct _all_screens
13 {
14 struct _all_screens *link;
15 CDKSCREEN *screen;
16 }
17 ALL_SCREENS;
18
19 static ALL_SCREENS *all_screens;
20
21 typedef struct _all_objects
22 {
23 struct _all_objects *link;
24 CDKOBJS *object;
25 }
26 ALL_OBJECTS;
27
28 static ALL_OBJECTS *all_objects;
29
30 static boolean validObjType (CDKOBJS *obj, EObjectType type)
31 {
32 bool valid = FALSE;
33
34 if (obj != 0 && ObjTypeOf (obj) == type)
35 {
36 switch (type)
37 {
38 case vALPHALIST:
39 case vBUTTON:
40 case vBUTTONBOX:
41 case vCALENDAR:
42 case vDIALOG:
43 case vDSCALE:
44 case vENTRY:
45 case vFSCALE:
46 case vFSELECT:
47 case vFSLIDER:
48 case vGRAPH:
49 case vHISTOGRAM:
50 case vITEMLIST:
51 case vLABEL:
52 case vMARQUEE:
53 case vMATRIX:
54 case vMENTRY:
55 case vMENU:
56 case vRADIO:
57 case vSCALE:
58 case vSCROLL:
59 case vSELECTION:
60 case vSLIDER:
61 case vSWINDOW:
62 case vTEMPLATE:
63 case vUSCALE:
64 case vUSLIDER:
65 case vVIEWER:
66 valid = TRUE;
67 break;
68 case vTRAVERSE: /* not really an object */
69 case vNULL:
70 break;
71 }
72 }
73 return valid;
74 }
75
76 /*
77 * Set indices so the screen and object point to each other.
78 */
79 static void setScreenIndex (CDKSCREEN *screen, int number, CDKOBJS *obj)
80 {
81 (obj)->screenIndex = number;
82 (obj)->screen = screen;
83 screen->object[number] = obj;
84 }
85
86 /*
87 * Returns true if we have done a "new" on this object but no "destroy"
88 */
89 bool validCDKObject (CDKOBJS *obj)
90 {
91 bool result = FALSE;
92 if (obj != 0)
93 {
94 ALL_OBJECTS *ptr;
95
96 for (ptr = all_objects; ptr != 0; ptr = ptr->link)
97 {
98 if (ptr->object == obj)
99 {
100 result = validObjType (obj, ObjTypeOf (obj));
101 break;
102 }
103 }
104 }
105 return result;
106 }
107
108 /*
109 * Create a new object beginning with a CDKOBJS struct. The whole object is
110 * initialized to zeroes except for special cases which have known values.
111 */
112 void *_newCDKObject (unsigned size, const CDKFUNCS * funcs)
113 {
114 ALL_OBJECTS *item;
115 CDKOBJS *result = 0;
116 if ((item = typeCalloc (ALL_OBJECTS)) != 0)
117 {
118 if ((result = (CDKOBJS *)calloc (1, size)) != 0)
119 {
120 result->fn = funcs;
121 result->hasFocus = TRUE;
122 result->isVisible = TRUE;
123
124 item->link = all_objects;
125 item->object = result;
126 all_objects = item;
127
128 /* set default line-drawing characters */
129 result->ULChar = ACS_ULCORNER;
130 result->URChar = ACS_URCORNER;
131 result->LLChar = ACS_LLCORNER;
132 result->LRChar = ACS_LRCORNER;
133 result->HZChar = ACS_HLINE;
134 result->VTChar = ACS_VLINE;
135 result->BXAttr = A_NORMAL;
136
137 /* set default exit-types */
138 result->exitType = vNEVER_ACTIVATED;
139 result->earlyExit = vNEVER_ACTIVATED;
140 }
141 else
142 {
143 free (item);
144 }
145 }
146 return (void *)result;
147 }
148
149 void _destroyCDKObject (CDKOBJS *obj)
150 {
151 ALL_OBJECTS *p, *q;
152
153 if (validCDKObject (obj))
154 {
155 for (p = all_objects, q = 0; p != 0; q = p, p = p->link)
156 {
157 if (p->object == obj)
158 {
159 /* delink it first, to avoid problems with recursion */
160 if (q != 0)
161 q->link = p->link;
162 else
163 all_objects = p->link;
164
165 MethodPtr (obj, destroyObj) (obj);
166 free (obj);
167 free (p);
168 break;
169 }
170 }
171 }
172 }
173
174 /*
175 * This creates a new CDK screen.
176 */
177 CDKSCREEN *initCDKScreen (WINDOW *window)
178 {
179 ALL_SCREENS *item;
180 CDKSCREEN *screen = 0;
181
182 /* initialization, for the first time */
183 if (all_screens == 0)
184 {
185 /* Set up basic curses settings. */
186 #ifdef HAVE_SETLOCALE
187 setlocale (LC_ALL, "");
188 #endif
189 noecho ();
190 cbreak ();
191 }
192
193 if ((item = typeMalloc (ALL_SCREENS)) != 0)
194 {
195 if ((screen = typeCalloc (CDKSCREEN)) != 0)
196 {
197 item->link = all_screens;
198 item->screen = screen;
199 all_screens = item;
200
201 /* Initialize the CDKSCREEN pointer. */
202 screen->objectCount = 0;
203 screen->objectLimit = 2;
204 screen->object = typeMallocN (CDKOBJS *, screen->objectLimit);
205 screen->window = window;
206
207 /* OK, we are done. */
208 }
209 else
210 {
211 free (item);
212 }
213 }
214 return (screen);
215 }
216
217 /*
218 * This registers a CDK object with a screen.
219 */
220 void registerCDKObject (CDKSCREEN *screen, EObjectType cdktype, void *object)
221 {
222 CDKOBJS *obj = (CDKOBJS *)object;
223
224 if (screen->objectCount + 1 >= screen->objectLimit)
225 {
226 screen->objectLimit += 2;
227 screen->objectLimit *= 2;
228 screen->object = typeReallocN (CDKOBJS *, screen->object, screen->objectLimit);
229 }
230 if (validObjType (obj, cdktype))
231 {
232 setScreenIndex (screen, screen->objectCount++, obj);
233 }
234 }
235
236 /*
237 * This removes an object from the CDK screen.
238 */
239 void unregisterCDKObject (EObjectType cdktype, void *object)
240 {
241 CDKOBJS *obj = (CDKOBJS *)object;
242
243 if (validObjType (obj, cdktype) && obj->screenIndex >= 0)
244 {
245 CDKSCREEN *screen = (obj)->screen;
246 int Index, x;
247
248 if (screen != 0)
249 {
250 Index = (obj)->screenIndex;
251 obj->screenIndex = -1;
252
253 /*
254 * Resequence the objects.
255 */
256 for (x = Index; x < screen->objectCount - 1; x++)
257 {
258 setScreenIndex (screen, x, screen->object[x + 1]);
259 }
260
261 if (screen->objectCount <= 1)
262 {
263 /* if no more objects, remove the array */
264 freeAndNull (screen->object);
265 screen->objectCount = 0;
266 screen->objectLimit = 0;
267 }
268 else
269 {
270 /* Reduce the list by one object. */
271 screen->object[screen->objectCount--] = 0;
272
273 /*
274 * Update the object-focus
275 */
276 if (screen->objectFocus == Index)
277 {
278 screen->objectFocus--;
279 (void)setCDKFocusNext (screen);
280 }
281 else if (screen->objectFocus > Index)
282 {
283 screen->objectFocus--;
284 }
285 }
286 }
287 }
288 }
289
290 #define validIndex(screen, n) ((n) >= 0 && (n) < (screen)->objectCount)
291
292 static void swapCDKIndices (CDKSCREEN *screen, int n1, int n2)
293 {
294 if (n1 != n2 && validIndex (screen, n1) && validIndex (screen, n2))
295 {
296 CDKOBJS *o1 = screen->object[n1];
297 CDKOBJS *o2 = screen->object[n2];
298 setScreenIndex (screen, n1, o2);
299 setScreenIndex (screen, n2, o1);
300
301 if (screen->objectFocus == n1)
302 screen->objectFocus = n2;
303 else if (screen->objectFocus == n2)
304 screen->objectFocus = n1;
305 }
306 }
307
308 /*
309 * This 'brings' a CDK object to the top of the stack.
310 */
311 void raiseCDKObject (EObjectType cdktype, void *object)
312 {
313 CDKOBJS *obj = (CDKOBJS *)object;
314
315 if (validObjType (obj, cdktype))
316 {
317 CDKSCREEN *screen = obj->screen;
318 swapCDKIndices (screen, obj->screenIndex, screen->objectCount - 1);
319 }
320 }
321
322 /*
323 * This 'lowers' an object.
324 */
325 void lowerCDKObject (EObjectType cdktype, void *object)
326 {
327 CDKOBJS *obj = (CDKOBJS *)object;
328
329 if (validObjType (obj, cdktype))
330 {
331 CDKSCREEN *screen = obj->screen;
332 swapCDKIndices (screen, obj->screenIndex, 0);
333 }
334 }
335
336 /*
337 * This calls refreshCDKScreen. (made consistent with widgets)
338 */
339 void drawCDKScreen (CDKSCREEN *cdkscreen)
340 {
341 refreshCDKScreen (cdkscreen);
342 }
343
344 /*
345 * Refresh one CDK window.
346 * FIXME: this should be rewritten to use the panel library, so it would not
347 * be necessary to touch the window to ensure that it covers other windows.
348 */
349 void refreshCDKWindow (WINDOW *win)
350 {
351 touchwin (win);
352 wrefresh (win);
353 }
354
355 /*
356 * This refreshes all the objects in the screen.
357 */
358 void refreshCDKScreen (CDKSCREEN *cdkscreen)
359 {
360 int objectCount = cdkscreen->objectCount;
361 int x;
362 int focused = -1;
363 int visible = -1;
364
365 refreshCDKWindow (cdkscreen->window);
366
367 /* We erase all the invisible objects, then only
368 * draw it all back, so that the objects
369 * can overlap, and the visible ones will always
370 * be drawn after all the invisible ones are erased */
371 for (x = 0; x < objectCount; x++)
372 {
373 CDKOBJS *obj = cdkscreen->object[x];
374
375 if (validObjType (obj, ObjTypeOf (obj)))
376 {
377 if (obj->isVisible)
378 {
379 if (visible < 0)
380 visible = x;
381 if (obj->hasFocus && focused < 0)
382 focused = x;
383 }
384 else
385 {
386 obj->fn->eraseObj (obj);
387 }
388 }
389 }
390
391 /*
392 * Exactly one widget should have focus, and it should be visible.
393 */
394 if (focused < 0)
395 focused = visible;
396
397 for (x = 0; x < objectCount; x++)
398 {
399 CDKOBJS *obj = cdkscreen->object[x];
400
401 if (validObjType (obj, ObjTypeOf (obj)))
402 {
403 obj->hasFocus = (x == focused);
404
405 if (obj->isVisible)
406 {
407 obj->fn->drawObj (obj, obj->box);
408 }
409 }
410 }
411 }
412
413 /*
414 * This clears all the objects in the screen.
415 */
416 void eraseCDKScreen (CDKSCREEN *cdkscreen)
417 {
418 int objectCount = cdkscreen->objectCount;
419 int x;
420
421 /* We just call the drawObject function. */
422 for (x = 0; x < objectCount; x++)
423 {
424 CDKOBJS *obj = cdkscreen->object[x];
425
426 if (validObjType (obj, ObjTypeOf (obj)))
427 {
428 obj->fn->eraseObj (obj);
429 }
430 }
431
432 /* Refresh the screen. */
433 wrefresh (cdkscreen->window);
434 }
435
436 /*
437 * Destroy all of the objects on a screen
438 */
439 void destroyCDKScreenObjects (CDKSCREEN *cdkscreen)
440 {
441 int x;
442
443 for (x = 0; x < cdkscreen->objectCount; x++)
444 {
445 CDKOBJS *obj = cdkscreen->object[x];
446 int before = cdkscreen->objectCount;
447
448 if (validObjType (obj, ObjTypeOf (obj)))
449 {
450 MethodPtr (obj, eraseObj) (obj);
451 _destroyCDKObject (obj);
452 x -= (cdkscreen->objectCount - before);
453 }
454 }
455 }
456
457 /*
458 * This destroys a CDK screen.
459 */
460 void destroyCDKScreen (CDKSCREEN *screen)
461 {
462 ALL_SCREENS *p, *q;
463
464 for (p = all_screens, q = 0; p != 0; q = p, p = p->link)
465 {
466 if (screen == p->screen)
467 {
468 if (q != 0)
469 q->link = p->link;
470 else
471 all_screens = p->link;
472 free (p);
473 free (screen);
474 break;
475 }
476 }
477 }
478
479 /*
480 * This is added to remain consistent.
481 */
482 void endCDK (void)
483 {
484 /* Turn echoing back on. */
485 echo ();
486
487 /* Turn off cbreak. */
488 nocbreak ();
489
490 /* End the curses windows. */
491 endwin ();
492
493 #ifdef HAVE_XCURSES
494 XCursesExit ();
495 #endif
496 }
0 # $Id: Makefile.in,v 1.4 2003/11/27 12:03:41 tom Exp $
1 #
2 # Makefile for the cli directory.
3 #
4 SHELL = /bin/sh
5
6 prefix = @prefix@
7 exec_prefix = @exec_prefix@
8
9 srcdir = @srcdir@
10 VPATH = $(srcdir)
11
12 CC = @CC@
13 RM = rm -f
14
15 LIBS = -l@LIB_ROOTNAME@ @LIBS@
16
17 LIBTOOL = @LIBTOOL@ @ECHO_LT@
18 LIBTOOL_CLEAN = @LIB_CLEAN@
19 LIBTOOL_LINK = @LIB_LINK@
20 LINK = $(LIBTOOL_LINK) $(CC)
21
22 x = @EXEEXT@
23 o = .@OBJEXT@
24
25 CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@
26 CPPFLAGS = @DEFS@ -I../include -I$(srcdir)/../include -I. @CPPFLAGS@
27 LDFLAGS = -L.. @LDFLAGS@
28
29 BINS = \
30 cdkalphalist$x \
31 cdkcalendar$x \
32 cdkdialog$x \
33 cdkentry$x \
34 cdkfselect$x \
35 cdkitemlist$x \
36 cdklabel$x \
37 cdkmatrix$x \
38 cdkmentry$x \
39 cdkradio$x \
40 cdkscale$x \
41 cdkscroll$x \
42 cdkselection$x \
43 cdkslider$x \
44 cdktemplate$x \
45 cdkviewer$x
46
47 LINKIT = @ECHO_LD@$(LINK) $(CFLAGS) $(CPPFLAGS) $? -o $@ $(LDFLAGS) $(LIBS)
48
49 all : $(BINS)
50
51 cdkalphalist$x : cdkalphalist.c ; $(LINKIT)
52 cdkcalendar$x : cdkcalendar.c ; $(LINKIT)
53 cdkdialog$x : cdkdialog.c ; $(LINKIT)
54 cdkentry$x : cdkentry.c ; $(LINKIT)
55 cdkfselect$x : cdkfselect.c ; $(LINKIT)
56 cdkitemlist$x : cdkitemlist.c ; $(LINKIT)
57 cdklabel$x : cdklabel.c ; $(LINKIT)
58 cdkmatrix$x : cdkmatrix.c ; $(LINKIT)
59 cdkmentry$x : cdkmentry.c ; $(LINKIT)
60 cdkradio$x : cdkradio.c ; $(LINKIT)
61 cdkscale$x : cdkscale.c ; $(LINKIT)
62 cdkscroll$x : cdkscroll.c ; $(LINKIT)
63 cdkselection$x : cdkselection.c ; $(LINKIT)
64 cdkslider$x : cdkslider.c ; $(LINKIT)
65 cdktemplate$x : cdktemplate.c ; $(LINKIT)
66 cdkviewer$x : cdkviewer.c ; $(LINKIT)
67 #
68 # Standard clean directives.
69 #
70 clean::
71 - $(LIBTOOL_CLEAN) $(RM) *.o core $(BINS)
72
73 distclean:: clean
74 $(RM) Makefile
0 /* $Id: cdkalphalist.c,v 1.12 2005/12/27 17:26:08 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdkalphalist";
6 #endif
7
8 /*
9 * Declare file local prototypes.
10 */
11 int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
12
13 /*
14 * Define file local variables.
15 */
16 static char *FPUsage = "-l List | -f filename [-F Field Character] [-T Title] [-L Label] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-H Height] [-W Width] [-N] [-S]";
17
18 /*
19 *
20 */
21 int main (int argc, char **argv)
22 {
23 /* Declare variables. */
24 CDKSCREEN *cdkScreen = 0;
25 CDKALPHALIST *widget = 0;
26 CDKBUTTONBOX *buttonWidget = 0;
27 WINDOW *cursesWindow = 0;
28 char *CDK_WIDGET_COLOR = 0;
29 char *answer = 0;
30 char *buttons;
31 char *temp = 0;
32 chtype *holder = 0;
33 chtype filler = A_NORMAL | '.';
34 int scrollLines = -1;
35 int buttonCount = 0;
36 int selection = 0;
37 int shadowHeight = 0;
38 FILE *fp = stderr;
39 char **scrollList = 0;
40 char **buttonList = 0;
41 int j1, j2;
42
43 CDK_PARAMS params;
44 boolean boxWidget;
45 boolean shadowWidget;
46 char *filename;
47 char *label;
48 char *list;
49 char *outputFile;
50 char *tempFiller;
51 char *title;
52 int height;
53 int width;
54 int xpos;
55 int ypos;
56
57 CDKparseParams(argc, argv, &params, "f:l:B:F:L:O:T:" CDK_CLI_PARAMS);
58
59 xpos = CDKparamValue(&params, 'X', CENTER);
60 ypos = CDKparamValue(&params, 'Y', CENTER);
61 height = CDKparamValue(&params, 'H', -1);
62 width = CDKparamValue(&params, 'W', -1);
63 boxWidget = CDKparamValue(&params, 'N', TRUE);
64 shadowWidget = CDKparamValue(&params, 'S', FALSE);
65
66 filename = CDKparamString(&params, 'f');
67 list = CDKparamString(&params, 'l');
68 buttons = CDKparamString(&params, 'B');
69 tempFiller = CDKparamString(&params, 'F');
70 label = CDKparamString(&params, 'L');
71 outputFile = CDKparamString(&params, 'O');
72 title = CDKparamString(&params, 'T');
73
74 /* If the user asked for an output file, try to open it. */
75 if (outputFile != 0)
76 {
77 if ((fp = fopen (outputFile, "w")) == 0)
78 {
79 fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
80 ExitProgram (CLI_ERROR);
81 }
82 }
83
84 /* Did they provide a list of items. */
85 if (list == 0)
86 {
87 /* Maybe they gave a filename to use to read. */
88 if (filename != 0)
89 {
90 /* Read the file in. */
91 scrollLines = CDKreadFile (filename, &scrollList);
92
93 /* Check if there was an error. */
94 if (scrollLines == -1)
95 {
96 fprintf (stderr, "Error: Could not open the file '%s'.\n", filename);
97 ExitProgram (CLI_ERROR);
98 }
99 }
100 else
101 {
102 /* They didn't provide anything. */
103 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
104 ExitProgram (CLI_ERROR);
105 }
106 }
107 else
108 {
109 /* Split the scroll lines up. */
110 scrollList = CDKsplitString (list, '\n');
111 scrollLines = CDKcountStrings (scrollList);
112 }
113
114 /* Start curses. */
115 cursesWindow = initscr();
116
117 /* Create the CDK screen. */
118 cdkScreen = initCDKScreen (cursesWindow);
119
120 /* Start color. */
121 initCDKColor();
122
123 /* Check if the user wants to set the background of the main screen. */
124 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
125 {
126 holder = char2Chtype (temp, &j1, &j2);
127 wbkgd (cdkScreen->window, holder[0]);
128 wrefresh (cdkScreen->window);
129 freeChtype (holder);
130 }
131
132 /* Get the widget color background color. */
133 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
134 {
135 CDK_WIDGET_COLOR = 0;
136 }
137
138 /* If they set the filler character, set it now. */
139 if (tempFiller != 0)
140 {
141 holder = char2Chtype (tempFiller, &j1, &j2);
142 filler = holder[0];
143 freeChtype (holder);
144 }
145
146 /* Create the widget. */
147 widget = newCDKAlphalist (cdkScreen, xpos, ypos,
148 height, width,
149 title, label,
150 scrollList, scrollLines,
151 filler, A_REVERSE,
152 boxWidget, shadowWidget);
153
154 /* Make sure we could create the widget. */
155 if (widget == 0)
156 {
157 CDKfreeStrings(scrollList);
158 destroyCDKScreen (cdkScreen);
159 endCDK();
160
161 fprintf (stderr, "Error: Could not create the alphalist. Is the window too small?\n");
162
163 ExitProgram (CLI_ERROR);
164 }
165
166 /* Split the buttons if they supplied some. */
167 if (buttons != 0)
168 {
169 buttonList = CDKsplitString (buttons, '\n');
170 buttonCount = CDKcountStrings (buttonList);
171
172 buttonWidget = newCDKButtonbox (cdkScreen,
173 getbegx (widget->win) + 1,
174 getbegy (widget->win) + widget->boxHeight - 1,
175 1, widget->boxWidth - 3,
176 0, 1, buttonCount,
177 buttonList, buttonCount,
178 A_REVERSE, boxWidget, FALSE);
179 CDKfreeStrings(buttonList);
180
181 setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
182 setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
183
184 /*
185 * We need to set the lower left and right
186 * characters of the entry field.
187 */
188 setCDKAlphalistLLChar (widget, ACS_LTEE);
189 setCDKAlphalistLRChar (widget, ACS_RTEE);
190
191 /*
192 * Bind the Tab key in the entry field to send a
193 * Tab key to the button box widget.
194 */
195 bindCDKObject (vENTRY, widget->entryField, KEY_RIGHT, widgetCB, buttonWidget);
196 bindCDKObject (vENTRY, widget->entryField, KEY_LEFT, widgetCB, buttonWidget);
197 bindCDKObject (vENTRY, widget->entryField, CDK_NEXT, widgetCB, buttonWidget);
198 bindCDKObject (vENTRY, widget->entryField, CDK_PREV, widgetCB, buttonWidget);
199
200 setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
201
202 drawCDKButtonbox (buttonWidget, boxWidget);
203 }
204
205 /*
206 * If the user asked for a shadow, we need to create one. Do this instead
207 * of using the shadow parameter because the button widget is not part of
208 * the main widget and if the user asks for both buttons and a shadow, we
209 * need to create a shadow big enough for both widgets. Create the shadow
210 * window using the widgets shadowWin element, so screen refreshes will draw
211 * them as well.
212 */
213 if (shadowWidget == TRUE)
214 {
215 /* Determine the height of the shadow window. */
216 shadowHeight = (buttonWidget == 0 ?
217 widget->boxHeight :
218 widget->boxHeight + buttonWidget->boxHeight - 1);
219
220 /* Create the shadow window. */
221 widget->shadowWin = newwin (shadowHeight,
222 widget->boxWidth,
223 getbegy (widget->win) + 1,
224 getbegx (widget->win) + 1);
225
226 /* Make sure we could have created the shadow window. */
227 if (widget->shadowWin != 0)
228 {
229 widget->shadow = TRUE;
230
231 /*
232 * We force the widget and buttonWidget to be drawn so the
233 * buttonbox widget will be drawn when the widget is activated.
234 * Otherwise the shadow window will draw over the button widget.
235 */
236 drawCDKAlphalist (widget, ObjOf(widget)->box);
237 eraseCDKButtonbox (buttonWidget);
238 drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
239 }
240 }
241
242 /* Check if the user wants to set the background of the widget. */
243 setCDKAlphalistBackgroundColor (widget, CDK_WIDGET_COLOR);
244
245 /* Activate the widget. */
246 answer = copyChar (activateCDKAlphalist (widget, 0));
247
248 /* If there were buttons, get the button selected. */
249 if (buttonWidget != 0)
250 {
251 selection = buttonWidget->currentButton;
252 destroyCDKButtonbox (buttonWidget);
253 }
254
255 CDKfreeStrings(scrollList);
256
257 destroyCDKAlphalist (widget);
258 destroyCDKScreen (cdkScreen);
259 endCDK();
260
261 /* Print out the answer. */
262 if (answer != 0)
263 {
264 fprintf (fp, "%s\n", answer);
265 freeChar (answer);
266 }
267
268 /* Exit with the selected button. */
269 ExitProgram (0);
270 }
271
272 int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
273 {
274 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
275 injectCDKButtonbox (buttonbox, key);
276 return (TRUE);
277 }
0 /* $Id: cdkcalendar.c,v 1.11 2005/12/27 16:11:09 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdkcalendar";
6 #endif
7
8 /*
9 * Declare file local prototypes.
10 */
11 static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
12
13 /*
14 * Define file local variables.
15 */
16 static void getTodaysDate (int *day, int *month, int *year);
17
18 int main (int argc, char **argv)
19 {
20 /* Declare variables. */
21 CDKSCREEN *cdkScreen = 0;
22 CDKCALENDAR *widget = 0;
23 CDKBUTTONBOX *buttonWidget = 0;
24 WINDOW *cursesWindow = 0;
25 struct tm *dateInfo = 0;
26 time_t selected = 0;
27 chtype dayAttrib = A_NORMAL;
28 chtype monthAttrib = A_NORMAL;
29 chtype yearAttrib = A_NORMAL;
30 chtype highlight = A_REVERSE;
31 chtype *holder = 0;
32 char *CDK_WIDGET_COLOR = 0;
33 char *temp = 0;
34 int buttonCount = 0;
35 int selection = 0;
36 int shadowHeight = 0;
37 FILE *fp = stderr;
38 char **buttonList = 0;
39 int j1, j2;
40
41 CDK_PARAMS params;
42 boolean boxWidget;
43 boolean shadowWidget;
44 char *buttons;
45 char *outputFile;
46 char *title;
47 int day;
48 int month;
49 int xpos;
50 int year;
51 int ypos;
52
53 getTodaysDate (&day, &month, &year);
54
55 CDKparseParams(argc, argv, &params, "d:m:y:B:O:T:X:Y:NS");
56
57 xpos = CDKparamValue(&params, 'X', CENTER);
58 ypos = CDKparamValue(&params, 'Y', CENTER);
59 boxWidget = CDKparamValue(&params, 'N', TRUE);
60 shadowWidget = CDKparamValue(&params, 'S', FALSE);
61
62 day = CDKparamValue(&params, 'd', day);
63 month = CDKparamValue(&params, 'm', month);
64 year = CDKparamValue(&params, 'y', year);
65 buttons = CDKparamString(&params, 'B');
66 outputFile = CDKparamString(&params, 'O');
67 title = CDKparamString(&params, 'T');
68
69 /* If the user asked for an output file, try to open it. */
70 if (outputFile != 0)
71 {
72 if ((fp = fopen (outputFile, "w")) == 0)
73 {
74 fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
75 ExitProgram (CLI_ERROR);
76 }
77 }
78
79 /* Set up CDK. */
80 cursesWindow = initscr();
81 cdkScreen = initCDKScreen (cursesWindow);
82
83 /* Start color. */
84 initCDKColor();
85
86 /* Check if the user wants to set the background of the main screen. */
87 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
88 {
89 holder = char2Chtype (temp, &j1, &j2);
90 wbkgd (cdkScreen->window, holder[0]);
91 wrefresh (cdkScreen->window);
92 freeChtype (holder);
93 }
94
95 /* Check if the user wants to set the background of the widget. */
96 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
97 {
98 CDK_WIDGET_COLOR = 0;
99 }
100
101 /* Create the calendar width. */
102 widget = newCDKCalendar (cdkScreen, xpos, ypos, title,
103 day, month, year,
104 dayAttrib, monthAttrib,
105 yearAttrib, highlight,
106 boxWidget, shadowWidget);
107 /* Check to make sure we created the dialog box. */
108 if (widget == 0)
109 {
110 destroyCDKScreen (cdkScreen);
111 endCDK();
112
113 fprintf (stderr, "Error: Could not create the calendar. Is the window too small?\n");
114
115 ExitProgram (CLI_ERROR);
116 }
117
118 /* Split the buttons if they supplied some. */
119 if (buttons != 0)
120 {
121 /* Split the button list up. */
122 buttonList = CDKsplitString (buttons, '\n');
123 buttonCount = CDKcountStrings (buttonList);
124
125 /* We need to create a buttonbox widget. */
126 buttonWidget = newCDKButtonbox (cdkScreen,
127 getbegx (widget->win),
128 getbegy (widget->win) + widget->boxHeight - 1,
129 1, widget->boxWidth - 1,
130 0, 1, buttonCount,
131 buttonList, buttonCount,
132 A_REVERSE, boxWidget, FALSE);
133 setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
134 setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
135
136 /*
137 * We need to set the lower left and right
138 * characters of the widget.
139 */
140 setCDKCalendarLLChar (widget, ACS_LTEE);
141 setCDKCalendarLRChar (widget, ACS_RTEE);
142
143 /*
144 * Bind the Tab key in the widget to send a
145 * Tab key to the button box widget.
146 */
147 bindCDKObject (vCALENDAR, widget, KEY_TAB, widgetCB, buttonWidget);
148 bindCDKObject (vCALENDAR, widget, CDK_PREV, widgetCB, buttonWidget);
149 bindCDKObject (vCALENDAR, widget, CDK_NEXT, widgetCB, buttonWidget);
150
151 /* Check if the user wants to set the background of the widget. */
152 setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
153
154 /* Draw the button widget. */
155 drawCDKButtonbox (buttonWidget, boxWidget);
156 }
157
158 /*
159 * If the user asked for a shadow, we need to create one. Do this instead
160 * of using the shadow parameter because the button widget is not part of
161 * the main widget and if the user asks for both buttons and a shadow, we
162 * need to create a shadow big enough for both widgets. Create the shadow
163 * window using the widgets shadowWin element, so screen refreshes will draw
164 * them as well.
165 */
166 if (shadowWidget == TRUE)
167 {
168 /* Determine the height of the shadow window. */
169 shadowHeight = (buttonWidget == 0 ?
170 widget->boxHeight :
171 widget->boxHeight + buttonWidget->boxHeight - 1);
172
173 /* Create the shadow window. */
174 widget->shadowWin = newwin (shadowHeight,
175 widget->boxWidth,
176 getbegy (widget->win) + 1,
177 getbegx (widget->win) + 1);
178
179 /* Make sure we could have created the shadow window. */
180 if (widget->shadowWin != 0)
181 {
182 widget->shadow = TRUE;
183
184 /*
185 * We force the widget and buttonWidget to be drawn so the
186 * buttonbox widget will be drawn when the widget is activated.
187 * Otherwise the shadow window will draw over the button widget.
188 */
189 drawCDKCalendar (widget, ObjOf(widget)->box);
190 eraseCDKButtonbox (buttonWidget);
191 drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
192 }
193 }
194
195 /* Check if the user wants to set the background of the widget. */
196 setCDKCalendarBackgroundColor (widget, CDK_WIDGET_COLOR);
197
198 /* Activate the calendar widget. */
199 selected = activateCDKCalendar (widget, 0);
200
201 /* If there were buttons, get the button selected. */
202 if (buttonWidget != 0)
203 {
204 selection = buttonWidget->currentButton;
205 destroyCDKButtonbox (buttonWidget);
206 }
207
208 CDKfreeStrings(buttonList);
209
210 destroyCDKCalendar (widget);
211 destroyCDKScreen (cdkScreen);
212 endCDK();
213
214 /* Print out the date selected. D/M/Y format. */
215 dateInfo = localtime (&selected);
216 fprintf (fp, "%02d/%02d/%d\n", dateInfo->tm_mday, (dateInfo->tm_mon+1), (dateInfo->tm_year+1900));
217 fclose (fp);
218
219 ExitProgram (selection);
220 }
221
222 /*
223 * This returns what day of the week the month starts on.
224 */
225 static void getTodaysDate (int *day, int *month, int *year)
226 {
227 struct tm *dateInfo;
228 time_t clck;
229
230 /* Determine the current time and determine if we are in DST. */
231 time (&clck);
232 dateInfo = localtime (&clck);
233
234 /* Set the pointers accordingly. */
235 (*day) = dateInfo->tm_mday;
236 (*month) = dateInfo->tm_mon + 1;
237 (*year) = dateInfo->tm_year + 1900;
238 }
239
240 static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
241 {
242 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
243 injectCDKButtonbox (buttonbox, key);
244 return (TRUE);
245 }
0 /* $Id: cdkdialog.c,v 1.9 2005/12/27 16:15:34 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdkdialog";
6 #endif
7
8 /*
9 * Define file local variables.
10 */
11 static char *FPUsage = "-m Message String | -f filename [-B Buttons] [-O Output file] [-X X Position] [-Y Y Position] [-N] [-S]";
12
13 /*
14 *
15 */
16 int main (int argc, char **argv)
17 {
18 /* Declare variables. */
19 CDKSCREEN *cdkScreen = 0;
20 CDKDIALOG *widget = 0;
21 WINDOW *cursesWindow = 0;
22 char *CDK_WIDGET_COLOR = 0;
23 char *button = 0;
24 char *temp = 0;
25 chtype *holder = 0;
26 int answer = 0;
27 int messageLines = -1;
28 int buttonCount = 0;
29 FILE *fp = stderr;
30 char **messageList = 0;
31 char **buttonList = 0;
32 int j1, j2;
33
34 CDK_PARAMS params;
35 boolean boxWidget;
36 boolean shadowWidget;
37 char *buttons;
38 char *filename;
39 char *outputFile;
40 char *message;
41 int xpos;
42 int ypos;
43
44 CDKparseParams(argc, argv, &params, "f:m:B:O:" "X:Y:NS");
45
46 xpos = CDKparamValue(&params, 'X', CENTER);
47 ypos = CDKparamValue(&params, 'Y', CENTER);
48 boxWidget = CDKparamValue(&params, 'N', TRUE);
49 shadowWidget = CDKparamValue(&params, 'S', FALSE);
50
51 filename = CDKparamString(&params, 'f');
52 message = CDKparamString(&params, 'm');
53 buttons = CDKparamString(&params, 'B');
54 outputFile = CDKparamString(&params, 'O');
55
56 /* If the user asked for an output file, try to open it. */
57 if (outputFile != 0)
58 {
59 if ((fp = fopen (outputFile, "w")) == 0)
60 {
61 fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
62 ExitProgram (CLI_ERROR);
63 }
64 }
65
66 /* Make sure we have a message to display. */
67 if (message == 0)
68 {
69 /* No message, maybe they provided a file to read. */
70 if (filename != 0)
71 {
72 /* Read the file in. */
73 messageLines = CDKreadFile (filename, &messageList);
74
75 /* Check if there was an error. */
76 if (messageLines == -1)
77 {
78 fprintf (stderr, "Error: Could not open the file %s\n", filename);
79 ExitProgram (CLI_ERROR);
80 }
81 }
82 else
83 {
84 /* No message, no file, it's an error. */
85 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
86 ExitProgram (CLI_ERROR);
87 }
88 }
89 else
90 {
91 /* Split the message up. */
92 messageList = CDKsplitString (message, '\n');
93 messageLines = CDKcountStrings (messageList);
94 }
95
96 /* Set up the buttons for the dialog box. */
97 if (buttons == 0)
98 {
99 buttonList[0] = copyChar ("OK");
100 buttonList[1] = copyChar ("Cancel");
101 buttonCount = 2;
102 }
103 else
104 {
105 /* Split the button list up. */
106 buttonList = CDKsplitString (buttons, '\n');
107 buttonCount = CDKcountStrings (buttonList);
108 }
109
110 /* Set up CDK. */
111 cursesWindow = initscr();
112 cdkScreen = initCDKScreen (cursesWindow);
113
114 /* Start color. */
115 initCDKColor();
116
117 /* Check if the user wants to set the background of the main screen. */
118 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
119 {
120 holder = char2Chtype (temp, &j1, &j2);
121 wbkgd (cdkScreen->window, holder[0]);
122 wrefresh (cdkScreen->window);
123 freeChtype (holder);
124 }
125
126 /* Get the widget color background color. */
127 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
128 {
129 CDK_WIDGET_COLOR = 0;
130 }
131
132 /* Create the dialog box. */
133 widget = newCDKDialog (cdkScreen, xpos, ypos,
134 messageList, messageLines,
135 buttonList, buttonCount,
136 A_REVERSE,
137 boxWidget, boxWidget, shadowWidget);
138
139 /* Check to make sure we created the dialog box. */
140 if (widget == 0)
141 {
142 CDKfreeStrings (messageList);
143 CDKfreeStrings (buttonList);
144
145 destroyCDKScreen (cdkScreen);
146 endCDK();
147
148 fprintf (stderr, "Error: Could not create the dialog box. Is the window too small?\n");
149
150 ExitProgram (CLI_ERROR);
151 }
152
153 /* Check if the user wants to set the background of the widget. */
154 setCDKDialogBackgroundColor (widget, CDK_WIDGET_COLOR);
155
156 /* Activate the dialog box. */
157 answer = activateCDKDialog (widget, 0);
158
159 /* End CDK. */
160 destroyCDKDialog (widget);
161 destroyCDKScreen (cdkScreen);
162 endCDK();
163
164 /* Print the name of the button selected. */
165 if (answer >= 0)
166 {
167 button = copyChar (buttonList[answer]);
168 fprintf (fp, "%s\n", button);
169 freeChar (button);
170 }
171
172 CDKfreeStrings (messageList);
173 CDKfreeStrings (buttonList);
174
175 /* Exit with the button number picked. */
176 ExitProgram (answer);
177 }
0 /* $Id: cdkentry.c,v 1.10 2005/12/27 16:19:26 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdkentry";
6 #endif
7
8 /*
9 * Declare file local prototypes.
10 */
11 static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
12
13 /*
14 * Define file local variables.
15 */
16 static char *FPUsage = "-f Field Width [-d Display Type] [-F Field Character] [-i Initial Value] [-m Minimum Length] [-M Maximum Length] [-T Title] [-L Label] [-B Buttons] [-O Output file] [-X X Position] [-Y Y Position] [-N] [-S]";
17
18 /*
19 *
20 */
21 int main (int argc, char **argv)
22 {
23 /* Declare variables. */
24 CDKSCREEN *cdkScreen = 0;
25 CDKENTRY *widget = 0;
26 CDKBUTTONBOX *buttonWidget = 0;
27 WINDOW *cursesWindow = 0;
28 chtype *holder = 0;
29 chtype fieldAttr = A_NORMAL;
30 char *answer = 0;
31 char *CDK_WIDGET_COLOR = 0;
32 char *temp = 0;
33 char filler = '.';
34 EDisplayType dType = vMIXED;
35 int buttonCount = 0;
36 int selection = 0;
37 int shadowHeight = 0;
38 FILE *fp = stderr;
39 char **buttonList = 0;
40 int j1, j2;
41
42 CDK_PARAMS params;
43 boolean boxWidget;
44 boolean shadowWidget;
45 char *buttons;
46 char *filename;
47 char *outputFile;
48 char *initValue;
49 char *title;
50 char *label;
51 char *tempFiller;
52 int maxValue;
53 int fieldWidth;
54 int minValue;
55 int xpos;
56 int ypos;
57
58 CDKparseParams(argc, argv, &params, "d:f:i:m:B:F:L:M:O:T:" "X:Y:NS");
59
60 xpos = CDKparamValue(&params, 'X', CENTER);
61 ypos = CDKparamValue(&params, 'Y', CENTER);
62 boxWidget = CDKparamValue(&params, 'N', TRUE);
63 shadowWidget = CDKparamValue(&params, 'S', FALSE);
64
65 minValue = CDKparamValue(&params, 'm', 0);
66 fieldWidth = CDKparamValue(&params, 'f', 0);
67 maxValue = CDKparamValue(&params, 'M', 256);
68 filename = CDKparamString(&params, 'f');
69 initValue = CDKparamString(&params, 'i');
70 buttons = CDKparamString(&params, 'B');
71 tempFiller = CDKparamString(&params, 'F');
72 label = CDKparamString(&params, 'L');
73 outputFile = CDKparamString(&params, 'O');
74 title = CDKparamString(&params, 'T');
75
76 if ((temp = CDKparamString(&params, 'd')) != 0)
77 dType = char2DisplayType (temp);
78
79 /* Make sure all the command line parameters were provided. */
80 if (fieldWidth <= 0)
81 {
82 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
83 ExitProgram (CLI_ERROR);
84 }
85
86 /* If the user asked for an output file, try to open it. */
87 if (outputFile != 0)
88 {
89 if ((fp = fopen (outputFile, "w")) == 0)
90 {
91 fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
92 ExitProgram (CLI_ERROR);
93 }
94 }
95
96 /* Set up CDK. */
97 cursesWindow = initscr();
98 cdkScreen = initCDKScreen (cursesWindow);
99
100 /* Start color. */
101 initCDKColor();
102
103 /* Check if the user wants to set the background of the main screen. */
104 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
105 {
106 holder = char2Chtype (temp, &j1, &j2);
107 wbkgd (cdkScreen->window, holder[0]);
108 wrefresh (cdkScreen->window);
109 freeChtype (holder);
110 }
111
112 /* Get the widget color background color. */
113 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
114 {
115 CDK_WIDGET_COLOR = 0;
116 }
117
118 /* If the set the filler character, set it now. */
119 if (tempFiller != 0)
120 {
121 holder = char2Chtype (tempFiller, &j1, &j2);
122 fieldAttr = A_ATTRIBUTES & holder[0];
123 filler = (chtype)holder[0];
124 freeChtype (holder);
125 }
126
127 /* Create the entry widget. */
128 widget = newCDKEntry (cdkScreen, xpos, ypos,
129 title, label,
130 fieldAttr, filler | fieldAttr,
131 dType, fieldWidth,
132 minValue, maxValue,
133 boxWidget, FALSE);
134
135 /* Check to make sure we created the dialog box. */
136 if (widget == 0)
137 {
138 /* Shut down curses and CDK. */
139 destroyCDKScreen (cdkScreen);
140 endCDK();
141
142 fprintf (stderr, "Error: Could not create the entry field. Is the window too small?\n");
143
144 ExitProgram (CLI_ERROR);
145 }
146
147 /* Split the buttons if they supplied some. */
148 if (buttons != 0)
149 {
150 buttonList = CDKsplitString (buttons, '\n');
151 buttonCount = CDKcountStrings (buttonList);
152
153 buttonWidget = newCDKButtonbox (cdkScreen,
154 getbegx (widget->win),
155 getbegy (widget->win) + widget->boxHeight - 1,
156 1, widget->boxWidth - 1,
157 0, 1, buttonCount,
158 buttonList, buttonCount,
159 A_REVERSE, boxWidget, FALSE);
160 CDKfreeStrings (buttonList);
161
162 setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
163 setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
164
165 /*
166 * We need to set the lower left and right
167 * characters of the entry field.
168 */
169 setCDKEntryLLChar (widget, ACS_LTEE);
170 setCDKEntryLRChar (widget, ACS_RTEE);
171
172 /*
173 * Bind the Tab key in the entry field to send a
174 * Tab key to the button box widget.
175 */
176 bindCDKObject (vENTRY, widget, KEY_TAB, widgetCB, buttonWidget);
177 bindCDKObject (vENTRY, widget, CDK_NEXT, widgetCB, buttonWidget);
178 bindCDKObject (vENTRY, widget, CDK_PREV, widgetCB, buttonWidget);
179
180 /* Check if the user wants to set the background of the widget. */
181 setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
182
183 /* Draw the button widget. */
184 drawCDKButtonbox (buttonWidget, boxWidget);
185 }
186
187 /*
188 * If the user asked for a shadow, we need to create one. Do this instead
189 * of using the shadow parameter because the button widget is not part of
190 * the main widget and if the user asks for both buttons and a shadow, we
191 * need to create a shadow big enough for both widgets. Create the shadow
192 * window using the widgets shadowWin element, so screen refreshes will draw
193 * them as well.
194 */
195 if (shadowWidget == TRUE)
196 {
197 /* Determine the height of the shadow window. */
198 shadowHeight = (buttonWidget == 0 ?
199 widget->boxHeight :
200 widget->boxHeight + buttonWidget->boxHeight - 1);
201
202 /* Create the shadow window. */
203 widget->shadowWin = newwin (shadowHeight,
204 widget->boxWidth,
205 getbegy (widget->win) + 1,
206 getbegx (widget->win) + 1);
207
208 /* Make sure we could have created the shadow window. */
209 if (widget->shadowWin != 0)
210 {
211 widget->shadow = TRUE;
212
213 /*
214 * We force the widget and buttonWidget to be drawn so the
215 * buttonbox widget will be drawn when the widget is activated.
216 * Otherwise the shadow window will draw over the button widget.
217 */
218 drawCDKEntry (widget, ObjOf(widget)->box);
219 eraseCDKButtonbox (buttonWidget);
220 drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
221 }
222 }
223
224 /* Check if the user wants to set the background of the widget. */
225 setCDKEntryBackgroundColor (widget, CDK_WIDGET_COLOR);
226
227 /* If there was an initial value, set it. */
228 if (initValue != 0)
229 {
230 setCDKEntryValue (widget, initValue);
231 }
232
233 /* Activate the widget. */
234 answer = copyChar (activateCDKEntry (widget, 0));
235
236 /* If there were buttons, get the button selected. */
237 if (buttonWidget != 0)
238 {
239 selection = buttonWidget->currentButton;
240 destroyCDKButtonbox (buttonWidget);
241 }
242
243 /* End CDK. */
244 destroyCDKEntry (widget);
245 destroyCDKScreen (cdkScreen);
246 endCDK();
247
248 /* Print the value from the widget. */
249 if (answer != 0)
250 {
251 fprintf (fp, "%s\n", answer);
252 freeChar (answer);
253 }
254 fclose (fp);
255
256 /* Exit with the button number picked. */
257 ExitProgram (selection);
258 }
259
260 static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
261 {
262 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
263 injectCDKButtonbox (buttonbox, key);
264 return (TRUE);
265 }
0 /* $Id: cdkfselect.c,v 1.10 2005/12/27 17:52:02 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdkfselect";
6 #endif
7
8 /*
9 * Declare file local prototypes.
10 */
11 static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
12
13 int main (int argc, char **argv)
14 {
15 /* Declare variables. */
16 CDKSCREEN *cdkScreen = 0;
17 CDKFSELECT *widget = 0;
18 CDKBUTTONBOX *buttonWidget = 0;
19 WINDOW *cursesWindow = 0;
20 char *filename = 0;
21 char *CDK_WIDGET_COLOR = 0;
22 char *temp = 0;
23 chtype *holder = 0;
24 int selection = 0;
25 int shadowHeight = 0;
26 int buttonCount = 0;
27 FILE *fp = stderr;
28 char **buttonList = 0;
29 int j1, j2;
30
31 CDK_PARAMS params;
32 boolean boxWidget;
33 boolean shadowWidget;
34 char *buttons;
35 char *directory;
36 char *label;
37 char *outputFile;
38 char *title;
39 int height;
40 int width;
41 int xpos;
42 int ypos;
43
44 CDKparseParams(argc, argv, &params, "d:B:L:O:T:" CDK_CLI_PARAMS);
45
46 xpos = CDKparamValue(&params, 'X', CENTER);
47 ypos = CDKparamValue(&params, 'Y', CENTER);
48 height = CDKparamValue(&params, 'H', 0);
49 width = CDKparamValue(&params, 'W', 0);
50 boxWidget = CDKparamValue(&params, 'N', TRUE);
51 shadowWidget = CDKparamValue(&params, 'S', FALSE);
52
53 directory = CDKparamString(&params, 'd');
54 buttons = CDKparamString(&params, 'B');
55 label = CDKparamString(&params, 'L');
56 outputFile = CDKparamString(&params, 'O');
57 title = CDKparamString(&params, 'T');
58
59 /* If the user asked for an output file, try to open it. */
60 if (outputFile != 0)
61 {
62 if ((fp = fopen (outputFile, "w")) == 0)
63 {
64 fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
65 ExitProgram (CLI_ERROR);
66 }
67 }
68
69 /* If they didn't provide a directory, use . */
70 if (directory == 0)
71 {
72 directory = copyChar (".");
73 }
74
75 /* Set the label of the file selector if it hasn't been yet. */
76 if (label == 0)
77 {
78 label = copyChar ("Directory: ");
79 }
80
81 /* Set up CDK. */
82 cursesWindow = initscr();
83 cdkScreen = initCDKScreen (cursesWindow);
84
85 /* Start color. */
86 initCDKColor();
87
88 /* Check if the user wants to set the background of the main screen. */
89 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
90 {
91 holder = char2Chtype (temp, &j1, &j2);
92 wbkgd (cdkScreen->window, holder[0]);
93 wrefresh (cdkScreen->window);
94 freeChtype (holder);
95 }
96
97 /* Get the widget color background color. */
98 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
99 {
100 CDK_WIDGET_COLOR = 0;
101 }
102
103 /* Create the file selector widget. */
104 widget = newCDKFselect (cdkScreen, xpos, ypos, height, width,
105 title, label, A_NORMAL, '.', A_REVERSE,
106 "", "", "", "",
107 boxWidget, shadowWidget);
108 freeChar (label);
109
110 /* Check to make sure we created the file selector. */
111 if (widget == 0)
112 {
113 CDKfreeStrings (buttonList);
114
115 destroyCDKScreen (cdkScreen);
116 endCDK();
117
118 fprintf (stderr, "Error: Could not create the file selector. Is the window too small?\n");
119
120 ExitProgram (CLI_ERROR);
121 }
122
123 /* Split the buttons if they supplied some. */
124 if (buttons != 0)
125 {
126 buttonList = CDKsplitString (buttons, '\n');
127 buttonCount = CDKcountStrings (buttonList);
128
129 /* We need to create a buttonbox widget. */
130 buttonWidget = newCDKButtonbox (cdkScreen,
131 getbegx (widget->win),
132 getbegy (widget->win) + widget->boxHeight - 2,
133 1, widget->boxWidth - 2,
134 0, 1, buttonCount,
135 buttonList, buttonCount,
136 A_REVERSE, boxWidget, FALSE);
137 CDKfreeStrings (buttonList);
138
139 setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
140 setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
141
142 /*
143 * We need to set the lower left and right
144 * characters of the widget.
145 */
146 setCDKFselectLLChar (widget, ACS_LTEE);
147 setCDKFselectLRChar (widget, ACS_RTEE);
148
149 /*
150 * Bind the Tab key in the widget to send a
151 * Tab key to the button box widget.
152 */
153 bindCDKObject (vFSELECT, widget, KEY_TAB, widgetCB, buttonWidget);
154 bindCDKObject (vFSELECT, widget, CDK_NEXT, widgetCB, buttonWidget);
155 bindCDKObject (vFSELECT, widget, CDK_PREV, widgetCB, buttonWidget);
156
157 /* Check if the user wants to set the background of the widget. */
158 setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
159
160 /* Draw the button widget. */
161 drawCDKButtonbox (buttonWidget, boxWidget);
162 }
163
164 /*
165 * If the user asked for a shadow, we need to create one. Do this instead
166 * of using the shadow parameter because the button widget is not part of
167 * the main widget and if the user asks for both buttons and a shadow, we
168 * need to create a shadow big enough for both widgets. Create the shadow
169 * window using the widgets shadowWin element, so screen refreshes will draw
170 * them as well.
171 */
172 if (shadowWidget == TRUE)
173 {
174 /* Determine the height of the shadow window. */
175 shadowHeight = (buttonWidget == 0 ?
176 widget->boxHeight :
177 widget->boxHeight + buttonWidget->boxHeight - 1);
178
179 /* Create the shadow window. */
180 widget->shadowWin = newwin (shadowHeight,
181 widget->boxWidth,
182 getbegy (widget->win) + 1,
183 getbegx (widget->win) + 1);
184
185 /* Make sure we could have created the shadow window. */
186 if (widget->shadowWin != 0)
187 {
188 widget->shadow = TRUE;
189
190 /*
191 * We force the widget and buttonWidget to be drawn so the
192 * buttonbox widget will be drawn when the widget is activated.
193 * Otherwise the shadow window will draw over the button widget.
194 */
195 drawCDKFselect (widget, ObjOf(widget)->box);
196 eraseCDKButtonbox (buttonWidget);
197 drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
198 }
199 }
200
201 /* Check if the user wants to set the background of the widget. */
202 setCDKFselectBackgroundColor (widget, CDK_WIDGET_COLOR);
203
204 /* Set the information for the file selector. */
205 setCDKFselectDirectory (widget, directory);
206
207 /* Activate the file selector. */
208 filename = copyChar(activateCDKFselect (widget, 0));
209
210 /* If there were buttons, get the button selected. */
211 if (buttonWidget != 0)
212 {
213 selection = buttonWidget->currentButton;
214 destroyCDKButtonbox (buttonWidget);
215 }
216
217 destroyCDKFselect (widget);
218 destroyCDKScreen (cdkScreen);
219 endCDK();
220
221 /* Print the filename selected. */
222 fprintf (fp, "%s\n", filename);
223 freeChar (filename);
224 fclose (fp);
225
226 ExitProgram (selection);
227 }
228
229 static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
230 {
231 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
232 injectCDKButtonbox (buttonbox, key);
233 return (TRUE);
234 }
0 /* $Id: cdkitemlist.c,v 1.9 2005/12/27 16:36:18 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdkitemlist";
6 #endif
7
8 /*
9 * Declare file local prototypes.
10 */
11 static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
12
13 /*
14 * Define file local variables.
15 */
16 static char *FPUsage = "-l List | -f filename [-d Default Item] [-T Title] [-L Label] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-N] [-S]";
17
18 /*
19 *
20 */
21 int main (int argc, char **argv)
22 {
23 /* Declare variables. */
24 CDKSCREEN *cdkScreen = 0;
25 CDKITEMLIST *widget = 0;
26 CDKBUTTONBOX *buttonWidget = 0;
27 WINDOW *cursesWindow = 0;
28 chtype *holder = 0;
29 char *answer = 0;
30 char *CDK_WIDGET_COLOR = 0;
31 char *temp = 0;
32 int ret = 0;
33 int buttonCount = 0;
34 int selection = 0;
35 int shadowHeight = 0;
36 FILE *fp = stderr;
37 char **itemlistList = 0;
38 char **buttonList = 0;
39 int itemlistLines, j1, j2;
40
41 CDK_PARAMS params;
42 boolean boxWidget;
43 boolean shadowWidget;
44 char *buttons;
45 char *filename;
46 char *label;
47 char *list;
48 char *outputFile;
49 char *title;
50 int defaultItem;
51 int xpos;
52 int ypos;
53
54 CDKparseParams(argc, argv, &params, "d:f:l:B:L:O:T:" "X:Y:NS");
55
56 xpos = CDKparamValue(&params, 'X', CENTER);
57 ypos = CDKparamValue(&params, 'Y', CENTER);
58 boxWidget = CDKparamValue(&params, 'N', TRUE);
59 shadowWidget = CDKparamValue(&params, 'S', FALSE);
60
61 defaultItem = CDKparamValue(&params, 'd', 0);
62 filename = CDKparamString(&params, 'f');
63 list = CDKparamString(&params, 'l');
64 buttons = CDKparamString(&params, 'B');
65 label = CDKparamString(&params, 'L');
66 outputFile = CDKparamString(&params, 'O');
67 title = CDKparamString(&params, 'T');
68
69 /* If the user asked for an output file, try to open it. */
70 if (outputFile != 0)
71 {
72 if ((fp = fopen (outputFile, "w")) == 0)
73 {
74 fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
75 ExitProgram (CLI_ERROR);
76 }
77 }
78
79 /* Did they provide a list of items. */
80 if (list == 0)
81 {
82 /* Maybe they gave a filename to use to read. */
83 if (filename != 0)
84 {
85 /* Read the file in. */
86 itemlistLines = CDKreadFile (filename, &itemlistList);
87
88 /* Check if there was an error. */
89 if (itemlistLines == -1)
90 {
91 fprintf (stderr, "Error: Could not open the file '%s'.\n", filename);
92 ExitProgram (CLI_ERROR);
93 }
94 }
95 else
96 {
97 /* They didn't provide anything. */
98 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
99 ExitProgram (CLI_ERROR);
100 }
101 }
102 else
103 {
104 /* Split the itemlist lines up. */
105 itemlistList = CDKsplitString (list, '\n');
106 itemlistLines = CDKcountStrings (itemlistList);
107 }
108
109 /* Start curses. */
110 cursesWindow = initscr();
111
112 /* Create the CDK screen. */
113 cdkScreen = initCDKScreen (cursesWindow);
114
115 /* Start color. */
116 initCDKColor();
117
118 /* Check if the user wants to set the background of the main screen. */
119 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
120 {
121 holder = char2Chtype (temp, &j1, &j2);
122 wbkgd (cdkScreen->window, holder[0]);
123 wrefresh (cdkScreen->window);
124 freeChtype (holder);
125 }
126
127 /* Get the widget color background color. */
128 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
129 {
130 CDK_WIDGET_COLOR = 0;
131 }
132
133 /* Create the item list. */
134 widget = newCDKItemlist (cdkScreen, xpos, ypos,
135 title, label,
136 itemlistList, itemlistLines,
137 defaultItem,
138 boxWidget, shadowWidget);
139
140 /* Make sure we could create the widget. */
141 if (widget == 0)
142 {
143 CDKfreeStrings(itemlistList);
144
145 destroyCDKScreen (cdkScreen);
146 endCDK();
147
148 fprintf (stderr, "Error: Could not create the item list. Is the window too small?\n");
149
150 ExitProgram (CLI_ERROR);
151 }
152
153 /* Split the buttons if they supplied some. */
154 if (buttons != 0)
155 {
156 buttonList = CDKsplitString (buttons, '\n');
157 buttonCount = CDKcountStrings (buttonList);
158
159 /* We need to create a buttonbox widget. */
160 buttonWidget = newCDKButtonbox (cdkScreen,
161 getbegx (widget->win),
162 getbegy (widget->win) + widget->boxHeight - 1,
163 1, widget->boxWidth - 1,
164 0, 1, buttonCount,
165 buttonList, buttonCount,
166 A_REVERSE, boxWidget, FALSE);
167 CDKfreeStrings (buttonList);
168
169 setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
170 setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
171
172 /*
173 * We need to set the lower left and right
174 * characters of the widget.
175 */
176 setCDKItemlistLLChar (widget, ACS_LTEE);
177 setCDKItemlistLRChar (widget, ACS_RTEE);
178
179 /*
180 * Bind the Tab key in the widget to send a
181 * Tab key to the button box widget.
182 */
183 bindCDKObject (vITEMLIST, widget, KEY_TAB, widgetCB, buttonWidget);
184 bindCDKObject (vITEMLIST, widget, CDK_NEXT, widgetCB, buttonWidget);
185 bindCDKObject (vITEMLIST, widget, CDK_PREV, widgetCB, buttonWidget);
186
187 /* Check if the user wants to set the background of the widget. */
188 setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
189
190 /* Draw the button widget. */
191 drawCDKButtonbox (buttonWidget, boxWidget);
192 }
193
194 /*
195 * If the user asked for a shadow, we need to create one. Do this instead
196 * of using the shadow parameter because the button widget is not part of
197 * the main widget and if the user asks for both buttons and a shadow, we
198 * need to create a shadow big enough for both widgets. Create the shadow
199 * window using the widgets shadowWin element, so screen refreshes will draw
200 * them as well.
201 */
202 if (shadowWidget == TRUE)
203 {
204 /* Determine the height of the shadow window. */
205 shadowHeight = (buttonWidget == 0 ?
206 widget->boxHeight :
207 widget->boxHeight + buttonWidget->boxHeight - 1);
208
209 /* Create the shadow window. */
210 widget->shadowWin = newwin (shadowHeight,
211 widget->boxWidth,
212 getbegy (widget->win) + 1,
213 getbegx (widget->win) + 1);
214
215 /* Make sure we could have created the shadow window. */
216 if (widget->shadowWin != 0)
217 {
218 widget->shadow = TRUE;
219
220 /*
221 * We force the widget and buttonWidget to be drawn so the
222 * buttonbox widget will be drawn when the widget is activated.
223 * Otherwise the shadow window will draw over the button widget.
224 */
225 drawCDKItemlist (widget, ObjOf(widget)->box);
226 eraseCDKButtonbox (buttonWidget);
227 drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
228 }
229 }
230
231 /* Check if the user wants to set the background of the widget. */
232 setCDKItemlistBackgroundColor (widget, CDK_WIDGET_COLOR);
233
234 /* Activate the item list. */
235 ret = activateCDKItemlist (widget, 0);
236
237 /* If there were buttons, get the button selected. */
238 if (buttonWidget != 0)
239 {
240 selection = buttonWidget->currentButton;
241 destroyCDKButtonbox (buttonWidget);
242 }
243
244 destroyCDKItemlist (widget);
245 destroyCDKScreen (cdkScreen);
246 endCDK();
247
248 /* Print out the answer. */
249 if (ret >= 0)
250 {
251 holder = char2Chtype (itemlistList[ret], &j1, &j2);
252 answer = chtype2Char (holder);
253 fprintf (fp, "%s\n", answer);
254 freeChar (answer);
255 freeChtype (holder);
256 }
257 CDKfreeStrings(itemlistList);
258 fclose (fp);
259
260 /* Exit with the answer. */
261 ExitProgram (selection);
262 }
263
264 static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
265 {
266 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
267 injectCDKButtonbox (buttonbox, key);
268 return (TRUE);
269 }
0 /* $Id: cdklabel.c,v 1.10 2005/12/27 16:06:34 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdklabel";
6 #endif
7
8 /*
9 * Declare file local variables.
10 */
11 static char *FPUsage = "-m Message String | -f filename [-c Command] [-p Pause Character] [-s Sleep] [-X X Position] [-Y Y Position] [-N] [-S]";
12
13 /*
14 *
15 */
16 int main (int argc, char **argv)
17 {
18 /* Declare variables. */
19 CDKSCREEN *cdkScreen = 0;
20 CDKLABEL *widget = 0;
21 WINDOW *cursesWindow = 0;
22 char *CDK_WIDGET_COLOR = 0;
23 char *temp = 0;
24 chtype *holder = 0;
25 int messageLines = -1;
26 char **messageList = 0;
27 char tempCommand[1000];
28 int j1, j2;
29
30 CDK_PARAMS params;
31 boolean boxWidget;
32 boolean shadowWidget;
33 char *command;
34 char *filename;
35 char *message;
36 char waitChar = 0;
37 int sleepLength;
38 int xpos;
39 int ypos;
40
41 CDKparseParams(argc, argv, &params, "c:f:m:p:s:" "X:Y:NS");
42
43 xpos = CDKparamValue(&params, 'X', CENTER);
44 ypos = CDKparamValue(&params, 'Y', CENTER);
45 boxWidget = CDKparamValue(&params, 'N', TRUE);
46 shadowWidget = CDKparamValue(&params, 'S', FALSE);
47
48 sleepLength = CDKparamValue(&params, 's', 0);
49 command = CDKparamString(&params, 'c');
50 filename = CDKparamString(&params, 'f');
51 message = CDKparamString(&params, 'm');
52
53 if ((temp = CDKparamString(&params, 'p')) != 0)
54 waitChar = *temp;
55
56 /* Make sure we have a message to display. */
57 if (message == 0)
58 {
59 /* No message, maybe they provided a file to read. */
60 if (filename != 0)
61 {
62 /* Read the file in. */
63 messageLines = CDKreadFile (filename, &messageList);
64
65 /* Check if there was an error. */
66 if (messageLines == -1)
67 {
68 fprintf (stderr, "Error: Could not open the file %s\n", filename);
69 ExitProgram (CLI_ERROR);
70 }
71 }
72 else
73 {
74 /* No message, no file, it's an error. */
75 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
76 ExitProgram (CLI_ERROR);
77 }
78 }
79 else
80 {
81 /* Split the message up. */
82 messageList = CDKsplitString (message, '\n');
83 messageLines = CDKcountStrings (messageList);
84 }
85
86 /* Set up CDK. */
87 cursesWindow = initscr();
88 cdkScreen = initCDKScreen (cursesWindow);
89
90 /* Start color. */
91 initCDKColor();
92
93 /* Check if the user wants to set the background of the main screen. */
94 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
95 {
96 holder = char2Chtype (temp, &j1, &j2);
97 wbkgd (cdkScreen->window, holder[0]);
98 wrefresh (cdkScreen->window);
99 freeChtype (holder);
100 }
101
102 /* Get the widget color background color. */
103 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
104 {
105 CDK_WIDGET_COLOR = 0;
106 }
107
108 /* Create the label widget. */
109 widget = newCDKLabel (cdkScreen, xpos, ypos,
110 messageList, messageLines,
111 boxWidget, shadowWidget);
112
113 /* Make sure we could create the widget. */
114 if (widget == 0)
115 {
116 CDKfreeStrings (messageList);
117
118 destroyCDKScreen (cdkScreen);
119 endCDK();
120
121 fprintf (stderr, "Error: Could not create the label. Is the window too small?\n");
122
123 ExitProgram (CLI_ERROR);
124 }
125
126 /* Check if the user wants to set the background of the widget. */
127 setCDKLabelBackgroundColor (widget, CDK_WIDGET_COLOR);
128
129 /* Draw the widget. */
130 drawCDKLabel (widget, boxWidget);
131
132 /* If they supplied a command, run it. */
133 if (command != 0)
134 {
135 char *fmt = "(sh -c %.*s) >/dev/null 2>&1";
136 sprintf (tempCommand, fmt, (int)(sizeof(tempCommand) - strlen(fmt)), command);
137 system (tempCommand);
138 }
139
140 /* If they supplied a wait character, wait for the user to hit it. */
141 if (waitChar != 0)
142 {
143 waitCDKLabel (widget, waitChar);
144 }
145
146 /* If they supplied a sleep time, sleep for the given length. */
147 if (sleepLength > 0)
148 {
149 sleep (sleepLength);
150 }
151
152 CDKfreeStrings (messageList);
153
154 destroyCDKLabel (widget);
155 destroyCDKScreen (cdkScreen);
156 endCDK();
157
158 /* Exit cleanly. */
159 ExitProgram (0);
160 }
0 /* $Id: cdkmatrix.c,v 1.13 2005/12/27 16:54:49 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName = "cdkmatrix";
6 #endif
7
8 #define MY_INFO(x,y) info[(x + 1) * cols + (y + 1)]
9
10 /*
11 * Declare file local prototypes.
12 */
13 static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
14
15 /*
16 * Define file local variables.
17 */
18 static char *FPUsage = "-r Row Titles -c Column Titles -v Visible Rows -w Column Widths [-t Column Types] [-d Default Values] [-F Field Character] [-T Title] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-N] [-S]";
19
20 /*
21 *
22 */
23 int main (int argc, char **argv)
24 {
25 /* Declare variables. */
26 CDKSCREEN *cdkScreen = 0;
27 CDKMATRIX *widget = 0;
28 CDKBUTTONBOX *buttonWidget = 0;
29 WINDOW *cursesWindow = 0;
30 chtype *holder = 0;
31 char *buttons = 0;
32 char *CDK_WIDGET_COLOR = 0;
33 char *temp = 0;
34 chtype filler = A_NORMAL | '.';
35 int rows = -1;
36 int cols = -1;
37 int buttonCount = 0;
38 int selection = 0;
39 int shadowHeight = 0;
40 FILE *fp = stderr;
41 char **rowTitles;
42 char **colTitles;
43 char **rowTemp = 0;
44 char **colTemp = 0;
45 char **kolTemp = 0;
46 char **buttonList = 0;
47 int *colWidths;
48 int *colTypes;
49 int count, infoLines, x, y, j1, j2;
50
51 CDK_PARAMS params;
52 boolean boxWidget;
53 boolean shadowWidget;
54 char *defaultValue;
55 char *myColTitles;
56 char *myColTypes;
57 char *myColWidths;
58 char *myFiller;
59 char *myRowTitles;
60 char *outputFile;
61 char *title;
62 int vrows;
63 int xpos;
64 int ypos;
65
66 CDKparseParams(argc, argv, &params, "c:d:r:t:w:v:B:F:O:T:" "X:Y:NS");
67
68 xpos = CDKparamValue(&params, 'X', CENTER);
69 ypos = CDKparamValue(&params, 'Y', CENTER);
70 boxWidget = CDKparamValue(&params, 'N', TRUE);
71 shadowWidget = CDKparamValue(&params, 'S', FALSE);
72
73 vrows = CDKparamValue(&params, 'v', -1);
74 myColTitles = CDKparamString(&params, 'c');
75 defaultValue = CDKparamString(&params, 'd');
76 myRowTitles = CDKparamString(&params, 'r');
77 myColTypes = CDKparamString(&params, 't');
78 myColWidths = CDKparamString(&params, 'w');
79 buttons = CDKparamString(&params, 'B');
80 myFiller = CDKparamString(&params, 'F');
81 outputFile = CDKparamString(&params, 'O');
82 title = CDKparamString(&params, 'T');
83
84 /* If the user asked for an output file, try to open it. */
85 if (outputFile != 0)
86 {
87 if ((fp = fopen (outputFile, "w")) == 0)
88 {
89 fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
90 ExitProgram (CLI_ERROR);
91 }
92 }
93
94 /* Make sure all the needed command line parameters were provided. */
95 if ((myRowTitles == 0) ||
96 (myColTitles == 0) ||
97 (myColWidths == 0) ||
98 (vrows == -1))
99 {
100 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
101 ExitProgram (CLI_ERROR);
102 }
103
104 /* Convert the char * titles to a char **, offset by one */
105 rowTemp = CDKsplitString (myRowTitles, '\n');
106 rows = CDKcountStrings (rowTemp);
107 rowTitles = (char **) calloc (rows + 1, sizeof(char *));
108 for (x=0; x < rows; x++)
109 {
110 rowTitles[x+1] = rowTemp[x];
111 }
112
113 colTemp = CDKsplitString (myColTitles, '\n');
114 cols = CDKcountStrings (colTemp);
115 colTitles = (char **) calloc (cols + 1, sizeof(char *));
116 for (x=0; x < cols; x++)
117 {
118 colTitles[x+1] = colTemp[x];
119 }
120
121 /* Convert the column widths. */
122 kolTemp = CDKsplitString (myColWidths, '\n');
123 count = CDKcountStrings (kolTemp);
124 colWidths = (int *) calloc (count + 1, sizeof(int));
125 for (x=0; x < count; x++)
126 {
127 colWidths[x+1] = atoi (kolTemp[x]);
128 }
129
130 /* If they passed in the column types, convert them. */
131 if (myColTypes != 0)
132 {
133 char **ss = CDKsplitString (myColTypes, '\n');
134 count = CDKcountStrings (ss);
135 colTypes = (int *) calloc (MAXIMUM(cols, count) + 1, sizeof(int));
136 for (x=0; x < count; x++)
137 {
138 colTypes[x+1] = char2DisplayType (ss[x]);
139 }
140 CDKfreeStrings(ss);
141 }
142 else
143 {
144 /* If they didn't set default values. */
145 colTypes = (int *) calloc (cols + 1, sizeof(int));
146 for (x=0; x < cols; x++)
147 {
148 colTypes[x+1] = vMIXED;
149 }
150 }
151
152 /* Start curses. */
153 cursesWindow = initscr();
154
155 /* Create the CDK screen. */
156 cdkScreen = initCDKScreen (cursesWindow);
157
158 /* Start color. */
159 initCDKColor();
160
161 /* Check if the user wants to set the background of the main screen. */
162 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
163 {
164 holder = char2Chtype (temp, &j1, &j2);
165 wbkgd (cdkScreen->window, holder[0]);
166 wrefresh (cdkScreen->window);
167 freeChtype (holder);
168 }
169
170 /* Get the widget color background color. */
171 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
172 {
173 CDK_WIDGET_COLOR = 0;
174 }
175
176 /* If the set the filler character, set it now. */
177 if (myFiller != 0)
178 {
179 holder = char2Chtype (myFiller, &j1, &j2);
180 filler = holder[0];
181 freeChtype (holder);
182 }
183
184 /* Create the matrix widget. */
185 widget = newCDKMatrix (cdkScreen, xpos, ypos,
186 rows, cols, vrows, cols,
187 title, rowTitles, colTitles,
188 colWidths, colTypes, 1, 1,
189 filler, COL,
190 boxWidget, TRUE, shadowWidget);
191 free (rowTitles);
192 free (colTitles);
193
194 /* Make sure we could create the widget. */
195 if (widget == 0)
196 {
197 /* Shut down curses and CDK. */
198 destroyCDKScreen (cdkScreen);
199 endCDK();
200
201 fprintf (stderr, "Error: Could not create the matrix. Is the window too small?\n");
202
203 ExitProgram (CLI_ERROR);
204 }
205
206 /*
207 * If the user sent in a file of default values, read it and
208 * stick the values read in from the file into the matrix.
209 */
210 if (defaultValue != 0)
211 {
212 int limit = (rows + 1) * (cols + 1);
213 char **info = (char **) calloc (limit, sizeof(char *));
214 char **lineTemp = 0;
215
216 /* Read the file. */
217 infoLines = CDKreadFile (defaultValue, &lineTemp);
218 if (infoLines > 0)
219 {
220 int *subSize = (int *) calloc(infoLines + 1, sizeof(int *));
221
222 /* For each line, split on a CTRL-V. */
223 for (x=0; x < infoLines; x++)
224 {
225 char **ss = CDKsplitString (lineTemp[x], CTRL('V'));
226 subSize[x+1] = CDKcountStrings (ss);
227 for (y=0; y < subSize[x+1]; y++)
228 {
229 MY_INFO(x, y) = ss[y];
230 }
231 free (ss);
232 }
233 CDKfreeStrings (lineTemp);
234
235 setCDKMatrixCells (widget, info, rows, cols, subSize);
236
237 for (x=0; x < infoLines; x++)
238 {
239 for (y=0; y < subSize[x+1]; y++)
240 {
241 freeChar (MY_INFO(x, y));
242 }
243 }
244 free (info);
245 free (subSize);
246 }
247 }
248
249 /* Split the buttons if they supplied some. */
250 if (buttons != 0)
251 {
252 /* Split the button list up. */
253 buttonList = CDKsplitString (buttons, '\n');
254 buttonCount = CDKcountStrings (buttonList);
255
256 /* We need to create a buttonbox widget. */
257 buttonWidget = newCDKButtonbox (cdkScreen,
258 getbegx (widget->win),
259 getbegy (widget->win) + widget->boxHeight - 1,
260 1, widget->boxWidth - 1,
261 NULL, 1, buttonCount,
262 buttonList, buttonCount,
263 A_REVERSE, boxWidget, FALSE);
264
265 setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
266 setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
267
268 /*
269 * We need to set the lower left and right
270 * characters of the widget.
271 */
272 setCDKMatrixLLChar (widget, ACS_LTEE);
273 setCDKMatrixLRChar (widget, ACS_RTEE);
274
275 /*
276 * Bind the Tab key in the widget to send a
277 * Tab key to the button box widget.
278 */
279 bindCDKObject (vMATRIX, widget, KEY_TAB, widgetCB, buttonWidget);
280 bindCDKObject (vMATRIX, widget, CDK_NEXT, widgetCB, buttonWidget);
281 bindCDKObject (vMATRIX, widget, CDK_PREV, widgetCB, buttonWidget);
282
283 /* Check if the user wants to set the background of the widget. */
284 setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
285
286 /* Draw the button widget. */
287 drawCDKButtonbox (buttonWidget, boxWidget);
288 }
289
290 /*
291 * If the user asked for a shadow, we need to create one. Do this instead
292 * of using the shadow parameter because the button widget is not part of
293 * the main widget and if the user asks for both buttons and a shadow, we
294 * need to create a shadow big enough for both widgets. Create the shadow
295 * window using the widgets shadowWin element, so screen refreshes will draw
296 * them as well.
297 */
298 if (shadowWidget == TRUE)
299 {
300 /* Determine the height of the shadow window. */
301 shadowHeight = (buttonWidget == (CDKBUTTONBOX *)NULL ?
302 widget->boxHeight :
303 widget->boxHeight + buttonWidget->boxHeight - 1);
304
305 /* Create the shadow window. */
306 widget->shadowWin = newwin (shadowHeight,
307 widget->boxWidth,
308 getbegy (widget->win) + 1,
309 getbegx (widget->win) + 1);
310
311 /* Make sure we could have created the shadow window. */
312 if (widget->shadowWin != 0)
313 {
314 widget->shadow = TRUE;
315
316 /*
317 * We force the widget and buttonWidget to be drawn so the
318 * buttonbox widget will be drawn when the widget is activated.
319 * Otherwise the shadow window will draw over the button widget.
320 */
321 drawCDKMatrix (widget, ObjOf(widget)->box);
322 eraseCDKButtonbox (buttonWidget);
323 drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
324 }
325 }
326
327 /* Check if the user wants to set the background of the widget. */
328 setCDKMatrixBackgroundColor (widget, CDK_WIDGET_COLOR);
329
330 /* Let them play. */
331 activateCDKMatrix (widget, 0);
332
333 /* Print out the matrix cells. */
334 if (widget->exitType == vNORMAL)
335 {
336 for (x=0; x < widget->rows; x++)
337 {
338 for (y=0; y < widget->cols; y++)
339 {
340 char *data = getCDKMatrixCell(widget, x, y);
341 if (data != 0)
342 {
343 fprintf (fp, "%s%c", data, CTRL('V'));
344 }
345 else
346 {
347 fprintf (fp, "%c", CTRL('V'));
348 }
349 }
350 fprintf (fp, "\n");
351 }
352 }
353
354 /* If there were buttons, get the button selected. */
355 if (buttonWidget != 0)
356 {
357 selection = buttonWidget->currentButton;
358 destroyCDKButtonbox (buttonWidget);
359 }
360
361 /* cleanup (not really needed) */
362 CDKfreeStrings (buttonList);
363 free (colTypes);
364 free (colWidths);
365
366 CDKfreeStrings (rowTemp);
367 CDKfreeStrings (colTemp);
368 CDKfreeStrings (kolTemp);
369
370 destroyCDKMatrix (widget);
371 destroyCDKScreen (cdkScreen);
372 endCDK();
373
374 /* do this late, in case it was stderr */
375 fclose (fp);
376
377 ExitProgram (selection);
378 }
379
380 static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
381 {
382 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
383 injectCDKButtonbox (buttonbox, key);
384 return (TRUE);
385 }
0 /* $Id: cdkmentry.c,v 1.9 2005/12/27 16:57:01 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdkmentry";
6 #endif
7
8 /*
9 * Declare file local prototypes.
10 */
11 static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
12
13 /*
14 * Define file local variables.
15 */
16 static char *FPUsage = "-f Field Width -s Screen Rows -v Virtual Rows [-d Display Type] [-F Field Character] [-i Initial Value] [-m Minimum Length] [-T Title] [-L Label] [-B Buttons] [-O Output file] [-X X Position] [-Y Y Position] [-N] [-S]";
17
18 /*
19 *
20 */
21 int main (int argc, char **argv)
22 {
23 /* Declare variables. */
24 CDKSCREEN *cdkScreen = 0;
25 CDKMENTRY *widget = 0;
26 CDKBUTTONBOX *buttonWidget = 0;
27 WINDOW *cursesWindow = 0;
28 chtype *holder = 0;
29 chtype fieldAttr = 0;
30 char *answer = 0;
31 char *CDK_WIDGET_COLOR = 0;
32 char *temp = 0;
33 char filler = '.';
34 EDisplayType dType = vMIXED;
35 int buttonCount = 0;
36 int selection = 0;
37 int shadowHeight = 0;
38 FILE *fp = stderr;
39 char **buttonList = 0;
40 int j1, j2;
41
42 CDK_PARAMS params;
43 boolean boxWidget;
44 boolean shadowWidget;
45 char *buttons;
46 char *initValue;
47 char *label;
48 char *outputFile;
49 char *tempFiller;
50 char *title;
51 int fieldWidth;
52 int min;
53 int screenRows;
54 int virtualRows;
55 int xpos;
56 int ypos;
57
58 CDKparseParams(argc, argv, &params, "d:f:i:m:s:v:B:F:L:O:T:" "X:Y:NS");
59
60 xpos = CDKparamValue(&params, 'X', CENTER);
61 ypos = CDKparamValue(&params, 'Y', CENTER);
62 boxWidget = CDKparamValue(&params, 'N', TRUE);
63 shadowWidget = CDKparamValue(&params, 'S', FALSE);
64
65 fieldWidth = CDKparamValue(&params, 'f', 0);
66 min = CDKparamValue(&params, 'm', 0);
67 screenRows = CDKparamValue(&params, 's', 0);
68 virtualRows = CDKparamValue(&params, 'v', 0);
69 initValue = CDKparamString(&params, 'i');
70 buttons = CDKparamString(&params, 'B');
71 tempFiller = CDKparamString(&params, 'F');
72 label = CDKparamString(&params, 'L');
73 outputFile = CDKparamString(&params, 'O');
74 title = CDKparamString(&params, 'T');
75
76 if ((temp = CDKparamString(&params, 'd')) != 0)
77 dType = char2DisplayType (temp);
78
79 /* Make sure all the command line parameters were provided. */
80 if ((fieldWidth <= 0) || (screenRows <= 0) || (virtualRows <= 0))
81 {
82 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
83 ExitProgram (CLI_ERROR);
84 }
85
86 /* If the user asked for an output file, try to open it. */
87 if (outputFile != 0)
88 {
89 if ((fp = fopen (outputFile, "w")) == 0)
90 {
91 fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
92 ExitProgram (CLI_ERROR);
93 }
94 }
95
96 /* Set up CDK. */
97 cursesWindow = initscr();
98 cdkScreen = initCDKScreen (cursesWindow);
99
100 /* Start color. */
101 initCDKColor();
102
103 /* Check if the user wants to set the background of the main screen. */
104 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
105 {
106 holder = char2Chtype (temp, &j1, &j2);
107 wbkgd (cdkScreen->window, holder[0]);
108 wrefresh (cdkScreen->window);
109 freeChtype (holder);
110 }
111
112 /* Get the widget color background color. */
113 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
114 {
115 CDK_WIDGET_COLOR = 0;
116 }
117
118 /* If the set the filler character, set it now. */
119 if (tempFiller != 0)
120 {
121 holder = char2Chtype (tempFiller, &j1, &j2);
122 fieldAttr = A_ATTRIBUTES & holder[0];
123 filler = (chtype)holder[0];
124 freeChtype (holder);
125 }
126 /* Create the mentry widget. */
127 widget = newCDKMentry (cdkScreen, xpos, ypos,
128 title, label,
129 fieldAttr, filler | fieldAttr,
130 dType, fieldWidth,
131 screenRows, virtualRows,
132 min, boxWidget, shadowWidget);
133
134 /* Check to make sure we created the dialog box. */
135 if (widget == 0)
136 {
137 /* Shut down curses and CDK. */
138 destroyCDKScreen (cdkScreen);
139 endCDK();
140
141 fprintf (stderr, "Error: Could not create the multiple line entry field. Is the window too small?\n");
142
143 ExitProgram (CLI_ERROR);
144 }
145
146 /* Split the buttons if they supplied some. */
147 if (buttons != 0)
148 {
149 buttonList = CDKsplitString (buttons, '\n');
150 buttonCount = CDKcountStrings (buttonList);
151
152 /* We need to create a buttonbox widget. */
153 buttonWidget = newCDKButtonbox (cdkScreen,
154 getbegx (widget->win),
155 getbegy (widget->win) + widget->boxHeight - 1,
156 1, widget->boxWidth - 1,
157 NULL, 1, buttonCount,
158 buttonList, buttonCount,
159 A_REVERSE, boxWidget, FALSE);
160 CDKfreeStrings (buttonList);
161
162 setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
163 setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
164
165 /*
166 * We need to set the lower left and right
167 * characters of the widget.
168 */
169 setCDKMentryLLChar (widget, ACS_LTEE);
170 setCDKMentryLRChar (widget, ACS_RTEE);
171
172 /*
173 * Bind the Tab key in the widget to send a
174 * Tab key to the button box widget.
175 */
176 bindCDKObject (vMENTRY, widget, KEY_TAB, widgetCB, buttonWidget);
177 bindCDKObject (vMENTRY, widget, CDK_NEXT, widgetCB, buttonWidget);
178 bindCDKObject (vMENTRY, widget, CDK_PREV, widgetCB, buttonWidget);
179
180 /* Check if the user wants to set the background of the widget. */
181 setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
182
183 /* Draw the button widget. */
184 drawCDKButtonbox (buttonWidget, boxWidget);
185 }
186
187 /*
188 * If the user asked for a shadow, we need to create one. Do this instead
189 * of using the shadow parameter because the button widget is not part of
190 * the main widget and if the user asks for both buttons and a shadow, we
191 * need to create a shadow big enough for both widgets. Create the shadow
192 * window using the widgets shadowWin element, so screen refreshes will draw
193 * them as well.
194 */
195 if (shadowWidget == TRUE)
196 {
197 /* Determine the height of the shadow window. */
198 shadowHeight = (buttonWidget == (CDKBUTTONBOX *)NULL ?
199 widget->boxHeight :
200 widget->boxHeight + buttonWidget->boxHeight - 1);
201
202 /* Create the shadow window. */
203 widget->shadowWin = newwin (shadowHeight,
204 widget->boxWidth,
205 getbegy (widget->win) + 1,
206 getbegx (widget->win) + 1);
207
208 /* Make sure we could have created the shadow window. */
209 if (widget->shadowWin != 0)
210 {
211 widget->shadow = TRUE;
212
213 /*
214 * We force the widget and buttonWidget to be drawn so the
215 * buttonbox widget will be drawn when the widget is activated.
216 * Otherwise the shadow window will draw over the button widget.
217 */
218 drawCDKMentry (widget, ObjOf(widget)->box);
219 eraseCDKButtonbox (buttonWidget);
220 drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
221 }
222 }
223
224 /* Check if the user wants to set the background of the widget. */
225 setCDKMentryBackgroundColor (widget, CDK_WIDGET_COLOR);
226
227 /* If there was an initial value, set it. */
228 if (initValue != 0)
229 {
230 setCDKMentryValue (widget, initValue);
231 }
232
233 /* Activate the widget. */
234 answer = copyChar (activateCDKMentry (widget, 0));
235
236 /* If there were buttons, get the button selected. */
237 if (buttonWidget != 0)
238 {
239 selection = buttonWidget->currentButton;
240 destroyCDKButtonbox (buttonWidget);
241 }
242
243 /* End CDK. */
244 destroyCDKMentry (widget);
245 destroyCDKScreen (cdkScreen);
246 endCDK();
247
248 /* Print the value from the widget. */
249 if (answer != 0)
250 {
251 fprintf (fp, "%s\n", answer);
252 freeChar (answer);
253 }
254 fclose (fp);
255
256 /* Exit with the button number picked. */
257 ExitProgram (selection);
258 }
259
260 static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
261 {
262 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
263 injectCDKButtonbox (buttonbox, key);
264 return (TRUE);
265 }
0 /* $Id: cdkradio.c,v 1.9 2005/12/27 17:06:03 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdkradio";
6 #endif
7
8 /*
9 * Declare file local prototypes.
10 */
11 static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
12
13 /*
14 * Define file local variables.
15 */
16 static char *FPUsage = "-l List | -f filename [-c Choice Character] [-d Default Item] [-s Scroll Bar Position] [-n Numbers] [-i Item Index] [-T Title] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-H Height] [-W Width] [-N] [-S]";
17
18 /*
19 *
20 */
21 int main (int argc, char **argv)
22 {
23 /* Declare variables. */
24 CDKSCREEN *cdkScreen = 0;
25 CDKRADIO *widget = 0;
26 CDKBUTTONBOX *buttonWidget = 0;
27 WINDOW *cursesWindow = 0;
28 char *buttons = 0;
29 char *CDK_WIDGET_COLOR = 0;
30 char *temp = 0;
31 chtype *holder = 0;
32 chtype *choiceChar = 0;
33 int answer = 0;
34 int spos = NONE;
35 int scrollLines = -1;
36 int buttonCount = 0;
37 int selection = 0;
38 int shadowHeight = 0;
39 FILE *fp = stderr;
40 char **buttonList = 0;
41 char **scrollList = 0;
42 int j1, j2;
43
44 CDK_PARAMS params;
45 boolean boxWidget;
46 boolean numberOutput;
47 boolean shadowWidget;
48 char *choice;
49 char *filename;
50 char *list;
51 char *outputFile;
52 char *title;
53 int defaultItem;
54 int height;
55 int width;
56 int xpos;
57 int ypos;
58
59 CDKparseParams(argc, argv, &params, "l:f:s:c:d:iB:O:T:" CDK_CLI_PARAMS);
60
61 xpos = CDKparamValue(&params, 'X', CENTER);
62 ypos = CDKparamValue(&params, 'Y', CENTER);
63 height = CDKparamValue(&params, 'H', 10);
64 width = CDKparamValue(&params, 'W', 1);
65 boxWidget = CDKparamValue(&params, 'N', TRUE);
66 shadowWidget = CDKparamValue(&params, 'S', FALSE);
67
68 defaultItem = CDKparamValue(&params, 'd', 0);
69 numberOutput = CDKparamValue(&params, 'i', FALSE);
70 filename = CDKparamString(&params, 'f');
71 list = CDKparamString(&params, 'l');
72 buttons = CDKparamString(&params, 'B');
73 outputFile = CDKparamString(&params, 'O');
74 title = CDKparamString(&params, 'T');
75
76 if ((choice = CDKparamString(&params, 'c')) == 0)
77 choice = "</R>X";
78
79 spos = CDKparsePosition(CDKparamString(&params, 's'));
80
81 /* If the user asked for an output file, try to open it. */
82 if (outputFile != 0)
83 {
84 if ((fp = fopen (outputFile, "w")) == 0)
85 {
86 fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
87 ExitProgram (CLI_ERROR);
88 }
89 }
90
91 /* Did they provide a list of items. */
92 if (list == 0)
93 {
94 /* Maybe they gave a filename to use to read. */
95 if (filename != 0)
96 {
97 /* Read the file in. */
98 scrollLines = CDKreadFile (filename, &scrollList);
99
100 /* Check if there was an error. */
101 if (scrollLines == -1)
102 {
103 fprintf (stderr, "Error: Could not open the file '%s'.\n", filename);
104 ExitProgram (CLI_ERROR);
105 }
106 }
107 else
108 {
109 /* They didn't provide anything. */
110 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
111 ExitProgram (CLI_ERROR);
112 }
113 }
114 else
115 {
116 /* Split the scroll lines up. */
117 scrollList = CDKsplitString (list, '\n');
118 scrollLines = CDKcountStrings (scrollList);
119 }
120
121 /* Start curses. */
122 cursesWindow = initscr();
123
124 /* Create the CDK screen. */
125 cdkScreen = initCDKScreen (cursesWindow);
126
127 /* Start color. */
128 initCDKColor();
129
130 /* Check if the user wants to set the background of the main screen. */
131 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
132 {
133 holder = char2Chtype (temp, &j1, &j2);
134 wbkgd (cdkScreen->window, holder[0]);
135 wrefresh (cdkScreen->window);
136 freeChtype (holder);
137 }
138
139 /* Get the widget color background color. */
140 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
141 {
142 CDK_WIDGET_COLOR = 0;
143 }
144
145 /* Convert the char * choiceChar to a chtype * */
146 choiceChar = char2Chtype (choice, &j1, &j2);
147
148 /* Create the scrolling list. */
149 widget = newCDKRadio (cdkScreen, xpos, ypos, spos,
150 height, width, title,
151 scrollList, scrollLines,
152 choiceChar[0], defaultItem,
153 A_REVERSE,
154 boxWidget, shadowWidget);
155 free (choiceChar);
156
157 /* Make sure we could create the widget. */
158 if (widget == 0)
159 {
160 CDKfreeStrings (scrollList);
161
162 destroyCDKScreen (cdkScreen);
163 endCDK();
164
165 fprintf (stderr, "Error: Could not create the radio list. Is the window too small?\n");
166
167 ExitProgram (CLI_ERROR);
168 }
169
170 /* Split the buttons if they supplied some. */
171 if (buttons != 0)
172 {
173 /* Split the button list up. */
174 buttonList = CDKsplitString (buttons, '\n');
175 buttonCount = CDKcountStrings (buttonList);
176
177 /* We need to create a buttonbox widget. */
178 buttonWidget = newCDKButtonbox (cdkScreen,
179 getbegx (widget->win),
180 getbegy (widget->win) + widget->boxHeight - 1,
181 1, widget->boxWidth - 1,
182 NULL, 1, buttonCount,
183 buttonList, buttonCount,
184 A_REVERSE, boxWidget, FALSE);
185 CDKfreeStrings (buttonList);
186
187 setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
188 setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
189
190 /*
191 * We need to set the lower left and right
192 * characters of the widget.
193 */
194 setCDKRadioLLChar (widget, ACS_LTEE);
195 setCDKRadioLRChar (widget, ACS_RTEE);
196
197 /*
198 * Bind the Tab key in the widget to send a
199 * Tab key to the button box widget.
200 */
201 bindCDKObject (vRADIO, widget, KEY_TAB, widgetCB, buttonWidget);
202 bindCDKObject (vRADIO, widget, CDK_NEXT, widgetCB, buttonWidget);
203 bindCDKObject (vRADIO, widget, CDK_PREV, widgetCB, buttonWidget);
204
205 /* Check if the user wants to set the background of the widget. */
206 setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
207
208 /* Draw the button widget. */
209 drawCDKButtonbox (buttonWidget, boxWidget);
210 }
211
212 /*
213 * If the user asked for a shadow, we need to create one. Do this instead
214 * of using the shadow parameter because the button widget is not part of
215 * the main widget and if the user asks for both buttons and a shadow, we
216 * need to create a shadow big enough for both widgets. Create the shadow
217 * window using the widgets shadowWin element, so screen refreshes will draw
218 * them as well.
219 */
220 if (shadowWidget == TRUE)
221 {
222 /* Determine the height of the shadow window. */
223 shadowHeight = (buttonWidget == (CDKBUTTONBOX *)NULL ?
224 widget->boxHeight :
225 widget->boxHeight + buttonWidget->boxHeight - 1);
226
227 /* Create the shadow window. */
228 widget->shadowWin = newwin (shadowHeight,
229 widget->boxWidth,
230 getbegy (widget->win) + 1,
231 getbegx (widget->win) + 1);
232
233 if (widget->shadowWin != 0)
234 {
235 widget->shadow = TRUE;
236
237 /*
238 * We force the widget and buttonWidget to be drawn so the
239 * buttonbox widget will be drawn when the widget is activated.
240 * Otherwise the shadow window will draw over the button widget.
241 */
242 drawCDKRadio (widget, ObjOf(widget)->box);
243 eraseCDKButtonbox (buttonWidget);
244 drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
245 }
246 }
247
248 /* Check if the user wants to set the background of the widget. */
249 setCDKRadioBackgroundColor (widget, CDK_WIDGET_COLOR);
250
251 /* Activate the scrolling list. */
252 answer = activateCDKRadio (widget, 0);
253
254 /* If there were buttons, get the button selected. */
255 if (buttonWidget != 0)
256 {
257 selection = buttonWidget->currentButton;
258 destroyCDKButtonbox (buttonWidget);
259 }
260
261 /* Shut down curses. */
262 destroyCDKRadio (widget);
263 destroyCDKScreen (cdkScreen);
264 endCDK();
265
266 /* Print out the answer. */
267 if (answer >= 0)
268 {
269 if (numberOutput == TRUE)
270 {
271 fprintf (fp, "%d\n", answer);
272 }
273 else
274 {
275 fprintf (fp, "%s\n", scrollList[answer]);
276 }
277 }
278 fclose (fp);
279
280 CDKfreeStrings(scrollList);
281
282 /* Exit with the button selected. */
283 ExitProgram (selection);
284 }
285
286 static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
287 {
288 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
289 injectCDKButtonbox (buttonbox, key);
290 return (TRUE);
291 }
0 /* $Id: cdkscale.c,v 1.9 2005/12/27 17:27:01 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdkscale";
6 #endif
7
8 /*
9 * Declare file local prototypes.
10 */
11 static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
12
13 /*
14 * Define file local variables.
15 */
16 static char *FPUsage = "-f Field Width -l Low Value -h High Value [-s Initial Value]] [-i Increment Value] [-a Accelerated Increment Value] [-T Title] [-L Label] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-N] [-S]";
17
18 /*
19 *
20 */
21 int main (int argc, char **argv)
22 {
23 /* Declare variables. */
24 CDKSCREEN *cdkScreen = 0;
25 CDKSCALE *widget = 0;
26 CDKBUTTONBOX *buttonWidget = 0;
27 WINDOW *cursesWindow = 0;
28 char *CDK_WIDGET_COLOR = 0;
29 char *temp = 0;
30 chtype *holder = 0;
31 int answer = 0;
32 int buttonCount = 0;
33 int selection = 0;
34 int shadowHeight = 0;
35 FILE *fp = stderr;
36 char **buttonList = 0;
37 int tmp, j1, j2;
38
39 CDK_PARAMS params;
40 boolean boxWidget;
41 boolean shadowWidget;
42 char *buttons;
43 char *label;
44 char *outputFile;
45 char *title;
46 int fieldWidth;
47 int incrementStep;
48 int acceleratedStep;
49 int initValue;
50 int lowValue;
51 int highValue;
52 int xpos;
53 int ypos;
54
55 CDKparseParams(argc, argv, &params, "a:f:h:i:l:s:B:L:O:T:" "X:Y:NS");
56
57 xpos = CDKparamValue(&params, 'X', CENTER);
58 ypos = CDKparamValue(&params, 'Y', CENTER);
59 boxWidget = CDKparamValue(&params, 'N', TRUE);
60 shadowWidget = CDKparamValue(&params, 'S', FALSE);
61
62 acceleratedStep = CDKparamValue(&params, 'a', -1);
63 fieldWidth = CDKparamValue(&params, 'f', 0);
64 highValue = CDKparamValue(&params, 'h', INT_MIN);
65 incrementStep = CDKparamValue(&params, 'i', 1);
66 lowValue = CDKparamValue(&params, 'l', INT_MAX);
67 initValue = CDKparamValue(&params, 's', INT_MIN);
68 buttons = CDKparamString(&params, 'B');
69 label = CDKparamString(&params, 'L');
70 outputFile = CDKparamString(&params, 'O');
71 title = CDKparamString(&params, 'T');
72
73 incrementStep = abs(incrementStep);
74
75 /* Make sure all the command line parameters were provided. */
76 if (fieldWidth <= 0)
77 {
78 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
79 ExitProgram (CLI_ERROR);
80 }
81
82 /* Make sure the user supplied the low/high values. */
83 if ((lowValue == INT_MAX) || (highValue == INT_MIN))
84 {
85 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
86 ExitProgram (CLI_ERROR);
87 }
88
89 /* If the user asked for an output file, try to open it. */
90 if (outputFile != 0)
91 {
92 if ((fp = fopen (outputFile, "w")) == 0)
93 {
94 fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
95 ExitProgram (CLI_ERROR);
96 }
97 }
98
99 /* Make sure the low is lower than the high (and vice versa). */
100 if (lowValue > highValue)
101 {
102 tmp = lowValue;
103 lowValue = highValue;
104 highValue = tmp;
105 }
106
107 /* Make sure the starting value is in range. */
108 if (initValue < lowValue)
109 {
110 initValue = lowValue;
111 }
112 else if (initValue > highValue)
113 {
114 initValue = highValue;
115 }
116
117 /* Check if the accelerated incremnt value was set. */
118 if (acceleratedStep <= 0)
119 {
120 acceleratedStep = (int)((highValue - lowValue) / 10);
121 acceleratedStep = MAXIMUM (1, acceleratedStep);
122 }
123
124 /* Set up CDK. */
125 cursesWindow = initscr();
126 cdkScreen = initCDKScreen (cursesWindow);
127
128 /* Start color. */
129 initCDKColor();
130
131 /* Check if the user wants to set the background of the main screen. */
132 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
133 {
134 holder = char2Chtype (temp, &j1, &j2);
135 wbkgd (cdkScreen->window, holder[0]);
136 wrefresh (cdkScreen->window);
137 freeChtype (holder);
138 }
139
140 /* Get the widget color background color. */
141 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
142 {
143 CDK_WIDGET_COLOR = 0;
144 }
145
146 /* Create the entry widget. */
147 widget = newCDKScale (cdkScreen, xpos, ypos,
148 title, label,
149 A_NORMAL, fieldWidth,
150 initValue, lowValue, highValue,
151 incrementStep, acceleratedStep,
152 boxWidget, shadowWidget);
153
154 /* Check to make sure we created the dialog box. */
155 if (widget == 0)
156 {
157 /* Shut down curses and CDK. */
158 destroyCDKScreen (cdkScreen);
159 endCDK();
160
161 fprintf (stderr, "Error: Could not create the numeric scale field. Is the window too small?\n");
162
163 ExitProgram (CLI_ERROR);
164 }
165
166 /* Split the buttons if they supplied some. */
167 if (buttons != 0)
168 {
169 /* Split the button list up. */
170 buttonList = CDKsplitString (buttons, '\n');
171 buttonCount = CDKcountStrings (buttonList);
172
173 /* We need to create a buttonbox widget. */
174 buttonWidget = newCDKButtonbox (cdkScreen,
175 getbegx (widget->win),
176 getbegy (widget->win) + widget->boxHeight - 1,
177 1, widget->boxWidth - 1,
178 0, 1, buttonCount,
179 buttonList, buttonCount,
180 A_REVERSE, boxWidget, FALSE);
181 CDKfreeStrings (buttonList);
182
183 setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
184 setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
185
186 /*
187 * We need to set the lower left and right
188 * characters of the widget.
189 */
190 setCDKScaleLLChar (widget, ACS_LTEE);
191 setCDKScaleLRChar (widget, ACS_RTEE);
192
193 /*
194 * Bind the Tab key in the widget to send a
195 * Tab key to the button box widget.
196 */
197 bindCDKObject (vSCALE, widget, KEY_TAB, widgetCB, buttonWidget);
198 bindCDKObject (vSCALE, widget, CDK_NEXT, widgetCB, buttonWidget);
199 bindCDKObject (vSCALE, widget, CDK_PREV, widgetCB, buttonWidget);
200
201 /* Check if the user wants to set the background of the widget. */
202 setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
203
204 /* Draw the button widget. */
205 drawCDKButtonbox (buttonWidget, boxWidget);
206 }
207
208 /*
209 * If the user asked for a shadow, we need to create one. Do this instead
210 * of using the shadow parameter because the button widget is not part of
211 * the main widget and if the user asks for both buttons and a shadow, we
212 * need to create a shadow big enough for both widgets. Create the shadow
213 * window using the widgets shadowWin element, so screen refreshes will draw
214 * them as well.
215 */
216 if (shadowWidget == TRUE)
217 {
218 /* Determine the height of the shadow window. */
219 shadowHeight = (buttonWidget == 0 ?
220 widget->boxHeight :
221 widget->boxHeight + buttonWidget->boxHeight - 1);
222
223 /* Create the shadow window. */
224 widget->shadowWin = newwin (shadowHeight,
225 widget->boxWidth,
226 getbegy (widget->win) + 1,
227 getbegx (widget->win) + 1);
228
229 /* Make sure we could have created the shadow window. */
230 if (widget->shadowWin != 0)
231 {
232 widget->shadow = TRUE;
233
234 /*
235 * We force the widget and buttonWidget to be drawn so the
236 * buttonbox widget will be drawn when the widget is activated.
237 * Otherwise the shadow window will draw over the button widget.
238 */
239 drawCDKScale (widget, ObjOf(widget)->box);
240 eraseCDKButtonbox (buttonWidget);
241 drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
242 }
243 }
244
245 /* Check if the user wants to set the background of the widget. */
246 setCDKScaleBackgroundColor (widget, CDK_WIDGET_COLOR);
247
248 /* Activate the widget. */
249 answer = activateCDKScale (widget, 0);
250
251 /* If there were buttons, get the button selected. */
252 if (buttonWidget != 0)
253 {
254 selection = buttonWidget->currentButton;
255 destroyCDKButtonbox (buttonWidget);
256 }
257
258 /* End CDK. */
259 destroyCDKScale (widget);
260 destroyCDKScreen (cdkScreen);
261 endCDK();
262
263 /* Print the value from the widget. */
264 fprintf (fp, "%d\n", answer);
265 fclose (fp);
266
267 /* Exit with the answer. */
268 ExitProgram (selection);
269 }
270
271 static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
272 {
273 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
274 injectCDKButtonbox (buttonbox, key);
275 return (TRUE);
276 }
0 /* $Id: cdkscroll.c,v 1.9 2005/12/27 17:29:58 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdkscroll";
6 #endif
7
8 /*
9 * Declare file local prototypes.
10 */
11 static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
12
13 /*
14 * Define file local variables.
15 */
16 static char *FPUsage = "-l List | -f filename [-s Scroll Bar Position] [-n Numbers] [-i Item Index] [-T Title] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-H Height] [-W Width] [-N] [-S]";
17
18 /*
19 *
20 */
21 int main (int argc, char **argv)
22 {
23 /* Declare variables. */
24 CDKSCREEN *cdkScreen = 0;
25 CDKSCROLL *widget = 0;
26 CDKBUTTONBOX *buttonWidget = 0;
27 WINDOW *cursesWindow = 0;
28 char *CDK_WIDGET_COLOR = 0;
29 char *temp = 0;
30 chtype *holder = 0;
31 int answer = 0;
32 int spos = NONE;
33 int buttonCount = 0;
34 int selection = 0;
35 int scrollLines = -1;
36 int shadowHeight = 0;
37 FILE *fp = stderr;
38 char **scrollList = 0;
39 char **buttonList = 0;
40 int j1, j2;
41
42 CDK_PARAMS params;
43 boolean boxWidget;
44 boolean shadowWidget;
45 char *buttons;
46 char *filename;
47 char *list;
48 char *outputFile;
49 char *title;
50 int height;
51 int numberOutput;
52 int numbers;
53 int width;
54 int xpos;
55 int ypos;
56
57 CDKparseParams(argc, argv, &params, "f:il:ns:B:O:T:" CDK_CLI_PARAMS);
58
59 xpos = CDKparamValue(&params, 'X', CENTER);
60 ypos = CDKparamValue(&params, 'Y', CENTER);
61 height = CDKparamValue(&params, 'H', 1);
62 width = CDKparamValue(&params, 'W', 1);
63 boxWidget = CDKparamValue(&params, 'N', TRUE);
64 shadowWidget = CDKparamValue(&params, 'S', FALSE);
65
66 numberOutput = CDKparamValue(&params, 'i', FALSE);
67 numbers = CDKparamValue(&params, 'n', FALSE);
68 filename = CDKparamString(&params, 'f');
69 list = CDKparamString(&params, 'l');
70 buttons = CDKparamString(&params, 'B');
71 outputFile = CDKparamString(&params, 'O');
72 title = CDKparamString(&params, 'T');
73
74 spos = CDKparsePosition(CDKparamString(&params, 's'));
75
76 /* If the user asked for an output file, try to open it. */
77 if (outputFile != 0)
78 {
79 if ((fp = fopen (outputFile, "w")) == 0)
80 {
81 fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
82 ExitProgram (CLI_ERROR);
83 }
84 }
85
86 /* Did they provide a list of items. */
87 if (list == 0)
88 {
89 /* Maybe they gave a filename to use to read. */
90 if (filename != 0)
91 {
92 /* Read the file in. */
93 scrollLines = CDKreadFile (filename, &scrollList);
94
95 /* Check if there was an error. */
96 if (scrollLines == -1)
97 {
98 fprintf (stderr, "Error: Could not open the file '%s'.\n", filename);
99 ExitProgram (CLI_ERROR);
100 }
101 }
102 else
103 {
104 /* They didn't provide anything. */
105 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
106 ExitProgram (CLI_ERROR);
107 }
108 }
109 else
110 {
111 /* Split the scroll lines up. */
112 scrollList = CDKsplitString (list, '\n');
113 scrollLines = CDKcountStrings (scrollList);
114 }
115
116 /* Start curses. */
117 cursesWindow = initscr();
118
119 /* Create the CDK screen. */
120 cdkScreen = initCDKScreen (cursesWindow);
121
122 /* Start color. */
123 initCDKColor();
124
125 /* Check if the user wants to set the background of the main screen. */
126 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
127 {
128 holder = char2Chtype (temp, &j1, &j2);
129 wbkgd (cdkScreen->window, holder[0]);
130 wrefresh (cdkScreen->window);
131 freeChtype (holder);
132 }
133
134 /* Get the widget color background color. */
135 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
136 {
137 CDK_WIDGET_COLOR = 0;
138 }
139
140 /* Create the scrolling list. */
141 widget = newCDKScroll (cdkScreen, xpos, ypos, spos,
142 height, width, title,
143 scrollList, scrollLines,
144 numbers, A_REVERSE,
145 boxWidget, shadowWidget);
146
147 /* Make sure we could create the widget. */
148 if (widget == 0)
149 {
150 CDKfreeStrings (scrollList);
151
152 destroyCDKScreen (cdkScreen);
153 endCDK();
154
155 fprintf (stderr, "Error: Could not create the scrolling list. Is the window too small?\n");
156
157 ExitProgram (CLI_ERROR);
158 }
159
160 /* Split the buttons if they supplied some. */
161 if (buttons != 0)
162 {
163 /* Split the button list up. */
164 buttonList = CDKsplitString (buttons, '\n');
165 buttonCount = CDKcountStrings (buttonList);
166
167 /* We need to create a buttonbox widget. */
168 buttonWidget = newCDKButtonbox (cdkScreen,
169 getbegx (widget->win),
170 getbegy (widget->win) + widget->boxHeight - 1,
171 1, widget->boxWidth - 1,
172 0, 1, buttonCount,
173 buttonList, buttonCount,
174 A_REVERSE, boxWidget, FALSE);
175 CDKfreeStrings (buttonList);
176
177 setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
178 setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
179
180 /*
181 * We need to set the lower left and right
182 * characters of the widget.
183 */
184 setCDKScrollLLChar (widget, ACS_LTEE);
185 setCDKScrollLRChar (widget, ACS_RTEE);
186
187 /*
188 * Bind the Tab key in the widget to send a
189 * Tab key to the button box widget.
190 */
191 bindCDKObject (vSCROLL, widget, KEY_TAB, widgetCB, buttonWidget);
192 bindCDKObject (vSCROLL, widget, CDK_NEXT, widgetCB, buttonWidget);
193 bindCDKObject (vSCROLL, widget, CDK_PREV, widgetCB, buttonWidget);
194
195 /* Check if the user wants to set the background of the widget. */
196 setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
197
198 /* Draw the button widget. */
199 drawCDKButtonbox (buttonWidget, boxWidget);
200 }
201
202 /*
203 * If the user asked for a shadow, we need to create one. Do this instead
204 * of using the shadow parameter because the button widget is not part of
205 * the main widget and if the user asks for both buttons and a shadow, we
206 * need to create a shadow big enough for both widgets. Create the shadow
207 * window using the widgets shadowWin element, so screen refreshes will draw
208 * them as well.
209 */
210 if (shadowWidget == TRUE)
211 {
212 /* Determine the height of the shadow window. */
213 shadowHeight = (buttonWidget == 0 ?
214 widget->boxHeight :
215 widget->boxHeight + buttonWidget->boxHeight - 1);
216
217 /* Create the shadow window. */
218 widget->shadowWin = newwin (shadowHeight,
219 widget->boxWidth,
220 getbegy (widget->win) + 1,
221 getbegx (widget->win) + 1);
222
223 /* Make sure we could have created the shadow window. */
224 if (widget->shadowWin != 0)
225 {
226 widget->shadow = TRUE;
227
228 /*
229 * We force the widget and buttonWidget to be drawn so the
230 * buttonbox widget will be drawn when the widget is activated.
231 * Otherwise the shadow window will draw over the button widget.
232 */
233 drawCDKScroll (widget, ObjOf(widget)->box);
234 eraseCDKButtonbox (buttonWidget);
235 drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
236 }
237 }
238
239 /* Check if the user wants to set the background of the widget. */
240 setCDKScrollBackgroundColor (widget, CDK_WIDGET_COLOR);
241
242 /* Activate the scrolling list. */
243 answer = activateCDKScroll (widget, 0);
244
245 /* If there were buttons, get the button selected. */
246 if (buttonWidget != 0)
247 {
248 selection = buttonWidget->currentButton;
249 destroyCDKButtonbox (buttonWidget);
250 }
251
252 /* Shut down curses. */
253 destroyCDKScroll (widget);
254 destroyCDKScreen (cdkScreen);
255 endCDK();
256
257 /* Print out the answer. */
258 if (answer >= 0)
259 {
260 if (numberOutput == TRUE)
261 {
262 fprintf (fp, "%d\n", answer);
263 }
264 else
265 {
266 fprintf (fp, "%s\n", scrollList[answer]);
267 }
268 }
269 fclose (fp);
270
271 CDKfreeStrings (scrollList);
272
273 /* Exit with the answer. */
274 ExitProgram (selection);
275 }
276
277 static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
278 {
279 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
280 injectCDKButtonbox (buttonbox, key);
281 return (TRUE);
282 }
0 /* $Id: cdkselection.c,v 1.9 2005/12/27 17:45:21 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdkselection";
6 #endif
7
8 /*
9 * Declare file local prototypes.
10 */
11 static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
12
13 /*
14 * Define file local variables.
15 */
16 static char *FPUsage = "-l List | -f filename [-c Choices ] [-s Selection Bar Position] [-T Title] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-H Height] [-W Width] [-N] [-S]";
17
18 /*
19 *
20 */
21 int main (int argc, char **argv)
22 {
23 /* Declare variables. */
24 CDKSCREEN *cdkScreen = 0;
25 CDKSELECTION *widget = 0;
26 CDKBUTTONBOX *buttonWidget = 0;
27 WINDOW *cursesWindow = 0;
28 chtype *holder = 0;
29 char *item = 0;
30 char *CDK_WIDGET_COLOR = 0;
31 char *temp = 0;
32 int scrollLines = -1;
33 int choiceSize = -1;
34 int buttonCount = 0;
35 int selection = 0;
36 int shadowHeight = 0;
37 FILE *fp = stderr;
38 char **scrollList = 0;
39 char **choiceList = 0;
40 char **buttonList = 0;
41 char **items = 0;
42 int choiceValues[MAX_ITEMS];
43 int editModes[MAX_ITEMS];
44 int x, fields, j1, j2;
45
46 CDK_PARAMS params;
47 boolean boxWidget;
48 boolean shadowWidget;
49 char *buttons;
50 char *choices;
51 char *filename;
52 char *list;
53 char *outputFile;
54 char *title;
55 int height;
56 int numbers;
57 int spos;
58 int width;
59 int xpos;
60 int ypos;
61
62 CDKparseParams(argc, argv, &params, "c:f:ln:s:B:O:T:" CDK_CLI_PARAMS);
63
64 xpos = CDKparamValue(&params, 'X', CENTER);
65 ypos = CDKparamValue(&params, 'Y', CENTER);
66 height = CDKparamValue(&params, 'H', 10);
67 width = CDKparamValue(&params, 'W', 10);
68 boxWidget = CDKparamValue(&params, 'N', TRUE);
69 shadowWidget = CDKparamValue(&params, 'S', FALSE);
70
71 choices = CDKparamString(&params, 'c');
72 filename = CDKparamString(&params, 'f');
73 list = CDKparamString(&params, 'l');
74 buttons = CDKparamString(&params, 'B');
75 outputFile = CDKparamString(&params, 'O');
76 title = CDKparamString(&params, 'T');
77
78 numbers = CDKparamValue(&params, 'n', FALSE);
79
80 spos = CDKparsePosition(CDKparamString(&params, 's'));
81
82 /* If the user asked for an output file, try to open it. */
83 if (outputFile != 0)
84 {
85 if ((fp = fopen (outputFile, "w")) == 0)
86 {
87 fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
88 ExitProgram (CLI_ERROR);
89 }
90 }
91
92 /* Did they provide a list of items. */
93 if (list == 0)
94 {
95 /* Maybe they gave a filename to use to read. */
96 if (filename != 0)
97 {
98 /* Read the file in. */
99 scrollLines = CDKreadFile (filename, &scrollList);
100
101 /* Check if there was an error. */
102 if (scrollLines == -1)
103 {
104 fprintf (stderr, "Error: Could not open the file '%s'.\n", filename);
105 ExitProgram (CLI_ERROR);
106 }
107
108 /*
109 * For each line, we will split on a CTRL-V and look for a selection
110 * value/edit mode. The format of the input file can be the following:
111 * Index value [choice value] [edit flag]
112 */
113 for (x=0; x < scrollLines; x++)
114 {
115 /* Split the line on CTRL-V. */
116 items = CDKsplitString (scrollList[x], CTRL('V'));
117 fields = CDKcountStrings (items);
118
119 /* Check the field count. */
120 if (fields == 1)
121 {
122 choiceValues[x] = 0;
123 editModes[x] = 0;
124 }
125 else if (fields == 2)
126 {
127 freeChar (scrollList[x]);
128 scrollList[x] = copyChar (items[0]);
129
130 choiceValues[x] = (int)atoi (items[1]);
131 editModes[x] = 0;
132 }
133 else if (fields == 3)
134 {
135 freeChar (scrollList[x]);
136 scrollList[x] = copyChar (items[0]);
137
138 choiceValues[x] = (int)atoi (items[1]);
139 editModes[x] = (int)atoi (items[2]);
140 }
141
142 CDKfreeStrings (items);
143 }
144 }
145 else
146 {
147 /* They didn't provide anything. */
148 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
149 ExitProgram (CLI_ERROR);
150 }
151 }
152 else
153 {
154 /* Split the scroll lines up. */
155 scrollList = CDKsplitString (list, '\n');
156 scrollLines = CDKcountStrings (scrollList);
157 }
158
159 /* Did they supply a chopice list. */
160 if (choices == 0)
161 {
162 choiceList[0] = copyChar ("Yes ");
163 choiceList[1] = copyChar ("No ");
164 choiceSize = 2;
165 }
166 else
167 {
168 /* Split the choices up. */
169 choiceList = CDKsplitString (choices, '\n');
170 choiceSize = CDKcountStrings (choiceList);
171 }
172
173 /* Start curses. */
174 cursesWindow = initscr();
175
176 /* Create the CDK screen. */
177 cdkScreen = initCDKScreen (cursesWindow);
178
179 /* Start color. */
180 initCDKColor();
181
182 /* Check if the user wants to set the background of the main screen. */
183 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
184 {
185 holder = char2Chtype (temp, &j1, &j2);
186 wbkgd (cdkScreen->window, holder[0]);
187 wrefresh (cdkScreen->window);
188 freeChtype (holder);
189 }
190
191 /* Get the widget color background color. */
192 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
193 {
194 CDK_WIDGET_COLOR = 0;
195 }
196
197 /* Create the scrolling list. */
198 widget = newCDKSelection (cdkScreen, xpos, ypos, spos,
199 height, width, title,
200 scrollList, scrollLines,
201 choiceList, choiceSize,
202 A_REVERSE,
203 boxWidget, shadowWidget);
204 CDKfreeStrings (choiceList);
205
206 /* Make sure we could create the widget. */
207 if (widget == 0)
208 {
209 CDKfreeStrings (scrollList);
210
211 destroyCDKScreen (cdkScreen);
212 endCDK();
213
214 fprintf (stderr, "Error: Could not create the selection list. Is the window too small?\n");
215
216 ExitProgram (CLI_ERROR);
217 }
218
219 /* Set up the default selection choices. */
220 setCDKSelectionChoices (widget, choiceValues);
221
222 /* Split the buttons if they supplied some. */
223 if (buttons != 0)
224 {
225 /* Split the button list up. */
226 buttonList = CDKsplitString (buttons, '\n');
227 buttonCount = CDKcountStrings (buttonList);
228
229 /* We need to create a buttonbox widget. */
230 buttonWidget = newCDKButtonbox (cdkScreen,
231 getbegx (widget->win),
232 getbegy (widget->win) + widget->boxHeight - 1,
233 1, widget->boxWidth - 1,
234 0, 1, buttonCount,
235 buttonList, buttonCount,
236 A_REVERSE, boxWidget, FALSE);
237 CDKfreeStrings (buttonList);
238
239 setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
240 setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
241
242 /*
243 * We need to set the lower left and right
244 * characters of the widget.
245 */
246 setCDKSelectionLLChar (widget, ACS_LTEE);
247 setCDKSelectionLRChar (widget, ACS_RTEE);
248
249 /*
250 * Bind the Tab key in the widget to send a
251 * Tab key to the button box widget.
252 */
253 bindCDKObject (vSELECTION, widget, KEY_TAB, widgetCB, buttonWidget);
254 bindCDKObject (vSELECTION, widget, CDK_NEXT, widgetCB, buttonWidget);
255 bindCDKObject (vSELECTION, widget, CDK_PREV, widgetCB, buttonWidget);
256
257 /* Check if the user wants to set the background of the widget. */
258 setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
259
260 /* Draw the button widget. */
261 drawCDKButtonbox (buttonWidget, boxWidget);
262 }
263
264 /*
265 * If the user asked for a shadow, we need to create one. Do this instead
266 * of using the shadow parameter because the button widget is not part of
267 * the main widget and if the user asks for both buttons and a shadow, we
268 * need to create a shadow big enough for both widgets. Create the shadow
269 * window using the widgets shadowWin element, so screen refreshes will draw
270 * them as well.
271 */
272 if (shadowWidget == TRUE)
273 {
274 /* Determine the height of the shadow window. */
275 shadowHeight = (buttonWidget == 0 ?
276 widget->boxHeight :
277 widget->boxHeight + buttonWidget->boxHeight - 1);
278
279 /* Create the shadow window. */
280 widget->shadowWin = newwin (shadowHeight,
281 widget->boxWidth,
282 getbegy (widget->win) + 1,
283 getbegx (widget->win) + 1);
284
285 /* Make sure we could have created the shadow window. */
286 if (widget->shadowWin != 0)
287 {
288 widget->shadow = TRUE;
289
290 /*
291 * We force the widget and buttonWidget to be drawn so the
292 * buttonbox widget will be drawn when the widget is activated.
293 * Otherwise the shadow window will draw over the button widget.
294 */
295 drawCDKSelection (widget, ObjOf(widget)->box);
296 eraseCDKButtonbox (buttonWidget);
297 drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
298 }
299 }
300
301 /* Check if the user wants to set the background of the widget. */
302 setCDKSelectionBackgroundColor (widget, CDK_WIDGET_COLOR);
303
304 /* Set up the default selection modes. */
305 setCDKSelectionModes (widget, editModes);
306
307 /* Activate the selection list. */
308 activateCDKSelection (widget, 0);
309
310 /* If there were buttons, get the button selected. */
311 if (buttonWidget != 0)
312 {
313 selection = buttonWidget->currentButton;
314 destroyCDKButtonbox (buttonWidget);
315 }
316
317 /* Print out the answer. */
318 for (x=0; x < scrollLines; x++)
319 {
320 holder = char2Chtype (scrollList[x], &j1, &j2);
321 item = chtype2Char (holder);
322 fprintf (fp, "%d %s\n", widget->selections[x], item);
323 freeChtype (holder);
324 freeChar (item);
325 }
326
327 CDKfreeStrings (scrollList);
328
329 /* Shut down curses. */
330 destroyCDKSelection (widget);
331 destroyCDKScreen (cdkScreen);
332 endCDK();
333 ExitProgram (selection);
334 }
335
336 static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
337 {
338 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
339 injectCDKButtonbox (buttonbox, key);
340 return (TRUE);
341 }
0 /* $Id: cdkslider.c,v 1.9 2005/12/27 17:47:12 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdkslider";
6 #endif
7
8 /*
9 * Declare file local prototypes.
10 */
11 static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
12
13 /*
14 * Define file local variables.
15 */
16 static char *FPUsage = "-f Field Width -l Low Value -h High Value [-s Initial Value]] [-i Increment Value] [-a Accelerated Increment Value] [-F Field Character] [-T Title] [-L Label] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-N] [-S]";
17
18 /*
19 *
20 */
21 int main (int argc, char **argv)
22 {
23 /* Declare variables. */
24 CDKSCREEN *cdkScreen = 0;
25 CDKSLIDER *widget = 0;
26 CDKBUTTONBOX *buttonWidget = 0;
27 WINDOW *cursesWindow = 0;
28 char *CDK_WIDGET_COLOR = 0;
29 char *temp = 0;
30 chtype *holder = 0;
31 chtype fieldAttr = A_REVERSE | ' ';
32 int answer = 0;
33 int buttonCount = 0;
34 int selection = 0;
35 int shadowHeight = 0;
36 FILE *fp = stderr;
37 char **buttonList = 0;
38 int j1, j2, tmp;
39
40 CDK_PARAMS params;
41 boolean boxWidget;
42 boolean shadowWidget;
43 char *barAttribute;
44 char *buttons;
45 char *label;
46 char *outputFile;
47 char *title;
48 int fieldWidth;
49 int incrementStep;
50 int acceleratedStep;
51 int initValue;
52 int lowValue;
53 int highValue;
54 int xpos;
55 int ypos;
56
57 CDKparseParams(argc, argv, &params, "a:f:h:i:l:s:B:F:L:O:T:" "X:Y:NS");
58
59 xpos = CDKparamValue(&params, 'X', CENTER);
60 ypos = CDKparamValue(&params, 'Y', CENTER);
61 boxWidget = CDKparamValue(&params, 'N', TRUE);
62 shadowWidget = CDKparamValue(&params, 'S', FALSE);
63
64 acceleratedStep = CDKparamValue(&params, 'a', -1);
65 fieldWidth = CDKparamValue(&params, 'f', 0);
66 highValue = CDKparamValue(&params, 'h', INT_MIN);
67 incrementStep = CDKparamValue(&params, 'i', 1);
68 lowValue = CDKparamValue(&params, 'l', INT_MAX);
69 initValue = CDKparamValue(&params, 's', INT_MIN);
70 buttons = CDKparamString(&params, 'B');
71 barAttribute = CDKparamString(&params, 'F');
72 label = CDKparamString(&params, 'L');
73 outputFile = CDKparamString(&params, 'O');
74 title = CDKparamString(&params, 'T');
75
76 incrementStep = abs(incrementStep);
77
78 /* Make sure all the command line parameters were provided. */
79 if (fieldWidth <= 0)
80 {
81 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
82 ExitProgram (CLI_ERROR);
83 }
84
85 /* Make sure the user supplied the low/high values. */
86 if ((lowValue == INT_MAX) || (highValue == INT_MIN))
87 {
88 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
89 ExitProgram (CLI_ERROR);
90 }
91
92 /* If the user asked for an output file, try to open it. */
93 if (outputFile != 0)
94 {
95 if ((fp = fopen (outputFile, "w")) == 0)
96 {
97 fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
98 ExitProgram (CLI_ERROR);
99 }
100 }
101
102 /* Make sure the low is lower than the high (and vice versa). */
103 if (lowValue > highValue)
104 {
105 tmp = lowValue;
106 lowValue = highValue;
107 highValue = tmp;
108 }
109
110 /* Make sure the starting value is in range. */
111 if (initValue < lowValue)
112 {
113 initValue = lowValue;
114 }
115 else if (initValue > highValue)
116 {
117 initValue = highValue;
118 }
119
120 /* Check if the accelerated incremnt value was set. */
121 if (acceleratedStep <= 0)
122 {
123 acceleratedStep = (int)((highValue - lowValue) / 10);
124 acceleratedStep = MAXIMUM (1, acceleratedStep);
125 }
126
127 /* Set up CDK. */
128 cursesWindow = initscr();
129 cdkScreen = initCDKScreen (cursesWindow);
130
131 /* Start color. */
132 initCDKColor();
133
134 /* Check if the user wants to set the background of the main screen. */
135 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
136 {
137 holder = char2Chtype (temp, &j1, &j2);
138 wbkgd (cdkScreen->window, holder[0]);
139 wrefresh (cdkScreen->window);
140 freeChtype (holder);
141 }
142
143 /* Get the widget color background color. */
144 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
145 {
146 CDK_WIDGET_COLOR = 0;
147 }
148
149 /* Did the user ask to change the bar attribute? */
150 if (barAttribute != 0)
151 {
152 holder = char2Chtype (barAttribute, &j1, &j2);
153 fieldAttr = holder[0];
154 freeChtype (holder);
155 }
156
157 /* Create the entry widget. */
158 widget = newCDKSlider (cdkScreen, xpos, ypos,
159 title, label,
160 fieldAttr, fieldWidth,
161 initValue, lowValue, highValue,
162 incrementStep, acceleratedStep,
163 boxWidget, shadowWidget);
164
165 /* Check to make sure we created the dialog box. */
166 if (widget == 0)
167 {
168 /* Shut down curses and CDK. */
169 destroyCDKScreen (cdkScreen);
170 endCDK();
171
172 fprintf (stderr, "Error: Could not create the numeric slider field. Is the window too small?\n");
173
174 ExitProgram (CLI_ERROR);
175 }
176
177 /* Split the buttons if they supplied some. */
178 if (buttons != 0)
179 {
180 /* Split the button list up. */
181 buttonList = CDKsplitString (buttons, '\n');
182 buttonCount = CDKcountStrings (buttonList);
183
184 /* We need to create a buttonbox widget. */
185 buttonWidget = newCDKButtonbox (cdkScreen,
186 getbegx (widget->win),
187 getbegy (widget->win) + widget->boxHeight - 1,
188 1, widget->boxWidth - 1,
189 0, 1, buttonCount,
190 buttonList, buttonCount,
191 A_REVERSE, boxWidget, FALSE);
192 CDKfreeStrings (buttonList);
193
194 setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
195 setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
196
197 /*
198 * We need to set the lower left and right
199 * characters of the widget.
200 */
201 setCDKSliderLLChar (widget, ACS_LTEE);
202 setCDKSliderLRChar (widget, ACS_RTEE);
203
204 /*
205 * Bind the Tab key in the widget to send a
206 * Tab key to the button box widget.
207 */
208 bindCDKObject (vSLIDER, widget, KEY_TAB, widgetCB, buttonWidget);
209 bindCDKObject (vSLIDER, widget, CDK_NEXT, widgetCB, buttonWidget);
210 bindCDKObject (vSLIDER, widget, CDK_PREV, widgetCB, buttonWidget);
211
212 /* Check if the user wants to set the background of the widget. */
213 setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
214
215 /* Draw the button widget. */
216 drawCDKButtonbox (buttonWidget, boxWidget);
217 }
218
219 /*
220 * If the user asked for a shadow, we need to create one. Do this instead
221 * of using the shadow parameter because the button widget is not part of
222 * the main widget and if the user asks for both buttons and a shadow, we
223 * need to create a shadow big enough for both widgets. Create the shadow
224 * window using the widgets shadowWin element, so screen refreshes will draw
225 * them as well.
226 */
227 if (shadowWidget == TRUE)
228 {
229 /* Determine the height of the shadow window. */
230 shadowHeight = (buttonWidget == 0 ?
231 widget->boxHeight :
232 widget->boxHeight + buttonWidget->boxHeight - 1);
233
234 /* Create the shadow window. */
235 widget->shadowWin = newwin (shadowHeight,
236 widget->boxWidth,
237 getbegy (widget->win) + 1,
238 getbegx (widget->win) + 1);
239
240 /* Make sure we could have created the shadow window. */
241 if (widget->shadowWin != 0)
242 {
243 widget->shadow = TRUE;
244
245 /*
246 * We force the widget and buttonWidget to be drawn so the
247 * buttonbox widget will be drawn when the widget is activated.
248 * Otherwise the shadow window will draw over the button widget.
249 */
250 drawCDKSlider (widget, ObjOf(widget)->box);
251 eraseCDKButtonbox (buttonWidget);
252 drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
253 }
254 }
255
256 /* Check if the user wants to set the background of the widget. */
257 setCDKSliderBackgroundColor (widget, CDK_WIDGET_COLOR);
258
259 /* Activate the widget. */
260 answer = activateCDKSlider (widget, 0);
261
262 /* If there were buttons, get the button selected. */
263 if (buttonWidget != 0)
264 {
265 selection = buttonWidget->currentButton;
266 destroyCDKButtonbox (buttonWidget);
267 }
268
269 /* End CDK. */
270 destroyCDKSlider (widget);
271 destroyCDKScreen (cdkScreen);
272 endCDK();
273
274 /* Print the value from the widget. */
275 fprintf (fp, "%d\n", answer);
276 fclose (fp);
277
278 /* Exit with the button selected. */
279 ExitProgram (selection);
280 }
281
282 static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
283 {
284 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
285 injectCDKButtonbox (buttonbox, key);
286 return (TRUE);
287 }
0 /* $Id: cdktemplate.c,v 1.9 2005/12/27 17:49:32 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdktemplate";
6 #endif
7
8 /*
9 * Declare file local prototypes.
10 */
11 static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
12
13 /*
14 * Define file local variables.
15 */
16 static char *FPUsage = "-p Plate [-o Overlay] [-P Mix Plate] [-d Default Answer] [-m Minimum Length] [-T Title] [-L Label] [-B Buttons] [-O Output file] [-X X Position] [-Y Y Position] [-N] [-S]";
17
18 /*
19 *
20 */
21 int main (int argc, char **argv)
22 {
23 /* Declare variables. */
24 CDKSCREEN *cdkScreen = 0;
25 CDKTEMPLATE *widget = 0;
26 CDKBUTTONBOX *buttonWidget = 0;
27 WINDOW *cursesWindow = 0;
28 char *answer = 0;
29 char *tmp = 0;
30 char *CDK_WIDGET_COLOR = 0;
31 char *temp = 0;
32 chtype *holder = 0;
33 int buttonCount = 0;
34 int selection = 0;
35 int shadowHeight = 0;
36 FILE *fp = stderr;
37 char **buttonList = 0;
38 int j1, j2;
39
40 CDK_PARAMS params;
41 boolean boxWidget;
42 boolean mixPlate;
43 boolean shadowWidget;
44 char *buttons;
45 char *defaultAnswer;
46 char *label;
47 char *my_overlay;
48 char *outputFile;
49 char *plate;
50 char *title;
51 int minimum;
52 int xpos;
53 int ypos;
54
55 CDKparseParams(argc, argv, &params, "d:m:o:p:B:L:O:P:T:" "X:Y:NS");
56
57 xpos = CDKparamValue(&params, 'X', CENTER);
58 ypos = CDKparamValue(&params, 'Y', CENTER);
59 boxWidget = CDKparamValue(&params, 'N', TRUE);
60 shadowWidget = CDKparamValue(&params, 'S', FALSE);
61
62 minimum = CDKparamValue(&params, 'm', 0);
63 mixPlate = CDKparamValue(&params, 'P', FALSE);
64 defaultAnswer = CDKparamString(&params, 'd');
65 my_overlay = CDKparamString(&params, 'o');
66 plate = CDKparamString(&params, 'p');
67 buttons = CDKparamString(&params, 'B');
68 label = CDKparamString(&params, 'L');
69 outputFile = CDKparamString(&params, 'O');
70 title = CDKparamString(&params, 'T');
71
72 /* Make sure all the command line parameters were provided. */
73 if (plate == 0)
74 {
75 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
76 ExitProgram (CLI_ERROR);
77 }
78
79 /* If the user asked for an output file, try to open it. */
80 if (outputFile != 0)
81 {
82 if ((fp = fopen (outputFile, "w")) == 0)
83 {
84 fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
85 ExitProgram (CLI_ERROR);
86 }
87 }
88
89 /* Set up CDK. */
90 cursesWindow = initscr();
91 cdkScreen = initCDKScreen (cursesWindow);
92
93 /* Start color. */
94 initCDKColor();
95
96 /* Check if the user wants to set the background of the main screen. */
97 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
98 {
99 holder = char2Chtype (temp, &j1, &j2);
100 wbkgd (cdkScreen->window, holder[0]);
101 wrefresh (cdkScreen->window);
102 freeChtype (holder);
103 }
104
105 /* Get the widget color background color. */
106 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
107 {
108 CDK_WIDGET_COLOR = 0;
109 }
110
111 /* Create the template widget. */
112 widget = newCDKTemplate (cdkScreen, xpos, ypos,
113 title, label,
114 plate, my_overlay,
115 boxWidget, shadowWidget);
116
117 /* Check to make sure we created the widget. */
118 if (widget == 0)
119 {
120 /* Shut down curses and CDK. */
121 destroyCDKScreen (cdkScreen);
122 endCDK();
123
124 fprintf (stderr, "Error: Could not create the template field. Is the window too small?\n");
125
126 ExitProgram (CLI_ERROR);
127 }
128
129 /* Split the buttons if they supplied some. */
130 if (buttons != 0)
131 {
132 /* Split the button list up. */
133 buttonList = CDKsplitString (buttons, '\n');
134 buttonCount = CDKcountStrings (buttonList);
135
136 /* We need to create a buttonbox widget. */
137 buttonWidget = newCDKButtonbox (cdkScreen,
138 getbegx (widget->win),
139 getbegy (widget->win) + widget->boxHeight - 1,
140 1, widget->boxWidth - 1,
141 0, 1, buttonCount,
142 buttonList, buttonCount,
143 A_REVERSE, boxWidget, FALSE);
144 setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
145 setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
146
147 /*
148 * We need to set the lower left and right
149 * characters of the widget.
150 */
151 setCDKTemplateLLChar (widget, ACS_LTEE);
152 setCDKTemplateLRChar (widget, ACS_RTEE);
153
154 /*
155 * Bind the Tab key in the widget to send a
156 * Tab key to the button box widget.
157 */
158 bindCDKObject (vTEMPLATE, widget, KEY_TAB, widgetCB, buttonWidget);
159 bindCDKObject (vTEMPLATE, widget, CDK_NEXT, widgetCB, buttonWidget);
160 bindCDKObject (vTEMPLATE, widget, CDK_PREV, widgetCB, buttonWidget);
161
162 /* Check if the user wants to set the background of the widget. */
163 setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
164
165 /* Draw the button widget. */
166 drawCDKButtonbox (buttonWidget, boxWidget);
167 }
168
169 /*
170 * If the user asked for a shadow, we need to create one. Do this instead
171 * of using the shadow parameter because the button widget is not part of
172 * the main widget and if the user asks for both buttons and a shadow, we
173 * need to create a shadow big enough for both widgets. Create the shadow
174 * window using the widgets shadowWin element, so screen refreshes will draw
175 * them as well.
176 */
177 if (shadowWidget == TRUE)
178 {
179 /* Determine the height of the shadow window. */
180 shadowHeight = (buttonWidget == 0 ?
181 widget->boxHeight :
182 widget->boxHeight + buttonWidget->boxHeight - 1);
183
184 /* Create the shadow window. */
185 widget->shadowWin = newwin (shadowHeight,
186 widget->boxWidth,
187 getbegy (widget->win) + 1,
188 getbegx (widget->win) + 1);
189
190 /* Make sure we could have created the shadow window. */
191 if (widget->shadowWin != 0)
192 {
193 widget->shadow = TRUE;
194
195 /*
196 * We force the widget and buttonWidget to be drawn so the
197 * buttonbox widget will be drawn when the widget is activated.
198 * Otherwise the shadow window will draw over the button widget.
199 */
200 drawCDKTemplate (widget, ObjOf(widget)->box);
201 eraseCDKButtonbox (buttonWidget);
202 drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
203 }
204 }
205
206 /* Check if the user wants to set the background of the widget. */
207 setCDKTemplateBackgroundColor (widget, CDK_WIDGET_COLOR);
208
209 /* If a default answer were proivded, set it in the widget. */
210 if (defaultAnswer != 0)
211 {
212 setCDKTemplateValue (widget, defaultAnswer);
213 }
214
215 /* If the user asked for a minimum value, set it. */
216 setCDKTemplateMin (widget, minimum);
217
218 /* Activate the widget. */
219 tmp = activateCDKTemplate (widget, 0);
220
221 /* If the user asked for plate mixing, give it to them. */
222 if (mixPlate == TRUE)
223 {
224 answer = mixCDKTemplate (widget);
225 }
226 else
227 {
228 answer = copyChar (tmp);
229 }
230
231 /* If there were buttons, get the button selected. */
232 if (buttonWidget != 0)
233 {
234 selection = buttonWidget->currentButton;
235 destroyCDKButtonbox (buttonWidget);
236 }
237
238 /* End CDK. */
239 destroyCDKTemplate (widget);
240 destroyCDKScreen (cdkScreen);
241 endCDK();
242
243 /* Print the value from the widget. */
244 if (answer != 0)
245 {
246 fprintf (fp, "%s\n", answer);
247 freeChar (answer);
248 }
249 fclose (fp);
250
251 /* Exit with the button number picked. */
252 ExitProgram (selection);
253 }
254
255 static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
256 {
257 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
258 injectCDKButtonbox (buttonbox, key);
259 return (TRUE);
260 }
0 /* $Id: cdkviewer.c,v 1.10 2005/12/27 17:54:31 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef XCURSES
5 char *XCursesProgramName="cdkviewer";
6 #endif
7
8 /*
9 * Declare file local prototypes.
10 */
11 static void saveInformation (CDKVIEWER *widget);
12 static int dumpViewer (CDKVIEWER *widget, char *filename);
13 static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
14
15 /*
16 * Define file local variables.
17 */
18 static char *FPUsage = "-f filename [-i Interpret] [-l Show Line Stats] [-T Title] [-B Buttons] [-X X Position] [-Y Y Position] [-H Height] [-W Width] [-N] [-S]";
19
20 /*
21 *
22 */
23 int main (int argc, char **argv)
24 {
25 /* Declare variables. */
26 CDKSCREEN *cdkScreen = 0;
27 CDKVIEWER *widget = 0;
28 WINDOW *cursesWindow = 0;
29 char *filename = 0;
30 char *CDK_WIDGET_COLOR = 0;
31 char *temp = 0;
32 chtype *holder = 0;
33 int answer = 0;
34 int messageLines = -1;
35 int buttonCount = 0;
36 char **messageList = 0;
37 char **buttonList = 0;
38 char tempTitle[256];
39 int j1, j2;
40
41 CDK_PARAMS params;
42 boolean boxWidget;
43 boolean interpret;
44 boolean shadowWidget;
45 boolean showInfoLine;
46 char *buttons;
47 char *title;
48 int height;
49 int width;
50 int xpos;
51 int ypos;
52
53 CDKparseParams(argc, argv, &params, "f:il:B:T:" CDK_CLI_PARAMS);
54
55 xpos = CDKparamValue(&params, 'X', CENTER);
56 ypos = CDKparamValue(&params, 'Y', CENTER);
57 height = CDKparamValue(&params, 'H', 20);
58 width = CDKparamValue(&params, 'W', 60);
59 boxWidget = CDKparamValue(&params, 'N', TRUE);
60 shadowWidget = CDKparamValue(&params, 'S', FALSE);
61
62 interpret = CDKparamValue(&params, 'i', FALSE);
63 showInfoLine = CDKparamValue(&params, 'l', FALSE);
64 filename = CDKparamString(&params, 'f');
65 buttons = CDKparamString(&params, 'B');
66 title = CDKparamString(&params, 'T');
67
68 /* Make sure they gave us a file to read. */
69 if (filename == 0)
70 {
71 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
72 ExitProgram (CLI_ERROR);
73 }
74
75 /* Read the file in. */
76 messageLines = CDKreadFile (filename, &messageList);
77
78 /* Check if there was an error. */
79 if (messageLines == -1)
80 {
81 fprintf (stderr, "Error: Could not open the file %s\n", filename);
82 ExitProgram (CLI_ERROR);
83 }
84
85 /* Set up the buttons of the viewer. */
86 if (buttons == 0)
87 {
88 buttonList[0] = copyChar ("OK");
89 buttonList[1] = copyChar ("Cancel");
90 buttonCount = 2;
91 }
92 else
93 {
94 /* Split the button list up. */
95 buttonList = CDKsplitString (buttons, '\n');
96 buttonCount = CDKcountStrings (buttonList);
97 }
98
99 /* Set up the title of the viewer. */
100 if (title == 0)
101 {
102 sprintf (tempTitle, "<C>Filename: </U>%s<!U>", filename);
103 title = copyChar (tempTitle);
104 }
105
106 /* Set up CDK. */
107 cursesWindow = initscr();
108 cdkScreen = initCDKScreen (cursesWindow);
109
110 /* Start color. */
111 initCDKColor();
112
113 /* Check if the user wants to set the background of the main screen. */
114 if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
115 {
116 holder = char2Chtype (temp, &j1, &j2);
117 wbkgd (cdkScreen->window, holder[0]);
118 wrefresh (cdkScreen->window);
119 freeChtype (holder);
120 }
121
122 /* Get the widget color background color. */
123 if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
124 {
125 CDK_WIDGET_COLOR = 0;
126 }
127
128 /* Create the viewer widget. */
129 widget = newCDKViewer (cdkScreen, xpos, ypos, height, width,
130 buttonList, buttonCount, A_REVERSE,
131 boxWidget, shadowWidget);
132
133 /* Check to make sure we created the file viewer. */
134 if (widget == 0)
135 {
136 CDKfreeStrings (messageList);
137 CDKfreeStrings (buttonList);
138
139 /* Shut down curses and CDK. */
140 destroyCDKScreen (cdkScreen);
141 endCDK();
142
143 fprintf (stderr, "Error: Could not create the file viewer. Is the window too small?\n");
144
145 ExitProgram (CLI_ERROR);
146 }
147
148 /* Check if the user wants to set the background of the widget. */
149 setCDKViewerBackgroundColor (widget, CDK_WIDGET_COLOR);
150
151 /* Set a binding for saving the info. */
152 bindCDKObject (vVIEWER, widget, 'S', widgetCB, 0);
153
154 /* Set the information needed for the viewer. */
155 setCDKViewer (widget, title, messageList, messageLines,
156 A_REVERSE, interpret, showInfoLine, TRUE);
157
158 /* Activate the viewer. */
159 answer = activateCDKViewer (widget, 0);
160
161 CDKfreeStrings (messageList);
162 CDKfreeStrings (buttonList);
163
164 destroyCDKViewer (widget);
165 destroyCDKScreen (cdkScreen);
166 endCDK();
167
168 /* Exit with the button number picked. */
169 ExitProgram (answer);
170 }
171
172 /*
173 * This function allows the user to dump the
174 * information from the viewer into a file.
175 */
176 static void saveInformation (CDKVIEWER *widget)
177 {
178 /* Declare local variables. */
179 CDKENTRY *entry = 0;
180 char *filename = 0;
181 char temp[256], *mesg[10];
182 int linesSaved;
183
184 /* Create the entry field to get the filename. */
185 entry = newCDKEntry (ScreenOf(widget), CENTER, CENTER,
186 "<C></B/5>Enter the filename of the save file.",
187 "Filename: ",
188 A_NORMAL, '_', vMIXED,
189 20, 1, 256,
190 TRUE, FALSE);
191
192 /* Get the filename. */
193 filename = activateCDKEntry (entry, 0);
194
195 /* Did they hit escape? */
196 if (entry->exitType == vESCAPE_HIT)
197 {
198 /* Popup a message. */
199 mesg[0] = "<C></B/5>Save Canceled.";
200 mesg[1] = "<C>Escape hit. Scrolling window information not saved.";
201 mesg[2] = " ";
202 mesg[3] = "<C>Press any key to continue.";
203 popupLabel (ScreenOf(widget), mesg, 4);
204
205 destroyCDKEntry (entry);
206 return;
207 }
208
209 /* Write the contents of the viewer to the file. */
210 linesSaved = dumpViewer (widget, filename);
211
212 /* Was the save successful? */
213 if (linesSaved == -1)
214 {
215 /* Nope, tell 'em. */
216 mesg[0] = "<C></B/16>Error";
217 mesg[1] = "<C>Could not save to the file.";
218 sprintf (temp, "<C>(%s)", filename);
219 mesg[2] = copyChar (temp);
220 mesg[3] = " ";
221 mesg[4] = "<C>Press any key to continue.";
222 popupLabel (ScreenOf(widget), mesg, 5);
223 freeChar (mesg[2]);
224 }
225 else
226 {
227 mesg[0] = "<C></B/5>Save Successful";
228 sprintf (temp, "<C>There were %d lines saved to the file", linesSaved);
229 mesg[1] = copyChar (temp);
230 sprintf (temp, "<C>(%s)", filename);
231 mesg[2] = copyChar (temp);
232 mesg[3] = " ";
233 mesg[4] = "<C>Press any key to continue.";
234 popupLabel (ScreenOf(widget), mesg, 5);
235 freeChar (mesg[1]); freeChar (mesg[2]);
236 }
237
238 destroyCDKEntry (entry);
239 eraseCDKScreen (ScreenOf(widget));
240 drawCDKScreen (ScreenOf(widget));
241 }
242
243 /*
244 * This actually dumps the information from the viewer to a file.
245 */
246 static int dumpViewer (CDKVIEWER *widget, char *filename)
247 {
248 /* Declare local variables. */
249 FILE *outputFile = 0;
250 char *rawLine = 0;
251 int listSize;
252 chtype **list = getCDKViewerInfo (widget, &listSize);
253 int x;
254
255 /* Try to open the file. */
256 if ((outputFile = fopen (filename, "w")) == 0)
257 {
258 return -1;
259 }
260
261 /* Start writing out the file. */
262 for (x=0; x < listSize; x++)
263 {
264 rawLine = chtype2Char (list[x]);
265 fprintf (outputFile, "%s\n", rawLine);
266 freeChar (rawLine);
267 }
268
269 /* Close the file and return the number of lines written. */
270 fclose (outputFile);
271 return listSize;
272 }
273
274 static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object, void *clientData GCC_UNUSED, chtype key GCC_UNUSED)
275 {
276 CDKVIEWER *widget = (CDKVIEWER *)object;
277 saveInformation (widget);
278 return (TRUE);
279 }
0 #!/bin/sh
1 # $Id: alphalist.sh,v 1.7 2005/12/27 16:04:57 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the alphalist widget.
7 #
8
9 #
10 # This gets the password file.
11 #
12 getPasswordFile()
13 {
14 system=$1
15 file=$2
16
17 #
18 # Depeding on the system, get the password file
19 # using nicat, ypcat, or just plain old /etc/passwd
20 #
21 if [ "$system" = "NIS" ]; then
22 niscat passwd.org_dir > $file
23 elif [ "$system" = "YP" ]; then
24 ypcat passwd > $file
25 else
26 cp /etc/passwd $file
27 fi
28 }
29
30 #
31 # This displays account information.
32 #
33 displayAccountInformation()
34 {
35 userAccount=$1
36 passwordFile=$2
37
38 #
39 # Get the user account information.
40 #
41 line=`grep "^${userAccount}" $passwordFile`
42 uid=`echo $line | cut -d: -f3`
43 gid=`echo $line | cut -d: -f4`
44 info=`echo $line | cut -d: -f5`
45 home=`echo $line | cut -d: -f6`
46 shell=`echo $line | cut -d: -f7`
47
48 #
49 # Create the label message information.
50 #
51 accountMessage="<C></U>Account
52 <C><#HL(30)>
53 Account: </U>${userAccount}
54 UID : </U>${uid}
55 GID : </U>${gid}
56 Info : </U>${info}
57 Home : </U>${home}
58 Shell : </U>${shell}
59 <C><#HL(30)>
60 <C>Hit </R>space<!R> to continue"
61
62 #
63 # Create the popup label.
64 #
65 ${CDK_LABEL} -m "${accountMessage}" -p " "
66 }
67
68 #
69 # Create some global variables.
70 #
71 CDK_ALPHALIST="${CDK_BINDIR=..}/cdkalphalist"
72 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
73
74 tmpPass="${TMPDIR=/tmp}/sl.$$"
75 output="${TMPDIR=/tmp}/alphalist.$$"
76 userAccounts="${TMPDIR=/tmp}/ua.$$"
77
78 #
79 # Create the message for the scrolling list.
80 #
81 title="<C>Pick an account
82 <C>you want to view."
83
84 #
85 # Get the password file and stick it into the temp file.
86 #
87 #getPasswordFile "YP" "$tmpPass"
88 #getPasswordFile "NIS" "$tmpPass"
89 getPasswordFile "Other" "$tmpPass"
90
91 #
92 # Get the user account from the password file.
93 #
94 awk 'BEGIN {FS=":"} {printf "%s\n", $1}' $tmpPass | sort > ${userAccounts}
95
96 #
97 # Create the scrolling list.
98 #
99 ${CDK_ALPHALIST} -T "${title}" -f ${userAccounts} -H -10 -W -20 2> ${output}
100 selected=$?
101 test $selected = 255 && exit 1
102
103 answer=`sed -e 's/^[ ]*//' -e 's/[ ]*$//' ${output}`
104
105 #
106 # Display the account information.
107 #
108 if [ -n "$answer" ]; then
109 displayAccountInformation $answer $tmpPass
110 fi
111
112 #
113 # Clean up.
114 #
115 rm -f ${output} ${tmpPass} ${userAccounts}
0 #!/bin/sh
1 # $Id: calendar.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the celendar widget.
7 #
8
9 #
10 # Create some global variables.
11 #
12 CDK_CALENDAR="${CDK_BINDIR=..}/cdkcalendar"
13 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
14
15 date="${TMPDIR=/tmp}/cal.$$"
16 tmp="${TMPDIR=/tmp}/tmp.$$"
17
18 xpos=CENTER
19 ypos=CENTER
20
21 #
22 # Get today's date.
23 #
24 day=`date +%d`
25 month=`date +%m`
26 year=`date +%Y`
27
28 #
29 # Chop up the command line.
30 #
31 set -- `getopt d:m:y:X:Y: $*`
32 if [ $? != 0 ]
33 then
34 echo $USAGE
35 exit 2
36 fi
37 for c in $*
38 do
39 case $c in
40 -d) day=$2; shift 2;;
41 -m) month=$2; shift 2;;
42 -y) year=$2; shift 2;;
43 -X) xpos=$2; shift 2;;
44 -Y) ypos=$2; shift 2;;
45 --) shift; break;;
46 esac
47 done
48
49 #
50 # Create the title and buttons.
51 #
52 title="<C><#HL(22)>
53 <C>Select a date
54 <C><#HL(22)>"
55 buttons=" OK
56 Cancel "
57
58 #
59 # Create the calendar widget.
60 #
61 ${CDK_CALENDAR} -B "${buttons}" -d ${day} -m ${month} -y ${year} -T "${title}" -X ${xpos} -Y ${ypos} -O ${date} -S
62 selected=$?
63 test $selected = 255 && exit 1
64
65 answer=`cat ${date}`
66
67 #
68 # Create the message for the label widget.
69 #
70 echo "<C>You chose the following date" > ${tmp}
71 echo " " >> ${tmp}
72 echo "<C><#HL(10)>" >> ${tmp}
73 echo "<C>${answer}" >> ${tmp}
74 echo "<C><#HL(10)>" >> ${tmp}
75 echo " " >> ${tmp}
76 echo "<C>You chose button #${selected}" >> ${tmp}
77 echo " " >> ${tmp}
78 echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
79
80 #
81 # Create the label widget to display the information.
82 #
83 ${CDK_LABEL} -f ${tmp} -p " "
84
85 #
86 # Clean up.
87 #
88 rm -f ${tmp} ${date}
0 #!/bin/sh
1 # $Id: dialog.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the dialog widget.
7 #
8
9 #
10 # Create some global variables.
11 #
12 CDK_DIALOG="${CDK_BINDIR=..}/cdkdialog"
13 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
14
15 output="${TMPDIR=/tmp}/dialog_output.$$"
16 tmp="${TMPDIR=/tmp}/tmp.$$"
17
18 #
19 # Create the message for the scrolling list.
20 #
21 message="<C>Pick which command
22 <C>you wish to run."
23
24 #
25 # Create the button labels.
26 #
27 commands="</B>who
28 </B>w
29 </B>uptime
30 </B>date
31 </B>pwd
32 </B>whoami
33 </B>df
34 </B>fortune"
35
36 #
37 # Create the dialog box.
38 #
39 ${CDK_DIALOG} -m "${message}" -B "${commands}" 2> ${output}
40 selection=$?
41 if [ "$selection" -eq 255 ]; then
42 exit;
43 fi
44
45 #
46 # Create the message for the label widget.
47 #
48 echo "<C>Here is the result of the command" > ${tmp}
49 echo " " >> ${tmp}
50
51 #
52 # Determine which command to run.
53 #
54 if [ "${selection}" -eq 0 ]; then
55 who | awk '{printf "</B>%s\n", $0}' >> ${tmp}
56 elif [ "${selection}" -eq 1 ]; then
57 w | awk '{printf "</B>%s\n", $0}' >> ${tmp}
58 elif [ "${selection}" -eq 2 ]; then
59 uptime | awk '{printf "<C></B>%s\n", $0}' >> ${tmp}
60 elif [ "${selection}" -eq 3 ]; then
61 date | awk '{printf "<C></B>%s\n", $0}' >> ${tmp}
62 elif [ "${selection}" -eq 4 ]; then
63 pwd | awk '{printf "<C></B>%s\n", $0}' >> ${tmp}
64 elif [ "${selection}" -eq 5 ]; then
65 whoami | awk '{printf "<C></B>%s\n", $0}' >> ${tmp}
66 elif [ "${selection}" -eq 6 ]; then
67 #
68 # We will use the label demo to do this.
69 #
70 ./label.sh
71 rm -f ${tmp} ${output} ${fileSystemList}
72 exit 0;
73 elif [ "${selection}" -eq 7 ]; then
74 fortune | awk '{printf "</B>%s\n", $0}' >> ${tmp}
75 fi
76 echo " " >> ${tmp}
77 echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
78
79 #
80 # Create the label widget to display the information.
81 #
82 ${CDK_LABEL} -f ${tmp} -p " "
83
84 #
85 # Clean up.
86 #
87 rm -f ${tmp} ${output} ${fileSystemList}
0 #!/bin/sh
1 # $Id: entry.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the entry widget.
7 #
8
9 #
10 # Create some global variables.
11 #
12 CDK_ENTRY="${CDK_BINDIR=..}/cdkentry"
13 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
14
15 output="${TMPDIR=/tmp}/entry_output.$$"
16 tmp="${TMPDIR=/tmp}/tmp.$$"
17
18 #
19 # Create the title.
20 #
21 title="<C> Type a simple string. "
22 buttons=" OK
23 Cancel "
24
25 #
26 # Create the entry box.
27 #
28 ${CDK_ENTRY} -f 20 -T "${title}" -B "${buttons}" -F "</5>_ " -O ${output} -S
29 selected=$?
30 test $selected = 255 && exit 1
31
32 answer=`cat ${output}`
33
34 #
35 # Create the message for the label widget.
36 #
37 echo "<C>Here is the string you typed in" > ${tmp}
38 echo " " >> ${tmp}
39 echo "<C></R>${answer}" >> ${tmp}
40 echo " " >> ${tmp}
41 echo "<C>You chose button #${selected}" >> ${tmp}
42 echo " " >> ${tmp}
43 echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
44
45 #
46 # Create the label widget to display the information.
47 #
48 ${CDK_LABEL} -f ${tmp} -p " "
49
50 #
51 # Clean up.
52 #
53 rm -f ${tmp} ${output}
0 #!/bin/sh
1 # $Id: fselect.sh,v 1.4 2005/12/27 17:56:05 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the file selection widget.
7 #
8
9 #
10 # Create some global variables.
11 #
12 CDK_FSELECT="${CDK_BINDIR=..}/cdkfselect"
13 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
14
15 directory="."
16 label="File: "
17 title="<C>Select a file"
18
19 buttons=" OK
20 Cancel "
21
22 xpos="CENTER"
23 ypos="CENTER"
24
25 width=0
26 height=-5
27
28 tmp="${TMPDIR=/tmp}/tmp.$$"
29 file="${TMPDIR=/tmp}/fs.$$"
30
31 #
32 # Chop up the command line.
33 #
34 set -- `getopt d:L:T:X:Y:W:H: $*`
35 if [ $? != 0 ]
36 then
37 echo $USAGE
38 exit 2
39 fi
40 for c in $*
41 do
42 case $c in
43 -d) directory=$2; shift 2;;
44 -T) title=$2; shift 2;;
45 -L) label=$2; shift 2;;
46 -X) xpos=$2; shift 2;;
47 -Y) ypos=$2; shift 2;;
48 -W) width=$2; shift 2;;
49 -H) height=$2; shift 2;;
50 --) shift; break;;
51 esac
52 done
53
54 #
55 # Create the CDK file selector.
56 #
57 ${CDK_FSELECT} -d "${directory}" -T "${title}" -L "${label}" -X ${xpos} -Y ${ypos} -W ${width} -H ${height} -B "${buttons}" 2> ${file}
58 selected=$?
59 test $selected = 255 && exit 1
60
61 answer=`cat ${file}`
62
63 #
64 # Diplay the file the user selected.
65 #
66 echo "<C>You selected the following file" > ${tmp}
67 echo " " >> ${tmp}
68 echo "<C><#HL(10)>" >> ${tmp}
69 echo "<C></B>${answer}" >> ${tmp}
70 echo "<C><#HL(10)>" >> ${tmp}
71 echo " " >> ${tmp}
72 echo "<C>You chose button #${selected}" >> ${tmp}
73 echo " " >> ${tmp}
74 echo "<C>Press </R>space<!R> to continue." >> ${tmp}
75
76 ${CDK_LABEL} -f ${tmp} -p " "
77
78 #
79 # Clean up.
80 #
81 rm -f ${tmp} ${file}
0 #!/bin/sh
1 # $Id: itemlist.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the itemlist list widget.
7 #
8
9 #
10 # This gets the password file.
11 #
12 getPasswordFile()
13 {
14 system=$1
15 file=$2
16
17 #
18 # Depeding on the system, get the password file
19 # using nicat, ypcat, or just plain old /etc/passwd
20 #
21 if [ "$system" = "NIS" ]; then
22 niscat passwd.org_dir | sort > $file
23 elif [ "$system" = "YP" ]; then
24 ypcat passwd | sort > $file
25 else
26 sort /etc/passwd > $file
27 fi
28 }
29
30 #
31 # This displays account information.
32 #
33 displayAccountInformation()
34 {
35 userAccount=$1
36 passwordFile=$2
37
38 #
39 # Get the user account information.
40 #
41 line=`grep "^${userAccount}" $passwordFile`
42 uid=`echo $line | cut -d: -f3`
43 gid=`echo $line | cut -d: -f4`
44 info=`echo $line | cut -d: -f5`
45 home=`echo $line | cut -d: -f6`
46 shell=`echo $line | cut -d: -f7`
47
48 #
49 # Create the label message information.
50 #
51 accountMessage="<C></U>Account
52 <C><#HL(30)>
53 Account: </U>${userAccount}
54 UID : </U>${uid}
55 GID : </U>${gid}
56 Info : </U>${info}
57 Home : </U>${home}
58 Shell : </U>${shell}
59 <C><#HL(30)>
60 <C>Hit </R>space<!R> to continue"
61
62 #
63 # Create the popup label.
64 #
65 ${CDK_LABEL} -m "${accountMessage}" -p " "
66 }
67
68 #
69 # Create some global variables.
70 #
71 CDK_ITEMLIST="${CDK_BINDIR=..}/cdkitemlist"
72 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
73
74 tmpPass="${TMPDIR=/tmp}/sl.$$"
75 output="${TMPDIR=/tmp}/output.$$"
76 userAccounts="${TMPDIR=/tmp}/ua.$$"
77
78 TYPE="Other";
79
80 #
81 # Chop up the command line.
82 #
83 set -- `getopt nNh $*`
84 if [ $? != 0 ]
85 then
86 echo $USAGE
87 exit 2
88 fi
89 for c in $*
90 do
91 case $c in
92 -n) TYPE="YP"; shift;;
93 -N) TYPE="NIS"; shift;;
94 -h) echo "$0 [-n YP] [-N NIS+] [-h]"; exit 0;;
95 --) shift; break;;
96 esac
97 done
98
99 #
100 # Create the message for the item list.
101 #
102 title="<C>Pick an account you want to view."
103 label="Account Name "
104 buttons=" OK
105 Cancel "
106
107 #
108 # Get the password file and stick it into the temp file.
109 #
110 getPasswordFile "${TYPE}" "$tmpPass"
111
112 #
113 # Get the user account from the password file.
114 #
115 awk 'BEGIN {FS=":"} {printf "</R>%s\n", $1}' $tmpPass | sort > ${userAccounts}
116
117 #
118 # Create the item list.
119 #
120 ${CDK_ITEMLIST} -d 3 -L "${label}" -T "${title}" -B "${buttons}" -f "${userAccounts}" 2> ${output}
121 selected=$?
122 test $selected = 255 && exit 1
123
124 answer=`cat ${output}`
125
126 #
127 # Display the account information.
128 #
129 displayAccountInformation $answer $tmpPass
130
131 #
132 # Clean up.
133 #
134 rm -f ${output} ${tmpPass} ${userAccounts}
0 #!/bin/sh
1 # $Id: label.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the label widget.
7 #
8
9 #
10 # Create some global variables.
11 #
12 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
13
14 dfTmp="${TMPDIR=/tmp}/label.$$"
15 tmp="${TMPDIR=/tmp}/tmp.$$"
16 top="${TMPDIR=/tmp}/dfTop.$$"
17 bottom="${TMPDIR=/tmp}/dfBottom.$$"
18
19 #
20 # Get the filesystem information.
21 #
22 getDiskInfo()
23 {
24 fileName=$1;
25 command="df"
26
27 #
28 # Determine the type of operating system.
29 #
30 machine=`uname -s`
31 if [ "$machine" = "SunOS" ]; then
32 level=`uname -r`
33
34 if [ "$level" -gt 4 ]; then
35 command="df -kl"
36 fi
37 else
38 if [ "$machine" = "AIX" ]; then
39 command="df -i"
40 fi
41 fi
42
43 #
44 # Run the command.
45 #
46 ${command} > ${fileName}
47 }
48
49 #
50 # Get the disk information.
51 #
52 getDiskInfo ${dfTmp}
53
54 #
55 # Bold the first line of the df command.
56 #
57 head -1 ${dfTmp} | awk '{printf "</B>%s\n", $0}' > ${top}
58 tail +2 ${dfTmp} > ${bottom}
59
60 #
61 # Create the message for the label widget.
62 #
63 echo "<C>This is the current" > ${tmp}
64 echo "<C>status of your local filesystems." >> ${tmp}
65 echo "<C><#HL(2)>" >> ${tmp}
66 cat ${top} >> ${tmp}
67 cat ${bottom} >> ${tmp}
68 echo "<C><#HL(2)>" >> ${tmp}
69 echo "" >> ${tmp}
70 echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
71
72 #
73 # Create the label widget to display the information.
74 #
75 ${CDK_LABEL} -f "${tmp}" -p " " -c "ls" -S
76
77 #
78 # Clean up.
79 #
80 rm -f ${tmp} ${output} ${dfTmp} ${top} ${bottom}
0 #!/bin/sh
1 # $Id: matrix.sh,v 1.4 2005/12/27 17:07:00 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the matrix widget.
7 #
8
9 #
10 # Create some global variables.
11 #
12 CDK_MATRIX="${CDK_BINDIR=..}/cdkmatrix"
13 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
14
15 fileSystemList="${TMPDIR=/tmp}/fsList.$$"
16 info="${TMPDIR=/tmp}/fsInfo.$$"
17 diskInfo="${TMPDIR=/tmp}/diskInfo.$$"
18 tmp="${TMPDIR=/tmp}/tmp.$$"
19
20 #
21 # Get the filesystem information.
22 #
23 getDiskInfo()
24 {
25 fileName=$1;
26 command="df"
27
28 #
29 # Determine the type of operating system.
30 #
31 machine=`uname -s`
32 if [ "$machine" = "SunOS" ]; then
33 level=`uname -r`
34
35 if [ "$level" -gt 4 ]; then
36 command="df -kl"
37 fi
38 else
39 if [ "$machine" = "AIX" ]; then
40 command="df -i"
41 fi
42 fi
43
44 #
45 # Run the command.
46 #
47 ${command} > ${fileName}
48 }
49
50 #
51 # Get the disk information.
52 #
53 getDiskInfo ${diskInfo}
54
55 #
56 # Create the row titles.
57 #
58 rowTitles=`tail +2 ${diskInfo} | awk '{printf "%s\n", $1}'`
59
60 #
61 # Create the column titles.
62 #
63 colTitles="KBytes
64 Used
65 Avail
66 Capacity
67 Mounted on"
68
69 #
70 # Define the matrix title.
71 #
72 title="<C></U>Current Filesystem Information"
73
74 #
75 # Create the data file to fill in the matrix.
76 #
77 tail +2 ${diskInfo} | awk '{printf "%s%s%s%s%s\n", $2, $3, $4, $5, $6}' > ${info}
78
79 #
80 # Set the widths of the columns.
81 #
82 colWidths="5
83 5
84 5
85 5
86 5"
87
88 #
89 # Set the cells as uneditable.
90 #
91 types="VIEWONLY
92 VIEWONLY
93 VIEWONLY
94 VIEWONLY
95 VIEWONLY"
96
97 buttons=" OK
98 Cancel "
99
100 #
101 # Start the matrix.
102 #
103 ${CDK_MATRIX} -r "${rowTitles}" -c "${colTitles}" -v 3 -w "${colWidths}" -d "${info}" -t "${types}" -T "${title}" -B "${buttons}" -O"$tmp"
104 selected=$?
105 test $selected = 255 && exit 1
106
107 #
108 # Create the message for the label widget.
109 #
110 echo "<C>You chose button #${selected}" > ${tmp}
111 echo " " >> ${tmp}
112 echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
113
114 #
115 # Create the label widget to display the information.
116 #
117 ${CDK_LABEL} -f "${tmp}" -p " "
118
119 #
120 # Clean up.
121 #
122 rm -f ${info} ${fileSystemList} ${tmp} ${diskInfo}
0 #!/bin/sh
1 # $Id: mentry.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the multiple line entry widget.
7 #
8
9 #
10 # Create some global variables.
11 #
12 CDK_MENTRY="${CDK_BINDIR=..}/cdkmentry"
13 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
14
15 output="${TMPDIR=/tmp}/mentry_output.$$"
16 tmp="${TMPDIR=/tmp}/tmp.$$"
17
18 #
19 # Create the title.
20 #
21 title="<C>Type in a short message."
22 buttons=" OK
23 Cancel "
24
25 #
26 # Create the mentry box.
27 #
28 ${CDK_MENTRY} -s 5 -v 10 -f 20 -T "${title}" -B "${buttons}" -F '_' -O ${output}
29 selected=$?
30 test $selected = 255 && exit 1
31
32 answer=`cat ${output}`
33
34 #
35 # Create the message for the label widget.
36 #
37 echo "<C>Here is the message you typed in" > ${tmp}
38 echo " " >> ${tmp}
39 echo "<C></R>${answer}" >> ${tmp}
40 echo " " >> ${tmp}
41 echo "<C>You chose button #${selected}" >> ${tmp}
42 echo " " >> ${tmp}
43 echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
44
45 #
46 # Create the label widget to display the information.
47 #
48 ${CDK_LABEL} -f ${tmp} -p " "
49
50 #
51 # Clean up.
52 #
53 rm -f ${tmp} ${output}
0 #!/bin/sh
1 # $Id: radio.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the radio widget.
7 #
8
9 #
10 # Create some global variables.
11 #
12 CDK_RADIO="${CDK_BINDIR=..}/cdkradio"
13 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
14
15 fileSystemList="${TMPDIR=/tmp}/fsList.$$"
16 diskInfo="${TMPDIR=/tmp}/diskInfo.$$"
17 output="${TMPDIR=/tmp}/radio_output.$$"
18 tmp="${TMPDIR=/tmp}/tmp.$$"
19
20 #
21 # Get the filesystem information.
22 #
23 getDiskInfo()
24 {
25 fileName=$1;
26 command="df"
27
28 #
29 # Determine the type of operating system.
30 #
31 machine=`uname -s`
32 if [ "$machine" = "SunOS" ]; then
33 level=`uname -r`
34
35 if [ "$level" -gt 4 ]; then
36 command="df -kl"
37 fi
38 else
39 if [ "$machine" = "AIX" ]; then
40 command="df -i"
41 fi
42 fi
43
44 #
45 # Run the command.
46 #
47 ${command} > ${fileName}
48 }
49
50 #
51 # Create the title for the scrolling list.
52 #
53 title="<C>Pick a filesystem to view."
54 buttons=" OK
55 Cancel "
56
57 #
58 # Get a list of the local filesystems.
59 #
60 getDiskInfo ${diskInfo}
61
62 #
63 # Create the file system list.
64 #
65 grep "^/" ${diskInfo} | awk '{printf "%s\n", $1}' > ${fileSystemList}
66
67 #
68 # Create the radio list.
69 #
70 ${CDK_RADIO} -T "${title}" -f "${fileSystemList}" -c "</U>*" -B "${buttons}" 2> $output
71 selected=$?
72 test $selected = 255 && exit 1
73
74 #
75 # The selection is now in the file $output.
76 #
77 fs=`cat ${output}`
78 echo "<C></R>File Statistics on the filesystem ${fs}" > ${tmp}
79 echo " " >> ${tmp}
80 grep "${fs}" ${diskInfo} | awk '{printf "</B>%s\n", $0}' >> ${tmp}
81 echo " " >> ${tmp}
82 echo "<C>You chose button #${selected}" >> ${tmp}
83 echo " " >> ${tmp}
84 echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
85
86 #
87 # Create the label widget to display the information.
88 #
89 ${CDK_LABEL} -f ${tmp} -p " "
90
91 #
92 # Clean up.
93 #
94 rm -f ${tmp} ${output} ${fileSystemList} ${diskInfo}
0 #!/bin/sh
1 # $Id: scale.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the scale widget.
7 #
8
9 #
10 # Create some global variables.
11 #
12 CDK_SCALE="${CDK_BINDIR=..}/cdkscale"
13 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
14
15 output="${TMPDIR=/tmp}/scale_output.$$"
16 tmp="${TMPDIR=/tmp}/tmp.$$"
17
18 #
19 # Create the title.
20 #
21 title="<C>Enter a value using the cursor keys."
22 label="</R>Value"
23 buttons=" OK
24 Cancel "
25
26 #
27 # Create the scale box.
28 #
29 ${CDK_SCALE} -f 20 -l 0 -h 100 -i 5 -L "${label}" -T "${title}" -B "${buttons}" -O ${output}
30 selected=$?
31 test $selected = 255 && exit 1
32
33 answer=`cat ${output}`
34
35 #
36 # Create the message for the label widget.
37 #
38 echo "<C>Here is the value you selected" > ${tmp}
39 echo " " >> ${tmp}
40 echo "<C></R>${answer}" >> ${tmp}
41 echo " " >> ${tmp}
42 echo "<C>You chose button #${selected}" >> ${tmp}
43 echo " " >> ${tmp}
44 echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
45
46 #
47 # Create the label widget to display the information.
48 #
49 ${CDK_LABEL} -f ${tmp} -p " "
50
51 #
52 # Clean up.
53 #
54 rm -f ${tmp} ${output}
0 #!/bin/sh
1 # $Id: scroll.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the scrolling list widget.
7 #
8
9 #
10 # This gets the password file.
11 #
12 getPasswordFile()
13 {
14 system=$1
15 file=$2
16
17 #
18 # Depeding on the system, get the password file
19 # using nicat, ypcat, or just plain old /etc/passwd
20 #
21 if [ "$system" = "NIS" ]; then
22 niscat passwd.org_dir > $file
23 elif [ "$system" = "YP" ]; then
24 ypcat passwd > $file
25 else
26 cp /etc/passwd $file
27 fi
28 }
29
30 #
31 # This displays account information.
32 #
33 displayAccountInformation()
34 {
35 userAccount=$1
36 passwordFile=$2
37
38 #
39 # Get the user account information.
40 #
41 line=`grep "^${userAccount}" $passwordFile`
42 uid=`echo $line | cut -d: -f3`
43 gid=`echo $line | cut -d: -f4`
44 info=`echo $line | cut -d: -f5`
45 home=`echo $line | cut -d: -f6`
46 shell=`echo $line | cut -d: -f7`
47
48 #
49 # Create the label message information.
50 #
51 accountMessage="<C></U>Account
52 <C><#HL(30)>
53 Account: </U>${userAccount}
54 UID : </U>${uid}
55 GID : </U>${gid}
56 Info : </U>${info}
57 Home : </U>${home}
58 Shell : </U>${shell}
59 <C><#HL(30)>
60 <C>Hit </R>space<!R> to continue"
61
62 #
63 # Create the popup label.
64 #
65 ${CDK_LABEL} -m "${accountMessage}" -p " "
66 }
67
68 #
69 # Create some global variables.
70 #
71 CDK_SCROLL="${CDK_BINDIR=..}/cdkscroll"
72 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
73
74 tmpPass="${TMPDIR=/tmp}/sl.$$"
75 output="${TMPDIR=/tmp}/output.$$"
76 userAccounts="${TMPDIR=/tmp}/ua.$$"
77
78 TYPE="Other"
79
80 #
81 # Chop up the command line.
82 #
83 set -- `getopt nNh $*`
84 if [ $? != 0 ]
85 then
86 echo $USAGE
87 exit 2
88 fi
89 for c in $*
90 do
91 case $c in
92 -n) TYPE="YP"; shift;;
93 -N) TYPE="NIS"; shift;;
94 -h) echo "$0 [-n YP] [-N NIS+] [-h]"; exit 0;;
95 --) shift; break;;
96 esac
97 done
98
99 #
100 # Create the message for the scrolling list.
101 #
102 title="<C><#HL(30)>
103 <C>Pick an account you want to view.
104 <C><#HL(30)>"
105 buttons=" OK
106 Cancel "
107
108 #
109 # Get the password file and stick it into the temp file.
110 #
111 getPasswordFile "${TYPE}" "$tmpPass"
112
113 #
114 # Get the user account from the password file.
115 #
116 awk 'BEGIN {FS=":"} {printf "%s\n", $1}' $tmpPass | sort > ${userAccounts}
117
118 #
119 # Create the scrolling list.
120 #
121 ${CDK_SCROLL} -T "${title}" -f ${userAccounts} -n -B "${buttons}" 2> ${output}
122 selected=$?
123 test $selected = 255 && exit 1
124
125 answer=`cat ${output}`
126
127 #
128 # Display the account information.
129 #
130 displayAccountInformation $answer $tmpPass
131
132 #
133 # Clean up.
134 #
135 rm -f ${output} ${tmpPass} ${userAccounts}
0 #!/bin/sh
1 # $Id: selection.sh,v 1.4 2005/12/27 17:56:58 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the selection widget.
7 #
8
9 #
10 # This gets the password file.
11 #
12 getPasswordFile()
13 {
14 system=$1
15 file=$2
16
17 #
18 # Depending on the system, get the password file
19 # using nicat, ypcat, or just plain old /etc/passwd
20 #
21 if [ "$system" = "NIS" ]; then
22 niscat passwd.org_dir > $file
23 elif [ "$system" = "YP" ]; then
24 ypcat passwd > $file
25 else
26 cp /etc/passwd $file
27 fi
28 }
29
30 #
31 # This displays account information.
32 #
33 displayAccountInformation()
34 {
35 totalSelections=$1
36 currentSelection=$2
37 userAccount=$3
38 passwordFile=$4
39
40 #
41 # Get the user account information.
42 #
43 line=`grep "^${userAccount}" $passwordFile`
44 uid=`echo $line | cut -d: -f3`
45 gid=`echo $line | cut -d: -f4`
46 info=`echo $line | cut -d: -f5`
47 home=`echo $line | cut -d: -f6`
48 shell=`echo $line | cut -d: -f7`
49
50 #
51 # Create the label message information.
52 #
53 accountMessage="<C></U>Account ${currentSelection}/${totalSelections}
54 <C><#HL(30)>
55 Account: </U>${userAccount}
56 UID : </U>${uid}
57 GID : </U>${gid}
58 Info : </U>${info}
59 Home : </U>${home}
60 Shell : </U>${shell}
61 <C><#HL(30)>
62 <C>Hit </R>space<!R> to continue"
63
64 #
65 # Create the popup label.
66 #
67 ${CDK_LABEL} -m "${accountMessage}" -p " "
68 }
69
70 #
71 # Define where the CDK widgets are.
72 #
73 CDK_SELECTION="${CDK_BINDIR=..}/cdkselection"
74 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
75
76 TYPE="Other"
77
78 #
79 # Define the output files.
80 #
81 accountList="${TMPDIR=/tmp}/accList.$$"
82 userAccounts="${TMPDIR=/tmp}/userAccList.$$"
83 output="${TMPDIR=/tmp}/selection_output.$$"
84 tmpPass="${TMPDIR=/tmp}/ps.$$"
85 tmp="${TMPDIR=/tmp}/tmp.$$"
86
87 #
88 # Chop up the command line.
89 #
90 set -- `getopt nNh $*`
91 if [ $? != 0 ]
92 then
93 echo $USAGE
94 exit 2
95 fi
96 for c in $*
97 do
98 case $c in
99 -n) TYPE="YP"; shift;;
100 -N) TYPE="NIS"; shift;;
101 -h) echo "$0 [-n YP] [-N NIS+] [-h]"; exit 0;;
102 --) shift; break;;
103 esac
104 done
105
106 #
107 # Create the message for the selection list.
108 #
109 title="<C>Pick a user account to view."
110
111 #
112 # Get the password file and stick it into the temp file.
113 #
114 getPasswordFile "${TYPE}" "$tmpPass"
115
116 #
117 # Create the user account list.
118 #
119 awk 'BEGIN {FS=":"} {printf "%s\n", $1}' $tmpPass | sort > ${userAccounts}
120 awk '{printf "<C></B>%s\n", $1}' ${userAccounts} > ${accountList}
121 accounts=`cat ${userAccounts}`
122
123 #
124 # Create the choices list.
125 #
126 choices="<C></B>No
127 <C></B> Yes "
128 buttons=" OK
129 Cancel "
130
131 #
132 # Create the selection list.
133 #
134 ${CDK_SELECTION} -T "${title}" -f "${accountList}" -c "${choices}" -B "${buttons}" 2> $output
135 selected=$?
136 test $selected = 255 && exit 1
137
138 #
139 # Initialize the variables.
140 #
141 selection=""
142 value=""
143
144 #
145 # Count how many were selected.
146 #
147 count=`grep -c "^1" ${output}`
148 current=0
149
150 #
151 # Create the label.
152 #
153 for i in `cat ${output}`
154 do
155 #
156 # Since every other variable is value/selection, we
157 # store every other value in the correct variable.
158 #
159 if [ "$value" = "" ]; then
160 value="$i"
161 else
162 selection="$i"
163
164 #
165 # Only display the selected accounts.
166 #
167 if [ "$value" -eq 1 ]; then
168 #
169 # Increment our counter.
170 #
171 current=`expr $current + 1`
172
173 #
174 # Display the account information.
175 #
176 displayAccountInformation $count $current $selection $tmpPass
177 fi
178
179 #
180 # Reset the variables.
181 #
182 value=""
183 selection=""
184 fi
185 done
186
187 #
188 # Clean up.
189 #
190 rm -f ${accountList} ${userAccounts} ${output} ${tmpPass} ${tmp}
0 #!/bin/sh
1 # $Id: slider.sh,v 1.4 2005/12/27 15:53:06 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the slider widget.
7 #
8
9 #
10 # Create some global variables.
11 #
12 CDK_SLIDER="${CDK_BINDIR=..}/cdkslider"
13 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
14
15 output="${TMPDIR=/tmp}/slider_output.$$"
16 tmp="${TMPDIR=/tmp}/tmp.$$"
17
18 #
19 # Create the title.
20 #
21 title="<C>Enter a value using the cursor keys"
22 label="Value: "
23 buttons=" OK
24 Cancel "
25
26 #
27 # Create the slider box.
28 #
29 ${CDK_SLIDER} -f 20 -l 0 -h 100 -i 5 -L "${label}" -T "${title}" -F "</R>*" -B "${buttons}" -O ${output}
30 selected=$?
31 test $selected = 255 && exit 1
32
33 answer=`cat ${output}`
34
35 #
36 # Create the message for the label widget.
37 #
38 echo "<C>Here is the value you selected" > ${tmp}
39 echo " " >> ${tmp}
40 echo "<C></R>${answer}" >> ${tmp}
41 echo " " >> ${tmp}
42 echo "<C>You chose button #${selected}" >> ${tmp}
43 echo " " >> ${tmp}
44 echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
45
46 #
47 # Create the label widget to display the information.
48 #
49 ${CDK_LABEL} -f ${tmp} -p " "
50
51 #
52 # Clean up.
53 #
54 rm -f ${tmp} ${output}
0 #!/bin/sh
1 # $Id: template.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the template widget.
7 #
8
9 #
10 # Create some global variables.
11 #
12 CDK_TEMPLATE="${CDK_BINDIR=..}/cdktemplate"
13 CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
14
15 output="${TMPDIR=/tmp}/template_output.$$"
16 tmp="${TMPDIR=/tmp}/tmp.$$"
17
18 #
19 # Create the title.
20 #
21 title="<C> Type in the
22 <C>IP Address for this machine."
23 buttons=" OK
24 Cancel "
25
26 #
27 # Create the template box.
28 #
29 ${CDK_TEMPLATE} -p "###.###.###.###" -o "___.___.___.___" -T "${title}" -P -B "${buttons}" 2> ${output}
30 selected=$?
31 test $selected = 255 && exit 1
32
33 answer=`cat ${output}`
34
35 #
36 # Create the message for the label widget.
37 #
38 echo "<C>Here is the IP you typed in" > ${tmp}
39 echo " " >> ${tmp}
40 echo "<C></R>${answer}" >> ${tmp}
41 echo " " >> ${tmp}
42 echo "<C>You chose button #${selected}" >> ${tmp}
43 echo " " >> ${tmp}
44 echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
45
46 #
47 # Create the label widget to display the information.
48 #
49 ${CDK_LABEL} -f ${tmp} -p " "
50
51 #
52 # Clean up.
53 #
54 rm -f ${tmp} ${output}
0 #!/bin/sh
1 # $Id: viewer.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
2
3 #
4 # Description:
5 # This demonstrates the CDK command line
6 # interface to the viewer widget.
7 #
8
9 #
10 # Create some global variables.
11 #
12 CDK_FSELECT="${CDK_BINDIR=..}/cdkfselect"
13 CDK_VIEWER="${CDK_BINDIR=..}/cdkviewer"
14
15 tmp="${TMPDIR=/tmp}/tmp.$$"
16 file="${TMPDIR=/tmp}/fs.$$"
17
18 directory="."
19 xpos=CENTER
20 ypos=CENTER
21 width="-2"
22 height="0"
23 interpret=0
24
25 #
26 # Chop up the command line.
27 #
28 set -- `getopt d:x:y:w:h:i $*`
29 if [ $? != 0 ]
30 then
31 echo $USAGE
32 exit 2
33 fi
34 for c in $*
35 do
36 case $c in
37 -d) directory=$2; shift 2;;
38 -x) xpos=$2; shift 2;;
39 -y) ypos=$2; shift 2;;
40 -w) width=$2; shift 2;;
41 -h) height=$2; shift 2;;
42 -i) interpret=1; shift 1;;
43 --) shift; break;;
44 esac
45 done
46
47 #
48 # Create the CDK file selector.
49 #
50 ${CDK_FSELECT} -T "<C>Select a file" -d "${directory}" 2> ${file}
51 selected=$?
52 test $selected = 255 && exit 1
53
54 answer=`cat ${file}`
55
56 #
57 # Create the title and buttons for the viewer.
58 #
59 title="<C>CDK File Viewer Widget
60 <C></U>${answer}"
61 buttons="OK"
62
63 #
64 # Create the file viewer.
65 #
66 if [ "$interpret" -eq 1 ]; then
67 ${CDK_VIEWER} -f "${answer}" -T "${title}" -B "${buttons}" -i -X ${xpos} -Y ${ypos} -H "${height}" -W "${width}"
68 else
69 ${CDK_VIEWER} -f "${answer}" -T "${title}" -B "${buttons}" -X ${xpos} -Y ${ypos} -H "${height}" -W "${width}" -B "${buttons}"
70 fi
71
72 #
73 # Clean up.
74 #
75 rm -f ${tmp} ${file}
0 #!/bin/sh
1 # $Id: adduser,v 1.3 2002/07/16 22:24:53 tom Exp $
2
3 #
4 # Written by: Mike Glover, March 1997
5 # E-mail : vexus@home.com, glover@credit.erin.utoronto.ca
6 #
7 # Purpose:
8 # This is a graphical adduser program. The widgets are
9 # the CDK command line widgets provided by the CDK
10 # distribution. If you have any questions about CDK,
11 # or the command line widgets please feel free to mail
12 # me at one of the two above addresses.
13 #
14
15 #
16 # Copyright 2000, Mike Glover
17 # All rights reserved.
18 #
19 # Redistribution and use in source and binary forms, with or without
20 # modification, are permitted provided that the following conditions
21 # are met:
22 # 1. Redistributions of source code must retain the above copyright
23 # notice, this list of conditions and the following disclaimer.
24 # 2. Redistributions in binary form must reproduce the above copyright
25 # notice, this list of conditions and the following disclaimer in the
26 # documentation and/or other materials provided with the distribution.
27 # 3. All advertising materials mentioning features or use of this software
28 # must display the following acknowledgment:
29 # This product includes software developed by Mike Glover
30 # and contributors.
31 # 4. Neither the name of Mike Glover nor the names of contributors
32 # may be used to endorse or promote products derived from this software
33 # without specific prior written permission.
34 #
35 # THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
36 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38 # ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
39 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
41 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
43 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
44 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 # SUCH DAMAGE.
46 #
47
48 #
49 # Set the screen and widget colors.
50 #
51 CDK_WIDGET_COLOR="</5>"; export CDK_WIDGET_COLOR
52 CDK_SCREEN_COLOR="</1>"; export CDK_SCREEN_COLOR
53
54 #
55 # Set up some variables.
56 #
57 CDK_DIALOG="../cdkdialog"
58 CDK_ENTRY="../cdkentry"
59 CDK_SCROLL="../cdkscroll"
60 tmpFile="/tmp/tmp.$$"
61 tmpInfo="/tmp/adduserInfo.$$"
62 shellFile="/tmp/shells.$$"
63 ACCOUNT_SHELL=""
64 ACCOUNT_INFO=""
65 ACCOUNT_NAME=""
66 ACCOUNT_HOME=""
67 ACCOUNT_GID=""
68 ACCOUNT_UID=""
69 GROUP_NAME=""
70 CURRENT_FUNCTION=1;
71
72 #
73 # This quits the program.
74 #
75 quitProgram()
76 {
77 #
78 # The person has decided to quit.
79 #
80 buttons="< OK >"
81 message="<C></B><#HL(30)>
82 <C></B>Add New User Canceled
83 <C></B>Program exiting
84 <C></B><#HL(30)>"
85 ${CDK_DIALOG} -m "${message}" -B "${buttons}" -N 2> /dev/null
86 exit;
87 }
88
89 #
90 # This warns the user to what is about to happen. It
91 # gives them a safe 'out'
92 #
93 warnUser()
94 {
95 #
96 # Pop up a little message telling the user what is
97 # about to happen.
98 #
99 message="<C></B>Adding New User
100
101 You are about to add a new user. If you do not want to
102 do this, move the cursor to the cancel button and hit
103 return. This will exit this program. Otherwise hit
104 return to continue."
105 buttons="< OK >
106 < Cancel >"
107 ${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
108 if [ $? -ne 0 ]; then
109 quitProgram;
110 fi
111 }
112
113 #
114 # This gets the account name from the user.
115 #
116 getAccountName()
117 {
118 #
119 # Keep doing this until we hit an account which does not
120 # already exist.
121 #
122 count=1;
123 while [ $count -ne 0 ]; do
124 #
125 # Get the account name from the user.
126 #
127 buttons="Next
128 Cancel"
129 label="</24/B>Account Name: "
130 title="<C></B>Account Name
131
132 <C>The name is the identity of the account which the
133 <C>user will use to access the system.
134
135 "
136
137 ${CDK_ENTRY} -i "${ACCOUNT_NAME}" -f 15 -m 3 -F "</56/B>_" -T "${title}" -L "${label}" -B "${buttons}" 2> ${tmpFile}
138 selected=$?
139 ACCOUNT_NAME=`cat ${tmpFile}`
140
141 #
142 # Check the selected button.
143 #
144 if [ $selected -eq 0 ]; then
145 DIRECTION=1; export DIRECTION;
146 else
147 quitProgram;
148 fi
149
150 #
151 # Look for the account name in the password file.
152 #
153 count=`grep -c "^${ACCOUNT_NAME}" /etc/passwd`
154 if [ ${count} -eq 1 ]; then
155 buttons="< OK >"
156 message="<C></B>Account Found
157
158 <C>The account you provided
159 <C></B>${ACCOUNT_NAME}
160 <C>already exists in the password file. Please pick
161 <C>another account name."
162 ${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
163 fi
164 done
165 }
166
167 #
168 # This gets the account information.
169 #
170 getAccountInfo()
171 {
172 #
173 # Set up the entry field.
174 #
175 buttons="Next
176 Previous
177 Cancel"
178 label="</24/B>Personal Info: "
179 title="<C></B>Account Information.
180
181 Enter in </B>${ACCOUNT_NAME}<!B>'s personal information. This is usually the
182 account holders name, phone number, or extension. This is fairly freeform.
183 The only character you can not use is a colon (:). If you do all colons will
184 be stripped out by this process.
185
186 "
187 ${CDK_ENTRY} -f 40 -i "${ACCOUNT_INFO}" -F "</56/B>_" -T "${title}" -L "${label}" -B "${buttons}" 2> ${tmpFile}
188 selected=$?
189 ACCOUNT_INFO=`cat ${tmpFile} | tr ':' ' '`
190
191 #
192 # Check the selected button.
193 #
194 if [ $selected -eq 0 ]; then
195 DIRECTION=1; export DIRECTION;
196 elif [ $selected -eq 1 ]; then
197 DIRECTION=-1; export DIRECTION;
198 return;
199 else
200 quitProgram;
201 fi
202 }
203
204 #
205 # This gets the account GID.
206 #
207 getAccountGID()
208 {
209 #
210 # Get the 'users' GID from /etc/group.
211 #
212 if [ "$ACCOUNT_GID" = "" ]; then
213 count=`grep -c "^users" /etc/group`
214 if [ $count -eq 0 ]; then
215 USER_GID="100";
216 else
217 USER_GID=`grep "^users" /etc/group | cut -d: -f3`
218 fi
219 else
220 USER_GID="$ACCOUNT_GID";
221 fi
222
223 #
224 # Keep doing this until we get a GID which exists.
225 #
226 count=0;
227 while [ $count -eq 0 ]; do
228 #
229 # Get the GID.
230 #
231 buttons="Next
232 Previous
233 Cancel"
234 label="</24/B>Account GID: "
235 title="<C></B>Account GID
236
237 The GID (Group IDentification) must be a number which already
238 exists in the /etc/group file. The default group </B>users<!B>
239 has been provided for you.
240
241 "
242 ${CDK_ENTRY} -f 6 -m 1 -i "${USER_GID}" -F "</56/B>_" -T "${title}" -L "${label}" -B "${buttons}" 2> ${tmpFile}
243 selected=$?
244 ACCOUNT_GID=`cat ${tmpFile}`
245
246 #
247 # Check the selected button.
248 #
249 if [ $selected -eq 0 ]; then
250 DIRECTION=1; export DIRECTION;
251 elif [ $selected -eq 1 ]; then
252 DIRECTION=-1; export DIRECTION;
253 return;
254 else
255 quitProgram;
256 fi
257
258 #
259 # Look for GID in the /etc/group
260 #
261 count=`grep -c ".*:.*:${ACCOUNT_GID}:" /etc/group`
262 if [ ${count} -eq 0 ]; then
263 buttons="< OK >"
264 message="<C></B>Error: No Such GID
265
266 <C>The GID you provided does not exist.
267 <C>Please pick a GID which does exist.
268 "
269 ${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
270 if [ $? -ne 0 ]; then
271 quitProgram;
272 fi
273 else
274 #
275 # Get the group name for later.
276 #
277 GROUP_NAME=`grep ".*:.*:${ACCOUNT_GID}:" /etc/group | cut -d: -f1`
278 fi
279 done
280 }
281
282 #
283 # This gets the account UID.
284 #
285 getAccountUID()
286 {
287 #
288 # Try to find the next available UID.
289 #
290 if [ "$ACCOUNT_UID" = "" ]; then
291 nextUID=`awk 'BEGIN {FS=":"} {print $3}' /etc/passwd | sort -n | grep -v "65535" | tail -1`
292 nextUID=`expr $nextUID + 1`
293 else
294 nextUID="$ACCOUNT_UID"
295 fi
296
297 #
298 # Keep doing this until we get a UID which does not exist.
299 #
300 count=1;
301 while [ $count -ne 0 ]; do
302 #
303 # Get the UID.
304 #
305 buttons="Next
306 Previous
307 Cancel"
308 label="</24/B>Account UID: "
309 title="<C></B>Account UID
310
311 The UID (User IDentification) must be a number which does not
312 already exist in the /etc/passwd file. The value filled in is
313 the next available UID found from the password file.
314
315 "
316 ${CDK_ENTRY} -f 6 -i "${nextUID}" -m 1 -F "</56/B>_" -T "${title}" -L "${label}" -B "${buttons}" 2> ${tmpFile}
317 selected=$?
318 ACCOUNT_UID=`cat ${tmpFile}`
319
320 #
321 # Check the selected button.
322 #
323 if [ $selected -eq 0 ]; then
324 DIRECTION=1; export DIRECTION;
325 elif [ $selected -eq 1 ]; then
326 DIRECTION=-1; export DIRECTION;
327 return;
328 else
329 quitProgram;
330 fi
331
332 #
333 # Look for UID in the /etc/passwd
334 #
335 count=`grep -c ".*:.*:${ACCOUNT_UID}:" /etc/passwd`
336 if [ ${count} -ne 0 ]; then
337 owner=`grep ".*:.*:${ACCOUNT_UID}:" /etc/passwd | head -1 |cut -d: -f1`
338 buttons="< OK >"
339 message="<C></B>Error: Duplicate UID
340
341 <C>The UID you provided is already owned by
342 <C>the account </B>$owner<!B>. Please pick a
343 <C>UID which does not already exist.
344 "
345 ${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
346 if [ $? -ne 0 ]; then
347 quitProgram;
348 fi
349 fi
350 done
351 }
352
353 #
354 # This gets the account home directory.
355 #
356 getAccountHome()
357 {
358 if [ "${ACCOUNT_HOME}" = "" ]; then
359 defaultHome="/home/${ACCOUNT_NAME}"
360 else
361 defaultHome="${ACCOUNT_HOME}"
362 fi
363
364 #
365 # Set up the entry field.
366 #
367 buttons="Next
368 Previous
369 Cancel"
370 label="</24/B>Home Directory: "
371 title="<C></B>Account Home Directory.
372
373 Enter in the account's home directory. If the directory
374 does not currently exist, it will be created in the account
375 creation phase of this process. A reasonable default value
376 for the home directory has been provided.
377
378 "
379 ${CDK_ENTRY} -f 20 -F "</56/B>_" -i "${defaultHome}" -T "${title}" -L "${label}" -B "${buttons}" 2> ${tmpFile}
380 selected=$?
381 ACCOUNT_HOME=`cat ${tmpFile}`
382
383 #
384 # Check the selected button.
385 #
386 if [ $selected -eq 0 ]; then
387 DIRECTION=1; export DIRECTION;
388 elif [ $selected -eq 1 ]; then
389 DIRECTION=-1; export DIRECTION;
390 return;
391 else
392 quitProgram;
393 fi
394 }
395
396 #
397 # This gets the shell the user want to assign to
398 # the account.
399 #
400 getAccountShell()
401 {
402 count=0;
403
404 while [ "$count" -eq 0 ]; do
405 #
406 # Get the shell they want to use.
407 #
408 buttons="Next
409 Previous
410 Cancel"
411 title="<C>Account Shell
412
413 Pick one of the shells to use. If you want to use a
414 custom shell, pick </B>Custom<!B> and you will be
415 prompted for it's path.
416 "
417 echo "Custom" > ${shellFile}
418 cat /etc/shells >> ${shellFile}
419 ${CDK_SCROLL} -H 5 -W 10 -T "${title}" -f ${shellFile} -B "${buttons}" 2> ${tmpFile}
420 selected=$?
421 ACCOUNT_SHELL=`cat ${tmpFile}`
422
423 #
424 # Check the selected buttons.
425 #
426 if [ $selected -eq 0 ]; then
427 DIRECTION=1; export DIRECTION;
428 count=1;
429 elif [ $selected -eq 1 ]; then
430 DIRECTION=-1; export DIRECTION;
431 return;
432 else
433 quitProgram;
434 fi
435
436 #
437 # Check the answer.
438 #
439 if [ "$ACCOUNT_SHELL" = "Custom" ]; then
440 #
441 # Get the shell from the user.
442 #
443 buttons="Next
444 Previuous
445 Cancel"
446 label="</24/B>Shell Pathname: "
447 title="<C></B>Custom Account Shell
448
449 Enter in the path to the custom shell. The authenticity
450 of the shell will not be checked here. It is assumed that
451 the shell will exist when the account is ready to be used.
452
453 "
454 ${CDK_ENTRY} -f 20 -F "</56/B>_" -T "${title}" -L "${label}" -B "${buttons}" 2> ${tmpFile}
455 selected=$?
456 ACCOUNT_SHELL=`cat ${tmpFile}`
457
458 #
459 # Check the selected buttons.
460 #
461 if [ $selected -eq 0 ]; then
462 DIRECTION=1; export DIRECTION;
463 count=1;
464 elif [ $selected -eq 1 ]; then
465 count=0;
466 else
467 quitProgram;
468 fi
469 fi
470 done
471 }
472
473 #
474 # This confirms the new account information.
475 #
476 confirmAccount()
477 {
478 message="<C></B>Confirm New Account.
479 You are about to add an account with the following
480 information:
481
482 <C><#HL(30)>
483 Account Name : </B>$ACCOUNT_NAME
484 Account Info : </B>$ACCOUNT_INFO
485 Account Home : </B>$ACCOUNT_HOME
486 Account Shell: </B>$ACCOUNT_SHELL
487 Account UID : </B>$ACCOUNT_UID
488 Account GID : </B>$ACCOUNT_GID
489 <C><#HL(30)>
490
491 Are you sure you want to do this. Hit </R>Yes<!R> if you
492 want to add the account; hit </R>No<!R> if you want to
493 edit the information; hit </R>Cancel<!R> if you want to
494 abandon all information.
495 "
496 buttons="< Yes >
497 < No >
498 < Cancel >"
499 ${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
500 answer=$?
501
502 #
503 # Check the answer.
504 #
505 if [ "$answer" -eq 2 -o "$answer" -eq 255 ]; then
506 quitProgram;
507 fi
508 if [ "$answer" -eq 0 ]; then
509 confirm=1; export confirm;
510 else
511 confirm=0; export confirm;
512 fi
513 }
514
515 #
516 # Find out if the user wants to change the password
517 # or not.
518 #
519 changeAccountPassword()
520 {
521 buttons="< Yes >
522 < No >"
523 message="<C></B>Change Account Password Now
524
525 Since the account was added without a password, this account
526 can be logged in to without providing a password. Would you
527 like to change the account's password now?
528 "
529 ${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
530 answer=$?
531 if [ "$answer" -eq 0 ]; then
532 passwd $ACCOUNT_NAME
533 fi
534 }
535
536 #
537 # This verifies the users ability to modify the
538 # password file.
539 #
540 checkPermissions()
541 {
542 #
543 # Try to touch the passwd file.
544 #
545 touch /etc/passwd >/dev/null 2>&1
546 if [ $? -ne 0 ]; then
547 #
548 # Can't touch the password file. Let's tell them and go.
549 #
550 buttons="< Log Into Root Now >
551 < Exit >"
552 message="<C></B>Can Not Edit Password File
553
554 It appears that you do not have permission to edit the
555 password file. To add a new user to this machine you
556 must be logged in as root. Would you like to su to root
557 now or exit and log in. If you try to su now, this
558 program will be restarted.
559 "
560 ${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
561 if [ $? -eq 0 ]; then
562 su root -c "$0"
563 fi
564 exit;
565 fi
566 }
567
568 #
569 # This creates the account and copies all needed
570 # information.
571 #
572 createAccount()
573 {
574 if [ ! -d "$ACCOUNT_HOME" ]; then
575 mkdir $ACCOUNT_HOME
576 fi
577 if [ "$ACCOUNT_SHELL" = "/bin/sh" ]; then
578 cp /etc/profile ${ACCOUNT_HOME}/.profile
579 fi
580 if [ "$ACCOUNT_SHELL" = "/bin/bash" ]; then
581 cp /etc/profile ${ACCOUNT_HOME}/.profile
582 fi
583 if [ "$ACCOUNT_SHELL" = "/bin/csh" ]; then
584 cp /etc/csh.cshrc ${ACCOUNT_HOME}/.cshrc
585 cp /etc/csh.login ${ACCOUNT_HOME}/.login
586 fi
587 if [ "$ACCOUNT_SHELL" = "/bin/tcsh" ]; then
588 cp /etc/csh.cshrc ${ACCOUNT_HOME}/.cshrc
589 cp /etc/csh.login ${ACCOUNT_HOME}/.login
590 fi
591 chown -R ${ACCOUNT_NAME}.${GROUP_NAME} $ACCOUNT_HOME
592 }
593
594 ###########################################################
595 #
596 # This is the start of the info retrieval.
597 #
598 ###########################################################
599
600 #
601 # Set up the intermiediate functions so we can go
602 # backward and forward.
603 #
604 function1()
605 {
606 getAccountName;
607 }
608 function2()
609 {
610 getAccountInfo;
611 }
612 function3()
613 {
614 getAccountGID;
615 }
616 function4()
617 {
618 getAccountUID;
619 }
620 function5()
621 {
622 getAccountHome;
623 }
624 function6()
625 {
626 getAccountShell;
627 }
628 function7()
629 {
630 confirmAccount;
631 }
632
633 #
634 # Make sure the user has permission to edit the password file.
635 #
636 checkPermissions;
637
638 #
639 # Tell the user what they are about to do.
640 #
641 warnUser;
642
643 #
644 # Call the functions to get the needed info.
645 #
646 confirm=0;
647 NUMBER=0;
648 DIRECTION=1;
649 while [ "$confirm" -eq 0 ]; do
650 NUMBER=`expr $NUMBER + $DIRECTION`
651 if [ $NUMBER -le 0 ]; then
652 NUMBER = 1;
653 fi
654 CURRENT_FUNCTION="function${NUMBER}";
655 $CURRENT_FUNCTION;
656 done
657
658 #
659 # Add the account to the password file.
660 #
661 cp /etc/passwd /etc/passwd.old
662 echo "${ACCOUNT_NAME}::${ACCOUNT_UID}:${ACCOUNT_GID}:${ACCOUNT_INFO}:${ACCOUNT_HOME}:${ACCOUNT_SHELL}" >> /etc/passwd
663
664 #
665 # Find out if the user wants to change the password or not.
666 #
667 changeAccountPassword;
668
669 #
670 # Create the account and copy . files.
671 #
672 createAccount;
673
674 #
675 # Pop up a last little message and tell the user everything
676 # if OK.
677 #
678 buttons="< OK >"
679 message="<C></B>Account Add Complete
680
681 The account </B>${ACCOUNT_NAME}<!B> has been added to the password
682 file. You should be able to log in under this account
683 now.
684 "
685 ${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
0 #!/bin/sh
1 # $Id: netconfig,v 1.3 2002/07/16 22:25:56 tom Exp $
2
3 #
4 # Written by: Mike Glover, March 1997
5 # E-mail : vexus@home.com, glover@credit.erin.utoronto.ca
6 #
7 # Purpose:
8 # This is a graphical network configuration program.
9 # It was inspired by the cdialog interface that Linux
10 # uses. The widgets are the CDK command line widgets
11 # provided by the CDK distribution. If you have any
12 # questions about CDK, or the command line widgets
13 # please feel free to mail me at one of the two above
14 # addresses.
15 #
16
17 #
18 # Copyright 2000, Mike Glover
19 # All rights reserved.
20 #
21 # Redistribution and use in source and binary forms, with or without
22 # modification, are permitted provided that the following conditions
23 # are met:
24 # 1. Redistributions of source code must retain the above copyright
25 # notice, this list of conditions and the following disclaimer.
26 # 2. Redistributions in binary form must reproduce the above copyright
27 # notice, this list of conditions and the following disclaimer in the
28 # documentation and/or other materials provided with the distribution.
29 # 3. All advertising materials mentioning features or use of this software
30 # must display the following acknowledgment:
31 # This product includes software developed by Mike Glover
32 # and contributors.
33 # 4. Neither the name of Mike Glover nor the names of contributors
34 # may be used to endorse or promote products derived from this software
35 # without specific prior written permission.
36 #
37 # THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
38 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40 # ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
41 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
43 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
45 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
46 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 # SUCH DAMAGE.
48 #
49
50 #
51 # Set up the root directory for the system files.
52 #
53 if [ "$1" = "" ]; then
54 ROOTDIR=""
55 else
56 ROOTDIR=$1;
57 fi
58
59 #
60 # This copies a file to it's destination and
61 # sets the file mode.
62 #
63 copyFile()
64 {
65 source=$1;
66 dest=$2;
67 mode=$3;
68
69 #
70 # If the original exists, make a copy.
71 #
72 if [ -f "${dest}" ]; then
73 cp ${dest} ${dest}.old
74 fi
75 mv ${source} ${dest}
76 chmod ${mode} ${dest}
77 }
78
79 #
80 # Set up some variables.
81 #
82 CDK_DIALOG="../cdkdialog"
83 CDK_ENTRY="../cdkentry"
84 CDK_TEMPLATE="../cdktemplate"
85 NETWORKS="${ROOTDIR}/etc/networks"
86 HOSTS="${ROOTDIR}/etc/hosts"
87 HOSTNAME_FILE="${ROOTDIR}/etc/HOSTNAME"
88 RESOLV="${ROOTDIR}/etc/resolv.conf"
89 INET="${ROOTDIR}/etc/rc.d/rc.inet1"
90 IFCONFIG="${ROOTDIR}/sbin/ifconfig"
91 ROUTE="${ROOTDIR}/sbin/route"
92 tmpFile="/tmp/tmp.$$"
93
94 #
95 # Define some global variables.
96 #
97 IP=""
98 HOST=""
99 DOMAIN=""
100 GATEWAY=""
101 NETMASK=""
102 NETWORK=""
103 BROADCAST=""
104 NAMESERVER=""
105
106 #
107 # Set the screen and widget colors.
108 #
109 CDK_WIDGET_COLOR="</5>"; export CDK_WIDGET_COLOR
110 CDK_SCREEN_COLOR="</7>"; export CDK_SCREEN_COLOR
111
112 #
113 #
114 #
115 exitMessage()
116 {
117 exit;
118 }
119
120 #
121 # Create the opening window.
122 #
123 intro()
124 {
125 program=`basename $0`
126 buttons="</R>< OK >"
127 message="<C></B>Network Configuration
128
129 We will now attempt to configure your mail and TCP/IP. This
130 process probably won't work on all possible network
131 configurations; but should give you a good start. You will
132 be able to reconfigure your network at any time by typing
133 in the command:
134 <C>${program}"
135
136 ${CDK_DIALOG} -m "${message}" -B "${buttons}" -S 2> /dev/null
137 }
138
139 #
140 # Get the hostname of the machine.
141 #
142 getHostname()
143 {
144 label="</24/B>Enter Hostname: "
145 title="<C></B>Enter Hostname
146
147 We need to give the machine a name. We only need the base
148 hostname of the machine; the domain will be queried for
149 next.
150 "
151
152 ${CDK_ENTRY} -i "${HOST}" -f 20 -F "</56/B>_" -T "${title}" -L "${label}" -S 2> ${tmpFile}
153 HOST=`cat ${tmpFile}`
154 }
155
156 #
157 # Get the domain name of the machine.
158 #
159 getDomainName()
160 {
161 label="</24/B>Enter Domain Name: "
162 title="<C></B>Enter Domain Name
163
164 Now enter in the domain in which this machine will
165 reside. Do </K>NOT<!K> supply a leading '.'
166
167 "
168
169 ${CDK_ENTRY} -i "${DOMAIN}" -f 20 -F "</56/B>_" -T "${title}" -L "${label}" -S 2> ${tmpFile}
170 DOMAIN=`cat ${tmpFile}`
171 }
172
173 #
174 # Ask them if they plan to use loopback only.
175 #
176 loopback()
177 {
178 buttons="< Yes >
179 < No >"
180 message="<C></B>Loopback
181
182 Do you plan to only use loopback? If so then your address will
183 be 127.0.0.1 and most of the following questions can be skipped.
184
185 <C>Do you plan to ONLY use loopback?
186 "
187
188 ${CDK_DIALOG} -m "${message}" -B "${buttons}" -S 2> /dev/null
189 answer=$?
190 if [ $answer -eq 0 ]; then
191 exitMessage;
192 fi
193 }
194
195 #
196 # Get the IP Address.
197 #
198 getIPAddress()
199 {
200 title="<C> </B>Enter Machine IP Address
201
202 <C>Enter the IP address you plan to assign to this machine.
203 "
204 plate="###.###.###.###"
205 overlay="</56/B>___.___.___.___"
206 ${CDK_TEMPLATE} -i "${IP}" -p "${plate}" -o "${overlay}" -T "${title}" -m 10 -P -S 2> ${tmpFile}
207 IP=`cat ${tmpFile}`
208 }
209
210 #
211 #
212 #
213 getGatewayAddress()
214 {
215 NETWORK=`echo ${IP} | awk 'BEGIN {FS="."} {printf ("%s.%s.%s.0",$1,$2,$3)}'`
216 BROADCAST=`echo ${IP} | awk 'BEGIN {FS="."} {printf ("%s.%s.%s.255",$1,$2,$3)}'`
217
218 #
219 # Get the machine's gateway address.
220 #
221 title="<C> </B>Enter Gateway Address
222
223 Enter the address of the gateway for this machine. If you do not
224 know, or have one, use the IP address of this machine. The IP
225 address you assigned to this machine should already be filled
226 in. If you want to erase it press control-x to erase the field
227 or hit the backspace or delete key to erase portions of the field.
228 "
229 tmp=`echo ${IP} | sed 's/\.//g'`
230 plate="###.###.###.###"
231 overlay="</B/56>___.___.___.___"
232 ${CDK_TEMPLATE} -d "${tmp}" -p "${plate}" -o "${overlay}" -T "${title}" -m 10 -P -S 2> ${tmpFile}
233 GATEWAY=`cat ${tmpFile}`
234
235 #
236 # Get the machine's netmask.
237 #
238 title="<C> </B>Enter Netmask
239
240 Enter your netmask. More often than not this value will be
241 255.255.255.0 A defaulted value of 255.255.255.0 is already
242 filled in. If you want to erase it press control-x to erase
243 the field or hit the backspace or delete key to erase
244 portions of the field.
245 "
246 plate="###.###.###.###"
247 overlay="</B/56>___.___.___.___"
248 ${CDK_TEMPLATE} -d "2552552550" -p "${plate}" -o "${overlay}" -T "${title}" -m 10 -P -S 2> ${tmpFile}
249 NETMASK=`cat ${tmpFile}`
250
251 #
252 # Find out if the user will be accessing a domain name server.
253 #
254 message="<C> </B>Named Services
255
256 Will you be accessing a name server.
257 "
258 buttons="< Yes >
259 < No >"
260 ${CDK_DIALOG} -m "${message}" -B "${buttons}" -S 2> /dev/null
261 answer=$?
262
263 #
264 # If they answered yes, get the IP address.
265 #
266 if [ "$answer" -eq 0 ]; then
267 #
268 # Get the machine's domain name server address.
269 #
270 title="<C> </B>Enter DNS Address
271
272 Enter the address of the domain name server (DNS) which you want to
273 use. The value of the DNS server has been filled in with the
274 gateway address you provided. If you want to erase it press
275 control-x to erase the field or hit the backspace or delete key
276 to erase portions of the field.
277 "
278 tmp=`echo ${GATEWAY} | sed 's/\.//g'`
279 plate="###.###.###.###"
280 overlay="</B/56>___.___.___.___"
281 ${CDK_TEMPLATE} -d "${tmp}" -p "${plate}" -o "${overlay}" -T "${title}" -m 10 -P -S 2> ${tmpFile}
282 NAMESERVER=`cat ${tmpFile}`
283 fi
284 }
285
286 #
287 # Call the functions needed.
288 #
289
290
291 #########################################
292 # Create the hosts file.
293 #
294 cat << EOF > ${tmpFile}
295 #
296 # hosts This file describes a number of hostname-to-address
297 # mappings for the TCP/IP subsystem. It is mostly
298 # used at boot time, when no name servers are running.
299 # On small systems, this file can be used instead of a
300 # "named" name server. Just add the names, addresses
301 # and any aliases to this file...
302 #
303 # By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
304 # should NEVER be named with the name of the machine. It causes problems
305 # for some (stupid) programs, irc and reputedly talk. :^)
306 #
307
308 # For loopbacking.
309 127.0.0.1 localhost
310 $IP ${HOST}.${DOMAIN} ${HOST}
311 # End of hosts
312 EOF
313 copyFile ${tmpFile} "${HOSTS}" 644
314 echo "${HOST}.${DOMAIN}" > ${tmpFile}
315 copyFile ${tmpFile} ${HOSTNAME_FILE} 644
316
317 #########################################
318 # Create the resolv.conf file.
319 #
320 cat << EOF > ${tmpFile}
321 domain ${DOMAIN}
322 nameserver ${NAMESERVER}
323 EOF
324 copyFile ${tmpFile} "${RESOLV}" 644
325
326 #########################################
327 # Create the /etc/networks file.
328 #
329 cat << EOF > ${tmpFile}
330 #
331 # networks This file describes a number of netname-to-address
332 # mappings for the TCP/IP subsystem. It is mostly
333 # used at boot time, when no name servers are running.
334 #
335
336 loopback 127.0.0.0
337 localnet ${IP}
338
339 # End of networks.
340 EOF
341 copyFile ${tmpFile} "${NETWORKS}" 644
342
343 #########################################
344 # Create the /etc/rc.d/inet1 file.
345 #
346 cat << EOF > ${tmpFile}
347 #! /bin/sh
348 #
349 # rc.inet1 This shell script boots up the base INET system.
350 #
351 # Version: @(#)/etc/rc.d/rc.inet1 1.01 05/27/93
352 #
353
354 HOSTNAME=\`cat /etc/HOSTNAME\`
355
356 # Attach the loopback device.
357 ${IFCONFIG} lo 127.0.0.1
358 ${ROUTE} add -net 127.0.0.0
359
360 # IF YOU HAVE AN ETHERNET CONNECTION, use these lines below to configure the
361 # eth0 interface. If you're only using loopback or SLIP, don't include the
362 # rest of the lines in this file.
363
364 # Edit for your setup.
365 IPADDR="$IP" # REPLACE with YOUR IP address!
366 NETMASK="$NETMASK" # REPLACE with YOUR netmask!
367 NETWORK="$NETWORK" # REPLACE with YOUR network address!
368 BROADCAST="$BROADCAST" # REPLACE with YOUR broadcast address, if you
369 # have one. If not, leave blank and edit below.
370 GATEWAY="$GATEWAY" # REPLACE with YOUR gateway address!
371
372 # Uncomment the line below to configure your ethernet card.
373 ${IFCONFIG} eth0 \${IP} broadcast \${BROADCAST} netmask \${NETMASK}
374
375 # If the line above is uncommented, the code below can also be uncommented.
376 # It sees if the ethernet was properly initialized, and gives the admin some
377 # hints about what to do if it wasn't.
378 if [ ! \$? = 0 ]; then
379 cat << END
380 Your ethernet card was not initialized properly. Here are some reasons why this
381 may have happened, and the solutions:
382 1. Your kernel does not contain support for your card. Including all the
383 network drivers in a Linux kernel can make it too large to even boot, and
384 sometimes including extra drivers can cause system hangs. To support your
385 ethernet, either edit /etc/rc.d/rc.modules to load the support at boottime,
386 or compile and install a kernel that contains support.
387 2. You don't have an ethernet card, in which case you should comment out this
388 section of /etc/rc.d/rc.inet1. (Unless you don't mind seeing this error...)
389 END
390 fi
391
392 # Uncomment these to set up your IP routing table.
393 ${ROUTE} add -net \${NETWORK} netmask \${NETMASK}
394 ${ROUTE} add default gw \${GATEWAY} metric 1
395
396 # End of rc.inet1
397 EOF
398 copyFile ${tmpFile} "${INET}" 755
399
400 #
401 # Spit out the 'we are done' message.
402 #
403 message="<C></B>Network Setup Complete
404
405 Your network software has now been configured. You may
406 rerun this program to reconfigure or you may edit the
407 respective system files."
408 buttons="< OK >"
409 ${CDK_DIALOG} -m "${message}" -B "${buttons}" -S 2> /dev/null
410
411 #
412 # Clean up
413 #
414 rm -f ${tmpFile}
0 #! /bin/sh
1 # Attempt to guess a canonical system name.
2 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4
5 timestamp='2005-11-11'
6
7 # This file is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
20 # 02110-1301, USA.
21 #
22 # As a special exception to the GNU General Public License, if you
23 # distribute this file as part of a program that contains a
24 # configuration script generated by Autoconf, you may include it under
25 # the same distribution terms that you use for the rest of that program.
26
27
28 # Originally written by Per Bothner <per@bothner.com>.
29 # Please send patches to <config-patches@gnu.org>. Submit a context
30 # diff and a properly formatted ChangeLog entry.
31 #
32 # This script attempts to guess a canonical system name similar to
33 # config.sub. If it succeeds, it prints the system name on stdout, and
34 # exits with 0. Otherwise, it exits with 1.
35 #
36 # The plan is that this can be called by configure scripts if you
37 # don't specify an explicit build system type.
38
39 me=`echo "$0" | sed -e 's,.*/,,'`
40
41 usage="\
42 Usage: $0 [OPTION]
43
44 Output the configuration name of the system \`$me' is run on.
45
46 Operation modes:
47 -h, --help print this help, then exit
48 -t, --time-stamp print date of last modification, then exit
49 -v, --version print version number, then exit
50
51 Report bugs and patches to <config-patches@gnu.org>."
52
53 version="\
54 GNU config.guess ($timestamp)
55
56 Originally written by Per Bothner.
57 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
58 Free Software Foundation, Inc.
59
60 This is free software; see the source for copying conditions. There is NO
61 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
62
63 help="
64 Try \`$me --help' for more information."
65
66 # Parse command line
67 while test $# -gt 0 ; do
68 case $1 in
69 --time-stamp | --time* | -t )
70 echo "$timestamp" ; exit ;;
71 --version | -v )
72 echo "$version" ; exit ;;
73 --help | --h* | -h )
74 echo "$usage"; exit ;;
75 -- ) # Stop option processing
76 shift; break ;;
77 - ) # Use stdin as input.
78 break ;;
79 -* )
80 echo "$me: invalid option $1$help" >&2
81 exit 1 ;;
82 * )
83 break ;;
84 esac
85 done
86
87 if test $# != 0; then
88 echo "$me: too many arguments$help" >&2
89 exit 1
90 fi
91
92 trap 'exit 1' 1 2 15
93
94 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a
95 # compiler to aid in system detection is discouraged as it requires
96 # temporary files to be created and, as you can see below, it is a
97 # headache to deal with in a portable fashion.
98
99 # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
100 # use `HOST_CC' if defined, but it is deprecated.
101
102 # Portable tmp directory creation inspired by the Autoconf team.
103
104 set_cc_for_build='
105 trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
106 trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
107 : ${TMPDIR=/tmp} ;
108 { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
109 { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
110 { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
111 { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
112 dummy=$tmp/dummy ;
113 tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
114 case $CC_FOR_BUILD,$HOST_CC,$CC in
115 ,,) echo "int x;" > $dummy.c ;
116 for c in cc gcc c89 c99 ; do
117 if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
118 CC_FOR_BUILD="$c"; break ;
119 fi ;
120 done ;
121 if test x"$CC_FOR_BUILD" = x ; then
122 CC_FOR_BUILD=no_compiler_found ;
123 fi
124 ;;
125 ,,*) CC_FOR_BUILD=$CC ;;
126 ,*,*) CC_FOR_BUILD=$HOST_CC ;;
127 esac ; set_cc_for_build= ;'
128
129 # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
130 # (ghazi@noc.rutgers.edu 1994-08-24)
131 if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
132 PATH=$PATH:/.attbin ; export PATH
133 fi
134
135 UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
136 UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
137 UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
138 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
139
140 # Note: order is significant - the case branches are not exclusive.
141
142 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
143 *:NetBSD:*:*)
144 # NetBSD (nbsd) targets should (where applicable) match one or
145 # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
146 # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
147 # switched to ELF, *-*-netbsd* would select the old
148 # object file format. This provides both forward
149 # compatibility and a consistent mechanism for selecting the
150 # object file format.
151 #
152 # Note: NetBSD doesn't particularly care about the vendor
153 # portion of the name. We always set it to "unknown".
154 sysctl="sysctl -n hw.machine_arch"
155 UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
156 /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
157 case "${UNAME_MACHINE_ARCH}" in
158 armeb) machine=armeb-unknown ;;
159 arm*) machine=arm-unknown ;;
160 sh3el) machine=shl-unknown ;;
161 sh3eb) machine=sh-unknown ;;
162 *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
163 esac
164 # The Operating System including object format, if it has switched
165 # to ELF recently, or will in the future.
166 case "${UNAME_MACHINE_ARCH}" in
167 arm*|i386|m68k|ns32k|sh3*|sparc|vax)
168 eval $set_cc_for_build
169 if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
170 | grep __ELF__ >/dev/null
171 then
172 # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
173 # Return netbsd for either. FIX?
174 os=netbsd
175 else
176 os=netbsdelf
177 fi
178 ;;
179 *)
180 os=netbsd
181 ;;
182 esac
183 # The OS release
184 # Debian GNU/NetBSD machines have a different userland, and
185 # thus, need a distinct triplet. However, they do not need
186 # kernel version information, so it can be replaced with a
187 # suitable tag, in the style of linux-gnu.
188 case "${UNAME_VERSION}" in
189 Debian*)
190 release='-gnu'
191 ;;
192 *)
193 release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
194 ;;
195 esac
196 # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
197 # contains redundant information, the shorter form:
198 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
199 echo "${machine}-${os}${release}"
200 exit ;;
201 *:OpenBSD:*:*)
202 UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
203 echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
204 exit ;;
205 *:ekkoBSD:*:*)
206 echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
207 exit ;;
208 macppc:MirBSD:*:*)
209 echo powerppc-unknown-mirbsd${UNAME_RELEASE}
210 exit ;;
211 *:MirBSD:*:*)
212 echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
213 exit ;;
214 alpha:OSF1:*:*)
215 case $UNAME_RELEASE in
216 *4.0)
217 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
218 ;;
219 *5.*)
220 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
221 ;;
222 esac
223 # According to Compaq, /usr/sbin/psrinfo has been available on
224 # OSF/1 and Tru64 systems produced since 1995. I hope that
225 # covers most systems running today. This code pipes the CPU
226 # types through head -n 1, so we only detect the type of CPU 0.
227 ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
228 case "$ALPHA_CPU_TYPE" in
229 "EV4 (21064)")
230 UNAME_MACHINE="alpha" ;;
231 "EV4.5 (21064)")
232 UNAME_MACHINE="alpha" ;;
233 "LCA4 (21066/21068)")
234 UNAME_MACHINE="alpha" ;;
235 "EV5 (21164)")
236 UNAME_MACHINE="alphaev5" ;;
237 "EV5.6 (21164A)")
238 UNAME_MACHINE="alphaev56" ;;
239 "EV5.6 (21164PC)")
240 UNAME_MACHINE="alphapca56" ;;
241 "EV5.7 (21164PC)")
242 UNAME_MACHINE="alphapca57" ;;
243 "EV6 (21264)")
244 UNAME_MACHINE="alphaev6" ;;
245 "EV6.7 (21264A)")
246 UNAME_MACHINE="alphaev67" ;;
247 "EV6.8CB (21264C)")
248 UNAME_MACHINE="alphaev68" ;;
249 "EV6.8AL (21264B)")
250 UNAME_MACHINE="alphaev68" ;;
251 "EV6.8CX (21264D)")
252 UNAME_MACHINE="alphaev68" ;;
253 "EV6.9A (21264/EV69A)")
254 UNAME_MACHINE="alphaev69" ;;
255 "EV7 (21364)")
256 UNAME_MACHINE="alphaev7" ;;
257 "EV7.9 (21364A)")
258 UNAME_MACHINE="alphaev79" ;;
259 esac
260 # A Pn.n version is a patched version.
261 # A Vn.n version is a released version.
262 # A Tn.n version is a released field test version.
263 # A Xn.n version is an unreleased experimental baselevel.
264 # 1.2 uses "1.2" for uname -r.
265 echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
266 exit ;;
267 Alpha\ *:Windows_NT*:*)
268 # How do we know it's Interix rather than the generic POSIX subsystem?
269 # Should we change UNAME_MACHINE based on the output of uname instead
270 # of the specific Alpha model?
271 echo alpha-pc-interix
272 exit ;;
273 21064:Windows_NT:50:3)
274 echo alpha-dec-winnt3.5
275 exit ;;
276 Amiga*:UNIX_System_V:4.0:*)
277 echo m68k-unknown-sysv4
278 exit ;;
279 *:[Aa]miga[Oo][Ss]:*:*)
280 echo ${UNAME_MACHINE}-unknown-amigaos
281 exit ;;
282 *:[Mm]orph[Oo][Ss]:*:*)
283 echo ${UNAME_MACHINE}-unknown-morphos
284 exit ;;
285 *:OS/390:*:*)
286 echo i370-ibm-openedition
287 exit ;;
288 *:z/VM:*:*)
289 echo s390-ibm-zvmoe
290 exit ;;
291 *:OS400:*:*)
292 echo powerpc-ibm-os400
293 exit ;;
294 arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
295 echo arm-acorn-riscix${UNAME_RELEASE}
296 exit ;;
297 arm:riscos:*:*|arm:RISCOS:*:*)
298 echo arm-unknown-riscos
299 exit ;;
300 SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
301 echo hppa1.1-hitachi-hiuxmpp
302 exit ;;
303 Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
304 # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
305 if test "`(/bin/universe) 2>/dev/null`" = att ; then
306 echo pyramid-pyramid-sysv3
307 else
308 echo pyramid-pyramid-bsd
309 fi
310 exit ;;
311 NILE*:*:*:dcosx)
312 echo pyramid-pyramid-svr4
313 exit ;;
314 DRS?6000:unix:4.0:6*)
315 echo sparc-icl-nx6
316 exit ;;
317 DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
318 case `/usr/bin/uname -p` in
319 sparc) echo sparc-icl-nx7; exit ;;
320 esac ;;
321 sun4H:SunOS:5.*:*)
322 echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
323 exit ;;
324 sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
325 echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
326 exit ;;
327 i86pc:SunOS:5.*:*)
328 echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
329 exit ;;
330 sun4*:SunOS:6*:*)
331 # According to config.sub, this is the proper way to canonicalize
332 # SunOS6. Hard to guess exactly what SunOS6 will be like, but
333 # it's likely to be more like Solaris than SunOS4.
334 echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
335 exit ;;
336 sun4*:SunOS:*:*)
337 case "`/usr/bin/arch -k`" in
338 Series*|S4*)
339 UNAME_RELEASE=`uname -v`
340 ;;
341 esac
342 # Japanese Language versions have a version number like `4.1.3-JL'.
343 echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
344 exit ;;
345 sun3*:SunOS:*:*)
346 echo m68k-sun-sunos${UNAME_RELEASE}
347 exit ;;
348 sun*:*:4.2BSD:*)
349 UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
350 test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
351 case "`/bin/arch`" in
352 sun3)
353 echo m68k-sun-sunos${UNAME_RELEASE}
354 ;;
355 sun4)
356 echo sparc-sun-sunos${UNAME_RELEASE}
357 ;;
358 esac
359 exit ;;
360 aushp:SunOS:*:*)
361 echo sparc-auspex-sunos${UNAME_RELEASE}
362 exit ;;
363 # The situation for MiNT is a little confusing. The machine name
364 # can be virtually everything (everything which is not
365 # "atarist" or "atariste" at least should have a processor
366 # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
367 # to the lowercase version "mint" (or "freemint"). Finally
368 # the system name "TOS" denotes a system which is actually not
369 # MiNT. But MiNT is downward compatible to TOS, so this should
370 # be no problem.
371 atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
372 echo m68k-atari-mint${UNAME_RELEASE}
373 exit ;;
374 atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
375 echo m68k-atari-mint${UNAME_RELEASE}
376 exit ;;
377 *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
378 echo m68k-atari-mint${UNAME_RELEASE}
379 exit ;;
380 milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
381 echo m68k-milan-mint${UNAME_RELEASE}
382 exit ;;
383 hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
384 echo m68k-hades-mint${UNAME_RELEASE}
385 exit ;;
386 *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
387 echo m68k-unknown-mint${UNAME_RELEASE}
388 exit ;;
389 m68k:machten:*:*)
390 echo m68k-apple-machten${UNAME_RELEASE}
391 exit ;;
392 powerpc:machten:*:*)
393 echo powerpc-apple-machten${UNAME_RELEASE}
394 exit ;;
395 RISC*:Mach:*:*)
396 echo mips-dec-mach_bsd4.3
397 exit ;;
398 RISC*:ULTRIX:*:*)
399 echo mips-dec-ultrix${UNAME_RELEASE}
400 exit ;;
401 VAX*:ULTRIX*:*:*)
402 echo vax-dec-ultrix${UNAME_RELEASE}
403 exit ;;
404 2020:CLIX:*:* | 2430:CLIX:*:*)
405 echo clipper-intergraph-clix${UNAME_RELEASE}
406 exit ;;
407 mips:*:*:UMIPS | mips:*:*:RISCos)
408 eval $set_cc_for_build
409 sed 's/^ //' << EOF >$dummy.c
410 #ifdef __cplusplus
411 #include <stdio.h> /* for printf() prototype */
412 int main (int argc, char *argv[]) {
413 #else
414 int main (argc, argv) int argc; char *argv[]; {
415 #endif
416 #if defined (host_mips) && defined (MIPSEB)
417 #if defined (SYSTYPE_SYSV)
418 printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
419 #endif
420 #if defined (SYSTYPE_SVR4)
421 printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
422 #endif
423 #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
424 printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
425 #endif
426 #endif
427 exit (-1);
428 }
429 EOF
430 $CC_FOR_BUILD -o $dummy $dummy.c &&
431 dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
432 SYSTEM_NAME=`$dummy $dummyarg` &&
433 { echo "$SYSTEM_NAME"; exit; }
434 echo mips-mips-riscos${UNAME_RELEASE}
435 exit ;;
436 Motorola:PowerMAX_OS:*:*)
437 echo powerpc-motorola-powermax
438 exit ;;
439 Motorola:*:4.3:PL8-*)
440 echo powerpc-harris-powermax
441 exit ;;
442 Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
443 echo powerpc-harris-powermax
444 exit ;;
445 Night_Hawk:Power_UNIX:*:*)
446 echo powerpc-harris-powerunix
447 exit ;;
448 m88k:CX/UX:7*:*)
449 echo m88k-harris-cxux7
450 exit ;;
451 m88k:*:4*:R4*)
452 echo m88k-motorola-sysv4
453 exit ;;
454 m88k:*:3*:R3*)
455 echo m88k-motorola-sysv3
456 exit ;;
457 AViiON:dgux:*:*)
458 # DG/UX returns AViiON for all architectures
459 UNAME_PROCESSOR=`/usr/bin/uname -p`
460 if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
461 then
462 if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
463 [ ${TARGET_BINARY_INTERFACE}x = x ]
464 then
465 echo m88k-dg-dgux${UNAME_RELEASE}
466 else
467 echo m88k-dg-dguxbcs${UNAME_RELEASE}
468 fi
469 else
470 echo i586-dg-dgux${UNAME_RELEASE}
471 fi
472 exit ;;
473 M88*:DolphinOS:*:*) # DolphinOS (SVR3)
474 echo m88k-dolphin-sysv3
475 exit ;;
476 M88*:*:R3*:*)
477 # Delta 88k system running SVR3
478 echo m88k-motorola-sysv3
479 exit ;;
480 XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
481 echo m88k-tektronix-sysv3
482 exit ;;
483 Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
484 echo m68k-tektronix-bsd
485 exit ;;
486 *:IRIX*:*:*)
487 echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
488 exit ;;
489 ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
490 echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
491 exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
492 i*86:AIX:*:*)
493 echo i386-ibm-aix
494 exit ;;
495 ia64:AIX:*:*)
496 if [ -x /usr/bin/oslevel ] ; then
497 IBM_REV=`/usr/bin/oslevel`
498 else
499 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
500 fi
501 echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
502 exit ;;
503 *:AIX:2:3)
504 if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
505 eval $set_cc_for_build
506 sed 's/^ //' << EOF >$dummy.c
507 #include <sys/systemcfg.h>
508
509 main()
510 {
511 if (!__power_pc())
512 exit(1);
513 puts("powerpc-ibm-aix3.2.5");
514 exit(0);
515 }
516 EOF
517 if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
518 then
519 echo "$SYSTEM_NAME"
520 else
521 echo rs6000-ibm-aix3.2.5
522 fi
523 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
524 echo rs6000-ibm-aix3.2.4
525 else
526 echo rs6000-ibm-aix3.2
527 fi
528 exit ;;
529 *:AIX:*:[45])
530 IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
531 if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
532 IBM_ARCH=rs6000
533 else
534 IBM_ARCH=powerpc
535 fi
536 if [ -x /usr/bin/oslevel ] ; then
537 IBM_REV=`/usr/bin/oslevel`
538 else
539 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
540 fi
541 echo ${IBM_ARCH}-ibm-aix${IBM_REV}
542 exit ;;
543 *:AIX:*:*)
544 echo rs6000-ibm-aix
545 exit ;;
546 ibmrt:4.4BSD:*|romp-ibm:BSD:*)
547 echo romp-ibm-bsd4.4
548 exit ;;
549 ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
550 echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
551 exit ;; # report: romp-ibm BSD 4.3
552 *:BOSX:*:*)
553 echo rs6000-bull-bosx
554 exit ;;
555 DPX/2?00:B.O.S.:*:*)
556 echo m68k-bull-sysv3
557 exit ;;
558 9000/[34]??:4.3bsd:1.*:*)
559 echo m68k-hp-bsd
560 exit ;;
561 hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
562 echo m68k-hp-bsd4.4
563 exit ;;
564 9000/[34678]??:HP-UX:*:*)
565 HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
566 case "${UNAME_MACHINE}" in
567 9000/31? ) HP_ARCH=m68000 ;;
568 9000/[34]?? ) HP_ARCH=m68k ;;
569 9000/[678][0-9][0-9])
570 if [ -x /usr/bin/getconf ]; then
571 sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
572 sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
573 case "${sc_cpu_version}" in
574 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
575 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
576 532) # CPU_PA_RISC2_0
577 case "${sc_kernel_bits}" in
578 32) HP_ARCH="hppa2.0n" ;;
579 64) HP_ARCH="hppa2.0w" ;;
580 '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
581 esac ;;
582 esac
583 fi
584 if [ "${HP_ARCH}" = "" ]; then
585 eval $set_cc_for_build
586 sed 's/^ //' << EOF >$dummy.c
587
588 #define _HPUX_SOURCE
589 #include <stdlib.h>
590 #include <unistd.h>
591
592 int main ()
593 {
594 #if defined(_SC_KERNEL_BITS)
595 long bits = sysconf(_SC_KERNEL_BITS);
596 #endif
597 long cpu = sysconf (_SC_CPU_VERSION);
598
599 switch (cpu)
600 {
601 case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
602 case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
603 case CPU_PA_RISC2_0:
604 #if defined(_SC_KERNEL_BITS)
605 switch (bits)
606 {
607 case 64: puts ("hppa2.0w"); break;
608 case 32: puts ("hppa2.0n"); break;
609 default: puts ("hppa2.0"); break;
610 } break;
611 #else /* !defined(_SC_KERNEL_BITS) */
612 puts ("hppa2.0"); break;
613 #endif
614 default: puts ("hppa1.0"); break;
615 }
616 exit (0);
617 }
618 EOF
619 (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
620 test -z "$HP_ARCH" && HP_ARCH=hppa
621 fi ;;
622 esac
623 if [ ${HP_ARCH} = "hppa2.0w" ]
624 then
625 eval $set_cc_for_build
626
627 # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
628 # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
629 # generating 64-bit code. GNU and HP use different nomenclature:
630 #
631 # $ CC_FOR_BUILD=cc ./config.guess
632 # => hppa2.0w-hp-hpux11.23
633 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
634 # => hppa64-hp-hpux11.23
635
636 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
637 grep __LP64__ >/dev/null
638 then
639 HP_ARCH="hppa2.0w"
640 else
641 HP_ARCH="hppa64"
642 fi
643 fi
644 echo ${HP_ARCH}-hp-hpux${HPUX_REV}
645 exit ;;
646 ia64:HP-UX:*:*)
647 HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
648 echo ia64-hp-hpux${HPUX_REV}
649 exit ;;
650 3050*:HI-UX:*:*)
651 eval $set_cc_for_build
652 sed 's/^ //' << EOF >$dummy.c
653 #include <unistd.h>
654 int
655 main ()
656 {
657 long cpu = sysconf (_SC_CPU_VERSION);
658 /* The order matters, because CPU_IS_HP_MC68K erroneously returns
659 true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
660 results, however. */
661 if (CPU_IS_PA_RISC (cpu))
662 {
663 switch (cpu)
664 {
665 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
666 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
667 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
668 default: puts ("hppa-hitachi-hiuxwe2"); break;
669 }
670 }
671 else if (CPU_IS_HP_MC68K (cpu))
672 puts ("m68k-hitachi-hiuxwe2");
673 else puts ("unknown-hitachi-hiuxwe2");
674 exit (0);
675 }
676 EOF
677 $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
678 { echo "$SYSTEM_NAME"; exit; }
679 echo unknown-hitachi-hiuxwe2
680 exit ;;
681 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
682 echo hppa1.1-hp-bsd
683 exit ;;
684 9000/8??:4.3bsd:*:*)
685 echo hppa1.0-hp-bsd
686 exit ;;
687 *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
688 echo hppa1.0-hp-mpeix
689 exit ;;
690 hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
691 echo hppa1.1-hp-osf
692 exit ;;
693 hp8??:OSF1:*:*)
694 echo hppa1.0-hp-osf
695 exit ;;
696 i*86:OSF1:*:*)
697 if [ -x /usr/sbin/sysversion ] ; then
698 echo ${UNAME_MACHINE}-unknown-osf1mk
699 else
700 echo ${UNAME_MACHINE}-unknown-osf1
701 fi
702 exit ;;
703 parisc*:Lites*:*:*)
704 echo hppa1.1-hp-lites
705 exit ;;
706 C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
707 echo c1-convex-bsd
708 exit ;;
709 C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
710 if getsysinfo -f scalar_acc
711 then echo c32-convex-bsd
712 else echo c2-convex-bsd
713 fi
714 exit ;;
715 C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
716 echo c34-convex-bsd
717 exit ;;
718 C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
719 echo c38-convex-bsd
720 exit ;;
721 C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
722 echo c4-convex-bsd
723 exit ;;
724 CRAY*Y-MP:*:*:*)
725 echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
726 exit ;;
727 CRAY*[A-Z]90:*:*:*)
728 echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
729 | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
730 -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
731 -e 's/\.[^.]*$/.X/'
732 exit ;;
733 CRAY*TS:*:*:*)
734 echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
735 exit ;;
736 CRAY*T3E:*:*:*)
737 echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
738 exit ;;
739 CRAY*SV1:*:*:*)
740 echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
741 exit ;;
742 *:UNICOS/mp:*:*)
743 echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
744 exit ;;
745 F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
746 FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
747 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
748 FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
749 echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
750 exit ;;
751 5000:UNIX_System_V:4.*:*)
752 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
753 FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
754 echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
755 exit ;;
756 i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
757 echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
758 exit ;;
759 sparc*:BSD/OS:*:*)
760 echo sparc-unknown-bsdi${UNAME_RELEASE}
761 exit ;;
762 *:BSD/OS:*:*)
763 echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
764 exit ;;
765 *:FreeBSD:*:*)
766 echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
767 exit ;;
768 i*:CYGWIN*:*)
769 echo ${UNAME_MACHINE}-pc-cygwin
770 exit ;;
771 i*:MINGW*:*)
772 echo ${UNAME_MACHINE}-pc-mingw32
773 exit ;;
774 i*:windows32*:*)
775 # uname -m includes "-pc" on this system.
776 echo ${UNAME_MACHINE}-mingw32
777 exit ;;
778 i*:PW*:*)
779 echo ${UNAME_MACHINE}-pc-pw32
780 exit ;;
781 x86:Interix*:[345]*)
782 echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
783 exit ;;
784 [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
785 echo i${UNAME_MACHINE}-pc-mks
786 exit ;;
787 i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
788 # How do we know it's Interix rather than the generic POSIX subsystem?
789 # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
790 # UNAME_MACHINE based on the output of uname instead of i386?
791 echo i586-pc-interix
792 exit ;;
793 i*:UWIN*:*)
794 echo ${UNAME_MACHINE}-pc-uwin
795 exit ;;
796 amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
797 echo x86_64-unknown-cygwin
798 exit ;;
799 p*:CYGWIN*:*)
800 echo powerpcle-unknown-cygwin
801 exit ;;
802 prep*:SunOS:5.*:*)
803 echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
804 exit ;;
805 *:GNU:*:*)
806 # the GNU system
807 echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
808 exit ;;
809 *:GNU/*:*:*)
810 # other systems with GNU libc and userland
811 echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
812 exit ;;
813 i*86:Minix:*:*)
814 echo ${UNAME_MACHINE}-pc-minix
815 exit ;;
816 arm*:Linux:*:*)
817 echo ${UNAME_MACHINE}-unknown-linux-gnu
818 exit ;;
819 cris:Linux:*:*)
820 echo cris-axis-linux-gnu
821 exit ;;
822 crisv32:Linux:*:*)
823 echo crisv32-axis-linux-gnu
824 exit ;;
825 frv:Linux:*:*)
826 echo frv-unknown-linux-gnu
827 exit ;;
828 ia64:Linux:*:*)
829 echo ${UNAME_MACHINE}-unknown-linux-gnu
830 exit ;;
831 m32r*:Linux:*:*)
832 echo ${UNAME_MACHINE}-unknown-linux-gnu
833 exit ;;
834 m68*:Linux:*:*)
835 echo ${UNAME_MACHINE}-unknown-linux-gnu
836 exit ;;
837 mips:Linux:*:*)
838 eval $set_cc_for_build
839 sed 's/^ //' << EOF >$dummy.c
840 #undef CPU
841 #undef mips
842 #undef mipsel
843 #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
844 CPU=mipsel
845 #else
846 #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
847 CPU=mips
848 #else
849 CPU=
850 #endif
851 #endif
852 EOF
853 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
854 test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
855 ;;
856 mips64:Linux:*:*)
857 eval $set_cc_for_build
858 sed 's/^ //' << EOF >$dummy.c
859 #undef CPU
860 #undef mips64
861 #undef mips64el
862 #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
863 CPU=mips64el
864 #else
865 #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
866 CPU=mips64
867 #else
868 CPU=
869 #endif
870 #endif
871 EOF
872 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
873 test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
874 ;;
875 or32:Linux:*:*)
876 echo or32-unknown-linux-gnu
877 exit ;;
878 ppc:Linux:*:*)
879 echo powerpc-unknown-linux-gnu
880 exit ;;
881 ppc64:Linux:*:*)
882 echo powerpc64-unknown-linux-gnu
883 exit ;;
884 alpha:Linux:*:*)
885 case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
886 EV5) UNAME_MACHINE=alphaev5 ;;
887 EV56) UNAME_MACHINE=alphaev56 ;;
888 PCA56) UNAME_MACHINE=alphapca56 ;;
889 PCA57) UNAME_MACHINE=alphapca56 ;;
890 EV6) UNAME_MACHINE=alphaev6 ;;
891 EV67) UNAME_MACHINE=alphaev67 ;;
892 EV68*) UNAME_MACHINE=alphaev68 ;;
893 esac
894 objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
895 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
896 echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
897 exit ;;
898 parisc:Linux:*:* | hppa:Linux:*:*)
899 # Look for CPU level
900 case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
901 PA7*) echo hppa1.1-unknown-linux-gnu ;;
902 PA8*) echo hppa2.0-unknown-linux-gnu ;;
903 *) echo hppa-unknown-linux-gnu ;;
904 esac
905 exit ;;
906 parisc64:Linux:*:* | hppa64:Linux:*:*)
907 echo hppa64-unknown-linux-gnu
908 exit ;;
909 s390:Linux:*:* | s390x:Linux:*:*)
910 echo ${UNAME_MACHINE}-ibm-linux
911 exit ;;
912 sh64*:Linux:*:*)
913 echo ${UNAME_MACHINE}-unknown-linux-gnu
914 exit ;;
915 sh*:Linux:*:*)
916 echo ${UNAME_MACHINE}-unknown-linux-gnu
917 exit ;;
918 sparc:Linux:*:* | sparc64:Linux:*:*)
919 echo ${UNAME_MACHINE}-unknown-linux-gnu
920 exit ;;
921 x86_64:Linux:*:*)
922 echo x86_64-unknown-linux-gnu
923 exit ;;
924 i*86:Linux:*:*)
925 # The BFD linker knows what the default object file format is, so
926 # first see if it will tell us. cd to the root directory to prevent
927 # problems with other programs or directories called `ld' in the path.
928 # Set LC_ALL=C to ensure ld outputs messages in English.
929 ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
930 | sed -ne '/supported targets:/!d
931 s/[ ][ ]*/ /g
932 s/.*supported targets: *//
933 s/ .*//
934 p'`
935 case "$ld_supported_targets" in
936 elf32-i386)
937 TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
938 ;;
939 a.out-i386-linux)
940 echo "${UNAME_MACHINE}-pc-linux-gnuaout"
941 exit ;;
942 coff-i386)
943 echo "${UNAME_MACHINE}-pc-linux-gnucoff"
944 exit ;;
945 "")
946 # Either a pre-BFD a.out linker (linux-gnuoldld) or
947 # one that does not give us useful --help.
948 echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
949 exit ;;
950 esac
951 # Determine whether the default compiler is a.out or elf
952 eval $set_cc_for_build
953 sed 's/^ //' << EOF >$dummy.c
954 #include <features.h>
955 #ifdef __ELF__
956 # ifdef __GLIBC__
957 # if __GLIBC__ >= 2
958 LIBC=gnu
959 # else
960 LIBC=gnulibc1
961 # endif
962 # else
963 LIBC=gnulibc1
964 # endif
965 #else
966 #ifdef __INTEL_COMPILER
967 LIBC=gnu
968 #else
969 LIBC=gnuaout
970 #endif
971 #endif
972 #ifdef __dietlibc__
973 LIBC=dietlibc
974 #endif
975 EOF
976 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
977 test x"${LIBC}" != x && {
978 echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
979 exit
980 }
981 test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
982 ;;
983 i*86:DYNIX/ptx:4*:*)
984 # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
985 # earlier versions are messed up and put the nodename in both
986 # sysname and nodename.
987 echo i386-sequent-sysv4
988 exit ;;
989 i*86:UNIX_SV:4.2MP:2.*)
990 # Unixware is an offshoot of SVR4, but it has its own version
991 # number series starting with 2...
992 # I am not positive that other SVR4 systems won't match this,
993 # I just have to hope. -- rms.
994 # Use sysv4.2uw... so that sysv4* matches it.
995 echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
996 exit ;;
997 i*86:OS/2:*:*)
998 # If we were able to find `uname', then EMX Unix compatibility
999 # is probably installed.
1000 echo ${UNAME_MACHINE}-pc-os2-emx
1001 exit ;;
1002 i*86:XTS-300:*:STOP)
1003 echo ${UNAME_MACHINE}-unknown-stop
1004 exit ;;
1005 i*86:atheos:*:*)
1006 echo ${UNAME_MACHINE}-unknown-atheos
1007 exit ;;
1008 i*86:syllable:*:*)
1009 echo ${UNAME_MACHINE}-pc-syllable
1010 exit ;;
1011 i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
1012 echo i386-unknown-lynxos${UNAME_RELEASE}
1013 exit ;;
1014 i*86:*DOS:*:*)
1015 echo ${UNAME_MACHINE}-pc-msdosdjgpp
1016 exit ;;
1017 i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
1018 UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
1019 if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
1020 echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
1021 else
1022 echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
1023 fi
1024 exit ;;
1025 i*86:*:5:[678]*)
1026 # UnixWare 7.x, OpenUNIX and OpenServer 6.
1027 case `/bin/uname -X | grep "^Machine"` in
1028 *486*) UNAME_MACHINE=i486 ;;
1029 *Pentium) UNAME_MACHINE=i586 ;;
1030 *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
1031 esac
1032 echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1033 exit ;;
1034 i*86:*:3.2:*)
1035 if test -f /usr/options/cb.name; then
1036 UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1037 echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
1038 elif /bin/uname -X 2>/dev/null >/dev/null ; then
1039 UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
1040 (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
1041 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
1042 && UNAME_MACHINE=i586
1043 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
1044 && UNAME_MACHINE=i686
1045 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
1046 && UNAME_MACHINE=i686
1047 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
1048 else
1049 echo ${UNAME_MACHINE}-pc-sysv32
1050 fi
1051 exit ;;
1052 pc:*:*:*)
1053 # Left here for compatibility:
1054 # uname -m prints for DJGPP always 'pc', but it prints nothing about
1055 # the processor, so we play safe by assuming i386.
1056 echo i386-pc-msdosdjgpp
1057 exit ;;
1058 Intel:Mach:3*:*)
1059 echo i386-pc-mach3
1060 exit ;;
1061 paragon:*:*:*)
1062 echo i860-intel-osf1
1063 exit ;;
1064 i860:*:4.*:*) # i860-SVR4
1065 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1066 echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
1067 else # Add other i860-SVR4 vendors below as they are discovered.
1068 echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
1069 fi
1070 exit ;;
1071 mini*:CTIX:SYS*5:*)
1072 # "miniframe"
1073 echo m68010-convergent-sysv
1074 exit ;;
1075 mc68k:UNIX:SYSTEM5:3.51m)
1076 echo m68k-convergent-sysv
1077 exit ;;
1078 M680?0:D-NIX:5.3:*)
1079 echo m68k-diab-dnix
1080 exit ;;
1081 M68*:*:R3V[5678]*:*)
1082 test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
1083 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
1084 OS_REL=''
1085 test -r /etc/.relid \
1086 && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1087 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1088 && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
1089 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1090 && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
1091 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
1092 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1093 && { echo i486-ncr-sysv4; exit; } ;;
1094 m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
1095 echo m68k-unknown-lynxos${UNAME_RELEASE}
1096 exit ;;
1097 mc68030:UNIX_System_V:4.*:*)
1098 echo m68k-atari-sysv4
1099 exit ;;
1100 TSUNAMI:LynxOS:2.*:*)
1101 echo sparc-unknown-lynxos${UNAME_RELEASE}
1102 exit ;;
1103 rs6000:LynxOS:2.*:*)
1104 echo rs6000-unknown-lynxos${UNAME_RELEASE}
1105 exit ;;
1106 PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
1107 echo powerpc-unknown-lynxos${UNAME_RELEASE}
1108 exit ;;
1109 SM[BE]S:UNIX_SV:*:*)
1110 echo mips-dde-sysv${UNAME_RELEASE}
1111 exit ;;
1112 RM*:ReliantUNIX-*:*:*)
1113 echo mips-sni-sysv4
1114 exit ;;
1115 RM*:SINIX-*:*:*)
1116 echo mips-sni-sysv4
1117 exit ;;
1118 *:SINIX-*:*:*)
1119 if uname -p 2>/dev/null >/dev/null ; then
1120 UNAME_MACHINE=`(uname -p) 2>/dev/null`
1121 echo ${UNAME_MACHINE}-sni-sysv4
1122 else
1123 echo ns32k-sni-sysv
1124 fi
1125 exit ;;
1126 PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
1127 # says <Richard.M.Bartel@ccMail.Census.GOV>
1128 echo i586-unisys-sysv4
1129 exit ;;
1130 *:UNIX_System_V:4*:FTX*)
1131 # From Gerald Hewes <hewes@openmarket.com>.
1132 # How about differentiating between stratus architectures? -djm
1133 echo hppa1.1-stratus-sysv4
1134 exit ;;
1135 *:*:*:FTX*)
1136 # From seanf@swdc.stratus.com.
1137 echo i860-stratus-sysv4
1138 exit ;;
1139 i*86:VOS:*:*)
1140 # From Paul.Green@stratus.com.
1141 echo ${UNAME_MACHINE}-stratus-vos
1142 exit ;;
1143 *:VOS:*:*)
1144 # From Paul.Green@stratus.com.
1145 echo hppa1.1-stratus-vos
1146 exit ;;
1147 mc68*:A/UX:*:*)
1148 echo m68k-apple-aux${UNAME_RELEASE}
1149 exit ;;
1150 news*:NEWS-OS:6*:*)
1151 echo mips-sony-newsos6
1152 exit ;;
1153 R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
1154 if [ -d /usr/nec ]; then
1155 echo mips-nec-sysv${UNAME_RELEASE}
1156 else
1157 echo mips-unknown-sysv${UNAME_RELEASE}
1158 fi
1159 exit ;;
1160 BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
1161 echo powerpc-be-beos
1162 exit ;;
1163 BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
1164 echo powerpc-apple-beos
1165 exit ;;
1166 BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
1167 echo i586-pc-beos
1168 exit ;;
1169 SX-4:SUPER-UX:*:*)
1170 echo sx4-nec-superux${UNAME_RELEASE}
1171 exit ;;
1172 SX-5:SUPER-UX:*:*)
1173 echo sx5-nec-superux${UNAME_RELEASE}
1174 exit ;;
1175 SX-6:SUPER-UX:*:*)
1176 echo sx6-nec-superux${UNAME_RELEASE}
1177 exit ;;
1178 Power*:Rhapsody:*:*)
1179 echo powerpc-apple-rhapsody${UNAME_RELEASE}
1180 exit ;;
1181 *:Rhapsody:*:*)
1182 echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
1183 exit ;;
1184 *:Darwin:*:*)
1185 UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
1186 case $UNAME_PROCESSOR in
1187 unknown) UNAME_PROCESSOR=powerpc ;;
1188 esac
1189 echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
1190 exit ;;
1191 *:procnto*:*:* | *:QNX:[0123456789]*:*)
1192 UNAME_PROCESSOR=`uname -p`
1193 if test "$UNAME_PROCESSOR" = "x86"; then
1194 UNAME_PROCESSOR=i386
1195 UNAME_MACHINE=pc
1196 fi
1197 echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
1198 exit ;;
1199 *:QNX:*:4*)
1200 echo i386-pc-qnx
1201 exit ;;
1202 NSE-?:NONSTOP_KERNEL:*:*)
1203 echo nse-tandem-nsk${UNAME_RELEASE}
1204 exit ;;
1205 NSR-?:NONSTOP_KERNEL:*:*)
1206 echo nsr-tandem-nsk${UNAME_RELEASE}
1207 exit ;;
1208 *:NonStop-UX:*:*)
1209 echo mips-compaq-nonstopux
1210 exit ;;
1211 BS2000:POSIX*:*:*)
1212 echo bs2000-siemens-sysv
1213 exit ;;
1214 DS/*:UNIX_System_V:*:*)
1215 echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
1216 exit ;;
1217 *:Plan9:*:*)
1218 # "uname -m" is not consistent, so use $cputype instead. 386
1219 # is converted to i386 for consistency with other x86
1220 # operating systems.
1221 if test "$cputype" = "386"; then
1222 UNAME_MACHINE=i386
1223 else
1224 UNAME_MACHINE="$cputype"
1225 fi
1226 echo ${UNAME_MACHINE}-unknown-plan9
1227 exit ;;
1228 *:TOPS-10:*:*)
1229 echo pdp10-unknown-tops10
1230 exit ;;
1231 *:TENEX:*:*)
1232 echo pdp10-unknown-tenex
1233 exit ;;
1234 KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
1235 echo pdp10-dec-tops20
1236 exit ;;
1237 XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
1238 echo pdp10-xkl-tops20
1239 exit ;;
1240 *:TOPS-20:*:*)
1241 echo pdp10-unknown-tops20
1242 exit ;;
1243 *:ITS:*:*)
1244 echo pdp10-unknown-its
1245 exit ;;
1246 SEI:*:*:SEIUX)
1247 echo mips-sei-seiux${UNAME_RELEASE}
1248 exit ;;
1249 *:DragonFly:*:*)
1250 echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
1251 exit ;;
1252 *:*VMS:*:*)
1253 UNAME_MACHINE=`(uname -p) 2>/dev/null`
1254 case "${UNAME_MACHINE}" in
1255 A*) echo alpha-dec-vms ; exit ;;
1256 I*) echo ia64-dec-vms ; exit ;;
1257 V*) echo vax-dec-vms ; exit ;;
1258 esac ;;
1259 *:XENIX:*:SysV)
1260 echo i386-pc-xenix
1261 exit ;;
1262 i*86:skyos:*:*)
1263 echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
1264 exit ;;
1265 esac
1266
1267 #echo '(No uname command or uname output not recognized.)' 1>&2
1268 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
1269
1270 eval $set_cc_for_build
1271 cat >$dummy.c <<EOF
1272 #ifdef _SEQUENT_
1273 # include <sys/types.h>
1274 # include <sys/utsname.h>
1275 #endif
1276 main ()
1277 {
1278 #if defined (sony)
1279 #if defined (MIPSEB)
1280 /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
1281 I don't know.... */
1282 printf ("mips-sony-bsd\n"); exit (0);
1283 #else
1284 #include <sys/param.h>
1285 printf ("m68k-sony-newsos%s\n",
1286 #ifdef NEWSOS4
1287 "4"
1288 #else
1289 ""
1290 #endif
1291 ); exit (0);
1292 #endif
1293 #endif
1294
1295 #if defined (__arm) && defined (__acorn) && defined (__unix)
1296 printf ("arm-acorn-riscix\n"); exit (0);
1297 #endif
1298
1299 #if defined (hp300) && !defined (hpux)
1300 printf ("m68k-hp-bsd\n"); exit (0);
1301 #endif
1302
1303 #if defined (NeXT)
1304 #if !defined (__ARCHITECTURE__)
1305 #define __ARCHITECTURE__ "m68k"
1306 #endif
1307 int version;
1308 version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1309 if (version < 4)
1310 printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1311 else
1312 printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1313 exit (0);
1314 #endif
1315
1316 #if defined (MULTIMAX) || defined (n16)
1317 #if defined (UMAXV)
1318 printf ("ns32k-encore-sysv\n"); exit (0);
1319 #else
1320 #if defined (CMU)
1321 printf ("ns32k-encore-mach\n"); exit (0);
1322 #else
1323 printf ("ns32k-encore-bsd\n"); exit (0);
1324 #endif
1325 #endif
1326 #endif
1327
1328 #if defined (__386BSD__)
1329 printf ("i386-pc-bsd\n"); exit (0);
1330 #endif
1331
1332 #if defined (sequent)
1333 #if defined (i386)
1334 printf ("i386-sequent-dynix\n"); exit (0);
1335 #endif
1336 #if defined (ns32000)
1337 printf ("ns32k-sequent-dynix\n"); exit (0);
1338 #endif
1339 #endif
1340
1341 #if defined (_SEQUENT_)
1342 struct utsname un;
1343
1344 uname(&un);
1345
1346 if (strncmp(un.version, "V2", 2) == 0) {
1347 printf ("i386-sequent-ptx2\n"); exit (0);
1348 }
1349 if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
1350 printf ("i386-sequent-ptx1\n"); exit (0);
1351 }
1352 printf ("i386-sequent-ptx\n"); exit (0);
1353
1354 #endif
1355
1356 #if defined (vax)
1357 # if !defined (ultrix)
1358 # include <sys/param.h>
1359 # if defined (BSD)
1360 # if BSD == 43
1361 printf ("vax-dec-bsd4.3\n"); exit (0);
1362 # else
1363 # if BSD == 199006
1364 printf ("vax-dec-bsd4.3reno\n"); exit (0);
1365 # else
1366 printf ("vax-dec-bsd\n"); exit (0);
1367 # endif
1368 # endif
1369 # else
1370 printf ("vax-dec-bsd\n"); exit (0);
1371 # endif
1372 # else
1373 printf ("vax-dec-ultrix\n"); exit (0);
1374 # endif
1375 #endif
1376
1377 #if defined (alliant) && defined (i860)
1378 printf ("i860-alliant-bsd\n"); exit (0);
1379 #endif
1380
1381 exit (1);
1382 }
1383 EOF
1384
1385 $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
1386 { echo "$SYSTEM_NAME"; exit; }
1387
1388 # Apollos put the system type in the environment.
1389
1390 test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
1391
1392 # Convex versions that predate uname can use getsysinfo(1)
1393
1394 if [ -x /usr/convex/getsysinfo ]
1395 then
1396 case `getsysinfo -f cpu_type` in
1397 c1*)
1398 echo c1-convex-bsd
1399 exit ;;
1400 c2*)
1401 if getsysinfo -f scalar_acc
1402 then echo c32-convex-bsd
1403 else echo c2-convex-bsd
1404 fi
1405 exit ;;
1406 c34*)
1407 echo c34-convex-bsd
1408 exit ;;
1409 c38*)
1410 echo c38-convex-bsd
1411 exit ;;
1412 c4*)
1413 echo c4-convex-bsd
1414 exit ;;
1415 esac
1416 fi
1417
1418 cat >&2 <<EOF
1419 $0: unable to guess system type
1420
1421 This script, last modified $timestamp, has failed to recognize
1422 the operating system you are using. It is advised that you
1423 download the most up to date version of the config scripts from
1424
1425 http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
1426 and
1427 http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
1428
1429 If the version you run ($0) is already up to date, please
1430 send the following data and any information you think might be
1431 pertinent to <config-patches@gnu.org> in order to provide the needed
1432 information to handle your system.
1433
1434 config.guess timestamp = $timestamp
1435
1436 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1437 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1438 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1439 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1440
1441 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
1442 /bin/uname -X = `(/bin/uname -X) 2>/dev/null`
1443
1444 hostinfo = `(hostinfo) 2>/dev/null`
1445 /bin/universe = `(/bin/universe) 2>/dev/null`
1446 /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
1447 /bin/arch = `(/bin/arch) 2>/dev/null`
1448 /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
1449 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
1450
1451 UNAME_MACHINE = ${UNAME_MACHINE}
1452 UNAME_RELEASE = ${UNAME_RELEASE}
1453 UNAME_SYSTEM = ${UNAME_SYSTEM}
1454 UNAME_VERSION = ${UNAME_VERSION}
1455 EOF
1456
1457 exit 1
1458
1459 # Local variables:
1460 # eval: (add-hook 'write-file-hooks 'time-stamp)
1461 # time-stamp-start: "timestamp='"
1462 # time-stamp-format: "%:y-%02m-%02d"
1463 # time-stamp-end: "'"
1464 # End:
0 #! /bin/sh
1 # Configuration validation subroutine script.
2 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4
5 timestamp='2005-11-13'
6
7 # This file is (in principle) common to ALL GNU software.
8 # The presence of a machine in this file suggests that SOME GNU software
9 # can handle that machine. It does not imply ALL GNU software can.
10 #
11 # This file is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
24 # 02110-1301, USA.
25 #
26 # As a special exception to the GNU General Public License, if you
27 # distribute this file as part of a program that contains a
28 # configuration script generated by Autoconf, you may include it under
29 # the same distribution terms that you use for the rest of that program.
30
31
32 # Please send patches to <config-patches@gnu.org>. Submit a context
33 # diff and a properly formatted ChangeLog entry.
34 #
35 # Configuration subroutine to validate and canonicalize a configuration type.
36 # Supply the specified configuration type as an argument.
37 # If it is invalid, we print an error message on stderr and exit with code 1.
38 # Otherwise, we print the canonical config type on stdout and succeed.
39
40 # This file is supposed to be the same for all GNU packages
41 # and recognize all the CPU types, system types and aliases
42 # that are meaningful with *any* GNU software.
43 # Each package is responsible for reporting which valid configurations
44 # it does not support. The user should be able to distinguish
45 # a failure to support a valid configuration from a meaningless
46 # configuration.
47
48 # The goal of this file is to map all the various variations of a given
49 # machine specification into a single specification in the form:
50 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51 # or in some cases, the newer four-part form:
52 # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53 # It is wrong to echo any other type of specification.
54
55 me=`echo "$0" | sed -e 's,.*/,,'`
56
57 usage="\
58 Usage: $0 [OPTION] CPU-MFR-OPSYS
59 $0 [OPTION] ALIAS
60
61 Canonicalize a configuration name.
62
63 Operation modes:
64 -h, --help print this help, then exit
65 -t, --time-stamp print date of last modification, then exit
66 -v, --version print version number, then exit
67
68 Report bugs and patches to <config-patches@gnu.org>."
69
70 version="\
71 GNU config.sub ($timestamp)
72
73 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
74 Free Software Foundation, Inc.
75
76 This is free software; see the source for copying conditions. There is NO
77 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
78
79 help="
80 Try \`$me --help' for more information."
81
82 # Parse command line
83 while test $# -gt 0 ; do
84 case $1 in
85 --time-stamp | --time* | -t )
86 echo "$timestamp" ; exit ;;
87 --version | -v )
88 echo "$version" ; exit ;;
89 --help | --h* | -h )
90 echo "$usage"; exit ;;
91 -- ) # Stop option processing
92 shift; break ;;
93 - ) # Use stdin as input.
94 break ;;
95 -* )
96 echo "$me: invalid option $1$help"
97 exit 1 ;;
98
99 *local*)
100 # First pass through any local machine types.
101 echo $1
102 exit ;;
103
104 * )
105 break ;;
106 esac
107 done
108
109 case $# in
110 0) echo "$me: missing argument$help" >&2
111 exit 1;;
112 1) ;;
113 *) echo "$me: too many arguments$help" >&2
114 exit 1;;
115 esac
116
117 # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
118 # Here we must recognize all the valid KERNEL-OS combinations.
119 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
120 case $maybe_os in
121 nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
122 kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
123 os=-$maybe_os
124 basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
125 ;;
126 *)
127 basic_machine=`echo $1 | sed 's/-[^-]*$//'`
128 if [ $basic_machine != $1 ]
129 then os=`echo $1 | sed 's/.*-/-/'`
130 else os=; fi
131 ;;
132 esac
133
134 ### Let's recognize common machines as not being operating systems so
135 ### that things like config.sub decstation-3100 work. We also
136 ### recognize some manufacturers as not being operating systems, so we
137 ### can provide default operating systems below.
138 case $os in
139 -sun*os*)
140 # Prevent following clause from handling this invalid input.
141 ;;
142 -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
143 -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
144 -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
145 -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
146 -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
147 -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
148 -apple | -axis | -knuth | -cray)
149 os=
150 basic_machine=$1
151 ;;
152 -sim | -cisco | -oki | -wec | -winbond)
153 os=
154 basic_machine=$1
155 ;;
156 -scout)
157 ;;
158 -wrs)
159 os=-vxworks
160 basic_machine=$1
161 ;;
162 -chorusos*)
163 os=-chorusos
164 basic_machine=$1
165 ;;
166 -chorusrdb)
167 os=-chorusrdb
168 basic_machine=$1
169 ;;
170 -hiux*)
171 os=-hiuxwe2
172 ;;
173 -sco6)
174 os=-sco5v6
175 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
176 ;;
177 -sco5)
178 os=-sco3.2v5
179 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
180 ;;
181 -sco4)
182 os=-sco3.2v4
183 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
184 ;;
185 -sco3.2.[4-9]*)
186 os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
187 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
188 ;;
189 -sco3.2v[4-9]*)
190 # Don't forget version if it is 3.2v4 or newer.
191 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
192 ;;
193 -sco5v6*)
194 # Don't forget version if it is 3.2v4 or newer.
195 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
196 ;;
197 -sco*)
198 os=-sco3.2v2
199 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
200 ;;
201 -udk*)
202 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
203 ;;
204 -isc)
205 os=-isc2.2
206 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
207 ;;
208 -clix*)
209 basic_machine=clipper-intergraph
210 ;;
211 -isc*)
212 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
213 ;;
214 -lynx*)
215 os=-lynxos
216 ;;
217 -ptx*)
218 basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
219 ;;
220 -windowsnt*)
221 os=`echo $os | sed -e 's/windowsnt/winnt/'`
222 ;;
223 -psos*)
224 os=-psos
225 ;;
226 -mint | -mint[0-9]*)
227 basic_machine=m68k-atari
228 os=-mint
229 ;;
230 esac
231
232 # Decode aliases for certain CPU-COMPANY combinations.
233 case $basic_machine in
234 # Recognize the basic CPU types without company name.
235 # Some are omitted here because they have special meanings below.
236 1750a | 580 \
237 | a29k \
238 | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
239 | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
240 | am33_2.0 \
241 | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
242 | bfin \
243 | c4x | clipper \
244 | d10v | d30v | dlx | dsp16xx \
245 | fr30 | frv \
246 | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
247 | i370 | i860 | i960 | ia64 \
248 | ip2k | iq2000 \
249 | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
250 | mips | mipsbe | mipseb | mipsel | mipsle \
251 | mips16 \
252 | mips64 | mips64el \
253 | mips64vr | mips64vrel \
254 | mips64orion | mips64orionel \
255 | mips64vr4100 | mips64vr4100el \
256 | mips64vr4300 | mips64vr4300el \
257 | mips64vr5000 | mips64vr5000el \
258 | mips64vr5900 | mips64vr5900el \
259 | mipsisa32 | mipsisa32el \
260 | mipsisa32r2 | mipsisa32r2el \
261 | mipsisa64 | mipsisa64el \
262 | mipsisa64r2 | mipsisa64r2el \
263 | mipsisa64sb1 | mipsisa64sb1el \
264 | mipsisa64sr71k | mipsisa64sr71kel \
265 | mipstx39 | mipstx39el \
266 | mn10200 | mn10300 \
267 | ms1 \
268 | msp430 \
269 | ns16k | ns32k \
270 | or32 \
271 | pdp10 | pdp11 | pj | pjl \
272 | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
273 | pyramid \
274 | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
275 | sh64 | sh64le \
276 | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
277 | sparcv8 | sparcv9 | sparcv9b \
278 | strongarm \
279 | tahoe | thumb | tic4x | tic80 | tron \
280 | v850 | v850e \
281 | we32k \
282 | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
283 | z8k)
284 basic_machine=$basic_machine-unknown
285 ;;
286 m32c)
287 basic_machine=$basic_machine-unknown
288 ;;
289 m6811 | m68hc11 | m6812 | m68hc12)
290 # Motorola 68HC11/12.
291 basic_machine=$basic_machine-unknown
292 os=-none
293 ;;
294 m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
295 ;;
296
297 # We use `pc' rather than `unknown'
298 # because (1) that's what they normally are, and
299 # (2) the word "unknown" tends to confuse beginning users.
300 i*86 | x86_64)
301 basic_machine=$basic_machine-pc
302 ;;
303 # Object if more than one company name word.
304 *-*-*)
305 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
306 exit 1
307 ;;
308 # Recognize the basic CPU types with company name.
309 580-* \
310 | a29k-* \
311 | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
312 | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
313 | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
314 | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
315 | avr-* \
316 | bfin-* | bs2000-* \
317 | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
318 | clipper-* | craynv-* | cydra-* \
319 | d10v-* | d30v-* | dlx-* \
320 | elxsi-* \
321 | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
322 | h8300-* | h8500-* \
323 | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
324 | i*86-* | i860-* | i960-* | ia64-* \
325 | ip2k-* | iq2000-* \
326 | m32r-* | m32rle-* \
327 | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
328 | m88110-* | m88k-* | maxq-* | mcore-* \
329 | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
330 | mips16-* \
331 | mips64-* | mips64el-* \
332 | mips64vr-* | mips64vrel-* \
333 | mips64orion-* | mips64orionel-* \
334 | mips64vr4100-* | mips64vr4100el-* \
335 | mips64vr4300-* | mips64vr4300el-* \
336 | mips64vr5000-* | mips64vr5000el-* \
337 | mips64vr5900-* | mips64vr5900el-* \
338 | mipsisa32-* | mipsisa32el-* \
339 | mipsisa32r2-* | mipsisa32r2el-* \
340 | mipsisa64-* | mipsisa64el-* \
341 | mipsisa64r2-* | mipsisa64r2el-* \
342 | mipsisa64sb1-* | mipsisa64sb1el-* \
343 | mipsisa64sr71k-* | mipsisa64sr71kel-* \
344 | mipstx39-* | mipstx39el-* \
345 | mmix-* \
346 | ms1-* \
347 | msp430-* \
348 | none-* | np1-* | ns16k-* | ns32k-* \
349 | orion-* \
350 | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
351 | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
352 | pyramid-* \
353 | romp-* | rs6000-* \
354 | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
355 | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
356 | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
357 | sparclite-* \
358 | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
359 | tahoe-* | thumb-* \
360 | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
361 | tron-* \
362 | v850-* | v850e-* | vax-* \
363 | we32k-* \
364 | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
365 | xstormy16-* | xtensa-* \
366 | ymp-* \
367 | z8k-*)
368 ;;
369 m32c-*)
370 ;;
371 # Recognize the various machine names and aliases which stand
372 # for a CPU type and a company and sometimes even an OS.
373 386bsd)
374 basic_machine=i386-unknown
375 os=-bsd
376 ;;
377 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
378 basic_machine=m68000-att
379 ;;
380 3b*)
381 basic_machine=we32k-att
382 ;;
383 a29khif)
384 basic_machine=a29k-amd
385 os=-udi
386 ;;
387 abacus)
388 basic_machine=abacus-unknown
389 ;;
390 adobe68k)
391 basic_machine=m68010-adobe
392 os=-scout
393 ;;
394 alliant | fx80)
395 basic_machine=fx80-alliant
396 ;;
397 altos | altos3068)
398 basic_machine=m68k-altos
399 ;;
400 am29k)
401 basic_machine=a29k-none
402 os=-bsd
403 ;;
404 amd64)
405 basic_machine=x86_64-pc
406 ;;
407 amd64-*)
408 basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
409 ;;
410 amdahl)
411 basic_machine=580-amdahl
412 os=-sysv
413 ;;
414 amiga | amiga-*)
415 basic_machine=m68k-unknown
416 ;;
417 amigaos | amigados)
418 basic_machine=m68k-unknown
419 os=-amigaos
420 ;;
421 amigaunix | amix)
422 basic_machine=m68k-unknown
423 os=-sysv4
424 ;;
425 apollo68)
426 basic_machine=m68k-apollo
427 os=-sysv
428 ;;
429 apollo68bsd)
430 basic_machine=m68k-apollo
431 os=-bsd
432 ;;
433 aux)
434 basic_machine=m68k-apple
435 os=-aux
436 ;;
437 balance)
438 basic_machine=ns32k-sequent
439 os=-dynix
440 ;;
441 c90)
442 basic_machine=c90-cray
443 os=-unicos
444 ;;
445 convex-c1)
446 basic_machine=c1-convex
447 os=-bsd
448 ;;
449 convex-c2)
450 basic_machine=c2-convex
451 os=-bsd
452 ;;
453 convex-c32)
454 basic_machine=c32-convex
455 os=-bsd
456 ;;
457 convex-c34)
458 basic_machine=c34-convex
459 os=-bsd
460 ;;
461 convex-c38)
462 basic_machine=c38-convex
463 os=-bsd
464 ;;
465 cray | j90)
466 basic_machine=j90-cray
467 os=-unicos
468 ;;
469 craynv)
470 basic_machine=craynv-cray
471 os=-unicosmp
472 ;;
473 cr16c)
474 basic_machine=cr16c-unknown
475 os=-elf
476 ;;
477 crds | unos)
478 basic_machine=m68k-crds
479 ;;
480 crisv32 | crisv32-* | etraxfs*)
481 basic_machine=crisv32-axis
482 ;;
483 cris | cris-* | etrax*)
484 basic_machine=cris-axis
485 ;;
486 crx)
487 basic_machine=crx-unknown
488 os=-elf
489 ;;
490 da30 | da30-*)
491 basic_machine=m68k-da30
492 ;;
493 decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
494 basic_machine=mips-dec
495 ;;
496 decsystem10* | dec10*)
497 basic_machine=pdp10-dec
498 os=-tops10
499 ;;
500 decsystem20* | dec20*)
501 basic_machine=pdp10-dec
502 os=-tops20
503 ;;
504 delta | 3300 | motorola-3300 | motorola-delta \
505 | 3300-motorola | delta-motorola)
506 basic_machine=m68k-motorola
507 ;;
508 delta88)
509 basic_machine=m88k-motorola
510 os=-sysv3
511 ;;
512 djgpp)
513 basic_machine=i586-pc
514 os=-msdosdjgpp
515 ;;
516 dpx20 | dpx20-*)
517 basic_machine=rs6000-bull
518 os=-bosx
519 ;;
520 dpx2* | dpx2*-bull)
521 basic_machine=m68k-bull
522 os=-sysv3
523 ;;
524 ebmon29k)
525 basic_machine=a29k-amd
526 os=-ebmon
527 ;;
528 elxsi)
529 basic_machine=elxsi-elxsi
530 os=-bsd
531 ;;
532 encore | umax | mmax)
533 basic_machine=ns32k-encore
534 ;;
535 es1800 | OSE68k | ose68k | ose | OSE)
536 basic_machine=m68k-ericsson
537 os=-ose
538 ;;
539 fx2800)
540 basic_machine=i860-alliant
541 ;;
542 genix)
543 basic_machine=ns32k-ns
544 ;;
545 gmicro)
546 basic_machine=tron-gmicro
547 os=-sysv
548 ;;
549 go32)
550 basic_machine=i386-pc
551 os=-go32
552 ;;
553 h3050r* | hiux*)
554 basic_machine=hppa1.1-hitachi
555 os=-hiuxwe2
556 ;;
557 h8300hms)
558 basic_machine=h8300-hitachi
559 os=-hms
560 ;;
561 h8300xray)
562 basic_machine=h8300-hitachi
563 os=-xray
564 ;;
565 h8500hms)
566 basic_machine=h8500-hitachi
567 os=-hms
568 ;;
569 harris)
570 basic_machine=m88k-harris
571 os=-sysv3
572 ;;
573 hp300-*)
574 basic_machine=m68k-hp
575 ;;
576 hp300bsd)
577 basic_machine=m68k-hp
578 os=-bsd
579 ;;
580 hp300hpux)
581 basic_machine=m68k-hp
582 os=-hpux
583 ;;
584 hp3k9[0-9][0-9] | hp9[0-9][0-9])
585 basic_machine=hppa1.0-hp
586 ;;
587 hp9k2[0-9][0-9] | hp9k31[0-9])
588 basic_machine=m68000-hp
589 ;;
590 hp9k3[2-9][0-9])
591 basic_machine=m68k-hp
592 ;;
593 hp9k6[0-9][0-9] | hp6[0-9][0-9])
594 basic_machine=hppa1.0-hp
595 ;;
596 hp9k7[0-79][0-9] | hp7[0-79][0-9])
597 basic_machine=hppa1.1-hp
598 ;;
599 hp9k78[0-9] | hp78[0-9])
600 # FIXME: really hppa2.0-hp
601 basic_machine=hppa1.1-hp
602 ;;
603 hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
604 # FIXME: really hppa2.0-hp
605 basic_machine=hppa1.1-hp
606 ;;
607 hp9k8[0-9][13679] | hp8[0-9][13679])
608 basic_machine=hppa1.1-hp
609 ;;
610 hp9k8[0-9][0-9] | hp8[0-9][0-9])
611 basic_machine=hppa1.0-hp
612 ;;
613 hppa-next)
614 os=-nextstep3
615 ;;
616 hppaosf)
617 basic_machine=hppa1.1-hp
618 os=-osf
619 ;;
620 hppro)
621 basic_machine=hppa1.1-hp
622 os=-proelf
623 ;;
624 i370-ibm* | ibm*)
625 basic_machine=i370-ibm
626 ;;
627 # I'm not sure what "Sysv32" means. Should this be sysv3.2?
628 i*86v32)
629 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
630 os=-sysv32
631 ;;
632 i*86v4*)
633 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
634 os=-sysv4
635 ;;
636 i*86v)
637 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
638 os=-sysv
639 ;;
640 i*86sol2)
641 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
642 os=-solaris2
643 ;;
644 i386mach)
645 basic_machine=i386-mach
646 os=-mach
647 ;;
648 i386-vsta | vsta)
649 basic_machine=i386-unknown
650 os=-vsta
651 ;;
652 iris | iris4d)
653 basic_machine=mips-sgi
654 case $os in
655 -irix*)
656 ;;
657 *)
658 os=-irix4
659 ;;
660 esac
661 ;;
662 isi68 | isi)
663 basic_machine=m68k-isi
664 os=-sysv
665 ;;
666 m88k-omron*)
667 basic_machine=m88k-omron
668 ;;
669 magnum | m3230)
670 basic_machine=mips-mips
671 os=-sysv
672 ;;
673 merlin)
674 basic_machine=ns32k-utek
675 os=-sysv
676 ;;
677 mingw32)
678 basic_machine=i386-pc
679 os=-mingw32
680 ;;
681 miniframe)
682 basic_machine=m68000-convergent
683 ;;
684 *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
685 basic_machine=m68k-atari
686 os=-mint
687 ;;
688 mips3*-*)
689 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
690 ;;
691 mips3*)
692 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
693 ;;
694 monitor)
695 basic_machine=m68k-rom68k
696 os=-coff
697 ;;
698 morphos)
699 basic_machine=powerpc-unknown
700 os=-morphos
701 ;;
702 msdos)
703 basic_machine=i386-pc
704 os=-msdos
705 ;;
706 mvs)
707 basic_machine=i370-ibm
708 os=-mvs
709 ;;
710 ncr3000)
711 basic_machine=i486-ncr
712 os=-sysv4
713 ;;
714 netbsd386)
715 basic_machine=i386-unknown
716 os=-netbsd
717 ;;
718 netwinder)
719 basic_machine=armv4l-rebel
720 os=-linux
721 ;;
722 news | news700 | news800 | news900)
723 basic_machine=m68k-sony
724 os=-newsos
725 ;;
726 news1000)
727 basic_machine=m68030-sony
728 os=-newsos
729 ;;
730 news-3600 | risc-news)
731 basic_machine=mips-sony
732 os=-newsos
733 ;;
734 necv70)
735 basic_machine=v70-nec
736 os=-sysv
737 ;;
738 next | m*-next )
739 basic_machine=m68k-next
740 case $os in
741 -nextstep* )
742 ;;
743 -ns2*)
744 os=-nextstep2
745 ;;
746 *)
747 os=-nextstep3
748 ;;
749 esac
750 ;;
751 nh3000)
752 basic_machine=m68k-harris
753 os=-cxux
754 ;;
755 nh[45]000)
756 basic_machine=m88k-harris
757 os=-cxux
758 ;;
759 nindy960)
760 basic_machine=i960-intel
761 os=-nindy
762 ;;
763 mon960)
764 basic_machine=i960-intel
765 os=-mon960
766 ;;
767 nonstopux)
768 basic_machine=mips-compaq
769 os=-nonstopux
770 ;;
771 np1)
772 basic_machine=np1-gould
773 ;;
774 nsr-tandem)
775 basic_machine=nsr-tandem
776 ;;
777 op50n-* | op60c-*)
778 basic_machine=hppa1.1-oki
779 os=-proelf
780 ;;
781 openrisc | openrisc-*)
782 basic_machine=or32-unknown
783 ;;
784 os400)
785 basic_machine=powerpc-ibm
786 os=-os400
787 ;;
788 OSE68000 | ose68000)
789 basic_machine=m68000-ericsson
790 os=-ose
791 ;;
792 os68k)
793 basic_machine=m68k-none
794 os=-os68k
795 ;;
796 pa-hitachi)
797 basic_machine=hppa1.1-hitachi
798 os=-hiuxwe2
799 ;;
800 paragon)
801 basic_machine=i860-intel
802 os=-osf
803 ;;
804 pbd)
805 basic_machine=sparc-tti
806 ;;
807 pbb)
808 basic_machine=m68k-tti
809 ;;
810 pc532 | pc532-*)
811 basic_machine=ns32k-pc532
812 ;;
813 pentium | p5 | k5 | k6 | nexgen | viac3)
814 basic_machine=i586-pc
815 ;;
816 pentiumpro | p6 | 6x86 | athlon | athlon_*)
817 basic_machine=i686-pc
818 ;;
819 pentiumii | pentium2 | pentiumiii | pentium3)
820 basic_machine=i686-pc
821 ;;
822 pentium4)
823 basic_machine=i786-pc
824 ;;
825 pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
826 basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
827 ;;
828 pentiumpro-* | p6-* | 6x86-* | athlon-*)
829 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
830 ;;
831 pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
832 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
833 ;;
834 pentium4-*)
835 basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
836 ;;
837 pn)
838 basic_machine=pn-gould
839 ;;
840 power) basic_machine=power-ibm
841 ;;
842 ppc) basic_machine=powerpc-unknown
843 ;;
844 ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
845 ;;
846 ppcle | powerpclittle | ppc-le | powerpc-little)
847 basic_machine=powerpcle-unknown
848 ;;
849 ppcle-* | powerpclittle-*)
850 basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
851 ;;
852 ppc64) basic_machine=powerpc64-unknown
853 ;;
854 ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
855 ;;
856 ppc64le | powerpc64little | ppc64-le | powerpc64-little)
857 basic_machine=powerpc64le-unknown
858 ;;
859 ppc64le-* | powerpc64little-*)
860 basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
861 ;;
862 ps2)
863 basic_machine=i386-ibm
864 ;;
865 pw32)
866 basic_machine=i586-unknown
867 os=-pw32
868 ;;
869 rom68k)
870 basic_machine=m68k-rom68k
871 os=-coff
872 ;;
873 rm[46]00)
874 basic_machine=mips-siemens
875 ;;
876 rtpc | rtpc-*)
877 basic_machine=romp-ibm
878 ;;
879 s390 | s390-*)
880 basic_machine=s390-ibm
881 ;;
882 s390x | s390x-*)
883 basic_machine=s390x-ibm
884 ;;
885 sa29200)
886 basic_machine=a29k-amd
887 os=-udi
888 ;;
889 sb1)
890 basic_machine=mipsisa64sb1-unknown
891 ;;
892 sb1el)
893 basic_machine=mipsisa64sb1el-unknown
894 ;;
895 sei)
896 basic_machine=mips-sei
897 os=-seiux
898 ;;
899 sequent)
900 basic_machine=i386-sequent
901 ;;
902 sh)
903 basic_machine=sh-hitachi
904 os=-hms
905 ;;
906 sh64)
907 basic_machine=sh64-unknown
908 ;;
909 sparclite-wrs | simso-wrs)
910 basic_machine=sparclite-wrs
911 os=-vxworks
912 ;;
913 sps7)
914 basic_machine=m68k-bull
915 os=-sysv2
916 ;;
917 spur)
918 basic_machine=spur-unknown
919 ;;
920 st2000)
921 basic_machine=m68k-tandem
922 ;;
923 stratus)
924 basic_machine=i860-stratus
925 os=-sysv4
926 ;;
927 sun2)
928 basic_machine=m68000-sun
929 ;;
930 sun2os3)
931 basic_machine=m68000-sun
932 os=-sunos3
933 ;;
934 sun2os4)
935 basic_machine=m68000-sun
936 os=-sunos4
937 ;;
938 sun3os3)
939 basic_machine=m68k-sun
940 os=-sunos3
941 ;;
942 sun3os4)
943 basic_machine=m68k-sun
944 os=-sunos4
945 ;;
946 sun4os3)
947 basic_machine=sparc-sun
948 os=-sunos3
949 ;;
950 sun4os4)
951 basic_machine=sparc-sun
952 os=-sunos4
953 ;;
954 sun4sol2)
955 basic_machine=sparc-sun
956 os=-solaris2
957 ;;
958 sun3 | sun3-*)
959 basic_machine=m68k-sun
960 ;;
961 sun4)
962 basic_machine=sparc-sun
963 ;;
964 sun386 | sun386i | roadrunner)
965 basic_machine=i386-sun
966 ;;
967 sv1)
968 basic_machine=sv1-cray
969 os=-unicos
970 ;;
971 symmetry)
972 basic_machine=i386-sequent
973 os=-dynix
974 ;;
975 t3e)
976 basic_machine=alphaev5-cray
977 os=-unicos
978 ;;
979 t90)
980 basic_machine=t90-cray
981 os=-unicos
982 ;;
983 tic54x | c54x*)
984 basic_machine=tic54x-unknown
985 os=-coff
986 ;;
987 tic55x | c55x*)
988 basic_machine=tic55x-unknown
989 os=-coff
990 ;;
991 tic6x | c6x*)
992 basic_machine=tic6x-unknown
993 os=-coff
994 ;;
995 tx39)
996 basic_machine=mipstx39-unknown
997 ;;
998 tx39el)
999 basic_machine=mipstx39el-unknown
1000 ;;
1001 toad1)
1002 basic_machine=pdp10-xkl
1003 os=-tops20
1004 ;;
1005 tower | tower-32)
1006 basic_machine=m68k-ncr
1007 ;;
1008 tpf)
1009 basic_machine=s390x-ibm
1010 os=-tpf
1011 ;;
1012 udi29k)
1013 basic_machine=a29k-amd
1014 os=-udi
1015 ;;
1016 ultra3)
1017 basic_machine=a29k-nyu
1018 os=-sym1
1019 ;;
1020 v810 | necv810)
1021 basic_machine=v810-nec
1022 os=-none
1023 ;;
1024 vaxv)
1025 basic_machine=vax-dec
1026 os=-sysv
1027 ;;
1028 vms)
1029 basic_machine=vax-dec
1030 os=-vms
1031 ;;
1032 vpp*|vx|vx-*)
1033 basic_machine=f301-fujitsu
1034 ;;
1035 vxworks960)
1036 basic_machine=i960-wrs
1037 os=-vxworks
1038 ;;
1039 vxworks68)
1040 basic_machine=m68k-wrs
1041 os=-vxworks
1042 ;;
1043 vxworks29k)
1044 basic_machine=a29k-wrs
1045 os=-vxworks
1046 ;;
1047 w65*)
1048 basic_machine=w65-wdc
1049 os=-none
1050 ;;
1051 w89k-*)
1052 basic_machine=hppa1.1-winbond
1053 os=-proelf
1054 ;;
1055 xbox)
1056 basic_machine=i686-pc
1057 os=-mingw32
1058 ;;
1059 xps | xps100)
1060 basic_machine=xps100-honeywell
1061 ;;
1062 ymp)
1063 basic_machine=ymp-cray
1064 os=-unicos
1065 ;;
1066 z8k-*-coff)
1067 basic_machine=z8k-unknown
1068 os=-sim
1069 ;;
1070 none)
1071 basic_machine=none-none
1072 os=-none
1073 ;;
1074
1075 # Here we handle the default manufacturer of certain CPU types. It is in
1076 # some cases the only manufacturer, in others, it is the most popular.
1077 w89k)
1078 basic_machine=hppa1.1-winbond
1079 ;;
1080 op50n)
1081 basic_machine=hppa1.1-oki
1082 ;;
1083 op60c)
1084 basic_machine=hppa1.1-oki
1085 ;;
1086 romp)
1087 basic_machine=romp-ibm
1088 ;;
1089 mmix)
1090 basic_machine=mmix-knuth
1091 ;;
1092 rs6000)
1093 basic_machine=rs6000-ibm
1094 ;;
1095 vax)
1096 basic_machine=vax-dec
1097 ;;
1098 pdp10)
1099 # there are many clones, so DEC is not a safe bet
1100 basic_machine=pdp10-unknown
1101 ;;
1102 pdp11)
1103 basic_machine=pdp11-dec
1104 ;;
1105 we32k)
1106 basic_machine=we32k-att
1107 ;;
1108 sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
1109 basic_machine=sh-unknown
1110 ;;
1111 sparc | sparcv8 | sparcv9 | sparcv9b)
1112 basic_machine=sparc-sun
1113 ;;
1114 cydra)
1115 basic_machine=cydra-cydrome
1116 ;;
1117 orion)
1118 basic_machine=orion-highlevel
1119 ;;
1120 orion105)
1121 basic_machine=clipper-highlevel
1122 ;;
1123 mac | mpw | mac-mpw)
1124 basic_machine=m68k-apple
1125 ;;
1126 pmac | pmac-mpw)
1127 basic_machine=powerpc-apple
1128 ;;
1129 *-unknown)
1130 # Make sure to match an already-canonicalized machine name.
1131 ;;
1132 *)
1133 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
1134 exit 1
1135 ;;
1136 esac
1137
1138 # Here we canonicalize certain aliases for manufacturers.
1139 case $basic_machine in
1140 *-digital*)
1141 basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
1142 ;;
1143 *-commodore*)
1144 basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
1145 ;;
1146 *)
1147 ;;
1148 esac
1149
1150 # Decode manufacturer-specific aliases for certain operating systems.
1151
1152 if [ x"$os" != x"" ]
1153 then
1154 case $os in
1155 # First match some system type aliases
1156 # that might get confused with valid system types.
1157 # -solaris* is a basic system type, with this one exception.
1158 -solaris1 | -solaris1.*)
1159 os=`echo $os | sed -e 's|solaris1|sunos4|'`
1160 ;;
1161 -solaris)
1162 os=-solaris2
1163 ;;
1164 -svr4*)
1165 os=-sysv4
1166 ;;
1167 -unixware*)
1168 os=-sysv4.2uw
1169 ;;
1170 -gnu/linux*)
1171 os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
1172 ;;
1173 # First accept the basic system types.
1174 # The portable systems comes first.
1175 # Each alternative MUST END IN A *, to match a version number.
1176 # -sysv* is not here because it comes later, after sysvr4.
1177 -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
1178 | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
1179 | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
1180 | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
1181 | -aos* \
1182 | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
1183 | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
1184 | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
1185 | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
1186 | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
1187 | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
1188 | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
1189 | -chorusos* | -chorusrdb* \
1190 | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
1191 | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
1192 | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
1193 | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
1194 | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
1195 | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
1196 | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
1197 | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
1198 | -skyos* | haiku*)
1199 # Remember, each alternative MUST END IN *, to match a version number.
1200 ;;
1201 -qnx*)
1202 case $basic_machine in
1203 x86-* | i*86-*)
1204 ;;
1205 *)
1206 os=-nto$os
1207 ;;
1208 esac
1209 ;;
1210 -nto-qnx*)
1211 ;;
1212 -nto*)
1213 os=`echo $os | sed -e 's|nto|nto-qnx|'`
1214 ;;
1215 -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
1216 | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
1217 | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
1218 ;;
1219 -mac*)
1220 os=`echo $os | sed -e 's|mac|macos|'`
1221 ;;
1222 -linux-dietlibc)
1223 os=-linux-dietlibc
1224 ;;
1225 -linux*)
1226 os=`echo $os | sed -e 's|linux|linux-gnu|'`
1227 ;;
1228 -sunos5*)
1229 os=`echo $os | sed -e 's|sunos5|solaris2|'`
1230 ;;
1231 -sunos6*)
1232 os=`echo $os | sed -e 's|sunos6|solaris3|'`
1233 ;;
1234 -opened*)
1235 os=-openedition
1236 ;;
1237 -os400*)
1238 os=-os400
1239 ;;
1240 -wince*)
1241 os=-wince
1242 ;;
1243 -osfrose*)
1244 os=-osfrose
1245 ;;
1246 -osf*)
1247 os=-osf
1248 ;;
1249 -utek*)
1250 os=-bsd
1251 ;;
1252 -dynix*)
1253 os=-bsd
1254 ;;
1255 -acis*)
1256 os=-aos
1257 ;;
1258 -atheos*)
1259 os=-atheos
1260 ;;
1261 -syllable*)
1262 os=-syllable
1263 ;;
1264 -386bsd)
1265 os=-bsd
1266 ;;
1267 -ctix* | -uts*)
1268 os=-sysv
1269 ;;
1270 -nova*)
1271 os=-rtmk-nova
1272 ;;
1273 -ns2 )
1274 os=-nextstep2
1275 ;;
1276 -nsk*)
1277 os=-nsk
1278 ;;
1279 # Preserve the version number of sinix5.
1280 -sinix5.*)
1281 os=`echo $os | sed -e 's|sinix|sysv|'`
1282 ;;
1283 -sinix*)
1284 os=-sysv4
1285 ;;
1286 -tpf*)
1287 os=-tpf
1288 ;;
1289 -triton*)
1290 os=-sysv3
1291 ;;
1292 -oss*)
1293 os=-sysv3
1294 ;;
1295 -svr4)
1296 os=-sysv4
1297 ;;
1298 -svr3)
1299 os=-sysv3
1300 ;;
1301 -sysvr4)
1302 os=-sysv4
1303 ;;
1304 # This must come after -sysvr4.
1305 -sysv*)
1306 ;;
1307 -ose*)
1308 os=-ose
1309 ;;
1310 -es1800*)
1311 os=-ose
1312 ;;
1313 -xenix)
1314 os=-xenix
1315 ;;
1316 -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
1317 os=-mint
1318 ;;
1319 -aros*)
1320 os=-aros
1321 ;;
1322 -kaos*)
1323 os=-kaos
1324 ;;
1325 -zvmoe)
1326 os=-zvmoe
1327 ;;
1328 -none)
1329 ;;
1330 *)
1331 # Get rid of the `-' at the beginning of $os.
1332 os=`echo $os | sed 's/[^-]*-//'`
1333 echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
1334 exit 1
1335 ;;
1336 esac
1337 else
1338
1339 # Here we handle the default operating systems that come with various machines.
1340 # The value should be what the vendor currently ships out the door with their
1341 # machine or put another way, the most popular os provided with the machine.
1342
1343 # Note that if you're going to try to match "-MANUFACTURER" here (say,
1344 # "-sun"), then you have to tell the case statement up towards the top
1345 # that MANUFACTURER isn't an operating system. Otherwise, code above
1346 # will signal an error saying that MANUFACTURER isn't an operating
1347 # system, and we'll never get to this point.
1348
1349 case $basic_machine in
1350 *-acorn)
1351 os=-riscix1.2
1352 ;;
1353 arm*-rebel)
1354 os=-linux
1355 ;;
1356 arm*-semi)
1357 os=-aout
1358 ;;
1359 c4x-* | tic4x-*)
1360 os=-coff
1361 ;;
1362 # This must come before the *-dec entry.
1363 pdp10-*)
1364 os=-tops20
1365 ;;
1366 pdp11-*)
1367 os=-none
1368 ;;
1369 *-dec | vax-*)
1370 os=-ultrix4.2
1371 ;;
1372 m68*-apollo)
1373 os=-domain
1374 ;;
1375 i386-sun)
1376 os=-sunos4.0.2
1377 ;;
1378 m68000-sun)
1379 os=-sunos3
1380 # This also exists in the configure program, but was not the
1381 # default.
1382 # os=-sunos4
1383 ;;
1384 m68*-cisco)
1385 os=-aout
1386 ;;
1387 mips*-cisco)
1388 os=-elf
1389 ;;
1390 mips*-*)
1391 os=-elf
1392 ;;
1393 or32-*)
1394 os=-coff
1395 ;;
1396 *-tti) # must be before sparc entry or we get the wrong os.
1397 os=-sysv3
1398 ;;
1399 sparc-* | *-sun)
1400 os=-sunos4.1.1
1401 ;;
1402 *-be)
1403 os=-beos
1404 ;;
1405 *-haiku)
1406 os=-haiku
1407 ;;
1408 *-ibm)
1409 os=-aix
1410 ;;
1411 *-knuth)
1412 os=-mmixware
1413 ;;
1414 *-wec)
1415 os=-proelf
1416 ;;
1417 *-winbond)
1418 os=-proelf
1419 ;;
1420 *-oki)
1421 os=-proelf
1422 ;;
1423 *-hp)
1424 os=-hpux
1425 ;;
1426 *-hitachi)
1427 os=-hiux
1428 ;;
1429 i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1430 os=-sysv
1431 ;;
1432 *-cbm)
1433 os=-amigaos
1434 ;;
1435 *-dg)
1436 os=-dgux
1437 ;;
1438 *-dolphin)
1439 os=-sysv3
1440 ;;
1441 m68k-ccur)
1442 os=-rtu
1443 ;;
1444 m88k-omron*)
1445 os=-luna
1446 ;;
1447 *-next )
1448 os=-nextstep
1449 ;;
1450 *-sequent)
1451 os=-ptx
1452 ;;
1453 *-crds)
1454 os=-unos
1455 ;;
1456 *-ns)
1457 os=-genix
1458 ;;
1459 i370-*)
1460 os=-mvs
1461 ;;
1462 *-next)
1463 os=-nextstep3
1464 ;;
1465 *-gould)
1466 os=-sysv
1467 ;;
1468 *-highlevel)
1469 os=-bsd
1470 ;;
1471 *-encore)
1472 os=-bsd
1473 ;;
1474 *-sgi)
1475 os=-irix
1476 ;;
1477 *-siemens)
1478 os=-sysv4
1479 ;;
1480 *-masscomp)
1481 os=-rtu
1482 ;;
1483 f30[01]-fujitsu | f700-fujitsu)
1484 os=-uxpv
1485 ;;
1486 *-rom68k)
1487 os=-coff
1488 ;;
1489 *-*bug)
1490 os=-coff
1491 ;;
1492 *-apple)
1493 os=-macos
1494 ;;
1495 *-atari*)
1496 os=-mint
1497 ;;
1498 *)
1499 os=-none
1500 ;;
1501 esac
1502 fi
1503
1504 # Here we handle the case where we know the os, and the CPU type, but not the
1505 # manufacturer. We pick the logical manufacturer.
1506 vendor=unknown
1507 case $basic_machine in
1508 *-unknown)
1509 case $os in
1510 -riscix*)
1511 vendor=acorn
1512 ;;
1513 -sunos*)
1514 vendor=sun
1515 ;;
1516 -aix*)
1517 vendor=ibm
1518 ;;
1519 -beos*)
1520 vendor=be
1521 ;;
1522 -hpux*)
1523 vendor=hp
1524 ;;
1525 -mpeix*)
1526 vendor=hp
1527 ;;
1528 -hiux*)
1529 vendor=hitachi
1530 ;;
1531 -unos*)
1532 vendor=crds
1533 ;;
1534 -dgux*)
1535 vendor=dg
1536 ;;
1537 -luna*)
1538 vendor=omron
1539 ;;
1540 -genix*)
1541 vendor=ns
1542 ;;
1543 -mvs* | -opened*)
1544 vendor=ibm
1545 ;;
1546 -os400*)
1547 vendor=ibm
1548 ;;
1549 -ptx*)
1550 vendor=sequent
1551 ;;
1552 -tpf*)
1553 vendor=ibm
1554 ;;
1555 -vxsim* | -vxworks* | -windiss*)
1556 vendor=wrs
1557 ;;
1558 -aux*)
1559 vendor=apple
1560 ;;
1561 -hms*)
1562 vendor=hitachi
1563 ;;
1564 -mpw* | -macos*)
1565 vendor=apple
1566 ;;
1567 -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
1568 vendor=atari
1569 ;;
1570 -vos*)
1571 vendor=stratus
1572 ;;
1573 esac
1574 basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
1575 ;;
1576 esac
1577
1578 echo $basic_machine$os
1579 exit
1580
1581 # Local variables:
1582 # eval: (add-hook 'write-file-hooks 'time-stamp)
1583 # time-stamp-start: "timestamp='"
1584 # time-stamp-format: "%:y-%02m-%02d"
1585 # time-stamp-end: "'"
1586 # End:
0 #! /bin/sh
1
2 # Guess values for system-dependent variables and create Makefiles.
3 # Generated automatically using autoconf version 2.13.20030927
4 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
5 #
6 # This configure script is free software; the Free Software Foundation
7 # gives unlimited permission to copy, distribute and modify it.
8
9 # Defaults:
10 ac_help=
11 ac_default_prefix=/usr/local
12 # Any additions from configure.in:
13
14 # Initialize some variables set by options.
15 # The variables have the same names as the options, with
16 # dashes changed to underlines.
17 build=NONE
18 cache_file=./config.cache
19 exec_prefix=NONE
20 host=NONE
21 no_create=
22 nonopt=NONE
23 no_recursion=
24 prefix=NONE
25 program_prefix=NONE
26 program_suffix=NONE
27 program_transform_name=s,x,x,
28 silent=
29 site=
30 srcdir=
31 target=NONE
32 verbose=
33 x_includes=NONE
34 x_libraries=NONE
35 bindir='${exec_prefix}/bin'
36 sbindir='${exec_prefix}/sbin'
37 libexecdir='${exec_prefix}/libexec'
38 datadir='${prefix}/share'
39 sysconfdir='${prefix}/etc'
40 sharedstatedir='${prefix}/com'
41 localstatedir='${prefix}/var'
42 libdir='${exec_prefix}/lib'
43 includedir='${prefix}/include'
44 oldincludedir='/usr/include'
45 infodir='${prefix}/info'
46 mandir='${prefix}/man'
47
48 # Initialize some other variables.
49 subdirs=
50 MFLAGS= MAKEFLAGS=
51 SHELL=${CONFIG_SHELL-/bin/sh}
52 # Maximum number of lines to put in a shell here document.
53 ac_max_here_lines=12
54
55 ac_prev=
56 for ac_option
57 do
58
59 # If the previous option needs an argument, assign it.
60 if test -n "$ac_prev"; then
61 eval "$ac_prev=\$ac_option"
62 ac_prev=
63 continue
64 fi
65
66 case "$ac_option" in
67 -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
68 *) ac_optarg= ;;
69 esac
70
71 # Accept the important Cygnus configure options, so we can diagnose typos.
72
73 case "$ac_option" in
74
75 -bindir | --bindir | --bindi | --bind | --bin | --bi)
76 ac_prev=bindir ;;
77 -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
78 bindir="$ac_optarg" ;;
79
80 -build | --build | --buil | --bui | --bu)
81 ac_prev=build ;;
82 -build=* | --build=* | --buil=* | --bui=* | --bu=*)
83 build="$ac_optarg" ;;
84
85 -cache-file | --cache-file | --cache-fil | --cache-fi \
86 | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
87 ac_prev=cache_file ;;
88 -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
89 | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
90 cache_file="$ac_optarg" ;;
91
92 -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
93 ac_prev=datadir ;;
94 -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
95 | --da=*)
96 datadir="$ac_optarg" ;;
97
98 -disable-* | --disable-*)
99 ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
100 # Reject names that are not valid shell variable names.
101 if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
102 { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
103 fi
104 ac_feature=`echo $ac_feature| sed 's/-/_/g'`
105 eval "enable_${ac_feature}=no" ;;
106
107 -enable-* | --enable-*)
108 ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
109 # Reject names that are not valid shell variable names.
110 if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
111 { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
112 fi
113 ac_feature=`echo $ac_feature| sed 's/-/_/g'`
114 case "$ac_option" in
115 *=*) ;;
116 *) ac_optarg=yes ;;
117 esac
118 eval "enable_${ac_feature}='$ac_optarg'" ;;
119
120 -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
121 | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
122 | --exec | --exe | --ex)
123 ac_prev=exec_prefix ;;
124 -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
125 | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
126 | --exec=* | --exe=* | --ex=*)
127 exec_prefix="$ac_optarg" ;;
128
129 -gas | --gas | --ga | --g)
130 # Obsolete; use --with-gas.
131 with_gas=yes ;;
132
133 -help | --help | --hel | --he)
134 # Omit some internal or obsolete options to make the list less imposing.
135 # This message is too long to be a string in the A/UX 3.1 sh.
136 cat << EOF
137 Usage: configure [options] [host]
138 Options: [defaults in brackets after descriptions]
139 Configuration:
140 --cache-file=FILE cache test results in FILE
141 --help print this message
142 --no-create do not create output files
143 --quiet, --silent do not print \`checking...' messages
144 --version print the version of autoconf that created configure
145 Directory and file names:
146 --prefix=PREFIX install architecture-independent files in PREFIX
147 [$ac_default_prefix]
148 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
149 [same as prefix]
150 --bindir=DIR user executables in DIR [EPREFIX/bin]
151 --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
152 --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
153 --datadir=DIR read-only architecture-independent data in DIR
154 [PREFIX/share]
155 --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
156 --sharedstatedir=DIR modifiable architecture-independent data in DIR
157 [PREFIX/com]
158 --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
159 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
160 --includedir=DIR C header files in DIR [PREFIX/include]
161 --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
162 --infodir=DIR info documentation in DIR [PREFIX/info]
163 --mandir=DIR man documentation in DIR [PREFIX/man]
164 --srcdir=DIR find the sources in DIR [configure dir or ..]
165 --program-prefix=PREFIX prepend PREFIX to installed program names
166 --program-suffix=SUFFIX append SUFFIX to installed program names
167 --program-transform-name=PROGRAM
168 run sed PROGRAM on installed program names
169 EOF
170 cat << EOF
171 Host type:
172 --build=BUILD configure for building on BUILD [BUILD=HOST]
173 --host=HOST configure for HOST [guessed]
174 --target=TARGET configure for TARGET [TARGET=HOST]
175 Features and packages:
176 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
177 --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
178 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
179 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
180 --x-includes=DIR X include files are in DIR
181 --x-libraries=DIR X library files are in DIR
182 EOF
183 cat <<\EOF
184 --enable and --with options recognized:
185 --disable-echo display "compiling" commands
186 --with-man-section=XXX change manpage section (default 3)
187 --with-curses-dir=DIR directory in which (n)curses is installed
188 --with-warnings test: turn on gcc warnings
189 --with-libtool generate libraries with libtool
190 --with-dbmalloc use Conor Cahill's dbmalloc library
191 --with-dmalloc use Gray Watson's dmalloc library
192 --with-ncurses compile/link with ncurses library
193 --with-ncursesw compile/line with wide-character ncurses
194 --with-pdcurses compile/link with pdcurses X11 library
195 --with-x use the X Window System
196 --with-Xaw3d link with Xaw 3d library
197 --with-neXtaw link with neXT Athena library
198 EOF
199 cat <<\EOF
200 --with-XawPlus link with Athena-Plus library
201 --disable-leaks test: suppress permanent memory-leaks
202 EOF
203 exit 0 ;;
204
205 -host | --host | --hos | --ho)
206 ac_prev=host ;;
207 -host=* | --host=* | --hos=* | --ho=*)
208 host="$ac_optarg" ;;
209
210 -includedir | --includedir | --includedi | --included | --include \
211 | --includ | --inclu | --incl | --inc)
212 ac_prev=includedir ;;
213 -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
214 | --includ=* | --inclu=* | --incl=* | --inc=*)
215 includedir="$ac_optarg" ;;
216
217 -infodir | --infodir | --infodi | --infod | --info | --inf)
218 ac_prev=infodir ;;
219 -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
220 infodir="$ac_optarg" ;;
221
222 -libdir | --libdir | --libdi | --libd)
223 ac_prev=libdir ;;
224 -libdir=* | --libdir=* | --libdi=* | --libd=*)
225 libdir="$ac_optarg" ;;
226
227 -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
228 | --libexe | --libex | --libe)
229 ac_prev=libexecdir ;;
230 -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
231 | --libexe=* | --libex=* | --libe=*)
232 libexecdir="$ac_optarg" ;;
233
234 -localstatedir | --localstatedir | --localstatedi | --localstated \
235 | --localstate | --localstat | --localsta | --localst \
236 | --locals | --local | --loca | --loc | --lo)
237 ac_prev=localstatedir ;;
238 -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
239 | --localstate=* | --localstat=* | --localsta=* | --localst=* \
240 | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
241 localstatedir="$ac_optarg" ;;
242
243 -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
244 ac_prev=mandir ;;
245 -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
246 mandir="$ac_optarg" ;;
247
248 -nfp | --nfp | --nf)
249 # Obsolete; use --without-fp.
250 with_fp=no ;;
251
252 -no-create | --no-create | --no-creat | --no-crea | --no-cre \
253 | --no-cr | --no-c)
254 no_create=yes ;;
255
256 -no-recursion | --no-recursion | --no-recursio | --no-recursi \
257 | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
258 no_recursion=yes ;;
259
260 -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
261 | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
262 | --oldin | --oldi | --old | --ol | --o)
263 ac_prev=oldincludedir ;;
264 -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
265 | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
266 | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
267 oldincludedir="$ac_optarg" ;;
268
269 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
270 ac_prev=prefix ;;
271 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
272 prefix="$ac_optarg" ;;
273
274 -program-prefix | --program-prefix | --program-prefi | --program-pref \
275 | --program-pre | --program-pr | --program-p)
276 ac_prev=program_prefix ;;
277 -program-prefix=* | --program-prefix=* | --program-prefi=* \
278 | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
279 program_prefix="$ac_optarg" ;;
280
281 -program-suffix | --program-suffix | --program-suffi | --program-suff \
282 | --program-suf | --program-su | --program-s)
283 ac_prev=program_suffix ;;
284 -program-suffix=* | --program-suffix=* | --program-suffi=* \
285 | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
286 program_suffix="$ac_optarg" ;;
287
288 -program-transform-name | --program-transform-name \
289 | --program-transform-nam | --program-transform-na \
290 | --program-transform-n | --program-transform- \
291 | --program-transform | --program-transfor \
292 | --program-transfo | --program-transf \
293 | --program-trans | --program-tran \
294 | --progr-tra | --program-tr | --program-t)
295 ac_prev=program_transform_name ;;
296 -program-transform-name=* | --program-transform-name=* \
297 | --program-transform-nam=* | --program-transform-na=* \
298 | --program-transform-n=* | --program-transform-=* \
299 | --program-transform=* | --program-transfor=* \
300 | --program-transfo=* | --program-transf=* \
301 | --program-trans=* | --program-tran=* \
302 | --progr-tra=* | --program-tr=* | --program-t=*)
303 program_transform_name="$ac_optarg" ;;
304
305 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
306 | -silent | --silent | --silen | --sile | --sil)
307 silent=yes ;;
308
309 -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
310 ac_prev=sbindir ;;
311 -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
312 | --sbi=* | --sb=*)
313 sbindir="$ac_optarg" ;;
314
315 -sharedstatedir | --sharedstatedir | --sharedstatedi \
316 | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
317 | --sharedst | --shareds | --shared | --share | --shar \
318 | --sha | --sh)
319 ac_prev=sharedstatedir ;;
320 -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
321 | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
322 | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
323 | --sha=* | --sh=*)
324 sharedstatedir="$ac_optarg" ;;
325
326 -site | --site | --sit)
327 ac_prev=site ;;
328 -site=* | --site=* | --sit=*)
329 site="$ac_optarg" ;;
330
331 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
332 ac_prev=srcdir ;;
333 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
334 srcdir="$ac_optarg" ;;
335
336 -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
337 | --syscon | --sysco | --sysc | --sys | --sy)
338 ac_prev=sysconfdir ;;
339 -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
340 | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
341 sysconfdir="$ac_optarg" ;;
342
343 -target | --target | --targe | --targ | --tar | --ta | --t)
344 ac_prev=target ;;
345 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
346 target="$ac_optarg" ;;
347
348 -v | -verbose | --verbose | --verbos | --verbo | --verb)
349 verbose=yes ;;
350
351 -version | --version | --versio | --versi | --vers)
352 echo "configure generated by autoconf version 2.13.20030927"
353 exit 0 ;;
354
355 -with-* | --with-*)
356 ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
357 # Reject names that are not valid shell variable names.
358 if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
359 { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
360 fi
361 ac_package=`echo $ac_package| sed 's/-/_/g'`
362 case "$ac_option" in
363 *=*) ;;
364 *) ac_optarg=yes ;;
365 esac
366 eval "with_${ac_package}='$ac_optarg'" ;;
367
368 -without-* | --without-*)
369 ac_package=`echo $ac_option|sed -e 's/-*without-//'`
370 # Reject names that are not valid shell variable names.
371 if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
372 { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
373 fi
374 ac_package=`echo $ac_package| sed 's/-/_/g'`
375 eval "with_${ac_package}=no" ;;
376
377 --x)
378 # Obsolete; use --with-x.
379 with_x=yes ;;
380
381 -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
382 | --x-incl | --x-inc | --x-in | --x-i)
383 ac_prev=x_includes ;;
384 -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
385 | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
386 x_includes="$ac_optarg" ;;
387
388 -x-libraries | --x-libraries | --x-librarie | --x-librari \
389 | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
390 ac_prev=x_libraries ;;
391 -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
392 | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
393 x_libraries="$ac_optarg" ;;
394
395 -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
396 ;;
397
398 *)
399 if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
400 echo "configure: warning: $ac_option: invalid host type" 1>&2
401 fi
402 if test "x$nonopt" != xNONE; then
403 { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
404 fi
405 nonopt="$ac_option"
406 ;;
407
408 esac
409 done
410
411 if test -n "$ac_prev"; then
412 { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
413 fi
414
415 trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
416
417 # File descriptor usage:
418 # 0 standard input
419 # 1 file creation
420 # 2 errors and warnings
421 # 3 some systems may open it to /dev/tty
422 # 4 used on the Kubota Titan
423 # 6 checking for... messages and results
424 # 5 compiler messages saved in config.log
425 if test "$silent" = yes; then
426 exec 6>/dev/null
427 else
428 exec 6>&1
429 fi
430 exec 5>./config.log
431
432 echo "\
433 This file contains any messages produced by compilers while
434 running configure, to aid debugging if configure makes a mistake.
435 " 1>&5
436
437 # Strip out --no-create and --no-recursion so they do not pile up.
438 # Also quote any args containing shell metacharacters.
439 ac_configure_args=
440 for ac_arg
441 do
442 case "$ac_arg" in
443 -no-create | --no-create | --no-creat | --no-crea | --no-cre \
444 | --no-cr | --no-c) ;;
445 -no-recursion | --no-recursion | --no-recursio | --no-recursi \
446 | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
447 *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
448 ac_configure_args="$ac_configure_args '$ac_arg'" ;;
449 *) ac_configure_args="$ac_configure_args $ac_arg" ;;
450 esac
451 done
452
453 # NLS nuisances.
454 # Only set these to C if already set. These must not be set unconditionally
455 # because not all systems understand e.g. LANG=C (notably SCO).
456 # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
457 # Non-C LC_CTYPE values break the ctype check.
458 if test "${LANG+set}" = set; then LANG=C; export LANG; fi
459 if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
460 if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
461 if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
462
463 # confdefs.h avoids OS command line length limits that DEFS can exceed.
464 rm -rf conftest* confdefs.h
465 # AIX cpp loses on an empty file, so make sure it contains at least a newline.
466 echo > confdefs.h
467
468 # A filename unique to this package, relative to the directory that
469 # configure is in, which we can look for to find out if srcdir is correct.
470 ac_unique_file=include/cdk.h
471
472 # Find the source files, if location was not specified.
473 if test -z "$srcdir"; then
474 ac_srcdir_defaulted=yes
475 # Try the directory containing this script, then its parent.
476 ac_prog=$0
477 ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
478 test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
479 srcdir=$ac_confdir
480 if test ! -r $srcdir/$ac_unique_file; then
481 srcdir=..
482 fi
483 else
484 ac_srcdir_defaulted=no
485 fi
486 if test ! -r $srcdir/$ac_unique_file; then
487 if test "$ac_srcdir_defaulted" = yes; then
488 { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
489 else
490 { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
491 fi
492 fi
493 srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
494
495 # Prefer explicitly selected file to automatically selected ones.
496 if test -z "$CONFIG_SITE"; then
497 if test "x$prefix" != xNONE; then
498 CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
499 else
500 CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
501 fi
502 fi
503 for ac_site_file in $CONFIG_SITE; do
504 if test -r "$ac_site_file"; then
505 echo "loading site script $ac_site_file"
506 . "$ac_site_file"
507 fi
508 done
509
510 if test -r "$cache_file"; then
511 echo "loading cache $cache_file"
512 . $cache_file
513 else
514 echo "creating cache $cache_file"
515 > $cache_file
516 fi
517
518 ac_ext=c
519 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
520 ac_cpp='$CPP $CPPFLAGS'
521 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
522 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
523 cross_compiling=$ac_cv_prog_cc_cross
524
525 ac_exeext=
526 ac_objext=o
527 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
528 # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
529 if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
530 ac_n= ac_c='
531 ' ac_t=' '
532 else
533 ac_n=-n ac_c= ac_t=
534 fi
535 else
536 ac_n= ac_c='\c' ac_t=
537 fi
538
539 # If we find X, set shell vars x_includes and x_libraries to the
540 # paths, otherwise set no_x=yes.
541 # Uses ac_ vars as temps to allow command line to override cache and checks.
542 # --without-x overrides everything else, but does not touch the cache.
543 echo $ac_n "checking for X""... $ac_c" 1>&6
544 echo "configure:546: checking for X" >&5
545
546
547 # Check whether --with-x or --without-x was given.
548 if test "${with_x+set}" = set; then
549 withval="$with_x"
550 :
551 fi
552
553 # $have_x is `yes', `no', `disabled', or empty when we do not yet know.
554 if test "x$with_x" = xno; then
555 # The user explicitly disabled X.
556 have_x=disabled
557 else
558 if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
559 # Both variables are already set.
560 have_x=yes
561 else
562 if eval "test \"`echo '$''{'ac_cv_have_x'+set}'`\" = set"; then
563 echo $ac_n "(cached) $ac_c" 1>&6
564 else
565 # One or both of the vars are not set, and there is no cached value.
566 ac_x_includes=NO ac_x_libraries=NO
567 rm -fr conftestdir
568 if mkdir conftestdir; then
569 cd conftestdir
570 # Make sure to not put "make" in the Imakefile rules, since we grep it out.
571 cat > Imakefile <<'EOF'
572 acfindx:
573 @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
574 EOF
575 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
576 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
577 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
578 # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
579 for ac_extension in a so sl; do
580 if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
581 test -f $ac_im_libdir/libX11.$ac_extension; then
582 ac_im_usrlibdir=$ac_im_libdir; break
583 fi
584 done
585 # Screen out bogus values from the imake configuration. They are
586 # bogus both because they are the default anyway, and because
587 # using them would break gcc on systems where it needs fixed includes.
588 case "$ac_im_incroot" in
589 /usr/include) ;;
590 *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;;
591 esac
592 case "$ac_im_usrlibdir" in
593 /usr/lib | /lib) ;;
594 *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;;
595 esac
596 fi
597 cd ..
598 rm -fr conftestdir
599 fi
600
601 if test "$ac_x_includes" = NO; then
602 # Guess where to find include files, by looking for this one X11 .h file.
603 test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
604
605 # First, try using that file with no special directory specified.
606 cat > conftest.$ac_ext <<EOF
607 #line 609 "configure"
608 #include "confdefs.h"
609 #include <$x_direct_test_include>
610 EOF
611 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
612 { (eval echo configure:614: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
613 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
614 if test -z "$ac_err"; then
615 rm -rf conftest*
616 # We can compile using X headers with no special include directory.
617 ac_x_includes=
618 else
619 echo "$ac_err" >&5
620 echo "configure: failed program was:" >&5
621 cat conftest.$ac_ext >&5
622 rm -rf conftest*
623 # Look for the header file in a standard set of common directories.
624 # Check X11 before X11Rn because it is often a symlink to the current release.
625 for ac_dir in \
626 /usr/X11/include \
627 /usr/X11R6/include \
628 /usr/X11R5/include \
629 /usr/X11R4/include \
630 \
631 /usr/include/X11 \
632 /usr/include/X11R6 \
633 /usr/include/X11R5 \
634 /usr/include/X11R4 \
635 \
636 /usr/local/X11/include \
637 /usr/local/X11R6/include \
638 /usr/local/X11R5/include \
639 /usr/local/X11R4/include \
640 \
641 /usr/local/include/X11 \
642 /usr/local/include/X11R6 \
643 /usr/local/include/X11R5 \
644 /usr/local/include/X11R4 \
645 \
646 /usr/X386/include \
647 /usr/x386/include \
648 /usr/XFree86/include/X11 \
649 \
650 /usr/include \
651 /usr/local/include \
652 /usr/unsupported/include \
653 /usr/athena/include \
654 /usr/local/x11r5/include \
655 /usr/lpp/Xamples/include \
656 \
657 /usr/openwin/include \
658 /usr/openwin/share/include \
659 ; \
660 do
661 if test -r "$ac_dir/$x_direct_test_include"; then
662 ac_x_includes=$ac_dir
663 break
664 fi
665 done
666 fi
667 rm -f conftest*
668 fi # $ac_x_includes = NO
669
670 if test "$ac_x_libraries" = NO; then
671 # Check for the libraries.
672
673 test -z "$x_direct_test_library" && x_direct_test_library=Xt
674 test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
675
676 # See if we find them without any special options.
677 # Don't add to $LIBS permanently.
678 ac_save_LIBS="$LIBS"
679 LIBS="-l$x_direct_test_library $LIBS"
680 cat > conftest.$ac_ext <<EOF
681 #line 683 "configure"
682 #include "confdefs.h"
683
684 int main() {
685 ${x_direct_test_function}()
686 ; return 0; }
687 EOF
688 if { (eval echo configure:690: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
689 rm -rf conftest*
690 LIBS="$ac_save_LIBS"
691 # We can link X programs with no special library path.
692 ac_x_libraries=
693 else
694 echo "configure: failed program was:" >&5
695 cat conftest.$ac_ext >&5
696 rm -rf conftest*
697 LIBS="$ac_save_LIBS"
698 # First see if replacing the include by lib works.
699 # Check X11 before X11Rn because it is often a symlink to the current release.
700 for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \
701 /usr/X11/lib \
702 /usr/X11R6/lib \
703 /usr/X11R5/lib \
704 /usr/X11R4/lib \
705 \
706 /usr/lib/X11 \
707 /usr/lib/X11R6 \
708 /usr/lib/X11R5 \
709 /usr/lib/X11R4 \
710 \
711 /usr/local/X11/lib \
712 /usr/local/X11R6/lib \
713 /usr/local/X11R5/lib \
714 /usr/local/X11R4/lib \
715 \
716 /usr/local/lib/X11 \
717 /usr/local/lib/X11R6 \
718 /usr/local/lib/X11R5 \
719 /usr/local/lib/X11R4 \
720 \
721 /usr/X386/lib \
722 /usr/x386/lib \
723 /usr/XFree86/lib/X11 \
724 \
725 /usr/lib \
726 /usr/local/lib \
727 /usr/unsupported/lib \
728 /usr/athena/lib \
729 /usr/local/x11r5/lib \
730 /usr/lpp/Xamples/lib \
731 /lib/usr/lib/X11 \
732 \
733 /usr/openwin/lib \
734 /usr/openwin/share/lib \
735 ; \
736 do
737 for ac_extension in a so sl; do
738 if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
739 ac_x_libraries=$ac_dir
740 break 2
741 fi
742 done
743 done
744 fi
745 rm -f conftest*
746 fi # $ac_x_libraries = NO
747
748 if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then
749 # Didn't find X anywhere. Cache the known absence of X.
750 ac_cv_have_x="have_x=no"
751 else
752 # Record where we found X for the cache.
753 ac_cv_have_x="have_x=yes \
754 ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
755 fi
756 fi
757 fi
758 eval "$ac_cv_have_x"
759 fi # $with_x != no
760
761 if test "$have_x" != yes; then
762 echo "$ac_t""$have_x" 1>&6
763 no_x=yes
764 else
765 # If each of the values was on the command line, it overrides each guess.
766 test "x$x_includes" = xNONE && x_includes=$ac_x_includes
767 test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
768 # Update the cache value to reflect the command line values.
769 ac_cv_have_x="have_x=yes \
770 ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
771 echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6
772 fi
773
774
775
776
777 ac_aux_dir=
778 for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
779 if test -f $ac_dir/install-sh; then
780 ac_aux_dir=$ac_dir
781 ac_install_sh="$ac_aux_dir/install-sh -c"
782 break
783 elif test -f $ac_dir/install.sh; then
784 ac_aux_dir=$ac_dir
785 ac_install_sh="$ac_aux_dir/install.sh -c"
786 break
787 fi
788 done
789 if test -z "$ac_aux_dir"; then
790 { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
791 fi
792 ac_config_guess=$ac_aux_dir/config.guess
793 ac_config_sub=$ac_aux_dir/config.sub
794 ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
795
796
797 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
798
799 # Make sure we can run config.sub.
800 if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
801 else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
802 fi
803
804 echo $ac_n "checking host system type""... $ac_c" 1>&6
805 echo "configure:807: checking host system type" >&5
806
807 host_alias=$host
808 case "$host_alias" in
809 NONE)
810 case $nonopt in
811 NONE)
812 if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
813 else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
814 fi ;;
815 *) host_alias=$nonopt ;;
816 esac ;;
817 esac
818
819 host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
820 host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
821 host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
822 host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
823 echo "$ac_t""$host" 1>&6
824
825 system_name="$host_os"
826 else
827 system_name="`(uname -s -r) 2>/dev/null`"
828 if test -z "$system_name" ; then
829 system_name="`(hostname) 2>/dev/null`"
830 fi
831 fi
832 test -n "$system_name" && cat >> confdefs.h <<EOF
833 #define SYSTEM_NAME "$system_name"
834 EOF
835
836 if eval "test \"`echo '$''{'cf_cv_system_name'+set}'`\" = set"; then
837 echo $ac_n "(cached) $ac_c" 1>&6
838 else
839 cf_cv_system_name="$system_name"
840 fi
841
842
843 test -z "$system_name" && system_name="$cf_cv_system_name"
844 test -n "$cf_cv_system_name" && echo "$ac_t""Configuring for $cf_cv_system_name" 1>&6
845
846 if test ".$system_name" != ".$cf_cv_system_name" ; then
847 echo "$ac_t""Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" 1>&6
848 { echo "configure: error: "Please remove config.cache and try again."" 1>&2; exit 1; }
849 fi
850
851
852 if test -f $srcdir/VERSION ; then
853 echo $ac_n "checking for package version""... $ac_c" 1>&6
854 echo "configure:856: checking for package version" >&5
855
856 # if there are not enough fields, cut returns the last one...
857 cf_field1=`sed -e '2,$d' $srcdir/VERSION|cut -f1`
858 cf_field2=`sed -e '2,$d' $srcdir/VERSION|cut -f2`
859 cf_field3=`sed -e '2,$d' $srcdir/VERSION|cut -f3`
860
861 # this is how CF_BUNDLED_INTL uses $VERSION:
862 VERSION="$cf_field1"
863
864 VERSION_MAJOR=`echo "$cf_field2" | sed -e 's/\..*//'`
865 test -z "$VERSION_MAJOR" && { echo "configure: error: missing major-version" 1>&2; exit 1; }
866
867 VERSION_MINOR=`echo "$cf_field2" | sed -e 's/^[^.]*\.//' -e 's/-.*//'`
868 test -z "$VERSION_MINOR" && { echo "configure: error: missing minor-version" 1>&2; exit 1; }
869
870 echo "$ac_t""${VERSION_MAJOR}.${VERSION_MINOR}" 1>&6
871
872 echo $ac_n "checking for package patch date""... $ac_c" 1>&6
873 echo "configure:875: checking for package patch date" >&5
874 VERSION_PATCH=`echo "$cf_field3" | sed -e 's/^[^-]*-//'`
875 case .$VERSION_PATCH in
876 .)
877 { echo "configure: error: missing patch-date $VERSION_PATCH" 1>&2; exit 1; }
878 ;;
879 .[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])
880 ;;
881 *)
882 { echo "configure: error: illegal patch-date $VERSION_PATCH" 1>&2; exit 1; }
883 ;;
884 esac
885 echo "$ac_t""$VERSION_PATCH" 1>&6
886 else
887 { echo "configure: error: did not find $srcdir/VERSION" 1>&2; exit 1; }
888 fi
889
890 # show the actual data that we have for versions:
891 test -n "$verbose" && echo " VERSION $VERSION" 1>&6
892
893 test -n "$verbose" && echo " VERSION_MAJOR $VERSION_MAJOR" 1>&6
894
895 test -n "$verbose" && echo " VERSION_MINOR $VERSION_MINOR" 1>&6
896
897 test -n "$verbose" && echo " VERSION_PATCH $VERSION_PATCH" 1>&6
898
899
900
901
902
903
904
905
906 PACKAGE=cdk
907 cat >> confdefs.h <<EOF
908 #define PACKAGE "$PACKAGE"
909 EOF
910
911
912
913 cf_PACKAGE=`echo "$PACKAGE" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
914
915 cat >> confdefs.h <<EOF
916 #define ${cf_PACKAGE}_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}"
917 EOF
918
919 cat >> confdefs.h <<EOF
920 #define ${cf_PACKAGE}_PATCHDATE ${VERSION_PATCH}
921 EOF
922
923
924
925
926 # Extract the first word of "gcc", so it can be a program name with args.
927 set dummy gcc; ac_word=$2
928 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
929 echo "configure:931: checking for $ac_word" >&5
930 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
931 echo $ac_n "(cached) $ac_c" 1>&6
932 else
933 if test -n "$CC"; then
934 ac_cv_prog_CC="$CC" # Let the user override the test.
935 else
936 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
937 ac_dummy="$PATH"
938 for ac_dir in $ac_dummy; do
939 test -z "$ac_dir" && ac_dir=.
940 if test -f $ac_dir/$ac_word; then
941 ac_cv_prog_CC="gcc"
942 break
943 fi
944 done
945 IFS="$ac_save_ifs"
946 fi
947 fi
948 CC="$ac_cv_prog_CC"
949 if test -n "$CC"; then
950 echo "$ac_t""$CC" 1>&6
951 else
952 echo "$ac_t""no" 1>&6
953 fi
954
955 if test -z "$CC"; then
956 # Extract the first word of "cc", so it can be a program name with args.
957 set dummy cc; ac_word=$2
958 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
959 echo "configure:961: checking for $ac_word" >&5
960 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
961 echo $ac_n "(cached) $ac_c" 1>&6
962 else
963 if test -n "$CC"; then
964 ac_cv_prog_CC="$CC" # Let the user override the test.
965 else
966 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
967 ac_prog_rejected=no
968 ac_dummy="$PATH"
969 for ac_dir in $ac_dummy; do
970 test -z "$ac_dir" && ac_dir=.
971 if test -f $ac_dir/$ac_word; then
972 if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
973 ac_prog_rejected=yes
974 continue
975 fi
976 ac_cv_prog_CC="cc"
977 break
978 fi
979 done
980 IFS="$ac_save_ifs"
981 if test $ac_prog_rejected = yes; then
982 # We found a bogon in the path, so make sure we never use it.
983 set dummy $ac_cv_prog_CC
984 shift
985 if test $# -gt 0; then
986 # We chose a different compiler from the bogus one.
987 # However, it has the same basename, so the bogon will be chosen
988 # first if we set CC to just the basename; use the full file name.
989 shift
990 set dummy "$ac_dir/$ac_word" "$@"
991 shift
992 ac_cv_prog_CC="$@"
993 fi
994 fi
995 fi
996 fi
997 CC="$ac_cv_prog_CC"
998 if test -n "$CC"; then
999 echo "$ac_t""$CC" 1>&6
1000 else
1001 echo "$ac_t""no" 1>&6
1002 fi
1003
1004 if test -z "$CC"; then
1005 case "`uname -s`" in
1006 *win32* | *WIN32*)
1007 # Extract the first word of "cl", so it can be a program name with args.
1008 set dummy cl; ac_word=$2
1009 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
1010 echo "configure:1012: checking for $ac_word" >&5
1011 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
1012 echo $ac_n "(cached) $ac_c" 1>&6
1013 else
1014 if test -n "$CC"; then
1015 ac_cv_prog_CC="$CC" # Let the user override the test.
1016 else
1017 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
1018 ac_dummy="$PATH"
1019 for ac_dir in $ac_dummy; do
1020 test -z "$ac_dir" && ac_dir=.
1021 if test -f $ac_dir/$ac_word; then
1022 ac_cv_prog_CC="cl"
1023 break
1024 fi
1025 done
1026 IFS="$ac_save_ifs"
1027 fi
1028 fi
1029 CC="$ac_cv_prog_CC"
1030 if test -n "$CC"; then
1031 echo "$ac_t""$CC" 1>&6
1032 else
1033 echo "$ac_t""no" 1>&6
1034 fi
1035 ;;
1036 esac
1037 fi
1038 test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
1039 fi
1040
1041 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
1042 echo "configure:1044: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
1043
1044 ac_ext=c
1045 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
1046 ac_cpp='$CPP $CPPFLAGS'
1047 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
1048 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
1049 cross_compiling=$ac_cv_prog_cc_cross
1050
1051 cat > conftest.$ac_ext << EOF
1052
1053 #line 1055 "configure"
1054 #include "confdefs.h"
1055
1056 main(){return(0);}
1057 EOF
1058 if { (eval echo configure:1060: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
1059 ac_cv_prog_cc_works=yes
1060 # If we can't run a trivial program, we are probably using a cross compiler.
1061 if (./conftest; exit) 2>/dev/null; then
1062 ac_cv_prog_cc_cross=no
1063 else
1064 ac_cv_prog_cc_cross=yes
1065 fi
1066 else
1067 echo "configure: failed program was:" >&5
1068 cat conftest.$ac_ext >&5
1069 ac_cv_prog_cc_works=no
1070 fi
1071 rm -fr conftest*
1072 ac_ext=c
1073 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
1074 ac_cpp='$CPP $CPPFLAGS'
1075 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
1076 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
1077 cross_compiling=$ac_cv_prog_cc_cross
1078
1079 echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
1080 if test $ac_cv_prog_cc_works = no; then
1081 { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
1082 fi
1083 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
1084 echo "configure:1086: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
1085 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
1086 cross_compiling=$ac_cv_prog_cc_cross
1087
1088 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
1089 echo "configure:1091: checking whether we are using GNU C" >&5
1090 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
1091 echo $ac_n "(cached) $ac_c" 1>&6
1092 else
1093 cat > conftest.c <<EOF
1094 #ifdef __GNUC__
1095 yes;
1096 #endif
1097 EOF
1098 if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1100: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
1099 ac_cv_prog_gcc=yes
1100 else
1101 ac_cv_prog_gcc=no
1102 fi
1103 fi
1104
1105 echo "$ac_t""$ac_cv_prog_gcc" 1>&6
1106
1107 if test $ac_cv_prog_gcc = yes; then
1108 GCC=yes
1109 else
1110 GCC=
1111 fi
1112
1113 ac_test_CFLAGS="${CFLAGS+set}"
1114 ac_save_CFLAGS="$CFLAGS"
1115 CFLAGS=
1116 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
1117 echo "configure:1119: checking whether ${CC-cc} accepts -g" >&5
1118 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
1119 echo $ac_n "(cached) $ac_c" 1>&6
1120 else
1121 echo 'void f(){}' > conftest.c
1122 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
1123 ac_cv_prog_cc_g=yes
1124 else
1125 ac_cv_prog_cc_g=no
1126 fi
1127 rm -f conftest*
1128
1129 fi
1130
1131 echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
1132 if test "$ac_test_CFLAGS" = set; then
1133 CFLAGS="$ac_save_CFLAGS"
1134 elif test $ac_cv_prog_cc_g = yes; then
1135 if test "$GCC" = yes; then
1136 CFLAGS="-g -O2"
1137 else
1138 CFLAGS="-g"
1139 fi
1140 else
1141 if test "$GCC" = yes; then
1142 CFLAGS="-O2"
1143 else
1144 CFLAGS=
1145 fi
1146 fi
1147
1148 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
1149 echo "configure:1151: checking how to run the C preprocessor" >&5
1150 # On Suns, sometimes $CPP names a directory.
1151 if test -n "$CPP" && test -d "$CPP"; then
1152 CPP=
1153 fi
1154 if test -z "$CPP"; then
1155 if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
1156 echo $ac_n "(cached) $ac_c" 1>&6
1157 else
1158 # This must be in double quotes, not single quotes, because CPP may get
1159 # substituted into the Makefile and "${CC-cc}" will confuse make.
1160 CPP="${CC-cc} -E"
1161 # On the NeXT, cc -E runs the code through the compiler's parser,
1162 # not just through cpp.
1163 cat > conftest.$ac_ext <<EOF
1164 #line 1166 "configure"
1165 #include "confdefs.h"
1166 #include <assert.h>
1167 Syntax Error
1168 EOF
1169 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
1170 { (eval echo configure:1172: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
1171 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
1172 if test -z "$ac_err"; then
1173 :
1174 else
1175 echo "$ac_err" >&5
1176 echo "configure: failed program was:" >&5
1177 cat conftest.$ac_ext >&5
1178 rm -rf conftest*
1179 CPP="${CC-cc} -E -traditional-cpp"
1180 cat > conftest.$ac_ext <<EOF
1181 #line 1183 "configure"
1182 #include "confdefs.h"
1183 #include <assert.h>
1184 Syntax Error
1185 EOF
1186 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
1187 { (eval echo configure:1189: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
1188 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
1189 if test -z "$ac_err"; then
1190 :
1191 else
1192 echo "$ac_err" >&5
1193 echo "configure: failed program was:" >&5
1194 cat conftest.$ac_ext >&5
1195 rm -rf conftest*
1196 CPP="${CC-cc} -nologo -E"
1197 cat > conftest.$ac_ext <<EOF
1198 #line 1200 "configure"
1199 #include "confdefs.h"
1200 #include <assert.h>
1201 Syntax Error
1202 EOF
1203 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
1204 { (eval echo configure:1206: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
1205 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
1206 if test -z "$ac_err"; then
1207 :
1208 else
1209 echo "$ac_err" >&5
1210 echo "configure: failed program was:" >&5
1211 cat conftest.$ac_ext >&5
1212 rm -rf conftest*
1213 CPP=/lib/cpp
1214 fi
1215 rm -f conftest*
1216 fi
1217 rm -f conftest*
1218 fi
1219 rm -f conftest*
1220 ac_cv_prog_CPP="$CPP"
1221 fi
1222 CPP="$ac_cv_prog_CPP"
1223 else
1224 ac_cv_prog_CPP="$CPP"
1225 fi
1226 echo "$ac_t""$CPP" 1>&6
1227
1228 if test $ac_cv_prog_gcc = yes; then
1229 echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
1230 echo "configure:1232: checking whether ${CC-cc} needs -traditional" >&5
1231 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
1232 echo $ac_n "(cached) $ac_c" 1>&6
1233 else
1234 ac_pattern="Autoconf.*'x'"
1235 cat > conftest.$ac_ext <<EOF
1236 #line 1238 "configure"
1237 #include "confdefs.h"
1238 #include <sgtty.h>
1239 Autoconf TIOCGETP
1240 EOF
1241 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
1242 egrep "$ac_pattern" >/dev/null 2>&1; then
1243 rm -rf conftest*
1244 ac_cv_prog_gcc_traditional=yes
1245 else
1246 rm -rf conftest*
1247 ac_cv_prog_gcc_traditional=no
1248 fi
1249 rm -f conftest*
1250
1251
1252 if test $ac_cv_prog_gcc_traditional = no; then
1253 cat > conftest.$ac_ext <<EOF
1254 #line 1256 "configure"
1255 #include "confdefs.h"
1256 #include <termio.h>
1257 Autoconf TCGETA
1258 EOF
1259 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
1260 egrep "$ac_pattern" >/dev/null 2>&1; then
1261 rm -rf conftest*
1262 ac_cv_prog_gcc_traditional=yes
1263 fi
1264 rm -f conftest*
1265
1266 fi
1267 fi
1268
1269 echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6
1270 if test $ac_cv_prog_gcc_traditional = yes; then
1271 CC="$CC -traditional"
1272 fi
1273 fi
1274
1275 # Extract the first word of "ranlib", so it can be a program name with args.
1276 set dummy ranlib; ac_word=$2
1277 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
1278 echo "configure:1280: checking for $ac_word" >&5
1279 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
1280 echo $ac_n "(cached) $ac_c" 1>&6
1281 else
1282 if test -n "$RANLIB"; then
1283 ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
1284 else
1285 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
1286 ac_dummy="$PATH"
1287 for ac_dir in $ac_dummy; do
1288 test -z "$ac_dir" && ac_dir=.
1289 if test -f $ac_dir/$ac_word; then
1290 ac_cv_prog_RANLIB="ranlib"
1291 break
1292 fi
1293 done
1294 IFS="$ac_save_ifs"
1295 test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
1296 fi
1297 fi
1298 RANLIB="$ac_cv_prog_RANLIB"
1299 if test -n "$RANLIB"; then
1300 echo "$ac_t""$RANLIB" 1>&6
1301 else
1302 echo "$ac_t""no" 1>&6
1303 fi
1304
1305 # Find a good install program. We prefer a C program (faster),
1306 # so one script is as good as another. But avoid the broken or
1307 # incompatible versions:
1308 # SysV /etc/install, /usr/sbin/install
1309 # SunOS /usr/etc/install
1310 # IRIX /sbin/install
1311 # AIX /bin/install
1312 # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
1313 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
1314 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
1315 # ./install, which can be erroneously created by make from ./install.sh.
1316 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
1317 echo "configure:1319: checking for a BSD compatible install" >&5
1318 if test -z "$INSTALL"; then
1319 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
1320 echo $ac_n "(cached) $ac_c" 1>&6
1321 else
1322 IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
1323 for ac_dir in $PATH; do
1324 # Account for people who put trailing slashes in PATH elements.
1325 case "$ac_dir/" in
1326 /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
1327 *)
1328 # OSF1 and SCO ODT 3.0 have their own names for install.
1329 # Don't use installbsd from OSF since it installs stuff as root
1330 # by default.
1331 for ac_prog in ginstall scoinst install; do
1332 if test -f $ac_dir/$ac_prog; then
1333 if test $ac_prog = install &&
1334 grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
1335 # AIX install. It has an incompatible calling convention.
1336 :
1337 else
1338 ac_cv_path_install="$ac_dir/$ac_prog -c"
1339 break 2
1340 fi
1341 fi
1342 done
1343 ;;
1344 esac
1345 done
1346 IFS="$ac_save_IFS"
1347
1348 fi
1349 if test "${ac_cv_path_install+set}" = set; then
1350 INSTALL="$ac_cv_path_install"
1351 else
1352 # As a last resort, use the slow shell script. We don't cache a
1353 # path for INSTALL within a source directory, because that will
1354 # break other packages using the cache if that directory is
1355 # removed, or if the path is relative.
1356 INSTALL="$ac_install_sh"
1357 fi
1358 fi
1359 echo "$ac_t""$INSTALL" 1>&6
1360
1361 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
1362 # It thinks the first close brace ends the variable substitution.
1363 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
1364
1365 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
1366
1367 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
1368
1369
1370 echo $ac_n "checking build system type""... $ac_c" 1>&6
1371 echo "configure:1373: checking build system type" >&5
1372
1373 build_alias=$build
1374 case "$build_alias" in
1375 NONE)
1376 case $nonopt in
1377 NONE) build_alias=$host_alias ;;
1378 *) build_alias=$nonopt ;;
1379 esac ;;
1380 esac
1381
1382 build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
1383 build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
1384 build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
1385 build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
1386 echo "$ac_t""$build" 1>&6
1387
1388 if test $host != $build; then
1389 ac_tool_prefix=${host_alias}-
1390 else
1391 ac_tool_prefix=
1392 fi
1393
1394 # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
1395 set dummy ${ac_tool_prefix}ar; ac_word=$2
1396 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
1397 echo "configure:1399: checking for $ac_word" >&5
1398 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
1399 echo $ac_n "(cached) $ac_c" 1>&6
1400 else
1401 if test -n "$AR"; then
1402 ac_cv_prog_AR="$AR" # Let the user override the test.
1403 else
1404 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
1405 ac_dummy="$PATH"
1406 for ac_dir in $ac_dummy; do
1407 test -z "$ac_dir" && ac_dir=.
1408 if test -f $ac_dir/$ac_word; then
1409 ac_cv_prog_AR="${ac_tool_prefix}ar"
1410 break
1411 fi
1412 done
1413 IFS="$ac_save_ifs"
1414 fi
1415 fi
1416 AR="$ac_cv_prog_AR"
1417 if test -n "$AR"; then
1418 echo "$ac_t""$AR" 1>&6
1419 else
1420 echo "$ac_t""no" 1>&6
1421 fi
1422
1423
1424 if test -z "$ac_cv_prog_AR"; then
1425 if test -n "$ac_tool_prefix"; then
1426 # Extract the first word of "ar", so it can be a program name with args.
1427 set dummy ar; ac_word=$2
1428 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
1429 echo "configure:1431: checking for $ac_word" >&5
1430 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
1431 echo $ac_n "(cached) $ac_c" 1>&6
1432 else
1433 if test -n "$AR"; then
1434 ac_cv_prog_AR="$AR" # Let the user override the test.
1435 else
1436 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
1437 ac_dummy="$PATH"
1438 for ac_dir in $ac_dummy; do
1439 test -z "$ac_dir" && ac_dir=.
1440 if test -f $ac_dir/$ac_word; then
1441 ac_cv_prog_AR="ar"
1442 break
1443 fi
1444 done
1445 IFS="$ac_save_ifs"
1446 test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="ar"
1447 fi
1448 fi
1449 AR="$ac_cv_prog_AR"
1450 if test -n "$AR"; then
1451 echo "$ac_t""$AR" 1>&6
1452 else
1453 echo "$ac_t""no" 1>&6
1454 fi
1455
1456 else
1457 AR="ar"
1458 fi
1459 fi
1460
1461
1462 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
1463 echo "configure:1465: checking whether ${MAKE-make} sets \${MAKE}" >&5
1464 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
1465 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
1466 echo $ac_n "(cached) $ac_c" 1>&6
1467 else
1468 cat > conftestmake <<\EOF
1469 all:
1470 @echo 'ac_maketemp="${MAKE}"'
1471 EOF
1472 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
1473 eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
1474 if test -n "$ac_maketemp"; then
1475 eval ac_cv_prog_make_${ac_make}_set=yes
1476 else
1477 eval ac_cv_prog_make_${ac_make}_set=no
1478 fi
1479 rm -f conftestmake
1480 fi
1481 if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
1482 echo "$ac_t""yes" 1>&6
1483 SET_MAKE=
1484 else
1485 echo "$ac_t""no" 1>&6
1486 SET_MAKE="MAKE=${MAKE-make}"
1487 fi
1488
1489
1490 echo $ac_n "checking for makeflags variable""... $ac_c" 1>&6
1491 echo "configure:1493: checking for makeflags variable" >&5
1492 if eval "test \"`echo '$''{'cf_cv_makeflags'+set}'`\" = set"; then
1493 echo $ac_n "(cached) $ac_c" 1>&6
1494 else
1495
1496 cf_cv_makeflags=''
1497 for cf_option in '-$(MAKEFLAGS)' '$(MFLAGS)'
1498 do
1499 cat >cf_makeflags.tmp <<CF_EOF
1500 SHELL = /bin/sh
1501 all :
1502 @ echo '.$cf_option'
1503 CF_EOF
1504 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null`
1505 case "$cf_result" in
1506 .*k)
1507 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
1508 case "$cf_result" in
1509 .*CC=*) cf_cv_makeflags=
1510 ;;
1511 *) cf_cv_makeflags=$cf_option
1512 ;;
1513 esac
1514 break
1515 ;;
1516 *) echo no match "$cf_result"
1517 ;;
1518 esac
1519 done
1520 rm -f cf_makeflags.tmp
1521
1522 fi
1523
1524 echo "$ac_t""$cf_cv_makeflags" 1>&6
1525
1526
1527
1528
1529 echo $ac_n "checking if filesystem supports mixed-case filenames""... $ac_c" 1>&6
1530 echo "configure:1532: checking if filesystem supports mixed-case filenames" >&5
1531 if eval "test \"`echo '$''{'cf_cv_mixedcase'+set}'`\" = set"; then
1532 echo $ac_n "(cached) $ac_c" 1>&6
1533 else
1534
1535 if test "$cross_compiling" = yes ; then
1536 case $target_alias in #(vi
1537 *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
1538 cf_cv_mixedcase=no
1539 ;;
1540 *)
1541 cf_cv_mixedcase=yes
1542 ;;
1543 esac
1544 else
1545 rm -f conftest CONFTEST
1546 echo test >conftest
1547 if test -f CONFTEST ; then
1548 cf_cv_mixedcase=no
1549 else
1550 cf_cv_mixedcase=yes
1551 fi
1552 rm -f conftest CONFTEST
1553 fi
1554
1555 fi
1556
1557 echo "$ac_t""$cf_cv_mixedcase" 1>&6
1558 test "$cf_cv_mixedcase" = yes && cat >> confdefs.h <<\EOF
1559 #define MIXEDCASE_FILENAMES 1
1560 EOF
1561
1562
1563
1564
1565 # Extract the first word of "ctags", so it can be a program name with args.
1566 set dummy ctags; ac_word=$2
1567 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
1568 echo "configure:1570: checking for $ac_word" >&5
1569 if eval "test \"`echo '$''{'ac_cv_prog_MAKE_LOWER_TAGS'+set}'`\" = set"; then
1570 echo $ac_n "(cached) $ac_c" 1>&6
1571 else
1572 if test -n "$MAKE_LOWER_TAGS"; then
1573 ac_cv_prog_MAKE_LOWER_TAGS="$MAKE_LOWER_TAGS" # Let the user override the test.
1574 else
1575 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
1576 ac_dummy="$PATH"
1577 for ac_dir in $ac_dummy; do
1578 test -z "$ac_dir" && ac_dir=.
1579 if test -f $ac_dir/$ac_word; then
1580 ac_cv_prog_MAKE_LOWER_TAGS="yes"
1581 break
1582 fi
1583 done
1584 IFS="$ac_save_ifs"
1585 test -z "$ac_cv_prog_MAKE_LOWER_TAGS" && ac_cv_prog_MAKE_LOWER_TAGS="no"
1586 fi
1587 fi
1588 MAKE_LOWER_TAGS="$ac_cv_prog_MAKE_LOWER_TAGS"
1589 if test -n "$MAKE_LOWER_TAGS"; then
1590 echo "$ac_t""$MAKE_LOWER_TAGS" 1>&6
1591 else
1592 echo "$ac_t""no" 1>&6
1593 fi
1594
1595
1596 if test "$cf_cv_mixedcase" = yes ; then
1597 # Extract the first word of "etags", so it can be a program name with args.
1598 set dummy etags; ac_word=$2
1599 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
1600 echo "configure:1602: checking for $ac_word" >&5
1601 if eval "test \"`echo '$''{'ac_cv_prog_MAKE_UPPER_TAGS'+set}'`\" = set"; then
1602 echo $ac_n "(cached) $ac_c" 1>&6
1603 else
1604 if test -n "$MAKE_UPPER_TAGS"; then
1605 ac_cv_prog_MAKE_UPPER_TAGS="$MAKE_UPPER_TAGS" # Let the user override the test.
1606 else
1607 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
1608 ac_dummy="$PATH"
1609 for ac_dir in $ac_dummy; do
1610 test -z "$ac_dir" && ac_dir=.
1611 if test -f $ac_dir/$ac_word; then
1612 ac_cv_prog_MAKE_UPPER_TAGS="yes"
1613 break
1614 fi
1615 done
1616 IFS="$ac_save_ifs"
1617 test -z "$ac_cv_prog_MAKE_UPPER_TAGS" && ac_cv_prog_MAKE_UPPER_TAGS="no"
1618 fi
1619 fi
1620 MAKE_UPPER_TAGS="$ac_cv_prog_MAKE_UPPER_TAGS"
1621 if test -n "$MAKE_UPPER_TAGS"; then
1622 echo "$ac_t""$MAKE_UPPER_TAGS" 1>&6
1623 else
1624 echo "$ac_t""no" 1>&6
1625 fi
1626
1627 else
1628 MAKE_UPPER_TAGS=no
1629 fi
1630
1631 if test "$MAKE_UPPER_TAGS" = yes ; then
1632 MAKE_UPPER_TAGS=
1633 else
1634 MAKE_UPPER_TAGS="#"
1635 fi
1636
1637
1638 if test "$MAKE_LOWER_TAGS" = yes ; then
1639 MAKE_LOWER_TAGS=
1640 else
1641 MAKE_LOWER_TAGS="#"
1642 fi
1643
1644
1645
1646
1647 echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6
1648 echo "configure:1650: checking for ${CC-cc} option to accept ANSI C" >&5
1649 if eval "test \"`echo '$''{'cf_cv_ansi_cc'+set}'`\" = set"; then
1650 echo $ac_n "(cached) $ac_c" 1>&6
1651 else
1652
1653 cf_cv_ansi_cc=no
1654 cf_save_CFLAGS="$CFLAGS"
1655 cf_save_CPPFLAGS="$CPPFLAGS"
1656 # Don't try gcc -ansi; that turns off useful extensions and
1657 # breaks some systems' header files.
1658 # AIX -qlanglvl=ansi
1659 # Ultrix and OSF/1 -std1
1660 # HP-UX -Aa -D_HPUX_SOURCE
1661 # SVR4 -Xc
1662 # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
1663 for cf_arg in "-DCC_HAS_PROTOS" \
1664 "" \
1665 -qlanglvl=ansi \
1666 -std1 \
1667 -Ae \
1668 "-Aa -D_HPUX_SOURCE" \
1669 -Xc
1670 do
1671
1672 cf_fix_cppflags=no
1673 cf_new_cflags=
1674 cf_new_cppflags=
1675 cf_new_extra_cppflags=
1676
1677 for cf_add_cflags in $cf_arg
1678 do
1679 case $cf_fix_cppflags in
1680 no)
1681 case $cf_add_cflags in #(vi
1682 -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
1683 case $cf_add_cflags in
1684 -D*)
1685 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
1686
1687 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
1688 && test -z "${cf_tst_cflags}" \
1689 && cf_fix_cppflags=yes
1690
1691 if test $cf_fix_cppflags = yes ; then
1692 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
1693 continue
1694 elif test "${cf_tst_cflags}" = "\"'" ; then
1695 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
1696 continue
1697 fi
1698 ;;
1699 esac
1700 case "$CPPFLAGS" in
1701 *$cf_add_cflags) #(vi
1702 ;;
1703 *) #(vi
1704 cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
1705 ;;
1706 esac
1707 ;;
1708 *)
1709 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
1710 ;;
1711 esac
1712 ;;
1713 yes)
1714 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
1715
1716 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
1717
1718 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
1719 && test -z "${cf_tst_cflags}" \
1720 && cf_fix_cppflags=no
1721 ;;
1722 esac
1723 done
1724
1725 if test -n "$cf_new_cflags" ; then
1726
1727 CFLAGS="$CFLAGS $cf_new_cflags"
1728 fi
1729
1730 if test -n "$cf_new_cppflags" ; then
1731
1732 CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
1733 fi
1734
1735 if test -n "$cf_new_extra_cppflags" ; then
1736
1737 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
1738 fi
1739
1740
1741
1742
1743 cat > conftest.$ac_ext <<EOF
1744 #line 1746 "configure"
1745 #include "confdefs.h"
1746
1747 #ifndef CC_HAS_PROTOS
1748 #if !defined(__STDC__) || (__STDC__ != 1)
1749 choke me
1750 #endif
1751 #endif
1752
1753 int main() {
1754
1755 int test (int i, double x);
1756 struct s1 {int (*f) (int a);};
1757 struct s2 {int (*f) (double a);};
1758 ; return 0; }
1759 EOF
1760 if { (eval echo configure:1762: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
1761 rm -rf conftest*
1762 cf_cv_ansi_cc="$cf_arg"; break
1763 else
1764 echo "configure: failed program was:" >&5
1765 cat conftest.$ac_ext >&5
1766 fi
1767 rm -f conftest*
1768 done
1769 CFLAGS="$cf_save_CFLAGS"
1770 CPPFLAGS="$cf_save_CPPFLAGS"
1771
1772 fi
1773
1774 echo "$ac_t""$cf_cv_ansi_cc" 1>&6
1775
1776 if test "$cf_cv_ansi_cc" != "no"; then
1777 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
1778
1779 cf_fix_cppflags=no
1780 cf_new_cflags=
1781 cf_new_cppflags=
1782 cf_new_extra_cppflags=
1783
1784 for cf_add_cflags in $cf_cv_ansi_cc
1785 do
1786 case $cf_fix_cppflags in
1787 no)
1788 case $cf_add_cflags in #(vi
1789 -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
1790 case $cf_add_cflags in
1791 -D*)
1792 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
1793
1794 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
1795 && test -z "${cf_tst_cflags}" \
1796 && cf_fix_cppflags=yes
1797
1798 if test $cf_fix_cppflags = yes ; then
1799 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
1800 continue
1801 elif test "${cf_tst_cflags}" = "\"'" ; then
1802 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
1803 continue
1804 fi
1805 ;;
1806 esac
1807 case "$CPPFLAGS" in
1808 *$cf_add_cflags) #(vi
1809 ;;
1810 *) #(vi
1811 cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
1812 ;;
1813 esac
1814 ;;
1815 *)
1816 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
1817 ;;
1818 esac
1819 ;;
1820 yes)
1821 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
1822
1823 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
1824
1825 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
1826 && test -z "${cf_tst_cflags}" \
1827 && cf_fix_cppflags=no
1828 ;;
1829 esac
1830 done
1831
1832 if test -n "$cf_new_cflags" ; then
1833
1834 CFLAGS="$CFLAGS $cf_new_cflags"
1835 fi
1836
1837 if test -n "$cf_new_cppflags" ; then
1838
1839 CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
1840 fi
1841
1842 if test -n "$cf_new_extra_cppflags" ; then
1843
1844 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
1845 fi
1846
1847
1848
1849
1850 else
1851 cat >> confdefs.h <<\EOF
1852 #define CC_HAS_PROTOS 1
1853 EOF
1854
1855 fi
1856 fi
1857
1858
1859 if test "$cf_cv_ansi_cc" = "no"; then
1860 { echo "configure: error: Your compiler does not appear to recognize prototypes.
1861 You have the following choices:
1862 a. adjust your compiler options
1863 b. get an up-to-date compiler
1864 c. use a wrapper such as unproto" 1>&2; exit 1; }
1865 fi
1866
1867 echo $ac_n "checking for working const""... $ac_c" 1>&6
1868 echo "configure:1870: checking for working const" >&5
1869 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
1870 echo $ac_n "(cached) $ac_c" 1>&6
1871 else
1872 cat > conftest.$ac_ext <<EOF
1873 #line 1875 "configure"
1874 #include "confdefs.h"
1875
1876 int main() {
1877
1878 /* Ultrix mips cc rejects this. */
1879 typedef int charset[2]; const charset x;
1880 /* SunOS 4.1.1 cc rejects this. */
1881 char const *const *ccp;
1882 char **p;
1883 /* NEC SVR4.0.2 mips cc rejects this. */
1884 struct point {int x, y;};
1885 static struct point const zero = {0,0};
1886 /* AIX XL C 1.02.0.0 rejects this.
1887 It does not let you subtract one const X* pointer from another in an arm
1888 of an if-expression whose if-part is not a constant expression */
1889 const char *g = "string";
1890 ccp = &g + (g ? g-g : 0);
1891 /* HPUX 7.0 cc rejects these. */
1892 ++ccp;
1893 p = (char**) ccp;
1894 ccp = (char const *const *) p;
1895 { /* SCO 3.2v4 cc rejects this. */
1896 char *t;
1897 char const *s = 0 ? (char *) 0 : (char const *) 0;
1898
1899 *t++ = 0;
1900 }
1901 { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
1902 int x[] = {25, 17};
1903 const int *foo = &x[0];
1904 ++foo;
1905 }
1906 { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
1907 typedef const int *iptr;
1908 iptr p = 0;
1909 ++p;
1910 }
1911 { /* AIX XL C 1.02.0.0 rejects this saying
1912 "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
1913 struct s { int j; const int *ap[3]; };
1914 struct s *b; b->j = 5;
1915 }
1916 { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
1917 const int foo = 10;
1918 }
1919
1920 ; return 0; }
1921 EOF
1922 if { (eval echo configure:1924: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
1923 rm -rf conftest*
1924 ac_cv_c_const=yes
1925 else
1926 echo "configure: failed program was:" >&5
1927 cat conftest.$ac_ext >&5
1928 rm -rf conftest*
1929 ac_cv_c_const=no
1930 fi
1931 rm -f conftest*
1932 fi
1933
1934 echo "$ac_t""$ac_cv_c_const" 1>&6
1935 if test $ac_cv_c_const = no; then
1936 cat >> confdefs.h <<\EOF
1937 #define const
1938 EOF
1939
1940 fi
1941
1942
1943 echo $ac_n "checking if $CC -U and -D options work together""... $ac_c" 1>&6
1944 echo "configure:1946: checking if $CC -U and -D options work together" >&5
1945 if eval "test \"`echo '$''{'cf_cv_cc_u_d_options'+set}'`\" = set"; then
1946 echo $ac_n "(cached) $ac_c" 1>&6
1947 else
1948
1949 cf_save_CPPFLAGS="$CPPFLAGS"
1950 CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
1951 cat > conftest.$ac_ext <<EOF
1952 #line 1954 "configure"
1953 #include "confdefs.h"
1954
1955 int main() {
1956
1957 #ifndef U_D_OPTIONS
1958 make an undefined-error
1959 #endif
1960 #ifdef D_U_OPTIONS
1961 make a defined-error
1962 #endif
1963
1964 ; return 0; }
1965 EOF
1966 if { (eval echo configure:1968: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
1967 rm -rf conftest*
1968
1969 cf_cv_cc_u_d_options=yes
1970 else
1971 echo "configure: failed program was:" >&5
1972 cat conftest.$ac_ext >&5
1973 rm -rf conftest*
1974
1975 cf_cv_cc_u_d_options=no
1976 fi
1977 rm -f conftest*
1978 CPPFLAGS="$cf_save_CPPFLAGS"
1979
1980 fi
1981
1982 echo "$ac_t""$cf_cv_cc_u_d_options" 1>&6
1983
1984
1985
1986
1987
1988 cf_XOPEN_SOURCE=500
1989 cf_POSIX_C_SOURCE=199506L
1990
1991 case $host_os in #(vi
1992 aix[45]*) #(vi
1993 CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
1994 ;;
1995 freebsd*) #(vi
1996 # 5.x headers associate
1997 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1998 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1999 cf_POSIX_C_SOURCE=200112L
2000 cf_XOPEN_SOURCE=600
2001 CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2002 ;;
2003 hpux*) #(vi
2004 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
2005 ;;
2006 irix[56].*) #(vi
2007 CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
2008 ;;
2009 linux*|gnu*) #(vi
2010
2011 echo $ac_n "checking if we must define _GNU_SOURCE""... $ac_c" 1>&6
2012 echo "configure:2014: checking if we must define _GNU_SOURCE" >&5
2013 if eval "test \"`echo '$''{'cf_cv_gnu_source'+set}'`\" = set"; then
2014 echo $ac_n "(cached) $ac_c" 1>&6
2015 else
2016
2017 cat > conftest.$ac_ext <<EOF
2018 #line 2020 "configure"
2019 #include "confdefs.h"
2020 #include <sys/types.h>
2021 int main() {
2022
2023 #ifndef _XOPEN_SOURCE
2024 make an error
2025 #endif
2026 ; return 0; }
2027 EOF
2028 if { (eval echo configure:2030: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2029 rm -rf conftest*
2030 cf_cv_gnu_source=no
2031 else
2032 echo "configure: failed program was:" >&5
2033 cat conftest.$ac_ext >&5
2034 rm -rf conftest*
2035 cf_save="$CPPFLAGS"
2036 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
2037 cat > conftest.$ac_ext <<EOF
2038 #line 2040 "configure"
2039 #include "confdefs.h"
2040 #include <sys/types.h>
2041 int main() {
2042
2043 #ifdef _XOPEN_SOURCE
2044 make an error
2045 #endif
2046 ; return 0; }
2047 EOF
2048 if { (eval echo configure:2050: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2049 rm -rf conftest*
2050 cf_cv_gnu_source=no
2051 else
2052 echo "configure: failed program was:" >&5
2053 cat conftest.$ac_ext >&5
2054 rm -rf conftest*
2055 cf_cv_gnu_source=yes
2056 fi
2057 rm -f conftest*
2058 CPPFLAGS="$cf_save"
2059
2060 fi
2061 rm -f conftest*
2062
2063 fi
2064
2065 echo "$ac_t""$cf_cv_gnu_source" 1>&6
2066 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
2067
2068 ;;
2069 mirbsd*) #(vi
2070 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
2071 ;;
2072 netbsd*) #(vi
2073 # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
2074 ;;
2075 openbsd*) #(vi
2076 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
2077 ;;
2078 osf[45]*) #(vi
2079 CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
2080 ;;
2081 nto-qnx*) #(vi
2082 CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE"
2083 ;;
2084 sco*) #(vi
2085 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
2086 ;;
2087 solaris*) #(vi
2088 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
2089 ;;
2090 *)
2091 echo $ac_n "checking if we should define _XOPEN_SOURCE""... $ac_c" 1>&6
2092 echo "configure:2094: checking if we should define _XOPEN_SOURCE" >&5
2093 if eval "test \"`echo '$''{'cf_cv_xopen_source'+set}'`\" = set"; then
2094 echo $ac_n "(cached) $ac_c" 1>&6
2095 else
2096
2097 cat > conftest.$ac_ext <<EOF
2098 #line 2100 "configure"
2099 #include "confdefs.h"
2100 #include <sys/types.h>
2101 int main() {
2102
2103 #ifndef _XOPEN_SOURCE
2104 make an error
2105 #endif
2106 ; return 0; }
2107 EOF
2108 if { (eval echo configure:2110: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2109 rm -rf conftest*
2110 cf_cv_xopen_source=no
2111 else
2112 echo "configure: failed program was:" >&5
2113 cat conftest.$ac_ext >&5
2114 rm -rf conftest*
2115 cf_save="$CPPFLAGS"
2116 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2117 cat > conftest.$ac_ext <<EOF
2118 #line 2120 "configure"
2119 #include "confdefs.h"
2120 #include <sys/types.h>
2121 int main() {
2122
2123 #ifdef _XOPEN_SOURCE
2124 make an error
2125 #endif
2126 ; return 0; }
2127 EOF
2128 if { (eval echo configure:2130: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2129 rm -rf conftest*
2130 cf_cv_xopen_source=no
2131 else
2132 echo "configure: failed program was:" >&5
2133 cat conftest.$ac_ext >&5
2134 rm -rf conftest*
2135 cf_cv_xopen_source=$cf_XOPEN_SOURCE
2136 fi
2137 rm -f conftest*
2138 CPPFLAGS="$cf_save"
2139
2140 fi
2141 rm -f conftest*
2142
2143 fi
2144
2145 echo "$ac_t""$cf_cv_xopen_source" 1>&6
2146 if test "$cf_cv_xopen_source" != no ; then
2147
2148 # remove _XOPEN_SOURCE symbol from $CFLAGS
2149 CFLAGS=`echo "$CFLAGS" | \
2150 sed -e 's/-[UD]_XOPEN_SOURCE\(=[^ ]*\)\?[ ]/ /g' \
2151 -e 's/-[UD]_XOPEN_SOURCE\(=[^ ]*\)\?$//g'`
2152
2153
2154 # remove _XOPEN_SOURCE symbol from $CPPFLAGS
2155 CPPFLAGS=`echo "$CPPFLAGS" | \
2156 sed -e 's/-[UD]_XOPEN_SOURCE\(=[^ ]*\)\?[ ]/ /g' \
2157 -e 's/-[UD]_XOPEN_SOURCE\(=[^ ]*\)\?$//g'`
2158
2159 test "$cf_cv_cc_u_d_options" = yes && \
2160 CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
2161 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source"
2162 fi
2163
2164 cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE
2165
2166 cf_save_CFLAGS="$CFLAGS"
2167 cf_save_CPPFLAGS="$CPPFLAGS"
2168
2169
2170 # remove _POSIX_C_SOURCE symbol from $cf_save_CFLAGS
2171 cf_trim_CFLAGS=`echo "$cf_save_CFLAGS" | \
2172 sed -e 's/-[UD]_POSIX_C_SOURCE\(=[^ ]*\)\?[ ]/ /g' \
2173 -e 's/-[UD]_POSIX_C_SOURCE\(=[^ ]*\)\?$//g'`
2174
2175
2176 # remove _POSIX_C_SOURCE symbol from $cf_save_CPPFLAGS
2177 cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \
2178 sed -e 's/-[UD]_POSIX_C_SOURCE\(=[^ ]*\)\?[ ]/ /g' \
2179 -e 's/-[UD]_POSIX_C_SOURCE\(=[^ ]*\)\?$//g'`
2180
2181
2182 echo $ac_n "checking if we should define _POSIX_C_SOURCE""... $ac_c" 1>&6
2183 echo "configure:2185: checking if we should define _POSIX_C_SOURCE" >&5
2184 if eval "test \"`echo '$''{'cf_cv_posix_c_source'+set}'`\" = set"; then
2185 echo $ac_n "(cached) $ac_c" 1>&6
2186 else
2187
2188
2189 echo "(line 2191) testing if the symbol is already defined go no further ..." 1>&5
2190
2191 cat > conftest.$ac_ext <<EOF
2192 #line 2194 "configure"
2193 #include "confdefs.h"
2194 #include <sys/types.h>
2195 int main() {
2196
2197 #ifndef _POSIX_C_SOURCE
2198 make an error
2199 #endif
2200 ; return 0; }
2201 EOF
2202 if { (eval echo configure:2204: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2203 rm -rf conftest*
2204 cf_cv_posix_c_source=no
2205 else
2206 echo "configure: failed program was:" >&5
2207 cat conftest.$ac_ext >&5
2208 rm -rf conftest*
2209 cf_want_posix_source=no
2210 case .$cf_POSIX_C_SOURCE in #(vi
2211 .[12]??*) #(vi
2212 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2213 ;;
2214 .2) #(vi
2215 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2216 cf_want_posix_source=yes
2217 ;;
2218 .*)
2219 cf_want_posix_source=yes
2220 ;;
2221 esac
2222 if test "$cf_want_posix_source" = yes ; then
2223 cat > conftest.$ac_ext <<EOF
2224 #line 2226 "configure"
2225 #include "confdefs.h"
2226 #include <sys/types.h>
2227 int main() {
2228
2229 #ifdef _POSIX_SOURCE
2230 make an error
2231 #endif
2232 ; return 0; }
2233 EOF
2234 if { (eval echo configure:2236: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2235 :
2236 else
2237 echo "configure: failed program was:" >&5
2238 cat conftest.$ac_ext >&5
2239 rm -rf conftest*
2240 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE"
2241 fi
2242 rm -f conftest*
2243 fi
2244
2245 echo "(line 2247) testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
2246
2247 CFLAGS="$cf_trim_CFLAGS"
2248 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
2249
2250 echo "(line 2252) testing if the second compile does not leave our definition intact error ..." 1>&5
2251
2252 cat > conftest.$ac_ext <<EOF
2253 #line 2255 "configure"
2254 #include "confdefs.h"
2255 #include <sys/types.h>
2256 int main() {
2257
2258 #ifndef _POSIX_C_SOURCE
2259 make an error
2260 #endif
2261 ; return 0; }
2262 EOF
2263 if { (eval echo configure:2265: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2264 :
2265 else
2266 echo "configure: failed program was:" >&5
2267 cat conftest.$ac_ext >&5
2268 rm -rf conftest*
2269 cf_cv_posix_c_source=no
2270 fi
2271 rm -f conftest*
2272 CFLAGS="$cf_save_CFLAGS"
2273 CPPFLAGS="$cf_save_CPPFLAGS"
2274
2275 fi
2276 rm -f conftest*
2277
2278 fi
2279
2280 echo "$ac_t""$cf_cv_posix_c_source" 1>&6
2281
2282 if test "$cf_cv_posix_c_source" != no ; then
2283 CFLAGS="$cf_trim_CFLAGS"
2284 CPPFLAGS="$cf_trim_CPPFLAGS"
2285 if test "$cf_cv_cc_u_d_options" = yes ; then
2286 cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \
2287 sed -e 's/-D/-U/g' -e 's/=[^ ]*//g'`
2288 CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source"
2289 fi
2290 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
2291 fi
2292
2293
2294 ;;
2295 esac
2296
2297
2298
2299 echo $ac_n "checking if you want to see long compiling messages""... $ac_c" 1>&6
2300 echo "configure:2302: checking if you want to see long compiling messages" >&5
2301
2302 # Check whether --enable-echo or --disable-echo was given.
2303 if test "${enable_echo+set}" = set; then
2304 enableval="$enable_echo"
2305 test "$enableval" != no && enableval=yes
2306 if test "$enableval" != "yes" ; then
2307
2308 ECHO_LT='--silent'
2309 ECHO_LD='@echo linking $@;'
2310 RULE_CC=' @echo compiling $<'
2311 SHOW_CC=' @echo compiling $@'
2312 ECHO_CC='@'
2313
2314 else
2315
2316 ECHO_LT=''
2317 ECHO_LD=''
2318 RULE_CC='# compiling'
2319 SHOW_CC='# compiling'
2320 ECHO_CC=''
2321
2322 fi
2323 else
2324 enableval=yes
2325
2326 ECHO_LT=''
2327 ECHO_LD=''
2328 RULE_CC='# compiling'
2329 SHOW_CC='# compiling'
2330 ECHO_CC=''
2331
2332
2333 fi
2334
2335 echo "$ac_t""$enableval" 1>&6
2336
2337
2338
2339
2340
2341
2342 echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
2343 echo "configure:2345: checking for Cygwin environment" >&5
2344 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then
2345 echo $ac_n "(cached) $ac_c" 1>&6
2346 else
2347 cat > conftest.$ac_ext <<EOF
2348 #line 2350 "configure"
2349 #include "confdefs.h"
2350
2351 int main() {
2352
2353 #ifndef __CYGWIN__
2354 #define __CYGWIN__ __CYGWIN32__
2355 #endif
2356 return __CYGWIN__;
2357 ; return 0; }
2358 EOF
2359 if { (eval echo configure:2361: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2360 rm -rf conftest*
2361 ac_cv_cygwin=yes
2362 else
2363 echo "configure: failed program was:" >&5
2364 cat conftest.$ac_ext >&5
2365 rm -rf conftest*
2366 ac_cv_cygwin=no
2367 fi
2368 rm -f conftest*
2369 rm -f conftest*
2370 fi
2371
2372 echo "$ac_t""$ac_cv_cygwin" 1>&6
2373 CYGWIN=
2374 test "$ac_cv_cygwin" = yes && CYGWIN=yes
2375 echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
2376 echo "configure:2378: checking for mingw32 environment" >&5
2377 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then
2378 echo $ac_n "(cached) $ac_c" 1>&6
2379 else
2380 cat > conftest.$ac_ext <<EOF
2381 #line 2383 "configure"
2382 #include "confdefs.h"
2383
2384 int main() {
2385 return __MINGW32__;
2386 ; return 0; }
2387 EOF
2388 if { (eval echo configure:2390: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2389 rm -rf conftest*
2390 ac_cv_mingw32=yes
2391 else
2392 echo "configure: failed program was:" >&5
2393 cat conftest.$ac_ext >&5
2394 rm -rf conftest*
2395 ac_cv_mingw32=no
2396 fi
2397 rm -f conftest*
2398 rm -f conftest*
2399 fi
2400
2401 echo "$ac_t""$ac_cv_mingw32" 1>&6
2402 MINGW32=
2403 test "$ac_cv_mingw32" = yes && MINGW32=yes
2404
2405
2406 case $cf_cv_system_name in
2407 os2*)
2408 CFLAGS="$CFLAGS -Zmt"
2409 CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
2410 CXXFLAGS="$CXXFLAGS -Zmt"
2411 # autoconf's macro sets -Zexe and suffix both, which conflict:w
2412 LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
2413 ac_cv_exeext=.exe
2414 ;;
2415 esac
2416
2417
2418
2419 echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
2420 echo "configure:2422: checking for executable suffix" >&5
2421 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
2422 echo $ac_n "(cached) $ac_c" 1>&6
2423 else
2424 if test "$CYGWIN" = yes || test "$MINGW32" = yes; then
2425 ac_cv_exeext=.exe
2426 else
2427 rm -f conftest*
2428 echo 'int main () { return 0; }' > conftest.$ac_ext
2429 ac_cv_exeext=
2430 if { (eval echo configure:2432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
2431 for file in conftest.*; do
2432 case $file in
2433 *.c | *.o | *.obj) ;;
2434 *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
2435 esac
2436 done
2437 else
2438 { echo "configure: error: installation or configuration problem: compiler cannot create executables." 1>&2; exit 1; }
2439 fi
2440 rm -f conftest*
2441 test x"${ac_cv_exeext}" = x && ac_cv_exeext=no
2442 fi
2443 fi
2444
2445 EXEEXT=""
2446 test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext}
2447 echo "$ac_t""${ac_cv_exeext}" 1>&6
2448 ac_exeext=$EXEEXT
2449
2450 echo $ac_n "checking for object suffix""... $ac_c" 1>&6
2451 echo "configure:2453: checking for object suffix" >&5
2452 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then
2453 echo $ac_n "(cached) $ac_c" 1>&6
2454 else
2455 rm -f conftest*
2456 echo 'int i = 1;' > conftest.$ac_ext
2457 if { (eval echo configure:2459: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2458 for ac_file in conftest.*; do
2459 case $ac_file in
2460 *.c) ;;
2461 *) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;;
2462 esac
2463 done
2464 else
2465 { echo "configure: error: installation or configuration problem; compiler does not work" 1>&2; exit 1; }
2466 fi
2467 rm -f conftest*
2468 fi
2469
2470 echo "$ac_t""$ac_cv_objext" 1>&6
2471 OBJEXT=$ac_cv_objext
2472 ac_objext=$ac_cv_objext
2473
2474
2475 PROG_EXT="$EXEEXT"
2476
2477 test -n "$PROG_EXT" && cat >> confdefs.h <<EOF
2478 #define PROG_EXT "$PROG_EXT"
2479 EOF
2480
2481
2482
2483 case $cf_cv_system_name in
2484 OS/2*) LIB_PREFIX='' ;;
2485 os2*) LIB_PREFIX='' ;;
2486 *) LIB_PREFIX='lib' ;;
2487 esac
2488
2489
2490
2491
2492
2493 # Check whether --with-man-section or --without-man-section was given.
2494 if test "${with_man_section+set}" = set; then
2495 withval="$with_man_section"
2496 MANSECT=$with_man_section
2497 else
2498 MANSECT=3
2499 fi
2500
2501 case .$MANSECT in
2502 .yes|.no)
2503 MANSECT=3
2504 ;;
2505 esac
2506 MAN_DIR=`echo $MANSECT | sed -e 's/^\(.\).*/\1/'`
2507
2508
2509
2510
2511
2512 # Check whether --with-curses-dir or --without-curses-dir was given.
2513 if test "${with_curses_dir+set}" = set; then
2514 withval="$with_curses_dir"
2515
2516 case ".$withval" in #(vi
2517 .\$\(*\)*|.\'*\'*) #(vi
2518 ;;
2519 ..|./*|.\\*) #(vi
2520 ;;
2521 .[a-zA-Z]:[\\/]*) #(vi OS/2 EMX
2522 ;;
2523 .\${*prefix}*) #(vi
2524 eval withval="$withval"
2525 case ".$withval" in #(vi
2526 .NONE/*)
2527 withval=`echo $withval | sed -e s%NONE%$ac_default_prefix%`
2528 ;;
2529 esac
2530 ;; #(vi
2531 .NONE/*)
2532 withval=`echo $withval | sed -e s%NONE%$ac_default_prefix%`
2533 ;;
2534 *)
2535 { echo "configure: error: expected a pathname, not \"$withval\"" 1>&2; exit 1; }
2536 ;;
2537 esac
2538
2539 cf_cv_curses_dir=$withval
2540 else
2541 cf_cv_curses_dir=no
2542 fi
2543
2544
2545
2546
2547 GCC_VERSION=none
2548 if test "$GCC" = yes ; then
2549 echo $ac_n "checking version of $CC""... $ac_c" 1>&6
2550 echo "configure:2552: checking version of $CC" >&5
2551 GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
2552 test -z "$GCC_VERSION" && GCC_VERSION=unknown
2553 echo "$ac_t""$GCC_VERSION" 1>&6
2554 fi
2555
2556
2557 if ( test "$GCC" = yes || test "$GXX" = yes )
2558 then
2559 echo $ac_n "checking if you want to check for gcc warnings""... $ac_c" 1>&6
2560 echo "configure:2562: checking if you want to check for gcc warnings" >&5
2561
2562 # Check whether --with-warnings or --without-warnings was given.
2563 if test "${with_warnings+set}" = set; then
2564 withval="$with_warnings"
2565 cf_opt_with_warnings=$withval
2566 else
2567 cf_opt_with_warnings=no
2568 fi
2569
2570 echo "$ac_t""$cf_opt_with_warnings" 1>&6
2571 if test "$cf_opt_with_warnings" != no ; then
2572
2573 if test "$GCC" = yes
2574 then
2575 cat > conftest.i <<EOF
2576 #ifndef GCC_PRINTF
2577 #define GCC_PRINTF 0
2578 #endif
2579 #ifndef GCC_SCANF
2580 #define GCC_SCANF 0
2581 #endif
2582 #ifndef GCC_NORETURN
2583 #define GCC_NORETURN /* nothing */
2584 #endif
2585 #ifndef GCC_UNUSED
2586 #define GCC_UNUSED /* nothing */
2587 #endif
2588 EOF
2589 if test "$GCC" = yes
2590 then
2591 echo "checking for $CC __attribute__ directives" 1>&6
2592 echo "configure:2594: checking for $CC __attribute__ directives" >&5
2593 cat > conftest.$ac_ext <<EOF
2594 #line 2596 "configure"
2595 #include "confdefs.h"
2596 #include "conftest.h"
2597 #include "conftest.i"
2598 #if GCC_PRINTF
2599 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
2600 #else
2601 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
2602 #endif
2603 #if GCC_SCANF
2604 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
2605 #else
2606 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
2607 #endif
2608 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
2609 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
2610 extern void foo(void) GCC_NORETURN;
2611 int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; }
2612 EOF
2613 for cf_attribute in scanf printf unused noreturn
2614 do
2615
2616 cf_ATTRIBUTE=`echo "$cf_attribute" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2617
2618 cf_directive="__attribute__(($cf_attribute))"
2619 echo "checking for $CC $cf_directive" 1>&5
2620 case $cf_attribute in
2621 scanf|printf)
2622 cat >conftest.h <<EOF
2623 #define GCC_$cf_ATTRIBUTE 1
2624 EOF
2625 ;;
2626 *)
2627 cat >conftest.h <<EOF
2628 #define GCC_$cf_ATTRIBUTE $cf_directive
2629 EOF
2630 ;;
2631 esac
2632 if { (eval echo configure:2634: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2633 test -n "$verbose" && echo "$ac_t""... $cf_attribute" 1>&6
2634 cat conftest.h >>confdefs.h
2635 fi
2636 done
2637 else
2638 fgrep define conftest.i >>confdefs.h
2639 fi
2640 rm -rf conftest*
2641 fi
2642
2643
2644
2645
2646 INTEL_COMPILER=no
2647
2648 if test "$GCC" = yes ; then
2649 case $host_os in
2650 linux*|gnu*)
2651 echo $ac_n "checking if this is really Intel C compiler""... $ac_c" 1>&6
2652 echo "configure:2654: checking if this is really Intel C compiler" >&5
2653 cf_save_CFLAGS="$CFLAGS"
2654 CFLAGS="$CFLAGS -no-gcc"
2655 cat > conftest.$ac_ext <<EOF
2656 #line 2658 "configure"
2657 #include "confdefs.h"
2658
2659 int main() {
2660
2661 #ifdef __INTEL_COMPILER
2662 #else
2663 make an error
2664 #endif
2665
2666 ; return 0; }
2667 EOF
2668 if { (eval echo configure:2670: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2669 rm -rf conftest*
2670 INTEL_COMPILER=yes
2671 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
2672
2673 else
2674 echo "configure: failed program was:" >&5
2675 cat conftest.$ac_ext >&5
2676 fi
2677 rm -f conftest*
2678 CFLAGS="$cf_save_CFLAGS"
2679 echo "$ac_t""$INTEL_COMPILER" 1>&6
2680 ;;
2681 esac
2682 fi
2683
2684
2685 cat > conftest.$ac_ext <<EOF
2686 #line 2688 "configure"
2687 int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
2688 EOF
2689
2690 if test "$INTEL_COMPILER" = yes
2691 then
2692 # The "-wdXXX" options suppress warnings:
2693 # remark #1419: external declaration in primary source file
2694 # remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
2695 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
2696 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
2697 # remark #193: zero used for undefined preprocessing identifier
2698 # remark #593: variable "curs_sb_left_arrow" was set but never used
2699 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
2700 # remark #869: parameter "tw" was never referenced
2701 # remark #981: operands are evaluated in unspecified order
2702 # warning #269: invalid format string conversion
2703
2704 echo "checking for $CC warning options" 1>&6
2705 echo "configure:2707: checking for $CC warning options" >&5
2706 cf_save_CFLAGS="$CFLAGS"
2707 EXTRA_CFLAGS="-Wall"
2708 for cf_opt in \
2709 wd1419 \
2710 wd1682 \
2711 wd1683 \
2712 wd1684 \
2713 wd193 \
2714 wd279 \
2715 wd593 \
2716 wd810 \
2717 wd869 \
2718 wd981
2719 do
2720 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
2721 if { (eval echo configure:2723: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2722 test -n "$verbose" && echo "$ac_t""... -$cf_opt" 1>&6
2723 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
2724 fi
2725 done
2726 CFLAGS="$cf_save_CFLAGS"
2727
2728 elif test "$GCC" = yes
2729 then
2730 echo "checking for $CC warning options" 1>&6
2731 echo "configure:2733: checking for $CC warning options" >&5
2732 cf_save_CFLAGS="$CFLAGS"
2733 EXTRA_CFLAGS="-W -Wall"
2734 cf_warn_CONST=""
2735 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
2736 for cf_opt in \
2737 Wbad-function-cast \
2738 Wcast-align \
2739 Wcast-qual \
2740 Winline \
2741 Wmissing-declarations \
2742 Wmissing-prototypes \
2743 Wnested-externs \
2744 Wpointer-arith \
2745 Wshadow \
2746 Wstrict-prototypes \
2747 Wundef $cf_warn_CONST
2748 do
2749 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
2750 if { (eval echo configure:2752: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
2751 test -n "$verbose" && echo "$ac_t""... -$cf_opt" 1>&6
2752 case $cf_opt in #(vi
2753 Wcast-qual) #(vi
2754 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
2755 ;;
2756 Winline) #(vi
2757 case $GCC_VERSION in
2758 3.3*)
2759 test -n "$verbose" && echo " feature is broken in gcc $GCC_VERSION" 1>&6
2760
2761 continue;;
2762 esac
2763 ;;
2764 esac
2765 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
2766 fi
2767 done
2768 CFLAGS="$cf_save_CFLAGS"
2769 fi
2770 rm -f conftest*
2771
2772
2773
2774 fi
2775 fi
2776
2777
2778
2779 LIBTOOL=
2780
2781 # common library maintenance symbols that are convenient for libtool scripts:
2782 LIB_CREATE='$(AR) -cr'
2783 LIB_OBJECT='$(OBJECTS)'
2784 LIB_SUFFIX=.a
2785 LIB_PREP="$RANLIB"
2786
2787 # symbols used to prop libtool up to enable it to determine what it should be
2788 # doing:
2789 LIB_CLEAN=
2790 LIB_COMPILE=
2791 LIB_LINK=
2792 LIB_INSTALL=
2793 LIB_UNINSTALL=
2794
2795 echo $ac_n "checking if you want to build libraries with libtool""... $ac_c" 1>&6
2796 echo "configure:2798: checking if you want to build libraries with libtool" >&5
2797
2798 # Check whether --with-libtool or --without-libtool was given.
2799 if test "${with_libtool+set}" = set; then
2800 withval="$with_libtool"
2801 with_libtool=$withval
2802 else
2803 with_libtool=no
2804 fi
2805
2806 echo "$ac_t""$with_libtool" 1>&6
2807 if test "$with_libtool" != "no"; then
2808
2809 if test "$with_libtool" != "yes" ; then
2810
2811 case ".$with_libtool" in #(vi
2812 .\$\(*\)*|.\'*\'*) #(vi
2813 ;;
2814 ..|./*|.\\*) #(vi
2815 ;;
2816 .[a-zA-Z]:[\\/]*) #(vi OS/2 EMX
2817 ;;
2818 .\${*prefix}*) #(vi
2819 eval with_libtool="$with_libtool"
2820 case ".$with_libtool" in #(vi
2821 .NONE/*)
2822 with_libtool=`echo $with_libtool | sed -e s%NONE%$ac_default_prefix%`
2823 ;;
2824 esac
2825 ;; #(vi
2826 .NONE/*)
2827 with_libtool=`echo $with_libtool | sed -e s%NONE%$ac_default_prefix%`
2828 ;;
2829 *)
2830 { echo "configure: error: expected a pathname, not \"$with_libtool\"" 1>&2; exit 1; }
2831 ;;
2832 esac
2833
2834 LIBTOOL=$with_libtool
2835 else
2836 # Extract the first word of "libtool", so it can be a program name with args.
2837 set dummy libtool; ac_word=$2
2838 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
2839 echo "configure:2841: checking for $ac_word" >&5
2840 if eval "test \"`echo '$''{'ac_cv_path_LIBTOOL'+set}'`\" = set"; then
2841 echo $ac_n "(cached) $ac_c" 1>&6
2842 else
2843 case "$LIBTOOL" in
2844 /*)
2845 ac_cv_path_LIBTOOL="$LIBTOOL" # Let the user override the test with a path.
2846 ;;
2847 ?:/*)
2848 ac_cv_path_LIBTOOL="$LIBTOOL" # Let the user override the test with a dos path.
2849 ;;
2850 *)
2851 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
2852 ac_dummy="$PATH"
2853 for ac_dir in $ac_dummy; do
2854 test -z "$ac_dir" && ac_dir=.
2855 if test -f $ac_dir/$ac_word; then
2856 ac_cv_path_LIBTOOL="$ac_dir/$ac_word"
2857 break
2858 fi
2859 done
2860 IFS="$ac_save_ifs"
2861 ;;
2862 esac
2863 fi
2864 LIBTOOL="$ac_cv_path_LIBTOOL"
2865 if test -n "$LIBTOOL"; then
2866 echo "$ac_t""$LIBTOOL" 1>&6
2867 else
2868 echo "$ac_t""no" 1>&6
2869 fi
2870
2871 fi
2872 if test -z "$LIBTOOL" ; then
2873 { echo "configure: error: Cannot find libtool" 1>&2; exit 1; }
2874 fi
2875 LIB_CREATE='$(LIBTOOL) --mode=link $(CC) -rpath $(DESTDIR)$(libdir) -version-info `cut -f1 $(srcdir)/VERSION` -o'
2876 LIB_OBJECT='$(OBJECTS:.o=.lo)'
2877 LIB_SUFFIX=.la
2878 LIB_CLEAN='$(LIBTOOL) --mode=clean'
2879 LIB_COMPILE='$(LIBTOOL) --mode=compile'
2880 LIB_LINK='$(LIBTOOL) --mode=link'
2881 LIB_INSTALL='$(LIBTOOL) --mode=install'
2882 LIB_UNINSTALL='$(LIBTOOL) --mode=uninstall'
2883 LIB_PREP=:
2884
2885 # Show the version of libtool
2886 echo $ac_n "checking version of libtool""... $ac_c" 1>&6
2887 echo "configure:2889: checking version of libtool" >&5
2888
2889 # Save the version in a cache variable - this is not entirely a good
2890 # thing, but the version string from libtool is very ugly, and for
2891 # bug reports it might be useful to have the original string.
2892 cf_cv_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '2,$d' -e 's/([^)]*)//g' -e 's/^[^1-9]*//' -e 's/[^0-9.].*//'`
2893 echo "$ac_t""$cf_cv_libtool_version" 1>&6
2894 if test -z "$cf_cv_libtool_version" ; then
2895 { echo "configure: error: This is not libtool" 1>&2; exit 1; }
2896 fi
2897
2898 # special hack to add --tag option for C++ compiler
2899 case $cf_cv_libtool_version in
2900 1.[5-9]*|[2-9]*)
2901 LIBTOOL_CXX="$LIBTOOL --tag=CXX"
2902 ;;
2903 *)
2904 LIBTOOL_CXX="$LIBTOOL"
2905 ;;
2906 esac
2907 else
2908 LIBTOOL=""
2909 LIBTOOL_CXX=""
2910 fi
2911
2912 test -z "$LIBTOOL" && ECHO_LT=
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929 if test "$with_libtool" = "yes" ; then
2930 OBJEXT="lo"
2931 fi
2932
2933
2934
2935 echo $ac_n "checking if you want to link with dbmalloc for testing""... $ac_c" 1>&6
2936 echo "configure:2938: checking if you want to link with dbmalloc for testing" >&5
2937
2938 # Check whether --with-dbmalloc or --without-dbmalloc was given.
2939 if test "${with_dbmalloc+set}" = set; then
2940 withval="$with_dbmalloc"
2941 with_dbmalloc=$withval
2942 else
2943 with_dbmalloc=no
2944 fi
2945
2946 echo "$ac_t""$with_dbmalloc" 1>&6
2947 if test "$with_dbmalloc" = yes ; then
2948 ac_safe=`echo "dbmalloc.h" | sed 'y%./+-%__p_%'`
2949 echo $ac_n "checking for dbmalloc.h""... $ac_c" 1>&6
2950 echo "configure:2952: checking for dbmalloc.h" >&5
2951 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
2952 echo $ac_n "(cached) $ac_c" 1>&6
2953 else
2954 cat > conftest.$ac_ext <<EOF
2955 #line 2957 "configure"
2956 #include "confdefs.h"
2957 #include <dbmalloc.h>
2958 EOF
2959 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
2960 { (eval echo configure:2962: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
2961 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
2962 if test -z "$ac_err"; then
2963 rm -rf conftest*
2964 eval "ac_cv_header_$ac_safe=yes"
2965 else
2966 echo "$ac_err" >&5
2967 echo "configure: failed program was:" >&5
2968 cat conftest.$ac_ext >&5
2969 rm -rf conftest*
2970 eval "ac_cv_header_$ac_safe=no"
2971 fi
2972 rm -f conftest*
2973 fi
2974 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
2975 echo "$ac_t""yes" 1>&6
2976 echo $ac_n "checking for debug_malloc in -ldbmalloc""... $ac_c" 1>&6
2977 echo "configure:2979: checking for debug_malloc in -ldbmalloc" >&5
2978 ac_lib_var=`echo dbmalloc'_'debug_malloc | sed 'y%./+-%__p_%'`
2979 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
2980 echo $ac_n "(cached) $ac_c" 1>&6
2981 else
2982 ac_save_LIBS="$LIBS"
2983 LIBS="-ldbmalloc $LIBS"
2984 cat > conftest.$ac_ext <<EOF
2985 #line 2987 "configure"
2986 #include "confdefs.h"
2987 /* Override any gcc2 internal prototype to avoid an error. */
2988 /* We use char because int might match the return type of a gcc2
2989 builtin and then its argument prototype would still apply. */
2990 char debug_malloc();
2991
2992 int main() {
2993 debug_malloc()
2994 ; return 0; }
2995 EOF
2996 if { (eval echo configure:2998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
2997 rm -rf conftest*
2998 eval "ac_cv_lib_$ac_lib_var=yes"
2999 else
3000 echo "configure: failed program was:" >&5
3001 cat conftest.$ac_ext >&5
3002 rm -rf conftest*
3003 eval "ac_cv_lib_$ac_lib_var=no"
3004 fi
3005 rm -f conftest*
3006 LIBS="$ac_save_LIBS"
3007
3008 fi
3009 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
3010 echo "$ac_t""yes" 1>&6
3011 ac_tr_lib=HAVE_LIB`echo dbmalloc | sed -e 's/[^a-zA-Z0-9_]/_/g' \
3012 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
3013 cat >> confdefs.h <<EOF
3014 #define $ac_tr_lib 1
3015 EOF
3016
3017 LIBS="-ldbmalloc $LIBS"
3018
3019 else
3020 echo "$ac_t""no" 1>&6
3021 fi
3022
3023 else
3024 echo "$ac_t""no" 1>&6
3025 fi
3026
3027 fi
3028
3029
3030 echo $ac_n "checking if you want to link with dmalloc for testing""... $ac_c" 1>&6
3031 echo "configure:3033: checking if you want to link with dmalloc for testing" >&5
3032
3033 # Check whether --with-dmalloc or --without-dmalloc was given.
3034 if test "${with_dmalloc+set}" = set; then
3035 withval="$with_dmalloc"
3036 with_dmalloc=$withval
3037 else
3038 with_dmalloc=no
3039 fi
3040
3041 echo "$ac_t""$with_dmalloc" 1>&6
3042 if test "$with_dmalloc" = yes ; then
3043 ac_safe=`echo "dmalloc.h" | sed 'y%./+-%__p_%'`
3044 echo $ac_n "checking for dmalloc.h""... $ac_c" 1>&6
3045 echo "configure:3047: checking for dmalloc.h" >&5
3046 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
3047 echo $ac_n "(cached) $ac_c" 1>&6
3048 else
3049 cat > conftest.$ac_ext <<EOF
3050 #line 3052 "configure"
3051 #include "confdefs.h"
3052 #include <dmalloc.h>
3053 EOF
3054 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
3055 { (eval echo configure:3057: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
3056 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
3057 if test -z "$ac_err"; then
3058 rm -rf conftest*
3059 eval "ac_cv_header_$ac_safe=yes"
3060 else
3061 echo "$ac_err" >&5
3062 echo "configure: failed program was:" >&5
3063 cat conftest.$ac_ext >&5
3064 rm -rf conftest*
3065 eval "ac_cv_header_$ac_safe=no"
3066 fi
3067 rm -f conftest*
3068 fi
3069 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
3070 echo "$ac_t""yes" 1>&6
3071 echo $ac_n "checking for dmalloc_debug in -ldmalloc""... $ac_c" 1>&6
3072 echo "configure:3074: checking for dmalloc_debug in -ldmalloc" >&5
3073 ac_lib_var=`echo dmalloc'_'dmalloc_debug | sed 'y%./+-%__p_%'`
3074 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
3075 echo $ac_n "(cached) $ac_c" 1>&6
3076 else
3077 ac_save_LIBS="$LIBS"
3078 LIBS="-ldmalloc $LIBS"
3079 cat > conftest.$ac_ext <<EOF
3080 #line 3082 "configure"
3081 #include "confdefs.h"
3082 /* Override any gcc2 internal prototype to avoid an error. */
3083 /* We use char because int might match the return type of a gcc2
3084 builtin and then its argument prototype would still apply. */
3085 char dmalloc_debug();
3086
3087 int main() {
3088 dmalloc_debug()
3089 ; return 0; }
3090 EOF
3091 if { (eval echo configure:3093: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
3092 rm -rf conftest*
3093 eval "ac_cv_lib_$ac_lib_var=yes"
3094 else
3095 echo "configure: failed program was:" >&5
3096 cat conftest.$ac_ext >&5
3097 rm -rf conftest*
3098 eval "ac_cv_lib_$ac_lib_var=no"
3099 fi
3100 rm -f conftest*
3101 LIBS="$ac_save_LIBS"
3102
3103 fi
3104 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
3105 echo "$ac_t""yes" 1>&6
3106 ac_tr_lib=HAVE_LIB`echo dmalloc | sed -e 's/[^a-zA-Z0-9_]/_/g' \
3107 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
3108 cat >> confdefs.h <<EOF
3109 #define $ac_tr_lib 1
3110 EOF
3111
3112 LIBS="-ldmalloc $LIBS"
3113
3114 else
3115 echo "$ac_t""no" 1>&6
3116 fi
3117
3118 else
3119 echo "$ac_t""no" 1>&6
3120 fi
3121
3122 fi
3123
3124
3125 ac_header_dirent=no
3126 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
3127 do
3128 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
3129 echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
3130 echo "configure:3132: checking for $ac_hdr that defines DIR" >&5
3131 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
3132 echo $ac_n "(cached) $ac_c" 1>&6
3133 else
3134 cat > conftest.$ac_ext <<EOF
3135 #line 3137 "configure"
3136 #include "confdefs.h"
3137 #include <sys/types.h>
3138 #include <$ac_hdr>
3139 int main() {
3140 DIR *dirp = 0;
3141 ; return 0; }
3142 EOF
3143 if { (eval echo configure:3145: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
3144 rm -rf conftest*
3145 eval "ac_cv_header_dirent_$ac_safe=yes"
3146 else
3147 echo "configure: failed program was:" >&5
3148 cat conftest.$ac_ext >&5
3149 rm -rf conftest*
3150 eval "ac_cv_header_dirent_$ac_safe=no"
3151 fi
3152 rm -f conftest*
3153 fi
3154 if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then
3155 echo "$ac_t""yes" 1>&6
3156 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
3157 cat >> confdefs.h <<EOF
3158 #define $ac_tr_hdr 1
3159 EOF
3160 ac_header_dirent=$ac_hdr; break
3161 else
3162 echo "$ac_t""no" 1>&6
3163 fi
3164 done
3165 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
3166 if test $ac_header_dirent = dirent.h; then
3167 echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
3168 echo "configure:3170: checking for opendir in -ldir" >&5
3169 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
3170 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
3171 echo $ac_n "(cached) $ac_c" 1>&6
3172 else
3173 ac_save_LIBS="$LIBS"
3174 LIBS="-ldir $LIBS"
3175 cat > conftest.$ac_ext <<EOF
3176 #line 3178 "configure"
3177 #include "confdefs.h"
3178 /* Override any gcc2 internal prototype to avoid an error. */
3179 /* We use char because int might match the return type of a gcc2
3180 builtin and then its argument prototype would still apply. */
3181 char opendir();
3182
3183 int main() {
3184 opendir()
3185 ; return 0; }
3186 EOF
3187 if { (eval echo configure:3189: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
3188 rm -rf conftest*
3189 eval "ac_cv_lib_$ac_lib_var=yes"
3190 else
3191 echo "configure: failed program was:" >&5
3192 cat conftest.$ac_ext >&5
3193 rm -rf conftest*
3194 eval "ac_cv_lib_$ac_lib_var=no"
3195 fi
3196 rm -f conftest*
3197 LIBS="$ac_save_LIBS"
3198
3199 fi
3200 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
3201 echo "$ac_t""yes" 1>&6
3202 LIBS="$LIBS -ldir"
3203 else
3204 echo "$ac_t""no" 1>&6
3205 fi
3206
3207 else
3208 echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
3209 echo "configure:3211: checking for opendir in -lx" >&5
3210 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
3211 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
3212 echo $ac_n "(cached) $ac_c" 1>&6
3213 else
3214 ac_save_LIBS="$LIBS"
3215 LIBS="-lx $LIBS"
3216 cat > conftest.$ac_ext <<EOF
3217 #line 3219 "configure"
3218 #include "confdefs.h"
3219 /* Override any gcc2 internal prototype to avoid an error. */
3220 /* We use char because int might match the return type of a gcc2
3221 builtin and then its argument prototype would still apply. */
3222 char opendir();
3223
3224 int main() {
3225 opendir()
3226 ; return 0; }
3227 EOF
3228 if { (eval echo configure:3230: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
3229 rm -rf conftest*
3230 eval "ac_cv_lib_$ac_lib_var=yes"
3231 else
3232 echo "configure: failed program was:" >&5
3233 cat conftest.$ac_ext >&5
3234 rm -rf conftest*
3235 eval "ac_cv_lib_$ac_lib_var=no"
3236 fi
3237 rm -f conftest*
3238 LIBS="$ac_save_LIBS"
3239
3240 fi
3241 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
3242 echo "$ac_t""yes" 1>&6
3243 LIBS="$LIBS -lx"
3244 else
3245 echo "$ac_t""no" 1>&6
3246 fi
3247
3248 fi
3249
3250 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
3251 echo "configure:3253: checking for ANSI C header files" >&5
3252 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
3253 echo $ac_n "(cached) $ac_c" 1>&6
3254 else
3255 cat > conftest.$ac_ext <<EOF
3256 #line 3258 "configure"
3257 #include "confdefs.h"
3258 #include <stdlib.h>
3259 #include <stdarg.h>
3260 #include <string.h>
3261 #include <float.h>
3262 EOF
3263 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
3264 { (eval echo configure:3266: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
3265 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
3266 if test -z "$ac_err"; then
3267 rm -rf conftest*
3268 ac_cv_header_stdc=yes
3269 else
3270 echo "$ac_err" >&5
3271 echo "configure: failed program was:" >&5
3272 cat conftest.$ac_ext >&5
3273 rm -rf conftest*
3274 ac_cv_header_stdc=no
3275 fi
3276 rm -f conftest*
3277
3278 if test $ac_cv_header_stdc = yes; then
3279 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
3280 cat > conftest.$ac_ext <<EOF
3281 #line 3283 "configure"
3282 #include "confdefs.h"
3283 #include <string.h>
3284 EOF
3285 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
3286 egrep "memchr" >/dev/null 2>&1; then
3287 :
3288 else
3289 rm -rf conftest*
3290 ac_cv_header_stdc=no
3291 fi
3292 rm -f conftest*
3293
3294 fi
3295
3296 if test $ac_cv_header_stdc = yes; then
3297 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
3298 cat > conftest.$ac_ext <<EOF
3299 #line 3301 "configure"
3300 #include "confdefs.h"
3301 #include <stdlib.h>
3302 EOF
3303 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
3304 egrep "free" >/dev/null 2>&1; then
3305 :
3306 else
3307 rm -rf conftest*
3308 ac_cv_header_stdc=no
3309 fi
3310 rm -f conftest*
3311
3312 fi
3313
3314 if test $ac_cv_header_stdc = yes; then
3315 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
3316 if test "$cross_compiling" = yes; then
3317 :
3318 else
3319 cat > conftest.$ac_ext <<EOF
3320 #line 3322 "configure"
3321 #include "confdefs.h"
3322 #include <ctype.h>
3323 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
3324 #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
3325 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
3326 int main () { int i; for (i = 0; i < 256; i++)
3327 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
3328 exit (0); }
3329
3330 EOF
3331 if { (eval echo configure:3333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
3332 then
3333 :
3334 else
3335 echo "configure: failed program was:" >&5
3336 cat conftest.$ac_ext >&5
3337 rm -fr conftest*
3338 ac_cv_header_stdc=no
3339 fi
3340 rm -fr conftest*
3341 fi
3342
3343 fi
3344 fi
3345
3346 echo "$ac_t""$ac_cv_header_stdc" 1>&6
3347 if test $ac_cv_header_stdc = yes; then
3348 cat >> confdefs.h <<\EOF
3349 #define STDC_HEADERS 1
3350 EOF
3351
3352 fi
3353
3354 for ac_hdr in \
3355 limits.h \
3356 unistd.h \
3357
3358 do
3359 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
3360 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
3361 echo "configure:3363: checking for $ac_hdr" >&5
3362 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
3363 echo $ac_n "(cached) $ac_c" 1>&6
3364 else
3365 cat > conftest.$ac_ext <<EOF
3366 #line 3368 "configure"
3367 #include "confdefs.h"
3368 #include <$ac_hdr>
3369 EOF
3370 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
3371 { (eval echo configure:3373: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
3372 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
3373 if test -z "$ac_err"; then
3374 rm -rf conftest*
3375 eval "ac_cv_header_$ac_safe=yes"
3376 else
3377 echo "$ac_err" >&5
3378 echo "configure: failed program was:" >&5
3379 cat conftest.$ac_ext >&5
3380 rm -rf conftest*
3381 eval "ac_cv_header_$ac_safe=no"
3382 fi
3383 rm -f conftest*
3384 fi
3385 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
3386 echo "$ac_t""yes" 1>&6
3387 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
3388 cat >> confdefs.h <<EOF
3389 #define $ac_tr_hdr 1
3390 EOF
3391
3392 else
3393 echo "$ac_t""no" 1>&6
3394 fi
3395 done
3396
3397
3398 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
3399 echo "configure:3401: checking for mode_t" >&5
3400 if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then
3401 echo $ac_n "(cached) $ac_c" 1>&6
3402 else
3403 cat > conftest.$ac_ext <<EOF
3404 #line 3406 "configure"
3405 #include "confdefs.h"
3406 #include <sys/types.h>
3407 #if STDC_HEADERS
3408 #include <stdlib.h>
3409 #include <stddef.h>
3410 #endif
3411 EOF
3412 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
3413 egrep "(^|[^a-zA-Z_0-9])mode_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
3414 rm -rf conftest*
3415 ac_cv_type_mode_t=yes
3416 else
3417 rm -rf conftest*
3418 ac_cv_type_mode_t=no
3419 fi
3420 rm -f conftest*
3421
3422 fi
3423 echo "$ac_t""$ac_cv_type_mode_t" 1>&6
3424 if test $ac_cv_type_mode_t = no; then
3425 cat >> confdefs.h <<\EOF
3426 #define mode_t int
3427 EOF
3428
3429 fi
3430
3431 echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
3432 echo "configure:3434: checking whether struct tm is in sys/time.h or time.h" >&5
3433 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
3434 echo $ac_n "(cached) $ac_c" 1>&6
3435 else
3436 cat > conftest.$ac_ext <<EOF
3437 #line 3439 "configure"
3438 #include "confdefs.h"
3439 #include <sys/types.h>
3440 #include <time.h>
3441 int main() {
3442 struct tm *tp; tp->tm_sec;
3443 ; return 0; }
3444 EOF
3445 if { (eval echo configure:3447: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
3446 rm -rf conftest*
3447 ac_cv_struct_tm=time.h
3448 else
3449 echo "configure: failed program was:" >&5
3450 cat conftest.$ac_ext >&5
3451 rm -rf conftest*
3452 ac_cv_struct_tm=sys/time.h
3453 fi
3454 rm -f conftest*
3455 fi
3456
3457 echo "$ac_t""$ac_cv_struct_tm" 1>&6
3458 if test $ac_cv_struct_tm = sys/time.h; then
3459 cat >> confdefs.h <<\EOF
3460 #define TM_IN_SYS_TIME 1
3461 EOF
3462
3463 fi
3464
3465
3466
3467 echo $ac_n "checking for extra include directories""... $ac_c" 1>&6
3468 echo "configure:3470: checking for extra include directories" >&5
3469 if eval "test \"`echo '$''{'cf_cv_curses_incdir'+set}'`\" = set"; then
3470 echo $ac_n "(cached) $ac_c" 1>&6
3471 else
3472
3473 cf_cv_curses_incdir=no
3474 case $host_os in #(vi
3475 hpux10.*|hpux11.*) #(vi
3476 test -d /usr/include/curses_colr && \
3477 cf_cv_curses_incdir="-I/usr/include/curses_colr"
3478 ;;
3479 sunos3*|sunos4*)
3480 test -d /usr/5lib && \
3481 test -d /usr/5include && \
3482 cf_cv_curses_incdir="-I/usr/5include"
3483 ;;
3484 esac
3485
3486 fi
3487
3488 echo "$ac_t""$cf_cv_curses_incdir" 1>&6
3489 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$cf_cv_curses_incdir $CPPFLAGS"
3490
3491 echo $ac_n "checking if we have identified curses headers""... $ac_c" 1>&6
3492 echo "configure:3494: checking if we have identified curses headers" >&5
3493 if eval "test \"`echo '$''{'cf_cv_ncurses_header'+set}'`\" = set"; then
3494 echo $ac_n "(cached) $ac_c" 1>&6
3495 else
3496
3497 cf_cv_ncurses_header=none
3498 for cf_header in \
3499 curses.h \
3500 ncurses.h \
3501 ncurses/curses.h \
3502 ncurses/ncurses.h
3503 do
3504 cat > conftest.$ac_ext <<EOF
3505 #line 3507 "configure"
3506 #include "confdefs.h"
3507 #include <${cf_header}>
3508 int main() {
3509 initscr(); tgoto("?", 0,0)
3510 ; return 0; }
3511 EOF
3512 if { (eval echo configure:3514: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
3513 rm -rf conftest*
3514 cf_cv_ncurses_header=$cf_header; break
3515 else
3516 echo "configure: failed program was:" >&5
3517 cat conftest.$ac_ext >&5
3518 fi
3519 rm -f conftest*
3520 done
3521
3522 fi
3523
3524 echo "$ac_t""$cf_cv_ncurses_header" 1>&6
3525
3526 if test "$cf_cv_ncurses_header" = none ; then
3527 { echo "configure: error: No curses header-files found" 1>&2; exit 1; }
3528 fi
3529
3530 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
3531 for ac_hdr in $cf_cv_ncurses_header
3532 do
3533 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
3534 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
3535 echo "configure:3537: checking for $ac_hdr" >&5
3536 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
3537 echo $ac_n "(cached) $ac_c" 1>&6
3538 else
3539 cat > conftest.$ac_ext <<EOF
3540 #line 3542 "configure"
3541 #include "confdefs.h"
3542 #include <$ac_hdr>
3543 EOF
3544 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
3545 { (eval echo configure:3547: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
3546 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
3547 if test -z "$ac_err"; then
3548 rm -rf conftest*
3549 eval "ac_cv_header_$ac_safe=yes"
3550 else
3551 echo "$ac_err" >&5
3552 echo "configure: failed program was:" >&5
3553 cat conftest.$ac_ext >&5
3554 rm -rf conftest*
3555 eval "ac_cv_header_$ac_safe=no"
3556 fi
3557 rm -f conftest*
3558 fi
3559 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
3560 echo "$ac_t""yes" 1>&6
3561 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
3562 cat >> confdefs.h <<EOF
3563 #define $ac_tr_hdr 1
3564 EOF
3565
3566 else
3567 echo "$ac_t""no" 1>&6
3568 fi
3569 done
3570
3571
3572
3573
3574 echo $ac_n "checking for chtype typedef""... $ac_c" 1>&6
3575 echo "configure:3577: checking for chtype typedef" >&5
3576 if eval "test \"`echo '$''{'cf_cv_chtype_decl'+set}'`\" = set"; then
3577 echo $ac_n "(cached) $ac_c" 1>&6
3578 else
3579
3580 cat > conftest.$ac_ext <<EOF
3581 #line 3583 "configure"
3582 #include "confdefs.h"
3583 #include <${cf_cv_ncurses_header-curses.h}>
3584 int main() {
3585 chtype foo
3586 ; return 0; }
3587 EOF
3588 if { (eval echo configure:3590: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
3589 rm -rf conftest*
3590 cf_cv_chtype_decl=yes
3591 else
3592 echo "configure: failed program was:" >&5
3593 cat conftest.$ac_ext >&5
3594 rm -rf conftest*
3595 cf_cv_chtype_decl=no
3596 fi
3597 rm -f conftest*
3598 fi
3599
3600 echo "$ac_t""$cf_cv_chtype_decl" 1>&6
3601 if test $cf_cv_chtype_decl = yes ; then
3602 cat >> confdefs.h <<\EOF
3603 #define HAVE_TYPE_CHTYPE 1
3604 EOF
3605
3606 echo $ac_n "checking if chtype is scalar or struct""... $ac_c" 1>&6
3607 echo "configure:3609: checking if chtype is scalar or struct" >&5
3608 if eval "test \"`echo '$''{'cf_cv_chtype_type'+set}'`\" = set"; then
3609 echo $ac_n "(cached) $ac_c" 1>&6
3610 else
3611
3612 cat > conftest.$ac_ext <<EOF
3613 #line 3615 "configure"
3614 #include "confdefs.h"
3615 #include <${cf_cv_ncurses_header-curses.h}>
3616 int main() {
3617 chtype foo; long x = foo
3618 ; return 0; }
3619 EOF
3620 if { (eval echo configure:3622: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
3621 rm -rf conftest*
3622 cf_cv_chtype_type=scalar
3623 else
3624 echo "configure: failed program was:" >&5
3625 cat conftest.$ac_ext >&5
3626 rm -rf conftest*
3627 cf_cv_chtype_type=struct
3628 fi
3629 rm -f conftest*
3630 fi
3631
3632 echo "$ac_t""$cf_cv_chtype_type" 1>&6
3633 if test $cf_cv_chtype_type = scalar ; then
3634 cat >> confdefs.h <<\EOF
3635 #define TYPE_CHTYPE_IS_SCALAR 1
3636 EOF
3637
3638 fi
3639 fi
3640
3641
3642 echo $ac_n "checking for header declaring getopt variables""... $ac_c" 1>&6
3643 echo "configure:3645: checking for header declaring getopt variables" >&5
3644 if eval "test \"`echo '$''{'cf_cv_getopt_header'+set}'`\" = set"; then
3645 echo $ac_n "(cached) $ac_c" 1>&6
3646 else
3647
3648 cf_cv_getopt_header=none
3649 for cf_header in stdio.h stdlib.h getopt.h
3650 do
3651 cat > conftest.$ac_ext <<EOF
3652 #line 3654 "configure"
3653 #include "confdefs.h"
3654
3655 #include <$cf_header>
3656 int main() {
3657 int x = optind; char *y = optarg
3658 ; return 0; }
3659 EOF
3660 if { (eval echo configure:3662: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
3661 rm -rf conftest*
3662 cf_cv_getopt_header=$cf_header
3663 break
3664 else
3665 echo "configure: failed program was:" >&5
3666 cat conftest.$ac_ext >&5
3667 fi
3668 rm -f conftest*
3669 done
3670
3671 fi
3672
3673 echo "$ac_t""$cf_cv_getopt_header" 1>&6
3674 case $cf_cv_getopt_header in #(vi
3675 getopt.h) #(vi
3676 cat >> confdefs.h <<\EOF
3677 #define HAVE_GETOPT_H 1
3678 EOF
3679
3680 cat >> confdefs.h <<\EOF
3681 #define HAVE_GETOPT_HEADER 1
3682 EOF
3683
3684 ;;
3685 stdlib.h) #(vi
3686 cat >> confdefs.h <<\EOF
3687 #define HAVE_STDLIB_H 1
3688 EOF
3689
3690 cat >> confdefs.h <<\EOF
3691 #define HAVE_GETOPT_HEADER 1
3692 EOF
3693
3694 ;;
3695 esac
3696
3697
3698 for ac_func in \
3699 getcwd \
3700 mktime \
3701 strdup \
3702 strerror \
3703
3704 do
3705 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
3706 echo "configure:3708: checking for $ac_func" >&5
3707 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
3708 echo $ac_n "(cached) $ac_c" 1>&6
3709 else
3710 cat > conftest.$ac_ext <<EOF
3711 #line 3713 "configure"
3712 #include "confdefs.h"
3713 /* System header to define __stub macros and hopefully few prototypes,
3714 which can conflict with char $ac_func(); below. */
3715 #include <assert.h>
3716 /* Override any gcc2 internal prototype to avoid an error. */
3717 /* We use char because int might match the return type of a gcc2
3718 builtin and then its argument prototype would still apply. */
3719 char $ac_func();
3720
3721 int main() {
3722
3723 /* The GNU C library defines this for functions which it implements
3724 to always fail with ENOSYS. Some functions are actually named
3725 something starting with __ and the normal name is an alias. */
3726 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
3727 choke me
3728 #else
3729 $ac_func();
3730 #endif
3731
3732 ; return 0; }
3733 EOF
3734 if { (eval echo configure:3736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
3735 rm -rf conftest*
3736 eval "ac_cv_func_$ac_func=yes"
3737 else
3738 echo "configure: failed program was:" >&5
3739 cat conftest.$ac_ext >&5
3740 rm -rf conftest*
3741 eval "ac_cv_func_$ac_func=no"
3742 fi
3743 rm -f conftest*
3744 fi
3745
3746 if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
3747 echo "$ac_t""yes" 1>&6
3748 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
3749 cat >> confdefs.h <<EOF
3750 #define $ac_tr_func 1
3751 EOF
3752
3753 else
3754 echo "$ac_t""no" 1>&6
3755 fi
3756 done
3757
3758
3759
3760 echo $ac_n "checking for lstat""... $ac_c" 1>&6
3761 echo "configure:3763: checking for lstat" >&5
3762 if eval "test \"`echo '$''{'ac_cv_func_lstat'+set}'`\" = set"; then
3763 echo $ac_n "(cached) $ac_c" 1>&6
3764 else
3765
3766 cat > conftest.$ac_ext <<EOF
3767 #line 3769 "configure"
3768 #include "confdefs.h"
3769
3770 #include <sys/types.h>
3771 #include <sys/stat.h>
3772 int main() {
3773 lstat(".", (struct stat *)0)
3774 ; return 0; }
3775 EOF
3776 if { (eval echo configure:3778: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
3777 rm -rf conftest*
3778 ac_cv_func_lstat=yes
3779 else
3780 echo "configure: failed program was:" >&5
3781 cat conftest.$ac_ext >&5
3782 rm -rf conftest*
3783 ac_cv_func_lstat=no
3784 fi
3785 rm -f conftest*
3786
3787 fi
3788
3789 echo "$ac_t""$ac_cv_func_lstat " 1>&6
3790 if test $ac_cv_func_lstat = yes; then
3791 cat >> confdefs.h <<\EOF
3792 #define HAVE_LSTAT 1
3793 EOF
3794
3795 fi
3796
3797
3798 echo $ac_n "checking for setlocale()""... $ac_c" 1>&6
3799 echo "configure:3801: checking for setlocale()" >&5
3800 if eval "test \"`echo '$''{'cf_cv_locale'+set}'`\" = set"; then
3801 echo $ac_n "(cached) $ac_c" 1>&6
3802 else
3803
3804 cat > conftest.$ac_ext <<EOF
3805 #line 3807 "configure"
3806 #include "confdefs.h"
3807 #include <locale.h>
3808 int main() {
3809 setlocale(LC_ALL, "")
3810 ; return 0; }
3811 EOF
3812 if { (eval echo configure:3814: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
3813 rm -rf conftest*
3814 cf_cv_locale=yes
3815 else
3816 echo "configure: failed program was:" >&5
3817 cat conftest.$ac_ext >&5
3818 rm -rf conftest*
3819 cf_cv_locale=no
3820 fi
3821 rm -f conftest*
3822
3823 fi
3824
3825 echo "$ac_t""$cf_cv_locale" 1>&6
3826 test $cf_cv_locale = yes && { cat >> confdefs.h <<\EOF
3827 #define HAVE_SETLOCALE 1
3828 EOF
3829 }
3830
3831
3832 use_library=curses
3833
3834 # Check whether --with-ncurses or --without-ncurses was given.
3835 if test "${with_ncurses+set}" = set; then
3836 withval="$with_ncurses"
3837 use_library=ncurses
3838 else
3839
3840
3841 # Check whether --with-ncursesw or --without-ncursesw was given.
3842 if test "${with_ncursesw+set}" = set; then
3843 withval="$with_ncursesw"
3844 use_library=ncursesw
3845 else
3846
3847
3848 # Check whether --with-pdcurses or --without-pdcurses was given.
3849 if test "${with_pdcurses+set}" = set; then
3850 withval="$with_pdcurses"
3851 use_library=pdcurses
3852 fi
3853
3854 fi
3855
3856 fi
3857
3858
3859 LIB_ROOTNAME=cdk
3860 case $use_library in #(vi
3861 ncurses) #(vi
3862
3863
3864 cf_ncuhdr_root=ncurses
3865
3866 test -n "$cf_cv_curses_dir" && \
3867 test "$cf_cv_curses_dir" != "no" && \
3868 CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS"
3869
3870 echo $ac_n "checking for $cf_ncuhdr_root header in include-path""... $ac_c" 1>&6
3871 echo "configure:3873: checking for $cf_ncuhdr_root header in include-path" >&5
3872 if eval "test \"`echo '$''{'cf_cv_ncurses_h'+set}'`\" = set"; then
3873 echo $ac_n "(cached) $ac_c" 1>&6
3874 else
3875
3876 cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
3877 ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
3878 for cf_header in $cf_header_list
3879 do
3880
3881 cat > conftest.$ac_ext <<EOF
3882 #line 3884 "configure"
3883 #include "confdefs.h"
3884
3885
3886 #include <$cf_header>
3887 int main() {
3888
3889 #ifdef NCURSES_VERSION
3890
3891 printf("%s\n", NCURSES_VERSION);
3892 #else
3893 #ifdef __NCURSES_H
3894 printf("old\n");
3895 #else
3896 make an error
3897 #endif
3898 #endif
3899
3900
3901 ; return 0; }
3902 EOF
3903 if { (eval echo configure:3905: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
3904 rm -rf conftest*
3905 cf_cv_ncurses_h=$cf_header
3906
3907 else
3908 echo "configure: failed program was:" >&5
3909 cat conftest.$ac_ext >&5
3910 rm -rf conftest*
3911 cf_cv_ncurses_h=no
3912 fi
3913 rm -f conftest*
3914
3915 test "$cf_cv_ncurses_h" != no && break
3916 done
3917
3918 fi
3919
3920 echo "$ac_t""$cf_cv_ncurses_h" 1>&6
3921
3922 if test "$cf_cv_ncurses_h" != no ; then
3923 cf_cv_ncurses_header=$cf_cv_ncurses_h
3924 else
3925 echo $ac_n "checking for $cf_ncuhdr_root include-path""... $ac_c" 1>&6
3926 echo "configure:3928: checking for $cf_ncuhdr_root include-path" >&5
3927 if eval "test \"`echo '$''{'cf_cv_ncurses_h2'+set}'`\" = set"; then
3928 echo $ac_n "(cached) $ac_c" 1>&6
3929 else
3930
3931 test -n "$verbose" && echo
3932 cf_search=""
3933
3934 test -d $HOME && {
3935 test -n "$verbose" && echo " ... testing include-directories under $HOME"
3936 test -d $HOME/include && cf_search="$cf_search $HOME/include"
3937 test -d $HOME/include/$cf_ncuhdr_root && cf_search="$cf_search $HOME/include/$cf_ncuhdr_root"
3938 test -d $HOME/include/$cf_ncuhdr_root/include && cf_search="$cf_search $HOME/include/$cf_ncuhdr_root/include"
3939 }
3940
3941 # For other stuff under the home directory, it should be sufficient to put
3942 # a symbolic link for $HOME/$cf_ncuhdr_root to the actual package location:
3943 test -d $HOME/$cf_ncuhdr_root && {
3944 test -n "$verbose" && echo " ... testing include-directories under $HOME/$cf_ncuhdr_root"
3945 test -d $HOME/$cf_ncuhdr_root/include && cf_search="$cf_search $HOME/$cf_ncuhdr_root/include"
3946 test -d $HOME/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search $HOME/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
3947 }
3948
3949 test "$prefix" != /usr/local && \
3950 test -d /usr/local && {
3951 test -n "$verbose" && echo " ... testing include-directories under /usr/local"
3952 test -d /usr/local/include && cf_search="$cf_search /usr/local/include"
3953 test -d /usr/local/include/$cf_ncuhdr_root && cf_search="$cf_search /usr/local/include/$cf_ncuhdr_root"
3954 test -d /usr/local/include/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/local/include/$cf_ncuhdr_root/include"
3955 test -d /usr/local/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/local/$cf_ncuhdr_root/include"
3956 test -d /usr/local/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search /usr/local/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
3957 }
3958
3959 test "$prefix" != NONE && \
3960 test -d $prefix && {
3961 test -n "$verbose" && echo " ... testing include-directories under $prefix"
3962 test -d $prefix/include && cf_search="$cf_search $prefix/include"
3963 test -d $prefix/include/$cf_ncuhdr_root && cf_search="$cf_search $prefix/include/$cf_ncuhdr_root"
3964 test -d $prefix/include/$cf_ncuhdr_root/include && cf_search="$cf_search $prefix/include/$cf_ncuhdr_root/include"
3965 test -d $prefix/$cf_ncuhdr_root/include && cf_search="$cf_search $prefix/$cf_ncuhdr_root/include"
3966 test -d $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
3967 }
3968
3969 test "$prefix" != /opt && \
3970 test -d /opt && {
3971 test -n "$verbose" && echo " ... testing include-directories under /opt"
3972 test -d /opt/include && cf_search="$cf_search /opt/include"
3973 test -d /opt/include/$cf_ncuhdr_root && cf_search="$cf_search /opt/include/$cf_ncuhdr_root"
3974 test -d /opt/include/$cf_ncuhdr_root/include && cf_search="$cf_search /opt/include/$cf_ncuhdr_root/include"
3975 test -d /opt/$cf_ncuhdr_root/include && cf_search="$cf_search /opt/$cf_ncuhdr_root/include"
3976 test -d /opt/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search /opt/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
3977 }
3978
3979 test "$prefix" != /usr && \
3980 test -d /usr && {
3981 test -n "$verbose" && echo " ... testing include-directories under /usr"
3982 test -d /usr/include && cf_search="$cf_search /usr/include"
3983 test -d /usr/include/$cf_ncuhdr_root && cf_search="$cf_search /usr/include/$cf_ncuhdr_root"
3984 test -d /usr/include/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/include/$cf_ncuhdr_root/include"
3985 test -d /usr/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/$cf_ncuhdr_root/include"
3986 }
3987
3988 test "$includedir" != NONE && \
3989 test "$includedir" != "/usr/include" && \
3990 test -d "$includedir" && {
3991 test -d $includedir && cf_search="$cf_search $includedir"
3992 test -d $includedir/$cf_ncuhdr_root && cf_search="$cf_search $includedir/$cf_ncuhdr_root"
3993 }
3994
3995 test "$oldincludedir" != NONE && \
3996 test "$oldincludedir" != "/usr/include" && \
3997 test -d "$oldincludedir" && {
3998 test -d $oldincludedir && cf_search="$cf_search $oldincludedir"
3999 test -d $oldincludedir/$cf_ncuhdr_root && cf_search="$cf_search $oldincludedir/$cf_ncuhdr_root"
4000 }
4001
4002
4003 test -n "$verbose" && echo search path $cf_search
4004 cf_save2_CPPFLAGS="$CPPFLAGS"
4005 for cf_incdir in $cf_search
4006 do
4007
4008 for cf_add_incdir in $cf_incdir
4009 do
4010 while true
4011 do
4012 case $cf_add_incdir in
4013 /usr/include) # (vi
4014 ;;
4015 /usr/local/include) # (vi
4016 if test "$GCC" = yes
4017 then
4018 cf_save_CPPFLAGS="$CPPFLAGS"
4019 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
4020 cat > conftest.$ac_ext <<EOF
4021 #line 4023 "configure"
4022 #include "confdefs.h"
4023 #include <stdio.h>
4024 int main() {
4025 printf("Hello")
4026 ; return 0; }
4027 EOF
4028 if { (eval echo configure:4030: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
4029 :
4030 else
4031 echo "configure: failed program was:" >&5
4032 cat conftest.$ac_ext >&5
4033 rm -rf conftest*
4034 CPPFLAGS="$cf_save_CPPFLAGS"
4035 fi
4036 rm -f conftest*
4037 fi
4038 ;;
4039 *) # (vi
4040 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
4041 ;;
4042 esac
4043 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
4044 test "$cf_top_incdir" = "$cf_add_incdir" && break
4045 cf_add_incdir="$cf_top_incdir"
4046 done
4047 done
4048
4049 for cf_header in \
4050 ncurses.h \
4051 curses.h
4052 do
4053
4054 cat > conftest.$ac_ext <<EOF
4055 #line 4057 "configure"
4056 #include "confdefs.h"
4057
4058
4059 #include <$cf_header>
4060 int main() {
4061
4062 #ifdef NCURSES_VERSION
4063
4064 printf("%s\n", NCURSES_VERSION);
4065 #else
4066 #ifdef __NCURSES_H
4067 printf("old\n");
4068 #else
4069 make an error
4070 #endif
4071 #endif
4072
4073
4074 ; return 0; }
4075 EOF
4076 if { (eval echo configure:4078: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
4077 rm -rf conftest*
4078 cf_cv_ncurses_h2=$cf_header
4079
4080 else
4081 echo "configure: failed program was:" >&5
4082 cat conftest.$ac_ext >&5
4083 rm -rf conftest*
4084 cf_cv_ncurses_h2=no
4085 fi
4086 rm -f conftest*
4087
4088 if test "$cf_cv_ncurses_h2" != no ; then
4089 cf_cv_ncurses_h2=$cf_incdir/$cf_header
4090 test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&6
4091 break
4092 fi
4093 test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&6
4094 done
4095 CPPFLAGS="$cf_save2_CPPFLAGS"
4096 test "$cf_cv_ncurses_h2" != no && break
4097 done
4098 test "$cf_cv_ncurses_h2" = no && { echo "configure: error: not found" 1>&2; exit 1; }
4099
4100 fi
4101
4102 echo "$ac_t""$cf_cv_ncurses_h2" 1>&6
4103
4104 cf_1st_incdir=`echo $cf_cv_ncurses_h2 | sed -e 's%/[^/]*$%%'`
4105 cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
4106 if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
4107 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
4108 fi
4109
4110 for cf_add_incdir in $cf_1st_incdir
4111 do
4112 while true
4113 do
4114 case $cf_add_incdir in
4115 /usr/include) # (vi
4116 ;;
4117 /usr/local/include) # (vi
4118 if test "$GCC" = yes
4119 then
4120 cf_save_CPPFLAGS="$CPPFLAGS"
4121 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
4122 cat > conftest.$ac_ext <<EOF
4123 #line 4125 "configure"
4124 #include "confdefs.h"
4125 #include <stdio.h>
4126 int main() {
4127 printf("Hello")
4128 ; return 0; }
4129 EOF
4130 if { (eval echo configure:4132: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
4131 :
4132 else
4133 echo "configure: failed program was:" >&5
4134 cat conftest.$ac_ext >&5
4135 rm -rf conftest*
4136 CPPFLAGS="$cf_save_CPPFLAGS"
4137 fi
4138 rm -f conftest*
4139 fi
4140 ;;
4141 *) # (vi
4142 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
4143 ;;
4144 esac
4145 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
4146 test "$cf_top_incdir" = "$cf_add_incdir" && break
4147 cf_add_incdir="$cf_top_incdir"
4148 done
4149 done
4150
4151
4152 fi
4153
4154 cat >> confdefs.h <<\EOF
4155 #define NCURSES 1
4156 EOF
4157
4158
4159 case $cf_cv_ncurses_header in # (vi
4160 *ncurses.h)
4161 cat >> confdefs.h <<\EOF
4162 #define HAVE_NCURSES_H 1
4163 EOF
4164
4165 ;;
4166 esac
4167
4168 case $cf_cv_ncurses_header in # (vi
4169 ncurses/curses.h|ncurses/ncurses.h)
4170 cat >> confdefs.h <<\EOF
4171 #define HAVE_NCURSES_NCURSES_H 1
4172 EOF
4173
4174 ;;
4175 ncursesw/curses.h|ncursesw/ncurses.h)
4176 cat >> confdefs.h <<\EOF
4177 #define HAVE_NCURSESW_NCURSES_H 1
4178 EOF
4179
4180 ;;
4181 esac
4182
4183
4184 echo $ac_n "checking for ncurses version""... $ac_c" 1>&6
4185 echo "configure:4187: checking for ncurses version" >&5
4186 if eval "test \"`echo '$''{'cf_cv_ncurses_version'+set}'`\" = set"; then
4187 echo $ac_n "(cached) $ac_c" 1>&6
4188 else
4189
4190 cf_cv_ncurses_version=no
4191 cf_tempfile=out$$
4192 rm -f $cf_tempfile
4193 if test "$cross_compiling" = yes; then
4194
4195
4196 # This will not work if the preprocessor splits the line after the
4197 # Autoconf token. The 'unproto' program does that.
4198 cat > conftest.$ac_ext <<EOF
4199 #include <${cf_cv_ncurses_header-curses.h}>
4200 #undef Autoconf
4201 #ifdef NCURSES_VERSION
4202 Autoconf NCURSES_VERSION
4203 #else
4204 #ifdef __NCURSES_H
4205 Autoconf "old"
4206 #endif
4207 ;
4208 #endif
4209 EOF
4210 cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
4211 { (eval echo configure:4213: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
4212 if test -f conftest.out ; then
4213 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
4214 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
4215 rm -f conftest.out
4216 fi
4217
4218 else
4219 cat > conftest.$ac_ext <<EOF
4220 #line 4222 "configure"
4221 #include "confdefs.h"
4222
4223 #include <${cf_cv_ncurses_header-curses.h}>
4224 #include <stdio.h>
4225 int main()
4226 {
4227 FILE *fp = fopen("$cf_tempfile", "w");
4228 #ifdef NCURSES_VERSION
4229 # ifdef NCURSES_VERSION_PATCH
4230 fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
4231 # else
4232 fprintf(fp, "%s\n", NCURSES_VERSION);
4233 # endif
4234 #else
4235 # ifdef __NCURSES_H
4236 fprintf(fp, "old\n");
4237 # else
4238 make an error
4239 # endif
4240 #endif
4241 exit(0);
4242 }
4243 EOF
4244 if { (eval echo configure:4246: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
4245 then
4246
4247 cf_cv_ncurses_version=`cat $cf_tempfile`
4248 else
4249 echo "configure: failed program was:" >&5
4250 cat conftest.$ac_ext >&5
4251 fi
4252 rm -fr conftest*
4253 fi
4254
4255 rm -f $cf_tempfile
4256
4257 fi
4258
4259 echo "$ac_t""$cf_cv_ncurses_version" 1>&6
4260 test "$cf_cv_ncurses_version" = no || cat >> confdefs.h <<\EOF
4261 #define NCURSES 1
4262 EOF
4263
4264
4265
4266
4267
4268 cf_nculib_root=ncurses
4269 # This works, except for the special case where we find gpm, but
4270 # ncurses is in a nonstandard location via $LIBS, and we really want
4271 # to link gpm.
4272 cf_ncurses_LIBS=""
4273 cf_ncurses_SAVE="$LIBS"
4274 echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6
4275 echo "configure:4277: checking for Gpm_Open in -lgpm" >&5
4276 ac_lib_var=`echo gpm'_'Gpm_Open | sed 'y%./+-%__p_%'`
4277 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
4278 echo $ac_n "(cached) $ac_c" 1>&6
4279 else
4280 ac_save_LIBS="$LIBS"
4281 LIBS="-lgpm $LIBS"
4282 cat > conftest.$ac_ext <<EOF
4283 #line 4285 "configure"
4284 #include "confdefs.h"
4285 /* Override any gcc2 internal prototype to avoid an error. */
4286 /* We use char because int might match the return type of a gcc2
4287 builtin and then its argument prototype would still apply. */
4288 char Gpm_Open();
4289
4290 int main() {
4291 Gpm_Open()
4292 ; return 0; }
4293 EOF
4294 if { (eval echo configure:4296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
4295 rm -rf conftest*
4296 eval "ac_cv_lib_$ac_lib_var=yes"
4297 else
4298 echo "configure: failed program was:" >&5
4299 cat conftest.$ac_ext >&5
4300 rm -rf conftest*
4301 eval "ac_cv_lib_$ac_lib_var=no"
4302 fi
4303 rm -f conftest*
4304 LIBS="$ac_save_LIBS"
4305
4306 fi
4307 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
4308 echo "$ac_t""yes" 1>&6
4309 echo $ac_n "checking for initscr in -lgpm""... $ac_c" 1>&6
4310 echo "configure:4312: checking for initscr in -lgpm" >&5
4311 ac_lib_var=`echo gpm'_'initscr | sed 'y%./+-%__p_%'`
4312 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
4313 echo $ac_n "(cached) $ac_c" 1>&6
4314 else
4315 ac_save_LIBS="$LIBS"
4316 LIBS="-lgpm $LIBS"
4317 cat > conftest.$ac_ext <<EOF
4318 #line 4320 "configure"
4319 #include "confdefs.h"
4320 /* Override any gcc2 internal prototype to avoid an error. */
4321 /* We use char because int might match the return type of a gcc2
4322 builtin and then its argument prototype would still apply. */
4323 char initscr();
4324
4325 int main() {
4326 initscr()
4327 ; return 0; }
4328 EOF
4329 if { (eval echo configure:4331: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
4330 rm -rf conftest*
4331 eval "ac_cv_lib_$ac_lib_var=yes"
4332 else
4333 echo "configure: failed program was:" >&5
4334 cat conftest.$ac_ext >&5
4335 rm -rf conftest*
4336 eval "ac_cv_lib_$ac_lib_var=no"
4337 fi
4338 rm -f conftest*
4339 LIBS="$ac_save_LIBS"
4340
4341 fi
4342 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
4343 echo "$ac_t""yes" 1>&6
4344 LIBS="$cf_ncurses_SAVE"
4345 else
4346 echo "$ac_t""no" 1>&6
4347 cf_ncurses_LIBS="-lgpm"
4348 fi
4349
4350 else
4351 echo "$ac_t""no" 1>&6
4352 fi
4353
4354
4355 case $host_os in #(vi
4356 freebsd*)
4357 # This is only necessary if you are linking against an obsolete
4358 # version of ncurses (but it should do no harm, since it's static).
4359 if test "$cf_nculib_root" = ncurses ; then
4360 echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6
4361 echo "configure:4363: checking for tgoto in -lmytinfo" >&5
4362 ac_lib_var=`echo mytinfo'_'tgoto | sed 'y%./+-%__p_%'`
4363 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
4364 echo $ac_n "(cached) $ac_c" 1>&6
4365 else
4366 ac_save_LIBS="$LIBS"
4367 LIBS="-lmytinfo $LIBS"
4368 cat > conftest.$ac_ext <<EOF
4369 #line 4371 "configure"
4370 #include "confdefs.h"
4371 /* Override any gcc2 internal prototype to avoid an error. */
4372 /* We use char because int might match the return type of a gcc2
4373 builtin and then its argument prototype would still apply. */
4374 char tgoto();
4375
4376 int main() {
4377 tgoto()
4378 ; return 0; }
4379 EOF
4380 if { (eval echo configure:4382: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
4381 rm -rf conftest*
4382 eval "ac_cv_lib_$ac_lib_var=yes"
4383 else
4384 echo "configure: failed program was:" >&5
4385 cat conftest.$ac_ext >&5
4386 rm -rf conftest*
4387 eval "ac_cv_lib_$ac_lib_var=no"
4388 fi
4389 rm -f conftest*
4390 LIBS="$ac_save_LIBS"
4391
4392 fi
4393 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
4394 echo "$ac_t""yes" 1>&6
4395 cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"
4396 else
4397 echo "$ac_t""no" 1>&6
4398 fi
4399
4400 fi
4401 ;;
4402 esac
4403
4404 LIBS="$cf_ncurses_LIBS $LIBS"
4405
4406 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
4407 then
4408 LIBS="-L$cf_cv_curses_dir/lib -l$cf_nculib_root $LIBS"
4409 else
4410
4411 eval 'cf_cv_have_lib_'$cf_nculib_root'=no'
4412 cf_libdir=""
4413 echo $ac_n "checking for initscr""... $ac_c" 1>&6
4414 echo "configure:4416: checking for initscr" >&5
4415 if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then
4416 echo $ac_n "(cached) $ac_c" 1>&6
4417 else
4418 cat > conftest.$ac_ext <<EOF
4419 #line 4421 "configure"
4420 #include "confdefs.h"
4421 /* System header to define __stub macros and hopefully few prototypes,
4422 which can conflict with char initscr(); below. */
4423 #include <assert.h>
4424 /* Override any gcc2 internal prototype to avoid an error. */
4425 /* We use char because int might match the return type of a gcc2
4426 builtin and then its argument prototype would still apply. */
4427 char initscr();
4428
4429 int main() {
4430
4431 /* The GNU C library defines this for functions which it implements
4432 to always fail with ENOSYS. Some functions are actually named
4433 something starting with __ and the normal name is an alias. */
4434 #if defined (__stub_initscr) || defined (__stub___initscr)
4435 choke me
4436 #else
4437 initscr();
4438 #endif
4439
4440 ; return 0; }
4441 EOF
4442 if { (eval echo configure:4444: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
4443 rm -rf conftest*
4444 eval "ac_cv_func_initscr=yes"
4445 else
4446 echo "configure: failed program was:" >&5
4447 cat conftest.$ac_ext >&5
4448 rm -rf conftest*
4449 eval "ac_cv_func_initscr=no"
4450 fi
4451 rm -f conftest*
4452 fi
4453
4454 if eval "test \"`echo '$ac_cv_func_'initscr`\" = yes"; then
4455 echo "$ac_t""yes" 1>&6
4456 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
4457 else
4458 echo "$ac_t""no" 1>&6
4459
4460 cf_save_LIBS="$LIBS"
4461 echo $ac_n "checking for initscr in -l$cf_nculib_root""... $ac_c" 1>&6
4462 echo "configure:4464: checking for initscr in -l$cf_nculib_root" >&5
4463 LIBS="-l$cf_nculib_root $LIBS"
4464 cat > conftest.$ac_ext <<EOF
4465 #line 4467 "configure"
4466 #include "confdefs.h"
4467 #include <${cf_cv_ncurses_header-curses.h}>
4468 int main() {
4469 initscr()
4470 ; return 0; }
4471 EOF
4472 if { (eval echo configure:4474: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
4473 rm -rf conftest*
4474 echo "$ac_t""yes" 1>&6
4475 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
4476
4477 else
4478 echo "configure: failed program was:" >&5
4479 cat conftest.$ac_ext >&5
4480 rm -rf conftest*
4481 echo "$ac_t""no" 1>&6
4482 cf_search=""
4483
4484 test -d $HOME && {
4485 test -n "$verbose" && echo " ... testing lib-directories under $HOME"
4486 test -d $HOME/lib && cf_search="$cf_search $HOME/lib"
4487 test -d $HOME/lib/$cf_nculib_root && cf_search="$cf_search $HOME/lib/$cf_nculib_root"
4488 test -d $HOME/lib/$cf_nculib_root/lib && cf_search="$cf_search $HOME/lib/$cf_nculib_root/lib"
4489 }
4490
4491 # For other stuff under the home directory, it should be sufficient to put
4492 # a symbolic link for $HOME/$cf_nculib_root to the actual package location:
4493 test -d $HOME/$cf_nculib_root && {
4494 test -n "$verbose" && echo " ... testing lib-directories under $HOME/$cf_nculib_root"
4495 test -d $HOME/$cf_nculib_root/lib && cf_search="$cf_search $HOME/$cf_nculib_root/lib"
4496 test -d $HOME/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search $HOME/$cf_nculib_root/lib/$cf_nculib_root"
4497 }
4498
4499 test "$prefix" != /usr/local && \
4500 test -d /usr/local && {
4501 test -n "$verbose" && echo " ... testing lib-directories under /usr/local"
4502 test -d /usr/local/lib && cf_search="$cf_search /usr/local/lib"
4503 test -d /usr/local/lib/$cf_nculib_root && cf_search="$cf_search /usr/local/lib/$cf_nculib_root"
4504 test -d /usr/local/lib/$cf_nculib_root/lib && cf_search="$cf_search /usr/local/lib/$cf_nculib_root/lib"
4505 test -d /usr/local/$cf_nculib_root/lib && cf_search="$cf_search /usr/local/$cf_nculib_root/lib"
4506 test -d /usr/local/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search /usr/local/$cf_nculib_root/lib/$cf_nculib_root"
4507 }
4508
4509 test "$prefix" != NONE && \
4510 test -d $prefix && {
4511 test -n "$verbose" && echo " ... testing lib-directories under $prefix"
4512 test -d $prefix/lib && cf_search="$cf_search $prefix/lib"
4513 test -d $prefix/lib/$cf_nculib_root && cf_search="$cf_search $prefix/lib/$cf_nculib_root"
4514 test -d $prefix/lib/$cf_nculib_root/lib && cf_search="$cf_search $prefix/lib/$cf_nculib_root/lib"
4515 test -d $prefix/$cf_nculib_root/lib && cf_search="$cf_search $prefix/$cf_nculib_root/lib"
4516 test -d $prefix/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search $prefix/$cf_nculib_root/lib/$cf_nculib_root"
4517 }
4518
4519 test "$prefix" != /opt && \
4520 test -d /opt && {
4521 test -n "$verbose" && echo " ... testing lib-directories under /opt"
4522 test -d /opt/lib && cf_search="$cf_search /opt/lib"
4523 test -d /opt/lib/$cf_nculib_root && cf_search="$cf_search /opt/lib/$cf_nculib_root"
4524 test -d /opt/lib/$cf_nculib_root/lib && cf_search="$cf_search /opt/lib/$cf_nculib_root/lib"
4525 test -d /opt/$cf_nculib_root/lib && cf_search="$cf_search /opt/$cf_nculib_root/lib"
4526 test -d /opt/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search /opt/$cf_nculib_root/lib/$cf_nculib_root"
4527 }
4528
4529 test "$prefix" != /usr && \
4530 test -d /usr && {
4531 test -n "$verbose" && echo " ... testing lib-directories under /usr"
4532 test -d /usr/lib && cf_search="$cf_search /usr/lib"
4533 test -d /usr/lib/$cf_nculib_root && cf_search="$cf_search /usr/lib/$cf_nculib_root"
4534 test -d /usr/lib/$cf_nculib_root/lib && cf_search="$cf_search /usr/lib/$cf_nculib_root/lib"
4535 test -d /usr/$cf_nculib_root/lib && cf_search="$cf_search /usr/$cf_nculib_root/lib"
4536 }
4537
4538 for cf_libdir in $cf_search
4539 do
4540 echo $ac_n "checking for -l$cf_nculib_root in $cf_libdir""... $ac_c" 1>&6
4541 echo "configure:4543: checking for -l$cf_nculib_root in $cf_libdir" >&5
4542 LIBS="-L$cf_libdir -l$cf_nculib_root $cf_save_LIBS"
4543 cat > conftest.$ac_ext <<EOF
4544 #line 4546 "configure"
4545 #include "confdefs.h"
4546 #include <${cf_cv_ncurses_header-curses.h}>
4547 int main() {
4548 initscr()
4549 ; return 0; }
4550 EOF
4551 if { (eval echo configure:4553: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
4552 rm -rf conftest*
4553 echo "$ac_t""yes" 1>&6
4554 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
4555 break
4556 else
4557 echo "configure: failed program was:" >&5
4558 cat conftest.$ac_ext >&5
4559 rm -rf conftest*
4560 echo "$ac_t""no" 1>&6
4561 LIBS="$cf_save_LIBS"
4562 fi
4563 rm -f conftest*
4564 done
4565
4566 fi
4567 rm -f conftest*
4568
4569 fi
4570
4571 eval 'cf_found_library=$cf_cv_have_lib_'$cf_nculib_root
4572
4573 if test $cf_found_library = no ; then
4574 { echo "configure: error: Cannot link $cf_nculib_root library" 1>&2; exit 1; }
4575 fi
4576
4577
4578 fi
4579
4580 if test -n "$cf_ncurses_LIBS" ; then
4581 echo $ac_n "checking if we can link $cf_nculib_root without $cf_ncurses_LIBS""... $ac_c" 1>&6
4582 echo "configure:4584: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
4583 cf_ncurses_SAVE="$LIBS"
4584 for p in $cf_ncurses_LIBS ; do
4585 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
4586 if test "$q" != "$LIBS" ; then
4587 LIBS="$q"
4588 fi
4589 done
4590 cat > conftest.$ac_ext <<EOF
4591 #line 4593 "configure"
4592 #include "confdefs.h"
4593 #include <${cf_cv_ncurses_header-curses.h}>
4594 int main() {
4595 initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
4596 ; return 0; }
4597 EOF
4598 if { (eval echo configure:4600: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
4599 rm -rf conftest*
4600 echo "$ac_t""yes" 1>&6
4601 else
4602 echo "configure: failed program was:" >&5
4603 cat conftest.$ac_ext >&5
4604 rm -rf conftest*
4605 echo "$ac_t""no" 1>&6
4606 LIBS="$cf_ncurses_SAVE"
4607 fi
4608 rm -f conftest*
4609 fi
4610
4611
4612 cf_nculib_ROOT=`echo "HAVE_LIB$cf_nculib_root" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
4613
4614 cat >> confdefs.h <<EOF
4615 #define $cf_nculib_ROOT 1
4616 EOF
4617
4618
4619 ;;
4620 ncursesw)
4621
4622 echo $ac_n "checking for multibyte character support""... $ac_c" 1>&6
4623 echo "configure:4625: checking for multibyte character support" >&5
4624 if eval "test \"`echo '$''{'cf_cv_utf8_lib'+set}'`\" = set"; then
4625 echo $ac_n "(cached) $ac_c" 1>&6
4626 else
4627
4628 cf_save_LIBS="$LIBS"
4629 cat > conftest.$ac_ext <<EOF
4630 #line 4632 "configure"
4631 #include "confdefs.h"
4632
4633 #include <stdlib.h>
4634 int main() {
4635 putwc(0,0);
4636 ; return 0; }
4637 EOF
4638 if { (eval echo configure:4640: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
4639 rm -rf conftest*
4640 cf_cv_utf8_lib=yes
4641 else
4642 echo "configure: failed program was:" >&5
4643 cat conftest.$ac_ext >&5
4644 rm -rf conftest*
4645 LIBS="-lutf8 $LIBS"
4646 cat > conftest.$ac_ext <<EOF
4647 #line 4649 "configure"
4648 #include "confdefs.h"
4649
4650 #include <libutf8.h>
4651 int main() {
4652 putwc(0,0);
4653 ; return 0; }
4654 EOF
4655 if { (eval echo configure:4657: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
4656 rm -rf conftest*
4657 cf_cv_utf8_lib=add-on
4658 else
4659 echo "configure: failed program was:" >&5
4660 cat conftest.$ac_ext >&5
4661 rm -rf conftest*
4662 cf_cv_utf8_lib=no
4663 fi
4664 rm -f conftest*
4665 LIBS="$cf_save_LIBS"
4666
4667 fi
4668 rm -f conftest*
4669 fi
4670
4671 echo "$ac_t""$cf_cv_utf8_lib" 1>&6
4672
4673 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
4674 # ncurses/ncursesw:
4675 if test "$cf_cv_utf8_lib" = "add-on" ; then
4676 cat >> confdefs.h <<\EOF
4677 #define HAVE_LIBUTF8_H 1
4678 EOF
4679
4680 LIBS="-lutf8 $LIBS"
4681 fi
4682
4683
4684
4685 cf_ncuhdr_root=ncursesw
4686
4687 test -n "$cf_cv_curses_dir" && \
4688 test "$cf_cv_curses_dir" != "no" && \
4689 CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS"
4690
4691 echo $ac_n "checking for $cf_ncuhdr_root header in include-path""... $ac_c" 1>&6
4692 echo "configure:4694: checking for $cf_ncuhdr_root header in include-path" >&5
4693 if eval "test \"`echo '$''{'cf_cv_ncurses_h'+set}'`\" = set"; then
4694 echo $ac_n "(cached) $ac_c" 1>&6
4695 else
4696
4697 cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
4698 ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
4699 for cf_header in $cf_header_list
4700 do
4701
4702 cat > conftest.$ac_ext <<EOF
4703 #line 4705 "configure"
4704 #include "confdefs.h"
4705
4706
4707 #define _XOPEN_SOURCE_EXTENDED
4708 #undef HAVE_LIBUTF8_H /* in case we used CF_UTF8_LIB */
4709 #define HAVE_LIBUTF8_H /* to force ncurses' header file to use cchar_t */
4710
4711 #include <$cf_header>
4712 int main() {
4713
4714 #ifdef NCURSES_VERSION
4715
4716 #ifndef WACS_BSSB
4717 make an error
4718 #endif
4719
4720 printf("%s\n", NCURSES_VERSION);
4721 #else
4722 #ifdef __NCURSES_H
4723 printf("old\n");
4724 #else
4725 make an error
4726 #endif
4727 #endif
4728
4729
4730 ; return 0; }
4731 EOF
4732 if { (eval echo configure:4734: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
4733 rm -rf conftest*
4734 cf_cv_ncurses_h=$cf_header
4735
4736 else
4737 echo "configure: failed program was:" >&5
4738 cat conftest.$ac_ext >&5
4739 rm -rf conftest*
4740 cf_cv_ncurses_h=no
4741 fi
4742 rm -f conftest*
4743
4744 test "$cf_cv_ncurses_h" != no && break
4745 done
4746
4747 fi
4748
4749 echo "$ac_t""$cf_cv_ncurses_h" 1>&6
4750
4751 if test "$cf_cv_ncurses_h" != no ; then
4752 cf_cv_ncurses_header=$cf_cv_ncurses_h
4753 else
4754 echo $ac_n "checking for $cf_ncuhdr_root include-path""... $ac_c" 1>&6
4755 echo "configure:4757: checking for $cf_ncuhdr_root include-path" >&5
4756 if eval "test \"`echo '$''{'cf_cv_ncurses_h2'+set}'`\" = set"; then
4757 echo $ac_n "(cached) $ac_c" 1>&6
4758 else
4759
4760 test -n "$verbose" && echo
4761 cf_search=""
4762
4763 test -d $HOME && {
4764 test -n "$verbose" && echo " ... testing include-directories under $HOME"
4765 test -d $HOME/include && cf_search="$cf_search $HOME/include"
4766 test -d $HOME/include/$cf_ncuhdr_root && cf_search="$cf_search $HOME/include/$cf_ncuhdr_root"
4767 test -d $HOME/include/$cf_ncuhdr_root/include && cf_search="$cf_search $HOME/include/$cf_ncuhdr_root/include"
4768 }
4769
4770 # For other stuff under the home directory, it should be sufficient to put
4771 # a symbolic link for $HOME/$cf_ncuhdr_root to the actual package location:
4772 test -d $HOME/$cf_ncuhdr_root && {
4773 test -n "$verbose" && echo " ... testing include-directories under $HOME/$cf_ncuhdr_root"
4774 test -d $HOME/$cf_ncuhdr_root/include && cf_search="$cf_search $HOME/$cf_ncuhdr_root/include"
4775 test -d $HOME/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search $HOME/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
4776 }
4777
4778 test "$prefix" != /usr/local && \
4779 test -d /usr/local && {
4780 test -n "$verbose" && echo " ... testing include-directories under /usr/local"
4781 test -d /usr/local/include && cf_search="$cf_search /usr/local/include"
4782 test -d /usr/local/include/$cf_ncuhdr_root && cf_search="$cf_search /usr/local/include/$cf_ncuhdr_root"
4783 test -d /usr/local/include/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/local/include/$cf_ncuhdr_root/include"
4784 test -d /usr/local/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/local/$cf_ncuhdr_root/include"
4785 test -d /usr/local/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search /usr/local/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
4786 }
4787
4788 test "$prefix" != NONE && \
4789 test -d $prefix && {
4790 test -n "$verbose" && echo " ... testing include-directories under $prefix"
4791 test -d $prefix/include && cf_search="$cf_search $prefix/include"
4792 test -d $prefix/include/$cf_ncuhdr_root && cf_search="$cf_search $prefix/include/$cf_ncuhdr_root"
4793 test -d $prefix/include/$cf_ncuhdr_root/include && cf_search="$cf_search $prefix/include/$cf_ncuhdr_root/include"
4794 test -d $prefix/$cf_ncuhdr_root/include && cf_search="$cf_search $prefix/$cf_ncuhdr_root/include"
4795 test -d $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
4796 }
4797
4798 test "$prefix" != /opt && \
4799 test -d /opt && {
4800 test -n "$verbose" && echo " ... testing include-directories under /opt"
4801 test -d /opt/include && cf_search="$cf_search /opt/include"
4802 test -d /opt/include/$cf_ncuhdr_root && cf_search="$cf_search /opt/include/$cf_ncuhdr_root"
4803 test -d /opt/include/$cf_ncuhdr_root/include && cf_search="$cf_search /opt/include/$cf_ncuhdr_root/include"
4804 test -d /opt/$cf_ncuhdr_root/include && cf_search="$cf_search /opt/$cf_ncuhdr_root/include"
4805 test -d /opt/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search /opt/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
4806 }
4807
4808 test "$prefix" != /usr && \
4809 test -d /usr && {
4810 test -n "$verbose" && echo " ... testing include-directories under /usr"
4811 test -d /usr/include && cf_search="$cf_search /usr/include"
4812 test -d /usr/include/$cf_ncuhdr_root && cf_search="$cf_search /usr/include/$cf_ncuhdr_root"
4813 test -d /usr/include/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/include/$cf_ncuhdr_root/include"
4814 test -d /usr/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/$cf_ncuhdr_root/include"
4815 }
4816
4817 test "$includedir" != NONE && \
4818 test "$includedir" != "/usr/include" && \
4819 test -d "$includedir" && {
4820 test -d $includedir && cf_search="$cf_search $includedir"
4821 test -d $includedir/$cf_ncuhdr_root && cf_search="$cf_search $includedir/$cf_ncuhdr_root"
4822 }
4823
4824 test "$oldincludedir" != NONE && \
4825 test "$oldincludedir" != "/usr/include" && \
4826 test -d "$oldincludedir" && {
4827 test -d $oldincludedir && cf_search="$cf_search $oldincludedir"
4828 test -d $oldincludedir/$cf_ncuhdr_root && cf_search="$cf_search $oldincludedir/$cf_ncuhdr_root"
4829 }
4830
4831
4832 test -n "$verbose" && echo search path $cf_search
4833 cf_save2_CPPFLAGS="$CPPFLAGS"
4834 for cf_incdir in $cf_search
4835 do
4836
4837 for cf_add_incdir in $cf_incdir
4838 do
4839 while true
4840 do
4841 case $cf_add_incdir in
4842 /usr/include) # (vi
4843 ;;
4844 /usr/local/include) # (vi
4845 if test "$GCC" = yes
4846 then
4847 cf_save_CPPFLAGS="$CPPFLAGS"
4848 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
4849 cat > conftest.$ac_ext <<EOF
4850 #line 4852 "configure"
4851 #include "confdefs.h"
4852 #include <stdio.h>
4853 int main() {
4854 printf("Hello")
4855 ; return 0; }
4856 EOF
4857 if { (eval echo configure:4859: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
4858 :
4859 else
4860 echo "configure: failed program was:" >&5
4861 cat conftest.$ac_ext >&5
4862 rm -rf conftest*
4863 CPPFLAGS="$cf_save_CPPFLAGS"
4864 fi
4865 rm -f conftest*
4866 fi
4867 ;;
4868 *) # (vi
4869 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
4870 ;;
4871 esac
4872 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
4873 test "$cf_top_incdir" = "$cf_add_incdir" && break
4874 cf_add_incdir="$cf_top_incdir"
4875 done
4876 done
4877
4878 for cf_header in \
4879 ncurses.h \
4880 curses.h
4881 do
4882
4883 cat > conftest.$ac_ext <<EOF
4884 #line 4886 "configure"
4885 #include "confdefs.h"
4886
4887
4888 #define _XOPEN_SOURCE_EXTENDED
4889 #undef HAVE_LIBUTF8_H /* in case we used CF_UTF8_LIB */
4890 #define HAVE_LIBUTF8_H /* to force ncurses' header file to use cchar_t */
4891
4892 #include <$cf_header>
4893 int main() {
4894
4895 #ifdef NCURSES_VERSION
4896
4897 #ifndef WACS_BSSB
4898 make an error
4899 #endif
4900
4901 printf("%s\n", NCURSES_VERSION);
4902 #else
4903 #ifdef __NCURSES_H
4904 printf("old\n");
4905 #else
4906 make an error
4907 #endif
4908 #endif
4909
4910
4911 ; return 0; }
4912 EOF
4913 if { (eval echo configure:4915: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
4914 rm -rf conftest*
4915 cf_cv_ncurses_h2=$cf_header
4916
4917 else
4918 echo "configure: failed program was:" >&5
4919 cat conftest.$ac_ext >&5
4920 rm -rf conftest*
4921 cf_cv_ncurses_h2=no
4922 fi
4923 rm -f conftest*
4924
4925 if test "$cf_cv_ncurses_h2" != no ; then
4926 cf_cv_ncurses_h2=$cf_incdir/$cf_header
4927 test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&6
4928 break
4929 fi
4930 test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&6
4931 done
4932 CPPFLAGS="$cf_save2_CPPFLAGS"
4933 test "$cf_cv_ncurses_h2" != no && break
4934 done
4935 test "$cf_cv_ncurses_h2" = no && { echo "configure: error: not found" 1>&2; exit 1; }
4936
4937 fi
4938
4939 echo "$ac_t""$cf_cv_ncurses_h2" 1>&6
4940
4941 cf_1st_incdir=`echo $cf_cv_ncurses_h2 | sed -e 's%/[^/]*$%%'`
4942 cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
4943 if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
4944 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
4945 fi
4946
4947 for cf_add_incdir in $cf_1st_incdir
4948 do
4949 while true
4950 do
4951 case $cf_add_incdir in
4952 /usr/include) # (vi
4953 ;;
4954 /usr/local/include) # (vi
4955 if test "$GCC" = yes
4956 then
4957 cf_save_CPPFLAGS="$CPPFLAGS"
4958 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
4959 cat > conftest.$ac_ext <<EOF
4960 #line 4962 "configure"
4961 #include "confdefs.h"
4962 #include <stdio.h>
4963 int main() {
4964 printf("Hello")
4965 ; return 0; }
4966 EOF
4967 if { (eval echo configure:4969: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
4968 :
4969 else
4970 echo "configure: failed program was:" >&5
4971 cat conftest.$ac_ext >&5
4972 rm -rf conftest*
4973 CPPFLAGS="$cf_save_CPPFLAGS"
4974 fi
4975 rm -f conftest*
4976 fi
4977 ;;
4978 *) # (vi
4979 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
4980 ;;
4981 esac
4982 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
4983 test "$cf_top_incdir" = "$cf_add_incdir" && break
4984 cf_add_incdir="$cf_top_incdir"
4985 done
4986 done
4987
4988
4989 fi
4990
4991 cat >> confdefs.h <<\EOF
4992 #define NCURSES 1
4993 EOF
4994
4995
4996 case $cf_cv_ncurses_header in # (vi
4997 *ncurses.h)
4998 cat >> confdefs.h <<\EOF
4999 #define HAVE_NCURSES_H 1
5000 EOF
5001
5002 ;;
5003 esac
5004
5005 case $cf_cv_ncurses_header in # (vi
5006 ncurses/curses.h|ncurses/ncurses.h)
5007 cat >> confdefs.h <<\EOF
5008 #define HAVE_NCURSES_NCURSES_H 1
5009 EOF
5010
5011 ;;
5012 ncursesw/curses.h|ncursesw/ncurses.h)
5013 cat >> confdefs.h <<\EOF
5014 #define HAVE_NCURSESW_NCURSES_H 1
5015 EOF
5016
5017 ;;
5018 esac
5019
5020
5021 echo $ac_n "checking for ncurses version""... $ac_c" 1>&6
5022 echo "configure:5024: checking for ncurses version" >&5
5023 if eval "test \"`echo '$''{'cf_cv_ncurses_version'+set}'`\" = set"; then
5024 echo $ac_n "(cached) $ac_c" 1>&6
5025 else
5026
5027 cf_cv_ncurses_version=no
5028 cf_tempfile=out$$
5029 rm -f $cf_tempfile
5030 if test "$cross_compiling" = yes; then
5031
5032
5033 # This will not work if the preprocessor splits the line after the
5034 # Autoconf token. The 'unproto' program does that.
5035 cat > conftest.$ac_ext <<EOF
5036 #include <${cf_cv_ncurses_header-curses.h}>
5037 #undef Autoconf
5038 #ifdef NCURSES_VERSION
5039 Autoconf NCURSES_VERSION
5040 #else
5041 #ifdef __NCURSES_H
5042 Autoconf "old"
5043 #endif
5044 ;
5045 #endif
5046 EOF
5047 cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
5048 { (eval echo configure:5050: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
5049 if test -f conftest.out ; then
5050 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
5051 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
5052 rm -f conftest.out
5053 fi
5054
5055 else
5056 cat > conftest.$ac_ext <<EOF
5057 #line 5059 "configure"
5058 #include "confdefs.h"
5059
5060 #include <${cf_cv_ncurses_header-curses.h}>
5061 #include <stdio.h>
5062 int main()
5063 {
5064 FILE *fp = fopen("$cf_tempfile", "w");
5065 #ifdef NCURSES_VERSION
5066 # ifdef NCURSES_VERSION_PATCH
5067 fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
5068 # else
5069 fprintf(fp, "%s\n", NCURSES_VERSION);
5070 # endif
5071 #else
5072 # ifdef __NCURSES_H
5073 fprintf(fp, "old\n");
5074 # else
5075 make an error
5076 # endif
5077 #endif
5078 exit(0);
5079 }
5080 EOF
5081 if { (eval echo configure:5083: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
5082 then
5083
5084 cf_cv_ncurses_version=`cat $cf_tempfile`
5085 else
5086 echo "configure: failed program was:" >&5
5087 cat conftest.$ac_ext >&5
5088 fi
5089 rm -fr conftest*
5090 fi
5091
5092 rm -f $cf_tempfile
5093
5094 fi
5095
5096 echo "$ac_t""$cf_cv_ncurses_version" 1>&6
5097 test "$cf_cv_ncurses_version" = no || cat >> confdefs.h <<\EOF
5098 #define NCURSES 1
5099 EOF
5100
5101
5102
5103
5104
5105 cf_nculib_root=ncursesw
5106 # This works, except for the special case where we find gpm, but
5107 # ncurses is in a nonstandard location via $LIBS, and we really want
5108 # to link gpm.
5109 cf_ncurses_LIBS=""
5110 cf_ncurses_SAVE="$LIBS"
5111 echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6
5112 echo "configure:5114: checking for Gpm_Open in -lgpm" >&5
5113 ac_lib_var=`echo gpm'_'Gpm_Open | sed 'y%./+-%__p_%'`
5114 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
5115 echo $ac_n "(cached) $ac_c" 1>&6
5116 else
5117 ac_save_LIBS="$LIBS"
5118 LIBS="-lgpm $LIBS"
5119 cat > conftest.$ac_ext <<EOF
5120 #line 5122 "configure"
5121 #include "confdefs.h"
5122 /* Override any gcc2 internal prototype to avoid an error. */
5123 /* We use char because int might match the return type of a gcc2
5124 builtin and then its argument prototype would still apply. */
5125 char Gpm_Open();
5126
5127 int main() {
5128 Gpm_Open()
5129 ; return 0; }
5130 EOF
5131 if { (eval echo configure:5133: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5132 rm -rf conftest*
5133 eval "ac_cv_lib_$ac_lib_var=yes"
5134 else
5135 echo "configure: failed program was:" >&5
5136 cat conftest.$ac_ext >&5
5137 rm -rf conftest*
5138 eval "ac_cv_lib_$ac_lib_var=no"
5139 fi
5140 rm -f conftest*
5141 LIBS="$ac_save_LIBS"
5142
5143 fi
5144 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
5145 echo "$ac_t""yes" 1>&6
5146 echo $ac_n "checking for initscr in -lgpm""... $ac_c" 1>&6
5147 echo "configure:5149: checking for initscr in -lgpm" >&5
5148 ac_lib_var=`echo gpm'_'initscr | sed 'y%./+-%__p_%'`
5149 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
5150 echo $ac_n "(cached) $ac_c" 1>&6
5151 else
5152 ac_save_LIBS="$LIBS"
5153 LIBS="-lgpm $LIBS"
5154 cat > conftest.$ac_ext <<EOF
5155 #line 5157 "configure"
5156 #include "confdefs.h"
5157 /* Override any gcc2 internal prototype to avoid an error. */
5158 /* We use char because int might match the return type of a gcc2
5159 builtin and then its argument prototype would still apply. */
5160 char initscr();
5161
5162 int main() {
5163 initscr()
5164 ; return 0; }
5165 EOF
5166 if { (eval echo configure:5168: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5167 rm -rf conftest*
5168 eval "ac_cv_lib_$ac_lib_var=yes"
5169 else
5170 echo "configure: failed program was:" >&5
5171 cat conftest.$ac_ext >&5
5172 rm -rf conftest*
5173 eval "ac_cv_lib_$ac_lib_var=no"
5174 fi
5175 rm -f conftest*
5176 LIBS="$ac_save_LIBS"
5177
5178 fi
5179 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
5180 echo "$ac_t""yes" 1>&6
5181 LIBS="$cf_ncurses_SAVE"
5182 else
5183 echo "$ac_t""no" 1>&6
5184 cf_ncurses_LIBS="-lgpm"
5185 fi
5186
5187 else
5188 echo "$ac_t""no" 1>&6
5189 fi
5190
5191
5192 case $host_os in #(vi
5193 freebsd*)
5194 # This is only necessary if you are linking against an obsolete
5195 # version of ncurses (but it should do no harm, since it's static).
5196 if test "$cf_nculib_root" = ncurses ; then
5197 echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6
5198 echo "configure:5200: checking for tgoto in -lmytinfo" >&5
5199 ac_lib_var=`echo mytinfo'_'tgoto | sed 'y%./+-%__p_%'`
5200 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
5201 echo $ac_n "(cached) $ac_c" 1>&6
5202 else
5203 ac_save_LIBS="$LIBS"
5204 LIBS="-lmytinfo $LIBS"
5205 cat > conftest.$ac_ext <<EOF
5206 #line 5208 "configure"
5207 #include "confdefs.h"
5208 /* Override any gcc2 internal prototype to avoid an error. */
5209 /* We use char because int might match the return type of a gcc2
5210 builtin and then its argument prototype would still apply. */
5211 char tgoto();
5212
5213 int main() {
5214 tgoto()
5215 ; return 0; }
5216 EOF
5217 if { (eval echo configure:5219: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5218 rm -rf conftest*
5219 eval "ac_cv_lib_$ac_lib_var=yes"
5220 else
5221 echo "configure: failed program was:" >&5
5222 cat conftest.$ac_ext >&5
5223 rm -rf conftest*
5224 eval "ac_cv_lib_$ac_lib_var=no"
5225 fi
5226 rm -f conftest*
5227 LIBS="$ac_save_LIBS"
5228
5229 fi
5230 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
5231 echo "$ac_t""yes" 1>&6
5232 cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"
5233 else
5234 echo "$ac_t""no" 1>&6
5235 fi
5236
5237 fi
5238 ;;
5239 esac
5240
5241 LIBS="$cf_ncurses_LIBS $LIBS"
5242
5243 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
5244 then
5245 LIBS="-L$cf_cv_curses_dir/lib -l$cf_nculib_root $LIBS"
5246 else
5247
5248 eval 'cf_cv_have_lib_'$cf_nculib_root'=no'
5249 cf_libdir=""
5250 echo $ac_n "checking for initscr""... $ac_c" 1>&6
5251 echo "configure:5253: checking for initscr" >&5
5252 if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then
5253 echo $ac_n "(cached) $ac_c" 1>&6
5254 else
5255 cat > conftest.$ac_ext <<EOF
5256 #line 5258 "configure"
5257 #include "confdefs.h"
5258 /* System header to define __stub macros and hopefully few prototypes,
5259 which can conflict with char initscr(); below. */
5260 #include <assert.h>
5261 /* Override any gcc2 internal prototype to avoid an error. */
5262 /* We use char because int might match the return type of a gcc2
5263 builtin and then its argument prototype would still apply. */
5264 char initscr();
5265
5266 int main() {
5267
5268 /* The GNU C library defines this for functions which it implements
5269 to always fail with ENOSYS. Some functions are actually named
5270 something starting with __ and the normal name is an alias. */
5271 #if defined (__stub_initscr) || defined (__stub___initscr)
5272 choke me
5273 #else
5274 initscr();
5275 #endif
5276
5277 ; return 0; }
5278 EOF
5279 if { (eval echo configure:5281: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5280 rm -rf conftest*
5281 eval "ac_cv_func_initscr=yes"
5282 else
5283 echo "configure: failed program was:" >&5
5284 cat conftest.$ac_ext >&5
5285 rm -rf conftest*
5286 eval "ac_cv_func_initscr=no"
5287 fi
5288 rm -f conftest*
5289 fi
5290
5291 if eval "test \"`echo '$ac_cv_func_'initscr`\" = yes"; then
5292 echo "$ac_t""yes" 1>&6
5293 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
5294 else
5295 echo "$ac_t""no" 1>&6
5296
5297 cf_save_LIBS="$LIBS"
5298 echo $ac_n "checking for initscr in -l$cf_nculib_root""... $ac_c" 1>&6
5299 echo "configure:5301: checking for initscr in -l$cf_nculib_root" >&5
5300 LIBS="-l$cf_nculib_root $LIBS"
5301 cat > conftest.$ac_ext <<EOF
5302 #line 5304 "configure"
5303 #include "confdefs.h"
5304 #include <${cf_cv_ncurses_header-curses.h}>
5305 int main() {
5306 initscr()
5307 ; return 0; }
5308 EOF
5309 if { (eval echo configure:5311: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5310 rm -rf conftest*
5311 echo "$ac_t""yes" 1>&6
5312 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
5313
5314 else
5315 echo "configure: failed program was:" >&5
5316 cat conftest.$ac_ext >&5
5317 rm -rf conftest*
5318 echo "$ac_t""no" 1>&6
5319 cf_search=""
5320
5321 test -d $HOME && {
5322 test -n "$verbose" && echo " ... testing lib-directories under $HOME"
5323 test -d $HOME/lib && cf_search="$cf_search $HOME/lib"
5324 test -d $HOME/lib/$cf_nculib_root && cf_search="$cf_search $HOME/lib/$cf_nculib_root"
5325 test -d $HOME/lib/$cf_nculib_root/lib && cf_search="$cf_search $HOME/lib/$cf_nculib_root/lib"
5326 }
5327
5328 # For other stuff under the home directory, it should be sufficient to put
5329 # a symbolic link for $HOME/$cf_nculib_root to the actual package location:
5330 test -d $HOME/$cf_nculib_root && {
5331 test -n "$verbose" && echo " ... testing lib-directories under $HOME/$cf_nculib_root"
5332 test -d $HOME/$cf_nculib_root/lib && cf_search="$cf_search $HOME/$cf_nculib_root/lib"
5333 test -d $HOME/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search $HOME/$cf_nculib_root/lib/$cf_nculib_root"
5334 }
5335
5336 test "$prefix" != /usr/local && \
5337 test -d /usr/local && {
5338 test -n "$verbose" && echo " ... testing lib-directories under /usr/local"
5339 test -d /usr/local/lib && cf_search="$cf_search /usr/local/lib"
5340 test -d /usr/local/lib/$cf_nculib_root && cf_search="$cf_search /usr/local/lib/$cf_nculib_root"
5341 test -d /usr/local/lib/$cf_nculib_root/lib && cf_search="$cf_search /usr/local/lib/$cf_nculib_root/lib"
5342 test -d /usr/local/$cf_nculib_root/lib && cf_search="$cf_search /usr/local/$cf_nculib_root/lib"
5343 test -d /usr/local/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search /usr/local/$cf_nculib_root/lib/$cf_nculib_root"
5344 }
5345
5346 test "$prefix" != NONE && \
5347 test -d $prefix && {
5348 test -n "$verbose" && echo " ... testing lib-directories under $prefix"
5349 test -d $prefix/lib && cf_search="$cf_search $prefix/lib"
5350 test -d $prefix/lib/$cf_nculib_root && cf_search="$cf_search $prefix/lib/$cf_nculib_root"
5351 test -d $prefix/lib/$cf_nculib_root/lib && cf_search="$cf_search $prefix/lib/$cf_nculib_root/lib"
5352 test -d $prefix/$cf_nculib_root/lib && cf_search="$cf_search $prefix/$cf_nculib_root/lib"
5353 test -d $prefix/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search $prefix/$cf_nculib_root/lib/$cf_nculib_root"
5354 }
5355
5356 test "$prefix" != /opt && \
5357 test -d /opt && {
5358 test -n "$verbose" && echo " ... testing lib-directories under /opt"
5359 test -d /opt/lib && cf_search="$cf_search /opt/lib"
5360 test -d /opt/lib/$cf_nculib_root && cf_search="$cf_search /opt/lib/$cf_nculib_root"
5361 test -d /opt/lib/$cf_nculib_root/lib && cf_search="$cf_search /opt/lib/$cf_nculib_root/lib"
5362 test -d /opt/$cf_nculib_root/lib && cf_search="$cf_search /opt/$cf_nculib_root/lib"
5363 test -d /opt/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search /opt/$cf_nculib_root/lib/$cf_nculib_root"
5364 }
5365
5366 test "$prefix" != /usr && \
5367 test -d /usr && {
5368 test -n "$verbose" && echo " ... testing lib-directories under /usr"
5369 test -d /usr/lib && cf_search="$cf_search /usr/lib"
5370 test -d /usr/lib/$cf_nculib_root && cf_search="$cf_search /usr/lib/$cf_nculib_root"
5371 test -d /usr/lib/$cf_nculib_root/lib && cf_search="$cf_search /usr/lib/$cf_nculib_root/lib"
5372 test -d /usr/$cf_nculib_root/lib && cf_search="$cf_search /usr/$cf_nculib_root/lib"
5373 }
5374
5375 for cf_libdir in $cf_search
5376 do
5377 echo $ac_n "checking for -l$cf_nculib_root in $cf_libdir""... $ac_c" 1>&6
5378 echo "configure:5380: checking for -l$cf_nculib_root in $cf_libdir" >&5
5379 LIBS="-L$cf_libdir -l$cf_nculib_root $cf_save_LIBS"
5380 cat > conftest.$ac_ext <<EOF
5381 #line 5383 "configure"
5382 #include "confdefs.h"
5383 #include <${cf_cv_ncurses_header-curses.h}>
5384 int main() {
5385 initscr()
5386 ; return 0; }
5387 EOF
5388 if { (eval echo configure:5390: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5389 rm -rf conftest*
5390 echo "$ac_t""yes" 1>&6
5391 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
5392 break
5393 else
5394 echo "configure: failed program was:" >&5
5395 cat conftest.$ac_ext >&5
5396 rm -rf conftest*
5397 echo "$ac_t""no" 1>&6
5398 LIBS="$cf_save_LIBS"
5399 fi
5400 rm -f conftest*
5401 done
5402
5403 fi
5404 rm -f conftest*
5405
5406 fi
5407
5408 eval 'cf_found_library=$cf_cv_have_lib_'$cf_nculib_root
5409
5410 if test $cf_found_library = no ; then
5411 { echo "configure: error: Cannot link $cf_nculib_root library" 1>&2; exit 1; }
5412 fi
5413
5414
5415 fi
5416
5417 if test -n "$cf_ncurses_LIBS" ; then
5418 echo $ac_n "checking if we can link $cf_nculib_root without $cf_ncurses_LIBS""... $ac_c" 1>&6
5419 echo "configure:5421: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
5420 cf_ncurses_SAVE="$LIBS"
5421 for p in $cf_ncurses_LIBS ; do
5422 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
5423 if test "$q" != "$LIBS" ; then
5424 LIBS="$q"
5425 fi
5426 done
5427 cat > conftest.$ac_ext <<EOF
5428 #line 5430 "configure"
5429 #include "confdefs.h"
5430 #include <${cf_cv_ncurses_header-curses.h}>
5431 int main() {
5432 initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
5433 ; return 0; }
5434 EOF
5435 if { (eval echo configure:5437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5436 rm -rf conftest*
5437 echo "$ac_t""yes" 1>&6
5438 else
5439 echo "configure: failed program was:" >&5
5440 cat conftest.$ac_ext >&5
5441 rm -rf conftest*
5442 echo "$ac_t""no" 1>&6
5443 LIBS="$cf_ncurses_SAVE"
5444 fi
5445 rm -f conftest*
5446 fi
5447
5448
5449 cf_nculib_ROOT=`echo "HAVE_LIB$cf_nculib_root" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
5450
5451 cat >> confdefs.h <<EOF
5452 #define $cf_nculib_ROOT 1
5453 EOF
5454
5455
5456 LIB_ROOTNAME=cdkw
5457 ;;
5458 pdcurses) #(vi
5459 if test "$no_x" = yes; then
5460 # Not all programs may use this symbol, but it does not hurt to define it.
5461 cat >> confdefs.h <<\EOF
5462 #define X_DISPLAY_MISSING 1
5463 EOF
5464
5465 X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
5466 else
5467 if test -n "$x_includes"; then
5468 X_CFLAGS="$X_CFLAGS -I$x_includes"
5469 fi
5470
5471 # It would also be nice to do this for all -L options, not just this one.
5472 if test -n "$x_libraries"; then
5473 X_LIBS="$X_LIBS -L$x_libraries"
5474 # For Solaris; some versions of Sun CC require a space after -R and
5475 # others require no space. Words are not sufficient . . . .
5476 case "`(uname -sr) 2>/dev/null`" in
5477 "SunOS 5"*)
5478 echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
5479 echo "configure:5481: checking whether -R must be followed by a space" >&5
5480 ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
5481 cat > conftest.$ac_ext <<EOF
5482 #line 5484 "configure"
5483 #include "confdefs.h"
5484
5485 int main() {
5486
5487 ; return 0; }
5488 EOF
5489 if { (eval echo configure:5491: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5490 rm -rf conftest*
5491 ac_R_nospace=yes
5492 else
5493 echo "configure: failed program was:" >&5
5494 cat conftest.$ac_ext >&5
5495 rm -rf conftest*
5496 ac_R_nospace=no
5497 fi
5498 rm -f conftest*
5499 if test $ac_R_nospace = yes; then
5500 echo "$ac_t""no" 1>&6
5501 X_LIBS="$X_LIBS -R$x_libraries"
5502 else
5503 LIBS="$ac_xsave_LIBS -R $x_libraries"
5504 cat > conftest.$ac_ext <<EOF
5505 #line 5507 "configure"
5506 #include "confdefs.h"
5507
5508 int main() {
5509
5510 ; return 0; }
5511 EOF
5512 if { (eval echo configure:5514: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5513 rm -rf conftest*
5514 ac_R_space=yes
5515 else
5516 echo "configure: failed program was:" >&5
5517 cat conftest.$ac_ext >&5
5518 rm -rf conftest*
5519 ac_R_space=no
5520 fi
5521 rm -f conftest*
5522 if test $ac_R_space = yes; then
5523 echo "$ac_t""yes" 1>&6
5524 X_LIBS="$X_LIBS -R $x_libraries"
5525 else
5526 echo "$ac_t""neither works" 1>&6
5527 fi
5528 fi
5529 LIBS="$ac_xsave_LIBS"
5530 esac
5531 fi
5532
5533 # Check for system-dependent libraries X programs must link with.
5534 # Do this before checking for the system-independent R6 libraries
5535 # (-lICE), since we may need -lsocket or whatever for X linking.
5536
5537 if test "$ISC" = yes; then
5538 X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
5539 else
5540 # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X
5541 # libraries were built with DECnet support. And karl@cs.umb.edu says
5542 # the Alpha needs dnet_stub (dnet does not exist).
5543 echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
5544 echo "configure:5546: checking for dnet_ntoa in -ldnet" >&5
5545 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
5546 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
5547 echo $ac_n "(cached) $ac_c" 1>&6
5548 else
5549 ac_save_LIBS="$LIBS"
5550 LIBS="-ldnet $LIBS"
5551 cat > conftest.$ac_ext <<EOF
5552 #line 5554 "configure"
5553 #include "confdefs.h"
5554 /* Override any gcc2 internal prototype to avoid an error. */
5555 /* We use char because int might match the return type of a gcc2
5556 builtin and then its argument prototype would still apply. */
5557 char dnet_ntoa();
5558
5559 int main() {
5560 dnet_ntoa()
5561 ; return 0; }
5562 EOF
5563 if { (eval echo configure:5565: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5564 rm -rf conftest*
5565 eval "ac_cv_lib_$ac_lib_var=yes"
5566 else
5567 echo "configure: failed program was:" >&5
5568 cat conftest.$ac_ext >&5
5569 rm -rf conftest*
5570 eval "ac_cv_lib_$ac_lib_var=no"
5571 fi
5572 rm -f conftest*
5573 LIBS="$ac_save_LIBS"
5574
5575 fi
5576 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
5577 echo "$ac_t""yes" 1>&6
5578 X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
5579 else
5580 echo "$ac_t""no" 1>&6
5581 fi
5582
5583 if test $ac_cv_lib_dnet_dnet_ntoa = no; then
5584 echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
5585 echo "configure:5587: checking for dnet_ntoa in -ldnet_stub" >&5
5586 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
5587 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
5588 echo $ac_n "(cached) $ac_c" 1>&6
5589 else
5590 ac_save_LIBS="$LIBS"
5591 LIBS="-ldnet_stub $LIBS"
5592 cat > conftest.$ac_ext <<EOF
5593 #line 5595 "configure"
5594 #include "confdefs.h"
5595 /* Override any gcc2 internal prototype to avoid an error. */
5596 /* We use char because int might match the return type of a gcc2
5597 builtin and then its argument prototype would still apply. */
5598 char dnet_ntoa();
5599
5600 int main() {
5601 dnet_ntoa()
5602 ; return 0; }
5603 EOF
5604 if { (eval echo configure:5606: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5605 rm -rf conftest*
5606 eval "ac_cv_lib_$ac_lib_var=yes"
5607 else
5608 echo "configure: failed program was:" >&5
5609 cat conftest.$ac_ext >&5
5610 rm -rf conftest*
5611 eval "ac_cv_lib_$ac_lib_var=no"
5612 fi
5613 rm -f conftest*
5614 LIBS="$ac_save_LIBS"
5615
5616 fi
5617 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
5618 echo "$ac_t""yes" 1>&6
5619 X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
5620 else
5621 echo "$ac_t""no" 1>&6
5622 fi
5623
5624 fi
5625
5626 # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
5627 # to get the SysV transport functions.
5628 # chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4)
5629 # needs -lnsl.
5630 # The nsl library prevents programs from opening the X display
5631 # on Irix 5.2, according to dickey@clark.net.
5632 echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
5633 echo "configure:5635: checking for gethostbyname" >&5
5634 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
5635 echo $ac_n "(cached) $ac_c" 1>&6
5636 else
5637 cat > conftest.$ac_ext <<EOF
5638 #line 5640 "configure"
5639 #include "confdefs.h"
5640 /* System header to define __stub macros and hopefully few prototypes,
5641 which can conflict with char gethostbyname(); below. */
5642 #include <assert.h>
5643 /* Override any gcc2 internal prototype to avoid an error. */
5644 /* We use char because int might match the return type of a gcc2
5645 builtin and then its argument prototype would still apply. */
5646 char gethostbyname();
5647
5648 int main() {
5649
5650 /* The GNU C library defines this for functions which it implements
5651 to always fail with ENOSYS. Some functions are actually named
5652 something starting with __ and the normal name is an alias. */
5653 #if defined (__stub_gethostbyname) || defined (__stub___gethostbyname)
5654 choke me
5655 #else
5656 gethostbyname();
5657 #endif
5658
5659 ; return 0; }
5660 EOF
5661 if { (eval echo configure:5663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5662 rm -rf conftest*
5663 eval "ac_cv_func_gethostbyname=yes"
5664 else
5665 echo "configure: failed program was:" >&5
5666 cat conftest.$ac_ext >&5
5667 rm -rf conftest*
5668 eval "ac_cv_func_gethostbyname=no"
5669 fi
5670 rm -f conftest*
5671 fi
5672
5673 if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then
5674 echo "$ac_t""yes" 1>&6
5675 :
5676 else
5677 echo "$ac_t""no" 1>&6
5678 fi
5679
5680 if test $ac_cv_func_gethostbyname = no; then
5681 echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
5682 echo "configure:5684: checking for gethostbyname in -lnsl" >&5
5683 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
5684 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
5685 echo $ac_n "(cached) $ac_c" 1>&6
5686 else
5687 ac_save_LIBS="$LIBS"
5688 LIBS="-lnsl $LIBS"
5689 cat > conftest.$ac_ext <<EOF
5690 #line 5692 "configure"
5691 #include "confdefs.h"
5692 /* Override any gcc2 internal prototype to avoid an error. */
5693 /* We use char because int might match the return type of a gcc2
5694 builtin and then its argument prototype would still apply. */
5695 char gethostbyname();
5696
5697 int main() {
5698 gethostbyname()
5699 ; return 0; }
5700 EOF
5701 if { (eval echo configure:5703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5702 rm -rf conftest*
5703 eval "ac_cv_lib_$ac_lib_var=yes"
5704 else
5705 echo "configure: failed program was:" >&5
5706 cat conftest.$ac_ext >&5
5707 rm -rf conftest*
5708 eval "ac_cv_lib_$ac_lib_var=no"
5709 fi
5710 rm -f conftest*
5711 LIBS="$ac_save_LIBS"
5712
5713 fi
5714 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
5715 echo "$ac_t""yes" 1>&6
5716 X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
5717 else
5718 echo "$ac_t""no" 1>&6
5719 fi
5720
5721 fi
5722
5723 # lieder@skyler.mavd.honeywell.com says without -lsocket,
5724 # socket/setsockopt and other routines are undefined under SCO ODT
5725 # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary
5726 # on later versions), says simon@lia.di.epfl.ch: it contains
5727 # gethostby* variants that don't use the nameserver (or something).
5728 # -lsocket must be given before -lnsl if both are needed.
5729 # We assume that if connect needs -lnsl, so does gethostbyname.
5730 echo $ac_n "checking for connect""... $ac_c" 1>&6
5731 echo "configure:5733: checking for connect" >&5
5732 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
5733 echo $ac_n "(cached) $ac_c" 1>&6
5734 else
5735 cat > conftest.$ac_ext <<EOF
5736 #line 5738 "configure"
5737 #include "confdefs.h"
5738 /* System header to define __stub macros and hopefully few prototypes,
5739 which can conflict with char connect(); below. */
5740 #include <assert.h>
5741 /* Override any gcc2 internal prototype to avoid an error. */
5742 /* We use char because int might match the return type of a gcc2
5743 builtin and then its argument prototype would still apply. */
5744 char connect();
5745
5746 int main() {
5747
5748 /* The GNU C library defines this for functions which it implements
5749 to always fail with ENOSYS. Some functions are actually named
5750 something starting with __ and the normal name is an alias. */
5751 #if defined (__stub_connect) || defined (__stub___connect)
5752 choke me
5753 #else
5754 connect();
5755 #endif
5756
5757 ; return 0; }
5758 EOF
5759 if { (eval echo configure:5761: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5760 rm -rf conftest*
5761 eval "ac_cv_func_connect=yes"
5762 else
5763 echo "configure: failed program was:" >&5
5764 cat conftest.$ac_ext >&5
5765 rm -rf conftest*
5766 eval "ac_cv_func_connect=no"
5767 fi
5768 rm -f conftest*
5769 fi
5770
5771 if eval "test \"`echo '$ac_cv_func_'connect`\" = yes"; then
5772 echo "$ac_t""yes" 1>&6
5773 :
5774 else
5775 echo "$ac_t""no" 1>&6
5776 fi
5777
5778 if test $ac_cv_func_connect = no; then
5779 echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
5780 echo "configure:5782: checking for connect in -lsocket" >&5
5781 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
5782 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
5783 echo $ac_n "(cached) $ac_c" 1>&6
5784 else
5785 ac_save_LIBS="$LIBS"
5786 LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
5787 cat > conftest.$ac_ext <<EOF
5788 #line 5790 "configure"
5789 #include "confdefs.h"
5790 /* Override any gcc2 internal prototype to avoid an error. */
5791 /* We use char because int might match the return type of a gcc2
5792 builtin and then its argument prototype would still apply. */
5793 char connect();
5794
5795 int main() {
5796 connect()
5797 ; return 0; }
5798 EOF
5799 if { (eval echo configure:5801: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5800 rm -rf conftest*
5801 eval "ac_cv_lib_$ac_lib_var=yes"
5802 else
5803 echo "configure: failed program was:" >&5
5804 cat conftest.$ac_ext >&5
5805 rm -rf conftest*
5806 eval "ac_cv_lib_$ac_lib_var=no"
5807 fi
5808 rm -f conftest*
5809 LIBS="$ac_save_LIBS"
5810
5811 fi
5812 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
5813 echo "$ac_t""yes" 1>&6
5814 X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
5815 else
5816 echo "$ac_t""no" 1>&6
5817 fi
5818
5819 fi
5820
5821 # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
5822 echo $ac_n "checking for remove""... $ac_c" 1>&6
5823 echo "configure:5825: checking for remove" >&5
5824 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then
5825 echo $ac_n "(cached) $ac_c" 1>&6
5826 else
5827 cat > conftest.$ac_ext <<EOF
5828 #line 5830 "configure"
5829 #include "confdefs.h"
5830 /* System header to define __stub macros and hopefully few prototypes,
5831 which can conflict with char remove(); below. */
5832 #include <assert.h>
5833 /* Override any gcc2 internal prototype to avoid an error. */
5834 /* We use char because int might match the return type of a gcc2
5835 builtin and then its argument prototype would still apply. */
5836 char remove();
5837
5838 int main() {
5839
5840 /* The GNU C library defines this for functions which it implements
5841 to always fail with ENOSYS. Some functions are actually named
5842 something starting with __ and the normal name is an alias. */
5843 #if defined (__stub_remove) || defined (__stub___remove)
5844 choke me
5845 #else
5846 remove();
5847 #endif
5848
5849 ; return 0; }
5850 EOF
5851 if { (eval echo configure:5853: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5852 rm -rf conftest*
5853 eval "ac_cv_func_remove=yes"
5854 else
5855 echo "configure: failed program was:" >&5
5856 cat conftest.$ac_ext >&5
5857 rm -rf conftest*
5858 eval "ac_cv_func_remove=no"
5859 fi
5860 rm -f conftest*
5861 fi
5862
5863 if eval "test \"`echo '$ac_cv_func_'remove`\" = yes"; then
5864 echo "$ac_t""yes" 1>&6
5865 :
5866 else
5867 echo "$ac_t""no" 1>&6
5868 fi
5869
5870 if test $ac_cv_func_remove = no; then
5871 echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
5872 echo "configure:5874: checking for remove in -lposix" >&5
5873 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
5874 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
5875 echo $ac_n "(cached) $ac_c" 1>&6
5876 else
5877 ac_save_LIBS="$LIBS"
5878 LIBS="-lposix $LIBS"
5879 cat > conftest.$ac_ext <<EOF
5880 #line 5882 "configure"
5881 #include "confdefs.h"
5882 /* Override any gcc2 internal prototype to avoid an error. */
5883 /* We use char because int might match the return type of a gcc2
5884 builtin and then its argument prototype would still apply. */
5885 char remove();
5886
5887 int main() {
5888 remove()
5889 ; return 0; }
5890 EOF
5891 if { (eval echo configure:5893: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5892 rm -rf conftest*
5893 eval "ac_cv_lib_$ac_lib_var=yes"
5894 else
5895 echo "configure: failed program was:" >&5
5896 cat conftest.$ac_ext >&5
5897 rm -rf conftest*
5898 eval "ac_cv_lib_$ac_lib_var=no"
5899 fi
5900 rm -f conftest*
5901 LIBS="$ac_save_LIBS"
5902
5903 fi
5904 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
5905 echo "$ac_t""yes" 1>&6
5906 X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
5907 else
5908 echo "$ac_t""no" 1>&6
5909 fi
5910
5911 fi
5912
5913 # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
5914 echo $ac_n "checking for shmat""... $ac_c" 1>&6
5915 echo "configure:5917: checking for shmat" >&5
5916 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then
5917 echo $ac_n "(cached) $ac_c" 1>&6
5918 else
5919 cat > conftest.$ac_ext <<EOF
5920 #line 5922 "configure"
5921 #include "confdefs.h"
5922 /* System header to define __stub macros and hopefully few prototypes,
5923 which can conflict with char shmat(); below. */
5924 #include <assert.h>
5925 /* Override any gcc2 internal prototype to avoid an error. */
5926 /* We use char because int might match the return type of a gcc2
5927 builtin and then its argument prototype would still apply. */
5928 char shmat();
5929
5930 int main() {
5931
5932 /* The GNU C library defines this for functions which it implements
5933 to always fail with ENOSYS. Some functions are actually named
5934 something starting with __ and the normal name is an alias. */
5935 #if defined (__stub_shmat) || defined (__stub___shmat)
5936 choke me
5937 #else
5938 shmat();
5939 #endif
5940
5941 ; return 0; }
5942 EOF
5943 if { (eval echo configure:5945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5944 rm -rf conftest*
5945 eval "ac_cv_func_shmat=yes"
5946 else
5947 echo "configure: failed program was:" >&5
5948 cat conftest.$ac_ext >&5
5949 rm -rf conftest*
5950 eval "ac_cv_func_shmat=no"
5951 fi
5952 rm -f conftest*
5953 fi
5954
5955 if eval "test \"`echo '$ac_cv_func_'shmat`\" = yes"; then
5956 echo "$ac_t""yes" 1>&6
5957 :
5958 else
5959 echo "$ac_t""no" 1>&6
5960 fi
5961
5962 if test $ac_cv_func_shmat = no; then
5963 echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
5964 echo "configure:5966: checking for shmat in -lipc" >&5
5965 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
5966 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
5967 echo $ac_n "(cached) $ac_c" 1>&6
5968 else
5969 ac_save_LIBS="$LIBS"
5970 LIBS="-lipc $LIBS"
5971 cat > conftest.$ac_ext <<EOF
5972 #line 5974 "configure"
5973 #include "confdefs.h"
5974 /* Override any gcc2 internal prototype to avoid an error. */
5975 /* We use char because int might match the return type of a gcc2
5976 builtin and then its argument prototype would still apply. */
5977 char shmat();
5978
5979 int main() {
5980 shmat()
5981 ; return 0; }
5982 EOF
5983 if { (eval echo configure:5985: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
5984 rm -rf conftest*
5985 eval "ac_cv_lib_$ac_lib_var=yes"
5986 else
5987 echo "configure: failed program was:" >&5
5988 cat conftest.$ac_ext >&5
5989 rm -rf conftest*
5990 eval "ac_cv_lib_$ac_lib_var=no"
5991 fi
5992 rm -f conftest*
5993 LIBS="$ac_save_LIBS"
5994
5995 fi
5996 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
5997 echo "$ac_t""yes" 1>&6
5998 X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
5999 else
6000 echo "$ac_t""no" 1>&6
6001 fi
6002
6003 fi
6004 fi
6005
6006 # Check for libraries that X11R6 Xt/Xaw programs need.
6007 ac_save_LDFLAGS="$LDFLAGS"
6008 test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
6009 # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
6010 # check for ICE first), but we must link in the order -lSM -lICE or
6011 # we get undefined symbols. So assume we have SM if we have ICE.
6012 # These have to be linked with before -lX11, unlike the other
6013 # libraries we check for below, so use a different variable.
6014 # --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
6015 echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
6016 echo "configure:6018: checking for IceConnectionNumber in -lICE" >&5
6017 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
6018 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
6019 echo $ac_n "(cached) $ac_c" 1>&6
6020 else
6021 ac_save_LIBS="$LIBS"
6022 LIBS="-lICE $X_EXTRA_LIBS $LIBS"
6023 cat > conftest.$ac_ext <<EOF
6024 #line 6026 "configure"
6025 #include "confdefs.h"
6026 /* Override any gcc2 internal prototype to avoid an error. */
6027 /* We use char because int might match the return type of a gcc2
6028 builtin and then its argument prototype would still apply. */
6029 char IceConnectionNumber();
6030
6031 int main() {
6032 IceConnectionNumber()
6033 ; return 0; }
6034 EOF
6035 if { (eval echo configure:6037: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
6036 rm -rf conftest*
6037 eval "ac_cv_lib_$ac_lib_var=yes"
6038 else
6039 echo "configure: failed program was:" >&5
6040 cat conftest.$ac_ext >&5
6041 rm -rf conftest*
6042 eval "ac_cv_lib_$ac_lib_var=no"
6043 fi
6044 rm -f conftest*
6045 LIBS="$ac_save_LIBS"
6046
6047 fi
6048 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
6049 echo "$ac_t""yes" 1>&6
6050 X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
6051 else
6052 echo "$ac_t""no" 1>&6
6053 fi
6054
6055 LDFLAGS="$ac_save_LDFLAGS"
6056
6057 fi
6058
6059
6060
6061
6062
6063 # SYSTEM_NAME=`echo "$cf_cv_system_name"|tr ' ' -`
6064
6065 cf_have_X_LIBS=no
6066
6067 LDFLAGS="$X_LIBS $LDFLAGS"
6068
6069 test -n "$verbose" && echo " checking additions to CFLAGS" 1>&6
6070
6071 cf_check_cflags="$CFLAGS"
6072 cf_check_cppflags="$CPPFLAGS"
6073
6074 cf_fix_cppflags=no
6075 cf_new_cflags=
6076 cf_new_cppflags=
6077 cf_new_extra_cppflags=
6078
6079 for cf_add_cflags in $X_CFLAGS
6080 do
6081 case $cf_fix_cppflags in
6082 no)
6083 case $cf_add_cflags in #(vi
6084 -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
6085 case $cf_add_cflags in
6086 -D*)
6087 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
6088
6089 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
6090 && test -z "${cf_tst_cflags}" \
6091 && cf_fix_cppflags=yes
6092
6093 if test $cf_fix_cppflags = yes ; then
6094 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
6095 continue
6096 elif test "${cf_tst_cflags}" = "\"'" ; then
6097 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
6098 continue
6099 fi
6100 ;;
6101 esac
6102 case "$CPPFLAGS" in
6103 *$cf_add_cflags) #(vi
6104 ;;
6105 *) #(vi
6106 cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
6107 ;;
6108 esac
6109 ;;
6110 *)
6111 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
6112 ;;
6113 esac
6114 ;;
6115 yes)
6116 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
6117
6118 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
6119
6120 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
6121 && test -z "${cf_tst_cflags}" \
6122 && cf_fix_cppflags=no
6123 ;;
6124 esac
6125 done
6126
6127 if test -n "$cf_new_cflags" ; then
6128 test -n "$verbose" && echo " add to \$CFLAGS $cf_new_cflags" 1>&6
6129
6130 CFLAGS="$CFLAGS $cf_new_cflags"
6131 fi
6132
6133 if test -n "$cf_new_cppflags" ; then
6134 test -n "$verbose" && echo " add to \$CPPFLAGS $cf_new_cppflags" 1>&6
6135
6136 CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
6137 fi
6138
6139 if test -n "$cf_new_extra_cppflags" ; then
6140 test -n "$verbose" && echo " add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6
6141
6142 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
6143 fi
6144
6145
6146
6147
6148 if test "$cf_check_cflags" != "$CFLAGS" ; then
6149 cat > conftest.$ac_ext <<EOF
6150 #line 6152 "configure"
6151 #include "confdefs.h"
6152 #include <stdio.h>
6153 int main() {
6154 printf("Hello world");
6155 ; return 0; }
6156 EOF
6157 if { (eval echo configure:6159: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
6158 :
6159 else
6160 echo "configure: failed program was:" >&5
6161 cat conftest.$ac_ext >&5
6162 rm -rf conftest*
6163 test -n "$verbose" && echo " test-compile failed. Undoing change to \$CFLAGS" 1>&6
6164
6165 if test "$cf_check_cppflags" != "$CPPFLAGS" ; then
6166 test -n "$verbose" && echo " but keeping change to \$CPPFLAGS" 1>&6
6167
6168 fi
6169 CFLAGS="$cf_check_flags"
6170 fi
6171 rm -f conftest*
6172 fi
6173
6174
6175 echo $ac_n "checking for XOpenDisplay""... $ac_c" 1>&6
6176 echo "configure:6178: checking for XOpenDisplay" >&5
6177 if eval "test \"`echo '$''{'ac_cv_func_XOpenDisplay'+set}'`\" = set"; then
6178 echo $ac_n "(cached) $ac_c" 1>&6
6179 else
6180 cat > conftest.$ac_ext <<EOF
6181 #line 6183 "configure"
6182 #include "confdefs.h"
6183 /* System header to define __stub macros and hopefully few prototypes,
6184 which can conflict with char XOpenDisplay(); below. */
6185 #include <assert.h>
6186 /* Override any gcc2 internal prototype to avoid an error. */
6187 /* We use char because int might match the return type of a gcc2
6188 builtin and then its argument prototype would still apply. */
6189 char XOpenDisplay();
6190
6191 int main() {
6192
6193 /* The GNU C library defines this for functions which it implements
6194 to always fail with ENOSYS. Some functions are actually named
6195 something starting with __ and the normal name is an alias. */
6196 #if defined (__stub_XOpenDisplay) || defined (__stub___XOpenDisplay)
6197 choke me
6198 #else
6199 XOpenDisplay();
6200 #endif
6201
6202 ; return 0; }
6203 EOF
6204 if { (eval echo configure:6206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
6205 rm -rf conftest*
6206 eval "ac_cv_func_XOpenDisplay=yes"
6207 else
6208 echo "configure: failed program was:" >&5
6209 cat conftest.$ac_ext >&5
6210 rm -rf conftest*
6211 eval "ac_cv_func_XOpenDisplay=no"
6212 fi
6213 rm -f conftest*
6214 fi
6215
6216 if eval "test \"`echo '$ac_cv_func_'XOpenDisplay`\" = yes"; then
6217 echo "$ac_t""yes" 1>&6
6218 :
6219 else
6220 echo "$ac_t""no" 1>&6
6221
6222 echo $ac_n "checking for XOpenDisplay in -lX11""... $ac_c" 1>&6
6223 echo "configure:6225: checking for XOpenDisplay in -lX11" >&5
6224 ac_lib_var=`echo X11'_'XOpenDisplay | sed 'y%./+-%__p_%'`
6225 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
6226 echo $ac_n "(cached) $ac_c" 1>&6
6227 else
6228 ac_save_LIBS="$LIBS"
6229 LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
6230 cat > conftest.$ac_ext <<EOF
6231 #line 6233 "configure"
6232 #include "confdefs.h"
6233 /* Override any gcc2 internal prototype to avoid an error. */
6234 /* We use char because int might match the return type of a gcc2
6235 builtin and then its argument prototype would still apply. */
6236 char XOpenDisplay();
6237
6238 int main() {
6239 XOpenDisplay()
6240 ; return 0; }
6241 EOF
6242 if { (eval echo configure:6244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
6243 rm -rf conftest*
6244 eval "ac_cv_lib_$ac_lib_var=yes"
6245 else
6246 echo "configure: failed program was:" >&5
6247 cat conftest.$ac_ext >&5
6248 rm -rf conftest*
6249 eval "ac_cv_lib_$ac_lib_var=no"
6250 fi
6251 rm -f conftest*
6252 LIBS="$ac_save_LIBS"
6253
6254 fi
6255 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
6256 echo "$ac_t""yes" 1>&6
6257 LIBS="-lX11 $LIBS"
6258 else
6259 echo "$ac_t""no" 1>&6
6260 fi
6261
6262 fi
6263
6264
6265 echo $ac_n "checking for XtAppInitialize""... $ac_c" 1>&6
6266 echo "configure:6268: checking for XtAppInitialize" >&5
6267 if eval "test \"`echo '$''{'ac_cv_func_XtAppInitialize'+set}'`\" = set"; then
6268 echo $ac_n "(cached) $ac_c" 1>&6
6269 else
6270 cat > conftest.$ac_ext <<EOF
6271 #line 6273 "configure"
6272 #include "confdefs.h"
6273 /* System header to define __stub macros and hopefully few prototypes,
6274 which can conflict with char XtAppInitialize(); below. */
6275 #include <assert.h>
6276 /* Override any gcc2 internal prototype to avoid an error. */
6277 /* We use char because int might match the return type of a gcc2
6278 builtin and then its argument prototype would still apply. */
6279 char XtAppInitialize();
6280
6281 int main() {
6282
6283 /* The GNU C library defines this for functions which it implements
6284 to always fail with ENOSYS. Some functions are actually named
6285 something starting with __ and the normal name is an alias. */
6286 #if defined (__stub_XtAppInitialize) || defined (__stub___XtAppInitialize)
6287 choke me
6288 #else
6289 XtAppInitialize();
6290 #endif
6291
6292 ; return 0; }
6293 EOF
6294 if { (eval echo configure:6296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
6295 rm -rf conftest*
6296 eval "ac_cv_func_XtAppInitialize=yes"
6297 else
6298 echo "configure: failed program was:" >&5
6299 cat conftest.$ac_ext >&5
6300 rm -rf conftest*
6301 eval "ac_cv_func_XtAppInitialize=no"
6302 fi
6303 rm -f conftest*
6304 fi
6305
6306 if eval "test \"`echo '$ac_cv_func_'XtAppInitialize`\" = yes"; then
6307 echo "$ac_t""yes" 1>&6
6308 :
6309 else
6310 echo "$ac_t""no" 1>&6
6311
6312 echo $ac_n "checking for XtAppInitialize in -lXt""... $ac_c" 1>&6
6313 echo "configure:6315: checking for XtAppInitialize in -lXt" >&5
6314 ac_lib_var=`echo Xt'_'XtAppInitialize | sed 'y%./+-%__p_%'`
6315 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
6316 echo $ac_n "(cached) $ac_c" 1>&6
6317 else
6318 ac_save_LIBS="$LIBS"
6319 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
6320 cat > conftest.$ac_ext <<EOF
6321 #line 6323 "configure"
6322 #include "confdefs.h"
6323 /* Override any gcc2 internal prototype to avoid an error. */
6324 /* We use char because int might match the return type of a gcc2
6325 builtin and then its argument prototype would still apply. */
6326 char XtAppInitialize();
6327
6328 int main() {
6329 XtAppInitialize()
6330 ; return 0; }
6331 EOF
6332 if { (eval echo configure:6334: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
6333 rm -rf conftest*
6334 eval "ac_cv_lib_$ac_lib_var=yes"
6335 else
6336 echo "configure: failed program was:" >&5
6337 cat conftest.$ac_ext >&5
6338 rm -rf conftest*
6339 eval "ac_cv_lib_$ac_lib_var=no"
6340 fi
6341 rm -f conftest*
6342 LIBS="$ac_save_LIBS"
6343
6344 fi
6345 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
6346 echo "$ac_t""yes" 1>&6
6347 cat >> confdefs.h <<\EOF
6348 #define HAVE_LIBXT 1
6349 EOF
6350
6351 cf_have_X_LIBS=Xt
6352 LIBS="-lXt $X_PRE_LIBS $LIBS"
6353 else
6354 echo "$ac_t""no" 1>&6
6355 fi
6356
6357 fi
6358
6359
6360 if test $cf_have_X_LIBS = no ; then
6361 echo "configure: warning: Unable to successfully link X Toolkit library (-lXt) with
6362 test program. You will have to check and add the proper libraries by hand
6363 to makefile." 1>&2
6364 fi
6365
6366
6367 cf_x_athena=${cf_x_athena-Xaw}
6368
6369 echo $ac_n "checking if you want to link with Xaw 3d library""... $ac_c" 1>&6
6370 echo "configure:6372: checking if you want to link with Xaw 3d library" >&5
6371 withval=
6372
6373 # Check whether --with-Xaw3d or --without-Xaw3d was given.
6374 if test "${with_Xaw3d+set}" = set; then
6375 withval="$with_Xaw3d"
6376 :
6377 fi
6378
6379 if test "$withval" = yes ; then
6380 cf_x_athena=Xaw3d
6381 echo "$ac_t""yes" 1>&6
6382 else
6383 echo "$ac_t""no" 1>&6
6384 fi
6385
6386 echo $ac_n "checking if you want to link with neXT Athena library""... $ac_c" 1>&6
6387 echo "configure:6389: checking if you want to link with neXT Athena library" >&5
6388 withval=
6389
6390 # Check whether --with-neXtaw or --without-neXtaw was given.
6391 if test "${with_neXtaw+set}" = set; then
6392 withval="$with_neXtaw"
6393 :
6394 fi
6395
6396 if test "$withval" = yes ; then
6397 cf_x_athena=neXtaw
6398 echo "$ac_t""yes" 1>&6
6399 else
6400 echo "$ac_t""no" 1>&6
6401 fi
6402
6403 echo $ac_n "checking if you want to link with Athena-Plus library""... $ac_c" 1>&6
6404 echo "configure:6406: checking if you want to link with Athena-Plus library" >&5
6405 withval=
6406
6407 # Check whether --with-XawPlus or --without-XawPlus was given.
6408 if test "${with_XawPlus+set}" = set; then
6409 withval="$with_XawPlus"
6410 :
6411 fi
6412
6413 if test "$withval" = yes ; then
6414 cf_x_athena=XawPlus
6415 echo "$ac_t""yes" 1>&6
6416 else
6417 echo "$ac_t""no" 1>&6
6418 fi
6419
6420 echo $ac_n "checking for XextCreateExtension in -lXext""... $ac_c" 1>&6
6421 echo "configure:6423: checking for XextCreateExtension in -lXext" >&5
6422 ac_lib_var=`echo Xext'_'XextCreateExtension | sed 'y%./+-%__p_%'`
6423 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
6424 echo $ac_n "(cached) $ac_c" 1>&6
6425 else
6426 ac_save_LIBS="$LIBS"
6427 LIBS="-lXext $LIBS"
6428 cat > conftest.$ac_ext <<EOF
6429 #line 6431 "configure"
6430 #include "confdefs.h"
6431 /* Override any gcc2 internal prototype to avoid an error. */
6432 /* We use char because int might match the return type of a gcc2
6433 builtin and then its argument prototype would still apply. */
6434 char XextCreateExtension();
6435
6436 int main() {
6437 XextCreateExtension()
6438 ; return 0; }
6439 EOF
6440 if { (eval echo configure:6442: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
6441 rm -rf conftest*
6442 eval "ac_cv_lib_$ac_lib_var=yes"
6443 else
6444 echo "configure: failed program was:" >&5
6445 cat conftest.$ac_ext >&5
6446 rm -rf conftest*
6447 eval "ac_cv_lib_$ac_lib_var=no"
6448 fi
6449 rm -f conftest*
6450 LIBS="$ac_save_LIBS"
6451
6452 fi
6453 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
6454 echo "$ac_t""yes" 1>&6
6455 LIBS="-lXext $LIBS"
6456 else
6457 echo "$ac_t""no" 1>&6
6458 fi
6459
6460
6461 cf_x_athena_lib=""
6462
6463
6464 cf_x_athena_root=$cf_x_athena
6465 cf_x_athena_include=""
6466
6467 for cf_path in default \
6468 /usr/contrib/X11R6 \
6469 /usr/contrib/X11R5 \
6470 /usr/lib/X11R5 \
6471 /usr/local
6472 do
6473 if test -z "$cf_x_athena_include" ; then
6474 cf_save="$CPPFLAGS"
6475 cf_test=X11/$cf_x_athena_root/SimpleMenu.h
6476 if test $cf_path != default ; then
6477 CPPFLAGS="-I$cf_path/include $cf_save"
6478 echo $ac_n "checking for $cf_test in $cf_path""... $ac_c" 1>&6
6479 echo "configure:6481: checking for $cf_test in $cf_path" >&5
6480 else
6481 echo $ac_n "checking for $cf_test""... $ac_c" 1>&6
6482 echo "configure:6484: checking for $cf_test" >&5
6483 fi
6484 cat > conftest.$ac_ext <<EOF
6485 #line 6487 "configure"
6486 #include "confdefs.h"
6487
6488 #include <X11/Intrinsic.h>
6489 #include <$cf_test>
6490 int main() {
6491
6492 ; return 0; }
6493 EOF
6494 if { (eval echo configure:6496: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
6495 rm -rf conftest*
6496 cf_result=yes
6497 else
6498 echo "configure: failed program was:" >&5
6499 cat conftest.$ac_ext >&5
6500 rm -rf conftest*
6501 cf_result=no
6502 fi
6503 rm -f conftest*
6504 echo "$ac_t""$cf_result" 1>&6
6505 if test "$cf_result" = yes ; then
6506 cf_x_athena_include=$cf_path
6507 break
6508 else
6509 CPPFLAGS="$cf_save"
6510 fi
6511 fi
6512 done
6513
6514 if test -z "$cf_x_athena_include" ; then
6515 echo "configure: warning: Unable to successfully find Athena header files with test program" 1>&2
6516 elif test "$cf_x_athena_include" != default ; then
6517 CPPFLAGS="$CPPFLAGS -I$cf_x_athena_include"
6518 fi
6519
6520
6521 cf_x_athena_root=$cf_x_athena
6522 cf_x_athena_lib=""
6523
6524 for cf_path in default \
6525 /usr/contrib/X11R6 \
6526 /usr/contrib/X11R5 \
6527 /usr/lib/X11R5 \
6528 /usr/local
6529 do
6530 for cf_lib in \
6531 "-l$cf_x_athena_root -lXmu" \
6532 "-l$cf_x_athena_root -lXpm -lXmu" \
6533 "-l${cf_x_athena_root}_s -lXmu_s"
6534 do
6535 if test -z "$cf_x_athena_lib" ; then
6536 cf_save="$LIBS"
6537 cf_test=XawSimpleMenuAddGlobalActions
6538 if test $cf_path != default ; then
6539 LIBS="-L$cf_path/lib $cf_lib $LIBS"
6540 echo $ac_n "checking for $cf_lib in $cf_path""... $ac_c" 1>&6
6541 echo "configure:6543: checking for $cf_lib in $cf_path" >&5
6542 else
6543 LIBS="$cf_lib $LIBS"
6544 echo $ac_n "checking for $cf_test in $cf_lib""... $ac_c" 1>&6
6545 echo "configure:6547: checking for $cf_test in $cf_lib" >&5
6546 fi
6547 cf_SAVE="$LIBS"
6548 LIBS="$X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
6549 cat > conftest.$ac_ext <<EOF
6550 #line 6552 "configure"
6551 #include "confdefs.h"
6552
6553 int main() {
6554 $cf_test()
6555 ; return 0; }
6556 EOF
6557 if { (eval echo configure:6559: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
6558 rm -rf conftest*
6559 cf_result=yes
6560 else
6561 echo "configure: failed program was:" >&5
6562 cat conftest.$ac_ext >&5
6563 rm -rf conftest*
6564 cf_result=no
6565 fi
6566 rm -f conftest*
6567 echo "$ac_t""$cf_result" 1>&6
6568 if test "$cf_result" = yes ; then
6569 cf_x_athena_lib="$cf_lib"
6570 LIBS="$cf_SAVE"
6571 break
6572 else
6573 LIBS="$cf_save"
6574 fi
6575 fi
6576 done
6577 done
6578
6579 if test -z "$cf_x_athena_lib" ; then
6580 { echo "configure: error: Unable to successfully link Athena library (-l$cf_x_athena_root) with test program" 1>&2; exit 1; }
6581 fi
6582
6583
6584 cf_x_athena_LIBS=`echo "HAVE_LIB_$cf_x_athena" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
6585
6586 cat >> confdefs.h <<EOF
6587 #define $cf_x_athena_LIBS 1
6588 EOF
6589
6590
6591
6592
6593
6594 LDFLAGS="$LDFLAGS $X_LIBS"
6595
6596 test -n "$verbose" && echo " checking additions to CFLAGS" 1>&6
6597
6598 cf_check_cflags="$CFLAGS"
6599 cf_check_cppflags="$CPPFLAGS"
6600
6601 cf_fix_cppflags=no
6602 cf_new_cflags=
6603 cf_new_cppflags=
6604 cf_new_extra_cppflags=
6605
6606 for cf_add_cflags in $X_CFLAGS
6607 do
6608 case $cf_fix_cppflags in
6609 no)
6610 case $cf_add_cflags in #(vi
6611 -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
6612 case $cf_add_cflags in
6613 -D*)
6614 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
6615
6616 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
6617 && test -z "${cf_tst_cflags}" \
6618 && cf_fix_cppflags=yes
6619
6620 if test $cf_fix_cppflags = yes ; then
6621 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
6622 continue
6623 elif test "${cf_tst_cflags}" = "\"'" ; then
6624 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
6625 continue
6626 fi
6627 ;;
6628 esac
6629 case "$CPPFLAGS" in
6630 *$cf_add_cflags) #(vi
6631 ;;
6632 *) #(vi
6633 cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
6634 ;;
6635 esac
6636 ;;
6637 *)
6638 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
6639 ;;
6640 esac
6641 ;;
6642 yes)
6643 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
6644
6645 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
6646
6647 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
6648 && test -z "${cf_tst_cflags}" \
6649 && cf_fix_cppflags=no
6650 ;;
6651 esac
6652 done
6653
6654 if test -n "$cf_new_cflags" ; then
6655 test -n "$verbose" && echo " add to \$CFLAGS $cf_new_cflags" 1>&6
6656
6657 CFLAGS="$CFLAGS $cf_new_cflags"
6658 fi
6659
6660 if test -n "$cf_new_cppflags" ; then
6661 test -n "$verbose" && echo " add to \$CPPFLAGS $cf_new_cppflags" 1>&6
6662
6663 CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
6664 fi
6665
6666 if test -n "$cf_new_extra_cppflags" ; then
6667 test -n "$verbose" && echo " add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6
6668
6669 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
6670 fi
6671
6672
6673
6674
6675 if test "$cf_check_cflags" != "$CFLAGS" ; then
6676 cat > conftest.$ac_ext <<EOF
6677 #line 6679 "configure"
6678 #include "confdefs.h"
6679 #include <stdio.h>
6680 int main() {
6681 printf("Hello world");
6682 ; return 0; }
6683 EOF
6684 if { (eval echo configure:6686: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
6685 :
6686 else
6687 echo "configure: failed program was:" >&5
6688 cat conftest.$ac_ext >&5
6689 rm -rf conftest*
6690 test -n "$verbose" && echo " test-compile failed. Undoing change to \$CFLAGS" 1>&6
6691
6692 if test "$cf_check_cppflags" != "$CPPFLAGS" ; then
6693 test -n "$verbose" && echo " but keeping change to \$CPPFLAGS" 1>&6
6694
6695 fi
6696 CFLAGS="$cf_check_flags"
6697 fi
6698 rm -f conftest*
6699 fi
6700
6701 echo $ac_n "checking for XOpenDisplay in -lX11""... $ac_c" 1>&6
6702 echo "configure:6704: checking for XOpenDisplay in -lX11" >&5
6703 ac_lib_var=`echo X11'_'XOpenDisplay | sed 'y%./+-%__p_%'`
6704 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
6705 echo $ac_n "(cached) $ac_c" 1>&6
6706 else
6707 ac_save_LIBS="$LIBS"
6708 LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
6709 cat > conftest.$ac_ext <<EOF
6710 #line 6712 "configure"
6711 #include "confdefs.h"
6712 /* Override any gcc2 internal prototype to avoid an error. */
6713 /* We use char because int might match the return type of a gcc2
6714 builtin and then its argument prototype would still apply. */
6715 char XOpenDisplay();
6716
6717 int main() {
6718 XOpenDisplay()
6719 ; return 0; }
6720 EOF
6721 if { (eval echo configure:6723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
6722 rm -rf conftest*
6723 eval "ac_cv_lib_$ac_lib_var=yes"
6724 else
6725 echo "configure: failed program was:" >&5
6726 cat conftest.$ac_ext >&5
6727 rm -rf conftest*
6728 eval "ac_cv_lib_$ac_lib_var=no"
6729 fi
6730 rm -f conftest*
6731 LIBS="$ac_save_LIBS"
6732
6733 fi
6734 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
6735 echo "$ac_t""yes" 1>&6
6736 LIBS="-lX11 $LIBS"
6737 else
6738 echo "$ac_t""no" 1>&6
6739 fi
6740
6741 echo $ac_n "checking for XCurses library""... $ac_c" 1>&6
6742 echo "configure:6744: checking for XCurses library" >&5
6743 if eval "test \"`echo '$''{'cf_cv_lib_XCurses'+set}'`\" = set"; then
6744 echo $ac_n "(cached) $ac_c" 1>&6
6745 else
6746
6747 LIBS="-lXCurses $LIBS"
6748 cat > conftest.$ac_ext <<EOF
6749 #line 6751 "configure"
6750 #include "confdefs.h"
6751
6752 #include <xcurses.h>
6753 char *XCursesProgramName = "test";
6754
6755 int main() {
6756 XCursesExit();
6757 ; return 0; }
6758 EOF
6759 if { (eval echo configure:6761: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
6760 rm -rf conftest*
6761 cf_cv_lib_XCurses=yes
6762 else
6763 echo "configure: failed program was:" >&5
6764 cat conftest.$ac_ext >&5
6765 rm -rf conftest*
6766 cf_cv_lib_XCurses=no
6767 fi
6768 rm -f conftest*
6769
6770 fi
6771
6772 echo "$ac_t""$cf_cv_lib_XCurses" 1>&6
6773 if test $cf_cv_lib_XCurses = yes ; then
6774 cat >> confdefs.h <<\EOF
6775 #define UNIX 1
6776 EOF
6777
6778 cat >> confdefs.h <<\EOF
6779 #define XCURSES 1
6780 EOF
6781
6782 cat >> confdefs.h <<\EOF
6783 #define HAVE_XCURSES 1
6784 EOF
6785
6786 else
6787 { echo "configure: error: Cannot link with XCurses" 1>&2; exit 1; }
6788 fi
6789
6790 LIB_ROOTNAME=cdkX
6791 ;;
6792 *)
6793
6794
6795 echo $ac_n "checking for extra include directories""... $ac_c" 1>&6
6796 echo "configure:6798: checking for extra include directories" >&5
6797 if eval "test \"`echo '$''{'cf_cv_curses_incdir'+set}'`\" = set"; then
6798 echo $ac_n "(cached) $ac_c" 1>&6
6799 else
6800
6801 cf_cv_curses_incdir=no
6802 case $host_os in #(vi
6803 hpux10.*|hpux11.*) #(vi
6804 test -d /usr/include/curses_colr && \
6805 cf_cv_curses_incdir="-I/usr/include/curses_colr"
6806 ;;
6807 sunos3*|sunos4*)
6808 test -d /usr/5lib && \
6809 test -d /usr/5include && \
6810 cf_cv_curses_incdir="-I/usr/5include"
6811 ;;
6812 esac
6813
6814 fi
6815
6816 echo "$ac_t""$cf_cv_curses_incdir" 1>&6
6817 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$cf_cv_curses_incdir $CPPFLAGS"
6818
6819 echo $ac_n "checking if we have identified curses headers""... $ac_c" 1>&6
6820 echo "configure:6822: checking if we have identified curses headers" >&5
6821 if eval "test \"`echo '$''{'cf_cv_ncurses_header'+set}'`\" = set"; then
6822 echo $ac_n "(cached) $ac_c" 1>&6
6823 else
6824
6825 cf_cv_ncurses_header=none
6826 for cf_header in \
6827 curses.h \
6828 ncurses.h \
6829 ncurses/curses.h \
6830 ncurses/ncurses.h
6831 do
6832 cat > conftest.$ac_ext <<EOF
6833 #line 6835 "configure"
6834 #include "confdefs.h"
6835 #include <${cf_header}>
6836 int main() {
6837 initscr(); tgoto("?", 0,0)
6838 ; return 0; }
6839 EOF
6840 if { (eval echo configure:6842: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
6841 rm -rf conftest*
6842 cf_cv_ncurses_header=$cf_header; break
6843 else
6844 echo "configure: failed program was:" >&5
6845 cat conftest.$ac_ext >&5
6846 fi
6847 rm -f conftest*
6848 done
6849
6850 fi
6851
6852 echo "$ac_t""$cf_cv_ncurses_header" 1>&6
6853
6854 if test "$cf_cv_ncurses_header" = none ; then
6855 { echo "configure: error: No curses header-files found" 1>&2; exit 1; }
6856 fi
6857
6858 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
6859 for ac_hdr in $cf_cv_ncurses_header
6860 do
6861 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
6862 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
6863 echo "configure:6865: checking for $ac_hdr" >&5
6864 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
6865 echo $ac_n "(cached) $ac_c" 1>&6
6866 else
6867 cat > conftest.$ac_ext <<EOF
6868 #line 6870 "configure"
6869 #include "confdefs.h"
6870 #include <$ac_hdr>
6871 EOF
6872 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
6873 { (eval echo configure:6875: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
6874 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
6875 if test -z "$ac_err"; then
6876 rm -rf conftest*
6877 eval "ac_cv_header_$ac_safe=yes"
6878 else
6879 echo "$ac_err" >&5
6880 echo "configure: failed program was:" >&5
6881 cat conftest.$ac_ext >&5
6882 rm -rf conftest*
6883 eval "ac_cv_header_$ac_safe=no"
6884 fi
6885 rm -f conftest*
6886 fi
6887 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
6888 echo "$ac_t""yes" 1>&6
6889 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
6890 cat >> confdefs.h <<EOF
6891 #define $ac_tr_hdr 1
6892 EOF
6893
6894 else
6895 echo "$ac_t""no" 1>&6
6896 fi
6897 done
6898
6899
6900
6901
6902 echo $ac_n "checking for ncurses version""... $ac_c" 1>&6
6903 echo "configure:6905: checking for ncurses version" >&5
6904 if eval "test \"`echo '$''{'cf_cv_ncurses_version'+set}'`\" = set"; then
6905 echo $ac_n "(cached) $ac_c" 1>&6
6906 else
6907
6908 cf_cv_ncurses_version=no
6909 cf_tempfile=out$$
6910 rm -f $cf_tempfile
6911 if test "$cross_compiling" = yes; then
6912
6913
6914 # This will not work if the preprocessor splits the line after the
6915 # Autoconf token. The 'unproto' program does that.
6916 cat > conftest.$ac_ext <<EOF
6917 #include <${cf_cv_ncurses_header-curses.h}>
6918 #undef Autoconf
6919 #ifdef NCURSES_VERSION
6920 Autoconf NCURSES_VERSION
6921 #else
6922 #ifdef __NCURSES_H
6923 Autoconf "old"
6924 #endif
6925 ;
6926 #endif
6927 EOF
6928 cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
6929 { (eval echo configure:6931: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
6930 if test -f conftest.out ; then
6931 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
6932 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
6933 rm -f conftest.out
6934 fi
6935
6936 else
6937 cat > conftest.$ac_ext <<EOF
6938 #line 6940 "configure"
6939 #include "confdefs.h"
6940
6941 #include <${cf_cv_ncurses_header-curses.h}>
6942 #include <stdio.h>
6943 int main()
6944 {
6945 FILE *fp = fopen("$cf_tempfile", "w");
6946 #ifdef NCURSES_VERSION
6947 # ifdef NCURSES_VERSION_PATCH
6948 fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
6949 # else
6950 fprintf(fp, "%s\n", NCURSES_VERSION);
6951 # endif
6952 #else
6953 # ifdef __NCURSES_H
6954 fprintf(fp, "old\n");
6955 # else
6956 make an error
6957 # endif
6958 #endif
6959 exit(0);
6960 }
6961 EOF
6962 if { (eval echo configure:6964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
6963 then
6964
6965 cf_cv_ncurses_version=`cat $cf_tempfile`
6966 else
6967 echo "configure: failed program was:" >&5
6968 cat conftest.$ac_ext >&5
6969 fi
6970 rm -fr conftest*
6971 fi
6972
6973 rm -f $cf_tempfile
6974
6975 fi
6976
6977 echo "$ac_t""$cf_cv_ncurses_version" 1>&6
6978 test "$cf_cv_ncurses_version" = no || cat >> confdefs.h <<\EOF
6979 #define NCURSES 1
6980 EOF
6981
6982
6983
6984
6985 echo $ac_n "checking if we have identified curses libraries""... $ac_c" 1>&6
6986 echo "configure:6988: checking if we have identified curses libraries" >&5
6987 cat > conftest.$ac_ext <<EOF
6988 #line 6990 "configure"
6989 #include "confdefs.h"
6990 #include <${cf_cv_ncurses_header-curses.h}>
6991 int main() {
6992 initscr(); tgoto("?", 0,0)
6993 ; return 0; }
6994 EOF
6995 if { (eval echo configure:6997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
6996 rm -rf conftest*
6997 cf_result=yes
6998 else
6999 echo "configure: failed program was:" >&5
7000 cat conftest.$ac_ext >&5
7001 rm -rf conftest*
7002 cf_result=no
7003 fi
7004 rm -f conftest*
7005 echo "$ac_t""$cf_result" 1>&6
7006
7007 if test "$cf_result" = no ; then
7008 case $host_os in #(vi
7009 freebsd*) #(vi
7010 echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6
7011 echo "configure:7013: checking for tgoto in -lmytinfo" >&5
7012 ac_lib_var=`echo mytinfo'_'tgoto | sed 'y%./+-%__p_%'`
7013 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
7014 echo $ac_n "(cached) $ac_c" 1>&6
7015 else
7016 ac_save_LIBS="$LIBS"
7017 LIBS="-lmytinfo $LIBS"
7018 cat > conftest.$ac_ext <<EOF
7019 #line 7021 "configure"
7020 #include "confdefs.h"
7021 /* Override any gcc2 internal prototype to avoid an error. */
7022 /* We use char because int might match the return type of a gcc2
7023 builtin and then its argument prototype would still apply. */
7024 char tgoto();
7025
7026 int main() {
7027 tgoto()
7028 ; return 0; }
7029 EOF
7030 if { (eval echo configure:7032: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
7031 rm -rf conftest*
7032 eval "ac_cv_lib_$ac_lib_var=yes"
7033 else
7034 echo "configure: failed program was:" >&5
7035 cat conftest.$ac_ext >&5
7036 rm -rf conftest*
7037 eval "ac_cv_lib_$ac_lib_var=no"
7038 fi
7039 rm -f conftest*
7040 LIBS="$ac_save_LIBS"
7041
7042 fi
7043 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
7044 echo "$ac_t""yes" 1>&6
7045 LIBS="-lmytinfo $LIBS"
7046 else
7047 echo "$ac_t""no" 1>&6
7048 fi
7049
7050 ;;
7051 hpux10.*|hpux11.*) #(vi
7052 echo $ac_n "checking for initscr in -lcur_colr""... $ac_c" 1>&6
7053 echo "configure:7055: checking for initscr in -lcur_colr" >&5
7054 ac_lib_var=`echo cur_colr'_'initscr | sed 'y%./+-%__p_%'`
7055 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
7056 echo $ac_n "(cached) $ac_c" 1>&6
7057 else
7058 ac_save_LIBS="$LIBS"
7059 LIBS="-lcur_colr $LIBS"
7060 cat > conftest.$ac_ext <<EOF
7061 #line 7063 "configure"
7062 #include "confdefs.h"
7063 /* Override any gcc2 internal prototype to avoid an error. */
7064 /* We use char because int might match the return type of a gcc2
7065 builtin and then its argument prototype would still apply. */
7066 char initscr();
7067
7068 int main() {
7069 initscr()
7070 ; return 0; }
7071 EOF
7072 if { (eval echo configure:7074: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
7073 rm -rf conftest*
7074 eval "ac_cv_lib_$ac_lib_var=yes"
7075 else
7076 echo "configure: failed program was:" >&5
7077 cat conftest.$ac_ext >&5
7078 rm -rf conftest*
7079 eval "ac_cv_lib_$ac_lib_var=no"
7080 fi
7081 rm -f conftest*
7082 LIBS="$ac_save_LIBS"
7083
7084 fi
7085 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
7086 echo "$ac_t""yes" 1>&6
7087
7088 LIBS="-lcur_colr $LIBS"
7089 ac_cv_func_initscr=yes
7090
7091 else
7092 echo "$ac_t""no" 1>&6
7093
7094 echo $ac_n "checking for initscr in -lHcurses""... $ac_c" 1>&6
7095 echo "configure:7097: checking for initscr in -lHcurses" >&5
7096 ac_lib_var=`echo Hcurses'_'initscr | sed 'y%./+-%__p_%'`
7097 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
7098 echo $ac_n "(cached) $ac_c" 1>&6
7099 else
7100 ac_save_LIBS="$LIBS"
7101 LIBS="-lHcurses $LIBS"
7102 cat > conftest.$ac_ext <<EOF
7103 #line 7105 "configure"
7104 #include "confdefs.h"
7105 /* Override any gcc2 internal prototype to avoid an error. */
7106 /* We use char because int might match the return type of a gcc2
7107 builtin and then its argument prototype would still apply. */
7108 char initscr();
7109
7110 int main() {
7111 initscr()
7112 ; return 0; }
7113 EOF
7114 if { (eval echo configure:7116: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
7115 rm -rf conftest*
7116 eval "ac_cv_lib_$ac_lib_var=yes"
7117 else
7118 echo "configure: failed program was:" >&5
7119 cat conftest.$ac_ext >&5
7120 rm -rf conftest*
7121 eval "ac_cv_lib_$ac_lib_var=no"
7122 fi
7123 rm -f conftest*
7124 LIBS="$ac_save_LIBS"
7125
7126 fi
7127 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
7128 echo "$ac_t""yes" 1>&6
7129
7130 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
7131 LIBS="-lHcurses $LIBS"
7132 CPPFLAGS="-D__HP_CURSES -D_HP_CURSES $CPPFLAGS"
7133 ac_cv_func_initscr=yes
7134
7135 else
7136 echo "$ac_t""no" 1>&6
7137 fi
7138
7139 fi
7140
7141 ;;
7142 linux*) # Suse Linux does not follow /usr/lib convention
7143 LIBS="$LIBS -L/lib"
7144 ;;
7145 sunos3*|sunos4*)
7146 test -d /usr/5lib && \
7147 LIBS="$LIBS -L/usr/5lib -lcurses -ltermcap"
7148 ac_cv_func_initscr=yes
7149 ;;
7150 esac
7151
7152 if test ".$ac_cv_func_initscr" != .yes ; then
7153 cf_save_LIBS="$LIBS"
7154 cf_term_lib=""
7155 cf_curs_lib=""
7156
7157 if test ".${cf_cv_ncurses_version-no}" != .no
7158 then
7159 cf_check_list="ncurses curses cursesX"
7160 else
7161 cf_check_list="cursesX curses ncurses"
7162 fi
7163
7164 # Check for library containing tgoto. Do this before curses library
7165 # because it may be needed to link the test-case for initscr.
7166 echo $ac_n "checking for tgoto""... $ac_c" 1>&6
7167 echo "configure:7169: checking for tgoto" >&5
7168 if eval "test \"`echo '$''{'ac_cv_func_tgoto'+set}'`\" = set"; then
7169 echo $ac_n "(cached) $ac_c" 1>&6
7170 else
7171 cat > conftest.$ac_ext <<EOF
7172 #line 7174 "configure"
7173 #include "confdefs.h"
7174 /* System header to define __stub macros and hopefully few prototypes,
7175 which can conflict with char tgoto(); below. */
7176 #include <assert.h>
7177 /* Override any gcc2 internal prototype to avoid an error. */
7178 /* We use char because int might match the return type of a gcc2
7179 builtin and then its argument prototype would still apply. */
7180 char tgoto();
7181
7182 int main() {
7183
7184 /* The GNU C library defines this for functions which it implements
7185 to always fail with ENOSYS. Some functions are actually named
7186 something starting with __ and the normal name is an alias. */
7187 #if defined (__stub_tgoto) || defined (__stub___tgoto)
7188 choke me
7189 #else
7190 tgoto();
7191 #endif
7192
7193 ; return 0; }
7194 EOF
7195 if { (eval echo configure:7197: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
7196 rm -rf conftest*
7197 eval "ac_cv_func_tgoto=yes"
7198 else
7199 echo "configure: failed program was:" >&5
7200 cat conftest.$ac_ext >&5
7201 rm -rf conftest*
7202 eval "ac_cv_func_tgoto=no"
7203 fi
7204 rm -f conftest*
7205 fi
7206
7207 if eval "test \"`echo '$ac_cv_func_'tgoto`\" = yes"; then
7208 echo "$ac_t""yes" 1>&6
7209 cf_term_lib=predefined
7210 else
7211 echo "$ac_t""no" 1>&6
7212
7213 for cf_term_lib in $cf_check_list termcap termlib unknown
7214 do
7215 echo $ac_n "checking for tgoto in -l$cf_term_lib""... $ac_c" 1>&6
7216 echo "configure:7218: checking for tgoto in -l$cf_term_lib" >&5
7217 ac_lib_var=`echo $cf_term_lib'_'tgoto | sed 'y%./+-%__p_%'`
7218 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
7219 echo $ac_n "(cached) $ac_c" 1>&6
7220 else
7221 ac_save_LIBS="$LIBS"
7222 LIBS="-l$cf_term_lib $LIBS"
7223 cat > conftest.$ac_ext <<EOF
7224 #line 7226 "configure"
7225 #include "confdefs.h"
7226 /* Override any gcc2 internal prototype to avoid an error. */
7227 /* We use char because int might match the return type of a gcc2
7228 builtin and then its argument prototype would still apply. */
7229 char tgoto();
7230
7231 int main() {
7232 tgoto()
7233 ; return 0; }
7234 EOF
7235 if { (eval echo configure:7237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
7236 rm -rf conftest*
7237 eval "ac_cv_lib_$ac_lib_var=yes"
7238 else
7239 echo "configure: failed program was:" >&5
7240 cat conftest.$ac_ext >&5
7241 rm -rf conftest*
7242 eval "ac_cv_lib_$ac_lib_var=no"
7243 fi
7244 rm -f conftest*
7245 LIBS="$ac_save_LIBS"
7246
7247 fi
7248 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
7249 echo "$ac_t""yes" 1>&6
7250 break
7251 else
7252 echo "$ac_t""no" 1>&6
7253 fi
7254
7255 done
7256
7257 fi
7258
7259
7260 # Check for library containing initscr
7261 test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
7262 for cf_curs_lib in $cf_check_list xcurses jcurses unknown
7263 do
7264 echo $ac_n "checking for initscr in -l$cf_curs_lib""... $ac_c" 1>&6
7265 echo "configure:7267: checking for initscr in -l$cf_curs_lib" >&5
7266 ac_lib_var=`echo $cf_curs_lib'_'initscr | sed 'y%./+-%__p_%'`
7267 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
7268 echo $ac_n "(cached) $ac_c" 1>&6
7269 else
7270 ac_save_LIBS="$LIBS"
7271 LIBS="-l$cf_curs_lib $LIBS"
7272 cat > conftest.$ac_ext <<EOF
7273 #line 7275 "configure"
7274 #include "confdefs.h"
7275 /* Override any gcc2 internal prototype to avoid an error. */
7276 /* We use char because int might match the return type of a gcc2
7277 builtin and then its argument prototype would still apply. */
7278 char initscr();
7279
7280 int main() {
7281 initscr()
7282 ; return 0; }
7283 EOF
7284 if { (eval echo configure:7286: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
7285 rm -rf conftest*
7286 eval "ac_cv_lib_$ac_lib_var=yes"
7287 else
7288 echo "configure: failed program was:" >&5
7289 cat conftest.$ac_ext >&5
7290 rm -rf conftest*
7291 eval "ac_cv_lib_$ac_lib_var=no"
7292 fi
7293 rm -f conftest*
7294 LIBS="$ac_save_LIBS"
7295
7296 fi
7297 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
7298 echo "$ac_t""yes" 1>&6
7299 break
7300 else
7301 echo "$ac_t""no" 1>&6
7302 fi
7303
7304 done
7305 test $cf_curs_lib = unknown && { echo "configure: error: no curses library found" 1>&2; exit 1; }
7306
7307 LIBS="-l$cf_curs_lib $cf_save_LIBS"
7308 if test "$cf_term_lib" = unknown ; then
7309 echo $ac_n "checking if we can link with $cf_curs_lib library""... $ac_c" 1>&6
7310 echo "configure:7312: checking if we can link with $cf_curs_lib library" >&5
7311 cat > conftest.$ac_ext <<EOF
7312 #line 7314 "configure"
7313 #include "confdefs.h"
7314 #include <${cf_cv_ncurses_header-curses.h}>
7315 int main() {
7316 initscr()
7317 ; return 0; }
7318 EOF
7319 if { (eval echo configure:7321: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
7320 rm -rf conftest*
7321 cf_result=yes
7322 else
7323 echo "configure: failed program was:" >&5
7324 cat conftest.$ac_ext >&5
7325 rm -rf conftest*
7326 cf_result=no
7327 fi
7328 rm -f conftest*
7329 echo "$ac_t""$cf_result" 1>&6
7330 test $cf_result = no && { echo "configure: error: Cannot link curses library" 1>&2; exit 1; }
7331 elif test "$cf_curs_lib" = "$cf_term_lib" ; then
7332 :
7333 elif test "$cf_term_lib" != predefined ; then
7334 echo $ac_n "checking if we need both $cf_curs_lib and $cf_term_lib libraries""... $ac_c" 1>&6
7335 echo "configure:7337: checking if we need both $cf_curs_lib and $cf_term_lib libraries" >&5
7336 cat > conftest.$ac_ext <<EOF
7337 #line 7339 "configure"
7338 #include "confdefs.h"
7339 #include <${cf_cv_ncurses_header-curses.h}>
7340 int main() {
7341 initscr(); tgoto((char *)0, 0, 0);
7342 ; return 0; }
7343 EOF
7344 if { (eval echo configure:7346: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
7345 rm -rf conftest*
7346 cf_result=no
7347 else
7348 echo "configure: failed program was:" >&5
7349 cat conftest.$ac_ext >&5
7350 rm -rf conftest*
7351
7352 LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
7353 cat > conftest.$ac_ext <<EOF
7354 #line 7356 "configure"
7355 #include "confdefs.h"
7356 #include <${cf_cv_ncurses_header-curses.h}>
7357 int main() {
7358 initscr()
7359 ; return 0; }
7360 EOF
7361 if { (eval echo configure:7363: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
7362 rm -rf conftest*
7363 cf_result=yes
7364 else
7365 echo "configure: failed program was:" >&5
7366 cat conftest.$ac_ext >&5
7367 rm -rf conftest*
7368 cf_result=error
7369 fi
7370 rm -f conftest*
7371
7372 fi
7373 rm -f conftest*
7374 echo "$ac_t""$cf_result" 1>&6
7375 fi
7376 fi
7377 fi
7378
7379
7380 ;;
7381 esac
7382
7383
7384
7385 echo $ac_n "checking if we must define _XOPEN_SOURCE_EXTENDED""... $ac_c" 1>&6
7386 echo "configure:7388: checking if we must define _XOPEN_SOURCE_EXTENDED" >&5
7387 if eval "test \"`echo '$''{'cf_cv_need_xopen_extension'+set}'`\" = set"; then
7388 echo $ac_n "(cached) $ac_c" 1>&6
7389 else
7390
7391 cat > conftest.$ac_ext <<EOF
7392 #line 7394 "configure"
7393 #include "confdefs.h"
7394
7395 #include <stdlib.h>
7396 #include <${cf_cv_ncurses_header-curses.h}>
7397 int main() {
7398
7399 long x = winnstr(stdscr, "", 0);
7400 int x1, y1;
7401 getbegyx(stdscr, y1, x1)
7402 ; return 0; }
7403 EOF
7404 if { (eval echo configure:7406: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
7405 rm -rf conftest*
7406 cf_cv_need_xopen_extension=no
7407 else
7408 echo "configure: failed program was:" >&5
7409 cat conftest.$ac_ext >&5
7410 rm -rf conftest*
7411 cat > conftest.$ac_ext <<EOF
7412 #line 7414 "configure"
7413 #include "confdefs.h"
7414
7415 #define _XOPEN_SOURCE_EXTENDED
7416 #include <stdlib.h>
7417 #include <${cf_cv_ncurses_header-curses.h}>
7418 int main() {
7419
7420 long x = winnstr(stdscr, "", 0);
7421 int x1, y1;
7422 getbegyx(stdscr, y1, x1)
7423 ; return 0; }
7424 EOF
7425 if { (eval echo configure:7427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
7426 rm -rf conftest*
7427 cf_cv_need_xopen_extension=yes
7428 else
7429 echo "configure: failed program was:" >&5
7430 cat conftest.$ac_ext >&5
7431 rm -rf conftest*
7432 cf_cv_need_xopen_extension=unknown
7433 fi
7434 rm -f conftest*
7435 fi
7436 rm -f conftest*
7437 fi
7438
7439 echo "$ac_t""$cf_cv_need_xopen_extension" 1>&6
7440 test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
7441
7442
7443 echo $ac_n "checking for term.h""... $ac_c" 1>&6
7444 echo "configure:7446: checking for term.h" >&5
7445 if eval "test \"`echo '$''{'cf_cv_term_header'+set}'`\" = set"; then
7446 echo $ac_n "(cached) $ac_c" 1>&6
7447 else
7448
7449
7450 # If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
7451 # for <term.h> if we do not find the variant.
7452 for cf_header in \
7453 `echo ${cf_cv_ncurses_header-curses.h} | sed -e 's%/.*%/%'`term.h \
7454 term.h
7455 do
7456 cat > conftest.$ac_ext <<EOF
7457 #line 7459 "configure"
7458 #include "confdefs.h"
7459
7460 #include <${cf_cv_ncurses_header-curses.h}>
7461 #include <${cf_header}>
7462 int main() {
7463 WINDOW *x
7464 ; return 0; }
7465 EOF
7466 if { (eval echo configure:7468: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
7467 rm -rf conftest*
7468 cf_cv_term_header=$cf_header
7469 break
7470 else
7471 echo "configure: failed program was:" >&5
7472 cat conftest.$ac_ext >&5
7473 rm -rf conftest*
7474 cf_cv_term_header=no
7475 fi
7476 rm -f conftest*
7477 done
7478
7479 fi
7480
7481 echo "$ac_t""$cf_cv_term_header" 1>&6
7482
7483 case $cf_cv_term_header in #(vi
7484 term.h) #(vi
7485 cat >> confdefs.h <<\EOF
7486 #define HAVE_TERM_H 1
7487 EOF
7488
7489 ;;
7490 ncurses/term.h)
7491 cat >> confdefs.h <<\EOF
7492 #define HAVE_NCURSES_TERM_H 1
7493 EOF
7494
7495 ;;
7496 ncursesw/term.h)
7497 cat >> confdefs.h <<\EOF
7498 #define HAVE_NCURSESW_TERM_H 1
7499 EOF
7500
7501 ;;
7502 esac
7503
7504
7505
7506
7507 for cf_func in \
7508 Xinitscr\
7509 getbegx \
7510 getbegy \
7511 getmaxx \
7512 getmaxy \
7513 start_color \
7514 \
7515
7516 do
7517
7518 cf_tr_func=`echo "$cf_func" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
7519
7520 echo $ac_n "checking for ${cf_func}""... $ac_c" 1>&6
7521 echo "configure:7523: checking for ${cf_func}" >&5
7522
7523 echo "(line 7525) testing ${cf_func} ..." 1>&5
7524
7525 if eval "test \"`echo '$''{'cf_cv_func_$cf_func'+set}'`\" = set"; then
7526 echo $ac_n "(cached) $ac_c" 1>&6
7527 else
7528
7529 eval cf_result='$ac_cv_func_'$cf_func
7530 if test ".$cf_result" != ".no"; then
7531 cat > conftest.$ac_ext <<EOF
7532 #line 7534 "configure"
7533 #include "confdefs.h"
7534
7535 #ifdef HAVE_XCURSES
7536 #include <xcurses.h>
7537 char * XCursesProgramName = "test";
7538 #else
7539 #include <${cf_cv_ncurses_header-curses.h}>
7540 #if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
7541 #include <ncursesw/term.h>
7542 #else
7543 #if defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
7544 #include <ncurses/term.h>
7545 #else
7546 #ifdef HAVE_TERM_H
7547 #include <term.h>
7548 #endif
7549 #endif
7550 #endif
7551 #endif
7552 int main() {
7553
7554 #ifndef ${cf_func}
7555 long foo = (long)(&${cf_func});
7556 exit(foo == 0);
7557 #endif
7558
7559 ; return 0; }
7560 EOF
7561 if { (eval echo configure:7563: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
7562 rm -rf conftest*
7563 cf_result=yes
7564 else
7565 echo "configure: failed program was:" >&5
7566 cat conftest.$ac_ext >&5
7567 rm -rf conftest*
7568 cf_result=no
7569 fi
7570 rm -f conftest*
7571 fi
7572 eval 'cf_cv_func_'$cf_func'=$cf_result'
7573
7574 fi
7575
7576 # use the computed/retrieved cache-value:
7577 eval 'cf_result=$cf_cv_func_'$cf_func
7578 echo "$ac_t""$cf_result" 1>&6
7579 if test $cf_result != no; then
7580 cat >> confdefs.h <<EOF
7581 #define HAVE_${cf_tr_func} 1
7582 EOF
7583
7584 fi
7585 done
7586
7587
7588
7589 case $LIBS in #(vi
7590 *ncurses*)
7591
7592 echo $ac_n "checking if you want to check for memory leaks""... $ac_c" 1>&6
7593 echo "configure:7595: checking if you want to check for memory leaks" >&5
7594 cf_disable_leaks=no
7595
7596 # Check whether --enable-leaks or --disable-leaks was given.
7597 if test "${enable_leaks+set}" = set; then
7598 enableval="$enable_leaks"
7599 test "$enableval" = no && cf_disable_leaks=yes
7600 fi
7601
7602 echo "$ac_t""$cf_disable_leaks" 1>&6
7603
7604 if test "$cf_disable_leaks" = yes ; then
7605 cat >> confdefs.h <<\EOF
7606 #define NO_LEAKS 1
7607 EOF
7608
7609 for ac_hdr in nc_alloc.h
7610 do
7611 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
7612 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
7613 echo "configure:7615: checking for $ac_hdr" >&5
7614 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
7615 echo $ac_n "(cached) $ac_c" 1>&6
7616 else
7617 cat > conftest.$ac_ext <<EOF
7618 #line 7620 "configure"
7619 #include "confdefs.h"
7620 #include <$ac_hdr>
7621 EOF
7622 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
7623 { (eval echo configure:7625: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
7624 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
7625 if test -z "$ac_err"; then
7626 rm -rf conftest*
7627 eval "ac_cv_header_$ac_safe=yes"
7628 else
7629 echo "$ac_err" >&5
7630 echo "configure: failed program was:" >&5
7631 cat conftest.$ac_ext >&5
7632 rm -rf conftest*
7633 eval "ac_cv_header_$ac_safe=no"
7634 fi
7635 rm -f conftest*
7636 fi
7637 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
7638 echo "$ac_t""yes" 1>&6
7639 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
7640 cat >> confdefs.h <<EOF
7641 #define $ac_tr_hdr 1
7642 EOF
7643
7644 else
7645 echo "$ac_t""no" 1>&6
7646 fi
7647 done
7648
7649 for ac_func in _nc_free_and_exit
7650 do
7651 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
7652 echo "configure:7654: checking for $ac_func" >&5
7653 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
7654 echo $ac_n "(cached) $ac_c" 1>&6
7655 else
7656 cat > conftest.$ac_ext <<EOF
7657 #line 7659 "configure"
7658 #include "confdefs.h"
7659 /* System header to define __stub macros and hopefully few prototypes,
7660 which can conflict with char $ac_func(); below. */
7661 #include <assert.h>
7662 /* Override any gcc2 internal prototype to avoid an error. */
7663 /* We use char because int might match the return type of a gcc2
7664 builtin and then its argument prototype would still apply. */
7665 char $ac_func();
7666
7667 int main() {
7668
7669 /* The GNU C library defines this for functions which it implements
7670 to always fail with ENOSYS. Some functions are actually named
7671 something starting with __ and the normal name is an alias. */
7672 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
7673 choke me
7674 #else
7675 $ac_func();
7676 #endif
7677
7678 ; return 0; }
7679 EOF
7680 if { (eval echo configure:7682: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
7681 rm -rf conftest*
7682 eval "ac_cv_func_$ac_func=yes"
7683 else
7684 echo "configure: failed program was:" >&5
7685 cat conftest.$ac_ext >&5
7686 rm -rf conftest*
7687 eval "ac_cv_func_$ac_func=no"
7688 fi
7689 rm -f conftest*
7690 fi
7691
7692 if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
7693 echo "$ac_t""yes" 1>&6
7694 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
7695 cat >> confdefs.h <<EOF
7696 #define $ac_tr_func 1
7697 EOF
7698
7699 else
7700 echo "$ac_t""no" 1>&6
7701 fi
7702 done
7703
7704 fi
7705 ;;
7706 esac
7707
7708
7709 echo $ac_n "checking how to define setbegyx""... $ac_c" 1>&6
7710 echo "configure:7712: checking how to define setbegyx" >&5
7711 cf_result=ERR
7712 for cf_check in \
7713 '((win)->_begy = (y), (win)->_begx = (x), OK)'
7714 do
7715 cat > conftest.$ac_ext <<EOF
7716 #line 7718 "configure"
7717 #include "confdefs.h"
7718
7719 #include <${cf_cv_ncurses_header-curses.h}>
7720
7721 int main() {
7722
7723 WINDOW *win = 0;
7724 #define setbegyx(win,y,x) $cf_check
7725 setbegyx(win, 2, 3);
7726
7727 ; return 0; }
7728 EOF
7729 if { (eval echo configure:7731: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
7730 rm -rf conftest*
7731 cf_result=$cf_check; break
7732 else
7733 echo "configure: failed program was:" >&5
7734 cat conftest.$ac_ext >&5
7735 fi
7736 rm -f conftest*
7737 done
7738 echo "$ac_t"""$cf_result"" 1>&6
7739 cat >> confdefs.h <<EOF
7740 #define setbegyx(win,y,x) $cf_result
7741 EOF
7742
7743
7744
7745 trap '' 1 2 15
7746 cat > confcache <<\EOF
7747 # This file is a shell script that caches the results of configure
7748 # tests run on this system so they can be shared between configure
7749 # scripts and configure runs. It is not useful on other systems.
7750 # If it contains results you don't want to keep, you may remove or edit it.
7751 #
7752 # By default, configure uses ./config.cache as the cache file,
7753 # creating it if it does not exist already. You can give configure
7754 # the --cache-file=FILE option to use a different cache file; that is
7755 # what configure does when it calls configure scripts in
7756 # subdirectories, so they share the cache.
7757 # Giving --cache-file=/dev/null disables caching, for debugging configure.
7758 # config.status only pays attention to the cache file if you give it the
7759 # --recheck option to rerun configure.
7760 #
7761 EOF
7762 # The following way of writing the cache mishandles newlines in values,
7763 # but we know of no workaround that is simple, portable, and efficient.
7764 # So, don't put newlines in cache variables' values.
7765 # Ultrix sh set writes to stderr and can't be redirected directly,
7766 # and sets the high bit in the cache file unless we assign to the vars.
7767 (set) 2>&1 |
7768 case `(ac_space=' '; set | grep ac_space) 2>&1` in
7769 *ac_space=\ *)
7770 # `set' does not quote correctly, so add quotes (double-quote substitution
7771 # turns \\\\ into \\, and sed turns \\ into \).
7772 sed -n \
7773 -e "s/'/'\\\\''/g" \
7774 -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
7775 ;;
7776 *)
7777 # `set' quotes correctly as required by POSIX, so do not add quotes.
7778 sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
7779 ;;
7780 esac >> confcache
7781 if cmp -s $cache_file confcache; then
7782 :
7783 else
7784 if test -w $cache_file; then
7785 echo "updating cache $cache_file"
7786 cat confcache > $cache_file
7787 else
7788 echo "not updating unwritable cache $cache_file"
7789 fi
7790 fi
7791 rm -f confcache
7792
7793 trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
7794
7795 test "x$prefix" = xNONE && prefix=$ac_default_prefix
7796 # Let make expand exec_prefix.
7797 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
7798
7799 # Any assignment to VPATH causes Sun make to only execute
7800 # the first set of double-colon rules, so remove it if not needed.
7801 # If there is a colon in the path, we need to keep it.
7802 if test "x$srcdir" = x.; then
7803 ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
7804 fi
7805
7806 trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
7807
7808 DEFS=-DHAVE_CONFIG_H
7809
7810 # Without the "./", some shells look in PATH for config.status.
7811 : ${CONFIG_STATUS=./config.status}
7812
7813 echo creating $CONFIG_STATUS
7814 rm -f $CONFIG_STATUS
7815 cat > $CONFIG_STATUS <<EOF
7816 #! /bin/sh
7817 # Generated automatically by configure.
7818 # Run this file to recreate the current configuration.
7819 # This directory was configured as follows,
7820 # on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
7821 #
7822 # $0 $ac_configure_args
7823 #
7824 # Compiler output produced by configure, useful for debugging
7825 # configure, is in ./config.log if it exists.
7826
7827 ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
7828 for ac_option
7829 do
7830 case "\$ac_option" in
7831 -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
7832 echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
7833 exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
7834 -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
7835 echo "$CONFIG_STATUS generated by autoconf version 2.13.20030927"
7836 exit 0 ;;
7837 -help | --help | --hel | --he | --h)
7838 echo "\$ac_cs_usage"; exit 0 ;;
7839 *) echo "\$ac_cs_usage"; exit 1 ;;
7840 esac
7841 done
7842
7843 ac_given_srcdir=$srcdir
7844 ac_given_INSTALL="$INSTALL"
7845
7846 trap 'rm -fr `echo "include/cdk_version.h:include/cdk_version.hin
7847 Makefile
7848 cli/Makefile
7849 examples/Makefile
7850 demos/Makefile include/cdk_config.h:include/config.hin" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
7851 EOF
7852 cat >> $CONFIG_STATUS <<EOF
7853
7854 # Protect against being on the right side of a sed subst in config.status.
7855 sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
7856 s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
7857 $ac_vpsub
7858 $extrasub
7859 s%@SHELL@%$SHELL%g
7860 s%@CFLAGS@%$CFLAGS%g
7861 s%@CPPFLAGS@%$CPPFLAGS%g
7862 s%@CXXFLAGS@%$CXXFLAGS%g
7863 s%@FFLAGS@%$FFLAGS%g
7864 s%@DEFS@%$DEFS%g
7865 s%@LDFLAGS@%$LDFLAGS%g
7866 s%@LIBS@%$LIBS%g
7867 s%@exec_prefix@%$exec_prefix%g
7868 s%@prefix@%$prefix%g
7869 s%@program_transform_name@%$program_transform_name%g
7870 s%@bindir@%$bindir%g
7871 s%@sbindir@%$sbindir%g
7872 s%@libexecdir@%$libexecdir%g
7873 s%@datadir@%$datadir%g
7874 s%@sysconfdir@%$sysconfdir%g
7875 s%@sharedstatedir@%$sharedstatedir%g
7876 s%@localstatedir@%$localstatedir%g
7877 s%@libdir@%$libdir%g
7878 s%@includedir@%$includedir%g
7879 s%@oldincludedir@%$oldincludedir%g
7880 s%@infodir@%$infodir%g
7881 s%@mandir@%$mandir%g
7882 s%@host@%$host%g
7883 s%@host_alias@%$host_alias%g
7884 s%@host_cpu@%$host_cpu%g
7885 s%@host_vendor@%$host_vendor%g
7886 s%@host_os@%$host_os%g
7887 s%@VERSION@%$VERSION%g
7888 s%@VERSION_MAJOR@%$VERSION_MAJOR%g
7889 s%@VERSION_MINOR@%$VERSION_MINOR%g
7890 s%@VERSION_PATCH@%$VERSION_PATCH%g
7891 s%@PACKAGE@%$PACKAGE%g
7892 s%@CC@%$CC%g
7893 s%@CPP@%$CPP%g
7894 s%@RANLIB@%$RANLIB%g
7895 s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
7896 s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
7897 s%@INSTALL_DATA@%$INSTALL_DATA%g
7898 s%@build@%$build%g
7899 s%@build_alias@%$build_alias%g
7900 s%@build_cpu@%$build_cpu%g
7901 s%@build_vendor@%$build_vendor%g
7902 s%@build_os@%$build_os%g
7903 s%@AR@%$AR%g
7904 s%@SET_MAKE@%$SET_MAKE%g
7905 s%@cf_cv_makeflags@%$cf_cv_makeflags%g
7906 s%@MAKE_LOWER_TAGS@%$MAKE_LOWER_TAGS%g
7907 s%@MAKE_UPPER_TAGS@%$MAKE_UPPER_TAGS%g
7908 s%@EXTRA_CPPFLAGS@%$EXTRA_CPPFLAGS%g
7909 s%@ECHO_LT@%$ECHO_LT%g
7910 s%@ECHO_LD@%$ECHO_LD%g
7911 s%@RULE_CC@%$RULE_CC%g
7912 s%@SHOW_CC@%$SHOW_CC%g
7913 s%@ECHO_CC@%$ECHO_CC%g
7914 s%@EXEEXT@%$EXEEXT%g
7915 s%@OBJEXT@%$OBJEXT%g
7916 s%@PROG_EXT@%$PROG_EXT%g
7917 s%@LIB_PREFIX@%$LIB_PREFIX%g
7918 s%@MAN_DIR@%$MAN_DIR%g
7919 s%@MANSECT@%$MANSECT%g
7920 s%@EXTRA_CFLAGS@%$EXTRA_CFLAGS%g
7921 s%@LIBTOOL@%$LIBTOOL%g
7922 s%@LIBTOOL_CXX@%$LIBTOOL_CXX%g
7923 s%@LIB_CREATE@%$LIB_CREATE%g
7924 s%@LIB_OBJECT@%$LIB_OBJECT%g
7925 s%@LIB_SUFFIX@%$LIB_SUFFIX%g
7926 s%@LIB_PREP@%$LIB_PREP%g
7927 s%@LIB_CLEAN@%$LIB_CLEAN%g
7928 s%@LIB_COMPILE@%$LIB_COMPILE%g
7929 s%@LIB_LINK@%$LIB_LINK%g
7930 s%@LIB_INSTALL@%$LIB_INSTALL%g
7931 s%@LIB_UNINSTALL@%$LIB_UNINSTALL%g
7932 s%@X_CFLAGS@%$X_CFLAGS%g
7933 s%@X_PRE_LIBS@%$X_PRE_LIBS%g
7934 s%@X_LIBS@%$X_LIBS%g
7935 s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g
7936 s%@LIB_ROOTNAME@%$LIB_ROOTNAME%g
7937
7938 CEOF
7939 EOF
7940
7941 cat >> $CONFIG_STATUS <<\EOF
7942
7943 # Split the substitutions into bite-sized pieces for seds with
7944 # small command number limits, like on Digital OSF/1 and HP-UX.
7945 ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
7946 ac_file=1 # Number of current file.
7947 ac_beg=1 # First line for current file.
7948 ac_end=$ac_max_sed_cmds # Line after last line for current file.
7949 ac_more_lines=:
7950 ac_sed_cmds=""
7951 while $ac_more_lines; do
7952 if test $ac_beg -gt 1; then
7953 sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
7954 else
7955 sed "${ac_end}q" conftest.subs > conftest.s$ac_file
7956 fi
7957 if test ! -s conftest.s$ac_file; then
7958 ac_more_lines=false
7959 rm -f conftest.s$ac_file
7960 else
7961 if test -z "$ac_sed_cmds"; then
7962 ac_sed_cmds="sed -f conftest.s$ac_file"
7963 else
7964 ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
7965 fi
7966 ac_file=`expr $ac_file + 1`
7967 ac_beg=$ac_end
7968 ac_end=`expr $ac_end + $ac_max_sed_cmds`
7969 fi
7970 done
7971 if test -z "$ac_sed_cmds"; then
7972 ac_sed_cmds=cat
7973 fi
7974 EOF
7975
7976 cat >> $CONFIG_STATUS <<EOF
7977
7978 CONFIG_FILES=\${CONFIG_FILES-"include/cdk_version.h:include/cdk_version.hin
7979 Makefile
7980 cli/Makefile
7981 examples/Makefile
7982 demos/Makefile"}
7983 EOF
7984 cat >> $CONFIG_STATUS <<\EOF
7985 for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
7986 # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
7987 case "$ac_file" in
7988 *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
7989 ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
7990 *) ac_file_in="${ac_file}.in" ;;
7991 esac
7992
7993 # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
7994
7995 # Remove last slash and all that follows it. Not all systems have dirname.
7996 ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
7997 if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
7998 # The file is in a subdirectory.
7999 test ! -d "$ac_dir" && mkdir "$ac_dir"
8000 ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
8001 # A "../" for each directory in $ac_dir_suffix.
8002 ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
8003 else
8004 ac_dir_suffix= ac_dots=
8005 fi
8006
8007 case "$ac_given_srcdir" in
8008 .) srcdir=.
8009 if test -z "$ac_dots"; then top_srcdir=.
8010 else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
8011 /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
8012 *) # Relative path.
8013 srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
8014 top_srcdir="$ac_dots$ac_given_srcdir" ;;
8015 esac
8016
8017 case "$ac_given_INSTALL" in
8018 [/$]*) INSTALL="$ac_given_INSTALL" ;;
8019 *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
8020 esac
8021
8022 echo creating "$ac_file"
8023 rm -f "$ac_file"
8024 configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
8025 case "$ac_file" in
8026 *Makefile*) ac_comsub="1i\\
8027 # $configure_input" ;;
8028 *) ac_comsub= ;;
8029 esac
8030
8031 ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
8032 sed -e "$ac_comsub
8033 s%@configure_input@%$configure_input%g
8034 s%@srcdir@%$srcdir%g
8035 s%@top_srcdir@%$top_srcdir%g
8036 s%@INSTALL@%$INSTALL%g
8037 " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
8038 fi; done
8039 rm -f conftest.s*
8040
8041 # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
8042 # NAME is the cpp macro being defined and VALUE is the value it is being given.
8043 #
8044 # ac_d sets the value in "#define NAME VALUE" lines.
8045 ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
8046 ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
8047 ac_dC='\3'
8048 ac_dD='%g'
8049 # ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
8050 ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
8051 ac_uB='\([ ]\)%\1#\2define\3'
8052 ac_uC=' '
8053 ac_uD='\4%g'
8054 # ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
8055 ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
8056 ac_eB='$%\1#\2define\3'
8057 ac_eC=' '
8058 ac_eD='%g'
8059
8060 if test "${CONFIG_HEADERS+set}" != set; then
8061 EOF
8062 cat >> $CONFIG_STATUS <<EOF
8063 CONFIG_HEADERS="include/cdk_config.h:include/config.hin"
8064 EOF
8065 cat >> $CONFIG_STATUS <<\EOF
8066 fi
8067 for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
8068 # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
8069 case "$ac_file" in
8070 *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
8071 ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
8072 *) ac_file_in="${ac_file}.in" ;;
8073 esac
8074
8075 echo creating $ac_file
8076
8077 rm -f conftest.frag conftest.in conftest.out
8078 ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
8079 cat $ac_file_inputs > conftest.in
8080
8081 EOF
8082
8083
8084 # Transform confdefs.h into a list of #define's. We won't use it as a sed
8085 # script, but as data to insert where we see @DEFS@. We expect AC_SAVE_DEFS to
8086 # be either 'cat' or 'sort'.
8087 sort confdefs.h >conftest.vals
8088
8089 # Break up conftest.vals because some shells have a limit on
8090 # the size of here documents, and old seds have small limits too.
8091
8092 rm -f conftest.tail
8093 echo ' rm -f conftest.frag' >> $CONFIG_STATUS
8094 while :
8095 do
8096 ac_lines=`grep -c . conftest.vals`
8097 # grep -c gives empty output for an empty file on some AIX systems.
8098 if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
8099 # Write chunks of a limited-size here document to conftest.frag.
8100 echo ' cat >> conftest.frag <<CEOF' >> $CONFIG_STATUS
8101 sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
8102 echo 'CEOF' >> $CONFIG_STATUS
8103 sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
8104 rm -f conftest.vals
8105 mv conftest.tail conftest.vals
8106 done
8107 rm -f conftest.vals
8108
8109 # Run sed to substitute the contents of conftest.frag into conftest.in at the
8110 # marker @DEFS@.
8111 echo ' cat >> conftest.edit <<CEOF
8112 /@DEFS@/r conftest.frag
8113 /@DEFS@/d
8114 CEOF
8115 sed -f conftest.edit conftest.in > conftest.out
8116 rm -f conftest.in
8117 mv conftest.out conftest.in
8118 rm -f conftest.edit conftest.frag
8119 ' >> $CONFIG_STATUS
8120
8121
8122 cat >> $CONFIG_STATUS <<\EOF
8123 rm -f conftest.frag conftest.h
8124 echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
8125 cat conftest.in >> conftest.h
8126 rm -f conftest.in
8127 if cmp -s $ac_file conftest.h 2>/dev/null; then
8128 echo "$ac_file is unchanged"
8129 rm -f conftest.h
8130 else
8131 # Remove last slash and all that follows it. Not all systems have dirname.
8132 ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
8133 if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
8134 # The file is in a subdirectory.
8135 test ! -d "$ac_dir" && mkdir "$ac_dir"
8136 fi
8137 rm -f $ac_file
8138 mv conftest.h $ac_file
8139 fi
8140 fi; done
8141
8142 EOF
8143 cat >> $CONFIG_STATUS <<EOF
8144 # Extra initialization commands, if any
8145
8146 EOF
8147 cat >> $CONFIG_STATUS <<\EOF
8148 # Extra commands, if any
8149
8150 exit 0
8151 EOF
8152 chmod +x $CONFIG_STATUS
8153 rm -fr confdefs* $ac_clean_files
8154 test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
8155
0 dnl $Id: configure.in,v 1.44 2005/12/28 22:41:13 tom Exp $
1 dnl Process this file with autoconf to produce a configure script for CDK.
2 dnl
3 AC_INIT(include/cdk.h)
4 AC_CONFIG_HEADER(include/cdk_config.h:include/config.hin)
5
6 CF_CHECK_CACHE
7 CF_VERSION_INFO(cdk)
8
9 dnl
10 dnl Checks for programs.
11 dnl
12 AC_PROG_CC
13 AC_PROG_CPP
14 AC_PROG_GCC_TRADITIONAL
15 AC_PROG_RANLIB
16 AC_PROG_INSTALL
17
18 dnl needed for CF_WITH_LIBTOOL
19 AC_CHECK_TOOL(AR, ar, ar)
20
21 AC_PROG_MAKE_SET
22 CF_MAKEFLAGS
23 CF_MAKE_TAGS
24
25 CF_ANSI_CC_REQD
26 AC_C_CONST
27 CF_XOPEN_SOURCE
28
29 CF_DISABLE_ECHO
30 CF_PROG_EXT
31 CF_LIB_PREFIX
32
33 AC_ARG_WITH(man-section,
34 [ --with-man-section=XXX change manpage section (default 3)],
35 [MANSECT=$with_man_section],
36 [MANSECT=3])
37 case .$MANSECT in
38 .yes|.no)
39 MANSECT=3
40 ;;
41 esac
42 MAN_DIR=`echo $MANSECT | sed -e 's/^\(.\).*/\1/'`
43 AC_SUBST(MAN_DIR)
44 AC_SUBST(MANSECT)
45
46 CF_WITH_CURSES_DIR
47 CF_WITH_WARNINGS
48 CF_WITH_LIBTOOL
49 if test "$with_libtool" = "yes" ; then
50 OBJEXT="lo"
51 fi
52
53 dnl
54 dnl Checks for libraries.
55 dnl
56
57 CF_WITH_DBMALLOC
58 CF_WITH_DMALLOC
59
60 dnl
61 dnl Checks for header files.
62 dnl
63 AC_HEADER_DIRENT
64 AC_HEADER_STDC
65 AC_CHECK_HEADERS(\
66 limits.h \
67 unistd.h \
68 )
69
70 dnl
71 dnl Checks for typedefs, structures, and compiler characteristics.
72 dnl
73 AC_TYPE_MODE_T
74 AC_STRUCT_TM
75 CF_CURSES_CHTYPE
76 CF_GETOPT_HEADER
77
78 dnl
79 dnl Checks for library functions.
80 dnl
81 AC_CHECK_FUNCS(\
82 getcwd \
83 mktime \
84 strdup \
85 strerror \
86 )
87
88 CF_FUNC_LSTAT
89 CF_LOCALE([AC_DEFINE(HAVE_SETLOCALE)])
90
91 dnl Check for curses libraries last, since XCurses has dependencies which
92 dnl break the checks for other functions.
93 use_library=curses
94 AC_ARG_WITH(ncurses,
95 [ --with-ncurses compile/link with ncurses library],
96 [use_library=ncurses],[
97 AC_ARG_WITH(ncursesw,
98 [ --with-ncursesw compile/line with wide-character ncurses],
99 [use_library=ncursesw],[
100 AC_ARG_WITH(pdcurses,
101 [ --with-pdcurses compile/link with pdcurses X11 library],
102 [use_library=pdcurses])])])
103
104 LIB_ROOTNAME=cdk
105 case $use_library in #(vi
106 ncurses) #(vi
107 CF_NCURSES_CPPFLAGS
108 CF_NCURSES_LIBS
109 ;;
110 ncursesw)
111 CF_UTF8_LIB
112 CF_NCURSES_CPPFLAGS(ncursesw)
113 CF_NCURSES_LIBS(ncursesw)
114 LIB_ROOTNAME=cdkw
115 ;;
116 pdcurses) #(vi
117 CF_PDCURSES_X11
118 LIB_ROOTNAME=cdkX
119 ;;
120 *)
121 CF_CURSES_CPPFLAGS
122 CF_NCURSES_VERSION
123 CF_CURSES_LIBS
124 ;;
125 esac
126 AC_SUBST(LIB_ROOTNAME)
127
128 CF_CURSES_FUNCS(\
129 Xinitscr\
130 getbegx \
131 getbegy \
132 getmaxx \
133 getmaxy \
134 start_color \
135 \
136 )
137
138 CF_WITH_NC_ALLOC_H
139 CF_CURSES_SETBEGYX
140
141 dnl
142 dnl Set pre-processor compile time variables.
143 dnl
144 AC_OUTPUT(
145 include/cdk_version.h:include/cdk_version.hin
146 Makefile
147 cli/Makefile
148 examples/Makefile
149 demos/Makefile,,,sort)
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2003/11/16 21:08:13 $
5 * $Revision: 1.10 $
6 */
7
8 FILE *CDKDEBUG;
9
10
11 /*
12 * This starts debugging for CDK.
13 */
14 FILE *startCDKDebug (char *filename)
15 {
16 char *defFile = "cdkdebug.log";
17
18 /* Check if the filename is null. */
19 if (filename == 0)
20 {
21 filename = defFile;
22 }
23
24 /* Try to open the file. */
25 return ( fopen (filename, "w") );
26 }
27
28 /*
29 * This writes a message to the debug file.
30 */
31 void writeCDKDebugMessage (FILE *fd, char *filename, char *function, int line, char *message)
32 {
33 /* Print the message as long as the file pointer is not null. */
34 if (fd != 0)
35 {
36 fprintf (fd, "%s::%s (Line %d) %s\n", filename, function, line, message);
37 }
38 }
39
40 /*
41 * This turns off the debugging for CDK.
42 */
43 void stopCDKDebug (FILE *fd)
44 {
45 if (fd != 0)
46 {
47 fclose (fd);
48 }
49 }
0 # $Id: Makefile.in,v 1.15 2003/11/27 12:03:51 tom Exp $
1 #
2 # Makefile for the examples directory.
3 #
4 SHELL = /bin/sh
5
6 prefix = @prefix@
7 exec_prefix = @exec_prefix@
8
9 srcdir = @srcdir@
10 VPATH = $(srcdir)
11
12 CC = @CC@
13 RM = rm -f
14
15 LIBS = -l@LIB_ROOTNAME@ @LIBS@
16
17 LIBTOOL = @LIBTOOL@ @ECHO_LT@
18 LIBTOOL_CLEAN = @LIB_CLEAN@
19 LIBTOOL_LINK = @LIB_LINK@
20 LINK = $(LIBTOOL_LINK) $(CC)
21
22 x = @EXEEXT@
23 o = .@OBJEXT@
24
25 CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@
26 CPPFLAGS = @DEFS@ -I../include -I$(srcdir)/../include -I. @CPPFLAGS@
27 LDFLAGS = -L.. @LDFLAGS@
28
29 BINS = \
30 fileview$x \
31 rolodex$x \
32 command$x \
33 clock$x \
34 stopSign$x \
35 appointment$x \
36 vinstall$x
37
38 # this needs configure-script work:
39 OTHER_BINS = \
40 serial$x
41
42 #
43 # If you have Sybase installed on your system, try making
44 # syb. It's a full screen interface to Sybase.
45 #
46 SYBROOT = $(SYBASE)
47 SYBINCDIR = -I$(SYBROOT)/include
48 SYBLIBDIR = -L$(SYBROOT)/devlib
49 SYBLIBS = -lnsl -lsybdb
50
51 all : $(BINS)
52
53 #
54 # Standard .c to .o compile line.
55 #
56 .c.o:
57 @RULE_CC@
58 @ECHO_CC@$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
59 #
60 # Most of the examples are built from a single .c file using the same libraries
61 #
62 LINKIT = @ECHO_LD@$(LINK) $(CFLAGS) $(CPPFLAGS) $? -o $@ $(LDFLAGS) $(LIBS)
63
64 # fileview - Basic file selector/file viewer combination.
65 fileview$x : fileview.o ; $(LINKIT)
66
67 # rolodex - A fairly robust rolodex.
68 rolodex$x : rolodex.o ; $(LINKIT)
69
70 # command - A basic command interface with command history.
71 command$x : command.o ; $(LINKIT)
72
73 # clock - A simple little clock.
74 clock$x : clock.o ; $(LINKIT)
75
76 # stopSign - A simple demo I wrote after a couple of pints. :)
77 stopSign$x : stopSign.o ; $(LINKIT)
78
79 # appointment - A basic appointment book/date keeper.
80 appointment$x : appointment.o ; $(LINKIT)
81
82 # serial - This probes the serial port.
83 serial$x : serial.o ; $(LINKIT)
84
85 # keycheck - This prints out the keys ASCII and Octal values.
86 keycheck$x : keycheck.o ; $(LINKIT)
87
88 # vinstall - CDK based installer.
89 vinstall$x : vinstall.o ; $(LINKIT)
90
91 #
92 # A Sybase interface.
93 #
94 syb$x : syb.c
95 $(CC) $(CFLAGS) -o $@ $? $(CPPFLAGS) $(SYBINCDIR) $(LDFLAGS) $(SYBLIBDIR) $(LIBS) $(SYBLIBS)
96
97 #
98 # Standard clean directives.
99 #
100 clean::
101 -$(LIBTOOL_CLEAN) $(RM) *.o core $(BINS) $(OTHER_BINS)
102
103 distclean:: clean
104 -rm -f Makefile
0 /* $Id: appointment.c,v 1.19 2005/12/30 20:19:06 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName="appointmentBook";
6 #endif
7
8 /*
9 * Create definitions.
10 */
11 #define MAX_MARKERS 2000
12
13 /*
14 *
15 */
16 static chtype GPAppointmentAttributes[] = {
17 A_BLINK,
18 A_BOLD,
19 A_REVERSE,
20 A_UNDERLINE};
21
22 /*
23 *
24 */
25 typedef enum {vBirthday, vAnniversary, vAppointment, vOther} EAppointmentType;
26
27 /*
28 *
29 */
30 struct AppointmentMarker {
31 EAppointmentType type;
32 char *description;
33 int day;
34 int month;
35 int year;
36 };
37
38 /*
39 *
40 */
41 struct AppointmentInfo {
42 struct AppointmentMarker appointment[MAX_MARKERS];
43 int appointmentCount;
44 };
45
46 /*
47 * Declare local function prototypes.
48 */
49 static BINDFN_PROTO(createCalendarMarkCB);
50 static BINDFN_PROTO(removeCalendarMarkCB);
51 static BINDFN_PROTO(displayCalendarMarkCB);
52 static BINDFN_PROTO(accelerateToDateCB);
53 void readAppointmentFile (char *filename, struct AppointmentInfo *appInfo);
54 void saveAppointmentFile (char *filename, struct AppointmentInfo *appInfo);
55
56 /*
57 * This program demonstrates the Cdk calendar widget.
58 */
59 int main (int argc, char **argv)
60 {
61 /* Declare variables. */
62 CDKSCREEN *cdkscreen = 0;
63 CDKCALENDAR *calendar = 0;
64 WINDOW *cursesWin = 0;
65 char *title = "<C></U>CDK Appointment Book\n<C><#HL(30)>\n";
66 char *filename = 0;
67 struct tm *dateInfo = 0;
68 time_t clck = 0;
69 time_t retVal = 0;
70 struct AppointmentInfo appointmentInfo;
71 int day, month, year, ret, x;
72 char temp[1000];
73
74 /*
75 * Get the current dates and set the default values for
76 * the day/month/year values for the calendar.
77 */
78 time (&clck);
79 dateInfo = localtime (&clck);
80 day = dateInfo->tm_mday;
81 month = dateInfo->tm_mon + 1;
82 year = dateInfo->tm_year + 1900;
83
84 /* Check the command line for options. */
85 while (1)
86 {
87 /* Are there any more command line options to parse. */
88 if ((ret = getopt (argc, argv, "d:m:y:t:f:")) == -1)
89 {
90 break;
91 }
92
93 switch (ret)
94 {
95 case 'd':
96 day = atoi (optarg);
97 break;
98
99 case 'm':
100 month = atoi (optarg);
101 break;
102
103 case 'y':
104 year = atoi (optarg);
105 break;
106
107 case 't':
108 title = copyChar (optarg);
109 break;
110
111 case 'f':
112 filename = copyChar (optarg);
113 break;
114 }
115 }
116
117 /* Create the appointment book filename. */
118 if (filename == 0)
119 {
120 char *home = getenv ("HOME");
121 if (home != 0)
122 {
123 sprintf (temp, "%s/.appointment", home);
124 }
125 else
126 {
127 strcat (temp, ".appointment");
128 }
129 filename = copyChar (temp);
130 }
131
132 /* Read the appointment book information. */
133 readAppointmentFile (filename, &appointmentInfo);
134
135 /* Set up CDK. */
136 cursesWin = initscr();
137 cdkscreen = initCDKScreen (cursesWin);
138
139 /* Start CDK Colors. */
140 initCDKColor();
141
142 /* Create the calendar widget. */
143 calendar = newCDKCalendar (cdkscreen, CENTER, CENTER,
144 title, day, month, year,
145 A_NORMAL, A_NORMAL,
146 A_NORMAL, A_REVERSE,
147 TRUE, FALSE);
148
149 /* Is the widget null? */
150 if (calendar == 0)
151 {
152 /* Clean up the memory. */
153 destroyCDKScreen (cdkscreen);
154
155 /* End curses... */
156 endCDK();
157
158 /* Spit out a message. */
159 printf ("Oops. Can't seem to create the calendar. Is the window too small?\n");
160 ExitProgram (EXIT_FAILURE);
161 }
162
163 /* Create a key binding to mark days on the calendar. */
164 bindCDKObject (vCALENDAR, calendar, 'm', createCalendarMarkCB, &appointmentInfo);
165 bindCDKObject (vCALENDAR, calendar, 'M', createCalendarMarkCB, &appointmentInfo);
166 bindCDKObject (vCALENDAR, calendar, 'r', removeCalendarMarkCB, &appointmentInfo);
167 bindCDKObject (vCALENDAR, calendar, 'R', removeCalendarMarkCB, &appointmentInfo);
168 bindCDKObject (vCALENDAR, calendar, '?', displayCalendarMarkCB, &appointmentInfo);
169 bindCDKObject (vCALENDAR, calendar, 'j', accelerateToDateCB, &appointmentInfo);
170 bindCDKObject (vCALENDAR, calendar, 'J', accelerateToDateCB, &appointmentInfo);
171
172 /* Set all the appointments read from the file. */
173 for (x=0; x < appointmentInfo.appointmentCount; x++)
174 {
175 chtype marker = GPAppointmentAttributes[appointmentInfo.appointment[x].type];
176
177 setCDKCalendarMarker (calendar,
178 appointmentInfo.appointment[x].day,
179 appointmentInfo.appointment[x].month,
180 appointmentInfo.appointment[x].year,
181 marker);
182 }
183
184 /* Draw the calendar widget. */
185 drawCDKCalendar (calendar, ObjOf(calendar)->box);
186
187 /* Let the user play with the widget. */
188 retVal = activateCDKCalendar (calendar, 0);
189
190 /* Save the appointment information. */
191 saveAppointmentFile (filename, &appointmentInfo);
192
193 free (filename);
194
195 /* Clean up and exit. */
196 destroyCDKCalendar (calendar);
197 destroyCDKScreen (cdkscreen);
198 endCDK();
199
200 ExitProgram (EXIT_SUCCESS);
201 }
202
203 /*
204 * This reads a given appointment file.
205 */
206 void readAppointmentFile (char *filename, struct AppointmentInfo *appInfo)
207 {
208 /* Declare local variables. */
209 int appointments = 0;
210 int linesRead = 0;
211 int segments = 0;
212 char **lines = 0;
213 char **temp;
214 int x;
215
216 /* Read the appointment file. */
217 linesRead = CDKreadFile (filename, &lines);
218 if (linesRead == -1)
219 {
220 appInfo->appointmentCount = 0;
221 return;
222 }
223
224 /* Split each line up and create an appointment. */
225 for (x=0; x < linesRead; x++)
226 {
227 temp = CDKsplitString (lines[x], CTRL('V'));
228 segments = CDKcountStrings (temp);
229
230 /*
231 * A valid line has 5 elements:
232 * Day, Month, Year, Type, Description.
233 */
234 if (segments == 5)
235 {
236 appInfo->appointment[appointments].day = atoi (temp[0]);
237 appInfo->appointment[appointments].month = atoi (temp[1]);
238 appInfo->appointment[appointments].year = atoi (temp[2]);
239 appInfo->appointment[appointments].type = (EAppointmentType) atoi (temp[3]);
240 appInfo->appointment[appointments].description = copyChar (temp[4]);
241 appointments++;
242 }
243 CDKfreeStrings(temp);
244 }
245 CDKfreeStrings(lines);
246
247 /* Keep the amount of appointments read. */
248 appInfo->appointmentCount = appointments;
249 }
250
251 /*
252 * This saves a given appointment file.
253 */
254 void saveAppointmentFile (char *filename, struct AppointmentInfo *appInfo)
255 {
256 /* Declare local variables. */
257 FILE *fd;
258 int x;
259
260 /* Can we open the file? */
261 if ((fd = fopen (filename, "w")) == 0)
262 {
263 return;
264 }
265
266 /* Start writing. */
267 for (x=0; x < appInfo->appointmentCount; x++)
268 {
269 if (appInfo->appointment[x].description != 0)
270 {
271 fprintf (fd, "%d%c%d%c%d%c%d%c%s\n",
272 appInfo->appointment[x].day, CTRL('V'),
273 appInfo->appointment[x].month, CTRL('V'),
274 appInfo->appointment[x].year, CTRL('V'),
275 appInfo->appointment[x].type, CTRL('V'),
276 appInfo->appointment[x].description);
277
278 freeChar (appInfo->appointment[x].description);
279 }
280 }
281 fclose (fd);
282 }
283
284 /*
285 * This adds a marker to the calendar.
286 */
287 static int createCalendarMarkCB (EObjectType objectType GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED)
288 {
289 CDKCALENDAR *calendar = (CDKCALENDAR *)object;
290 CDKENTRY *entry = 0;
291 CDKITEMLIST *itemlist = 0;
292 char *items[] = {"Birthday", "Anniversary", "Appointment", "Other"};
293 char *description = 0;
294 struct AppointmentInfo *appointmentInfo = (struct AppointmentInfo *)clientData;
295 int current = appointmentInfo->appointmentCount;
296 chtype marker;
297 int selection;
298
299 /* Create the itemlist widget. */
300 itemlist = newCDKItemlist (ScreenOf(calendar),
301 CENTER, CENTER, 0,
302 "Select Appointment Type: ",
303 items, 4, 0,
304 TRUE, FALSE);
305
306 /* Get the appointment tye from the user. */
307 selection = activateCDKItemlist (itemlist, 0);
308
309 /* They hit escape, kill the itemlist widget and leave. */
310 if (selection == -1)
311 {
312 destroyCDKItemlist (itemlist);
313 drawCDKCalendar (calendar, ObjOf(calendar)->box);
314 return (FALSE);
315 }
316
317 /* Destroy the itemlist and set the marker. */
318 destroyCDKItemlist (itemlist);
319 drawCDKCalendar (calendar, ObjOf(calendar)->box);
320 marker = GPAppointmentAttributes[selection];
321
322 /* Create the entry field for the description. */
323 entry = newCDKEntry (ScreenOf(calendar),
324 CENTER, CENTER,
325 "<C>Enter a description of the appointment.",
326 "Description: ",
327 A_NORMAL, (chtype)'.',
328 vMIXED, 40, 1, 512,
329 TRUE, FALSE);
330
331 /* Get the description. */
332 description = activateCDKEntry (entry, 0);
333 if (description == 0)
334 {
335 destroyCDKEntry (entry);
336 drawCDKCalendar (calendar, ObjOf(calendar)->box);
337 return (FALSE);
338 }
339
340 /* Destroy the entry and set the marker. */
341 description = copyChar (entry->info);
342 destroyCDKEntry (entry);
343 drawCDKCalendar (calendar, ObjOf(calendar)->box);
344
345 /* Set the marker. */
346 setCDKCalendarMarker (calendar,
347 calendar->day,
348 calendar->month,
349 calendar->year,
350 marker);
351
352 /* Keep the marker. */
353 appointmentInfo->appointment[current].day = calendar->day;
354 appointmentInfo->appointment[current].month = calendar->month;
355 appointmentInfo->appointment[current].year = calendar->year;
356 appointmentInfo->appointment[current].type = (EAppointmentType)selection;
357 appointmentInfo->appointment[current].description = description;
358 appointmentInfo->appointmentCount++;
359
360 /* Redraw the calendar. */
361 drawCDKCalendar (calendar, ObjOf(calendar)->box);
362 return (FALSE);
363 }
364
365 /*
366 * This removes a marker from the calendar.
367 */
368 static int removeCalendarMarkCB (EObjectType objectType GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED)
369 {
370 CDKCALENDAR *calendar = (CDKCALENDAR *)object;
371 struct AppointmentInfo *appointmentInfo = (struct AppointmentInfo *)clientData;
372 int x;
373
374 /* Look for the marker in the list. */
375 for (x=0; x < appointmentInfo->appointmentCount; x++)
376 {
377 if ((appointmentInfo->appointment[x].day == calendar->day) &&
378 (appointmentInfo->appointment[x].month == calendar->month) &&
379 (appointmentInfo->appointment[x].year == calendar->year))
380 {
381 freeChar (appointmentInfo->appointment[x].description);
382 appointmentInfo->appointment[x].description = 0;
383 break;
384 }
385 }
386
387 /* Remove the marker from the calendar. */
388 removeCDKCalendarMarker (calendar,
389 calendar->day,
390 calendar->month,
391 calendar->year);
392
393 /* Redraw the calendar. */
394 drawCDKCalendar (calendar, ObjOf(calendar)->box);
395 return (FALSE);
396 }
397
398 /*
399 * This displays the marker(s) on the given day.
400 */
401 static int displayCalendarMarkCB (EObjectType objectType GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED)
402 {
403 CDKCALENDAR *calendar = (CDKCALENDAR *)object;
404 CDKLABEL *label = 0;
405 struct AppointmentInfo *appointmentInfo = (struct AppointmentInfo *)clientData;
406 int found = 0;
407 int day = 0;
408 int month = 0;
409 int year = 0;
410 int mesgLines = 0;
411 char *type = 0;
412 char *mesg[10], temp[256];
413 int x;
414
415 /* Look for the marker in the list. */
416 for (x=0; x < appointmentInfo->appointmentCount; x++)
417 {
418 /* Get the day month year. */
419 day = appointmentInfo->appointment[x].day;
420 month = appointmentInfo->appointment[x].month;
421 year = appointmentInfo->appointment[x].year;
422
423 /* Determine the appointment type. */
424 if (appointmentInfo->appointment[x].type == vBirthday)
425 {
426 type = "Birthday";
427 }
428 else if (appointmentInfo->appointment[x].type == vAnniversary)
429 {
430 type = "Anniversary";
431 }
432 else if (appointmentInfo->appointment[x].type == vAppointment)
433 {
434 type = "Appointment";
435 }
436 else
437 {
438 type = "Other";
439 }
440
441 /* Find the marker by the day/month/year. */
442 if ((day == calendar->day) &&
443 (month == calendar->month) &&
444 (year == calendar->year) &&
445 (appointmentInfo->appointment[x].description != 0))
446 {
447 /* Create the message for the label widget. */
448 sprintf (temp, "<C>Appointment Date: %02d/%02d/%d", day, month, year);
449 mesg[mesgLines++] = copyChar (temp);
450 mesg[mesgLines++] = copyChar (" ");
451 mesg[mesgLines++] = copyChar ("<C><#HL(35)>");
452
453 sprintf (temp, " Appointment Type: %s", type);
454 mesg[mesgLines++] = copyChar (temp);
455
456 mesg[mesgLines++] = copyChar (" Description :");
457 sprintf (temp, " %s", appointmentInfo->appointment[x].description);
458 mesg[mesgLines++] = copyChar (temp);
459
460 mesg[mesgLines++] = copyChar ("<C><#HL(35)>");
461 mesg[mesgLines++] = copyChar (" ");
462 mesg[mesgLines++] = copyChar ("<C>Press space to continue.");
463
464 found = 1;
465 break;
466 }
467 }
468
469 /* If we didn't find the marker, create a different message. */
470 if (found == 0)
471 {
472 sprintf (temp, "<C>There is no appointment for %02d/%02d/%d",
473 calendar->day, calendar->month, calendar->year);
474 mesg[mesgLines++] = copyChar (temp);
475 mesg[mesgLines++] = copyChar ("<C><#HL(30)>");
476 mesg[mesgLines++] = copyChar ("<C>Press space to continue.");
477 }
478
479 /* Create the label widget. */
480 label = newCDKLabel (ScreenOf(calendar), CENTER, CENTER,
481 mesg, mesgLines, TRUE, FALSE);
482 drawCDKLabel (label, ObjOf(label)->box);
483 waitCDKLabel (label, ' ');
484 destroyCDKLabel (label);
485
486 /* Clean up the memory used. */
487 for (x=0; x < mesgLines; x++)
488 {
489 freeChar (mesg[x]);
490 }
491
492 /* Redraw the calendar widget. */
493 drawCDKCalendar (calendar, ObjOf(calendar)->box);
494 return (FALSE);
495 }
496
497 /*
498 * This allows the user to accelerate to a given date.
499 */
500 static int accelerateToDateCB (EObjectType objectType GCC_UNUSED, void *object GCC_UNUSED, void *clientData GCC_UNUSED, chtype key GCC_UNUSED)
501 {
502 return (FALSE);
503 }
+0
-95
demos/async less more
0 #!/usr/bin/perl -w
1 # $Id: async,v 1.2 2002/07/27 20:07:47 tom Exp $
2
3 #
4 # This demo demonstrates how to use async functions with Cdk...
5 #
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Set the async function...
14 $SIG{'ALRM'} = "littleWeeClock";
15
16 # Set up the scrolling list.
17 setpwent();
18 while ($item = getpwent())
19 {
20 push (@listItems, $item);
21 }
22
23 # Get the screen dimensions.
24 my ($rows, $cols) = Cdk::getCdkScreenDim ();
25
26 # Create the scrolling list object.
27 my $scroll = new Cdk::Scroll ('Title' => "<C></U/5>Pick An Account",
28 'Height' => 10,
29 'Numbers' => "TRUE",
30 'Highlight' => "</B/29>",
31 'Width' => 25,
32 'List' => \@listItems);
33
34 # Create the label...
35 my $clock = new Cdk::Label ('Message' => ["Current Time: HH:MM:SS"], 'Xpos' => "TOP");
36
37 # Draw the scrolling window.
38 $clock->draw();
39
40 # Set the alarm to go off.
41 alarm (1);
42
43 # Do this forever.
44 for (;;)
45 {
46 # Activate the scrolling list.
47 my $itemPicked = $scroll->activate();
48
49 # Do we need to exit...
50 exit if ! defined $itemPicked;
51
52 # Get the password info.
53 my ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = getpwnam ($listItems[$itemPicked]);
54
55 # Display it.
56 my $info = ["</B/5>Account Name<!B!5> $name",
57 "</B/5>UID <!B!5> $uid",
58 "</B/5>GID <!B!5> $gid",
59 "</B/5>Directory <!B!5> $dir",
60 "</B/5>Shell <!B!5> $shell"];
61 popupLabel ($info);
62 }
63
64 # Exit Cdk.
65 Cdk::end();
66
67 #
68 # This is the async function.
69 #
70 sub littleWeeClock
71 {
72 #
73 # Turn off the alarm
74 #
75 $SIG{'ALRM'} = "IGNORE";
76 alarm (0);
77
78 #
79 # Get the current time/date.
80 #
81 my ($sec, $min, $hour) = (localtime(time));
82 my $mesg = sprintf ("%02d:%02d:%02d", $hour, $min, $sec);
83
84 #
85 # Add the line to the scrolling window.
86 #
87 $clock->set ('Message' => ["Current Time: </B/$sec>$mesg"]);
88
89 #
90 # Reset the alarm.
91 #
92 $SIG{'ALRM'} = "littleWeeClock";
93 alarm (1);
94 }
+0
-120
demos/bday less more
0 #!/usr/bin/perl -w
1 # $Id: bday,v 1.3 2002/07/24 10:04:30 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Calendar Widget
6
7 # Set some global variables.
8 my %birthdays = ();
9 my %appointments = ();
10 my %anniversay = ();
11
12 # Initialize Cdk.
13 use Cdk;
14 Cdk::init();
15
16 # Create the calendar object.
17 my $calendar = new Cdk::Calendar ('Dattrib' => "</32/B>",
18 'Mattrib' => "</5/B>",
19 'Yattrib' => "</24/B>",
20 'Highlight' => "</R>");
21
22 # Create the scrolling window.
23 my $swindow = new Cdk::Swindow ('Title' => "<C></B/5>Date Information",
24 'Lines' => 300,
25 'Height' => 4,
26 'Width' => 50,
27 'Ypos' => "BOTTOM");
28
29 # Set the key binding for the calendar widget.
30 $calendar->bind ('Key' => "m", 'Function' => sub { setMarkerCB ($calendar);});
31
32 # Set the post-process function for the calendar widget.
33 $calendar->postProcess ('Function' => sub { checkDatePP ($calendar);});
34
35 # Draw the scrolling window.
36 $swindow->draw();
37
38 # Let the user play.
39 for (;;)
40 {
41 # Activate the object.
42 my $ret = $calendar->activate();
43 }
44
45 # Exit Cdk.
46 Cdk::end();
47
48 #
49 # This checks if the current date has a marker set on it.
50 #
51 sub checkDatePP
52 {
53 my $calendar = shift;
54 }
55
56 #
57 # This allows the user to create a marker.
58 #
59 sub setMarkerCB
60 {
61 my $calendar = shift;
62 my @mesg = ("<C></B/5>What type of a marker is it?");
63 my @buttons = ("</B/3>Birthday", "</B/5>Anniversary", "</B/30>Appointment");
64
65 # Get the current date the marker is at.
66 my ($day, $month, $year) = $calendar->getDate();
67
68 # Ask the user what type of marker to add.
69 my $dialog = new Cdk::Dialog ('Message' => \@mesg, 'Buttons' => \@buttons);
70 my $choice = $dialog->activate();
71 undef $dialog;
72
73 # If they hit escape, tell them...
74 if (!defined $choice)
75 {
76 popupLabel (["Escape Hit. No marker set."]);
77 $calendar->draw();
78 return 1;
79 }
80
81 # Check the choice.
82 if ($choice == 0)
83 {
84 addBirthdayMarker ($day, $month, $year);
85 }
86 elsif ($choice == 1)
87 {
88 addAnniversaryMarker ($day, $month, $year);
89 }
90 elsif ($choice == 2)
91 {
92 addAppointmentMarker ($day, $month, $year);
93 }
94 return 1;
95 }
96
97 #
98 #
99 #
100 sub addBirthdayMarker
101 {
102 my ($day, $month, $year) = @_;
103 }
104
105 #
106 #
107 #
108 sub addAnniversaryMarker
109 {
110 my ($day, $month, $year) = @_;
111 }
112
113 #
114 #
115 #
116 sub addAppointmentMarker
117 {
118 my ($day, $month, $year) = @_;
119 }
0 /* $Id: clock.c,v 1.8 2005/12/27 18:08:22 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName="label_ex";
6 #endif
7
8 int main (int argc, char **argv)
9 {
10 /* Declare variables. */
11 CDKSCREEN *cdkscreen = 0;
12 CDKLABEL *demo = 0;
13 WINDOW *cursesWin = 0;
14 int boxLabel = 0;
15 char *mesg[4], temp[256];
16 struct tm *currentTime;
17 time_t clck;
18 int ret;
19
20 /* Parse up the command line. */
21 while ((ret = getopt (argc, argv, "b")) != -1)
22 {
23 switch (ret)
24 {
25 case 'b' :
26 boxLabel = 1;
27 }
28 }
29
30 /* Set up CDK */
31 cursesWin = initscr();
32 cdkscreen = initCDKScreen (cursesWin);
33
34 /* Start CDK Colors */
35 initCDKColor();
36
37 /* Set the labels up. */
38 mesg[0] = "</1/B>HH:MM:SS";
39
40 /* Declare the labels. */
41 demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 1, boxLabel, FALSE);
42
43 /* Is the label null??? */
44 if (demo == 0)
45 {
46 /* Clean up the memory. */
47 destroyCDKScreen (cdkscreen);
48
49 /* End curses... */
50 endCDK();
51
52 /* Spit out a message. */
53 printf ("Oops. Can't seem to create the label. Is the window too small?\n");
54 ExitProgram (EXIT_FAILURE);
55 }
56
57 curs_set(0);
58 wtimeout (WindowOf(demo), 50);
59
60 /* Do this for-a-while... */
61 do
62 {
63 /* Get the current time. */
64 time(&clck);
65 currentTime = localtime (&clck);
66
67 /* Put the current time in a string. */
68 sprintf (temp, "<C></B/29>%02d:%02d:%02d", currentTime->tm_hour, currentTime->tm_min, currentTime->tm_sec);
69 mesg[0] = copyChar (temp);
70
71 /* Set the label contents. */
72 setCDKLabel (demo, mesg, 1, ObjOf(demo)->box);
73
74 /* Clean up the memory used. */
75 freeChar (mesg[0]);
76
77 /* Draw the label, and sleep. */
78 drawCDKLabel (demo, ObjOf(demo)->box);
79 napms (500);
80 }
81 while (wgetch(WindowOf(demo)) == ERR);
82
83 /* Clean up */
84 destroyCDKLabel (demo);
85 destroyCDKScreen (cdkscreen);
86 endCDK();
87
88 ExitProgram (EXIT_SUCCESS);
89 }
0 /* $Id: command.c,v 1.16 2005/12/27 18:11:54 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName="command";
6 #endif
7
8 /* Define some global variables. */
9 #define MAXHISTORY 5000
10 static char *introductionMessage[] = {
11 "<C></B/16>Little Command Interface", "",
12 "<C>Written by Mike Glover", "",
13 "<C>Type </B>help<!B> to get help."};
14
15 /* This structure is used for keeping command history. */
16 struct history_st {
17 int count;
18 int current;
19 char *command[MAXHISTORY];
20 };
21
22 /* Define some local prototypes. */
23 char *uc (char *word);
24 void help (CDKENTRY *entry);
25 static BINDFN_PROTO(historyUpCB);
26 static BINDFN_PROTO(historyDownCB);
27 static BINDFN_PROTO(viewHistoryCB);
28 static BINDFN_PROTO(listHistoryCB);
29 static BINDFN_PROTO(jumpWindowCB);
30
31 /*
32 * Written by: Mike Glover
33 * Purpose:
34 * This creates a very simple command interface.
35 */
36 int main(int argc, char **argv)
37 {
38 /* Declare variables. */
39 CDKSCREEN *cdkscreen = 0;
40 CDKSWINDOW *commandOutput = 0;
41 CDKENTRY *commandEntry = 0;
42 WINDOW *cursesWin = 0;
43 chtype *convert = 0;
44 char *command = 0;
45 char *upper = 0;
46 char *prompt = "</B/24>Command >";
47 char *title = "<C></B/5>Command Output Window";
48 int promptLen = 0;
49 int commandFieldWidth = 0;
50 struct history_st history;
51 char temp[600];
52 int ret, junk;
53
54 /* Set up the history. */
55 history.current = 0;
56 history.count = 0;
57
58 /* Check the command line for options. */
59 while (1)
60 {
61 /* Are there any more command line options to parse. */
62 if ((ret = getopt (argc, argv, "t:p:")) == -1)
63 {
64 break;
65 }
66 switch (ret)
67 {
68 case 'p':
69 prompt = copyChar (optarg);
70 break;
71
72 case 't':
73 title = copyChar (optarg);
74 break;
75
76 default:
77 break;
78 }
79 }
80
81 /* Set up CDK. */
82 cursesWin = initscr();
83 cdkscreen = initCDKScreen (cursesWin);
84
85 /* Start color. */
86 initCDKColor();
87
88 /* Create the scrolling window. */
89 commandOutput = newCDKSwindow (cdkscreen, CENTER, TOP, -8, -2,
90 title, 1000, TRUE, FALSE);
91
92 /* Convert the prompt to a chtype and determine its length. */
93 convert = char2Chtype (prompt, &promptLen, &junk);
94 commandFieldWidth = COLS - promptLen - 4;
95 freeChtype (convert);
96
97 /* Create the entry field. */
98 commandEntry = newCDKEntry (cdkscreen, CENTER, BOTTOM,
99 0, prompt, A_BOLD|COLOR_PAIR(8), COLOR_PAIR(24)|'_',
100 vMIXED, commandFieldWidth, 1, 512, FALSE, FALSE);
101
102 /* Create the key bindings. */
103 bindCDKObject (vENTRY, commandEntry, KEY_UP, historyUpCB, &history);
104 bindCDKObject (vENTRY, commandEntry, KEY_DOWN, historyDownCB, &history);
105 bindCDKObject (vENTRY, commandEntry, KEY_TAB, viewHistoryCB, commandOutput);
106 bindCDKObject (vENTRY, commandEntry, CTRL('^'), listHistoryCB, &history);
107 bindCDKObject (vENTRY, commandEntry, CTRL('G'), jumpWindowCB, commandOutput);
108
109 /* Draw the screen. */
110 refreshCDKScreen (cdkscreen);
111
112 /* Show them who wrote this and how to get help. */
113 popupLabel (cdkscreen, introductionMessage, 5);
114 eraseCDKEntry (commandEntry);
115
116 /* Do this forever. */
117 for (;;)
118 {
119 /* Get the command. */
120 drawCDKEntry (commandEntry, ObjOf(commandEntry)->box);
121 command = activateCDKEntry (commandEntry, 0);
122 upper = uc (command);
123
124 /* Check the output of the command. */
125 if (strcmp (upper, "QUIT") == 0 ||
126 strcmp (upper, "EXIT") == 0 ||
127 strcmp (upper, "Q") == 0 ||
128 strcmp (upper, "E") == 0 ||
129 commandEntry->exitType == vESCAPE_HIT)
130 {
131 /* All done. */
132 freeChar (upper);
133
134 while (history.count-- > 0)
135 free (history.command[history.count]);
136
137 destroyCDKEntry (commandEntry);
138 destroyCDKSwindow (commandOutput);
139 destroyCDKScreen (cdkscreen);
140
141 endCDK();
142
143 ExitProgram (EXIT_SUCCESS);
144 }
145 else if (strcmp (command, "clear") == 0)
146 {
147 /* Keep the history. */
148 history.command[history.count] = copyChar (command);
149 history.count++;
150 history.current = history.count;
151 cleanCDKSwindow (commandOutput);
152 cleanCDKEntry (commandEntry);
153 }
154 else if (strcmp (command, "history") == 0)
155 {
156 /* Display the history list. */
157 listHistoryCB (vENTRY, commandEntry, &history, 0);
158
159 /* Keep the history. */
160 history.command[history.count] = copyChar (command);
161 history.count++;
162 history.current = history.count;
163 }
164 else if (strcmp (command, "help") == 0)
165 {
166 /* Keep the history. */
167 history.command[history.count] = copyChar (command);
168 history.count++;
169 history.current = history.count;
170
171 /* Display the help. */
172 help (commandEntry);
173
174 /* Clean the entry field. */
175 cleanCDKEntry (commandEntry);
176 eraseCDKEntry (commandEntry);
177 }
178 else
179 {
180 /* Keep the history. */
181 history.command[history.count] = copyChar (command);
182 history.count++;
183 history.current = history.count;
184
185 /* Jump to the bottom of the scrolling window. */
186 jumpToLineCDKSwindow (commandOutput, BOTTOM);
187
188 /* Insert a line providing the command. */
189 sprintf (temp, "Command: </R>%s", command);
190 addCDKSwindow (commandOutput, temp, BOTTOM);
191
192 /* Run the command. */
193 execCDKSwindow (commandOutput, command, BOTTOM);
194
195 /* Clean out the entry field. */
196 cleanCDKEntry (commandEntry);
197 }
198
199 /* Clean up a little. */
200 freeChar (upper);
201 }
202 }
203
204 /*
205 * This is the callback for the down arrow.
206 */
207 static int historyUpCB (EObjectType cdktype GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED)
208 {
209 CDKENTRY *entry = (CDKENTRY *)object;
210 struct history_st *history = (struct history_st *) clientData;
211
212 /* Make sure we don't go out of bounds. */
213 if (history->current == 0)
214 {
215 Beep();
216 return (FALSE);
217 }
218
219 /* Decrement the counter. */
220 history->current--;
221
222 /* Display the command. */
223 setCDKEntryValue (entry, history->command[history->current]);
224 drawCDKEntry (entry, ObjOf(entry)->box);
225 return (FALSE);
226 }
227
228 /*
229 * This is the callback for the down arrow.
230 */
231 static int historyDownCB (EObjectType cdktype GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED)
232 {
233 CDKENTRY *entry = (CDKENTRY *)object;
234 struct history_st *history = (struct history_st *) clientData;
235
236 /* Make sure we don't go out of bounds. */
237 if (history->current == history->count)
238 {
239 Beep();
240 return (FALSE);
241 }
242
243 /* Increment the counter... */
244 history->current++;
245
246 /* If we are at the end, clear the entry field. */
247 if (history->current == history->count)
248 {
249 cleanCDKEntry (entry);
250 drawCDKEntry (entry, ObjOf(entry)->box);
251 return (FALSE);
252 }
253
254 /* Display the command. */
255 setCDKEntryValue (entry, history->command[history->current]);
256 drawCDKEntry (entry, ObjOf(entry)->box);
257 return (FALSE);
258 }
259
260 /*
261 * This callback allows the user to play with the scrolling window.
262 */
263 static int viewHistoryCB (EObjectType cdktype GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED)
264 {
265 CDKSWINDOW *swindow = (CDKSWINDOW *)clientData;
266 CDKENTRY *entry = (CDKENTRY *)object;
267
268 /* Let them play... */
269 activateCDKSwindow (swindow, 0);
270
271 /* Redraw the entry field. */
272 drawCDKEntry (entry, ObjOf(entry)->box);
273 return (FALSE);
274 }
275
276 /*
277 * This callback jumps to a line in the scrolling window.
278 */
279 static int jumpWindowCB (EObjectType cdktype GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED)
280 {
281 CDKENTRY *entry = (CDKENTRY *)object;
282 CDKSWINDOW *swindow = (CDKSWINDOW *)clientData;
283 CDKSCALE *scale = 0;
284 int line;
285
286 /* Ask them which line they want to jump to. */
287 scale = newCDKScale (ScreenOf(entry), CENTER, CENTER,
288 "<C>Jump To Which Line",
289 "Line",
290 A_NORMAL, 5,
291 0, 0, swindow->listSize, 1, 2, TRUE, FALSE);
292
293 /* Get the line. */
294 line = activateCDKScale (scale, 0);
295
296 /* Clean up. */
297 destroyCDKScale (scale);
298
299 /* Jump to the line. */
300 jumpToLineCDKSwindow (swindow, line);
301
302 /* Redraw the widgets. */
303 drawCDKEntry (entry, ObjOf(entry)->box);
304 return (FALSE);
305 }
306
307 /*
308 * This callback allows the user to pick from the history list from a
309 * scrolling list.
310 */
311 static int listHistoryCB (EObjectType cdktype GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED)
312 {
313 CDKENTRY *entry = (CDKENTRY *)object;
314 struct history_st *history = (struct history_st *) clientData;
315 CDKSCROLL *scrollList;
316 int height = (history->count < 10 ? history->count+3 : 13);
317 int selection;
318
319 /* No history, no list. */
320 if (history->count == 0)
321 {
322 /* Popup a little window telling the user there are no commands. */
323 char *mesg[] = {"<C></B/16>No Commands Entered", "<C>No History"};
324 popupLabel (ScreenOf(entry), mesg, 2);
325
326 /* Redraw the screen. */
327 eraseCDKEntry (entry);
328 drawCDKScreen (ScreenOf(entry));
329
330 /* And leave... */
331 return (FALSE);
332 }
333
334 /* Create the scrolling list of previous commands. */
335 scrollList = newCDKScroll (ScreenOf(entry), CENTER, CENTER, RIGHT,
336 height, 20, "<C></B/29>Command History",
337 history->command, history->count,
338 NUMBERS, A_REVERSE, TRUE, FALSE);
339
340 /* Get the command to execute. */
341 selection = activateCDKScroll (scrollList, 0);
342 destroyCDKScroll (scrollList);
343
344 /* Check the results of the selection. */
345 if (selection >= 0)
346 {
347 /* Get the command and stick it back in the entry field. */
348 setCDKEntryValue (entry, history->command[selection]);
349 }
350
351 /* Redraw the screen. */
352 eraseCDKEntry (entry);
353 drawCDKScreen (ScreenOf(entry));
354 return (FALSE);
355 }
356
357 /*
358 * This function displays help.
359 */
360 void help (CDKENTRY *entry)
361 {
362 char *mesg[25];
363
364 /* Create the help message. */
365 mesg[0] = "<C></B/29>Help";
366 mesg[1] = "";
367 mesg[2] = "</B/24>When in the command line.";
368 mesg[3] = "<B=history > Displays the command history.";
369 mesg[4] = "<B=Ctrl-^ > Displays the command history.";
370 mesg[5] = "<B=Up Arrow > Scrolls back one command.";
371 mesg[6] = "<B=Down Arrow> Scrolls forward one command.";
372 mesg[7] = "<B=Tab > Activates the scrolling window.";
373 mesg[8] = "<B=help > Displays this help window.";
374 mesg[9] = "";
375 mesg[10] = "</B/24>When in the scrolling window.";
376 mesg[11] = "<B=l or L > Loads a file into the window.";
377 mesg[12] = "<B=s or S > Saves the contents of the window to a file.";
378 mesg[13] = "<B=Up Arrow > Scrolls up one line.";
379 mesg[14] = "<B=Down Arrow> Scrolls down one line.";
380 mesg[15] = "<B=Page Up > Scrolls back one page.";
381 mesg[16] = "<B=Page Down > Scrolls forward one page.";
382 mesg[17] = "<B=Tab/Escape> Returns to the command line.";
383 mesg[18] = "";
384 mesg[19] = "<C> (</B/24>Refer to the scrolling window online manual for more help<!B!24>.)";
385 popupLabel (ScreenOf(entry), mesg, 20);
386 }
387
388 /*
389 * This converts a word to upper case.
390 */
391 char *uc (char *word)
392 {
393 char *upper = 0;
394 int length = 0;
395 int x;
396
397 /* Make sure the word is not null. */
398 if (word == 0)
399 {
400 return 0;
401 }
402 length = strlen (word);
403
404 /* Get the memory for the new word. */
405 upper = (char *)malloc (sizeof (char *) * (length+2));
406 if (upper == 0)
407 {
408 return (word);
409 }
410
411 /* Start converting the case. */
412 for (x=0; x < length; x++)
413 {
414 int ch = (unsigned char)(word[x]);
415 if (isalpha (ch))
416 {
417 upper[x] = toupper(ch);
418 }
419 else
420 {
421 upper[x] = word[x];
422 }
423 }
424 upper[length] = '\0';
425 return upper;
426 }
0 /* $Id: fileview.c,v 1.10 2005/12/27 18:13:14 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName="codeViewer";
6 #endif
7
8 /*
9 * This program demonstrates the file selector and the viewer widget.
10 */
11 int main (int argc, char **argv)
12 {
13 /* Declare variables. */
14 CDKSCREEN *cdkscreen = 0;
15 CDKVIEWER *example = 0;
16 CDKFSELECT *fSelect = 0;
17 WINDOW *cursesWin = 0;
18 char *title = "<C>Pick a file.";
19 char *label = "File: ";
20 char *directory = ".";
21 char *filename = 0;
22 char **info = 0;
23 char *button[5], vtitle[256], *mesg[4], temp[256];
24 int selected, lines, ret;
25
26 /* Parse up the command line. */
27 while (1)
28 {
29 ret = getopt (argc, argv, "d:f:");
30 if (ret == -1)
31 {
32 break;
33 }
34 switch (ret)
35 {
36 case 'd' :
37 directory = strdup (optarg);
38 break;
39
40 case 'f' :
41 filename = strdup (optarg);
42 break;
43 }
44 }
45
46 /* Create the viewer buttons. */
47 button[0] = "</5><OK><!5>";
48 button[1] = "</5><Cancel><!5>";
49
50 /* Set up CDK. */
51 cursesWin = initscr();
52 cdkscreen = initCDKScreen (cursesWin);
53
54 /* Start color. */
55 initCDKColor();
56
57 /* Get the filename. */
58 if (filename == 0)
59 {
60 fSelect = newCDKFselect (cdkscreen, CENTER, CENTER, 20, 65,
61 title, label, A_NORMAL, '_', A_REVERSE,
62 "</5>", "</48>", "</N>", "</N>", TRUE, FALSE);
63
64 /*
65 * Set the starting directory. This is not neccessary because when
66 * the file selector starts it uses the present directory as a default.
67 */
68 setCDKFselect (fSelect, directory, A_NORMAL, '.', A_REVERSE,
69 "</5>", "</48>", "</N>", "</N>", ObjOf(fSelect)->box);
70
71 /* Activate the file selector. */
72 filename = copyChar (activateCDKFselect (fSelect, 0));
73
74 /* Check how the person exited from the widget. */
75 if (fSelect->exitType == vESCAPE_HIT)
76 {
77 /* Pop up a message for the user. */
78 mesg[0] = "<C>Escape hit. No file selected.";
79 mesg[1] = "";
80 mesg[2] = "<C>Press any key to continue.";
81 popupLabel (cdkscreen, mesg, 3);
82
83 /* Destroy the file selector. */
84 destroyCDKFselect (fSelect);
85
86 /* Exit CDK. */
87 destroyCDKScreen (cdkscreen);
88 endCDK();
89
90 ExitProgram (EXIT_SUCCESS);
91 }
92 }
93
94 /* Destroy the file selector. */
95 destroyCDKFselect (fSelect);
96
97 /* Create the file viewer to view the file selected.*/
98 example = newCDKViewer (cdkscreen, CENTER, CENTER, 20, -2,
99 button, 2, A_REVERSE, TRUE, FALSE);
100
101 /* Could we create the viewer widget? */
102 if (example == 0)
103 {
104 /* Exit CDK. */
105 destroyCDKScreen (cdkscreen);
106 endCDK();
107
108 /* Print out a message and exit. */
109 printf ("Oops. Can't seem to create viewer. Is the window too small?\n");
110 ExitProgram (EXIT_SUCCESS);
111 }
112
113 /* Open the file and read the contents. */
114 lines = CDKreadFile (filename, &info);
115 if (lines == -1)
116 {
117 printf ("Could not open %s\n", filename);
118 ExitProgram (EXIT_FAILURE);
119 }
120
121 /* Set up the viewer title, and the contents to the widget. */
122 sprintf (vtitle, "<C></B/22>%20s<!22!B>", filename);
123 setCDKViewer (example, vtitle, info, lines, A_REVERSE, TRUE, TRUE, TRUE);
124
125 /* Activate the viewer widget. */
126 selected = activateCDKViewer (example, 0);
127
128 /* Check how the person exited from the widget.*/
129 if (example->exitType == vESCAPE_HIT)
130 {
131 mesg[0] = "<C>Escape hit. No Button selected.";
132 mesg[1] = "";
133 mesg[2] = "<C>Press any key to continue.";
134 popupLabel (cdkscreen, mesg, 3);
135 }
136 else if (example->exitType == vNORMAL)
137 {
138 sprintf (temp, "<C>You selected button %d", selected);
139 mesg[0] = copyChar (temp);
140 mesg[1] = "";
141 mesg[2] = "<C>Press any key to continue.";
142 popupLabel (cdkscreen, mesg, 3);
143 free (mesg[0]);
144 }
145
146 /* Clean up. */
147 destroyCDKViewer (example);
148 destroyCDKScreen (cdkscreen);
149 CDKfreeStrings (info);
150 freeChar (filename);
151
152 endCDK();
153
154 ExitProgram (EXIT_SUCCESS);
155 }
+0
-414
demos/perlbug less more
0 #!/usr/bin/perl -w
1 # $Id: perlbug,v 1.3 2002/07/27 20:07:47 tom Exp $
2
3 #
4 # Purpose:
5 # This 'rips' off Larry's perlbug from the utils directory.
6
7 # Determine if the user has one of the mail modules.
8 BEGIN {
9 eval "use Mail::Send;";
10 $::HaveSend = ($@ eq "");
11 };
12
13 use Config;
14 use Sys::Hostname;
15 use Getopt::Std;
16
17 #
18 # Load in the Cdk Extension.
19 #
20 use Cdk;
21 Cdk::init();
22
23 # Create global variables.
24 my ($Version) = "1.00";
25 my $address = "perlbug\@perl.com";
26
27 # Check the command line arguments.
28 getopts("c:a:f:r:s:vh");
29
30 # Did they ask for help?
31 if (defined $opt_h)
32 {
33 my @help = ("<C></B/5>Perl Bug Reporting Facility Help Window.",
34 "</B/5>Usage:<!B!5> $0 [-c CC] [-a Admin Account]",
35 " [-r Reply Account] [-s subject]",
36 " [-f filename] [-v] [-h]", "",
37 "<B=-c> The account to carbon copy to.",
38 "<B=-a> The perl admin account.",
39 "<B=-r> The account to reply to.",
40 "<B=-s> The subject of the bug report.",
41 "<B=-f> The file to read in as the bug report.",
42 "<B=-v> Turns on verbose output for the bug report.",
43 "<B=-h> Pops up this help window.", "",
44 "<C></B/5>Press Any Key To Continue.");
45 popupLabel (\@help);
46 }
47
48 # Create a program information message.
49 my @progInfo = ("<C></5/B>Perl Bug Reporting Facility",
50 "<C></24/B>Version $Version", "",
51 "This program allows you to create a bug report which will be",
52 "mailed to </B>$address<!B> once the report has been filled out.", "",
53 "<C>Hit any key when you are ready to start.");
54 popupLabel (\@progInfo);
55
56 # Create the generic label.
57 my @mesg = ("******************************************************",
58 "******************************************************",
59 "******************************************************",
60 "******************************************************");
61 my $mainTitle = new Cdk::Label ('Message' => \@mesg, 'Xpos' => "TOP");
62
63 # Get the subject to the mail message.
64 my $subject = $opt_s || getSubject ($mainTitle);
65 my $verbose = $opt_v;
66
67 # Get the reply address.
68 @mesg = ("<C></B/24>Return Email Address",
69 "<C>Enter your return e-mail address.");
70 my $defaultAddress = getlogin() . "@" . hostname() . ".";
71 my $replyAddress = $opt_r || getEmailAddress ($mainTitle, $defaultAddress, @mesg);
72
73 # Get the perl admin address.
74 @mesg = ("<C></B/24>Perl Admin Email Address",
75 "<C>Enter the email address of the perl admin.");
76 my $defaultAddress = $::Config{perladmin};
77 my $adminAddress = $opt_a || getEmailAddress ($mainTitle, $defaultAddress, @mesg);
78
79 # Create the bug report.
80 my @report = createBugReport ($mainTitle, $subject, $opt_f);
81
82 # View the bug report.
83 viewBugReport($subject, $replyAddress, $adminAddress, $cc, @report);
84 exit;
85
86 ############################################################################
87 #
88 # This gets the subject to the bug report.
89 #
90 sub getSubject
91 {
92 my $mainTitle = shift;
93
94 # Create the subject entry field.
95 my $entry = new Cdk::Entry ('Label' => "</B/5>Subject: ",
96 'Width' => 35,
97 'Min' => 3,
98 'Max' => 256);
99
100 # Set the main title info.
101 @mesg = ("<C></24/B>Enter Subject",
102 "<C>Please provide a subject for the message. It",
103 "<C>should be as a concise description of the bug",
104 "<C>as is possible.");
105 $mainTitle->set ('Message' => \@mesg);
106 $mainTitle->draw();
107
108 # Get the subject.
109 while (1)
110 {
111 my $subject = $entry->activate();
112 last if defined $subject;
113
114 # No subject, prompt them for one...
115 popupLabel (["<C></16/B>Error",
116 "<C>You must have a subject line for the mail message.", "",
117 "<C>Please try again."]);
118 }
119 return $subject;
120 }
121
122 ############################################################################
123 #
124 # This gets an emial address.
125 #
126 sub getEmailAddress
127 {
128 my ($mainTitle, $entryValue, @mesg) = @_;
129 my $info;
130
131 # Set the main title info.
132 $mainTitle->set ('Message' => \@mesg);
133
134 # Create the entry field to get the email address.
135 $entry = new Cdk::Entry ('Label' => "</B/5>email Address: ",
136 'Min' => 3,
137 'Max' => 256,
138 'Width' => 35);
139
140 # Put the user name in the entry field.
141 $entry->set ('Value' => "$entryValue");
142
143 # Get the emial address
144 while (1)
145 {
146 $info = $entry->activate();
147 last if defined $info;
148
149 # No subject, prompt them for one...
150 popupLabel (["<C></B/16>Error",
151 "<C>You must provide an email address.", "",
152 "<C>Please Try again."]);
153 }
154 return $info;
155 }
156
157 ############################################################################
158 #
159 # This gets the bug report from the user.
160 #
161 sub createBugReport
162 {
163 my ($mainTitle, $subject, $filename) = @_;
164 my @bugReport = ();
165 my @info = ();
166
167 # If a filename has been speicifed, then we will use the contents of the
168 # file for the bug report.
169 if (defined $filename && -e $filename)
170 {
171 open (FILE, $filename);
172 my @tmp = <FILE>;
173 chomp (@tmp);
174 return @tmp;
175 }
176
177 # Create the title.
178 my @mesg = ("<C></24/B>Bug Report",
179 "<C>Enter a description of the bug you are submitting.");
180
181 # Set the main title info.
182 $mainTitle->set ('Message' => \@mesg);
183
184 # Create the entry field to get the email address.
185 $entry = new Cdk::Mentry ('Label' => "</B/5>Description: ",
186 'Prows' => 8,
187 'Lrows' => 15,
188 'Width' => 50);
189
190 # Get the bug report.
191 while (1)
192 {
193 $info = $entry->activate();
194 last if defined $info;
195
196 # No subject, prompt them for one...
197 popupLabel (["<C></B/16>Error",
198 "<C>You must provide a description of the bug.", "",
199 "<C>Please Try again."]);
200 }
201
202 # Split the string into a list.
203 my @info = Cdk::scalar2List ($info, 40);
204
205 # Create the bug report.
206 push (@bugReport, "This is a bug report for perl from $from generated with");
207 push (@bugReport, "the help of the Cdk version of perlbug running under perl $].");
208 push (@bugReport, "");
209 push (@bugReport, "Subject: $subject");
210 push (@bugReport, "");
211 for ($x=0; $x <= $#info; $x++)
212 {
213 push (@bugReport, $info[$x]);
214 }
215 push (@bugReport, "");
216 push (@bugReport, "Site configuration information for perl $]:");
217
218 if ($::Config{cf_by} and $::Config{cf_time})
219 {
220 push (@bugReport, "Configured by $::Config{cf_by} at $::Config{cf_time}.");
221 }
222 push (@bugReport, "");
223 foreach (split (/\n/, Config::myconfig))
224 {
225 push (@bugReport, $_);
226 }
227
228 # Do they want a verbose bug report?
229 if ($::opt_v)
230 {
231 push (@bugReport, "");
232 push (@bugReport, "Complete configuration data for perl $]:");
233 push (@bugReport, "");
234 foreach (sort keys %::Config)
235 {
236 my $value = $::Config{$_};
237 $value =~ s/'/\\'/g;
238 push (@bugReport, "$_='$value'");
239 }
240 }
241 return @bugReport;
242 }
243
244 ############################################################################
245 #
246 # This views the bug report.
247 #
248 sub viewBugReport
249 {
250 my ($subject, $replyAddress, $adminAddress, @bugReport) = @_;
251 my @buttons = ("</B/24>OK");
252
253 # Get the height and width of the screen.
254 my ($height, $width) = Cdk::getCdkScreenDim();
255 $height -= 3;
256 $width -= 3;
257
258 # Create the file viewer.
259 my $viewer = new Cdk::Viewer ('Buttons' => \@buttons,
260 'Height' => $height,
261 'Width' => $width);
262
263 # Fill the viewer with the contents of the bug report.
264 $viewer->set ('Title' => "<C></5>Bug Report",
265 'Highlight' => "</B/5>",
266 'Info' => \@bugReport);
267 $viewer->activate();
268
269 # Ask them what they want to do with the bug report.
270 my @mesg = ("<C>Now that the bug report has been created, you can",
271 "<C>send the bug report to </R>$replyAddress<!R> and </R>$adminAddress<!R>,",
272 "<C>or you can save the report to a file and send it later",
273 "<C>on your own, or you can quit without saving or sending",
274 "<C>the bug report.");
275 my @buttons = ("</B/24>Send", "</B/8>Save", "</B/16>Cancel");
276 my $choice = popupDialog (\@mesg, \@buttons);
277
278 # Redraw the viewer widget.
279 $viewer->draw();
280
281 # Check what they want to do.
282 if ($choice == 0)
283 {
284 # Mail to bug report.
285 sendBugReport ($subject, $replyAddress, $adminAddress, @bugReport);
286 }
287 elsif ($choice == 1)
288 {
289 # Save to a file.
290 saveBugReport (@bugReport);
291 }
292 else
293 {
294 popupLabel (["<C></B/24>Send Bug Report Canceled."]);
295 }
296 }
297
298 #
299 # This saves the bug report to a file.
300 #
301 sub saveBugReport
302 {
303 my @bugReport = @_;
304
305 # Get the filename to save to.
306 my $entry = new Cdk::Entry ('Label' => "</B/5>Filename: ",
307 'Width' => 30,
308 'Min' => 2,
309 'Max' => 256);
310
311 # Make sure we can write to the file.
312 while (1)
313 {
314 # Get the filename.
315 $filename = $entry->activate();
316
317 # Try to open the filename.
318 last if open (FILE, ">$filename");
319
320 popupLabel (["<C></B/16>Error", "<C>Can not save to the file $filename"]);
321 }
322
323 # Save the bug report to the file.
324 foreach (@bugReport)
325 {
326 print FILE "$_\n";
327 }
328 close (FILE);
329
330 # Tell the user the file has been saved.
331 popupLabel (["The bug report has been saved to $filename", "",
332 "<C>Press any key to continue."]);
333 }
334
335 #
336 # This sends the bug report to the given addresses.
337 #
338 sub sendBugReport
339 {
340 my ($subject, $replyAddress, $adminAddress, $cc, @bugReport) = @_;
341 my $address = "perlbug\@perl.com";
342
343 # Do we have the sendmail module?
344 if ($::HaveSend)
345 {
346 # Create a mail object.
347 my $mailMessage = new Mail::Send ('Subject' => "$subject",
348 'To' => "$address");
349
350 # Add a carbon copy, if we have one.
351 $mailMessage->cc ($cc) if $cc;
352
353 # Add a from line.
354 $mailMessage->add ("Reply-To" => $replyAddress) if $replyAddress;
355
356 # Open the mail message and write the contents.
357 $fh = $msg->open;
358 foreach (@bugReport)
359 {
360 print $fh "$_\n";
361 }
362
363 # Close the mail message (aka send it.)
364 $fh->close;
365
366 # Popup a little message.
367 popupLabel (["<C>The bug report has been sent."]);
368 return;
369 }
370 else
371 {
372 # No, Okay, let's try to use sendmail normally. (normally????)
373 my $sendmail = "";
374
375 # Where oh where are you you today...
376 foreach (qw(/usr/lib/sendmail /usr/sbin/sendmail /usr/ucblib/sendmail))
377 {
378 $sendmail = $_, last if -e $_;
379 }
380
381 # Can we even send the bug report?
382 if ($sendmail eq "")
383 {
384 # We can't send the bug report, maybe we can save it to a file.
385 my @mesg = ("</B/5>Hmmmm.",
386 "<C>I'm terribly sorry but I can't find sendmail and the package",
387 "<C>Mail::Send has not been installed, so I can't send your bug",
388 "<C>report. Since I can't send the bug report, would you like to",
389 "<C>save it to a file and send it yourself?");
390 if (popupDialog (\@mesg, ["Yep", "Nope"]) == 0)
391 {
392 saveBugReport (@bugReport);
393 }
394 return;
395 }
396
397 # Send the message via sendmail.
398 open (SENDMAIL,"|$sendmail -t");
399 print SENDMAIL "To: $address\n";
400 print SENDMAIL "Subject: $subject\n";
401 print SENDMAIL "Cc: $cc\n" if $cc;
402 print SENDMAIL "Reply-To: $replyAddress\n" if $replyAddress;
403 print SENDMAIL "\n\n";
404 foreach (@bugReport)
405 {
406 print SENDMAIL "$_\n";
407 }
408 close(SENDMAIL);
409
410 # Popup a little message.
411 popupLabel (["<C>The bug report has been sent."]);
412 }
413 }
+0
-269
demos/pkgInfo less more
0 #!/usr/bin/perl -w
1 # $Id: pkgInfo,v 1.3 2002/07/27 20:07:36 tom Exp $
2
3 #
4 # This script provideds a user interface to packages on the system.
5 #
6 use Cdk;
7 Cdk::init();
8
9 # Create a dialog box with options.
10 my @dialogMessge = ("<C></U>Unix Package Interface",
11 "<C>Select an option.");
12
13 # Create the buutons for the dialog box.
14 my @buttons = ("<Add Package>", "<Remove Package>", "<Package Info>", "<Exit>");
15
16 # Create the dialog widget.
17 my $dialog = new Cdk::Dialog ('Message' => \@dialogMessge, 'Buttons' => \@buttons);
18
19 # Do this forever.
20 for (;;)
21 {
22 # Activate the dialog box.
23 my $choice = $dialog->activate();
24 next if ! defined $choice;
25
26 # Check the answer.
27 if ($choice == 0)
28 {
29 addPackage();
30 }
31 elsif ($choice == 1)
32 {
33 removePackage();
34 }
35 elsif ($choice == 2)
36 {
37 packageInfo();
38 }
39 elsif ($choice == 3)
40 {
41 # Exit.
42 Cdk::end();
43 exit;
44 }
45 }
46
47 #
48 # This function adds a package.
49 #
50 sub addPackage
51 {
52 my @packageList = ();
53 my $x;
54
55 # Set up the entry field.
56 my $mesg = "Enter the source package directory:";
57 my $entry = new Cdk::Entry ('Label' => $mesg,
58 'Max' => 512,
59 'Width' => 30);
60
61 # Get the package directory.
62 my $pkgDir = $entry->activate();
63 return if ! defined $pkgDir;
64
65 # Open the given directory.
66 if (!opendir (DIR, $pkgDir))
67 {
68 # Couldn't open the directory.
69 my @mesg = ("<C></B/U>Error",
70 "<C>Could not open the directory </B>$pkgDir",
71 "<C></U>$!", "",
72 "<C>Press any key to continue.");
73 my $label = new Cdk::Label ('Message' => \@mesg);
74 $label->draw();
75 $label->wait();
76 return;
77 }
78
79 # Get the directory listing of the given directory.
80 my @contents = readdir(DIR); closedir (DIR);
81
82 # Create a list of all of the directories under the given directory.
83 foreach $file (@contents)
84 {
85 next if $file =~ /^\./;
86 push (@packageList, $file) if (-d "$pkgDir/$file");
87 }
88
89 # Create a selection list and display the known packages.
90 my $select = new Cdk::Selection ('Title' => "Add Which Packages?",
91 'List' => \@packageList,
92 'Choices' => ["Yes ", "No"],
93 'Height' => 20,
94 'Width' => 50);
95
96 # Activate the packages.
97 my @choiceList = $select->activate();
98 my @selectedPackages = ();
99 return if ! defined @choiceList;
100
101 # Generate the names of the selected packages.
102 for ($x=0; $x <= $#choiceList; $x++)
103 {
104 if ($choiceList[$x] == 1)
105 {
106 push (@selectedPackages, $packageNames[$x]);
107 }
108 }
109 my $label = new Cdk::Label ('Message' => \@selectedPackages);
110 $label->draw();
111 $label->wait();
112 }
113
114 #
115 # This function removes a package.
116 #
117 sub removePackage
118 {
119 # Get the packages to remove.
120 my @packageNames = selectPackages("<C></U>Select the packages to delete.");
121 my @buttons = ("<No>", "<Yes>", "<Yes To ALL>");
122 my $yesToAll = 0;
123
124 # Now that we have the package names, ask for each one.
125 foreach $name (@packageNames)
126 {
127 # If they asked for all to be deleted, no need to ask
128 if (! $yesToAll)
129 {
130 # Create the dialog message.
131 my @mesg = ("<C>Are you sure you want",
132 "to delete the package </U>$name<!U>?");
133
134 # Make sure they want to do it.
135 my $dialog = new Cdk::Dialog ('Message' => \@mesg,
136 'Buttons' => \@buttons);
137
138 # Activate it.
139 my $answer = $dialog->activate();
140
141 # If the user hit escape, let the user know the package
142 # was NOT deleted.
143 if (!defined $answer)
144 {
145 popupLabel (["<C>Escape Hit", "<C>The package was </R>Not<!R> deleted."]);
146 next;
147 }
148
149 # Check the answer
150 if ($answer == 1)
151 {
152 # Delete the package
153 system ("pkgrm $name");
154 }
155 else
156 {
157 # Set the yes to all flag.
158 $yesToAll = 1;
159
160 # Delete the package
161 system ("pkgrm $name");
162 }
163 }
164 else
165 {
166 # Delete the package
167 system ("pkgrm $name");
168 }
169 }
170 }
171
172 #
173 # This function provides information about packages.
174 #
175 sub packageInfo
176 {
177 # Get the package to view.
178 my $packageName = selectPackage("<C></U>Select a package to view.");
179
180 # Get the information about the selected package.
181 my @pinfo = qx (pkginfo -l $packageName); chomp @pinfo;
182
183 # Create the information viewer.
184 my $viewer = new Cdk::Viewer ('Buttons' => ["OK"],
185 'Height' => -2,
186 'Width' => -4);
187
188 # Activate the viewer.
189 $viewer->set ('Title' => "<C>Package Name: </U>$packageName<!U>",
190 'Info' => \@pinfo,
191 'Interp' => "FALSE");
192 $viewer->activate ();
193 }
194
195 #
196 # This function creates a scrolling list of all the packages on the system
197 # and returns the name of the package selected.
198 #
199 sub selectPackage
200 {
201 my $title = shift;
202
203 # Get a list of all the packages installed on the system.
204 my @packageList = qx (pkginfo);
205 my @packageNames = ();
206
207 # Strip out the names of the packages.
208 foreach $PKG (@packageList)
209 {
210 my $pkgName = (split (/\s+/, $PKG))[1];
211 push (@packageNames, $pkgName);
212 }
213
214 # Create the scrolling list.
215 my $packageList = new Cdk::Scroll ('Title' => $title,
216 'List' => \@packageNames,
217 'Numbers' => "TRUE",
218 'Height' => 20,
219 'Width' => 50);
220
221 # Return the selected name.
222 my $choice = $packageList->activate();
223 return ($packageNames[$choice]);
224 }
225
226 #
227 # This function creates a selection list of all the packages on the system
228 # and returns the name of the package selected.
229 #
230 sub selectPackages
231 {
232 my $title = shift;
233 my @options = qw (Keep Delete);
234 my @selectedNames = ();
235
236 # Get a list of all the packages installed on the system.
237 my @packageList = qx (pkginfo);
238 my @packageNames = ();
239 my @selectedPackages = ();
240 my $x = 0;
241
242 # Strip out the names of the packages.
243 foreach $PKG (@packageList)
244 {
245 my $pkgName = (split (/\s+/, $PKG))[1];
246 push (@packageNames, $pkgName);
247 }
248
249 # Create the selection list.
250 my $select = new Cdk::Selection ('Title' => $title,
251 'List' => \@packageNames,
252 'Choices' => \@options,
253 'Height' => 20,
254 'Width' => 50);
255
256 # Activate the selection list.
257 my @list = $select->activate();
258
259 # Generate the names of the selected packages.
260 for ($x=0; $x <= $#packageNames; $x++)
261 {
262 if ($list[$x] == 1)
263 {
264 push (@selectedPackages, $packageNames[$x]);
265 }
266 }
267 return (@selectedPackages);
268 }
+0
-74
demos/pwdInfo less more
0 #!/usr/bin/perl -w
1 # $Id: pwdInfo,v 1.2 2002/07/27 20:07:47 tom Exp $
2
3 #
4 # This reads the passwd file and creates an interface to browse the
5 # information.
6 #
7
8 use Cdk;
9 Cdk::init();
10
11 #
12 # This function loads up the passwd file and returns a reference to the
13 # data structure.
14 #
15 sub loadPasswd
16 {
17 my %passwd = ();
18 my @logins = ();
19 my ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell);
20
21 # Start reading through the passwd file.
22 while (($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = getpwent)
23 {
24 # Store the information.
25 $passwd{$name} = "$uid$gid$comment$gcos$dir$shell";
26 push (@logins, $name);
27 }
28
29 return (\@logins, \%passwd);
30 }
31
32 # Load up the passwd file.
33 my ($logins, $passwdObject) = loadPasswd();
34
35 # Create a scrolling list of all the names.
36 my $mainScroll = new Cdk::Scroll ('Title' => '<C></U>Pick An Account',
37 'Numbers' => "TRUE",
38 'List' => $logins,
39 'Height' => 13,
40 'Width' => 45);
41
42 # Do this forever.
43 for (;;)
44 {
45 # Let the user select the login to view.
46 my $selected = $mainScroll->activate();
47
48 # Did the user just hit escape?
49 if (!defined $selected)
50 {
51 Cdk::end();
52 exit 0;
53 }
54
55 # Get the name and display the info.
56 my $name = $logins->[$selected];
57
58 # Display the info.
59 my ($uid, $gid, $comment, $gcos, $dir, $shell) = split (//, $passwdObject->{$name});
60 my $info = ["Account Name : </R>$name",
61 "UID/GID : ($uid/$gid)",
62 "Comment : </R>$comment",
63 "GCOS Value : </R>$gcos",
64 "Home Directory : </R>$dir",
65 "Shell : </R>$shell"];
66
67 my $title = new Cdk::Label ('Message' => $info);
68
69 # Draw the label.
70 $title->draw ('Box' => "TRUE");
71 $title->wait();
72 undef $title;
73 }
+0
-1039
demos/rolodex less more
0 #!/usr/bin/perl -w
1 # $Id: rolodex,v 1.3 2002/07/24 10:04:31 tom Exp $
2
3 #
4 # Initialize Cdk.
5 #
6 use Cdk;
7 Cdk::init();
8
9 # Declare global variables.
10 $GGroupInfoChanged = 0;
11 @GLineType = ("Voice", "Cell", "Pager",
12 "First FAX", "Second FAX", "Third FAX",
13 "First Data Line", "Second Data Line", "Third Data Line");
14
15 # Create the menu list items.
16 my $fMenu = ["</5/B>File", "</5/B>Open ", "</5/B>Save ", "</5/B>Save As", "</5/B>Quit "];
17 my $eMenu = ["</5/B>Groups", "</5/B>New ", "</5/B>Open ", "</5/B>Delete"];
18 my $pMenu = ["</5/B>Print", "</5/B>Print Rolodex"];
19 my $hMenu = ["</5/B>Help", "</5/B>About Rolodex ", "</5/B>Rolodex Statistics"];
20 my $menulist = [$fMenu, $eMenu, $pMenu, $hMenu];
21 my $menuloc = ["LEFT", "LEFT", "LEFT", "RIGHT"];
22
23 # Create the menu object.
24 my $menu = new Cdk::Menu ('Menulist' => $menulist, 'Menuloc' => $menuloc);
25 $menu->draw();
26
27 # Create the title.
28 my @title = ("<C></16/U>Cdk/Perl5 Rolodex", "<C></16>Written by Mike Glover");
29 my $rolodexTitle = new Cdk::Label ('Message' => \@title, 'Box' => "FALSE");
30 $rolodexTitle->draw("Box" => "FALSE");
31
32 # Load up the RC file.
33 my $filename = $ENV{"HOME"} . "/.rolorc";
34 my $dbmDir = $ENV{"HOME"} . "/.rolodex";
35 my %groupInfo = readRCFile ($filename);
36 my $groupCount = keys %groupInfo;
37
38 # Pop up a message stating how many groups were loaded.
39 if ($groupCount == 0)
40 {
41 my $groupMessage = ["</B>Empty rolodex RC file. No groups loaded.",
42 "<C></B>Press any key to continue."];
43 popupLabel ($groupMessage);
44 }
45 elsif ($groupCount == 1)
46 {
47 my $groupMessage = ["</B>There was 1 group loaded from the RC file.",
48 "<C></B>Press any key to continue."];
49 popupLabel ($groupMessage);
50 }
51 else
52 {
53 my $groupMessage = ["</B>There were $groupCount groups loaded from the RC file.",
54 "<C></B>Press any key to continue."];
55 popupLabel ($groupMessage);
56 }
57
58 # Start the main loop
59 for (;;)
60 {
61 # Activate the object.
62 my ($menuItem, $submenuItem) = $menu->activate();
63
64 # Make sure they didn't hit escape.
65 next if ! defined $menuItem;
66
67 # Determine which menuitem was selected.
68 if ($menuItem == 0)
69 {
70 if ($submenuItem == 1)
71 {
72 # Open a new RC file.
73 my $fselect = new Cdk::Fselect ('Label' => "Filename:",
74 'Height' => 20,
75 'Width' => 55);
76 my $file = $fselect->activate();
77 undef $fselect;
78
79 # Make sure they chose a file.
80 if (defined $file)
81 {
82 my %tmpGroup = readRCFile ($file);
83
84 # Check the results.
85 if (! defined %tmpGroup)
86 {
87 my $mesg = ["<C></16>There were too many errors in the file",
88 "<C></16>$file.",
89 "<C></16>Are you sure it is a rolodex RC file?"];
90 popupLabel ($mesg);
91 }
92 else
93 {
94 %groupInfo = %tmpGroup;
95 }
96 }
97 }
98 elsif ($submenuItem == 2)
99 {
100 # Save the RC file.
101 saveRCFile ($filename, %groupInfo);
102 }
103 elsif ($submenuItem == 3)
104 {
105 # Save As...
106 my $entry = new Cdk::Entry ('Label' => "</24/B>Save As",
107 'Max' => 256,
108 'Width' => 20,
109 'Min' => 2,
110 'Filler' => "_");
111 $filename = $entry->activate();
112
113 # Check if they supplied a value.
114 if (!defined $filename)
115 {
116 my $mesg = ["<C>No name provided.", "<C>Information not saved."];
117 popupLabel ($mesg);
118 }
119 else
120 {
121 saveRCFile ($filename, %groupInfo);
122 }
123 undef $entry;
124 }
125 elsif ($submenuItem == 4)
126 {
127 # Quit
128 saveRCFile ($filename, %groupInfo) if $GGroupInfoChanged == 1;
129 exit;
130 }
131 }
132 elsif ($menuItem == 1)
133 {
134 if ($submenuItem == 1)
135 {
136 my %tmp = addRolodexGroup (%groupInfo);
137 %groupInfo = %tmp;
138 }
139 elsif ($submenuItem == 2)
140 {
141 useRolodexGroup (%groupInfo);
142 }
143 elsif ($submenuItem == 3)
144 {
145 my %tmp = deleteRolodexGroup (%groupInfo);
146 %groupInfo = %tmp;
147 }
148 }
149 elsif ($menuItem == 2)
150 {
151 printRolodexGroups (%groupInfo);
152 }
153 elsif ($menuItem == 3)
154 {
155 if ($submenuItem == 1)
156 {
157 # About rolodex.
158 my $roloInfo = ["<C></U>About Cdk/Perl5 Rolodex", "",
159 "This demo was written to demonstrate the widgets",
160 "available with the Cdk Perl5 extension. Not all of",
161 "the Cdk widgets are used, but most of them have",
162 "been. I hope this little demonstration helps give",
163 "you an understanding of what the Cdk Perl5",
164 "extension offers.", "Have fun with it.", "",
165 "ttfn,", "<C>Mike", "<C><#HL(30)>", "<C>March 1996"];
166 popupLabel ($roloInfo);
167 }
168 elsif ($submenuItem == 2)
169 {
170 # Rolodex statistics.
171 my $groupCount = keys %groupInfo;
172 my $roloInfo = ["<C></U>Rolodex Statistics",
173 "</R>Read Command Filename<!R> </U>$filename",
174 "</R>Group Count <!R> </U>$groupCount"];
175 popupLabel ($roloInfo);
176 }
177 }
178 }
179
180 #
181 # This reads an RC file.
182 #
183 sub readRCFile
184 {
185 my $filename = shift;
186 my %groupList = ();
187
188 # Open the RC file.
189 open (FILE, $filename) || return (0,"");
190
191 # Start ripping through the file.
192 for $row (<FILE>)
193 {
194 # Ingore comments and white space.
195 next if ($row =~ /^#/);
196 next if ($row =~ /^$/);
197 chomp $row;
198
199 # Split the line.
200 my @tmp = split (//, $row);
201
202 # Check if the file is in the correct format.
203 if ($#tmp == 2)
204 {
205 $groupList{$tmp[0]} = "$tmp[1]$tmp[2]";
206 }
207 }
208 return %groupList;
209 }
210
211 #
212 # This saves the group information to a RC file.
213 #
214 sub saveRCFile
215 {
216 my ($filename, %info) = @_;
217 my $date = qx (date);
218 my $count = 0;
219
220 # Open the file.
221 if (!open (FILE, ">$filename"))
222 {
223 my $mesg = ["<C>Could not write RC file to",
224 "<C>$filename", "<C>Try </R>Save As<!R> option."];
225 popupLabel ($mesg);
226 return;
227 }
228
229 # Attach the header to the file.
230 print FILE "#\n";
231 print FILE "# This file was automatically created on $date";
232 print FILE "#\n";
233
234 # Start writing the info to the file.
235 foreach $name (keys %info)
236 {
237 print FILE "$name$info{$name}\n";
238 $count++;
239 }
240
241 # Close the file.
242 close (FILE);
243
244 # Pop up a little message.
245 if ($count == 1)
246 {
247 my $mesg = ["<C>There was 1 group saved to file",
248 "<C>$filename", "<C>Press any key to continue."];
249 popupLabel ($mesg);
250 }
251 else
252 {
253 my $mesg = ["<C>There were $count groups saved to file",
254 "<C>$filename", "<C>Press any key to continue."];
255 popupLabel ($mesg);
256 }
257
258 # Reset the global flag.
259 $GGroupInfoChanged = 0;
260 return;
261 }
262
263 #
264 # This adds a new rolodex group to the current list of rolodex groups.
265 #
266 sub addRolodexGroup
267 {
268 my (%info) = @_;
269 my $description;
270
271 # Create the entry fields.
272 my $name = new Cdk::Entry ('Label' => "</R> New Group Name",
273 'Width' => 20,
274 'Filler' => "_",
275 'Min' => 2,
276 'Max' =>256,
277 'Ypos' => 8);
278 my $desc = new Cdk::Entry ('Label' => "</R>Group Description",
279 'Width' => 20,
280 'Filler' => "_",
281 'Min' => 2,
282 'Max' =>256,
283 'Ypos' => 11);
284
285 # Get the group name.
286 my $newName = $name->activate();
287
288 # Did they send in a name.
289 if (!defined $newName)
290 {
291 my $mesg = ["<C>No name provided.", "<C>Group not added."];
292 popupLabel ($mesg);
293 return %info;
294 }
295 else
296 {
297 # Check if the group already exists.
298 if (defined $info{$newName})
299 {
300 my $mesg = ["<C>Sorry the group ($newName) already exists."];
301 popupLabel ($mesg);
302 return %info;
303 }
304 }
305
306 # Get the group description.
307 while (!defined $description)
308 {
309 $description = $desc->activate();
310
311 # If there is no description given then tell them they need one.
312 if (!defined $description)
313 {
314 popupLabel (["The group has to have a description."]);
315 $name->draw();
316 }
317 }
318
319 # Create the DBM filename.
320 my $dbm = "${dbmDir}/${newName}.phl";
321
322 # Add it to the groupList.
323 $info{$newName} = "${description}${dbm}";
324 $GGroupInfoChanged = 1;
325
326 return %info;
327 }
328
329 #
330 # This allows a user to open and play with a rolodex group.
331 #
332 sub useRolodexGroup
333 {
334 my (%info) = @_;
335 my @list = ();
336
337 # Pick which group to open.
338 my $name = pickRolodexGroup ("<C></U>Open Rolodex Group", %info);
339 return if (! defined $name);
340
341 # Read the group database.
342 my $database = (split (//, $info{$name}))[1];
343 my @rolodexData = readPhoneDataFile ($database);
344
345 # Create the list.
346 for ($x=0; $x <= $#rolodexData; $x++)
347 {
348 my $name = $rolodexData[$x]->{'Name'};
349 my $type = $GLineType[$rolodexData[$x]->{'Type'}];
350 push (@list, "</B/40>$name ($type)");
351 }
352 my $height = ($#rolodexData > 5 ? 8 : $#rolodexData+4);
353
354 # Create the help window.
355 my $helpMesg = ["<C><#HL(30)",
356 "Press </B>?<!B> to get detailed help.",
357 "<C><#HL(30)>"];
358 my $helpWindow = new Cdk::Label ('Message' => $helpMesg,
359 'Box' => "FALSE",
360 'Xpos' => "BOTTOM");
361 $helpWindow->draw('Box' => "FALSE");
362
363 # If the list if empty, ask them if they want to add an entry.
364 if ($#list < 0)
365 {
366 my $mesg = ["<C>There were no entries in this group.",
367 "<C>Do you want to add a new listng?"];
368 my $buttons = ["<<Yes>>", "<<No>>"];
369
370 # Go ahead and ask.
371 if (popupDialog ($mesg, $buttons) == 0)
372 {
373 # Get the new record.
374 my $newRecord = getNewPhoneRecord();
375 if (defined $newRecord)
376 {
377 my $name = $newRecord->{'Name'};
378 my $type = $GLineType [$newRecord->{'Type'}];
379 $rolodexData[0] = $newRecord;
380 push (@list, "$name ($type)");
381 }
382 else
383 {
384 return;
385 }
386 }
387 else
388 {
389 return;
390 }
391 }
392
393 # Create the scrolling list.
394 my $scroll = new Cdk::Scroll ('Title' => "<C></48>Listing of Group </U>$name",
395 'Height' => $height,
396 'Width' => 50,
397 'Numbers' => "TRUE",
398 'List' => \@list);
399
400 # Create a key binding for the widget.
401 $scroll->bind ('Key' => '?', 'Function' => sub {rolodexHelpCB();});
402 $scroll->bind ('Key' => 'i', 'Function' => sub {insertPhoneEntryCB($scroll, \@rolodexData, \@list);});
403 $scroll->bind ('Key' => 'd', 'Function' => sub {deletePhoneEntryCB($scroll, \@rolodexData, \@list);});
404
405 # Do this until they hit escape.
406 for (;;)
407 {
408 # Let the user play.
409 $selection = $scroll->activate();
410 last if !defined $selection;
411
412 # Display the phone record.
413 displayPhoneRecord ($rolodexData[$selection]);
414 }
415
416 # Save the information into the file.
417 if (!open (FILE, ">$database"))
418 {
419 my $mesg = ["<C>Can not save phone information to",
420 "<C></U>$database", "<C>$!",
421 "<C>Press any key to continue."];
422 popupLabel ($mesg);
423 }
424
425 # Start writing.
426 my $date = qx (date);
427 print FILE "#\n";
428 print FILE "# This file was automatically generated on $date";
429 print FILE "#\n";
430 for ($x=0; $x <= $#rolodexData; $x++)
431 {
432 my $object = $rolodexData[$x];
433 print FILE "$object->{'Name'}$object->{'Type'}$object->{'Number'}$object->{'Address'}$object->{'City'}$object->{'Province'}$object->{'Postal Code'}$object->{'Description'}\n";
434 }
435 close FILE;
436 undef $scroll;
437 }
438
439 #
440 # This deletes a rolodex group from the given list.
441 #
442 sub deleteRolodexGroup
443 {
444 my (%info) = @_;
445
446 # Pick which group to delete.
447 my $name = pickRolodexGroup ("<C></U>Delete Which Rolodex Group?", %info);
448 if (! defined $name)
449 {
450 my $mesg = ["<C> Delete Canceled ", "<C>No Group Deleted"];
451 popupLabel ($mesg);
452 return;
453 }
454
455 # Confirm the delete
456 my $mesg = ["<C></U>Confirm Delete",
457 "<C>Are you sure you want to delete the group",
458 "<C></R>$name<!R>?"];
459 my $buttons = ["<<No>>", "<<Yes>>"];
460 if (popupDialog ($mesg, $buttons) == 1)
461 {
462 # Delete the group.
463 my $dbm = (split (//, $info{$name}))[1];
464 delete $info{$name};
465 unlink $dbm;
466 $GGroupInfoChanged = 1;
467 }
468 return %info;
469 }
470
471 #
472 # This allows the user to pick a rolodex group.
473 #
474 sub pickRolodexGroup
475 {
476 my ($title, %info) = @_;
477 my @list = ();
478 my $height = keys %info;
479 my @items = sort keys %info;
480
481 # Create the scrolling list item list.
482 foreach $item (@items)
483 {
484 push (@list, "<C></24>$item");
485 }
486
487 # Determine the height of the scrolling list.
488 if ($height > 5)
489 {
490 $height = 5;
491 }
492 $height += 3;
493
494 # Create the scrolling list.
495 my $scroll = new Cdk::Scroll ('Title' => "$title",
496 'Height' => $height,
497 'Width' => 50,
498 'List' => \@list);
499 my $item = $scroll->activate();
500
501 return $items[$item] if (defined $item);
502 return;
503 }
504
505 #
506 # This reads a phone data file and stores it in an object.
507 #
508 sub readPhoneDataFile
509 {
510 my ($database) = @_;
511 my @phoneRecords = ();
512
513 # Open the database.
514 if (!open (DB, $database))
515 {
516 my $mesg = ["<C></R>Error",
517 "<C>Could not open the database",
518 "<C>$database", "<C></U>$!", "",
519 "<C>Press any key to continue."];
520 popupLabel ($mesg);
521 return;
522 }
523
524 # Start scanning through the file.
525 foreach $row (<DB>)
526 {
527 next if $row =~ /^#/;
528 next if $row =~ /^$/;
529 chomp $row;
530
531 # Split the row and create an object.
532 my $object = new PhoneData ($row);
533 push (@phoneRecords, $object);
534 }
535 return @phoneRecords;
536 }
537
538 #
539 # This is a callback to the scrolling list.
540 #
541 sub rolodexHelpCB
542 {
543 my $mesg = ["<C></R>Rolodex Phone Editor",
544 "</B>i <!B> Inserts a new phone entry.",
545 "</B>d <!B> Deletes the currently selected phone entry.",
546 "</B>Escape <!B> Exits the scrolling list.",
547 "</B>? <!B> Pops up this help window."];
548 popupLabel ($mesg);
549 return 1;
550 }
551
552 #
553 # This displays a phone record.
554 #
555 sub displayPhoneRecord
556 {
557 my $record = shift;
558 my $type = $GLineType[$record->{'Type'}];
559 my $mesg = "";
560
561 # Assemble the phone record details.
562 if ($type =~ /cell/i || $type =~ /pager/i)
563 {
564 $mesg = ["<C></U>$type Phone Record",
565 "</B/5>Name <!B!5>$record->{'Name'}",
566 "</B/5>Phone Number<!B!5>$record->{'Number'}",
567 "</B/5>Comment <!B!5>$record->{'Description'}"];
568 }
569 else
570 {
571 $mesg = ["<C></U>$type Phone Record",
572 "</B/5>Name <!B!5>$record->{'Name'}",
573 "</B/5>Phone Number<!B!5>$record->{'Number'}",
574 "</B/5>Address <!B!5>$record->{'Address'}",
575 "</B/5>City <!B!5>$record->{'City'}",
576 "</B/5>Province <!B!5>$record->{'Province'}",
577 "</B/5>Postal Code <!B!5>$record->{'Postal Code'}",
578 "</B/5>Comment <!B!5>$record->{'Description'}"];
579 }
580 popupLabel ($mesg);
581 }
582
583 #
584 # This gets a new phone record.
585 #
586 sub getNewPhoneRecord
587 {
588 my @list = ();
589 my ($record, $type);
590
591 # Create a list.
592 foreach $item (@GLineType)
593 {
594 push (@list, "<C></U>$item");
595 }
596
597 # Create the title label.
598 my $mesg = ["<C></R>Add New Phone Record"];
599 my $title = new Cdk::Label ('Message' => $mesg,
600 'Box' => "FALSE",
601 'Xpos' => "TOP");
602 $title->draw ('Box' => "FALSE");
603
604 # Ask the user what type of line it it.
605 my $itemList = new Cdk::Itemlist ('Label' => "What Type Of Line Is It?",
606 'List' => \@list);
607
608 while (!defined $type)
609 {
610 $type = $itemList->activate();
611
612 if (!defined $type)
613 {
614 popupLabel (["Please specify a line type."]);
615 }
616 }
617 undef $itemList;
618
619 # Given the type, ask certain questions.
620 if ($GLineType[$type] =~ /Cell/ || $GLineType[$type] =~ /Pager/)
621 {
622 $record = getSmallPhoneRecord($type);
623 }
624 else
625 {
626 $record = getLargePhoneRecord($type);
627 }
628 return $record;
629 }
630
631 #
632 # This gets a small phone record.
633 #
634 sub getSmallPhoneRecord
635 {
636 my $type = shift;
637 my $mesg = ["<C></U>Confirm New Phone Entry",
638 "<C>Do you want to add this phone number?"];
639 my $buttons = ["<<Add Phone Number>>",
640 "<<Cancel>>", "<<Modify Information>>"];
641 my ($name, $unmixedPhone, $desc);
642
643 # Create the entry fields.
644 my $nameEntry = new Cdk::Entry ('Label' => "</R>Name",
645 'Ypos' => 8,
646 'Width' => 20,
647 'Min' => 2,
648 'Max' => 256,
649 'Filler' => "_");
650 my $phoneTemp = new Cdk::Template ('Label' => "</R>Number",
651 'Plate' => "(###) ###-####",
652 'Overlay' => "(___) ___-____",
653 'Ypos' => 11);
654 my $descEntry = new Cdk::Entry ('Label' => "</R>Description",
655 'Ypos' => 14,
656 'Width' => 20,
657 'Min' => 2,
658 'Max' => 256,
659 'Filler' => "_");
660
661 # Start the loop.
662 for (;;)
663 {
664 # Draw the objects.
665 $nameEntry->draw();
666 $phoneTemp->draw();
667 $descEntry->draw();
668
669 # Get the information.
670 $name = $nameEntry->activate();
671 $unmixedPhone = $phoneTemp->activate();
672 $desc = $descEntry->activate();
673
674 # Make sure they want to add this number.
675 my $answer = popupDialog ($mesg, $buttons);
676 last if $answer == 0;
677 return if $answer == 1;
678 }
679
680 # Assemble the information and create the object.
681 my $phone = $phoneTemp->mix();
682 my $temp = "$name$type$phone----$desc";
683 my $object = new PhoneData ($temp);
684 return $object;
685 }
686
687 #
688 # This gets a large phone record.
689 #
690 sub getLargePhoneRecord
691 {
692 my $type = shift;
693 my $mesg = ["<C></U>Confirm New Phone Entry",
694 "<C>Do you want to add this phone number?"];
695 my $buttons = ["<<Add Phone Number>>",
696 "<<Cancel>>", "<<Modify Information>>"];
697 my ($name, $address, $city, $prov, $postal, $unmixedPhone, $desc);
698
699 # Create the widgets.
700 my $nameEntry = new Cdk::Entry ('Label' => "</R>Name",
701 'Ypos' => 5, 'Xpos' => "LEFT",
702 'Min' => 2, 'Max' => 256,
703 'Filler' => "_", 'Width' => 20);
704 my $addressEntry = new Cdk::Entry ('Label' => "</R>Address",
705 'Ypos' => 5, 'Xpos' => "RIGHT",
706 'Min' => 2, 'Max' => 256,
707 'Filler' => "_", 'Width' => 40);
708 my $cityEntry = new Cdk::Entry ('Label' => "</R>City",
709 'Ypos' => 8, 'Xpos' => "LEFT",
710 'Min' => 2, 'Max' => 256,
711 'Filler' => "_", 'Width' => 20);
712 my $provEntry = new Cdk::Entry ('Label' => "</R>Province",
713 'Ypos' => 8, 'Xpos' => 29,
714 'Min' => 2, 'Max' => 256,
715 'Filler' => "_", 'Width' => 15);
716 my $postalEntry = new Cdk::Entry ('Label' => "</R>Postal Code",
717 'Ypos' => 8, 'Xpos' => "RIGHT",
718 'Min' => 2, 'Max' => 256,
719 'Filler' => "_", 'Width' => 10,
720 'Dtype' => "UMIXED");
721 my $phoneTemp = new Cdk::Template ('Label' => "</R>Number",
722 'Ypos' => 11, 'Xpos' => "LEFT",
723 'Overlay' => "(___) ___-____",
724 'Plate' => "(###) ###-####");
725 my $descEntry = new Cdk::Entry ('Label' => "</R>Description",
726 'Ypos' => 11, 'Xpos' => "RIGHT",
727 'Min' => 2, 'Max' => 256,
728 'Filler' => "_", 'Width' => 20);
729
730 # Start the loop.
731 for (;;)
732 {
733 # Draw the screen.
734 $nameEntry->draw();
735 $addressEntry->draw();
736 $cityEntry->draw();
737 $provEntry->draw();
738 $postalEntry->draw();
739 $phoneTemp->draw();
740 $descEntry->draw();
741
742 # Get the information.
743 $name = $nameEntry->activate();
744 $address = $addressEntry->activate();
745 $city = $cityEntry->activate();
746 $prov = $provEntry->activate();
747 $postal = $postalEntry->activate();
748 $unmixedPhone = $phoneTemp->activate();
749 $desc = $descEntry->activate();
750
751 # Make sure they want to add this number.
752 my $answer = popupDialog ($mesg, $buttons);
753 last if $answer == 0;
754 return if $answer == 1;
755 }
756
757 # Assemble the information and create the object.
758 my $phone = $phoneTemp->mix();
759 my $temp = "$name$type$phone$address$city$prov$postal$desc";
760 my $object = new PhoneData ($temp);
761 return $object;
762 }
763
764 #
765 # This inserts an entry into the phone scrolling list.
766 #
767 sub insertPhoneEntryCB
768 {
769 my ($scroll, $data, $list) = @_;
770 my ($size, $currentItem) = $scroll->info();
771 my $itemName = $list->[$currentItem];
772
773 # Erase the scrolling list.
774 $scroll->erase();
775
776 # Get a new phone record.
777 my $newRecord = getNewPhoneRecord();
778
779 # Make sure there is a record to add.
780 if (!defined $newRecord)
781 {
782 $scroll->draw();
783 return 1;
784 }
785
786 # Push the information onto the record array.
787 push (@$data, $newRecord);
788
789 # Push the information onto the list array.
790 my $name = $newRecord->{'Name'};
791 my $namedTyped = $GLineType[$newRecord->{'Type'}];
792 my $temp = "$name ($namedTyped)";
793 push (@$list, $temp);
794
795 # Add it to the scrolling list.
796 $scroll->add ('Item' => $temp);
797 $scroll->draw();
798 return 1;
799 }
800
801 #
802 # This deletes an entry from a scrolling list.
803 #
804 sub deletePhoneEntryCB
805 {
806 my ($scroll, $data, $list) = @_;
807 my ($size, $currentItem) = $scroll->info();
808 my $itemName = $list->[$currentItem];
809 my $buttons = ["<<No>>", "<<Yes>>"];
810 my $mesg = ["Do you really want to delete the phone entry",
811 "<C></R>$itemName"];
812 my @array = @$data;
813
814 # Ask the user if they really want to delete this item.
815 if (popupDialog ($mesg, $buttons) == 1)
816 {
817 # Nuke it.
818 $scroll->delete ('Position' => $currentItem);
819
820 # Remove it from the arrays.
821 for ($x=$currentItem; $x < $#array; $x++)
822 {
823 $data->[$x] = $data->[$x+1];
824 $list->[$x] = $list->[$x+1];
825 }
826 pop (@$data);
827 pop (@$list);
828 }
829 $scroll->erase();
830 $scroll->draw();
831 return 1;
832 }
833
834 #
835 # This prints out certain rolodex groups.
836 #
837 sub printRolodexGroups
838 {
839 my (%groupInfo) = @_;
840 my $options = ["Print to Printer ", "Print to File ", "Don't Print "];
841 my $title = "<C></U>Select Which Groups To Print";
842 my @list = ();
843 my ($height, $filename);
844
845 # Create the group list to print.
846 foreach $key (sort keys %groupInfo)
847 {
848 push (@list, $key);
849 }
850
851 # Determine the height of the selection box.
852 $height = ($#list > 5 ? 8 : $#list + 4);
853
854 # Create the selection list.
855 my $select = new Cdk::Selection ('Title' => $title,
856 'Height' => $height,
857 'Width' => 40,
858 'List' => \@list,
859 'Choices' => $options);
860
861 # Get the selections to print.
862 my @answer = $select->activate();
863 undef $select;
864
865 # check if the user canceled.
866 if (!defined @answer)
867 {
868 my $mesg = ["Print Canceled"];
869 popupLabel ($mesg);
870 return;
871 }
872
873 # Start printing the groups.
874 for ($x=0; $x <= $#answer; $x++)
875 {
876 my $groupName = $list[$x];
877 if ($answer[$x] == 0)
878 {
879 # Create a label for a title.
880 my $mesg = ["<C></R>Printing Group [$groupName] to Printer"];
881 my $title = new Cdk::Label ('Message' => $mesg,
882 'Box' => "FALSE",
883 'Xpos' => "TOP");
884 $title->draw ('Box' => "FALSE");
885
886 # Print to Printer.
887 my $printEntry = new Cdk::Entry ('Label' => "</R>Printer Name",
888 'Filler' => "_",
889 'Width' => 20,
890 'Min' => 2,
891 'Max' => 256);
892
893 # Set the default value as the PRINTER ENV variable.
894 if (defined $ENV{'PRINTER'})
895 {
896 $printEntry->set ('Value' => "$ENV{'PRINTER'}",
897 'Min' => 2, 'Max' => 256);
898 }
899 my $printer = $printEntry->activate();
900 printGroup ($groupName, %groupInfo, "/tmp/rolodex.$$");
901 system ("lpr /tmp/rolodex.$$");
902 unlink "/tmp/rolodex.$$";
903 }
904 elsif ($answer[$x] == 1)
905 {
906 # Create a label for a title.
907 my $mesg = ["<C></R>Printing Group [$groupName] to File"];
908 my $title = new Cdk::Label ('Message' => $mesg,
909 'Box' => "FALSE",
910 'Xpos' => "TOP");
911 $title->draw ('Box' => "FALSE");
912
913 # Print to file.
914 my $fileEntry = new Cdk::Entry ('Label' => "</R>Filename",
915 'Filler' => "_",
916 'Width' => 20,
917 'Min' => 2,
918 'Max' => 256);
919
920 # Make sure that a filename is given.
921 while (!defined $filename)
922 {
923 $filename = $fileEntry->activate();
924
925 if (!defined $filename)
926 {
927 popupLabel (["Please supply a filename."]);
928 }
929 }
930
931 # Print the group to a file.
932 printGroup ($groupName, %groupInfo, $filename);
933 }
934 }
935 }
936
937 #
938 # This opens a phone database file and prints it to the given filename.
939 #
940 sub printGroup
941 {
942 my ($name, %groupInfo, $filename) = @_;
943
944 # Try to open the file.
945 if (!open (PHONE, ">$filename"))
946 {
947 my $mesg = ["<C></R>Error",
948 "<C>Could not print the group </B>$name<!B> to </B>$filename<!B>.",
949 "<C></U>$!", "<C>Press any key to continue."];
950 popupLabel ($mesg);
951 return;
952 }
953
954 # Open the phone database file and read in the contents.
955 my ($desc, $dbm) = split (//, $groupInfo{$name});
956 my @rolodexData = readPhoneDataFile ($dbm);
957 select (PHONE); $| =1;
958
959 # Set variables for the report.
960 foreach $object (@rolodexData)
961 {
962 $fullName = $object->{'Name'};
963 $number = $object->{'Number'};
964 $address = $object->{'Address'};
965 $city = $object->{'City'};
966 $province = $object->{'Province'};
967 $postalCode = $object->{'Postal Code'};
968 $description = $object->{'Description'};
969 write;
970 }
971 close (PHONE);
972 }
973
974 #########################################
975 format PHONE=
976 Name @<<<<<<<<<<<<<<<<<<<<<<<<<< Phone Number @<<<<<<<<<<<<<<<<<<<<<<<<<<<
977 $fullName, $number
978 Address @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< City @<<<<<<<<<<<<<<<<<<<<<<<<<<<
979 $address, $city
980 City @<<<<<<<<<<<<< Province @<<<<<<<<<<<<<<<<<< Postal Code @<<<<<<<<<<<<<<<
981 $city, $province, $postalCode
982 Description @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
983 $description
984 -----------------------------------------------------------------------------
985 .
986
987 #########################################
988 package PhoneData;
989
990 #
991 # This creates a new object.
992 #
993 sub new
994 {
995 my $junk = shift;
996 my $record = shift;
997 my $self = {};
998
999 # Split the record apart.
1000 my ($name, $type, $phone, $address, $city, $prov, $postal, $desc) = split (//, $record);
1001
1002 # Store the info in the object.
1003 $self->{'Name'} = $name;
1004 $self->{'Type'} = $type;
1005 $self->{'Number'} = $phone;
1006 $self->{'Address'} = $address;
1007 $self->{'City'} = $city;
1008 $self->{'Province'} = $prov;
1009 $self->{'Postal Code'} = $postal;
1010 $self->{'Description'} = $desc;
1011
1012 return bless $self;
1013 }
1014
1015 #
1016 # This prints out the contents of an object.
1017 #
1018 sub display
1019 {
1020 my $self = shift;
1021 my %object = %$self;
1022 my @mesg = ();
1023
1024 foreach $key (sort keys %object)
1025 {
1026 push (@mesg, sprintf ("Key = %-10s Value = %-30s", $key, $object{$key}));
1027 }
1028 main::popupLabel (\@mesg);
1029 }
1030 sub print
1031 {
1032 my $object = shift;
1033
1034 foreach $key (sort keys %info)
1035 {
1036 print "Key = $key Value = $info{$key}\n";
1037 }
1038 }
0 /* $Id: rolodex.c,v 1.20 2005/12/31 00:36:00 tom Exp $ */
1 #include "rolodex.h"
2
3 #ifdef HAVE_XCURSES
4 char *XCursesProgramName="rolodex";
5 #endif
6
7 /*
8 * This is the main part of the loop.
9 */
10 int main(void)
11 {
12 /* Declare variables. */
13 CDKSCREEN *cdkscreen;
14 CDKMENU *rolodexMenu;
15 CDKLABEL *rolodexTitle;
16 SRolodex groupList[MAXGROUPS];
17 WINDOW *cursesWin;
18 char *menulist[MAX_MENU_ITEMS][MAX_SUB_ITEMS], *title[5];
19 char *home, temp[256], *mesg[15];
20 int subMenuSize[10], menuLocations[10], selection;
21 int group, ret, x;
22 int groupCount = 0;
23
24 /* Set up CDK */
25 cursesWin = initscr();
26 cdkscreen = initCDKScreen (cursesWin);
27
28 /* Start CDK color. */
29 initCDKColor();
30
31 /* Create the menu lists. */
32 menulist[0][0] = "</U>File";menulist[1][0] = "</U>Groups";
33 menulist[0][1] = "</B/5>Open ";menulist[1][1] = "</B/5>New ";
34 menulist[0][2] = "</B/5>Save ";menulist[1][2] = "</B/5>Open ";
35 menulist[0][3] = "</B/5>Save As";menulist[1][3] = "</B/5>Delete";
36 menulist[0][4] = "</B/5>Quit ";
37
38 menulist[2][0] = "</U>Print";menulist[3][0] = "</U>Help";
39 menulist[2][1] = "</B/5>Print Groups";menulist[3][1] = "</B/5>About Rolodex ";
40 menulist[3][2] = "</B/5>Rolodex Statistics";
41
42 /* Set up the sub-menu sizes and their locations. */
43 subMenuSize[0] = 5;menuLocations[0] = LEFT;
44 subMenuSize[1] = 4;menuLocations[1] = LEFT;
45 subMenuSize[2] = 2;menuLocations[2] = LEFT;
46 subMenuSize[3] = 3;menuLocations[3] = RIGHT;
47
48 /* Create the menu. */
49 rolodexMenu = newCDKMenu (cdkscreen, menulist, 4,
50 subMenuSize, menuLocations,
51 TOP, A_BOLD|A_UNDERLINE, A_REVERSE);
52
53 /* Create the title. */
54 title[0]= "<C></U>Cdk Rolodex";
55 title[1]= "<C></B/24>Written by Mike Glover";
56 rolodexTitle = newCDKLabel (cdkscreen, CENTER, CENTER, title, 2, FALSE, FALSE);
57
58 /* Define the help key binding. */
59 bindCDKObject (vMENU, rolodexMenu, '?', helpCB, 0);
60
61 /* Draw the CDK screen. */
62 refreshCDKScreen (cdkscreen);
63
64 /* Check the value of the HOME env var. */
65 home = getenv ("HOME");
66 if (home != 0)
67 {
68 /* Make sure the $HOME/.rolodex directory exists. */
69 sprintf (temp, "%s/.rolodex", home);
70
71 /* Set the value of the global rolodex DBM directory. */
72 GDBMDir = copyChar (temp);
73
74 /* Set the value of the global RC filename. */
75 sprintf (temp, "%s/.rolorc", home);
76 GRCFile = copyChar (temp);
77 }
78 else
79 {
80 /* Set the value of the global rolodex DBM directory. */
81 GDBMDir = copyChar (".rolodex");
82
83 /* Set the value of the global RC filename. */
84 GRCFile = copyChar (".rolorc");
85 }
86
87 /* Make the rolodex directory. */
88 mkdir (GDBMDir, 0755);
89
90 /* Open the rolodex RC file. */
91 groupCount = readRCFile (GRCFile, groupList);
92
93 /* Check the value of groupCount. */
94 if (groupCount < 0)
95 {
96 /* The RC file seems to be corrupt. */
97 sprintf (temp, "<C></B/16>The RC file (%s) seems to be corrupt.", GRCFile);
98 mesg[0] = copyChar (temp);
99 mesg[1] = "<C></B/16>No rolodex groups were loaded.";
100 mesg[2] = "<C>Press any key to continue.";
101 popupLabel (cdkscreen, mesg, 3);
102 freeChar (mesg[0]);
103 groupCount = 0;
104 }
105 else if (groupCount == 0)
106 {
107 mesg[0] = "<C></B/24>Empty rolodex RC file. No groups loaded.";
108 mesg[1] = "<C>Press any key to continue.";
109 popupLabel (cdkscreen, mesg, 2);
110 }
111 else
112 {
113 if (groupCount == 1)
114 {
115 sprintf (temp, "<C></24>There was 1 group loaded from the RC file.");
116 }
117 else
118 {
119 sprintf (temp, "<C></24>There were %d groups loaded from the RC file.", groupCount);
120 }
121 mesg[0] = copyChar (temp);
122 mesg[1] = "<C>Press any key to continue.";
123 popupLabel (cdkscreen, mesg, 2);
124 freeChar (mesg[0]);
125 }
126
127 /* Loop until we are done. */
128 for (;;)
129 {
130 /* Activate the menu */
131 selection= activateCDKMenu (rolodexMenu, 0);
132
133 /* Check the return value of the selection. */
134 if (selection == 0)
135 {
136 /* Open the rolodex RC file. */
137 groupCount = openNewRCFile (cdkscreen, groupList, groupCount);
138 }
139 else if (selection == 1)
140 {
141 /* Write out the RC file. */
142 ret = writeRCFile (cdkscreen, GRCFile, groupList, groupCount);
143
144 /* Reset the saved flag if the rc file saved ok. */
145 if (ret != 0)
146 {
147 GGroupModified = 0;
148 }
149 }
150 else if (selection == 2)
151 {
152 /* Save as. */
153 ret = writeRCFileAs (cdkscreen, groupList, groupCount);
154
155 /* Reset the saved flag if the rc file saved ok. */
156 if (ret != 0)
157 {
158 GGroupModified = 0;
159 }
160 }
161 else if (selection == 3)
162 {
163 /* Has anything changed??? */
164 if (GGroupModified != 0)
165 {
166 /* Write out the RC file. */
167 writeRCFile (cdkscreen, GRCFile, groupList, groupCount);
168 }
169
170 /* Remove the CDK widget pointers. */
171 destroyCDKMenu (rolodexMenu);
172 destroyCDKLabel (rolodexTitle);
173 destroyCDKScreen (cdkscreen);
174
175 /* Free up other pointers. */
176 freeChar (GCurrentGroup);
177 freeChar (GRCFile);
178 freeChar (GDBMDir);
179
180 /* Clean up the group information. */
181 for (x=0; x < groupCount; x++)
182 {
183 freeChar (groupList[x].name);
184 freeChar (groupList[x].desc);
185 freeChar (groupList[x].dbm);
186 }
187
188 /* Shutdown CDK. */
189 endCDK();
190
191 /* Exit cleanly. */
192 ExitProgram (EXIT_SUCCESS);
193 }
194 else if (selection == 100)
195 {
196 /* Add a new group to the list. */
197 groupCount = addRolodexGroup (cdkscreen, groupList, groupCount);
198 }
199 else if (selection == 101)
200 {
201 /* If there are no groups, ask them if they want to create a new one. */
202 if (groupCount == 0)
203 {
204 char *buttons[] = {"<Yes>", "<No>"};
205 mesg[0] = "<C>There are no groups defined.";
206 mesg[1] = "<C>Do you want to define a new group?";
207
208 /* Add the group if they said yes. */
209 if (popupDialog (cdkscreen, mesg, 2, buttons, 2) == 0)
210 {
211 groupCount = addRolodexGroup (cdkscreen, groupList, groupCount);
212 }
213 }
214 else
215 {
216 /* Get the number of the group to open. */
217 group = pickRolodexGroup (cdkscreen, "<C></B/29>Open Rolodex Group",
218 groupList, groupCount);
219
220 /* Make sure a group was picked. */
221 if (group >= 0)
222 {
223 /* Set the global variable GCurrentGroup */
224 freeChar (GCurrentGroup);
225 GCurrentGroup = copyChar (groupList[group].name);
226
227 /* Try to open the DBM file and read the contents. */
228 useRolodexGroup (cdkscreen,
229 groupList[group].name,
230 groupList[group].desc,
231 groupList[group].dbm);
232 }
233 }
234 }
235 else if (selection == 102)
236 {
237 /* Delete the group chosen. */
238 groupCount = deleteRolodexGroup (cdkscreen, groupList, groupCount);
239 }
240 else if (selection == 200)
241 {
242 /* Print Phone Number Group. */
243 printGroupNumbers (cdkscreen, groupList, groupCount);
244 }
245 else if (selection == 300)
246 {
247 /* About Rolodex. */
248 aboutCdkRolodex(cdkscreen);
249 }
250 else if (selection == 301)
251 {
252 displayRolodexStats (ScreenOf(rolodexMenu), groupCount);
253 }
254 }
255 }
256
257 /*
258 * This writes out the new RC file.
259 */
260 int writeRCFile (CDKSCREEN *screen, char *filename, SRolodex *groupList, int groupCount)
261 {
262 /* Declare local variables. */
263 char *mesg[5], temp[256];
264 time_t clck;
265 FILE *fd;
266 int x;
267
268 /* Can we open the file? */
269 if ((fd = fopen (filename, "w")) == 0)
270 {
271 /* Pop up a message. */
272 sprintf (temp, "</B/16>The file <%s> could not be opened.", filename);
273 mesg[0] = copyChar (temp);
274 #ifdef HAVE_STRERROR
275 sprintf (temp, "<C></B/16>%s", strerror(errno));
276 #else
277 sprintf (temp, "<C></B/16>Unknown reason.");
278 #endif
279 mesg[1] = copyChar (temp);
280 mesg[2] = "<C>Press any key to continue.";
281
282 popupLabel (screen, mesg, 3);
283
284 freeChar (mesg[0]);
285 freeChar (mesg[1]);
286
287 return (0);
288 }
289
290 /* Get the current time. */
291 time(&clck);
292
293 /* Put some comments at the top of the header. */
294 fprintf (fd, "#\n");
295 fprintf (fd, "# This file was automatically generated on %s", ctime(&clck));
296 fprintf (fd, "#\n");
297
298 /* Start writing the RC file. */
299 for (x=0; x < groupCount; x++)
300 {
301 fprintf (fd, "%s%c%s%c%s\n",
302 groupList[x].name, CTRL('V'),
303 groupList[x].desc, CTRL('V'),
304 groupList[x].dbm);
305 }
306 fclose (fd);
307
308 /* Pop up a message stating that it has been saved. */
309 if (groupCount == 1)
310 {
311 sprintf (temp, "There was 1 group saved to file");
312 mesg[0] = copyChar (temp);
313 }
314 else
315 {
316 sprintf (temp, "There were %d groups saved to file", groupCount);
317 mesg[0] = copyChar (temp);
318 }
319
320 sprintf (temp, "<C>%s", filename);
321 mesg[1] = copyChar (temp);
322 mesg[2] = "<C>Press any key to continue.";
323
324 popupLabel (screen, mesg, 3);
325 freeChar (mesg[0]); freeChar (mesg[1]);
326 return (1);
327 }
328
329 /*
330 * This allows the user to pick a DBM file to open.
331 */
332 int pickRolodexGroup (CDKSCREEN *screen, char *title, SRolodex *groupList, int groupCount)
333 {
334 /* Declare local variables. */
335 CDKSCROLL *roloList = 0;
336 int height = groupCount;
337 char *mesg[MAXGROUPS], temp[256];
338 int selection, x;
339
340 /* Determine the height of the scrolling list. */
341 if (groupCount > 5)
342 {
343 height = 5;
344 }
345 height += 3;
346
347 /* Copy the names of the scrolling list into an array. */
348 for (x=0; x < groupCount; x++)
349 {
350 sprintf (temp, "<C></B/29>%s", groupList[x].name);
351 mesg[x] = copyChar (temp);
352 }
353
354 /* Create the scrolling list. */
355 roloList = newCDKScroll (screen, CENTER, CENTER, NONE,
356 height, 50, title, mesg, groupCount,
357 NONUMBERS, A_REVERSE, TRUE, FALSE);
358
359 /* Create a callback to the scrolling list. */
360 bindCDKObject (vSCROLL, roloList, '?', groupInfoCB, groupList);
361
362 /* Activate the scrolling list. */
363 selection = activateCDKScroll (roloList, 0);
364
365 /* Destroy the scrolling list. */
366 destroyCDKScroll (roloList);
367 for (x=0; x < groupCount; x++)
368 {
369 freeChar (mesg[x]);
370 }
371
372 /* Return the item selected. */
373 return selection;
374 }
375
376 /*
377 * This allows the user to add a rolo group to the list.
378 */
379 int addRolodexGroup (CDKSCREEN *screen, SRolodex *groupList, int groupCount)
380 {
381 /* Declare local variables. */
382 CDKENTRY *newName= 0;
383 CDKENTRY *newDesc= 0;
384 char *mesg[4], *desc, *newGroupName, temp[256];
385 int x;
386
387 /* Create the name widget. */
388 newName = newCDKEntry (screen, CENTER, 8,
389 "<C></B/29>New Group Name",
390 "</B/29> Name: ",
391 A_NORMAL, '_', vMIXED,
392 20, 2, 256, TRUE, FALSE);
393
394
395 /* Get the name. */
396 newGroupName = activateCDKEntry (newName, 0);
397
398 /* Make sure they didn't hit escape. */
399 if (newName->exitType == vESCAPE_HIT)
400 {
401 mesg[0] = "<C></B/16>Add Group Canceled.";
402 destroyCDKEntry (newName);
403 popupLabel (screen, mesg, 1);
404 return groupCount;
405 }
406
407 /* Make sure that group name does not already exist. */
408 for (x=0; x < groupCount; x++)
409 {
410 if (strcmp (newGroupName, groupList[x].name) == 0)
411 {
412 sprintf (temp, "<C></B/16>Sorry the group (%s) already exists.", newGroupName);
413 mesg[0] = copyChar (temp);
414 popupLabel (screen, mesg, 1);
415 freeChar (mesg[0]);
416 destroyCDKEntry (newName);
417 return groupCount;
418 }
419 }
420
421 /* Keep the name. */
422 groupList[groupCount].name = copyChar (newGroupName);
423
424 /* Create the description widget. */
425 newDesc = newCDKEntry (screen, CENTER, 13,
426 "<C></B/29>Group Description",
427 "</B/29>Descriprion: ",
428 A_NORMAL, '_', vMIXED,
429 20, 2, 256, TRUE, FALSE);
430
431 /* Get the description. */
432 desc = activateCDKEntry (newDesc, 0);
433
434 /* Check if they hit escape or not. */
435 if (newDesc->exitType == vESCAPE_HIT)
436 {
437 groupList[groupCount].desc = copyChar ("No Description Provided.");
438 }
439 else
440 {
441 groupList[groupCount].desc = copyChar (desc);
442 }
443
444 /* Create the DBM filename. */
445 sprintf (temp, "%s/%s.phl", GDBMDir, groupList[groupCount].name);
446 groupList[groupCount].dbm = copyChar (temp);
447
448 /* Inrement the group count. */
449 groupCount++;
450 GGroupModified = 1;
451
452 /* Destroy the widgets. */
453 destroyCDKEntry (newName);
454 destroyCDKEntry (newDesc);
455 return groupCount;
456 }
457
458 /*
459 * This displays rolodex information.
460 */
461 void displayRolodexStats (CDKSCREEN *screen, int groupCount)
462 {
463 /* Declare local variables. */
464 char *mesg[6], temp[256];
465
466 /* Create the information to display. */
467 sprintf (temp, "<C></U>Rolodex Statistics");
468 mesg[0] = copyChar (temp);
469 sprintf (temp, "</B/5>Read Command Filename<!B!5> </U>%s<!U>", GRCFile);
470 mesg[1] = copyChar (temp);
471 sprintf (temp, "</B/5>Group Count <!B!5> </U>%d<!U>", groupCount);
472 mesg[2] = copyChar (temp);
473
474 /* Display the message. */
475 popupLabel (screen, mesg, 3);
476
477 /* Clean up. */
478 freeChar (mesg[0]); freeChar (mesg[1]); freeChar (mesg[2]);
479 }
480
481 /*
482 * This function gets a new rc filename and saves the contents of the
483 * groups under that name.
484 */
485 int writeRCFileAs (CDKSCREEN *screen, SRolodex *groupList, int groupCount)
486 {
487 /* Declare local variables. */
488 CDKENTRY *newRCFile;
489 char *newFilename;
490 int ret;
491
492 /* Create the entry field. */
493 newRCFile = newCDKEntry (screen, CENTER, CENTER,
494 "<C></R>Save As",
495 "Filename: ",
496 A_NORMAL, '_', vMIXED,
497 20, 2, 256, TRUE, FALSE);
498
499 /* Add a pre-process function so no spaces are introduced. */
500 setCDKEntryPreProcess (newRCFile, entryPreProcessCB, 0);
501
502 /* Get the filename. */
503 newFilename = activateCDKEntry (newRCFile, 0);
504
505 /* Check if they hit escape or not. */
506 if (newRCFile->exitType == vESCAPE_HIT)
507 {
508 destroyCDKEntry (newRCFile);
509 return 1;
510 }
511
512 /* Call the function to save the RC file. */
513 ret = writeRCFile (screen, newFilename, groupList, groupCount);
514
515 /* Reset the saved flag if the rc file saved ok. */
516 if (ret != 0)
517 {
518 /* Change the default filename. */
519 freeChar (GRCFile);
520 GRCFile = copyChar (newFilename);
521 GGroupModified = 0;
522 }
523
524 /* Clean up. */
525 destroyCDKEntry (newRCFile);
526 return 1;
527 }
528
529 /*
530 * This opens a new RC file.
531 */
532 int openNewRCFile (CDKSCREEN *screen, SRolodex *groupList, int groupCount)
533 {
534 /* Declare local variables. */
535 CDKFSELECT *fileSelector;
536 char *filename, *mesg[10], temp[256];
537 int x;
538
539 /* Get the filename. */
540 fileSelector = newCDKFselect (screen, CENTER, CENTER, 20, 55,
541 "<C>Open RC File",
542 "Filename: ",
543 A_NORMAL, '.', A_REVERSE,
544 "</5>", "</48>", "</N>", "</N>",
545 TRUE, FALSE);
546
547 /* Activate the file selector. */
548 filename = activateCDKFselect (fileSelector, 0);
549
550 /* Check if the file selector left early. */
551 if (fileSelector->exitType == vESCAPE_HIT)
552 {
553 destroyCDKFselect (fileSelector);
554 mesg[0] = "Open New RC File Aborted.";
555 popupLabel (screen, mesg, 1);
556 return groupCount;
557 }
558
559 /* Clean out the old information. */
560 for (x=0; x < groupCount; x++)
561 {
562 freeChar (groupList[x].name);
563 freeChar (groupList[x].desc);
564 freeChar (groupList[x].dbm);
565 }
566
567 /* Open the RC file. */
568 groupCount = readRCFile (filename, groupList);
569
570 /* Check the return value. */
571 if (groupCount < 0)
572 {
573 /* This file does not appear to be a rolodex file. */
574 mesg[0] = "<C></B/16>The file<!B!16>";
575 sprintf (temp, "<C></B/16>(%s)<!B!16>", filename);
576 mesg[1] = copyChar (temp);
577 mesg[2] = "<C>does not seem to be a rolodex RC file.";
578 mesg[3] = "<C>Press any key to continue.";
579 popupLabel (screen, mesg, 4);
580 freeChar (mesg[1]);
581 groupCount = 0;
582 }
583
584 /* Clean up. */
585 destroyCDKFselect (fileSelector);
586 return groupCount;
587 }
588
589 /*
590 * This reads the users rc file.
591 */
592 int readRCFile (char *filename, SRolodex *groupList)
593 {
594 /* Declare variables. */
595 int groupsFound = 0;
596 int errorsFound = 0;
597 char **lines = 0;
598 char **items;
599 int linesRead, chunks, x;
600
601 /* Open the file and start reading. */
602 linesRead = CDKreadFile (filename, &lines);
603
604 /* Check the number of lines read. */
605 if (linesRead == 0)
606 {
607 return (0);
608 }
609
610 /*
611 * Cycle through what was given to us and save it.
612 */
613 for (x=0; x < linesRead; x++)
614 {
615 /* Strip white space from the line. */
616 stripWhiteSpace (vBOTH, lines[x]);
617
618 /* Only split lines which do not start with a # */
619 if (strlen (lines[x]) != 0 && lines[x][0] != '#')
620 {
621 items = CDKsplitString (lines[x], CTRL('V'));
622 chunks = CDKcountStrings (items);
623
624 /* Only take the ones which fit the format. */
625 if (chunks == 3)
626 {
627 /* Clean off the name and DB name. */
628 stripWhiteSpace (vBOTH, items[0]);
629 stripWhiteSpace (vBOTH, items[1]);
630 stripWhiteSpace (vBOTH, items[2]);
631
632 /* Set the group name and DB name. */
633 groupList[groupsFound].name = items[0];
634 groupList[groupsFound].desc = items[1];
635 groupList[groupsFound].dbm = items[2];
636 groupsFound++;
637 free(items);
638 }
639 else
640 {
641 CDKfreeStrings(items);
642 errorsFound++;
643 }
644 }
645 }
646
647 /* Clean up. */
648 CDKfreeStrings(lines);
649
650 /* Check the number of groups to the number of errors. */
651 if (errorsFound > 0 && groupsFound == 0)
652 {
653 /* This does NOT look like the rolodex RC file. */
654 return -1;
655 }
656 return groupsFound;
657 }
658
659 /*
660 * This function allows the user to add/delete/modify/save the
661 * contents of a rolodex group.
662 */
663 void useRolodexGroup (CDKSCREEN *screen, char *groupName, char *groupDesc GCC_UNUSED, char *groupDBM)
664 {
665 /* Declare local variables. */
666 CDKSCROLL *nameList= 0;
667 CDKLABEL *helpWindow = 0;
668 SPhoneData phoneData;
669 SPhoneRecord *phoneRecord;
670 char *Index[MAX_ITEMS], *title[3], *mesg[3], temp[256];
671 int phoneCount, selection, height, x;
672
673 /* Set up the help window at the bottom of the screen. */
674 title[0] = "<C><#HL(30)>";
675 title[1] = "<C>Press </B>?<!B> to get detailed help.";
676 title[2] = "<C><#HL(30)>";
677 helpWindow= newCDKLabel (screen, CENTER, BOTTOM, title, 3, FALSE, FALSE);
678 drawCDKLabel (helpWindow, FALSE);
679
680 /* Open the DBM file and read in the contents of the file */
681 phoneCount = readPhoneDataFile (groupDBM, &phoneData);
682 phoneData.recordCount = phoneCount;
683
684 /* Check the number of entries returned. */
685 if (phoneCount == 0)
686 {
687 /*
688 * They tried to open an empty group, maybe they want to
689 * add a new entry to this number.
690 */
691 char *buttons[] = {"<Yes>", "<No>"};
692 mesg[0] = "<C>There were no entries in this group.";
693 mesg[1] = "<C>Do you want to add a new listng?";
694 if (popupDialog (screen, mesg, 2, buttons, 2) == 1)
695 {
696 destroyCDKLabel (helpWindow);
697 return;
698 }
699
700 /* Get the information for a new number. */
701 if (addPhoneRecord (screen, &phoneData) != 0)
702 {
703 return;
704 }
705 }
706 else if (phoneCount < 0)
707 {
708 mesg[0] = "<C>Could not open the database for this group.";
709 popupLabel (screen, mesg, 1);
710 destroyCDKLabel (helpWindow);
711 return;
712 }
713
714 /* Set up the data needed for the scrolling list. */
715 for (x=0; x < phoneData.recordCount; x++)
716 {
717 phoneRecord = &phoneData.record[x];
718 sprintf (temp, "</B/29>%s (%s)", phoneRecord->name, GLineType[phoneRecord->lineType]);
719 Index[x] = copyChar (temp);
720 }
721 sprintf (temp, "<C>Listing of Group </U>%s", groupName);
722 height = (phoneData.recordCount > 5 ? 8 : phoneData.recordCount+3);
723
724 /* Create the scrolling list. */
725 nameList = newCDKScroll (screen, CENTER, CENTER, RIGHT,
726 height, 50, temp, Index,
727 phoneData.recordCount,
728 NUMBERS, A_REVERSE, TRUE, FALSE);
729
730 /* Clean up. */
731 for (x=0; x < phoneData.recordCount; x++)
732 {
733 freeChar (Index[x]);
734 }
735
736 /* Create key bindings. */
737 bindCDKObject (vSCROLL, nameList, 'i', insertPhoneEntryCB, &phoneData);
738 bindCDKObject (vSCROLL, nameList, 'd', deletePhoneEntryCB, &phoneData);
739 bindCDKObject (vSCROLL, nameList, KEY_DC, deletePhoneEntryCB, &phoneData);
740 bindCDKObject (vSCROLL, nameList, '?', phoneEntryHelpCB, 0);
741
742 /* Let them play. */
743 selection = 0;
744 while (selection >= 0)
745 {
746 /* Get the information they want to view. */
747 selection = activateCDKScroll (nameList, 0);
748
749 /* Display the information. */
750 if (selection >= 0)
751 {
752 /* Display the information. */
753 displayPhoneInfo (screen, phoneData.record[selection]);
754 }
755 }
756
757 /* Save the rolodex information to file. */
758 if (savePhoneDataFile (groupDBM, &phoneData) == 0)
759 {
760 /* Something happened. */
761 mesg[0] = "<C>Could not save phone data to data file.";
762 mesg[1] = "<C>All changes have been lost.";
763 popupLabel (screen, mesg, 2);
764 }
765
766 /* Clean up. */
767 for (x=0; x < phoneData.recordCount; x++)
768 {
769 freeChar (phoneData.record[x].name);
770 freeChar (phoneData.record[x].phoneNumber);
771 freeChar (phoneData.record[x].address);
772 freeChar (phoneData.record[x].city);
773 freeChar (phoneData.record[x].province);
774 freeChar (phoneData.record[x].postalCode);
775 freeChar (phoneData.record[x].desc);
776 }
777 destroyCDKScroll (nameList);
778 destroyCDKLabel (helpWindow);
779 }
780
781 /*
782 * This opens a phone data file and returns the number of elements read.
783 */
784 int readPhoneDataFile (char *dataFile, SPhoneData *phoneData)
785 {
786 /* Declare variables. */
787 char **lines = 0;
788 char **items;
789 int linesRead = 0;
790 int chunks= 0;
791 int linesFound = 0;
792 int x;
793
794 /* Open the file and start reading. */
795 linesRead = CDKreadFile (dataFile, &lines);
796
797 /* Check the number of lines read. */
798 if (linesRead <= 0)
799 {
800 return (0);
801 }
802
803 /*
804 * Cycle through what was given to us and save it.
805 */
806 for (x=0; x < linesRead; x++)
807 {
808 if (lines[x][0] != '#')
809 {
810 /* Split the string. */
811 items = CDKsplitString (lines[x], CTRL('V'));
812 chunks = CDKcountStrings (items);
813
814 /* Copy the chunks. */
815 if (chunks == 8)
816 {
817 phoneData->record[linesFound].name = items[0];
818 phoneData->record[linesFound].lineType = atoi (items[1]);
819 phoneData->record[linesFound].phoneNumber = items[2];
820 phoneData->record[linesFound].address = items[3];
821 phoneData->record[linesFound].city = items[4];
822 phoneData->record[linesFound].province = items[5];
823 phoneData->record[linesFound].postalCode = items[6];
824 phoneData->record[linesFound].desc = items[7];
825 freeChar (items[1]);
826 free (items);
827 linesFound++;
828 }
829 else
830 {
831 /* Bad line in the file; recover the memory. */
832 CDKfreeStrings(items);
833 }
834 }
835 }
836
837 /* Clean up. */
838 CDKfreeStrings(lines);
839
840 /* Keep the record count and return. */
841 phoneData->recordCount = linesFound;
842 return linesFound;
843 }
844
845 /*
846 * This opens a phone data file and returns the number of elements read.
847 */
848 int savePhoneDataFile (char *filename, SPhoneData *phoneData)
849 {
850 /* Declare variables. */
851 SPhoneRecord *phoneRecord;
852 time_t clck;
853 FILE *fd;
854 int x;
855
856 /* Can we open the file? */
857 if ((fd = fopen (filename, "w")) == 0)
858 {
859 return 0;
860 }
861
862 /* Get the current time. */
863 time(&clck);
864
865 /* Add the header to the file. */
866 fprintf (fd, "#\n");
867 fprintf (fd, "# This file was automatically saved on %s", ctime(&clck));
868 fprintf (fd, "# There should be %d phone numbers in this file.\n", phoneData->recordCount);
869 fprintf (fd, "#\n");
870
871 /* Cycle through the data and start writing it to the file. */
872 for (x=0; x < phoneData->recordCount; x++)
873 {
874 /* Get a pointer to the object. */
875 phoneRecord = &phoneData->record[x];
876
877 /* Check the phone type. */
878 if (phoneRecord->lineType == vCell || phoneRecord->lineType == vPager)
879 {
880 fprintf (fd, "%s%c%d%c%s%c-%c-%c-%c-%c%s\n",
881 phoneRecord->name, CTRL('V'),
882 phoneRecord->lineType, CTRL('V'),
883 phoneRecord->phoneNumber, CTRL('V'),
884 CTRL('V'), CTRL('V'), CTRL('V'), CTRL('V'),
885 phoneRecord->desc);
886 }
887 else
888 {
889 fprintf (fd, "%s%c%d%c%s%c%s%c%s%c%s%c%s%c%s\n",
890 phoneRecord->name, CTRL('V'),
891 phoneRecord->lineType, CTRL('V'),
892 phoneRecord->phoneNumber, CTRL('V'),
893 phoneRecord->address, CTRL('V'),
894 phoneRecord->city, CTRL('V'),
895 phoneRecord->province, CTRL('V'),
896 phoneRecord->postalCode, CTRL('V'),
897 phoneRecord->desc);
898 }
899 }
900 fclose (fd);
901 return 1;
902 }
903
904 /*
905 * This displays the information about the phone record.
906 */
907 void displayPhoneInfo (CDKSCREEN *screen, SPhoneRecord record)
908 {
909 /* Declare local variables. */
910 char *mesg[10], temp[256];
911
912 /* Check the type of line it is. */
913 if (record.lineType == vVoice ||
914 record.lineType == vData1 ||
915 record.lineType == vData2 ||
916 record.lineType == vData3 ||
917 record.lineType == vFAX1 ||
918 record.lineType == vFAX2 ||
919 record.lineType == vFAX3)
920 {
921 /* Create the information to display. */
922 sprintf (temp, "<C></U>%s Phone Record", GLineType[record.lineType]);
923 mesg[0] = copyChar (temp);
924
925 sprintf (temp, "</B/29>Name <!B!29>%s", record.name);
926 mesg[1] = copyChar (temp);
927
928 sprintf (temp, "</B/29>Phone Number<!B!29>%s", record.phoneNumber);
929 mesg[2] = copyChar (temp);
930
931 sprintf (temp, "</B/29>Address <!B!29>%s", record.address);
932 mesg[3] = copyChar (temp);
933
934 sprintf (temp, "</B/29>City <!B!29>%s", record.city);
935 mesg[4] = copyChar (temp);
936
937 sprintf (temp, "</B/29>Province <!B!29>%s", record.province);
938 mesg[5] = copyChar (temp);
939
940 sprintf (temp, "</B/29>Postal Code <!B!29>%s", record.postalCode);
941 mesg[6] = copyChar (temp);
942
943 sprintf (temp, "</B/29>Comment <!B!29>%s", record.desc);
944 mesg[7] = copyChar (temp);
945
946 /* Pop the information up on the screen. */
947 popupLabel (screen, mesg, 8);
948
949 /* Clean up. */
950 freeChar (mesg[0]); freeChar (mesg[1]); freeChar (mesg[2]);
951 freeChar (mesg[3]); freeChar (mesg[4]); freeChar (mesg[5]);
952 freeChar (mesg[6]); freeChar (mesg[7]);
953 }
954 else if (record.lineType == vPager || record.lineType == vCell)
955 {
956 /* Create the information to display. */
957 sprintf (temp, "<C></U>%s Phone Record", GLineType[record.lineType]);
958 mesg[0] = copyChar (temp);
959
960 sprintf (temp, "</B/29>Name <!B!29>%s", record.name);
961 mesg[1] = copyChar (temp);
962
963 sprintf (temp, "</B/29>Phone Number<!B!29>%s", record.phoneNumber);
964 mesg[2] = copyChar (temp);
965
966 sprintf (temp, "</B/29>Comment <!B!29>%s", record.desc);
967 mesg[3] = copyChar (temp);
968
969 /* Pop the information up on the screen. */
970 popupLabel (screen, mesg, 4);
971
972 /* Clean up. */
973 freeChar (mesg[0]); freeChar (mesg[1]);
974 freeChar (mesg[2]); freeChar (mesg[3]);
975 }
976 else
977 {
978 mesg[0] = "<C></R>Error<!R> </U>Unknown Phone Line Type";
979 mesg[1] = "<C>Can not display information.";
980 popupLabel (screen, mesg, 2);
981 }
982 }
983
984 /*
985 * This function displays a little pop up window discussing this demo.
986 */
987 void aboutCdkRolodex (CDKSCREEN *screen)
988 {
989 char *mesg[15];
990
991 mesg[0] = "<C></U>About Cdk Rolodex";
992 mesg[1] = " ";
993 mesg[2] = "</B/24>This demo was written to demonstrate the widgets";
994 mesg[3] = "</B/24>available with the Cdk library. Not all of the";
995 mesg[4] = "</B/24>Cdk widgets are used, but most of them have been.";
996 mesg[5] = "</B/24>I hope this little demonstration helps give you an";
997 mesg[6] = "</B/24>understanding of what the Cdk library offers.";
998 mesg[7] = " ";
999 mesg[8] = "<C></B/24>Have fun with it.";
1000 mesg[9] = " ";
1001 mesg[10] = "</B/24>ttfn,";
1002 mesg[11] = "<C></B/24>Mike";
1003 mesg[12] = "<C><#HL(35)>";
1004 mesg[13] = "<R></B/24>March 1996";
1005
1006 popupLabel (screen, mesg, 14);
1007 }
1008
1009 /*
1010 * This deletes a rolodex group.
1011 */
1012 int deleteRolodexGroup (CDKSCREEN *screen, SRolodex *groupList, int groupCount)
1013 {
1014 /* Declare local variables. */
1015 char *mesg[10], *buttons[5], temp[256];
1016 int selection, choice, x;
1017
1018 /* If there are no groups, pop up a message telling them. */
1019 if (groupCount == 0)
1020 {
1021 mesg[0] = "<C>Error";
1022 mesg[1] = "<C>There as no groups defined.";
1023 popupLabel (screen, mesg, 2);
1024
1025 /* Return the current group count. */
1026 return groupCount;
1027 }
1028
1029 /* Get the number of the group to delete. */
1030 selection = pickRolodexGroup (screen, "<C></U>Delete Which Rolodex Group?", groupList, groupCount);
1031
1032 /* Check the results. */
1033 if (selection < 0)
1034 {
1035 mesg[0] = "<C> Delete Canceled ";
1036 mesg[1] = "<C>No Group Deleted";
1037 popupLabel (screen, mesg, 2);
1038 return groupCount;
1039 }
1040
1041 /* Let's make sure they want to delete the group. */
1042 mesg[0] = "<C></U>Confirm Delete";
1043 mesg[1] = "<C>Are you sure you want to delete the group";
1044 sprintf (temp, "<C></R>%s<!R>?", groupList[selection].name);
1045 mesg[2] = copyChar (temp);
1046 buttons[0] = "<No>";
1047 buttons[1] = "<Yes>";
1048 choice = popupDialog (screen, mesg, 3, buttons, 2);
1049 freeChar (mesg[2]);
1050
1051 /* Check the results of the confirmation. */
1052 if (choice == 0)
1053 {
1054 mesg[0] = "<C> Delete Canceled ";
1055 mesg[1] = "<C>No Group Deleted";
1056 popupLabel (screen, mesg, 2);
1057 return groupCount;
1058 }
1059
1060 /* We need to delete the group file first. */
1061 unlink (groupList[selection].dbm);
1062
1063 /* OK, lets delete the group. */
1064 freeChar (groupList[selection].name);
1065 freeChar (groupList[selection].desc);
1066 freeChar (groupList[selection].dbm);
1067 for (x=selection; x < groupCount-1; x++)
1068 {
1069 groupList[x].name = groupList[x+1].name;
1070 groupList[x].desc = groupList[x+1].desc;
1071 groupList[x].dbm = groupList[x+1].dbm;
1072 }
1073 groupCount--;
1074 GGroupModified = 1;
1075
1076 /* Clean up. */
1077 return groupCount;
1078 }
1079
1080 /*
1081 * This function gets information about a new phone number.
1082 */
1083 int addPhoneRecord (CDKSCREEN *screen, SPhoneData *phoneData)
1084 {
1085 /* Declare local variables. */
1086 CDKLABEL *title;
1087 CDKITEMLIST *itemList;
1088 SPhoneRecord *phoneRecord;
1089 char *titleMesg[3], *types[GLINETYPECOUNT], temp[256];
1090 int ret, x;
1091
1092 /* Get the phone record pointer. */
1093 phoneRecord = &phoneData->record[phoneData->recordCount];
1094
1095 /* Create a title label to display. */
1096 titleMesg[0] = "<C></B/16>Add New Phone Record";
1097 title = newCDKLabel (screen, CENTER, TOP, titleMesg, 1, FALSE, FALSE);
1098 drawCDKLabel (title, FALSE);
1099
1100 /* Create the phone line type list. */
1101 for (x=0; x < GLINETYPECOUNT; x++)
1102 {
1103 sprintf (temp, "<C></U>%s", GLineType[x]);
1104 types[x] = copyChar (temp);
1105 }
1106
1107 /* Get the phone line type. */
1108 itemList = newCDKItemlist (screen, CENTER, CENTER,
1109 "<C>What Type Of Line Is It?",
1110 "Type: ",
1111 types, GLINETYPECOUNT, 0,
1112 TRUE, FALSE);
1113 phoneRecord->lineType = activateCDKItemlist (itemList, 0);
1114 destroyCDKItemlist (itemList);
1115
1116 /* Clean up. */
1117 for (x=0; x < GLINETYPECOUNT; x++)
1118 {
1119 freeChar (types[x]);
1120 }
1121
1122 /* Check the return code of the line type question. */
1123 if (phoneRecord->lineType == -1)
1124 {
1125 phoneRecord->lineType = (ELineType) 0;
1126 return 1;
1127 }
1128 else if (phoneRecord->lineType == vPager || phoneRecord->lineType == vCell)
1129 {
1130 ret = getSmallPhoneRecord (screen, phoneRecord);
1131 }
1132 else
1133 {
1134 ret = getLargePhoneRecord (screen, phoneRecord);
1135 }
1136
1137 /* Check the return value from the getXXXPhoneRecord function.*/
1138 if (ret == 0)
1139 {
1140 phoneData->recordCount++;
1141 }
1142
1143 /* Clean up. */
1144 destroyCDKLabel (title);
1145
1146 /* Return the new phone list count. */
1147 return ret;
1148 }
1149
1150 /*
1151 * This gets a phone record with all of the details.
1152 */
1153 int getLargePhoneRecord (CDKSCREEN *screen, SPhoneRecord *phoneRecord)
1154 {
1155 /* Declare local variables. */
1156 CDKENTRY *nameEntry, *addressEntry, *cityEntry;
1157 CDKENTRY *provEntry, *postalEntry, *descEntry;
1158 CDKTEMPLATE *phoneTemplate;
1159 char *buttons[5], *mesg[15];
1160 int ret;
1161
1162 /* Define the widgets. */
1163 nameEntry = newCDKEntry (screen, LEFT, 5,
1164 0, "</B/5>Name: ",
1165 A_NORMAL,
1166 '_', vMIXED, 20, 2, 256,
1167 TRUE, FALSE);
1168 addressEntry = newCDKEntry (screen, RIGHT, 5,
1169 0, "</B/5>Address: ",
1170 A_NORMAL,
1171 '_', vMIXED, 40, 2, 256,
1172 TRUE, FALSE);
1173 cityEntry = newCDKEntry (screen, LEFT, 8,
1174 0, "</B/5>City: ",
1175 A_NORMAL,
1176 '_', vMIXED, 20, 2, 256,
1177 TRUE, FALSE);
1178 provEntry = newCDKEntry (screen, 29, 8,
1179 0, "</B/5>Province: ",
1180 A_NORMAL,
1181 '_', vMIXED, 15, 2, 256,
1182 TRUE, FALSE);
1183 postalEntry = newCDKEntry (screen, RIGHT, 8,
1184 0, "</B/5>Postal Code: ",
1185 A_NORMAL,
1186 '_', vUMIXED, 8, 2, 256,
1187 TRUE, FALSE);
1188 phoneTemplate = newCDKTemplate (screen, LEFT, 11,
1189 0,
1190 "</B/5>Number: ",
1191 "(###) ###-####",
1192 "(___) ___-____",
1193 TRUE, FALSE);
1194 descEntry = newCDKEntry (screen, RIGHT, 11,
1195 0,
1196 "</B/5>Description: ",
1197 A_NORMAL,
1198 '_', vMIXED, 20, 2, 256,
1199 TRUE, FALSE);
1200
1201 /* Get the phone information. */
1202 for (;;)
1203 {
1204 /* Draw the widgets on the screen. */
1205 drawCDKEntry (nameEntry, ObjOf(nameEntry)->box);
1206 drawCDKEntry (addressEntry, ObjOf(addressEntry)->box);
1207 drawCDKEntry (cityEntry, ObjOf(cityEntry)->box);
1208 drawCDKEntry (provEntry, ObjOf(provEntry)->box);
1209 drawCDKEntry (postalEntry, ObjOf(postalEntry)->box);
1210 drawCDKTemplate (phoneTemplate, ObjOf(phoneTemplate)->box);
1211 drawCDKEntry (descEntry, ObjOf(descEntry)->box);
1212
1213 /* Activate the entries to get the information. */
1214 phoneRecord->name = copyChar (activateCDKEntry (nameEntry, 0));
1215 phoneRecord->address = copyChar (activateCDKEntry (addressEntry, 0));
1216 phoneRecord->city = copyChar (activateCDKEntry (cityEntry, 0));
1217 phoneRecord->province = copyChar (activateCDKEntry (provEntry, 0));
1218 phoneRecord->postalCode = copyChar (activateCDKEntry (postalEntry, 0));
1219 activateCDKTemplate (phoneTemplate, 0);
1220 phoneRecord->phoneNumber = mixCDKTemplate (phoneTemplate);
1221 phoneRecord->desc = copyChar (activateCDKEntry (descEntry, 0));
1222
1223 /* Determine if the user wants to submit the info. */
1224 mesg[0] = "<C></U>Confirm New Phone Entry";
1225 mesg[1] = "<C>Do you want to add this phone number?";
1226 buttons[0] = "</B/24><Add Phone Number>";
1227 buttons[1] = "</B/16><Cancel>";
1228 buttons[2] = "</B/32><Modify Information>";
1229 ret = popupDialog (screen, mesg, 2, buttons, 3);
1230
1231 /* Check the response of the popup dialog box. */
1232 if (ret == 0)
1233 {
1234 /* The user wants to submit the information. */
1235 destroyCDKEntry (nameEntry);
1236 destroyCDKEntry (addressEntry);
1237 destroyCDKEntry (cityEntry);
1238 destroyCDKEntry (provEntry);
1239 destroyCDKEntry (postalEntry);
1240 destroyCDKEntry (descEntry);
1241 destroyCDKTemplate (phoneTemplate);
1242 return ret;
1243 }
1244 else if (ret == 1)
1245 {
1246 /* The user does not want to submit the information. */
1247 freeChar (phoneRecord->name);
1248 freeChar (phoneRecord->address);
1249 freeChar (phoneRecord->city);
1250 freeChar (phoneRecord->province);
1251 freeChar (phoneRecord->postalCode);
1252 freeChar (phoneRecord->phoneNumber);
1253 freeChar (phoneRecord->desc);
1254 destroyCDKEntry (nameEntry);
1255 destroyCDKEntry (addressEntry);
1256 destroyCDKEntry (cityEntry);
1257 destroyCDKEntry (provEntry);
1258 destroyCDKEntry (postalEntry);
1259 destroyCDKEntry (descEntry);
1260 destroyCDKTemplate (phoneTemplate);
1261 return ret;
1262 }
1263 else
1264 {
1265 /* The user wants to edit the information again. */
1266 freeChar (phoneRecord->name);
1267 freeChar (phoneRecord->address);
1268 freeChar (phoneRecord->city);
1269 freeChar (phoneRecord->province);
1270 freeChar (phoneRecord->postalCode);
1271 freeChar (phoneRecord->phoneNumber);
1272 freeChar (phoneRecord->desc);
1273 }
1274 }
1275 }
1276
1277 /*
1278 * This gets a small phone record.
1279 */
1280 int getSmallPhoneRecord (CDKSCREEN *screen, SPhoneRecord *phoneRecord)
1281 {
1282 /* Declare local variables. */
1283 CDKENTRY *nameEntry, *descEntry;
1284 CDKTEMPLATE *phoneTemplate;
1285 char *buttons[5], *mesg[15];
1286 int ret;
1287
1288 /* Define the widgets. */
1289 nameEntry = newCDKEntry (screen, CENTER, 8,
1290 0, "</B/5>Name: ",
1291 A_NORMAL,
1292 '_', vMIXED, 20, 2, 256,
1293 TRUE, FALSE);
1294 phoneTemplate = newCDKTemplate (screen, CENTER, 11,
1295 0, "</B/5>Number: ",
1296 "(###) ###-####",
1297 "(___) ___-____",
1298 TRUE, FALSE);
1299 descEntry = newCDKEntry (screen, CENTER, 14,
1300 0, "</B/5>Description: ",
1301 A_NORMAL,
1302 '_', vMIXED, 20, 2, 256,
1303 TRUE, FALSE);
1304
1305 /* Get the phone information. */
1306 for (;;)
1307 {
1308 /* Draw the widgets on the screen. */
1309 drawCDKEntry (nameEntry, ObjOf(nameEntry)->box);
1310 drawCDKTemplate (phoneTemplate, ObjOf(phoneTemplate)->box);
1311 drawCDKEntry (descEntry, ObjOf(descEntry)->box);
1312
1313 /* Activate the entries to get the information. */
1314 phoneRecord->name = copyChar (activateCDKEntry (nameEntry, 0));
1315 activateCDKTemplate (phoneTemplate, 0);
1316 phoneRecord->phoneNumber = mixCDKTemplate (phoneTemplate);
1317 phoneRecord->desc = copyChar (activateCDKEntry (descEntry, 0));
1318 phoneRecord->address = copyChar ("-");
1319 phoneRecord->city = copyChar ("-");
1320 phoneRecord->province = copyChar ("-");
1321 phoneRecord->postalCode = copyChar ("-");
1322
1323 /* Determine if the user wants to submit the info. */
1324 mesg[0] = "<C></B/5>Confirm New Phone Entry";
1325 mesg[1] = "<C>Do you want to add this phone number?";
1326 buttons[0] = "</B/24><Add Phone Number>";
1327 buttons[1] = "</B/16><Cancel>";
1328 buttons[2] = "</B/8><Modify Information>";
1329 ret = popupDialog (screen, mesg, 2, buttons, 3);
1330
1331 /* Check the response of the popup dialog box. */
1332 if (ret == 0)
1333 {
1334 /* The user wants to submit the information. */
1335 destroyCDKEntry (nameEntry);
1336 destroyCDKEntry (descEntry);
1337 destroyCDKTemplate (phoneTemplate);
1338 return ret;
1339 }
1340 else if (ret == 1)
1341 {
1342 /* The user does not want to submit the information. */
1343 freeChar (phoneRecord->name);
1344 freeChar (phoneRecord->phoneNumber);
1345 freeChar (phoneRecord->desc);
1346 freeChar (phoneRecord->address);
1347 freeChar (phoneRecord->city);
1348 freeChar (phoneRecord->province);
1349 freeChar (phoneRecord->postalCode);
1350
1351 destroyCDKEntry (nameEntry);
1352 destroyCDKEntry (descEntry);
1353 destroyCDKTemplate (phoneTemplate);
1354 return ret;
1355 }
1356 else
1357 {
1358 /* The user wants to edit the information again. */
1359 freeChar (phoneRecord->name);
1360 freeChar (phoneRecord->phoneNumber);
1361 freeChar (phoneRecord->desc);
1362 freeChar (phoneRecord->address);
1363 freeChar (phoneRecord->city);
1364 freeChar (phoneRecord->province);
1365 freeChar (phoneRecord->postalCode);
1366 }
1367 }
1368 }
1369
1370 /*
1371 * This prints a groups phone numbers.
1372 */
1373 void printGroupNumbers (CDKSCREEN *screen, SRolodex *groupList, int groupCount)
1374 {
1375 /* Declare local variables. */
1376 CDKSELECTION *selectionList;
1377 CDKENTRY *entry;
1378 CDKLABEL *title;
1379 char *itemList[MAX_ITEMS], *mesg[10], temp[256];
1380 char *choices[] = {"Print to Printer ", "Print to File", "Don't Print"};
1381 char *filename = 0;
1382 char *printer = 0;
1383 char *defaultPrinter = 0;
1384 int height = groupCount;
1385 int x;
1386
1387 /* Create the group list. */
1388 for (x=0; x < groupCount; x++)
1389 {
1390 itemList[x] = copyChar (groupList[x].name);
1391 }
1392
1393 /* Set the height of the selection list. */
1394 if (groupCount > 5)
1395 {
1396 height = 5;
1397 }
1398 height += 3;
1399
1400 /* Create the selection list. */
1401 selectionList = newCDKSelection (screen, CENTER, CENTER, RIGHT,
1402 height, 40,
1403 "<C></U>Select Which Groups To Print",
1404 itemList, groupCount,
1405 choices, 3,
1406 A_REVERSE, TRUE, FALSE);
1407
1408 /* Activate the selection list. */
1409 if (activateCDKSelection (selectionList, 0) == -1)
1410 {
1411 /* Tell the user they exited early. */
1412 destroyCDKSelection (selectionList);
1413 mesg[0] = "<C>Print Canceled.";
1414 popupLabel (screen, mesg, 1);
1415
1416 /* Clean up. */
1417 for (x=0; x < groupCount; x++)
1418 {
1419 freeChar (itemList[x]);
1420 }
1421 return;
1422 }
1423 eraseCDKSelection (selectionList);
1424
1425 /* Determine which groups we want to print. */
1426 for (x=0; x < groupCount; x++)
1427 {
1428 if (selectionList->selections[x] == 0)
1429 {
1430 /* Create a title. */
1431 sprintf (temp, "<C></R>Printing Group [%s] to Printer", groupList[x].name);
1432 mesg[0] = copyChar (temp);
1433 title = newCDKLabel (screen, CENTER, TOP, mesg, 1, FALSE, FALSE);
1434 drawCDKLabel (title, FALSE);
1435 freeChar (mesg[0]);
1436
1437 /* Get the printer name to print to. */
1438 entry = newCDKEntry (screen, CENTER, 8,
1439 0, "</R>Printer Name: ",
1440 A_NORMAL,
1441 '_', vMIXED, 20, 2, 256, TRUE, FALSE);
1442
1443 /* Set the printer name to the default printer. */
1444 defaultPrinter = getenv("PRINTER");
1445 setCDKEntry (entry, defaultPrinter, 2, 256, TRUE);
1446 printer = copyChar (activateCDKEntry (entry, 0));
1447 destroyCDKEntry (entry);
1448
1449 /* Print the group. */
1450 if (printGroup (groupList[x], "/tmp/rolodex.tmp", printer) == 0)
1451 {
1452 /* The group could not be printed. */
1453 sprintf (temp, "<C>Sorry the group '%s' could not be printed.", groupList[x].name);
1454 mesg[0] = strdup (temp);
1455 popupLabel (screen, mesg, 1);
1456 freeChar (mesg[0]);
1457 }
1458
1459 /* Clean up. */
1460 destroyCDKLabel (title);
1461 freeChar (printer);
1462 unlink ("/tmp/rolodex.tmp");
1463 }
1464 else if (selectionList->selections[x] == 1)
1465 {
1466 /* Create a title. */
1467 sprintf (temp, "<C></R>Printing Group [%s] to File", groupList[x].name);
1468 mesg[0] = copyChar (temp);
1469 title = newCDKLabel (screen, CENTER, TOP, mesg, 1, FALSE, FALSE);
1470 drawCDKLabel (title, FALSE);
1471 freeChar (mesg[0]);
1472
1473 /* Get the filename to print to. */
1474 entry = newCDKEntry (screen, CENTER, 8,
1475 0, "</R>Filename: ",
1476 A_NORMAL, '_', vMIXED,
1477 20, 2, 256, TRUE, FALSE);
1478 filename = copyChar (activateCDKEntry (entry, 0));
1479 destroyCDKEntry (entry);
1480
1481 /* Print the group. */
1482 if (printGroup (groupList[x], filename, printer) == 0)
1483 {
1484 /* The group could not be printed. */
1485 sprintf (temp, "<C>Sorry the group '%s' could not be printed.", groupList[x].name);
1486 mesg[0] = strdup (temp);
1487 popupLabel (screen, mesg, 1);
1488 freeChar (mesg[0]);
1489 }
1490
1491 /* Clean up. */
1492 destroyCDKLabel (title);
1493 freeChar (filename);
1494 }
1495 }
1496
1497 /* Clean up. */
1498 destroyCDKSelection (selectionList);
1499 for (x=0; x < groupCount; x++)
1500 {
1501 freeChar (itemList[x]);
1502 }
1503 }
1504
1505 /*
1506 * This actually prints the phone record.
1507 */
1508 int printGroup (SRolodex groupRecord, char *filename, char *printer)
1509 {
1510 /* Declare local variables. */
1511 uid_t uid = getuid();
1512 char tempFilename[256], command[256];
1513 SPhoneData phoneData;
1514 SPhoneRecord *phoneRecord;
1515 int phoneCount, x;
1516 FILE *fd;
1517
1518 /* Read the data file. */
1519 phoneCount = readPhoneDataFile (groupRecord.dbm, &phoneData);
1520
1521 /* Create the temporary filename. */
1522 if (filename != 0)
1523 {
1524 sprintf (tempFilename, "%s", filename);
1525 }
1526 else
1527 {
1528 sprintf (tempFilename, "/tmp/rolodex.%d", (int)uid);
1529 }
1530
1531 /* Open the file. */
1532 if ((fd = fopen (tempFilename, "a+")) == 0)
1533 {
1534 /* Clean up. */
1535 for (x=0; x < phoneCount; x++)
1536 {
1537 freeChar (phoneData.record[x].name);
1538 freeChar (phoneData.record[x].phoneNumber);
1539 freeChar (phoneData.record[x].address);
1540 freeChar (phoneData.record[x].city);
1541 freeChar (phoneData.record[x].province);
1542 freeChar (phoneData.record[x].postalCode);
1543 freeChar (phoneData.record[x].desc);
1544 }
1545 return 0;
1546 }
1547
1548 /* Start writing the group information to the temp file. */
1549 fprintf (fd, "Group Name: %40s\n", groupRecord.name);
1550 fprintf (fd, "==============================================================================\n");
1551 for (x=0; x < phoneCount; x++)
1552 {
1553 phoneRecord = &phoneData.record[x];
1554 fprintf (fd, "Name : %s\n", phoneRecord->name);
1555 fprintf (fd, "Phone Number: %s (%s)\n", phoneRecord->phoneNumber, GLineType[phoneRecord->lineType]);
1556 if (phoneRecord->lineType != vPager && phoneRecord->lineType != vCell)
1557 {
1558 fprintf (fd, "Address : %-20s, %-20s\n", phoneRecord->address, phoneRecord->city);
1559 fprintf (fd, " : %-10s, %-10s\n", phoneRecord->province, phoneRecord->postalCode);
1560 }
1561 fprintf (fd, "Description : %-30s\n", phoneRecord->desc);
1562 fprintf (fd, "------------------------------------------------------------------------------\n");
1563 }
1564
1565 /* Determine if the information is going to a file or printer. */
1566 if (printer != 0)
1567 {
1568 /* Print the file to the given printer. */
1569 sprintf (command, "lpr -P%s %s", printer, tempFilename);
1570 system (command);
1571
1572 /* We have to unlkink the temp file. */
1573 unlink (tempFilename);
1574 }
1575
1576 /* Clean up some memory. */
1577 for (x=0; x < phoneCount; x++)
1578 {
1579 freeChar (phoneData.record[x].name);
1580 freeChar (phoneData.record[x].phoneNumber);
1581 freeChar (phoneData.record[x].address);
1582 freeChar (phoneData.record[x].city);
1583 freeChar (phoneData.record[x].province);
1584 freeChar (phoneData.record[x].postalCode);
1585 freeChar (phoneData.record[x].desc);
1586 }
1587
1588 /* Close the filename. */
1589 fclose (fd);
1590 return 1;
1591 }
1592
1593 /*
1594 ****************************************************************
1595 * Start of callback functions.
1596 ****************************************************************
1597 */
1598 int entryPreProcessCB (EObjectType cdkType GCC_UNUSED, void *object GCC_UNUSED, void *clientData GCC_UNUSED, chtype input)
1599 {
1600 if (input == ' ')
1601 {
1602 Beep();
1603 return 0;
1604 }
1605 return 1;
1606 }
1607
1608 /*
1609 * This allows the user to insert a new phone entry into the database.
1610 */
1611 int insertPhoneEntryCB (EObjectType cdkType GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED)
1612 {
1613 /* Declare local variables. */
1614 CDKSCROLL *scrollp= (CDKSCROLL *)object;
1615 SPhoneData *phoneData= (SPhoneData *)clientData;
1616 SPhoneRecord *phoneRecord= &phoneData->record[phoneData->recordCount];
1617 char temp[256];
1618
1619 /* Make the scrolling list disappear. */
1620 eraseCDKScroll (scrollp);
1621
1622 /* Call the function which gets phone record information. */
1623 if (addPhoneRecord (ScreenOf(scrollp), phoneData) == 0)
1624 {
1625 sprintf (temp, "%s (%s)", phoneRecord->name, GLineType[phoneRecord->lineType]);
1626 addCDKScrollItem (scrollp, temp);
1627 }
1628
1629 /* Redraw the scrolling list. */
1630 drawCDKScroll (scrollp, ObjOf(scrollp)->box);
1631 return (FALSE);
1632 }
1633
1634 /*
1635 * This allows the user to delete a phone entry from the database.
1636 */
1637 int deletePhoneEntryCB (EObjectType cdkType GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED)
1638 {
1639 /* Declare local variables. */
1640 CDKSCROLL *scrollp = (CDKSCROLL *)object;
1641 SPhoneData *phoneData = (SPhoneData *)clientData;
1642 char *mesg[3], temp[256], *hold;
1643 char *buttons[] = {"</B/16><No>", "</B/24><Yes>"};
1644 int position = scrollp->currentItem;
1645 int x;
1646
1647 /* Make the scrolling list disappear. */
1648 eraseCDKScroll (scrollp);
1649
1650 /* Check the number of entries left in the list. */
1651 if (scrollp->listSize == 0)
1652 {
1653 mesg[0] = "There are no more numbers to delete.";
1654 popupLabel (ScreenOf(scrollp), mesg, 1);
1655 return (FALSE);
1656 }
1657
1658 /* Ask the user if they really want to delete the listing. */
1659 mesg[0] = "<C>Do you really want to delete the phone entry";
1660 hold = chtype2Char (scrollp->item[scrollp->currentItem]);
1661 sprintf (temp, "<C></B/16>%s", hold);
1662 freeChar (hold);
1663 mesg[1] = copyChar (temp);
1664 if (popupDialog (ScreenOf(scrollp), mesg, 2, buttons, 2) == 1)
1665 {
1666 /* Remove the item from the phone data record. */
1667 for (x=position; x < phoneData->recordCount-1; x++)
1668 {
1669 phoneData->record[x].name = phoneData->record[x+1].name;
1670 phoneData->record[x].lineType = phoneData->record[x+1].lineType;
1671 phoneData->record[x].phoneNumber = phoneData->record[x+1].phoneNumber;
1672 phoneData->record[x].address = phoneData->record[x+1].address;
1673 phoneData->record[x].city = phoneData->record[x+1].city;
1674 phoneData->record[x].province = phoneData->record[x+1].province;
1675 phoneData->record[x].postalCode = phoneData->record[x+1].postalCode;
1676 phoneData->record[x].desc = phoneData->record[x+1].desc;
1677 }
1678 phoneData->recordCount--;
1679
1680 /* Nuke the entry. */
1681 deleteCDKScrollItem (scrollp, position);
1682 }
1683 freeChar (mesg[1]);
1684
1685 /* Redraw the scrolling list. */
1686 drawCDKScroll (scrollp, ObjOf(scrollp)->box);
1687 return (FALSE);
1688 }
1689
1690 /*
1691 * This function provides help for the phone list editor.
1692 */
1693 int phoneEntryHelpCB (EObjectType cdkType GCC_UNUSED, void *object, void *clientData GCC_UNUSED, chtype key GCC_UNUSED)
1694 {
1695 /* Declare local variables. */
1696 CDKSCROLL *scrollp = (CDKSCROLL *)object;
1697 char *mesg[10], temp[100];
1698
1699 /* Create the help title. */
1700 sprintf (temp, "<C></R>Rolodex Phone Editor");
1701 mesg[0] = copyChar (temp);
1702
1703 sprintf (temp, "<B=i > Inserts a new phone entry.");
1704 mesg[1] = copyChar (temp);
1705
1706 sprintf (temp, "<B=d > Deletes the currently selected phone entry.");
1707 mesg[2] = copyChar (temp);
1708
1709 sprintf (temp, "<B=Escape> Exits the scrolling list.");
1710 mesg[3] = copyChar (temp);
1711
1712 sprintf (temp, "<B=? > Pops up this help window.");
1713 mesg[4] = copyChar (temp);
1714
1715 /* Pop up the message. */
1716 popupLabel (ScreenOf(scrollp), mesg, 5);
1717
1718 /* Clean up. */
1719 freeChar (mesg[0]); freeChar (mesg[1]);
1720 freeChar (mesg[2]); freeChar (mesg[3]);
1721 freeChar (mesg[4]);
1722 return (FALSE);
1723 }
1724
1725 /*
1726 * This is a callback to the menu widget. It allows the user to
1727 * ask for help about any sub-menu item.
1728 */
1729 int helpCB (EObjectType cdkType GCC_UNUSED, void *object, void *clientData GCC_UNUSED, chtype key GCC_UNUSED)
1730 {
1731 /* Declare local variables. */
1732 CDKMENU *menu= (CDKMENU *)object;
1733 int menuList= menu->currentTitle;
1734 int submenuList= menu->currentSubtitle;
1735 int selection= ((menuList * 100) + submenuList);
1736 char *mesg[20], *name, temp[100];
1737
1738 /* Create the help title. */
1739 name = chtype2Char (menu->sublist[menuList][submenuList]);
1740 stripWhiteSpace (vBOTH, name);
1741 sprintf (temp, "<C></R>Help<!R> </U>%s<!U>", name);
1742 mesg[0] = copyChar (temp);
1743 freeChar (name);
1744
1745 /* Set the default value for the message. */
1746 mesg[1] = "<C>No help defined for this menu.";
1747
1748 /* Given the current menu item, create a message. */
1749 if (selection == 0)
1750 {
1751 mesg[1] = "<C>This reads a new rolodex RC file.";
1752 }
1753 else if (selection == 1)
1754 {
1755 mesg[1] = "<C>This saves the current group information in the default RC file.";
1756 }
1757 else if (selection == 2)
1758 {
1759 mesg[1] = "<C>This saves the current group information in a new RC file.";
1760 }
1761 else if (selection == 3)
1762 {
1763 mesg[1] = "<C>This exits this program.";
1764 }
1765 else if (selection == 100)
1766 {
1767 mesg[1] = "<C>This creates a new rolodex group.";
1768 }
1769 else if (selection == 101)
1770 {
1771 mesg[1] = "<C>This opens a rolodex group.";
1772 }
1773 else if (selection == 102)
1774 {
1775 mesg[1] = "<C>This deletes a rolodex group.";
1776 }
1777 else if (selection == 200)
1778 {
1779 mesg[1] = "<C>This prints out selected groups phone numbers.";
1780 }
1781 else if (selection == 300)
1782 {
1783 mesg[1] = "<C>This gives a little history on this program.";
1784 }
1785 else if (selection == 301)
1786 {
1787 mesg[1] = "<C>This provides information about the rolodex.";
1788 }
1789
1790 /* Pop up the message. */
1791 popupLabel (ScreenOf(menu), mesg, 2);
1792 freeChar (mesg[0]);
1793
1794 /* Redraw the submenu window. */
1795 drawCDKMenuSubwin (menu);
1796 return (FALSE);
1797 }
1798
1799 /*
1800 * This is a callback to the group list scrolling list.
1801 */
1802 int groupInfoCB (EObjectType cdkType GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED)
1803 {
1804 /* Declare local variables. */
1805 CDKSCROLL *scrollp= (CDKSCROLL *)object;
1806 SRolodex *groupList= (SRolodex *)clientData;
1807 int selection= scrollp->currentItem;
1808 char *mesg[5], temp[100];
1809
1810 /* Create the message to be displayed. */
1811 mesg[0] = "<C></U>Detailed Group Information.";
1812
1813 sprintf (temp, "</R>Group Name <!R> %s", groupList[selection].name);
1814 mesg[1] = copyChar (temp);
1815
1816 sprintf (temp, "</R>Group Description <!R> %s", groupList[selection].desc);
1817 mesg[2] = copyChar (temp);
1818
1819 sprintf (temp, "</R>Group Database File<!R> %s", groupList[selection].dbm);
1820 mesg[3] = copyChar (temp);
1821
1822 /* Display the message. */
1823 popupLabel (ScreenOf(scrollp), mesg, 4);
1824 freeChar (mesg[1]); freeChar (mesg[2]);
1825 freeChar (mesg[3]);
1826
1827 /* Redraw the scrolling list. */
1828 drawCDKScroll (scrollp, ObjOf(scrollp)->box);
1829 return (FALSE);
1830 }
0 /* $Id: rolodex.h,v 1.9 2005/12/27 12:34:20 tom Exp $ */
1
2 #include <cdk_test.h>
3 #include <time.h>
4 #include <fcntl.h>
5 #include <unistd.h>
6
7 #define MAXGROUPS 100
8 #define GLINETYPECOUNT 9
9
10 /*
11 * Declare some global variables.
12 */
13 static char *GCurrentGroup = 0;
14 static char *GRCFile = 0;
15 static char *GDBMDir = 0;
16 static int GGroupModified = FALSE;
17 static char *GLineType[] = {"Voice", "Cell", "Pager", "First FAX", "Second FAX", "Third FAX", "First Data Line", "Second Data Line", "Third Data Line"};
18
19 /*
20 * Create some definitions.
21 */
22 typedef enum {vUnknown = -1, vVoice = 0, vCell, vPager, vFAX1, vFAX2, vFAX3, vData1, vData2, vData3} ELineType;
23
24 /*
25 * Define the group record structure.
26 */
27 struct _group_st {
28 char *name;
29 char *desc;
30 char *dbm;
31 };
32 typedef struct _group_st SRolodex;
33
34 /*
35 * Define a phone record structure;
36 */
37 struct _record_st {
38 char *name;
39 ELineType lineType;
40 char *phoneNumber;
41 char *address;
42 char *city;
43 char *province;
44 char *postalCode;
45 char *desc;
46 };
47 typedef struct _record_st SPhoneRecord;
48
49 struct _phone_data_st {
50 SPhoneRecord record[MAX_ITEMS];
51 int recordCount;
52 };
53 typedef struct _phone_data_st SPhoneData;
54
55 /*
56 * Define the callback prototypes.
57 */
58 BINDFN_PROTO(helpCB);
59 BINDFN_PROTO(groupInfoCB);
60 BINDFN_PROTO(insertPhoneEntryCB);
61 BINDFN_PROTO(deletePhoneEntryCB);
62 BINDFN_PROTO(phoneEntryHelpCB);
63 int entryPreProcessCB (EObjectType cdkType, void *object, void *clientData, chtype input);
64
65 /*
66 * These functions use/modify the rolodex RC file.
67 */
68 int readRCFile (char *filename, SRolodex *groupInfo);
69 int openNewRCFile (CDKSCREEN *screen, SRolodex *groups, int groupCount);
70 int writeRCFile (CDKSCREEN *screen, char *file, SRolodex *groups, int count);
71 int writeRCFileAs (CDKSCREEN *screen, SRolodex *groups, int count);
72
73 /*
74 * These functions use/modify rolodex phone groups.
75 */
76 int addRolodexGroup (CDKSCREEN *screen, SRolodex *groups, int count);
77 int deleteRolodexGroup (CDKSCREEN *screen, SRolodex *groups, int count);
78 int pickRolodexGroup (CDKSCREEN *screen, char *title, SRolodex *groups, int count);
79 void useRolodexGroup (CDKSCREEN *screen, char *name, char *desc, char *dbm);
80
81 /*
82 * These functions display misc information about the rolodex program.
83 */
84 void displayRolodexStats (CDKSCREEN *screen, int groupCount);
85 void aboutCdkRolodex (CDKSCREEN *screen);
86 void displayPhoneInfo (CDKSCREEN *screen, SPhoneRecord record);
87
88 /*
89 * These functions use/modify phone data lists.
90 */
91 int readPhoneDataFile (char *filename, SPhoneData *record);
92 int savePhoneDataFile (char *filename, SPhoneData *record);
93 int addPhoneRecord (CDKSCREEN *screen, SPhoneData *phoneData);
94 int deletePhoneRecord (CDKSCREEN *screen, SPhoneData *phoneData);
95 int getLargePhoneRecord (CDKSCREEN *screen, SPhoneRecord *phoneRecord);
96 int getSmallPhoneRecord (CDKSCREEN *screen, SPhoneRecord *phoneRecord);
97
98 /*
99 * These functions allow us to print out phone numbers.
100 */
101 void printGroupNumbers (CDKSCREEN *screen, SRolodex *groups, int count);
102 int printGroup (SRolodex groupRecord, char *filename, char *printer);
0 /* $Id: serial.c,v 1.6 2005/12/27 12:36:06 tom Exp $ */
1
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include <fcntl.h>
6 #include <termios.h>
7 #include <sys/termios.h>
8 #include <sys/ioctl.h>
9 #include <unistd.h>
10 #include <time.h>
11
12 #include <cdk_test.h>
13
14 #ifdef HAVE_XCURSES
15 char *XCursesProgramName="serial";
16 #endif
17
18 /*
19 * Create global definitions.
20 */
21 #define DEFAULT_PORT "/dev/ttya"
22 #define DEFAULT_POLL_INTERVAL 1 /* milliseconds */
23
24 /*
25 * This is the working function which probes the serial port.
26 */
27 boolean probeModem (void);
28
29 /*
30 * Define some global variables.
31 */
32 CDKLABEL *label = 0;
33 int LLastState = 0;
34 int LCurrentState = 0;
35 extern char *optarg;
36 char port[256];
37 int LFD;
38
39 /*
40 *
41 */
42 int main (int argc, char **argv)
43 {
44 CDKSCREEN *cdkScreen = 0;
45 WINDOW *cursesWin = 0;
46 int lines = 0;
47 char *info[256], temp[256];
48 struct termios termInfo;
49 int ret;
50
51 /* Set the deault values. */
52 strcpy (port, DEFAULT_PORT);
53
54 /* Parse up the command line. */
55 while (1)
56 {
57 if ((ret = getopt (argc, argv, "p:h")) == -1)
58 {
59 break;
60 }
61
62 switch (ret)
63 {
64 case 'p' :
65 strcpy (port, optarg);
66 break;
67
68 case 'h' :
69 printf ("Usage: %s [-p Port] [-i Poll Interval] [-c Poll Count] [-v] [-h]\n", argv[0]);
70 ExitProgram (EXIT_SUCCESS);
71 break;
72 }
73 }
74
75 /*
76 * Create the CDK screen.
77 */
78 cursesWin = initscr();
79 cdkScreen = initCDKScreen (cursesWin);
80
81 /* Start CDK color. */
82 initCDKColor();
83
84 /*
85 * Set the title of the main window.
86 */
87 sprintf (temp, "<C>Serial Port Monitor (%s)", port);
88 info[lines++] = copyChar (temp);
89 info[lines++] = copyChar ("<C><#HL(30)>");
90 info[lines++] = copyChar ("");
91 info[lines++] = copyChar ("Line Enabled : -");
92 info[lines++] = copyChar ("Data Terminal Ready: -");
93 info[lines++] = copyChar ("Carrier Detect : -");
94 info[lines++] = copyChar ("Request To Send : -");
95 info[lines++] = copyChar ("Clear To Send : -");
96 info[lines++] = copyChar ("Secondary Transmit : -");
97 info[lines++] = copyChar ("Secondary Receive : -");
98 info[lines++] = copyChar ("");
99
100 /* Create the label widget. */
101 label = newCDKLabel (cdkScreen, CENTER, CENTER, info, lines, TRUE, FALSE);
102 drawCDKLabel (label, TRUE);
103
104 /*
105 * Open the serial port read only.
106 */
107 if ((LFD = open (port, O_RDONLY|O_NDELAY, 0)) == -1)
108 {
109 /* Create a pop-up dialog box... */
110 printf ("Error: Open of <%s> failed.\n", port);
111 ExitProgram (EXIT_FAILURE);
112 }
113
114 termInfo.c_cflag = CRTSCTS | CLOCAL;
115 if (tcgetattr (LFD, &termInfo) != 0)
116 {
117 /* Really should create a pop-up dialog box... */
118 printf ("Error: Could not get port attributes. Closing the port.\n");
119 close (LFD);
120 ExitProgram (EXIT_FAILURE);
121 }
122
123 for (;;)
124 {
125 /* Probe the modem. */
126 probeModem();
127
128 /*
129 * Sleep for the given amount of time. We do this first so no
130 * weird refresh things happen.
131 */
132 napms (DEFAULT_POLL_INTERVAL);
133 }
134 }
135
136 /*
137 * This probes the modem and determines if we need to update
138 * the display.
139 */
140 boolean probeModem (void)
141 {
142 int lines = 0;
143 char *info[256], temp[256];
144
145 /* Start building the label. */
146 sprintf (temp, "<C>Serial Port Monitor (%s)", port);
147 info[lines++] = copyChar (temp);
148 info[lines++] = copyChar ("<C><#HL(30)>");
149 info[lines++] = copyChar ("");
150
151 /*
152 * Get the serial port info.
153 */
154 ioctl (LFD, TIOCMGET, &LCurrentState);
155
156 /*
157 * If the states are different, change the display.
158 */
159 if (LLastState != LCurrentState)
160 {
161 /*
162 * Check for line enabled.
163 */
164 if (LCurrentState & TIOCM_LE)
165 {
166 info[lines++] = copyChar ("Line Enabled : <#DI>");
167 }
168 else
169 {
170 info[lines++] = copyChar ("Line Enabled : ");
171 }
172
173 /*
174 * Check for data terminal ready.
175 */
176 if (LCurrentState & TIOCM_DTR)
177 {
178 info[lines++] = copyChar ("Data Terminal Ready: <#DI>");
179 }
180 else
181 {
182 info[lines++] = copyChar ("Data Terminal Ready: ");
183 }
184
185 /*
186 * Check for carrier detect.
187 */
188 if (LCurrentState & TIOCM_CAR)
189 {
190 info[lines++] = copyChar ("Carrier Detect : <#DI>");
191 }
192 else
193 {
194 info[lines++] = copyChar ("Carrier Detect : ");
195 }
196
197 /*
198 * Check for request to send.
199 */
200 if (LCurrentState & TIOCM_RTS)
201 {
202 info[lines++] = copyChar ("Request To Send : <#DI>");
203 }
204 else
205 {
206 info[lines++] = copyChar ("Request To Send : ");
207 }
208
209 /*
210 * Check for clear to send.
211 */
212 if (LCurrentState & TIOCM_CTS)
213 {
214 info[lines++] = copyChar ("Clear To Send : <#DI>");
215 }
216 else
217 {
218 info[lines++] = copyChar ("Clear To Send : ");
219 }
220
221 /*
222 * Check for secondary transmit.
223 */
224 if (LCurrentState & TIOCM_ST)
225 {
226 info[lines++] = copyChar ("Secondary Transmit : <#DI>");
227 }
228 else
229 {
230 info[lines++] = copyChar ("Secondary Transmit : ");
231 }
232
233 /*
234 * Check for secondary receive.
235 */
236 if (LCurrentState & TIOCM_SR)
237 {
238 info[lines++] = copyChar ("Secondary Receive : <#DI>");
239 }
240 else
241 {
242 info[lines++] = copyChar ("Secondary Receive : ");
243 }
244 }
245 info[lines++] = copyChar ("");
246
247 /* Only do this if things have changed. */
248 if (LLastState != LCurrentState)
249 {
250 eraseCDKLabel (label);
251 setCDKLabel (label, info, lines, TRUE);
252 drawCDKLabel (label, TRUE);
253 }
254
255 /*
256 * Keep the current state.
257 */
258 LLastState = LCurrentState;
259
260 /*
261 * Return False to tell X that we want this funtion to be
262 * run again.
263 */
264 return FALSE;
265 }
0 /* $Id: stopSign.c,v 1.9 2005/12/30 00:17:57 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName="sillyness_ex";
6 #endif
7
8 int main(void)
9 {
10 /* Declare variables. */
11 CDKSCREEN *cdkscreen = 0;
12 CDKLABEL *stopSign = 0;
13 CDKLABEL *title = 0;
14 WINDOW *cursesWin = 0;
15 int currentLight = 0;
16 char *mesg[5], *sign[4];
17 chtype key;
18 boolean functionKey;
19
20 /* Set up CDK. */
21 cursesWin = initscr();
22 cdkscreen = initCDKScreen (cursesWin);
23
24 /* Start CDK Colors. */
25 initCDKColor();
26
27 /* Set the labels up. */
28 mesg[0] = "<C><#HL(40)>";
29 mesg[1] = "<C>Press </B/16>r<!B!16> for the </B/16>red light";
30 mesg[2] = "<C>Press </B/32>y<!B!32> for the </B/32>yellow light";
31 mesg[3] = "<C>Press </B/24>g<!B!24> for the </B/24>green light";
32 mesg[4] = "<C><#HL(40)>";
33 sign[0] = " <#DI> ";
34 sign[1] = " <#DI> ";
35 sign[2] = " <#DI> ";
36
37 /* Declare the labels. */
38 title = newCDKLabel (cdkscreen, CENTER, TOP, mesg, 5, FALSE, FALSE);
39 stopSign = newCDKLabel (cdkscreen, CENTER, CENTER, sign, 3, TRUE, TRUE);
40
41 /* Do this until they hit q or escape. */
42 for (;;)
43 {
44 drawCDKLabel (title, FALSE);
45 drawCDKLabel (stopSign, TRUE);
46
47 key = getchCDKObject (ObjOf(stopSign), &functionKey);
48 if (key == KEY_ESC || key == 'q' || key == 'Q')
49 {
50 break;
51 }
52 else if (key == 'r' || key == 'R')
53 {
54 sign[0] = " </B/16><#DI> ";
55 sign[1] = " o ";
56 sign[2] = " o ";
57 currentLight = 0;
58 }
59 else if (key == 'y' || key == 'Y')
60 {
61 sign[0] = " o ";
62 sign[1] = " </B/32><#DI> ";
63 sign[2] = " o ";
64 currentLight = 1;
65 }
66 else if (key == 'g' || key == 'G')
67 {
68 sign[0] = " o ";
69 sign[1] = " o ";
70 sign[2] = " </B/24><#DI> ";
71 currentLight = 2;
72 }
73
74 /* Set the contents of the label and re-draw it. */
75 setCDKLabel (stopSign, sign, 3, TRUE);
76 }
77
78 /* Clean up. */
79 destroyCDKLabel (title);
80 destroyCDKLabel (stopSign);
81 destroyCDKScreen (cdkscreen);
82 endCDK();
83 ExitProgram (EXIT_SUCCESS);
84 }
0 /* $Id: syb.c,v 1.12 2005/12/27 12:36:06 tom Exp $ */
1
2 #include <cdk_test.h>
3 #include <sybfront.h>
4 #include <sybdb.h>
5
6 #ifdef HAVE_XCURSES
7 char *XCursesProgramName="syb";
8 #endif
9
10 #define MAXWIDTH 5000
11 #define MAXHISTORY 1000
12
13 /*
14 * This structure is used for keeping command history.
15 */
16 struct history_st {
17 unsigned used;
18 int count;
19 int current;
20 char **cmd_history;
21 };
22
23 /*
24 * Define some global variables.
25 */
26 char *GPUsage = "[-p Command Prompt] [-U User] [-P Password] [-S Server] [-h help]";
27 char *GPCurrentDatabase = 0;
28 extern char *dberrstr;
29
30 /*
31 * Because the error/message callback do not allow you to pass in
32 * data of your own, we have to make the screen pointer global. :(
33 */
34 CDKSCREEN *GPCdkScreen = 0;
35
36 /*
37 * Define function prototypes.
38 */
39 DBPROCESS *loginToSybase (CDKSCREEN *screen, char *login, char *password);
40 DBPROCESS *sybaseLogin (CDKSCREEN *screen, char *login, char *password, int attempts);
41 char *assembleTitle (DBPROCESS *dbProcess);
42 char *assembleRow (DBPROCESS *dbProcess);
43 char *uc (char *word);
44 int getColWidth (DBPROCESS *dbProcess, int col);
45 void runIsqlCommand (CDKSCREEN *cdkscreen, CDKSWINDOW *swindow, DBPROCESS *process);
46 void useDatabase (CDKSWINDOW *swindow, DBPROCESS *dbProc, char *command);
47 void intro (CDKSCREEN *screen);
48 void help (CDKENTRY *entry);
49 void loadHistory (struct history_st *history);
50 void saveHistory (struct history_st *history, int count);
51
52 /*
53 * Define callback prototypes.
54 */
55 BINDFN_PROTO(viewHistoryCB);
56 BINDFN_PROTO(swindowHelpCB);
57 BINDFN_PROTO(historyUpCB);
58 BINDFN_PROTO(historyDownCB);
59 BINDFN_PROTO(listHistoryCB);
60
61 /*
62 * Define Sybase error/message callbacks. This is required by DBLib.
63 */
64 int err_handler (DBPROCESS *dbProcess, DBINT mesgNumber, int mesgState,
65 int severity, char *mesgText);
66 int msg_handler (DBPROCESS *dbProcess, DBINT mesgNumber, int mesgState,
67 int severity, char *mesgText);
68
69 /*
70 * Written by: Mike Glover
71 * Purpose:
72 * This creates a very simple interface to Sybase.
73 */
74 int main (int argc, char **argv)
75 {
76 /* Declare variables. */
77 CDKSWINDOW *commandOutput = 0;
78 CDKENTRY *commandEntry = 0;
79 DBPROCESS *dbProcess = 0;
80 WINDOW *cursesWin = 0;
81 char *dsquery = 0;
82 char *command = 0;
83 char *prompt = 0;
84 char *upper = 0;
85 char *login = 0;
86 char *password = 0;
87 char *server = 0;
88 int count = 0;
89 int width = 0;
90 int ret = 0;
91 struct history_st history;
92 char *mesg[5], temp[1000];
93
94 /* Set up the history. */
95 GPCurrentDatabase = copyChar ("master");
96 history.used = 0;
97 history.current = 0;
98 history.count = 0;
99
100 /* Check the command line for options. */
101 while (1)
102 {
103 /* Are there any more command line options to parse. */
104 if ((ret = getopt (argc, argv, "p:U:P:S:h")) == -1)
105 {
106 break;
107 }
108
109 switch (ret)
110 {
111 case 'p':
112 prompt = copyChar (optarg);
113 break;
114
115 case 'U':
116 login = copyChar (optarg);
117 break;
118
119 case 'P':
120 password = copyChar (optarg);
121 break;
122
123 case 'S':
124 server = copyChar (optarg);
125 break;
126
127 case 'h':
128 printf ("Usage: %s %s\n", argv[0], GPUsage);
129 ExitProgram (EXIT_SUCCESS);
130 break;
131 }
132 }
133
134 /* Set up the command prompt. */
135 if (prompt == 0)
136 {
137 if (server == 0)
138 {
139 if ((dsquery = getenv ("DSQUERY")) != 0)
140 {
141 sprintf (temp, "</B/24>[%s] Command >", dsquery);
142 prompt = copyChar (temp);
143 }
144 else
145 {
146 prompt = copyChar ("</B/24>Command >");
147 }
148 }
149 else
150 {
151 sprintf (temp, "</B/24>[%s] Command >", server);
152 prompt = copyChar (temp);
153 }
154 }
155
156 /* Set up CDK. */
157 cursesWin = initscr();
158 GPCdkScreen = initCDKScreen (cursesWin);
159
160 /* Start color. */
161 initCDKColor();
162
163 /* Initialize DB-Library. */
164 if (dbinit() == FAIL)
165 {
166 mesg[0] = "<C></U>Fatal Error";
167 mesg[1] = "<C>Could not connect to the Sybase database.";
168 popupLabel (GPCdkScreen, mesg, 2);
169 ExitProgram (EXIT_FAILURE);
170 }
171
172 /* Load the history. */
173 loadHistory (&history);
174
175 /* Create the scrolling window. */
176 commandOutput = newCDKSwindow (GPCdkScreen, CENTER, TOP, -8, -2,
177 "<C></B/5>Command Output Window",
178 MAXWIDTH, TRUE, FALSE);
179
180 /* Create the entry field. */
181 width = COLS - strlen (prompt) - 1;
182 commandEntry = newCDKEntry (GPCdkScreen, CENTER, BOTTOM,
183 0, prompt, A_BOLD|COLOR_PAIR(8),
184 COLOR_PAIR(24)|'_', vMIXED,
185 width, 1, 512, FALSE, FALSE);
186
187 /* Create the key bindings. */
188 bindCDKObject (vENTRY, commandEntry, KEY_UP, &historyUpCB, &history);
189 bindCDKObject (vENTRY, commandEntry, KEY_DOWN, &historyDownCB, &history);
190 bindCDKObject (vENTRY, commandEntry, CTRL('^'), &listHistoryCB, &history);
191 bindCDKObject (vENTRY, commandEntry, KEY_TAB, &viewHistoryCB, commandOutput);
192 bindCDKObject (vSWINDOW, commandOutput, '?', swindowHelpCB, commandEntry);
193
194 /* Draw the screen. */
195 refreshCDKScreen (GPCdkScreen);
196
197 /* Display the introduction window. */
198 intro (GPCdkScreen);
199
200 /* Make them login first. */
201 dbProcess = sybaseLogin (GPCdkScreen, login, password, 3);
202 if (dbProcess == 0)
203 {
204 destroyCDKScreen (GPCdkScreen);
205 endCDK ();
206 ExitProgram (EXIT_FAILURE);
207 }
208
209 /* Do this forever. */
210 for (;;)
211 {
212 /* Get the command. */
213 command = activateCDKEntry (commandEntry, 0);
214
215 /* Strip off leading and trailing white space. */
216 stripWhiteSpace (vBOTH, command);
217
218 /* Upper case the command. */
219 upper = uc (command);
220
221 /* Check the output of the command. */
222 if (strcmp (upper, "QUIT") == 0 ||
223 strcmp (upper, "EXIT") == 0 ||
224 strcmp (upper, "Q") == 0 ||
225 strcmp (upper, "E") == 0 ||
226 commandEntry->exitType == vESCAPE_HIT)
227 {
228 /* Save the history. */
229 saveHistory (&history, 100);
230
231 /* Exit. */
232 dbclose (dbProcess);
233 dbexit();
234
235 /* All done. */
236 destroyCDKEntry (commandEntry);
237 destroyCDKSwindow (commandOutput);
238 freeChar (upper);
239 endCDK();
240 ExitProgram (EXIT_SUCCESS);
241 }
242 else if (strcmp (command, "login") == 0)
243 {
244 DBPROCESS *newLogin = sybaseLogin (GPCdkScreen, 0, 0, 3);
245 if (newLogin == 0)
246 {
247 addCDKSwindow (commandOutput, "Login Error: Could not switch to new user.", BOTTOM);
248 }
249 else
250 {
251 /* Close the old connection. */
252 dbclose (dbProcess);
253 dbProcess = newLogin;
254
255 /* Add a message to the scrolling window. */
256 addCDKSwindow (commandOutput,
257 "Logged into database as new user.",
258 BOTTOM);
259 count = 0;
260 }
261 }
262 else if (strcmp (command, "logout") == 0)
263 {
264 /* Close the old connection. */
265 dbclose (dbProcess);
266 dbProcess = 0;
267
268 /* Add a message to the scrolling window. */
269 addCDKSwindow (commandOutput, "Logged out.", BOTTOM);
270 count = 0;
271 }
272 else if (strcmp (command, "clear") == 0)
273 {
274 /* Clear the scrolling window. */
275 cleanCDKSwindow (commandOutput);
276 }
277 else if (strcmp (command, "history") == 0)
278 {
279 listHistoryCB (vENTRY, (void *)commandEntry, (void *)&history, 0);
280 }
281 else if (strcmp (command, "tables") == 0)
282 {
283 /* Check if we are logged in. */
284 if (dbProcess == 0)
285 {
286 addCDKSwindow (commandOutput, "You must login first.", BOTTOM);
287 }
288 else
289 {
290 sprintf (command, "select * from sysobjects where type = 'U'");
291
292 /* Put the command into the ISQL buffer. */
293 dbcmd (dbProcess, command);
294
295 /* Put the command into the scrolling window. */
296 sprintf (temp, "</R>%d><!R> %s", count+1, command);
297 addCDKSwindow (commandOutput, temp, BOTTOM);
298
299 /* Increment the counter. */
300 count++;
301 }
302 }
303 else if (strcmp (command, "help") == 0)
304 {
305 /* Display the help. */
306 help(commandEntry);
307 }
308 else if (command[0] == 'u' && command[1] == 's' &&
309 command[2] == 'e' && command[3] == ' ')
310 {
311 /* They want to use a database. */
312 useDatabase (commandOutput, dbProcess, command);
313 count = 0;
314 }
315 else if (strcmp (command, "go") == 0)
316 {
317 /* Check if we are logged in. */
318 if (dbProcess == 0)
319 {
320 addCDKSwindow (commandOutput, "You must login first.", BOTTOM);
321 }
322 else
323 {
324 /* Put the command into the scrolling window. */
325 sprintf (temp, "</R>%d><!R> %s", count+1, command);
326 addCDKSwindow (commandOutput, temp, BOTTOM);
327 count = 0;
328
329 /* Run the command. */
330 runIsqlCommand (GPCdkScreen, commandOutput, dbProcess);
331 }
332 }
333 else
334 {
335 /* Check if we are logged in. */
336 if (dbProcess == 0)
337 {
338 addCDKSwindow (commandOutput, "You must login first.", BOTTOM);
339 }
340 else
341 {
342 /* Put the command into the ISQL buffer. */
343 dbcmd (dbProcess, command);
344
345 /* Put the command into the scrolling window. */
346 sprintf (temp, "</R>%d><!R> %s", count+1, command);
347 addCDKSwindow (commandOutput, temp, BOTTOM);
348
349 /* Increment the counter. */
350 count++;
351 }
352 }
353
354 /* Keep the history. */
355 history.used = CDKallocStrings(&(history.cmd_history), command, history.count++, history.used);
356 history.current = history.count;
357
358 /* Clear the entry field. */
359 cleanCDKEntry (commandEntry);
360
361 /* Free up the memory used by the upper pointer. */
362 freeChar (upper);
363 }
364 }
365
366 /*
367 * This lets a person 'use' a database.
368 */
369 void useDatabase (CDKSWINDOW *swindow, DBPROCESS *dbProc, char *command)
370 {
371 char *database = 0;
372 char temp[256];
373 char **words;
374 int wordCount, x;
375
376 /* Split the command line up and get the database name. */
377 words = CDKsplitString (command, ' ');
378 wordCount = CDKcountStrings (words);
379
380 /* Look for the name. */
381 for (x=1; x < wordCount; x++)
382 {
383 if (strlen (words[x]) != 0)
384 {
385 database = copyChar (words[x]);
386 }
387 }
388 CDKfreeStrings(words);
389
390 /* Try to actually use the database. */
391 if (dbuse(dbProc, database) == FAIL)
392 {
393 /* We aren't allowed to use that database. */
394 sprintf (temp, "Command: %s", command);
395 addCDKSwindow (swindow, temp, BOTTOM);
396 addCDKSwindow (swindow, "</B/16>Error<!B!16> You are not allowed to use that database.", BOTTOM);
397 return;
398 }
399
400 /* Set the global database name. */
401 if (database == 0)
402 {
403 /* Put a syntax error in the scrolling window. */
404 sprintf (temp, "Command: %s", command);
405 addCDKSwindow (swindow, temp, BOTTOM);
406 addCDKSwindow (swindow, "</B/16>Error<!B!16> Syntax Error", BOTTOM);
407 return;
408 }
409
410 /* Clear out the old database name and set the new one. */
411 freeChar (GPCurrentDatabase);
412 GPCurrentDatabase = database;
413
414 /* Add a message into the scrolling window. */
415 sprintf (temp, "Command: %s", command);
416 addCDKSwindow (swindow, temp, BOTTOM);
417 sprintf (temp, "Default Database set to %s", GPCurrentDatabase);
418 addCDKSwindow (swindow, temp, BOTTOM);
419 }
420
421 /*
422 * This does the requisite checking for failed login attempts.
423 */
424 DBPROCESS *sybaseLogin (CDKSCREEN *screen, char *accountName, char *accountPassword, int attemptCount)
425 {
426 DBPROCESS *dbProcess = 0;
427 char *login = accountName;
428 char *password = accountPassword;
429 int count = 0;
430 int lines = 0;
431 char *mesg[5];
432
433 /* Give them X attempts, then kick them out. */
434 while (count < attemptCount)
435 {
436 /* Try to login. */
437 dbProcess = loginToSybase (GPCdkScreen, login, password);
438
439 /*
440 * If the dbprocess is null the account/password
441 * pair does not exist.
442 */
443 if (dbProcess == 0)
444 {
445 /*
446 * If the login and account names were provided,
447 * set them to null and allow the user to enter
448 * the name and password by hand.
449 */
450 login = 0;
451 password = 0;
452
453 /* Spit out the login error message. */
454 lines = 0;
455 mesg[lines++] = "<C></B/5>Login Error";
456 mesg[lines++] = " ";
457 mesg[lines++] = "<C>The login/password pair does not exist.";
458 mesg[lines++] = " ";
459 mesg[lines++] = "<C>Please try again.";
460
461 popupLabel (GPCdkScreen, mesg, lines);
462
463 eraseCDKScreen (GPCdkScreen);
464 refreshCDKScreen (GPCdkScreen);
465 count++;
466 }
467 else
468 {
469 break;
470 }
471 }
472
473 /* Did we expire the login attempts? */
474 if (count > attemptCount-1)
475 {
476 lines = 0;
477 mesg[lines++] = "<C>Login Error";
478 mesg[lines++] = " ";
479 mesg[lines++] = "<C>Too many attempyts to login.";
480 mesg[lines++] = "<C>Exiting.";
481
482 popupLabel (GPCdkScreen, mesg, lines);
483
484 return 0;
485 }
486 return dbProcess;
487 }
488
489 /*
490 * Let the user login.
491 */
492 DBPROCESS *loginToSybase (CDKSCREEN *screen, char *accountName, char *accountPassword)
493 {
494 CDKENTRY *loginEntry = 0;
495 CDKENTRY *passwordEntry = 0;
496 LOGINREC *dbLogin = 0;
497 char *hostAccount = 0;
498 char *login = accountName;
499 char *password = accountPassword;
500 char *mesg[10], temp[256];
501
502 /* Draw the screen. */
503 refreshCDKScreen (screen);
504
505 /* Define the login entry field. */
506 if (login == 0)
507 {
508 loginEntry = newCDKEntry (screen, CENTER, CENTER,
509 "\n<C></B/5>Sybase Login\n",
510 "Account Name: ",
511 A_BOLD|COLOR_PAIR(8),
512 COLOR_PAIR(24)|'_', vMIXED,
513 20, 1, 20, TRUE, FALSE);
514
515 /* Use the current account name as the default answer. */
516 hostAccount = getlogin();
517 setCDKEntryValue (loginEntry, hostAccount);
518
519 /* Get the login. */
520 while (1)
521 {
522 /* Redraw the screen. */
523 eraseCDKScreen (ScreenOf(loginEntry));
524 refreshCDKScreen (ScreenOf(loginEntry));
525
526 /* Get the login to the sybase account. */
527 login = copyChar (activateCDKEntry (loginEntry, 0));
528
529 /* Check if they hit escape. */
530 if (loginEntry->exitType == vESCAPE_HIT)
531 {
532 mesg[0] = "<C></U>Error";
533 mesg[1] = "A user name must be provided.";
534 popupLabel (screen, mesg, 2);
535 }
536 else
537 {
538 break;
539 }
540 }
541
542 /* Destroy the widget. */
543 destroyCDKEntry (loginEntry);
544 }
545
546 /* Get the password if we need too. */
547 if (password == 0)
548 {
549 sprintf (temp, "\n<C></B/5>%s's Password\n", login);
550 passwordEntry = newCDKEntry (screen, CENTER, CENTER,
551 temp, "Account Password: ",
552 A_BOLD|COLOR_PAIR(8),
553 COLOR_PAIR(24)|'_', vHMIXED,
554 20, 0, 20, TRUE, FALSE);
555 setCDKEntryHiddenChar (passwordEntry, '*');
556
557 /* Get the password. (the account may not have a password.) */
558 password = copyChar (activateCDKEntry (passwordEntry, 0));
559 if ((passwordEntry->exitType == vESCAPE_HIT) ||
560 (strlen(password) == 0))
561 {
562 password = "";
563 }
564
565 /* Destroy the widget. */
566 destroyCDKEntry (passwordEntry);
567 }
568
569 /*
570 * Try to connect to the database and get a LOGINREC structre.
571 */
572 if ((dbLogin = dblogin()) == 0)
573 {
574 mesg[0] = "<C></U>Fatal Error";
575 mesg[1] = "<C>Could not connect to the Sybase database.";
576 popupLabel (screen, mesg, 2);
577 refreshCDKScreen (screen);
578 ExitProgram (EXIT_FAILURE);
579 }
580
581 /*
582 * Set the login and password and try to login to the database.
583 */
584 DBSETLUSER (dbLogin, login);
585 DBSETLPWD (dbLogin, password);
586 DBSETLAPP (dbLogin, "cdk_syb");
587
588 /* Create a dbprocess structure to communicate with the database. */
589 return dbopen (dbLogin, 0);
590 }
591
592 /*
593 * This actually runs the command.
594 */
595 void runIsqlCommand (CDKSCREEN *screen, CDKSWINDOW *swindow, DBPROCESS *dbProcess)
596 {
597 /* Declare local variables. */
598 RETCODE returnCode;
599 int rowCount;
600
601 /* Add in a output seperation line. */
602 addCDKSwindow (swindow, "<C><#HL(5)> Start of Output <#HL(5)>", BOTTOM);
603
604 /* Run the command. */
605 dbsqlexec (dbProcess);
606
607 /* Check the return code of the commands. */
608 while ((returnCode = dbresults (dbProcess)) != NO_MORE_RESULTS)
609 {
610 if (returnCode == FAIL)
611 {
612 /* Oops, the command bombed. */
613 addCDKSwindow (swindow, "</5/16>Command failed.", BOTTOM);
614 }
615 else
616 {
617 if (!(DBCMDROW (dbProcess)))
618 {
619 /* The command could not return any rows. */
620 addCDKSwindow (swindow, "</5/16>Command could not return rows.", BOTTOM);
621 }
622 else
623 {
624 /*
625 * The command returned some rows, print out the title.
626 */
627 char *row = assembleTitle (dbProcess);
628 addCDKSwindow (swindow, row, BOTTOM);
629 freeChar (row);
630
631 /* For each row returned, assemble the info. */
632 rowCount = 0;
633 while (dbnextrow (dbProcess) != NO_MORE_ROWS)
634 {
635 row = assembleRow (dbProcess);
636 addCDKSwindow (swindow, row, BOTTOM);
637 freeChar (row);
638 }
639 }
640 }
641 }
642
643 /* Add in a output seperation line. */
644 addCDKSwindow (swindow, "<C><#HL(5)> End of Output <#HL(5)>", BOTTOM);
645 addCDKSwindow (swindow, "", BOTTOM);
646
647 /* Can the query... */
648 dbcanquery (dbProcess);
649 }
650
651 /*
652 * This creates a single line from the column widths and values.
653 */
654 char *assembleTitle (DBPROCESS *dbProc)
655 {
656 char *colName = 0;
657 int colWidth = 0;
658 int colNameLen = 0;
659 int colCount = dbnumcols (dbProc);
660 int x = 0;
661 char temp[MAXWIDTH];
662 char row[MAXWIDTH];
663
664 /* Clean the row out. */
665 memset (row, '\0', MAXWIDTH);
666
667 /* Start assembling the row. */
668 for (x=1; x <= colCount; x++)
669 {
670 colName = dbcolname (dbProc, x);
671 colWidth = getColWidth (dbProc, x);
672 colNameLen = strlen (colName);
673
674 /* If we need to pad, then pad. */
675 if (colNameLen < colWidth)
676 {
677 /* Create a string the same length as the col width. */
678 memset (temp, '\0', MAXWIDTH);
679 memset (temp, ' ', (colWidth-colNameLen));
680
681 /* Copy the name. */
682 sprintf (row, "%s %s%s", row, colName, temp);
683 }
684 else
685 {
686 /* Copy the name. */
687 sprintf (row, "%s %s", row, colName);
688 }
689 }
690 return copyChar (row);
691 }
692
693 /*
694 * This assembles a single row.
695 */
696 char *assembleRow (DBPROCESS *dbProcess)
697 {
698 char *dataValue = 0;
699 int colCount = dbnumcols (dbProcess);
700 int columnType = 0;
701 int colWidth = 0;
702 int valueLen = 0;
703 char value[MAXWIDTH];
704 char temp[MAXWIDTH];
705 char row[MAXWIDTH];
706 char format[20];
707 int x;
708
709 /* Clean out the row. */
710 memset (row, '\0', MAXWIDTH);
711
712 /* Start assembling the row. */
713 for (x=1; x <= colCount; x++)
714 {
715 columnType = (int)dbcoltype (dbProcess, x);
716 colWidth = (int)getColWidth (dbProcess, x);
717 valueLen = (int)dbdatlen (dbProcess, x);
718
719 /* Check the column type. */
720 if (columnType == SYBINT1)
721 {
722 DBINT object_id = *((DBINT *)dbdata(dbProcess, x));
723 sprintf (format, "%%-%dd", colWidth);
724 sprintf (value, format, (int)object_id);
725 }
726 else if (columnType == SYBINT2)
727 {
728 DBINT object_id = *((DBINT *)dbdata(dbProcess, x));
729 sprintf (format, "%%-%dd", colWidth);
730 sprintf (value, format, (int)object_id);
731 }
732 else if (columnType == SYBINT4)
733 {
734 DBINT object_id = *((DBINT *)dbdata(dbProcess, x));
735 sprintf (format, "%%-%dd", colWidth);
736 sprintf (value, format, (int)object_id);
737 }
738 else if (columnType == SYBREAL)
739 {
740 DBREAL object_id = *((DBREAL *)dbdata(dbProcess, x));
741 sprintf (format, "%%-%d.2f", colWidth);
742 sprintf (value, format, object_id);
743 }
744 else if (columnType == SYBFLT8)
745 {
746 DBFLT8 object_id = *((DBFLT8 *)dbdata(dbProcess, x));
747 sprintf (format, "%%-%d.2f", colWidth);
748 sprintf (value, format, object_id);
749 }
750 else
751 {
752 if (valueLen <= 0)
753 {
754 strcpy (value, " ");
755 }
756 else
757 {
758 memset (value, '\0', MAXWIDTH);
759 dataValue = (DBCHAR *)dbdata (dbProcess, x);
760 strncpy (value, dataValue, valueLen);
761 }
762 }
763
764 /* If we need to pad, then pad. */
765 if (valueLen < colWidth)
766 {
767 /* Copy the value into the string. */
768 memset (temp, '\0', MAXWIDTH);
769 memset (temp, ' ', (colWidth-valueLen));
770 sprintf (row, "%s %s%s", row, value, temp);
771 }
772 else
773 {
774 sprintf (row, "%s %s", row, value);
775 }
776 }
777 return copyChar (row);
778 }
779
780 /*
781 * This function returns the correct width of a column, taking
782 * into account the width of the title, the width of the data
783 * element.
784 */
785 int getColWidth (DBPROCESS *dbProcess, int col)
786 {
787 char *colName = dbcolname (dbProcess, col);
788 int colNameLen = strlen(colName);
789 int colWidth = dbcollen (dbProcess, col);
790 int columnType = (int)dbcoltype (dbProcess, col);
791
792 /* If the colType is int/real/float adjust accordingly. */
793 if (columnType == SYBINT1 || columnType == SYBINT2 ||
794 columnType == SYBINT4)
795 {
796 colWidth = 5;
797 }
798 else if (columnType == SYBREAL || columnType == SYBFLT8)
799 {
800 colWidth = 8;
801 }
802
803 /* Is the name of the column wider than the col width? */
804 if (colNameLen >= colWidth)
805 {
806 return (colNameLen+1);
807 }
808 return colWidth;
809 }
810
811 /*
812 * This callback allows the user to play with the scrolling window.
813 */
814 int viewHistoryCB (EObjectType cdktype, void *object, void *clientData, chtype key)
815 {
816 CDKSWINDOW *swindow = (CDKSWINDOW *)clientData;
817 CDKENTRY *entry = (CDKENTRY *)object;
818
819 /* Let them play... */
820 activateCDKSwindow (swindow, 0);
821
822 /* Redraw the entry field. */
823 drawCDKEntry (entry, ObjOf(entry)->box);
824 return (TRUE);
825 }
826
827 /*
828 * This displays a little introduction screen.
829 */
830 void intro (CDKSCREEN *screen)
831 {
832 int lines = 0;
833 char *mesg[10];
834
835 /* Create the message. */
836 mesg[lines++] = "";
837 mesg[lines++] = "<C></B/16>Sybase Command Interface";
838 mesg[lines++] = "<C>Written by Mike Glover";
839 mesg[lines++] = "";
840 mesg[lines++] = "<C>Type </B>help<!B> to get help.";
841
842 /* Display the message. */
843 popupLabel (screen, mesg, lines);
844 }
845
846 /*
847 * This function displays help.
848 */
849 void help (CDKENTRY *entry)
850 {
851 int lines = 0;
852 char *mesg[25];
853
854 /* Create the help message. */
855 mesg[lines++] = "<C></B/29>Help";
856 mesg[lines++] = "";
857 mesg[lines++] = "</B/24>When in the command line.";
858 mesg[lines++] = "<B=Up Arrow > Scrolls back one command.";
859 mesg[lines++] = "<B=Down Arrow> Scrolls forward one command.";
860 mesg[lines++] = "<B=Tab > Activates the scrolling window.";
861 mesg[lines++] = "<B=help > Displays this help window.";
862 mesg[lines++] = "";
863 mesg[lines++] = "</B/24>When in the scrolling window.";
864 mesg[lines++] = "<B=l or L > Loads a file into the window.";
865 mesg[lines++] = "<B=s or S > Saves the contents of the window to a file.";
866 mesg[lines++] = "<B=Up Arrow > Scrolls up one line.";
867 mesg[lines++] = "<B=Down Arrow> Scrolls down one line.";
868 mesg[lines++] = "<B=Page Up > Scrolls back one page.";
869 mesg[lines++] = "<B=Page Down > Scrolls forward one page.";
870 mesg[lines++] = "<B=Tab or Esc> Returns to the command line.";
871 mesg[lines++] = "<B=? > Displays this help window.";
872 mesg[lines++] = "";
873 mesg[lines++] = "<C> (</B/24>Refer to the scrolling window online manual for more help<!B!24>.)";
874
875 /* Pop up the help message. */
876 popupLabel (ScreenOf(entry), mesg, lines);
877 }
878
879 /*
880 * This converts a word to upper case.
881 */
882 char *uc (char *word)
883 {
884 int length = strlen (word);
885 char *upper = (char *)malloc (sizeof (char *) * (length+2));
886 int x;
887
888 /* Start converting the case. */
889 for (x=0; x < length; x++)
890 {
891 int ch = (unsigned char)(word[x]);
892 if (isalpha (ch))
893 {
894 upper[x] = toupper(ch);
895 }
896 else
897 {
898 upper[x] = word[x];
899 }
900 }
901 upper[length] = '\0';
902 return upper;
903 }
904
905 /*
906 * The following two functions are the error and message handler callbacks.
907 * which will be called by Sybase when and error occurs.
908 */
909 int err_handler (DBPROCESS *dbProcess, DBINT mesgNumber, int mesgState, int severity, char *mesgText)
910 {
911 /* Declare local variables. */
912 char *mesg[10], temp[256];
913 int errorCount = 0;
914
915 /* Check if the process is dead. */
916 if ((dbProcess == 0) || (DBDEAD(dbProcess)))
917 {
918 mesg[0] = "</B/32>Database Process Error";
919 mesg[1] = "<C>The database process seems to have died.";
920 mesg[2] = "<C>Try logging in again with the </R>login<!R> command";
921 popupLabel (GPCdkScreen, mesg, 3);
922 return INT_EXIT;
923 }
924 else
925 {
926 mesg[0] = "</B/32>DB-Library Error";
927 sprintf (temp, "<C>%s", dberrstr);
928 mesg[1] = copyChar (temp);
929 errorCount = 2;
930 }
931
932 /* Display the message if we have an error. */
933 if (errorCount > 0)
934 {
935 popupLabel (GPCdkScreen, mesg, --errorCount);
936 }
937
938 /* Clean up. */
939 if (errorCount == 2)
940 {
941 freeChar (mesg[1]);
942 }
943 return (1);
944 }
945 int mesg_handler (DBPROCESS *dbProcess, DBINT mesgNumber, int mesgState, int severity, char *mesgText)
946 {
947 /* Declare local variables. */
948 char *mesg[10], temp[256];
949
950 /* Create the message. */
951 mesg[0] = "<C></B/16>SQL Server Message";
952 sprintf (temp, "</R>Message Number<!R> %ld", mesgNumber);
953 mesg[1] = copyChar (temp);
954 sprintf (temp, "</R>State <!R> %d", mesgState);
955 mesg[2] = copyChar (temp);
956 sprintf (temp, "</R>Severity <!R> %d", severity);
957 mesg[3] = copyChar (temp);
958 sprintf (temp, "</R>Message <!R> %s", mesgText);
959 mesg[4] = copyChar (temp);
960 popupLabel (GPCdkScreen, mesg, 5);
961
962 /* Clean up. */
963 freeChar (mesg[1]); freeChar (mesg[2]);
964 freeChar (mesg[3]); freeChar (mesg[4]);
965 return (1);
966 }
967
968 /*
969 * This is for the scrolling window help callback.
970 */
971 int swindowHelpCB (EObjectType cdktype, void *object, void *clientData, chtype key)
972 {
973 CDKENTRY *entry = (CDKENTRY *)clientData;
974 help(entry);
975 return (TRUE);
976 }
977
978 /*
979 * This is the callback for the down arrow.
980 */
981 int historyUpCB (EObjectType cdktype, void *object, void *clientData, chtype key)
982 {
983 CDKENTRY *entry = (CDKENTRY *)object;
984 struct history_st *history = (struct history_st *) clientData;
985
986 /* Make sure we don't go out of bounds. */
987 if (history->current == 0)
988 {
989 Beep();
990 return (TRUE);
991 }
992
993 /* Decrement the counter. */
994 history->current--;
995
996 /* Display the command. */
997 setCDKEntryValue (entry, history->cmd_history[history->current]);
998 drawCDKEntry (entry, ObjOf(entry)->box);
999 return (TRUE);
1000 }
1001
1002 /*
1003 * This is the callback for the down arrow.
1004 */
1005 int historyDownCB (EObjectType cdktype, void *object, void *clientData, chtype key)
1006 {
1007 CDKENTRY *entry = (CDKENTRY *)object;
1008 struct history_st *history = (struct history_st *) clientData;
1009
1010 /* Make sure we don't go out of bounds. */
1011 if (history->current == history->count)
1012 {
1013 Beep();
1014 return (TRUE);
1015 }
1016
1017 /* Increment the counter... */
1018 history->current++;
1019
1020 /* If we are at the end, clear the entry field. */
1021 if (history->current == history->count)
1022 {
1023 cleanCDKEntry (entry);
1024 drawCDKEntry (entry, ObjOf(entry)->box);
1025 return (TRUE);
1026 }
1027
1028 /* Display the command. */
1029 setCDKEntryValue (entry, history->cmd_history[history->current]);
1030 drawCDKEntry (entry, ObjOf(entry)->box);
1031 return (TRUE);
1032 }
1033
1034 /*
1035 * This callback allows the user to pick from the history list from a
1036 * scrolling list.
1037 */
1038 int listHistoryCB (EObjectType cdktype, void *object, void *clientData, chtype key)
1039 {
1040 CDKSCROLL *scrollList = 0;
1041 CDKENTRY *entry = (CDKENTRY *)object;
1042 struct history_st *history = (struct history_st *) clientData;
1043 int height = (history->count < 10 ? history->count+3 : 13);
1044 int selection;
1045
1046 /* No history, no list. */
1047 if (history->count == 0)
1048 {
1049 /* Popup a little window telling the user there are no commands. */
1050 char *mesg[] = {"<C></B/16>No Commands Entered", "<C>No History"};
1051 popupLabel (ScreenOf(entry), mesg, 2);
1052
1053 /* Redraw the screen. */
1054 eraseCDKEntry (entry);
1055 drawCDKScreen (ScreenOf(entry));
1056
1057 /* And leave... */
1058 return (TRUE);
1059 }
1060
1061 /* Create the scrolling list of previous commands. */
1062 scrollList = newCDKScroll (ScreenOf(entry), CENTER, CENTER, RIGHT,
1063 height, -10, "<C></B/29>Command History",
1064 history->cmd_history, history->count,
1065 NUMBERS, A_REVERSE, TRUE, FALSE);
1066
1067 /* Get the command to execute. */
1068 selection = activateCDKScroll (scrollList, 0);
1069 destroyCDKScroll (scrollList);
1070
1071 /* Check the results of the selection. */
1072 if (selection >= 0)
1073 {
1074 /* Get the command and stick it back in the entry field. */
1075 setCDKEntryValue (entry, history->cmd_history[selection]);
1076 }
1077
1078 /* Redraw the screen. */
1079 eraseCDKEntry (entry);
1080 drawCDKScreen (ScreenOf(entry));
1081 return (TRUE);
1082 }
1083
1084 /*
1085 * This loads the history into the editor from the RC file.
1086 */
1087 void loadHistory (struct history_st *history)
1088 {
1089 char *home = 0;
1090 char filename[1000];
1091
1092 /* Create the RC filename. */
1093 if ((home = getenv ("HOME")) == 0)
1094 {
1095 home = ".";
1096 }
1097 sprintf (filename, "%s/.sybrc", home);
1098
1099 /* Set some variables. */
1100 history->current = 0;
1101 history->count = 0;
1102
1103 /* Read the file. */
1104 if ((history->count = CDKreadFile (filename, &(history->cmd_history))) != -1)
1105 {
1106 history->current = history->count;
1107 }
1108 return;
1109 }
1110
1111 /*
1112 * This saves the history into RC file.
1113 */
1114 void saveHistory (struct history_st *history, int count)
1115 {
1116 FILE *fd = 0;
1117 char *home = 0;
1118 char filename[1000];
1119 int x;
1120
1121 /* Create the RC filename. */
1122 if ((home = getenv ("HOME")) == 0)
1123 {
1124 home = ".";
1125 }
1126 sprintf (filename, "%s/.sybrc", home);
1127
1128 /* Open the file for writing. */
1129 if ((fd = fopen (filename, "w")) == 0)
1130 {
1131 return;
1132 }
1133
1134 /* Start saving the history. */
1135 for (x=0; x < history->count; x++)
1136 {
1137 fprintf (fd, "%s\n", history->cmd_history[x]);
1138 }
1139 fclose (fd);
1140 return;
1141 }
0 /* $Id: vinstall.c,v 1.13 2005/12/27 12:36:06 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName="vinstall";
6 #endif
7
8 /*
9 * Written by: Mike Glover
10 * Purpose:
11 * This is a fairly basic install interface.
12 */
13
14 /* Declare global types and prototypes. */
15 static char *FPUsage = "-f filename [-s source directory] [-d destination directory] [-t title] [-o Output file] [-q]";
16
17 typedef enum {vCanNotOpenSource,
18 vCanNotOpenDest,
19 vOK
20 } ECopyFile;
21
22 static ECopyFile copyFile (CDKSCREEN *cdkScreen, char *src, char *dest);
23 static int verifyDirectory (CDKSCREEN *screen, char *directory);
24
25 int main (int argc, char **argv)
26 {
27 /* Declare variables. */
28 WINDOW *cursesWin = 0;
29 CDKSCREEN *cdkScreen = 0;
30 CDKSWINDOW *installOutput = 0;
31 CDKENTRY *sourceEntry = 0;
32 CDKENTRY *destEntry = 0;
33 CDKLABEL *titleWin = 0;
34 CDKHISTOGRAM *progressBar = 0;
35 char *sourcePath = 0;
36 char *destPath = 0;
37 char *sourceDir = 0;
38 char *destDir = 0;
39 char *filename = 0;
40 char *title = 0;
41 char *output = 0;
42 int quiet = FALSE;
43 int errors = 0;
44 int sWindowHeight = 0;
45 char *titleMessage[10], **fileList = 0, *mesg[20];
46 char oldPath[512], newPath[512], temp[2000];
47 char **files;
48 int count, chunks, ret, x;
49
50 /* Parse up the command line. */
51 while (1)
52 {
53 ret = getopt (argc, argv, "d:s:f:t:o:q");
54 if (ret == -1)
55 {
56 break;
57 }
58 switch (ret)
59 {
60 case 's' :
61 sourcePath = strdup (optarg);
62 break;
63
64 case 'd' :
65 destPath = strdup (optarg);
66 break;
67
68 case 'f' :
69 filename = strdup (optarg);
70 break;
71
72 case 't' :
73 title = strdup (optarg);
74 break;
75
76 case 'o' :
77 output = strdup (optarg);
78 break;
79
80 case 'q' :
81 quiet = TRUE;
82 break;
83 }
84 }
85
86 /* Make sure have everything we need. */
87 if (filename == 0)
88 {
89 fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
90 ExitProgram (EXIT_FAILURE);
91 }
92
93 /* Open the file list file and read it in. */
94 count = CDKreadFile (filename, &fileList);
95 if (count == 0)
96 {
97 fprintf (stderr, "%s: Input filename <%s> is empty.\n", argv[0], filename);
98 ExitProgram (EXIT_FAILURE);
99 }
100
101 /*
102 * Cycle through what was given to us and save it.
103 */
104 for (x=0; x < count; x++)
105 {
106 /* Strip white space from the line. */
107 stripWhiteSpace (vBOTH, fileList[x]);
108 }
109
110 /* Set up CDK. */
111 cursesWin = initscr();
112 cdkScreen = initCDKScreen (cursesWin);
113
114 /* Start color. */
115 initCDKColor();
116
117 /* Create the title label. */
118 titleMessage[0] = "<C></32/B><#HL(30)>";
119 if (title == 0)
120 {
121 sprintf (temp, "<C></32/B>CDK Installer");
122 }
123 else
124 {
125 sprintf (temp, "<C></32/B>%.256s", title);
126 }
127 titleMessage[1] = copyChar (temp);
128 titleMessage[2] = "<C></32/B><#HL(30)>";
129 titleWin = newCDKLabel (cdkScreen, CENTER, TOP,
130 titleMessage, 3, FALSE, FALSE);
131 freeChar (titleMessage[1]);
132
133 /* Allow them to change the install directory. */
134 if (sourcePath == 0)
135 {
136 sourceEntry = newCDKEntry (cdkScreen, CENTER, 8,
137 0, "Source Directory :",
138 A_NORMAL, '.', vMIXED,
139 40, 0, 256, TRUE, FALSE);
140 }
141 if (destPath == 0)
142 {
143 destEntry = newCDKEntry (cdkScreen, CENTER, 11,
144 0, "Destination Directory:", A_NORMAL,
145 '.', vMIXED, 40, 0, 256, TRUE, FALSE);
146 }
147
148 /* Get the source install path. */
149 if (sourceEntry != 0)
150 {
151 drawCDKScreen (cdkScreen);
152 sourceDir = copyChar (activateCDKEntry (sourceEntry, 0));
153 }
154 else
155 {
156 sourceDir = copyChar (sourcePath);
157 }
158
159 /* Get the destination install path. */
160 if (destEntry != 0)
161 {
162 drawCDKScreen (cdkScreen);
163 destDir = copyChar (activateCDKEntry (destEntry, 0));
164 }
165 else
166 {
167 destDir = copyChar (destPath);
168 }
169
170 /* Destroy the path entry fields. */
171 if (sourceEntry != 0)
172 {
173 destroyCDKEntry (sourceEntry);
174 }
175 if (destEntry != 0)
176 {
177 destroyCDKEntry (destEntry);
178 }
179
180 /*
181 * Verify that the source directory is valid.
182 */
183 if (verifyDirectory (cdkScreen, sourceDir) != 0)
184 {
185 /* Clean up and leave. */
186 freeChar (destDir);
187 freeChar (sourceDir);
188 destroyCDKLabel (titleWin);
189 destroyCDKScreen (cdkScreen);
190 endCDK();
191 ExitProgram (EXIT_FAILURE);
192 }
193
194 /*
195 * Verify that the source directory is valid.
196 */
197 if (verifyDirectory (cdkScreen, destDir) != 0)
198 {
199 /* Clean up and leave. */
200 freeChar (destDir);
201 freeChar (sourceDir);
202 destroyCDKLabel (titleWin);
203 destroyCDKScreen (cdkScreen);
204 endCDK();
205 ExitProgram (EXIT_FAILURE);
206 }
207
208 /* Create the histogram. */
209 progressBar = newCDKHistogram (cdkScreen, CENTER, 5,
210 3, 0, HORIZONTAL,
211 "<C></56/B>Install Progress",
212 TRUE, FALSE);
213
214 /* Set the top left/right characters of the histogram.*/
215 setCDKHistogramLLChar (progressBar, ACS_LTEE);
216 setCDKHistogramLRChar (progressBar, ACS_RTEE);
217
218 /* Set the initial value of the histogram. */
219 setCDKHistogram (progressBar, vPERCENT, TOP, A_BOLD,
220 1, count, 1,
221 COLOR_PAIR (24) | A_REVERSE | ' ',
222 TRUE);
223
224 /* Determine the height of the scrolling window. */
225 if (LINES >= 16)
226 {
227 sWindowHeight = LINES - 13;
228 }
229 else
230 {
231 sWindowHeight = 3;
232 }
233
234 /* Create the scrolling window. */
235 installOutput = newCDKSwindow (cdkScreen, CENTER, BOTTOM,
236 sWindowHeight, 0,
237 "<C></56/B>Install Results",
238 2000, TRUE, FALSE);
239
240 /* Set the top left/right characters of the scrolling window.*/
241 setCDKSwindowULChar (installOutput, ACS_LTEE);
242 setCDKSwindowURChar (installOutput, ACS_RTEE);
243
244 /* Draw the screen. */
245 drawCDKScreen (cdkScreen);
246
247 /* Start copying the files. */
248 for (x=0; x < count; x++)
249 {
250 /*
251 * If the 'file' list file has 2 columns, the first is
252 * the source filename, the second being the destination
253 * filename.
254 */
255 files = CDKsplitString (fileList[x], ' ');
256 chunks = CDKcountStrings (files);
257 if (chunks == 2)
258 {
259 /* Create the correct paths. */
260 sprintf (oldPath, "%s/%s", sourceDir, files[0]);
261 sprintf (newPath, "%s/%s", destDir, files[1]);
262 }
263 else
264 {
265 /* Create the correct paths. */
266 sprintf (oldPath, "%s/%s", sourceDir, fileList[x]);
267 sprintf (newPath, "%s/%s", destDir, fileList[x]);
268 }
269 CDKfreeStrings(files);
270
271 /* Copy the file from the source to the destination. */
272 ret = copyFile (cdkScreen, oldPath, newPath);
273 if (ret == vCanNotOpenSource)
274 {
275 sprintf (temp, "</16>Error: Can not open source file \"%.256s\"<!16>", oldPath);
276 errors++;
277 }
278 else if (ret == vCanNotOpenDest)
279 {
280 sprintf (temp, "</16>Error: Can not open destination file \"%.256s\"<!16>", newPath);
281 errors++;
282 }
283 else
284 {
285 sprintf (temp, "</24>%.256s -> %.256s", oldPath, newPath);
286 }
287
288 /* Add the message to the scrolling window. */
289 addCDKSwindow (installOutput, temp, BOTTOM);
290 drawCDKSwindow (installOutput, ObjOf(installOutput)->box);
291
292 /* Update the histogram. */
293 setCDKHistogram (progressBar, vPERCENT, TOP, A_BOLD,
294 1, count, x+1,
295 COLOR_PAIR (24) | A_REVERSE | ' ',
296 TRUE);
297
298 /* Update the screen. */
299 drawCDKHistogram (progressBar, TRUE);
300 }
301
302 /*
303 * If there were errors, inform the user and allow them to look at the
304 * errors in the scrolling window.
305 */
306 if (errors != 0)
307 {
308 /* Create the information for the dialog box. */
309 char *buttons[] = {"Look At Errors Now", "Save Output To A File", "Ignore Errors"};
310 mesg[0] = "<C>There were errors in the installation.";
311 mesg[1] = "<C>If you want, you may scroll through the";
312 mesg[2] = "<C>messages of the scrolling window to see";
313 mesg[3] = "<C>what the errors were. If you want to save";
314 mesg[4] = "<C>the output of the window you may press </R>s<!R>";
315 mesg[5] = "<C>while in the window, or you may save the output";
316 mesg[6] = "<C>of the install now and look at the install";
317 mesg[7] = "<C>history at a later date.";
318
319 /* Popup the dialog box. */
320 ret = popupDialog (cdkScreen, mesg, 8, buttons, 3);
321 if (ret == 0)
322 {
323 activateCDKSwindow (installOutput, 0);
324 }
325 else if (ret == 1)
326 {
327 injectCDKSwindow (installOutput, 's');
328 }
329 }
330 else
331 {
332 /*
333 * If they specified the name of an output file, then save the
334 * results of the installation to that file.
335 */
336 if (output != 0)
337 {
338 dumpCDKSwindow (installOutput, output);
339 }
340 else
341 {
342 /* Ask them if they want to save the output of the scrolling window. */
343 if (quiet == FALSE)
344 {
345 char *buttons[] = {"No", "Yes"};
346 mesg[0] = "<C>Do you want to save the output of the";
347 mesg[1] = "<C>scrolling window to a file?";
348
349 if (popupDialog (cdkScreen, mesg, 2, buttons, 2) == 1)
350 {
351 injectCDKSwindow (installOutput, 's');
352 }
353 }
354 }
355 }
356
357 /* Clean up. */
358 destroyCDKLabel (titleWin);
359 destroyCDKHistogram (progressBar);
360 destroyCDKSwindow (installOutput);
361 destroyCDKScreen (cdkScreen);
362 endCDK();
363 ExitProgram (EXIT_SUCCESS);
364 }
365
366 /*
367 * This copies a file from one place to another. (tried rename
368 * library call, but it is equivalent to mv)
369 */
370 static ECopyFile copyFile (CDKSCREEN *cdkScreen GCC_UNUSED, char *src, char *dest)
371 {
372 char command[2000];
373 FILE *fd;
374
375 /* Make sure we can open the source file. */
376 if ((fd = fopen (src, "r")) == 0)
377 {
378 return vCanNotOpenSource;
379 }
380 fclose (fd);
381
382 /*
383 * Remove the destination file first, just in case it already exists.
384 * This allows us to check if we can write to the desintation file.
385 */
386 sprintf (command, "rm -f %s", dest);
387 system (command);
388
389 /* Try to open the destination. */
390 if ((fd = fopen (dest, "w")) == 0)
391 {
392 return vCanNotOpenDest;
393 }
394 fclose (fd);
395
396 /*
397 * Copy the file. There has to be a better way to do this. I
398 * tried rename and link but they both have the same limitation
399 * as the 'mv' command that you can not move across partitions.
400 * Quite limiting in an install binary.
401 */
402 sprintf (command, "rm -f %s; cp %s %s; chmod 444 %s", dest, src, dest, dest);
403 system (command);
404 return vOK;
405 }
406
407 /*
408 * This makes sure that the directory given exists. If it
409 * doesn't then it will make it.
410 * THINK
411 */
412 static int verifyDirectory (CDKSCREEN *cdkScreen, char *directory)
413 {
414 char *buttons[] = {"Yes", "No"};
415 int status = 0;
416 mode_t dirMode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH;
417 struct stat fileStat;
418 char *mesg[10];
419 char *error[10];
420 char temp[512];
421
422 /* Stat the directory. */
423 if (lstat (directory, &fileStat) != 0)
424 {
425 /* The directory does not exist. */
426 if (errno == ENOENT)
427 {
428 /* Create the question. */
429 mesg[0] = "<C>The directory ";
430 sprintf (temp, "<C>%.256s", directory);
431 mesg[1] = copyChar (temp);
432 mesg[2] = "<C>Does not exist. Do you want to";
433 mesg[3] = "<C>create it?";
434
435 /* Ask them if they want to create the directory. */
436 if (popupDialog (cdkScreen, mesg, 4, buttons, 2) == 0)
437 {
438 /* Create the directory. */
439 if (mkdir (directory, dirMode) != 0)
440 {
441 /* Create the error message. */
442 error[0] = "<C>Could not create the directory";
443 sprintf (temp, "<C>%.256s", directory);
444 error[1] = copyChar (temp);
445
446 #ifdef HAVE_STRERROR
447 sprintf (temp, "<C>%.256s", strerror (errno));
448 #else
449 sprintf (temp, "<C>Check the permissions and try again.");
450 #endif
451 error[2] = copyChar (temp);
452
453 /* Pop up the error message. */
454 popupLabel (cdkScreen, error, 3);
455
456 /* Clean up and set the error status. */
457 freeChar (error[1]);
458 freeChar (error[2]);
459 status = -1;
460 }
461 }
462 else
463 {
464 /* Create the message. */
465 error[0] = "<C>Installation aborted.";
466
467 /* Pop up the error message. */
468 popupLabel (cdkScreen, error, 1);
469
470 /* Set the exit status. */
471 status = -1;
472 }
473
474 /* Clean up. */
475 freeChar (mesg[1]);
476 }
477 }
478 return status;
479 }
+0
-128
demos/workman less more
0 #!/usr/bin/perl -w
1 # $Id: workman,v 1.2 2002/07/27 20:07:47 tom Exp $
2
3 #
4 # Initialize Cdk.
5 #
6 use Cdk;
7 Cdk::init();
8
9 # Pop up the opening label.
10 popupLabel (["<C></16/B>Workman Database Editor.", "",
11 "<C></24/B>Written By Mike Glover"]);
12
13 # Set a default name for the workman database.
14 my $workmandb = $ENV{'HOME'} . "/.workmandb";
15
16 # Open up the database and read in the contents.
17 my @cdList = readWorkmanDatabase ($workmandb);
18
19 # Let the user play with the given information.
20 playWithWorkManDatabase (@cdList);
21
22 #
23 # This allows the user to manipulate the workman database.
24 #
25 sub playWithWorkManDatabase
26 {
27 }
28
29 #
30 # This reads in the current contents of the workman database.
31 #
32 sub readWorkmanDatabase
33 {
34 my $filename = shift;
35 my @contents = ();
36 my $count = 0;
37 my $x = 0;
38
39 # Return if we can't open the file.
40 return if !(open (FILE, $filename));
41
42 # Slurp in the file.
43 my @workmandb = <FILE>;
44 chomp @workmandb;
45
46 # Strip out the contents of the database.
47 for ($x=0; $x < $#workmandb; $x++)
48 {
49 # Remove comments and empty lines.
50 next if $workmandb[$x] =~ /^#/;
51 next if $workmandb[$x] =~ /^$/;
52
53 # Is this a start of a CD listing.
54 if ($workmandb[$x] =~ /^tracks (\d*)/)
55 {
56 my $trackCount = $1;
57 my $trackLine = $workmandb[$x++];
58 my $cdName = $workmandb[$x++];
59 my $artist = $workmandb[$x++];
60 my @tracks = ();
61 my $current = 0;
62
63 # Get each track from the database.
64 for ($current=0; $current < $trackCount; $current++)
65 {
66 push (@tracks, $workmandb[$x++]);
67 }
68 $x--;
69
70 # Create the database object and put it onto the stack.
71 my $object = new WorkManData ($trackLine, $cdName, $artist, @tracks);
72
73 # Put it onto the stack.
74 push (@contents, $object);
75 }
76 }
77 return @contents;
78 }
79
80 #
81 # This writes out a workman database.
82 #
83 sub writeWorkManData
84 {
85 }
86
87 #########################################
88 package WorkManData;
89
90 #
91 # This creates a new object.
92 #
93 sub new
94 {
95 my ($type, $trackLine, $cdName, $artist, @tracks) = @_;
96 my @trackInfo = ();
97 my @indexInfo = ();
98 my $self = {};
99
100 # Split the trackline apart.
101 my ($junk, $trackCount, @index) = split (/\s+/, $trackLine);
102
103 # Clean off the garbage from the track lines.
104 for ($x=0; $x <= $#tracks; $x++)
105 {
106 # Strip out the track name.
107 ($trackName = $1) if $tracks[$x] =~ /^track\s+(.*)/;
108
109 # If there is no track name, then provide a default answer.
110 if ($trackName ne "")
111 {
112 push (@trackInfo, $trackName);
113 }
114 else
115 {
116 push (@trackInfo, "No Track Name Given");
117 }
118 }
119
120 # Store the info in the object.
121 ($self->{'Artist'} = $1) if $artist =~ /^artist\s+(.*)/;
122 ($self->{'CDName'} = $1) if $cdName =~ /^cdname\s+(.*)/;
123 $self->{'Tracks'} = \@trackInfo;
124 $self->{'Index'} = \@indexInfo;
125
126 return bless $self;
127 }
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:44 $
5 * $Revision: 1.95 $
6 */
7
8 DeclareCDKObjects(DIALOG, Dialog, setCdk, Int);
9
10 /*
11 * This function creates a dialog widget.
12 */
13 CDKDIALOG *newCDKDialog (CDKSCREEN *cdkscreen, int xplace, int yplace, char **mesg, int rows, char **buttonLabel, int buttonCount, chtype highlight, boolean separator, boolean Box, boolean shadow)
14 {
15 CDKDIALOG *dialog = 0;
16 int boxHeight;
17 int boxWidth = MIN_DIALOG_WIDTH;
18 int maxmessagewidth = -1;
19 int buttonwidth = 0;
20 int xpos = xplace;
21 int ypos = yplace;
22 int temp = 0;
23 int buttonadj = 0;
24 int x = 0;
25
26 if (rows <= 0
27 || buttonCount <= 0
28 || (dialog = newCDKObject(CDKDIALOG, &my_funcs)) == 0
29 || (dialog->info = typeCallocN(chtype *, rows + 1)) == 0
30 || (dialog->infoLen = typeCallocN(int, rows + 1)) == 0
31 || (dialog->infoPos = typeCallocN(int, rows + 1)) == 0
32 || (dialog->buttonLabel = typeCallocN(chtype *, buttonCount + 1)) == 0
33 || (dialog->buttonLen = typeCallocN(int, buttonCount + 1)) == 0
34 || (dialog->buttonPos = typeCallocN(int, buttonCount + 1)) == 0)
35 {
36 destroyCDKObject (dialog);
37 return (0);
38 }
39
40 setCDKDialogBox (dialog, Box);
41 boxHeight = rows + 2 * BorderOf(dialog) + separator + 1;
42
43 /* Translate the char * message to a chtype * */
44 for (x=0; x < rows; x++)
45 {
46 dialog->info[x] = char2Chtype (mesg[x], &dialog->infoLen[x], &dialog->infoPos[x]);
47 maxmessagewidth = MAXIMUM(maxmessagewidth, dialog->infoLen[x]);
48 }
49
50 /* Translate the button label char * to a chtype * */
51 for (x = 0; x < buttonCount; x++)
52 {
53 dialog->buttonLabel[x] = char2Chtype (buttonLabel[x], &dialog->buttonLen[x], &temp);
54 buttonwidth += dialog->buttonLen[x] + 1;
55 }
56 buttonwidth--;
57
58 /* Determine the final dimensions of the box. */
59 boxWidth = MAXIMUM(boxWidth, maxmessagewidth);
60 boxWidth = MAXIMUM(boxWidth, buttonwidth);
61 boxWidth = boxWidth + 2 + 2 * BorderOf(dialog);
62
63 /* Now we have to readjust the x and y positions. */
64 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
65
66 /* Set up the dialog box attributes. */
67 ScreenOf(dialog) = cdkscreen;
68 dialog->parent = cdkscreen->window;
69 dialog->win = newwin (boxHeight, boxWidth, ypos, xpos);
70 dialog->shadowWin = 0;
71 dialog->buttonCount = buttonCount;
72 dialog->currentButton = 0;
73 dialog->messageRows = rows;
74 dialog->boxHeight = boxHeight;
75 dialog->boxWidth = boxWidth;
76 dialog->highlight = highlight;
77 dialog->separator = separator;
78 initExitType(dialog);
79 ObjOf(dialog)->acceptsFocus = TRUE;
80 ObjOf(dialog)->inputWindow = dialog->win;
81 dialog->shadow = shadow;
82
83 /* If we couldn't create the window, we should return a null value. */
84 if (dialog->win == 0)
85 {
86 destroyCDKObject (dialog);
87 return (0);
88 }
89 keypad (dialog->win, TRUE);
90
91 /* Find the button positions. */
92 buttonadj = ((int)((boxWidth-buttonwidth)/2));
93 for (x = 0; x < buttonCount; x++)
94 {
95 dialog->buttonPos[x] = buttonadj;
96 buttonadj = buttonadj + dialog->buttonLen[x] + BorderOf(dialog);
97 }
98
99 /* Create the string alignments. */
100 for (x=0; x < rows; x++)
101 {
102 dialog->infoPos[x] = justifyString (boxWidth - 2 * BorderOf(dialog), dialog->infoLen[x], dialog->infoPos[x]);
103 }
104
105 /* Was there a shadow? */
106 if (shadow)
107 {
108 dialog->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
109 }
110
111 /* Register this baby. */
112 registerCDKObject (cdkscreen, vDIALOG, dialog);
113
114 /* Return the dialog box pointer. */
115 return (dialog);
116 }
117
118 /*
119 * This lets the user select the button.
120 */
121 int activateCDKDialog (CDKDIALOG *dialog, chtype *actions)
122 {
123 chtype input = 0;
124 boolean functionKey;
125 int ret;
126
127 /* Draw the dialog box. */
128 drawCDKDialog (dialog, ObjOf(dialog)->box);
129
130 /* Lets move to the first button. */
131 writeChtypeAttrib (dialog->win,
132 dialog->buttonPos[dialog->currentButton],
133 dialog->boxHeight - 1 - BorderOf(dialog),
134 dialog->buttonLabel[dialog->currentButton],
135 dialog->highlight,
136 HORIZONTAL,
137 0, dialog->buttonLen[dialog->currentButton]);
138 wrefresh (dialog->win);
139
140 if (actions == 0)
141 {
142 for (;;)
143 {
144 input = getchCDKObject (ObjOf(dialog), &functionKey);
145
146 /* Inject the character into the widget. */
147 ret = injectCDKDialog (dialog, input);
148 if (dialog->exitType != vEARLY_EXIT)
149 {
150 return ret;
151 }
152 }
153 }
154 else
155 {
156 int length = chlen (actions);
157 int x = 0;
158
159 /* Inject each character one at a time. */
160 for (x=0; x < length; x++)
161 {
162 ret = injectCDKDialog (dialog, actions[x]);
163 if (dialog->exitType != vEARLY_EXIT)
164 {
165 return ret;
166 }
167 }
168 }
169
170 /* Set the exit type and exit. */
171 setExitType(dialog, 0);
172 return -1;
173 }
174
175 /*
176 * This injects a single character into the dialog widget.
177 */
178 static int _injectCDKDialog (CDKOBJS *object, chtype input)
179 {
180 CDKDIALOG *dialog = (CDKDIALOG *)object;
181 int firstButton = 0;
182 int lastButton = dialog->buttonCount - 1;
183 int ppReturn = 1;
184 int ret = unknownInt;
185 bool complete = FALSE;
186
187 /* Set the exit type. */
188 setExitType(dialog, 0);
189
190 /* Check if there is a pre-process function to be called. */
191 if (PreProcessFuncOf(dialog) != 0)
192 {
193 ppReturn = PreProcessFuncOf(dialog) (vDIALOG, dialog, PreProcessDataOf(dialog), input);
194 }
195
196 /* Should we continue? */
197 if (ppReturn != 0)
198 {
199 /* Check for a key binding. */
200 if (checkCDKObjectBind (vDIALOG, dialog, input) != 0)
201 {
202 checkEarlyExit(dialog);
203 complete = TRUE;
204 }
205 else
206 {
207 switch (input)
208 {
209 case KEY_LEFT : case KEY_BTAB : case KEY_BACKSPACE :
210 if (dialog->currentButton == firstButton)
211 {
212 dialog->currentButton = lastButton;;
213 }
214 else
215 {
216 dialog->currentButton--;
217 }
218 break;
219
220 case KEY_RIGHT : case KEY_TAB : case SPACE :
221 if (dialog->currentButton == lastButton)
222 {
223 dialog->currentButton = firstButton;
224 }
225 else
226 {
227 dialog->currentButton++;
228 }
229 break;
230
231 case KEY_UP : case KEY_DOWN :
232 Beep();
233 break;
234
235 case CDK_REFRESH :
236 eraseCDKScreen (ScreenOf(dialog));
237 refreshCDKScreen (ScreenOf(dialog));
238 break;
239
240 case KEY_ESC :
241 setExitType(dialog, input);
242 complete = TRUE;
243 break;
244
245 case KEY_ENTER :
246 setExitType(dialog, input);
247 ret = dialog->currentButton;
248 complete = TRUE;
249 break;
250
251 default :
252 break;
253 }
254 }
255
256 /* Should we call a post-process? */
257 if (!complete && (PostProcessFuncOf(dialog) != 0))
258 {
259 PostProcessFuncOf(dialog) (vDIALOG, dialog, PostProcessDataOf(dialog), input);
260 }
261 }
262
263 if (!complete) {
264 drawCDKDialogButtons (dialog);
265 wrefresh (dialog->win);
266 setExitType(dialog, 0);
267 }
268
269 ResultOf(dialog).valueInt = ret;
270 return (ret != unknownInt);
271 }
272
273 /*
274 * This moves the dialog field to the given location.
275 */
276 static void _moveCDKDialog (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag)
277 {
278 CDKDIALOG *dialog = (CDKDIALOG *)object;
279 int currentX = getbegx(dialog->win);
280 int currentY = getbegy(dialog->win);
281 int xpos = xplace;
282 int ypos = yplace;
283 int xdiff = 0;
284 int ydiff = 0;
285
286 /*
287 * If this is a relative move, then we will adjust where we want
288 * to move to.
289 */
290 if (relative)
291 {
292 xpos = getbegx(dialog->win) + xplace;
293 ypos = getbegy(dialog->win) + yplace;
294 }
295
296 /* Adjust the window if we need to. */
297 alignxy (WindowOf(dialog), &xpos, &ypos, dialog->boxWidth, dialog->boxHeight);
298
299 /* Get the difference. */
300 xdiff = currentX - xpos;
301 ydiff = currentY - ypos;
302
303 /* Move the window to the new location. */
304 moveCursesWindow(dialog->win, -xdiff, -ydiff);
305 moveCursesWindow(dialog->shadowWin, -xdiff, -ydiff);
306
307 /* Touch the windows so they 'move'. */
308 refreshCDKWindow (WindowOf(dialog));
309
310 /* Redraw the window, if they asked for it. */
311 if (refresh_flag)
312 {
313 drawCDKDialog (dialog, ObjOf(dialog)->box);
314 }
315 }
316
317 /*
318 * This function draws the dialog widget.
319 */
320 static void _drawCDKDialog (CDKOBJS *object, boolean Box)
321 {
322 CDKDIALOG *dialog = (CDKDIALOG *)object;
323 int x = 0;
324
325 /* Is there a shadow? */
326 if (dialog->shadowWin != 0)
327 {
328 drawShadow (dialog->shadowWin);
329 }
330
331 /* Box the widget if they asked. */
332 if (Box)
333 {
334 drawObjBox (dialog->win, ObjOf(dialog));
335 }
336
337 /* Draw in the message. */
338 for (x=0; x < dialog->messageRows; x++)
339 {
340 writeChtype (dialog->win,
341 dialog->infoPos[x] + BorderOf(dialog), x + BorderOf(dialog),
342 dialog->info[x],
343 HORIZONTAL, 0,
344 dialog->infoLen[x]);
345 }
346
347 /* Draw in the buttons. */
348 drawCDKDialogButtons (dialog);
349
350 wrefresh (dialog->win);
351 }
352
353 /*
354 * This function destroys the dialog widget.
355 */
356 static void _destroyCDKDialog (CDKOBJS *object)
357 {
358 if (object != 0)
359 {
360 CDKDIALOG *dialog = (CDKDIALOG *)object;
361
362 CDKfreeChtypes (dialog->info);
363 freeChecked (dialog->infoLen);
364 freeChecked (dialog->infoPos);
365
366 CDKfreeChtypes (dialog->buttonLabel);
367 freeChecked (dialog->buttonLen);
368 freeChecked (dialog->buttonPos);
369
370 /* Clean up the windows. */
371 deleteCursesWindow (dialog->win);
372 deleteCursesWindow (dialog->shadowWin);
373
374 /* Clean the key bindings. */
375 cleanCDKObjectBindings (vDIALOG, dialog);
376
377 /* Unregister this object. */
378 unregisterCDKObject (vDIALOG, dialog);
379 }
380 }
381
382 /*
383 * This function erases the dialog widget from the screen.
384 */
385 static void _eraseCDKDialog (CDKOBJS *object)
386 {
387 if (validCDKObject (object))
388 {
389 CDKDIALOG *dialog = (CDKDIALOG *)object;
390
391 eraseCursesWindow (dialog->win);
392 eraseCursesWindow (dialog->shadowWin);
393 }
394 }
395
396 /*
397 * This sets attributes of the dialog box.
398 */
399 void setCDKDialog (CDKDIALOG *dialog, chtype highlight, boolean separator, boolean Box)
400 {
401 setCDKDialogHighlight (dialog, highlight);
402 setCDKDialogSeparator (dialog, separator);
403 setCDKDialogBox (dialog, Box);
404 }
405
406 /*
407 * This sets the highlight attribute for the buttons.
408 */
409 void setCDKDialogHighlight (CDKDIALOG *dialog, chtype highlight)
410 {
411 dialog->highlight = highlight;
412 }
413 chtype getCDKDialogHighlight (CDKDIALOG *dialog)
414 {
415 return dialog->highlight;
416 }
417
418 /*
419 * This sets whether or not the dialog box will have a separator line.
420 */
421 void setCDKDialogSeparator (CDKDIALOG *dialog, boolean separator)
422 {
423 dialog->separator = separator;
424 }
425 boolean getCDKDialogSeparator (CDKDIALOG *dialog)
426 {
427 return dialog->separator;
428 }
429
430 /*
431 * This sets the box attribute of the widget.
432 */
433 void setCDKDialogBox (CDKDIALOG *dialog, boolean Box)
434 {
435 ObjOf(dialog)->box = Box;
436 ObjOf(dialog)->borderSize = Box ? 1 : 0;
437 }
438 boolean getCDKDialogBox (CDKDIALOG *dialog)
439 {
440 return ObjOf(dialog)->box;
441 }
442
443 /*
444 * This sets the background attribute of the widget.
445 */
446 static void _setBKattrDialog (CDKOBJS *object, chtype attrib)
447 {
448 if (object != 0)
449 {
450 CDKDIALOG *widget = (CDKDIALOG *) object;
451
452 wbkgd (widget->win, attrib);
453 }
454 }
455
456 /*
457 * This draws the dialog buttons and the separation line.
458 */
459 void drawCDKDialogButtons (CDKDIALOG *dialog)
460 {
461 int x;
462
463 for (x=0; x < dialog->buttonCount; x++)
464 {
465 writeChtype (dialog->win,
466 dialog->buttonPos[x],
467 dialog->boxHeight - 1 - BorderOf(dialog),
468 dialog->buttonLabel[x],
469 HORIZONTAL, 0,
470 dialog->buttonLen[x]);
471 }
472
473 /* Draw the separation line. */
474 if (dialog->separator)
475 {
476 chtype boxattr = BXAttrOf(dialog);
477
478 for (x=1; x < dialog->boxWidth-1; x++)
479 {
480 mvwaddch (dialog->win, dialog->boxHeight - 2 - BorderOf(dialog), x, ACS_HLINE | boxattr);
481 }
482 mvwaddch (dialog->win, dialog->boxHeight - 2 - BorderOf(dialog), 0, ACS_LTEE | boxattr);
483 mvwaddch (dialog->win, dialog->boxHeight - 2 - BorderOf(dialog), getmaxx(dialog->win)-1, ACS_RTEE | boxattr);
484 }
485 writeChtypeAttrib (dialog->win,
486 dialog->buttonPos[dialog->currentButton],
487 dialog->boxHeight - 1 - BorderOf(dialog),
488 dialog->buttonLabel[dialog->currentButton],
489 dialog->highlight,
490 HORIZONTAL, 0,
491 dialog->buttonLen[dialog->currentButton]);
492
493 }
494
495 static void _focusCDKDialog(CDKOBJS *object)
496 {
497 CDKDIALOG *widget = (CDKDIALOG *)object;
498
499 drawCDKDialog (widget, ObjOf(widget)->box);
500 }
501
502 static void _unfocusCDKDialog(CDKOBJS *object)
503 {
504 CDKDIALOG *widget = (CDKDIALOG *)object;
505
506 drawCDKDialog (widget, ObjOf(widget)->box);
507 }
508
509 dummyRefreshData(Dialog)
510
511 dummySaveData(Dialog)
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2004/11/07 23:36:55 $
5 * $Revision: 1.58 $
6 */
7
8 /*
9 * This sets up a basic set of color pairs. These can be redefined
10 * if wanted...
11 */
12 void initCDKColor (void)
13 {
14 #ifdef HAVE_START_COLOR
15 int color[] = {
16 COLOR_WHITE, COLOR_RED, COLOR_GREEN,
17 COLOR_YELLOW, COLOR_BLUE, COLOR_MAGENTA,
18 COLOR_CYAN, COLOR_BLACK
19 };
20 int pair = 1;
21 int fg, bg;
22 int limit;
23
24 if (has_colors()) {
25 start_color();
26
27 limit = (COLORS < 8) ? COLORS : 8;
28
29 /* Create the color pairs. */
30 for (fg=0; fg < limit; fg++)
31 {
32 for (bg=0; bg < limit; bg++)
33 {
34 init_pair (pair++, color[fg], color[bg]);
35 }
36 }
37 }
38 #endif
39 }
40
41 /*
42 * This prints out a box around a window with attributes
43 */
44 void boxWindow (WINDOW *window, chtype attr)
45 {
46 /* Set some variables. */
47 int tlx = 0;
48 int tly = 0;
49 int brx = getmaxx(window) - 1;
50 int bry = getmaxy(window) - 1;
51
52 /* Draw horizontal lines. */
53 mvwhline(window, tly, 0, ACS_HLINE | attr, getmaxx(window));
54 mvwhline(window, bry, 0, ACS_HLINE | attr, getmaxx(window));
55
56 /* Draw vertical lines. */
57 mvwvline(window, 0, tlx, ACS_VLINE | attr, getmaxy(window));
58 mvwvline(window, 0, brx, ACS_VLINE | attr, getmaxy(window));
59
60 /* Draw in the corners. */
61 mvwaddch (window, tly, tlx, ACS_ULCORNER | attr);
62 mvwaddch (window, tly, brx, ACS_URCORNER | attr);
63 mvwaddch (window, bry, tlx, ACS_LLCORNER | attr);
64 mvwaddch (window, bry, brx, ACS_LRCORNER | attr);
65 wrefresh (window);
66 }
67
68 /*
69 * This draws a box with attributes and lets the user define
70 * each element of the box.
71 */
72 void attrbox (WINDOW *win, chtype tlc, chtype trc, chtype blc, chtype brc, chtype horz, chtype vert, chtype attr)
73 {
74 /* Set the coordinates. */
75 int x1 = 0;
76 int y1 = 0;
77 int y2 = getmaxy(win) - 1;
78 int x2 = getmaxx(win) - 1;
79 int count = 0;
80
81 /* Draw horizontal lines. */
82 if (horz != 0)
83 {
84 mvwhline(win, y1, 0, horz | attr, getmaxx(win));
85 mvwhline(win, y2, 0, horz | attr, getmaxx(win));
86 count++;
87 }
88
89 /* Draw vertical lines. */
90 if (vert != 0)
91 {
92 mvwvline(win, 0, x1, vert | attr, getmaxy(win));
93 mvwvline(win, 0, x2, vert | attr, getmaxy(win));
94 count++;
95 }
96
97 /* Draw in the corners. */
98 if (tlc != 0)
99 {
100 mvwaddch (win, y1, x1, tlc | attr);
101 count++;
102 }
103 if (trc != 0)
104 {
105 mvwaddch (win, y1, x2, trc | attr);
106 count++;
107 }
108 if (blc != 0)
109 {
110 mvwaddch (win, y2, x1, blc | attr);
111 count++;
112 }
113 if (brc != 0)
114 {
115 mvwaddch (win, y2, x2, brc | attr);
116 count++;
117 }
118 if (count != 0)
119 {
120 wrefresh (win);
121 }
122 }
123
124 /*
125 * Draw a box around the given window using the object's defined line-drawing
126 * characters.
127 */
128 void drawObjBox (WINDOW *win, CDKOBJS *object)
129 {
130 attrbox (win,
131 object->ULChar,
132 object->URChar,
133 object->LLChar,
134 object->LRChar,
135 object->HZChar,
136 object->VTChar,
137 object->BXAttr);
138 }
139
140 /*
141 * This draws a line on the given window. (odd angle lines not working yet)
142 */
143 void drawLine (WINDOW *window, int startx, int starty, int endx, int endy, chtype line)
144 {
145 /* De=clare some local vars. */
146 int xdiff = endx - startx;
147 int ydiff = endy - starty;
148 int x = 0;
149 int y = 0;
150
151 /* Determine if we are drawing a horizontal or vertical line. */
152 if (ydiff == 0)
153 {
154 if (xdiff > 0)
155 mvwhline (window, starty, startx, line, xdiff);
156 }
157 else if (xdiff == 0)
158 {
159 if (ydiff > 0)
160 mvwvline (window, starty, startx, line, ydiff);
161 }
162 else
163 {
164 /* We need to determine the angle of the line. */
165 int height = xdiff;
166 int width = ydiff;
167 int xratio = (height > width ? 1 : (width / height));
168 int yratio = (width > height ? (width / height) : 1);
169 int xadj = 0;
170 int yadj = 0;
171
172 /* Set the vars. */
173 x = startx;
174 y = starty;
175 while (x != endx && y != endy)
176 {
177 /* Add the char to the window. */
178 mvwaddch (window, y, x, line);
179
180 /* Make the x and y adjustments. */
181 if (xadj != xratio)
182 {
183 x = (xdiff < 0 ? x-1 : x+1);
184 xadj++;
185 }
186 else
187 {
188 xadj = 0;
189 }
190 if (yadj != yratio)
191 {
192 y = (ydiff < 0 ? y-1 : y+1);
193 yadj++;
194 }
195 else
196 {
197 yadj = 0;
198 }
199 }
200 }
201 }
202
203 /*
204 * This draws a shadow around a window.
205 */
206 void drawShadow (WINDOW *shadowWin)
207 {
208 if (shadowWin != 0)
209 {
210 int x_hi = getmaxx(shadowWin) - 1;
211 int y_hi = getmaxy(shadowWin) - 1;
212
213 /* Draw the line on the bottom. */
214 mvwhline(shadowWin, y_hi, 1, ACS_HLINE | A_DIM, x_hi);
215
216 /* Draw the line on the right. */
217 mvwvline(shadowWin, 0, x_hi, ACS_VLINE | A_DIM, y_hi);
218
219 mvwaddch (shadowWin, 0, x_hi, ACS_URCORNER | A_DIM);
220 mvwaddch (shadowWin, y_hi, 0, ACS_LLCORNER | A_DIM);
221 mvwaddch (shadowWin, y_hi, x_hi, ACS_LRCORNER | A_DIM);
222 wrefresh (shadowWin);
223 }
224 }
225
226 /*
227 * Write a string of blanks, using writeChar().
228 */
229 void writeBlanks (WINDOW *window, int xpos, int ypos, int align, int start, int end)
230 {
231 if (start < end)
232 {
233 unsigned want = (end - start) + 1000;
234 char *blanks = (char *)malloc (want);
235
236 if (blanks != 0)
237 {
238 cleanChar (blanks, want - 1, ' ');
239 writeChar (window, xpos, ypos, blanks, align, start, end);
240 freeChar (blanks);
241 }
242 }
243 }
244
245 /*
246 * This writes out a char * string with no attributes.
247 */
248 void writeChar (WINDOW *window, int xpos, int ypos, char *string, int align, int start, int end)
249 {
250 writeCharAttrib (window, xpos, ypos, string, A_NORMAL, align, start, end);
251 }
252
253 /*
254 * This writes out a char * string with attributes.
255 */
256 void writeCharAttrib (WINDOW *window, int xpos, int ypos, char *string, chtype attr, int align, int start, int end)
257 {
258 int display = end - start;
259 int x;
260
261 if (align == HORIZONTAL)
262 {
263 /* Draw the message on a horizontal axis. */
264 display = MINIMUM(display, getmaxx(window) - 1);
265 for (x=0; x < display ; x++)
266 {
267 mvwaddch (window, ypos, xpos+x, CharOf(string[x+start]) | attr);
268 }
269 }
270 else
271 {
272 /* Draw the message on a vertical axis. */
273 display = MINIMUM(display, getmaxy(window) - 1);
274 for (x=0; x < display ; x++)
275 {
276 mvwaddch (window, ypos+x, xpos, CharOf(string[x+start]) | attr);
277 }
278 }
279 }
280
281 /*
282 * This writes out a chtype * string.
283 */
284 void writeChtype (WINDOW *window, int xpos, int ypos, chtype *string, int align, int start, int end)
285 {
286 writeChtypeAttrib (window, xpos, ypos, string, A_NORMAL, align, start, end);
287 }
288
289 /*
290 * This writes out a chtype * string * with the given attributes added.
291 */
292 void writeChtypeAttrib (WINDOW *window, int xpos, int ypos, chtype *string, chtype attr, int align, int start, int end)
293 {
294 int diff = end - start;
295 int display = 0;
296 int x = 0;
297
298 if (align == HORIZONTAL)
299 {
300 /* Draw the message on a horizontal axis. */
301 display = MINIMUM(diff, getmaxx(window) - xpos);
302 for (x=0; x < display; x++)
303 {
304 mvwaddch (window, ypos, xpos+x, string[x+start] | attr);
305 }
306 }
307 else
308 {
309 /* Draw the message on a vertical axis. */
310 display = MINIMUM(diff, getmaxy(window) - ypos);
311 for (x=0; x < display; x++)
312 {
313 mvwaddch (window, ypos+x, xpos, string[x+start] | attr);
314 }
315 }
316 }
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:24:48 $
5 * $Revision: 1.214 $
6 */
7
8 /*
9 * Declare file local prototypes.
10 */
11 static void CDKEntryCallBack (CDKENTRY *entry, chtype character);
12 static void drawCDKEntryField (CDKENTRY *entry);
13
14 DeclareCDKObjects (ENTRY, Entry, setCdk, String);
15
16 /*
17 * This creates a pointer to an entry widget.
18 */
19 CDKENTRY *newCDKEntry (CDKSCREEN *cdkscreen,
20 int xplace,
21 int yplace,
22 char *title,
23 char *label,
24 chtype fieldAttr,
25 chtype filler,
26 EDisplayType dispType,
27 int fWidth,
28 int min,
29 int max,
30 boolean Box,
31 boolean shadow)
32 {
33 CDKENTRY *entry = 0;
34 int parentWidth = getmaxx (cdkscreen->window);
35 int parentHeight = getmaxy (cdkscreen->window);
36 int fieldWidth = fWidth;
37 int boxWidth = 0;
38 int boxHeight;
39 int xpos = xplace;
40 int ypos = yplace;
41 int junk = 0;
42 int horizontalAdjust, oldWidth;
43
44 if ((entry = newCDKObject (CDKENTRY, &my_funcs)) == 0)
45 return (0);
46
47 setCDKEntryBox (entry, Box);
48 boxHeight = (BorderOf (entry) * 2) + 1;
49
50 /*
51 * If the fieldWidth is a negative value, the fieldWidth will
52 * be COLS-fieldWidth, otherwise, the fieldWidth will be the
53 * given width.
54 */
55 fieldWidth = setWidgetDimension (parentWidth, fieldWidth, 0);
56 boxWidth = fieldWidth + 2 * BorderOf (entry);
57
58 /* Set some basic values of the entry field. */
59 entry->label = 0;
60 entry->labelLen = 0;
61 entry->labelWin = 0;
62
63 /* Translate the label char *pointer to a chtype pointer. */
64 if (label != 0)
65 {
66 entry->label = char2Chtype (label, &entry->labelLen, &junk);
67 boxWidth += entry->labelLen;
68 }
69
70 oldWidth = boxWidth;
71 boxWidth = setCdkTitle (ObjOf (entry), title, boxWidth);
72 horizontalAdjust = (boxWidth - oldWidth) / 2;
73
74 boxHeight += TitleLinesOf (entry);
75
76 /*
77 * Make sure we didn't extend beyond the dimensions of the window.
78 */
79 boxWidth = MINIMUM (boxWidth, parentWidth);
80 boxHeight = MINIMUM (boxHeight, parentHeight);
81 fieldWidth = MINIMUM (fieldWidth,
82 boxWidth - entry->labelLen - 2 * BorderOf (entry));
83
84 /* Rejustify the x and y positions if we need to. */
85 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
86
87 /* Make the label window. */
88 entry->win = subwin (cdkscreen->window, boxHeight, boxWidth, ypos, xpos);
89 if (entry->win == 0)
90 {
91 destroyCDKObject (entry);
92 return (0);
93 }
94 keypad (entry->win, TRUE);
95
96 /* Make the field window. */
97 entry->fieldWin = subwin (entry->win, 1, fieldWidth,
98 ypos + TitleLinesOf (entry) + BorderOf (entry),
99 xpos + entry->labelLen + horizontalAdjust + BorderOf (entry));
100 if (entry->fieldWin == 0)
101 {
102 destroyCDKObject (entry);
103 return (0);
104 }
105 keypad (entry->fieldWin, TRUE);
106
107 /* Make the label win, if we need to. */
108 if (label != 0)
109 {
110 entry->labelWin = subwin (entry->win, 1, entry->labelLen,
111 ypos + TitleLinesOf (entry) + BorderOf (entry),
112 xpos + horizontalAdjust + BorderOf (entry));
113 }
114
115 /* Make room for the info char * pointer. */
116 entry->info = typeMallocN (char, max + 3);
117 if (entry->info == 0)
118 {
119 destroyCDKObject (entry);
120 return (0);
121 }
122 cleanChar (entry->info, max + 3, '\0');
123 entry->infoWidth = max + 3;
124
125 /* Set up the rest of the structure. */
126 ScreenOf (entry) = cdkscreen;
127 entry->parent = cdkscreen->window;
128 entry->shadowWin = 0;
129 entry->fieldAttr = fieldAttr;
130 entry->fieldWidth = fieldWidth;
131 entry->filler = filler;
132 entry->hidden = filler;
133 ObjOf (entry)->inputWindow = entry->fieldWin;
134 ObjOf (entry)->acceptsFocus = TRUE;
135 ReturnOf (entry) = NULL;
136 entry->shadow = shadow;
137 entry->screenCol = 0;
138 entry->leftChar = 0;
139 entry->min = min;
140 entry->max = max;
141 entry->boxWidth = boxWidth;
142 entry->boxHeight = boxHeight;
143 initExitType (entry);
144 entry->dispType = dispType;
145 entry->callbackfn = CDKEntryCallBack;
146
147 /* Do we want a shadow? */
148 if (shadow)
149 {
150 entry->shadowWin = subwin (cdkscreen->window,
151 boxHeight,
152 boxWidth,
153 ypos + 1,
154 xpos + 1);
155 }
156
157 registerCDKObject (cdkscreen, vENTRY, entry);
158
159 return (entry);
160 }
161
162 /*
163 * This means you want to use the given entry field. It takes input
164 * from the keyboard, and when its done, it fills the entry info
165 * element of the structure with what was typed.
166 */
167 char *activateCDKEntry (CDKENTRY *entry, chtype *actions)
168 {
169 chtype input = 0;
170 boolean functionKey;
171 char *ret = 0;
172
173 /* Draw the widget. */
174 drawCDKEntry (entry, ObjOf (entry)->box);
175
176 if (actions == 0)
177 {
178 for (;;)
179 {
180 input = getchCDKObject (ObjOf (entry), &functionKey);
181
182 /* Inject the character into the widget. */
183 ret = injectCDKEntry (entry, input);
184 if (entry->exitType != vEARLY_EXIT)
185 {
186 return ret;
187 }
188 }
189 }
190 else
191 {
192 int length = chlen (actions);
193 int x;
194
195 /* Inject each character one at a time. */
196 for (x = 0; x < length; x++)
197 {
198 ret = injectCDKEntry (entry, actions[x]);
199 if (entry->exitType != vEARLY_EXIT)
200 {
201 return ret;
202 }
203 }
204 }
205
206 /* Make sure we return the correct info. */
207 if (entry->exitType == vNORMAL)
208 {
209 return entry->info;
210 }
211 else
212 {
213 return 0;
214 }
215 }
216
217 static void setPositionToEnd (CDKENTRY *entry)
218 {
219 int stringLen;
220 int charCount;
221
222 stringLen = (int)strlen (entry->info);
223 if (stringLen >= entry->fieldWidth)
224 {
225 if (stringLen < entry->max)
226 {
227 charCount = entry->fieldWidth - 1;
228 entry->leftChar = stringLen - charCount;
229 entry->screenCol = charCount;
230 }
231 else
232 {
233 entry->leftChar = stringLen - entry->fieldWidth;
234 entry->screenCol = stringLen - 1;
235 }
236 }
237 else
238 {
239 entry->leftChar = 0;
240 entry->screenCol = stringLen;
241 }
242 }
243
244 /*
245 * This injects a single character into the widget.
246 */
247 static int _injectCDKEntry (CDKOBJS *object, chtype input)
248 {
249 CDKENTRY *entry = (CDKENTRY *)object;
250 int ppReturn = 1;
251 int x;
252 char holder;
253 char *ret = unknownString;
254 bool complete = FALSE;
255
256 /* Set the exit type. */
257 setExitType (entry, 0);
258
259 /* Refresh the entry field. */
260 drawCDKEntryField (entry);
261
262 /* Check if there is a pre-process function to be called. */
263 if (PreProcessFuncOf (entry) != 0)
264 {
265 ppReturn = PreProcessFuncOf (entry) (vENTRY,
266 entry,
267 PreProcessDataOf (entry),
268 input);
269 }
270
271 /* Should we continue? */
272 if (ppReturn != 0)
273 {
274 /* Check a predefined binding... */
275 if (checkCDKObjectBind (vENTRY, entry, input) != 0)
276 {
277 checkEarlyExit (entry);
278 complete = TRUE;
279 }
280 else
281 {
282 int infoLength = (int)strlen (entry->info);
283 int currPos = entry->screenCol + entry->leftChar;
284
285 switch (input)
286 {
287 case KEY_UP:
288 case KEY_DOWN:
289 Beep ();
290 break;
291
292 case KEY_HOME:
293 entry->leftChar = 0;
294 entry->screenCol = 0;
295 drawCDKEntryField (entry);
296 break;
297
298 case CDK_TRANSPOSE:
299 if (currPos >= infoLength - 1)
300 {
301 Beep ();
302 }
303 else
304 {
305 holder = entry->info[currPos];
306 entry->info[currPos] = entry->info[currPos + 1];
307 entry->info[currPos + 1] = holder;
308 drawCDKEntryField (entry);
309 }
310 break;
311
312 case KEY_END:
313 setPositionToEnd (entry);
314 drawCDKEntryField (entry);
315 break;
316
317 case KEY_LEFT:
318 if (currPos <= 0)
319 {
320 Beep ();
321 }
322 else if (entry->screenCol == 0)
323 {
324 /* Scroll left. */
325 entry->leftChar--;
326 drawCDKEntryField (entry);
327 }
328 else
329 {
330 wmove (entry->fieldWin, 0, --entry->screenCol);
331 }
332 break;
333
334 case KEY_RIGHT:
335 if (currPos >= infoLength)
336 {
337 Beep ();
338 }
339 else if (entry->screenCol == entry->fieldWidth - 1)
340 {
341 /* Scroll to the right. */
342 entry->leftChar++;
343 drawCDKEntryField (entry);
344 }
345 else
346 {
347 /* Move right. */
348 wmove (entry->fieldWin, 0, ++entry->screenCol);
349 }
350 break;
351
352 case KEY_BACKSPACE:
353 case KEY_DC:
354 if (entry->dispType == vVIEWONLY)
355 {
356 Beep ();
357 }
358 else
359 {
360 bool success = FALSE;
361
362 if (input == KEY_BACKSPACE)
363 --currPos;
364
365 if (currPos >= 0 && infoLength > 0)
366 {
367 if (currPos < infoLength)
368 {
369 for (x = currPos; x < infoLength; x++)
370 {
371 entry->info[x] = entry->info[x + 1];
372 }
373 success = TRUE;
374 }
375 else if (input == KEY_BACKSPACE)
376 {
377 entry->info[infoLength - 1] = '\0';
378 success = TRUE;
379 }
380 }
381
382 if (success)
383 {
384 if (input == KEY_BACKSPACE)
385 {
386 if (entry->screenCol > 0)
387 entry->screenCol--;
388 else
389 entry->leftChar--;
390 }
391
392 drawCDKEntryField (entry);
393 }
394 else
395 {
396 Beep ();
397 }
398 }
399 break;
400
401 case KEY_ESC:
402 setExitType (entry, input);
403 complete = TRUE;
404 break;
405
406 case CDK_ERASE:
407 if (infoLength != 0)
408 {
409 cleanCDKEntry (entry);
410 drawCDKEntryField (entry);
411 }
412 break;
413
414 case CDK_CUT:
415 if (infoLength != 0)
416 {
417 freeChar (GPasteBuffer);
418 GPasteBuffer = copyChar (entry->info);
419 cleanCDKEntry (entry);
420 drawCDKEntryField (entry);
421 }
422 else
423 {
424 Beep ();
425 }
426 break;
427
428 case CDK_COPY:
429 if (infoLength != 0)
430 {
431 freeChar (GPasteBuffer);
432 GPasteBuffer = copyChar (entry->info);
433 }
434 else
435 {
436 Beep ();
437 }
438 break;
439
440 case CDK_PASTE:
441 if (GPasteBuffer != 0)
442 {
443 setCDKEntryValue (entry, GPasteBuffer);
444 drawCDKEntryField (entry);
445 }
446 else
447 {
448 Beep ();
449 }
450 break;
451
452 case KEY_TAB:
453 case KEY_ENTER:
454 if (infoLength >= entry->min)
455 {
456 setExitType (entry, input);
457 ret = (entry->info);
458 complete = TRUE;
459 }
460 else
461 {
462 Beep ();
463 }
464 break;
465
466 case CDK_REFRESH:
467 eraseCDKScreen (ScreenOf (entry));
468 refreshCDKScreen (ScreenOf (entry));
469 break;
470
471 default:
472 (entry->callbackfn) (entry, input);
473 break;
474 }
475 }
476
477 /* Should we do a post-process? */
478 if (!complete && (PostProcessFuncOf (entry) != 0))
479 {
480 PostProcessFuncOf (entry) (vENTRY,
481 entry,
482 PostProcessDataOf (entry),
483 input);
484 }
485 }
486
487 if (!complete)
488 setExitType (entry, 0);
489
490 ResultOf (entry).valueString = ret;
491 return (ret != unknownString);
492 }
493
494 /*
495 * This moves the entry field to the given location.
496 */
497 static void _moveCDKEntry (CDKOBJS *object,
498 int xplace,
499 int yplace,
500 boolean relative,
501 boolean refresh_flag)
502 {
503 CDKENTRY *entry = (CDKENTRY *)object;
504 int currentX = getbegx (entry->win);
505 int currentY = getbegy (entry->win);
506 int xpos = xplace;
507 int ypos = yplace;
508 int xdiff = 0;
509 int ydiff = 0;
510
511 /*
512 * If this is a relative move, then we will adjust where we want
513 * to move to.
514 */
515 if (relative)
516 {
517 xpos = getbegx (entry->win) + xplace;
518 ypos = getbegy (entry->win) + yplace;
519 }
520
521 /* Adjust the window if we need to. */
522 alignxy (WindowOf (entry), &xpos, &ypos, entry->boxWidth, entry->boxHeight);
523
524 /* Get the difference. */
525 xdiff = currentX - xpos;
526 ydiff = currentY - ypos;
527
528 /* Move the window to the new location. */
529 moveCursesWindow (entry->win, -xdiff, -ydiff);
530 moveCursesWindow (entry->fieldWin, -xdiff, -ydiff);
531 moveCursesWindow (entry->labelWin, -xdiff, -ydiff);
532 moveCursesWindow (entry->shadowWin, -xdiff, -ydiff);
533
534 /* Touch the windows so they 'move'. */
535 refreshCDKWindow (WindowOf (entry));
536
537 /* Redraw the window, if they asked for it. */
538 if (refresh_flag)
539 {
540 drawCDKEntry (entry, ObjOf (entry)->box);
541 }
542 }
543
544 /*
545 * This is a generic character parser for the entry field. It is used as a
546 * callback function, so any personal modifications can be made by creating
547 * a new function and calling the activation with its name.
548 */
549 static void CDKEntryCallBack (CDKENTRY *entry, chtype character)
550 {
551 int plainchar = filterByDisplayType (entry->dispType, character);
552 unsigned temp;
553
554 if (plainchar == ERR ||
555 ((int)strlen (entry->info) >= entry->max))
556 {
557 Beep ();
558 }
559 else
560 {
561 /* Update the screen and pointer. */
562 if (entry->screenCol != entry->fieldWidth - 1)
563 {
564 int x;
565
566 for (x = (int)strlen (entry->info);
567 x > (entry->screenCol + entry->leftChar);
568 x--)
569 {
570 entry->info[x] = entry->info[x - 1];
571 }
572 entry->info[entry->screenCol + entry->leftChar] = plainchar;
573 entry->screenCol++;
574 }
575 else
576 {
577 /* Update the character pointer. */
578 temp = strlen (entry->info);
579 entry->info[temp] = plainchar;
580 entry->info[temp + 1] = '\0';
581 /* Do not update the pointer if it's the last character */
582 if ((int)(temp + 1) < entry->max)
583 entry->leftChar++;
584 }
585
586 /* Update the entry field. */
587 drawCDKEntryField (entry);
588 }
589 }
590
591 /*
592 * This erases the information in the entry field
593 * and redraws a clean and empty entry field.
594 */
595 void cleanCDKEntry (CDKENTRY *entry)
596 {
597 int width = entry->fieldWidth;
598
599 /* Erase the information in the character pointer. */
600 cleanChar (entry->info, entry->infoWidth, '\0');
601
602 /* Clean the entry screen field. */
603 mvwhline (entry->fieldWin, 0, 0, entry->filler, width);
604
605 /* Reset some variables. */
606 entry->screenCol = 0;
607 entry->leftChar = 0;
608
609 /* Refresh the entry field. */
610 wrefresh (entry->fieldWin);
611 }
612
613 /*
614 * This draws the entry field.
615 */
616 static void _drawCDKEntry (CDKOBJS *object, boolean Box)
617 {
618 CDKENTRY *entry = (CDKENTRY *)object;
619
620 /* Did we ask for a shadow? */
621 if (entry->shadowWin != 0)
622 {
623 drawShadow (entry->shadowWin);
624 }
625
626 /* Box the widget if asked. */
627 if (Box)
628 {
629 drawObjBox (entry->win, ObjOf (entry));
630 }
631
632 drawCdkTitle (entry->win, object);
633
634 wrefresh (entry->win);
635
636 /* Draw in the label to the widget. */
637 if (entry->labelWin != 0)
638 {
639 writeChtype (entry->labelWin, 0, 0, entry->label, HORIZONTAL, 0, entry->labelLen);
640 wrefresh (entry->labelWin);
641 }
642
643 drawCDKEntryField (entry);
644 }
645
646 /*
647 * This redraws the entry field.
648 */
649 static void drawCDKEntryField (CDKENTRY *entry)
650 {
651 int infoLength = 0;
652 int x = 0;
653
654 /* Draw in the filler characters. */
655 mvwhline (entry->fieldWin, 0, x, entry->filler, entry->fieldWidth);
656
657 /* If there is information in the field. Then draw it in. */
658 if (entry->info != 0)
659 {
660 infoLength = (int)strlen (entry->info);
661
662 /* Redraw the field. */
663 if (isHiddenDisplayType (entry->dispType))
664 {
665 for (x = entry->leftChar; x < infoLength; x++)
666 {
667 mvwaddch (entry->fieldWin, 0, x - entry->leftChar, entry->hidden);
668 }
669 }
670 else
671 {
672 for (x = entry->leftChar; x < infoLength; x++)
673 {
674 mvwaddch (entry->fieldWin, 0, x - entry->leftChar,
675 CharOf (entry->info[x]) | entry->fieldAttr);
676 }
677 }
678 wmove (entry->fieldWin, 0, entry->screenCol);
679 }
680
681 wrefresh (entry->fieldWin);
682 }
683
684 /*
685 * This erases an entry widget from the screen.
686 */
687 static void _eraseCDKEntry (CDKOBJS *object)
688 {
689 if (validCDKObject (object))
690 {
691 CDKENTRY *entry = (CDKENTRY *)object;
692
693 eraseCursesWindow (entry->fieldWin);
694 eraseCursesWindow (entry->labelWin);
695 eraseCursesWindow (entry->win);
696 eraseCursesWindow (entry->shadowWin);
697 }
698 }
699
700 /*
701 * This destroys an entry widget.
702 */
703 static void _destroyCDKEntry (CDKOBJS *object)
704 {
705 if (object != 0)
706 {
707 CDKENTRY *entry = (CDKENTRY *)object;
708
709 cleanCdkTitle (object);
710 freeChtype (entry->label);
711 freeChar (entry->info);
712
713 /* Delete the windows. */
714 deleteCursesWindow (entry->fieldWin);
715 deleteCursesWindow (entry->labelWin);
716 deleteCursesWindow (entry->shadowWin);
717 deleteCursesWindow (entry->win);
718
719 /* Clean the key bindings. */
720 cleanCDKObjectBindings (vENTRY, entry);
721
722 /* Unregister this object. */
723 unregisterCDKObject (vENTRY, entry);
724 }
725 }
726
727 /*
728 * This sets specific attributes of the entry field.
729 */
730 void setCDKEntry (CDKENTRY *entry,
731 char *value,
732 int min,
733 int max,
734 boolean Box GCC_UNUSED)
735 {
736 setCDKEntryValue (entry, value);
737 setCDKEntryMin (entry, min);
738 setCDKEntryMax (entry, max);
739 }
740
741 /*
742 * This removes the old information in the entry field and keeps the
743 * new information given.
744 */
745 void setCDKEntryValue (CDKENTRY *entry, char *newValue)
746 {
747 int copychars = 0;
748
749 /* If the pointer sent in is the same pointer as before, do nothing. */
750 if (entry->info != newValue)
751 {
752 /* Just to be sure, if lets make sure the new value isn't null. */
753 if (newValue == 0)
754 {
755 /* Then we want to just erase the old value. */
756 cleanChar (entry->info, entry->infoWidth, '\0');
757
758 /* Set the pointers back to zero. */
759 entry->leftChar = 0;
760 entry->screenCol = 0;
761 }
762 else
763 {
764 /* Determine how many characters we need to copy. */
765 copychars = MINIMUM ((int)strlen (newValue), entry->max);
766
767 /* OK, erase the old value, and copy in the new value. */
768 cleanChar (entry->info, entry->max, '\0');
769 strncpy (entry->info, newValue, (unsigned)copychars);
770
771 setPositionToEnd (entry);
772 }
773 }
774 }
775 char *getCDKEntryValue (CDKENTRY *entry)
776 {
777 return entry->info;
778 }
779
780 /*
781 * This sets the maximum length of the string that will be accepted.
782 */
783 void setCDKEntryMax (CDKENTRY *entry, int max)
784 {
785 entry->max = max;
786 }
787 int getCDKEntryMax (CDKENTRY *entry)
788 {
789 return entry->max;
790 }
791
792 /*
793 * This sets the minimum length of the string that will
794 * be accepted.
795 */
796 void setCDKEntryMin (CDKENTRY *entry, int min)
797 {
798 entry->min = min;
799 }
800 int getCDKEntryMin (CDKENTRY *entry)
801 {
802 return entry->min;
803 }
804
805 /*
806 * This sets the filler character to be used in the entry field.
807 */
808 void setCDKEntryFillerChar (CDKENTRY *entry, chtype fillerCharacter)
809 {
810 entry->filler = fillerCharacter;
811 }
812 chtype getCDKEntryFillerChar (CDKENTRY *entry)
813 {
814 return entry->filler;
815 }
816
817 /*
818 * This sets the character to use when a hidden type is used.
819 */
820 void setCDKEntryHiddenChar (CDKENTRY *entry, chtype hiddenCharacter)
821 {
822 entry->hidden = hiddenCharacter;
823 }
824 chtype getCDKEntryHiddenChar (CDKENTRY *entry)
825 {
826 return entry->hidden;
827 }
828
829 /*
830 * This sets the widgets box attribute.
831 */
832 void setCDKEntryBox (CDKENTRY *entry, boolean Box)
833 {
834 ObjOf (entry)->box = Box;
835 ObjOf (entry)->borderSize = Box ? 1 : 0;
836 }
837 boolean getCDKEntryBox (CDKENTRY *entry)
838 {
839 return ObjOf (entry)->box;
840 }
841
842 /*
843 * This sets the background attribute of the widget.
844 */
845 static void _setBKattrEntry (CDKOBJS *object, chtype attrib)
846 {
847 if (object != 0)
848 {
849 CDKENTRY *widget = (CDKENTRY *)object;
850
851 wbkgd (widget->win, attrib);
852 wbkgd (widget->fieldWin, attrib);
853 if (widget->labelWin != 0)
854 {
855 wbkgd (widget->labelWin, attrib);
856 }
857 }
858 }
859
860 /*
861 * This sets the attribute of the entry field.
862 */
863 void setCDKEntryHighlight (CDKENTRY *entry, chtype highlight, boolean cursor)
864 {
865 wbkgd (entry->fieldWin, highlight);
866 entry->fieldAttr = highlight;
867 curs_set (cursor);
868 /*
869 * FIXME - if (cursor) { move the cursor to this widget }
870 */
871 }
872
873 /*
874 * This sets the entry field callback function.
875 */
876 void setCDKEntryCB (CDKENTRY *entry, ENTRYCB callback)
877 {
878 entry->callbackfn = callback;
879 }
880
881 static void _focusCDKEntry (CDKOBJS *object)
882 {
883 CDKENTRY *entry = (CDKENTRY *)object;
884
885 wmove (entry->fieldWin, 0, entry->screenCol);
886 wrefresh (entry->fieldWin);
887 }
888
889 static void _unfocusCDKEntry (CDKOBJS *object)
890 {
891 CDKENTRY *entry = (CDKENTRY *)object;
892
893 drawCDKEntry (entry, ObjOf (entry)->box);
894 wrefresh (entry->fieldWin);
895 }
896
897 #if 0
898 static void _refreshDataCDKEntry (CDKOBJS *object)
899 {
900 CDKENTRY *entry = (CDKENTRY *)object;
901
902 if (ReturnOf (entry))
903 {
904 switch (DataTypeOf (entry))
905 {
906 default:
907 case DataTypeString:
908 strcpy (entry->info, (char *)ReturnOf (entry));
909 break;
910 case DataTypeInt:
911 sprintf (entry->info, "%d", *((int *)ReturnOf (entry)));
912 break;
913 case DataTypeFloat:
914 sprintf (entry->info, "%g", *((float *)ReturnOf (entry)));
915 break;
916 case DataTypeDouble:
917 sprintf (entry->info, "%g", *((double *)ReturnOf (entry)));
918 break;
919 }
920 entry->screenCol = strlen (entry->info);
921 drawCDKEntryField (entry);
922 }
923 }
924
925 static void _saveDataCDKEntry (CDKOBJS *object)
926 {
927 CDKENTRY *entry = (CDKENTRY *)object;
928
929 if (ReturnOf (entry))
930 {
931 switch (DataTypeOf (entry))
932 {
933 default:
934 case DataTypeString:
935 strcpy ((char *)ReturnOf (entry), entry->info);
936 break;
937 case DataTypeInt:
938 *((int *)ReturnOf (entry)) = atoi (entry->info);
939 break;
940 case DataTypeFloat:
941 *((float *)ReturnOf (entry)) = atof (entry->info);
942 break;
943 case DataTypeDouble:
944 *((double *)ReturnOf (entry)) = atof (entry->info);
945 break;
946 }
947 }
948 }
949 #else
950 dummyRefreshData (Entry)
951 dummySaveData (Entry)
952 #endif
0 # $Id: Makefile.in,v 1.18 2005/12/28 00:03:39 tom Exp $
1 #
2 # Makefile for the examples directory.
3 #
4 SHELL = /bin/sh
5
6 prefix = @prefix@
7 exec_prefix = @exec_prefix@
8
9 srcdir = @srcdir@
10 VPATH = $(srcdir)
11
12 CC = @CC@
13 RM = rm -f
14
15 LIBS = -l@LIB_ROOTNAME@ @LIBS@
16
17 LIBTOOL = @LIBTOOL@ @ECHO_LT@
18 LIBTOOL_CLEAN = @LIB_CLEAN@
19 LIBTOOL_LINK = @LIB_LINK@
20 LINK = $(LIBTOOL_LINK) $(CC)
21
22 x = @EXEEXT@
23 o = .@OBJEXT@
24
25 CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@
26 CPPFLAGS = @DEFS@ -I../include -I$(srcdir)/../include -I. @CPPFLAGS@
27 LDFLAGS = -L.. @LDFLAGS@
28
29 BINS = \
30 alphalist_ex$x \
31 bind_ex$x \
32 buttonbox_ex$x \
33 calendar_ex$x \
34 cdkscreen_ex$x \
35 dialog_ex$x \
36 entry_ex$x \
37 fscale_ex$x \
38 fselect_ex$x \
39 fslider_ex$x \
40 graph_ex$x \
41 hello_ex$x \
42 histogram_ex$x \
43 itemlist_ex$x \
44 label_ex$x \
45 lowerCDKObject_ex$x \
46 marquee_ex$x \
47 matrix_ex$x \
48 mentry_ex$x \
49 menu_ex$x \
50 position_ex$x \
51 preprocess_ex$x \
52 radio1_ex$x \
53 radio_ex$x \
54 raiseCDKObject_ex$x \
55 scale_ex$x \
56 scroll_ex$x \
57 selection_ex$x \
58 slider_ex$x \
59 subwindow_ex$x \
60 swindow_ex$x \
61 template_ex$x \
62 traverse_ex$x \
63 uslider_ex$x \
64 viewer_ex$x \
65 viewer_ex2$x
66
67 LINKIT = @ECHO_LD@$(LINK) $(CFLAGS) $(CPPFLAGS) $? -o $@ $(LDFLAGS) $(LIBS)
68
69 all : $(BINS)
70
71 alphalist_ex$x : alphalist_ex.c ; $(LINKIT)
72 bind_ex$x : bind_ex.c ; $(LINKIT)
73 buttonbox_ex$x : buttonbox_ex.c ; $(LINKIT)
74 calendar_ex$x : calendar_ex.c ; $(LINKIT)
75 cdkscreen_ex$x : cdkscreen_ex.c ; $(LINKIT)
76 dialog_ex$x : dialog_ex.c ; $(LINKIT)
77 entry_ex$x : entry_ex.c ; $(LINKIT)
78 fscale_ex$x : fscale_ex.c ; $(LINKIT)
79 fselect_ex$x : fselect_ex.c ; $(LINKIT)
80 fslider_ex$x : fslider_ex.c ; $(LINKIT)
81 graph_ex$x : graph_ex.c ; $(LINKIT)
82 hello_ex$x : hello_ex.c ; $(LINKIT)
83 histogram_ex$x : histogram_ex.c ; $(LINKIT)
84 itemlist_ex$x : itemlist_ex.c ; $(LINKIT)
85 label_ex$x : label_ex.c ; $(LINKIT)
86 lowerCDKObject_ex$x : lowerCDKObject_ex.c ; $(LINKIT)
87 marquee_ex$x : marquee_ex.c ; $(LINKIT)
88 matrix_ex$x : matrix_ex.c ; $(LINKIT)
89 mentry_ex$x : mentry_ex.c ; $(LINKIT)
90 menu_ex$x : menu_ex.c ; $(LINKIT)
91 position_ex$x : position_ex.c ; $(LINKIT)
92 preprocess_ex$x : preprocess_ex.c ; $(LINKIT)
93 radio1_ex$x : radio1_ex.c ; $(LINKIT)
94 radio_ex$x : radio_ex.c ; $(LINKIT)
95 raiseCDKObject_ex$x : raiseCDKObject_ex.c ; $(LINKIT)
96 scale_ex$x : scale_ex.c ; $(LINKIT)
97 scroll_ex$x : scroll_ex.c ; $(LINKIT)
98 selection_ex$x : selection_ex.c ; $(LINKIT)
99 slider_ex$x : slider_ex.c ; $(LINKIT)
100 subwindow_ex$x : subwindow_ex.c ; $(LINKIT)
101 swindow_ex$x : swindow_ex.c ; $(LINKIT)
102 template_ex$x : template_ex.c ; $(LINKIT)
103 traverse_ex$x : traverse_ex.c ; $(LINKIT)
104 uslider_ex$x : uslider_ex.c ; $(LINKIT)
105 viewer_ex$x : viewer_ex.c ; $(LINKIT)
106 viewer_ex2$x : viewer_ex2.c ; $(LINKIT)
107 #
108 # Standard clean directives.
109 #
110 clean::
111 -$(LIBTOOL_CLEAN) $(RM) *.o core $(BINS)
112
113 distclean:: clean
114 $(RM) Makefile
+0
-41
examples/alphalist less more
0 #!/usr/bin/perl -w
1 # $Id: alphalist,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Alphalist Widget.
6
7 #
8 # Load in the Cdk Extension.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Get the contents of the current directory.
14 my @info = qx (ls);
15 chomp @info;
16
17 # Create a new alphalist object.
18 my $alphalist = new Cdk::Alphalist ('Label' => "Type Anything:",
19 'Filler' => "</R/24>_",
20 'Height' => 20,
21 'Width' => 60,
22 'List' => \@info);
23
24 $alphalist->set ('BoxAttribute' => "</R>");
25
26 # Activate the object.
27 my $info = $alphalist->activate();
28
29 # Check the results...
30 if (! defined $info)
31 {
32 popupLabel (["<C>You hit escape to exit the widget."]);
33 }
34 else
35 {
36 popupLabel (["<C>You selected ($info)"]);
37 }
38
39 # Exit Cdk.
40 Cdk::end();
0 /* $Id: alphalist_ex.c,v 1.22 2006/05/07 23:15:34 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "alphalist_ex";
6 #endif
7
8 /*
9 * This program demonstrates the Cdk alphalist widget.
10 *
11 * Options (in addition to normal CLI parameters):
12 * -c create the data after the widget
13 */
14 static CDKSCREEN *cdkscreen = 0;
15 static char **myUserList = 0;
16 static int userSize;
17
18 typedef struct
19 {
20 int deleted; /* index in current list which is deleted */
21 int original; /* index in myUserList[] of deleted item */
22 int position; /* position before delete */
23 int topline; /* top-line before delete */
24 } UNDO;
25
26 static UNDO *myUndoList;
27 static int undoSize;
28
29 /*
30 * This reads the passwd file and retrieves user information.
31 */
32 static int getUserList (char ***list)
33 {
34 struct passwd *ent;
35 int x = 0;
36 unsigned used = 0;
37
38 while ((ent = getpwent ()) != 0)
39 {
40 used = CDKallocStrings (list, ent->pw_name, x++, used);
41 }
42 endpwent ();
43 return x;
44 }
45
46 #define CB_PARAMS EObjectType cdktype GCC_UNUSED, void* object GCC_UNUSED, void* clientdata GCC_UNUSED, chtype key GCC_UNUSED
47
48 static void fill_undo (CDKALPHALIST *widget, int deleted, char *data)
49 {
50 int top = getCDKScrollCurrentTop (widget->scrollField);
51 int item = getCDKAlphalistCurrentItem (widget);
52 int n;
53
54 myUndoList[undoSize].deleted = deleted;
55 myUndoList[undoSize].topline = top;
56 myUndoList[undoSize].original = -1;
57 myUndoList[undoSize].position = item;
58 for (n = 0; n < userSize; ++n)
59 {
60 if (!strcmp (myUserList[n], data))
61 {
62 myUndoList[undoSize].original = n;
63 break;
64 }
65 }
66 ++undoSize;
67 }
68
69 static int do_delete (CB_PARAMS)
70 {
71 CDKALPHALIST *widget = (CDKALPHALIST *)clientdata;
72 int size;
73 char **list = getCDKAlphalistContents (widget, &size);
74 int result = FALSE;
75
76 if (size)
77 {
78 int save = getCDKScrollCurrentTop (widget->scrollField);
79 int first = getCDKAlphalistCurrentItem (widget);
80 int n;
81
82 fill_undo (widget, first, list[first]);
83 for (n = first; n < size; ++n)
84 list[n] = list[n + 1];
85 setCDKAlphalistContents (widget, list, size - 1);
86 setCDKScrollCurrentTop (widget->scrollField, save);
87 setCDKAlphalistCurrentItem (widget, first);
88 drawCDKAlphalist (widget, BorderOf (widget));
89 result = TRUE;
90 }
91 return result;
92 }
93
94 static int do_delete1 (CB_PARAMS)
95 {
96 CDKALPHALIST *widget = (CDKALPHALIST *)clientdata;
97 int size;
98 char **list = getCDKAlphalistContents (widget, &size);
99 int result = FALSE;
100
101 if (size)
102 {
103 int save = getCDKScrollCurrentTop (widget->scrollField);
104 int first = getCDKAlphalistCurrentItem (widget);
105
106 if (first-- > 0)
107 {
108 int n;
109
110 fill_undo (widget, first, list[first]);
111 for (n = first; n < size; ++n)
112 list[n] = list[n + 1];
113 setCDKAlphalistContents (widget, list, size - 1);
114 setCDKScrollCurrentTop (widget->scrollField, save);
115 setCDKAlphalistCurrentItem (widget, first);
116 drawCDKAlphalist (widget, BorderOf (widget));
117 result = TRUE;
118 }
119 }
120 return result;
121 }
122
123 static int do_help (CB_PARAMS)
124 {
125 static char *message[] =
126 {
127 "Alpha List tests:",
128 "",
129 "F1 = help (this message)",
130 "F2 = delete current item",
131 "F3 = delete previous item",
132 "F4 = reload all items",
133 "F5 = undo deletion",
134 0
135 };
136 popupLabel (cdkscreen, message, CDKcountStrings (message));
137 return TRUE;
138 }
139
140 static int do_reload (CB_PARAMS)
141 {
142 int result = FALSE;
143
144 if (userSize)
145 {
146 CDKALPHALIST *widget = (CDKALPHALIST *)clientdata;
147 setCDKAlphalistContents (widget, myUserList, userSize);
148 setCDKAlphalistCurrentItem (widget, 0);
149 drawCDKAlphalist (widget, BorderOf (widget));
150 result = TRUE;
151 }
152 return result;
153 }
154
155 static int do_undo (CB_PARAMS)
156 {
157 int result = FALSE;
158
159 if (undoSize > 0)
160 {
161 CDKALPHALIST *widget = (CDKALPHALIST *)clientdata;
162 int size;
163 int n;
164 char **oldlist = getCDKAlphalistContents (widget, &size);
165 char **newlist = (char **)malloc ((++size + 1) * sizeof (char *));
166
167 --undoSize;
168 newlist[size] = 0;
169 for (n = size - 1; n > myUndoList[undoSize].deleted; --n)
170 {
171 newlist[n] = copyChar (oldlist[n - 1]);
172 }
173 newlist[n--] = copyChar (myUserList[myUndoList[undoSize].original]);
174 while (n >= 0)
175 {
176 newlist[n] = copyChar (oldlist[n]);
177 --n;
178 }
179 setCDKAlphalistContents (widget, newlist, size);
180 setCDKScrollCurrentTop (widget->scrollField, myUndoList[undoSize].topline);
181 setCDKAlphalistCurrentItem (widget, myUndoList[undoSize].position);
182 drawCDKAlphalist (widget, BorderOf (widget));
183 result = TRUE;
184 }
185 return result;
186 }
187
188 int main (int argc, char **argv)
189 {
190 CDKALPHALIST *alphaList = 0;
191 WINDOW *cursesWin = 0;
192 char *title = "<C></B/24>Alpha List\n<C>Title";
193 char *label = "</B>Account: ";
194 char *word = 0;
195 char **userList = 0;
196 char *mesg[5], temp[256];
197
198 CDK_PARAMS params;
199
200 CDKparseParams (argc, argv, &params, "c" CDK_CLI_PARAMS);
201
202 /* Get the user list. */
203 userSize = getUserList (&userList);
204 if (userSize <= 0)
205 {
206 fprintf (stderr, "Cannot get user list\n");
207 ExitProgram (EXIT_FAILURE);
208 }
209 myUserList = copyCharList (userList);
210 myUndoList = (UNDO *) malloc (userSize * sizeof (UNDO));
211 undoSize = 0;
212
213 /* Set up CDK. */
214 cursesWin = initscr ();
215 cdkscreen = initCDKScreen (cursesWin);
216
217 /* Start color. */
218 initCDKColor ();
219
220 /* Create the alpha list widget. */
221 alphaList = newCDKAlphalist (cdkscreen,
222 CDKparamValue (&params, 'X', CENTER),
223 CDKparamValue (&params, 'Y', CENTER),
224 CDKparamValue (&params, 'H', 0),
225 CDKparamValue (&params, 'W', 0),
226 title, label,
227 CDKparamNumber (&params, 'c') ? 0 : userList,
228 CDKparamNumber (&params, 'c') ? 0 : userSize,
229 '_', A_REVERSE,
230 CDKparamValue (&params, 'N', TRUE),
231 CDKparamValue (&params, 'S', FALSE));
232 if (alphaList == 0)
233 {
234 destroyCDKScreen (cdkscreen);
235 endCDK ();
236
237 fprintf (stderr, "Cannot create widget\n");
238 ExitProgram (EXIT_FAILURE);
239 }
240
241 bindCDKObject (vALPHALIST, alphaList, '?', do_help, NULL);
242 bindCDKObject (vALPHALIST, alphaList, KEY_F1, do_help, NULL);
243 bindCDKObject (vALPHALIST, alphaList, KEY_F2, do_delete, alphaList);
244 bindCDKObject (vALPHALIST, alphaList, KEY_F3, do_delete1, alphaList);
245 bindCDKObject (vALPHALIST, alphaList, KEY_F4, do_reload, alphaList);
246 bindCDKObject (vALPHALIST, alphaList, KEY_F5, do_undo, alphaList);
247
248 if (CDKparamNumber (&params, 'c'))
249 {
250 setCDKAlphalistContents (alphaList, userList, userSize);
251 }
252
253 /* Let them play with the alpha list. */
254 word = activateCDKAlphalist (alphaList, 0);
255
256 /* Determine what the user did. */
257 if (alphaList->exitType == vESCAPE_HIT)
258 {
259 mesg[0] = "<C>You hit escape. No word was selected.";
260 mesg[1] = "";
261 mesg[2] = "<C>Press any key to continue.";
262 popupLabel (cdkscreen, mesg, 3);
263 }
264 else if (alphaList->exitType == vNORMAL)
265 {
266 mesg[0] = "<C>You selected the following";
267 sprintf (temp, "<C>(%.*s)", (int)(sizeof (temp) - 10), word);
268 mesg[1] = temp;
269 mesg[2] = "";
270 mesg[3] = "<C>Press any key to continue.";
271 popupLabel (cdkscreen, mesg, 4);
272 }
273
274 freeCharList (myUserList, userSize);
275 free (myUserList);
276
277 destroyCDKAlphalist (alphaList);
278 destroyCDKScreen (cdkscreen);
279 endCDK ();
280
281 ExitProgram (EXIT_SUCCESS);
282 }
+0
-67
examples/bind less more
0 #!/usr/bin/perl -w
1 # $Id: bind,v 1.3 2002/07/24 10:04:32 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the character binding features of the
6 # Perl5/Cdk extension.
7 #
8
9 #
10 # Load in the Cdk Extension.
11 #
12 use Cdk;
13 Cdk::init();
14
15 # This callback fills the entry field with a filename.
16 sub callback
17 {
18 my $entryObj = shift @_;
19
20 # Generate a list of files in the current directory.
21 my @files = <*>;
22 my $filelist = new Cdk::Scroll ('Title' => "<C></U>Pick A File",
23 'Height' => 10,
24 'Width' => 20,
25 'List' => \@files);
26
27 # Activate the scrolling list.
28 my $itemPicked = $filelist->activate ();
29 undef $filelist;
30
31 # Set the filename.
32 $entryObj->set ('Min' => 0, 'Max' => 255, 'Value' => $files[$itemPicked]);
33
34 # Redraw the entry field.
35 $entryObj->draw();
36 return 1;
37 }
38
39 # Create a new entry object.
40 my $title = ["", "<C>Type in a filename or",
41 "<C>Press </R>tab<!R> to get a list.", ""];
42 $filename = new Cdk::Entry ('Label' => "Filename: ",
43 'Title' => $title,
44 'Width' => 20,
45 'Min' => 0,
46 'Max' => 256);
47
48 # Create a key binding.
49 my @mesg = ("<C>Hi Mike", "<C></U>How Are You?");
50 $filename->bind ('Key' => "KEY_TAB", 'Function' => sub {main::callback ($filename);});
51
52 # Activate the object.
53 my $file = $filename->activate();
54
55 # Check the results.
56 if (! defined $file)
57 {
58 popupLabel (["<C>Escape hit, no filename entered."]);
59 }
60 else
61 {
62 popupLabel (["<C>You typed in the filename ($file)"]);
63 }
64
65 # Exit Cdk.
66 Cdk::end();
0 /* $Id: bind_ex.c,v 1.16 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "bind_ex";
6 #endif
7
8 static int dialogHelpCB (EObjectType cdktype GCC_UNUSED,
9 void *object,
10 void *clientData GCC_UNUSED,
11 chtype key GCC_UNUSED)
12 {
13 CDKDIALOG *dialog = (CDKDIALOG *) object;
14 char *mesg[5];
15
16 /* Check which button we are on. */
17 if (dialog->currentButton == 0)
18 {
19 mesg[0] = "<C></U>Help for </U>Who<!U>.";
20 mesg[1] = "<C>When this button is picked the name of the current";
21 mesg[2] = "<C>user is displayed on the screen in a popup window.";
22 popupLabel (ScreenOf (dialog), mesg, 3);
23 }
24 else if (dialog->currentButton == 1)
25 {
26 mesg[0] = "<C></U>Help for </U>Time<!U>.";
27 mesg[1] = "<C>When this button is picked the current time is";
28 mesg[2] = "<C>displayed on the screen in a popup window.";
29 popupLabel (ScreenOf (dialog), mesg, 3);
30 }
31 else if (dialog->currentButton == 2)
32 {
33 mesg[0] = "<C></U>Help for </U>Date<!U>.";
34 mesg[1] = "<C>When this button is picked the current date is";
35 mesg[2] = "<C>displayed on the screen in a popup window.";
36 popupLabel (ScreenOf (dialog), mesg, 3);
37 }
38 else if (dialog->currentButton == 3)
39 {
40 mesg[0] = "<C></U>Help for </U>Quit<!U>.";
41 mesg[1] = "<C>When this button is picked the dialog box is exited.";
42 popupLabel (ScreenOf (dialog), mesg, 2);
43 }
44 return (FALSE);
45 }
46
47 int main(int argc, char **argv)
48 {
49 /* Declare variables. */
50 CDKSCREEN *cdkscreen;
51 CDKDIALOG *question;
52 WINDOW *cursesWin;
53 char *buttons[40];
54 char *message[40];
55 char *info[5];
56 char *loginName;
57 char temp[256];
58 int selection;
59 time_t clck;
60 struct tm *currentTime;
61
62 CDK_PARAMS params;
63
64 CDKparseParams(argc, argv, &params, CDK_MIN_PARAMS);
65
66 /* Set up CDK. */
67 cursesWin = initscr ();
68 cdkscreen = initCDKScreen (cursesWin);
69
70 /* Start color. */
71 initCDKColor ();
72
73 /* Set up the dialog box. */
74 message[0] = "<C></U>Simple Command Interface";
75 message[1] = "Pick the command you wish to run.";
76 message[2] = "<C>Press </R>?<!R> for help.";
77 buttons[0] = "Who";
78 buttons[1] = "Time";
79 buttons[2] = "Date";
80 buttons[3] = "Quit";
81
82 /* Create the dialog box. */
83 question = newCDKDialog (cdkscreen,
84 CDKparamValue(&params, 'X', CENTER),
85 CDKparamValue(&params, 'Y', CENTER),
86 message, 3, buttons, 4, A_REVERSE,
87 TRUE,
88 CDKparamValue(&params, 'N', TRUE),
89 CDKparamValue(&params, 'S', FALSE));
90
91 /* Check if we got a null value back. */
92 if (question == (CDKDIALOG *) 0)
93 {
94 destroyCDKScreen (cdkscreen);
95
96 /* End curses... */
97 endCDK ();
98
99 /* Spit out a message. */
100 printf ("Oops. Can't seem to create the dialog box. ");
101 printf ("Is the window too small?\n");
102 ExitProgram (EXIT_FAILURE);
103 }
104
105 /* Create the key binding. */
106 bindCDKObject (vDIALOG, question, '?', dialogHelpCB, 0);
107
108 /* Activate the dialog box. */
109 selection = 0;
110 while (selection != 3)
111 {
112 /* Get the users button selection. */
113 selection = activateCDKDialog (question, (chtype *) 0);
114
115 /* Check the results. */
116 if (selection == 0)
117 {
118 /* Get the users login name. */
119 info[0] = "<C> </U>Login Name<!U> ";
120 loginName = getlogin ();
121 if (loginName == (char *)0)
122 {
123 strcpy (temp, "<C></R>Unknown");
124 }
125 else
126 {
127 sprintf (temp, "<C><%.*s>", (int)(sizeof(temp) - 10), loginName);
128 }
129 info[1] = copyChar (temp);
130 popupLabel (ScreenOf (question), info, 2);
131 freeChar (info[1]);
132 }
133 else if (selection == 1)
134 {
135 /* Print out the time. */
136 time (&clck);
137 currentTime = localtime (&clck);
138 sprintf (temp, "<C>%2d:%02d:%02d",
139 currentTime->tm_hour,
140 currentTime->tm_min,
141 currentTime->tm_sec);
142 info[0] = "<C> </U>Current Time<!U> ";
143 info[1] = copyChar (temp);
144 popupLabel (ScreenOf (question), info, 2);
145 freeChar (info[1]);
146 }
147 else if (selection == 2)
148 {
149 /* Print out the date. */
150 time (&clck);
151 currentTime = localtime (&clck);
152 sprintf (temp, "<C>%d/%02d/%02d",
153 currentTime->tm_mday,
154 currentTime->tm_mon + 1,
155 currentTime->tm_year % 100);
156 info[0] = "<C> </U>Current Date<!U> ";
157 info[1] = copyChar (temp);
158 popupLabel (ScreenOf (question), info, 2);
159 freeChar (info[1]);
160 }
161 }
162
163 /* Clean up. */
164 destroyCDKDialog (question);
165 destroyCDKScreen (cdkscreen);
166 endCDK ();
167 ExitProgram (EXIT_SUCCESS);
168 }
+0
-41
examples/buttonbox less more
0 #!/usr/bin/perl -w
1 # $Id: buttonbox,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Buttonbox Widget.
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Create the buttonbox buttons.
14 my @buttons = ("</3>Button 0<!3>",
15 "</4>Button 1<!4>",
16 "</5>Button 2<!5>",
17 "</6>Button 3<!6>");
18
19 # Create the buttonbox object.
20 my $buttonbox = new Cdk::Buttonbox ( 'Buttons' => \@buttons,
21 'Height' => 1,
22 'Width' => 50,
23 'Cols' => 4,
24 'Rows' => 1);
25
26 # Activate the object.
27 my $button = $buttonbox->activate();
28
29 # Check the results.
30 if (!defined $button)
31 {
32 popupLabel (["<C>Escape hit. No button selected."]);
33 }
34 else
35 {
36 popupLabel (["<C>You selected button $button"]);
37 }
38
39 # Exit Cdk.
40 Cdk::end();
0 /* $Id: buttonbox_ex.c,v 1.18 2005/12/30 09:50:48 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "buttonbox_ex";
6 #endif
7
8 static BINDFN_PROTO (entryCB);
9
10 /*
11 * This program demonstrates the Cdk buttonbox widget.
12 */
13 int main (void)
14 {
15 /* Declare variables. */
16 CDKSCREEN *cdkscreen = 0;
17 CDKBUTTONBOX *buttonWidget = 0;
18 CDKENTRY *entry = 0;
19 WINDOW *cursesWin = 0;
20 char *buttons[] = {" OK ", " Cancel "};
21 char *info = 0;
22 int selection;
23
24 /* Set up CDK. */
25 cursesWin = initscr ();
26 cdkscreen = initCDKScreen (cursesWin);
27
28 /* Start color. */
29 initCDKColor ();
30
31 /* Create the entry widget. */
32 entry = newCDKEntry (cdkscreen, CENTER, CENTER,
33 "<C>Enter a name", "Name ", A_NORMAL, '.', vMIXED,
34 40, 0, 256, TRUE, FALSE);
35 if (entry == 0)
36 {
37 destroyCDKScreen (cdkscreen);
38 endCDK();
39
40 fprintf(stderr, "Cannot create entry-widget\n");
41 ExitProgram (EXIT_FAILURE);
42 }
43
44
45 /* Create the button box widget. */
46 buttonWidget = newCDKButtonbox (cdkscreen,
47 getbegx (entry->win),
48 getbegy (entry->win) + entry->boxHeight - 1,
49 1, entry->boxWidth - 1,
50 0, 1, 2,
51 buttons, 2, A_REVERSE,
52 TRUE, FALSE);
53 if (buttonWidget == 0)
54 {
55 destroyCDKScreen (cdkscreen);
56 endCDK();
57
58 fprintf(stderr, "Cannot create buttonbox-widget\n");
59 ExitProgram (EXIT_FAILURE);
60 }
61
62 /* Set the lower left and right characters of the box. */
63 setCDKEntryLLChar (entry, ACS_LTEE);
64 setCDKEntryLRChar (entry, ACS_RTEE);
65 setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
66 setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
67
68 /*
69 * Bind the Tab key in the entry field to send a
70 * Tab key to the button box widget.
71 */
72 bindCDKObject (vENTRY, entry, KEY_TAB, entryCB, buttonWidget);
73
74 /* Activate the entry field. */
75 drawCDKButtonbox (buttonWidget, TRUE);
76 info = copyChar (activateCDKEntry (entry, 0));
77 selection = buttonWidget->currentButton;
78
79 /* Clean up. */
80 destroyCDKButtonbox (buttonWidget);
81 destroyCDKEntry (entry);
82 destroyCDKScreen (cdkscreen);
83 endCDK ();
84
85 /* Spit out some info. */
86 printf ("You typed in (%s) and selected button (%s)\n",
87 (info != 0) ? info : "<null>",
88 buttons[selection]);
89
90 freeChar (info);
91 ExitProgram (EXIT_SUCCESS);
92 }
93
94 static int entryCB (EObjectType cdktype GCC_UNUSED,
95 void *object GCC_UNUSED,
96 void *clientData, chtype key)
97 {
98 CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *) clientData;
99 injectCDKButtonbox (buttonbox, key);
100 return (TRUE);
101 }
+0
-21
examples/calendar less more
0 #!/usr/bin/perl -w
1 # $Id: calendar,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Calendar Widget
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Create the celendar object.
14 my $calendar = new Cdk::Calendar ();
15
16 # Activate the object.
17 my $ret = $calendar->activate();
18
19 # Exit Cdk.
20 Cdk::end();
0 /* $Id: calendar_ex.c,v 1.13 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "calendar_ex";
6 #endif
7
8 static BINDFN_PROTO(createCalendarMarkCB);
9 static BINDFN_PROTO(removeCalendarMarkCB);
10
11 /*
12 * This program demonstrates the Cdk calendar widget.
13 */
14 int main (int argc, char **argv)
15 {
16 /* Declare variables. */
17 CDKSCREEN *cdkscreen = 0;
18 CDKCALENDAR *calendar = 0;
19 WINDOW *cursesWin = 0;
20 char *mesg[5], temp[256];
21 struct tm *dateInfo;
22 time_t clck, retVal;
23
24 CDK_PARAMS params;
25 char *title;
26 int day;
27 int month;
28 int year;
29
30 /*
31 * Get the current dates and set the default values for
32 * the day/month/year values for the calendar.
33 */
34 time (&clck);
35 dateInfo = localtime (&clck);
36
37 CDKparseParams(argc, argv, &params, "d:m:y:t:" CDK_MIN_PARAMS);
38 day = CDKparamNumber2(&params, 'd', dateInfo->tm_mday);
39 month = CDKparamNumber2(&params, 'm', dateInfo->tm_mon + 1);
40 year = CDKparamNumber2(&params, 'y', dateInfo->tm_year + 1900);
41 title = CDKparamString2(&params, 't', "<C></U>CDK Calendar Widget\n<C>Demo");
42
43 /* Set up CDK. */
44 cursesWin = initscr();
45 cdkscreen = initCDKScreen (cursesWin);
46
47 /* Start CDK Colors. */
48 initCDKColor();
49
50 /* Create the calendar widget. */
51 calendar = newCDKCalendar (cdkscreen,
52 CDKparamValue(&params, 'X', CENTER),
53 CDKparamValue(&params, 'Y', CENTER),
54 title, day, month, year,
55 COLOR_PAIR(16)|A_BOLD,
56 COLOR_PAIR(24)|A_BOLD,
57 COLOR_PAIR(32)|A_BOLD,
58 COLOR_PAIR(40)|A_REVERSE,
59 CDKparamValue(&params, 'N', TRUE),
60 CDKparamValue(&params, 'S', FALSE));
61
62 /* Is the widget null? */
63 if (calendar == 0)
64 {
65 /* Clean up the memory. */
66 destroyCDKScreen (cdkscreen);
67
68 /* End curses... */
69 endCDK();
70
71 /* Spit out a message. */
72 printf ("Oops. Can't seem to create the calendar. Is the window too small?\n");
73 ExitProgram (EXIT_FAILURE);
74 }
75
76 /* Create a key binding to mark days on the calendar. */
77 bindCDKObject (vCALENDAR, calendar, 'm', createCalendarMarkCB, calendar);
78 bindCDKObject (vCALENDAR, calendar, 'M', createCalendarMarkCB, calendar);
79 bindCDKObject (vCALENDAR, calendar, 'r', removeCalendarMarkCB, calendar);
80 bindCDKObject (vCALENDAR, calendar, 'R', removeCalendarMarkCB, calendar);
81
82 /* Draw the calendar widget. */
83 drawCDKCalendar (calendar, ObjOf(calendar)->box);
84
85 /* Let the user play with the widget. */
86 retVal = activateCDKCalendar (calendar, 0);
87
88 /* Check which day they selected. */
89 if (calendar->exitType == vESCAPE_HIT)
90 {
91 mesg[0] = "<C>You hit escape. No date selected.";
92 mesg[1] = "",
93 mesg[2] = "<C>Press any key to continue.";
94 popupLabel (cdkscreen, mesg, 3);
95 }
96 else if (calendar->exitType == vNORMAL)
97 {
98 mesg[0] = "You selected the following date";
99 sprintf (temp, "<C></B/16>%02d/%02d/%d (dd/mm/yyyy)", calendar->day, calendar->month, calendar->year);
100 mesg[1] = copyChar (temp);
101 mesg[2] = "<C>Press any key to continue.";
102 popupLabel (cdkscreen, mesg, 3);
103 freeChar (mesg[1]);
104 }
105
106 /* Clean up and exit. */
107 destroyCDKCalendar (calendar);
108 destroyCDKScreen (cdkscreen);
109 endCDK();
110 fflush (stdout);
111 printf ("Selected Time: %s\n", ctime(&retVal));
112 ExitProgram (EXIT_SUCCESS);
113 }
114
115 /*
116 * This adds a marker to the calendar.
117 */
118 static int createCalendarMarkCB (EObjectType objectType GCC_UNUSED, void *object, void *clientData GCC_UNUSED, chtype key GCC_UNUSED)
119 {
120 CDKCALENDAR *calendar = (CDKCALENDAR *)object;
121
122 setCDKCalendarMarker (calendar,
123 calendar->day,
124 calendar->month,
125 calendar->year,
126 COLOR_PAIR (5) | A_REVERSE);
127
128 drawCDKCalendar (calendar, ObjOf(calendar)->box);
129 return (FALSE);
130 }
131
132 /*
133 * This removes a marker from the calendar.
134 */
135 static int removeCalendarMarkCB (EObjectType objectType GCC_UNUSED, void *object, void *clientData GCC_UNUSED, chtype key GCC_UNUSED)
136 {
137 CDKCALENDAR *calendar = (CDKCALENDAR *)object;
138
139 removeCDKCalendarMarker (calendar,
140 calendar->day,
141 calendar->month,
142 calendar->year);
143
144 drawCDKCalendar (calendar, ObjOf(calendar)->box);
145 return (FALSE);
146 }
0 /* $Id: cdkscreen_ex.c,v 1.6 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 /*
5 * This demonstrates how to create four different Cdk
6 * screens and flip between them.
7 */
8
9 #ifdef HAVE_XCURSES
10 char *XCursesProgramName = "cdkscreen_ex";
11 #endif
12
13 int main (void)
14 {
15 /* Declare vars. */
16 WINDOW *cursesWindow;
17 CDKSCREEN *cdkScreen1, *cdkScreen2;
18 CDKSCREEN *cdkScreen3, *cdkScreen4;
19 CDKSCREEN *cdkScreen5;
20 CDKLABEL *label1, *label2;
21 CDKLABEL *label3, *label4;
22 CDKDIALOG *dialog;
23 char *title1Mesg[4], *title2Mesg[4];
24 char *title3Mesg[4], *title4Mesg[4];
25 char *dialogMesg[10];
26 char *buttons[] = {"Continue", "Exit"};
27 int answer;
28
29 /* Create the curses window. */
30 cursesWindow = initscr();
31
32 /* Create the two screens. */
33 cdkScreen1 = initCDKScreen (cursesWindow);
34 cdkScreen2 = initCDKScreen (cursesWindow);
35 cdkScreen3 = initCDKScreen (cursesWindow);
36 cdkScreen4 = initCDKScreen (cursesWindow);
37 cdkScreen5 = initCDKScreen (cursesWindow);
38
39 /* Create the first screen. */
40 title1Mesg[0] = "<C><#HL(30)>";
41 title1Mesg[1] = "<C></R>This is the first screen.";
42 title1Mesg[2] = "<C>Hit space to go to the next screen";
43 title1Mesg[3] = "<C><#HL(30)>";
44 label1 = newCDKLabel (cdkScreen1, CENTER, TOP, title1Mesg, 4, FALSE, FALSE);
45
46 /* Create the second screen. */
47 title2Mesg[0] = "<C><#HL(30)>";
48 title2Mesg[1] = "<C></R>This is the second screen.";
49 title2Mesg[2] = "<C>Hit space to go to the next screen";
50 title2Mesg[3] = "<C><#HL(30)>";
51 label2 = newCDKLabel (cdkScreen2, RIGHT, CENTER, title2Mesg, 4, FALSE, FALSE);
52
53 /* Create the third screen. */
54 title3Mesg[0] = "<C><#HL(30)>";
55 title3Mesg[1] = "<C></R>This is the third screen.";
56 title3Mesg[2] = "<C>Hit space to go to the next screen";
57 title3Mesg[3] = "<C><#HL(30)>";
58 label3 = newCDKLabel (cdkScreen3, CENTER, BOTTOM, title3Mesg, 4, FALSE, FALSE);
59
60 /* Create the fourth screen. */
61 title4Mesg[0] = "<C><#HL(30)>";
62 title4Mesg[1] = "<C></R>This is the fourth screen.";
63 title4Mesg[2] = "<C>Hit space to go to the next screen";
64 title4Mesg[3] = "<C><#HL(30)>";
65 label4 = newCDKLabel (cdkScreen4, LEFT, CENTER, title4Mesg, 4, FALSE, FALSE);
66
67 /* Create the fifth screen. */
68 dialogMesg[0] = "<C><#HL(30)>";
69 dialogMesg[1] = "<C>Screen 5";
70 dialogMesg[2] = "<C>This is the last of 5 screens. If you want";
71 dialogMesg[3] = "<C>to continue press the 'Continue' button.";
72 dialogMesg[4] = "<C>Otherwise press the 'Exit' button";
73 dialogMesg[5] = "<C><#HL(30)>";
74 dialog = newCDKDialog (cdkScreen5, CENTER, CENTER,
75 dialogMesg, 6, buttons, 2,
76 A_REVERSE, TRUE, TRUE, FALSE);
77
78 /* Do this for ever... (almost) */
79 for (;;)
80 {
81 /* Draw the first screen. */
82 drawCDKScreen (cdkScreen1);
83 waitCDKLabel (label1, ' ');
84 eraseCDKScreen (cdkScreen1);
85
86 /* Draw the second screen. */
87 drawCDKScreen (cdkScreen2);
88 waitCDKLabel (label2, ' ');
89 eraseCDKScreen (cdkScreen2);
90
91 /* Draw the third screen. */
92 drawCDKScreen (cdkScreen3);
93 waitCDKLabel (label3, ' ');
94 eraseCDKScreen (cdkScreen3);
95
96 /* Draw the fourth screen. */
97 drawCDKScreen (cdkScreen4);
98 waitCDKLabel (label4, ' ');
99 eraseCDKScreen (cdkScreen4);
100
101 /* Draw the fourth screen. */
102 drawCDKScreen (cdkScreen5);
103 answer = activateCDKDialog (dialog, 0);
104
105 /* Check the users answer. */
106 if (answer == 1)
107 {
108 destroyCDKLabel (label1);
109 destroyCDKLabel (label2);
110 destroyCDKLabel (label3);
111 destroyCDKLabel (label4);
112 destroyCDKDialog (dialog);
113 destroyCDKScreen (cdkScreen1);
114 destroyCDKScreen (cdkScreen2);
115 destroyCDKScreen (cdkScreen3);
116 destroyCDKScreen (cdkScreen4);
117 destroyCDKScreen (cdkScreen5);
118 endCDK();
119 ExitProgram (EXIT_SUCCESS);
120 }
121 }
122 }
0 dnl
1 dnl Process this file with autoconf to produce a configure script.
2 dnl
3 AC_INIT(CDKDemo)
4
5 dnl
6 dnl Checks for programs.
7 dnl
8 AC_PROG_CC
9
10 dnl
11 dnl Put -Wall on compile line if we are using gcc or g++
12 dnl
13 if test "$ac_cv_prog_CC" = "gcc"; then
14 CFLAGS="$CFLAGS -Wall"
15 fi
16 if test "$ac_cv_prog_CC" = "g++"; then
17 CFLAGS="$CFLAGS -Wall"
18 fi
19
20 dnl
21 dnl Checks for libraries.
22 dnl
23 dnl -lncurses -lm -lcdk -L..
24 AC_CHECK_LIB(ncurses, start_color)
25
26 AC_OUTPUT(Makefile)
+0
-62
examples/dialog less more
0 #!/usr/bin/perl -w
1 # $Id: dialog,v 1.3 2002/07/24 10:04:33 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Dialog Widget.
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Create the dialog buttons.
14 my @buttons = ("</3>Button 0<!3>",
15 "</4>Button 1<!4>",
16 "</5>Button 2<!5>",
17 "</6>Button 3<!6>");
18
19 # Create the dialog message.
20 my @mesg = ("<C></2>This should be centered<!2>",
21 "<L></7>This should be on the left.<!7>",
22 "<R></3>This should be on the right.<!3>");
23
24 # Create the dialog object.
25 my $dialog = new Cdk::Dialog ('Message' => \@mesg,
26 'Buttons' => \@buttons,
27 'Xpos' => "CENTER",
28 'Ypos' => "CENTER",
29 'Highlight' => "A_REVERSE");
30
31 # Create a key binding.
32 $dialog->bind ('Key' => '?', 'Function' => sub {main::callback();});
33
34 # Activate the object.
35 my $button = $dialog->activate();
36
37 # Check the results.
38 if (!defined $button)
39 {
40 popupLabel (["<C>Escape hit. No button selected."]);
41 }
42 else
43 {
44 popupLabel (["<C>You selected button $button"]);
45 }
46
47 # Exit Cdk.
48 Cdk::end();
49
50 #
51 # This is the callback function to the dialog widget.
52 #
53 sub callback
54 {
55 my $label = new Cdk::Label ('Message' => ["<C>This is the",
56 "<C>callback to the",
57 "<C>dialog widget."]);
58 $label->draw();
59 $label->wait();
60 return 1;
61 }
0 /* $Id: dialog_ex.c,v 1.12 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "dialog_ex";
6 #endif
7
8 /*
9 * This program demonstrates the Cdk dialog widget.
10 */
11 int main(int argc, char **argv)
12 {
13 /* Declare variables. */
14 CDKSCREEN *cdkscreen = 0;
15 CDKDIALOG *question = 0;
16 WINDOW *cursesWin = 0;
17 char *buttons[] = {"</B/24>Ok", "</B16>Cancel"};
18 char *message[10], *mesg[3], temp[100];
19 int selection;
20
21 CDK_PARAMS params;
22
23 CDKparseParams(argc, argv, &params, CDK_MIN_PARAMS);
24
25 /* Set up CDK. */
26 cursesWin = initscr();
27 cdkscreen = initCDKScreen (cursesWin);
28
29 /* Start color. */
30 initCDKColor();
31
32 /* Create the message within the dialog box. */
33 message[0] = "<C></U>Dialog Widget Demo";
34 message[1] = " ";
35 message[2] = "<C>The dialog widget allows the programmer to create";
36 message[3] = "<C>a popup dialog box with buttons. The dialog box";
37 message[4] = "<C>can contain </B/32>colours<!B!32>, </R>character attributes<!R>";
38 message[5] = "<R>and even be right justified.";
39 message[6] = "<L>and left.";
40
41 /* Create the dialog box. */
42 question = newCDKDialog (cdkscreen,
43 CDKparamValue(&params, 'X', CENTER),
44 CDKparamValue(&params, 'Y', CENTER),
45 message, 7, buttons, 2,
46 COLOR_PAIR(2)|A_REVERSE,
47 TRUE,
48 CDKparamValue(&params, 'N', TRUE),
49 CDKparamValue(&params, 'S', FALSE));
50
51 /* Check if we got a null value back. */
52 if (question == 0)
53 {
54 /* Shut down Cdk. */
55 destroyCDKScreen (cdkscreen);
56 endCDK();
57
58 /* Spit out a message. */
59 printf ("Oops. Can't seem to create the dialog box. Is the window too small?\n");
60 ExitProgram (EXIT_FAILURE);
61 }
62
63 /* Activate the dialog box. */
64 selection = activateCDKDialog (question, 0);
65
66 /* Tell them what was selected. */
67 if (question->exitType == vESCAPE_HIT)
68 {
69 mesg[0] = "<C>You hit escape. No button selected.";
70 mesg[1] = "",
71 mesg[2] = "<C>Press any key to continue.";
72 popupLabel (cdkscreen, mesg, 3);
73 }
74 else if (question->exitType == vNORMAL)
75 {
76 sprintf (temp, "<C>You selected button #%d", selection);
77 mesg[0] = temp;
78 mesg[1] = "";
79 mesg[2] = "<C>Press any key to continue.";
80 popupLabel (cdkscreen, mesg, 3);
81 }
82
83 /* Clean up. */
84 destroyCDKDialog (question);
85 destroyCDKScreen (cdkscreen);
86 endCDK();
87 ExitProgram (EXIT_SUCCESS);
88 }
+0
-34
examples/entry less more
0 #!/usr/bin/perl -w
1 # $Id: entry,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Entry Widget.
6
7 #
8 # Load in the Cdk Extension.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Create a new entry object.
14 my $entry = new Cdk::Entry ('Label' => "Type Anything: ",
15 'Width' => 20,
16 'Min' => 0,
17 'Max' => 256);
18
19 # Activate the object.
20 my $info = $entry->activate();
21
22 # Check the results.
23 if (!defined $info)
24 {
25 popupLabel (["<C>You hit escape, nothing returned."]);
26 }
27 else
28 {
29 popupLabel (["<C>You typed in ($info)"]);
30 }
31
32 # Exit Cdk.
33 Cdk::end();
0 /* $Id: entry_ex.c,v 1.15 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "entry_ex";
6 #endif
7
8 static BINDFN_PROTO(XXXCB);
9
10 /*
11 * This demonstrates the Cdk entry field widget.
12 */
13 int main(int argc, char **argv)
14 {
15 /* Declare local variables. */
16 CDKSCREEN *cdkscreen = 0;
17 CDKENTRY *directory = 0;
18 WINDOW *cursesWin = 0;
19 char *title = "<C>Enter a\n<C>directory name.";
20 char *label = "</U/5>Directory:<!U!5>";
21 char *info, *mesg[10], temp[256];
22
23 CDK_PARAMS params;
24
25 CDKparseParams(argc, argv, &params, CDK_MIN_PARAMS);
26
27 /* Set up CDK. */
28 cursesWin = initscr();
29 cdkscreen = initCDKScreen (cursesWin);
30
31 /* Start CDK colors. */
32 initCDKColor();
33
34 /* Create the entry field widget. */
35 directory = newCDKEntry (cdkscreen,
36 CDKparamValue(&params, 'X', CENTER),
37 CDKparamValue(&params, 'Y', CENTER),
38 title, label, A_NORMAL, '.', vMIXED,
39 40, 0, 256,
40 CDKparamValue(&params, 'N', TRUE),
41 CDKparamValue(&params, 'S', FALSE));
42 bindCDKObject (vENTRY, directory, '?', XXXCB, 0);
43
44 /* Is the widget null? */
45 if (directory == 0)
46 {
47 /* Clean up. */
48 destroyCDKScreen (cdkscreen);
49 endCDK();
50
51 /* Print out a little message. */
52 printf ("Oops. Can't seem to create the entry box. Is the window too small?\n");
53 ExitProgram (EXIT_FAILURE);
54 }
55
56 /* Draw the screen. */
57 refreshCDKScreen (cdkscreen);
58
59 /*
60 * Pass in whatever was given off of the command line. Notice we
61 * don't check if argv[1] is null or not. The function setCDKEntry
62 * already performs any needed checks.
63 */
64 setCDKEntry (directory, argv[optind], 0, 256, TRUE);
65
66 /* Activate the entry field. */
67 info = activateCDKEntry (directory, 0);
68
69 /* Tell them what they typed. */
70 if (directory->exitType == vESCAPE_HIT)
71 {
72 mesg[0] = "<C>You hit escape. No information passed back.";
73 mesg[1] = "",
74 mesg[2] = "<C>Press any key to continue.";
75
76 destroyCDKEntry (directory);
77
78 popupLabel (cdkscreen, mesg, 3);
79 }
80 else if (directory->exitType == vNORMAL)
81 {
82 mesg[0] = "<C>You typed in the following";
83 sprintf (temp, "<C>(%.*s)", (int)(sizeof(temp) - 10), info);
84 mesg[1] = copyChar (temp);
85 mesg[2] = "";
86 mesg[3] = "<C>Press any key to continue.";
87
88 destroyCDKEntry (directory);
89
90 popupLabel (cdkscreen, mesg, 4);
91 freeChar (mesg[1]);
92 }
93 else
94 {
95 destroyCDKEntry (directory);
96 }
97
98 /* Clean up and exit. */
99 destroyCDKScreen (cdkscreen);
100 endCDK();
101 ExitProgram (EXIT_SUCCESS);
102 }
103
104 static int XXXCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData GCC_UNUSED, chtype key GCC_UNUSED)
105 {
106 return (TRUE);
107 }
0 /* $Id: fscale_ex.c,v 1.6 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "fscale_ex";
6 #endif
7
8 static float myFloatParam (CDK_PARAMS *params, int code, float missing)
9 {
10 char *opt = CDKparamString (params, code);
11 float result = missing;
12
13 if (opt != 0)
14 result = atof(opt);
15 return result;
16 }
17
18 /*
19 * This program demonstrates the Cdk scale widget.
20 */
21 int main (int argc, char **argv)
22 {
23 /* Declare variables. */
24 CDKSCREEN *cdkscreen = 0;
25 CDKFSCALE *scale = 0;
26 WINDOW *cursesWin = 0;
27 char *title = "<C>Select a value";
28 char *label = "</5>Current value";
29 char temp[256], *mesg[5];
30 float selection;
31
32 CDK_PARAMS params;
33 float high;
34 float inc;
35 float low;
36
37 CDKparseParams(argc, argv, &params, "h:i:l:w:" CDK_MIN_PARAMS);
38 high = myFloatParam(&params, 'h', 2.4);
39 inc = myFloatParam(&params, 'i', 0.2);
40 low = myFloatParam(&params, 'l', -1.2);
41
42 /* Set up CDK. */
43 cursesWin = initscr();
44 cdkscreen = initCDKScreen (cursesWin);
45
46 /* Start CDK Colors. */
47 initCDKColor();
48
49 /* Create the scale. */
50 scale = newCDKFScale (cdkscreen,
51 CDKparamValue(&params, 'X', CENTER),
52 CDKparamValue(&params, 'Y', CENTER),
53 title, label, A_NORMAL,
54 CDKparamNumber2(&params, 'w', 10),
55 low, low, high,
56 inc, (inc*2.), 1,
57 CDKparamValue(&params, 'N', TRUE),
58 CDKparamValue(&params, 'S', FALSE));
59
60 /* Is the scale null? */
61 if (scale == 0)
62 {
63 /* Exit CDK. */
64 destroyCDKScreen (cdkscreen);
65 endCDK();
66
67 /* Print out a message. */
68 printf ("Oops. Can't make the scale widget. Is the window too small?\n");
69 ExitProgram (EXIT_FAILURE);
70 }
71
72 /* Activate the scale. */
73 selection = activateCDKFScale (scale, 0);
74
75 /* Check the exit value of the scale widget. */
76 if (scale->exitType == vESCAPE_HIT)
77 {
78 mesg[0] = "<C>You hit escape. No value selected.";
79 mesg[1] = "",
80 mesg[2] = "<C>Press any key to continue.";
81 popupLabel (cdkscreen, mesg, 3);
82 }
83 else if (scale->exitType == vNORMAL)
84 {
85 sprintf (temp, "<C>You selected %f", selection);
86 mesg[0] = copyChar (temp);
87 mesg[1] = "",
88 mesg[2] = "<C>Press any key to continue.";
89 popupLabel (cdkscreen, mesg, 3);
90 freeChar (mesg[0]);
91 }
92
93 /* Clean up. */
94 destroyCDKFScale (scale);
95 destroyCDKScreen (cdkscreen);
96 endCDK();
97 ExitProgram (EXIT_SUCCESS);
98 }
+0
-35
examples/fselect less more
0 #!/usr/bin/perl -w
1 # $Id: fselect,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk file selector widget.
6
7 #
8 # Load in the Cdk Extension.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Create the file selector.
14 my $fselect = new Cdk::Fselect ('Label' => "</B/16>Filename:",
15 'Filler' => "</B/24>_",
16 'Height' => 0,
17 'Width' => 0);
18
19 # Activate the object.
20 $fselect->set ('ULChar' => "#");
21 my $filename = $fselect->activate();
22
23 # Check the results.
24 if (! defined $filename)
25 {
26 popupLabel (["<C>You hit escape. No file selected."]);
27 }
28 else
29 {
30 popupLabel (["<C>You selected the following file", "<C>($filename)"]);
31 }
32
33 # Exit Cdk.
34 Cdk::end();
0 /* $Id: fselect_ex.c,v 1.22 2006/05/07 23:06:12 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "fselect_ex";
6 #endif
7
8 /*
9 * This program demonstrates the file selector and the viewer widget.
10 */
11 static CDKSCREEN *cdkscreen = 0;
12 static char **myUserList = 0;
13 static int userSize;
14
15 typedef struct
16 {
17 int deleted; /* index in current list which is deleted */
18 int original; /* index in myUserList[] of deleted item */
19 int position; /* position before delete */
20 int topline; /* top-line before delete */
21 } UNDO;
22
23 static UNDO *myUndoList;
24 static int undoSize;
25
26 #define CB_PARAMS EObjectType cdktype GCC_UNUSED, void* object GCC_UNUSED, void* clientdata GCC_UNUSED, chtype key GCC_UNUSED
27
28 static void fill_undo (CDKFSELECT *widget, int deleted, char *data)
29 {
30 int top = getCDKScrollCurrentTop (widget->scrollField);
31 int item = getCDKFselectCurrentItem (widget);
32 int n;
33
34 myUndoList[undoSize].deleted = deleted;
35 myUndoList[undoSize].topline = top;
36 myUndoList[undoSize].original = -1;
37 myUndoList[undoSize].position = item;
38 for (n = 0; n < userSize; ++n)
39 {
40 if (!strcmp (myUserList[n], data))
41 {
42 myUndoList[undoSize].original = n;
43 break;
44 }
45 }
46 ++undoSize;
47 }
48
49 static int do_delete (CB_PARAMS)
50 {
51 CDKFSELECT *widget = (CDKFSELECT *)clientdata;
52 int size;
53 char **list = getCDKFselectContents (widget, &size);
54 int result = FALSE;
55
56 if (size)
57 {
58 int save = getCDKScrollCurrentTop (widget->scrollField);
59 int first = getCDKFselectCurrentItem (widget);
60 int n;
61
62 fill_undo (widget, first, list[first]);
63 for (n = first; n < size; ++n)
64 list[n] = list[n + 1];
65 setCDKFselectContents (widget, list, size - 1);
66 setCDKScrollCurrentTop (widget->scrollField, save);
67 setCDKFselectCurrentItem (widget, first);
68 drawCDKFselect (widget, BorderOf (widget));
69 result = TRUE;
70 }
71 return result;
72 }
73
74 static int do_delete1 (CB_PARAMS)
75 {
76 CDKFSELECT *widget = (CDKFSELECT *)clientdata;
77 int size;
78 char **list = getCDKFselectContents (widget, &size);
79 int result = FALSE;
80
81 if (size)
82 {
83 int save = getCDKScrollCurrentTop (widget->scrollField);
84 int first = getCDKFselectCurrentItem (widget);
85
86 if (first-- > 0)
87 {
88 int n;
89
90 fill_undo (widget, first, list[first]);
91 for (n = first; n < size; ++n)
92 list[n] = list[n + 1];
93 setCDKFselectContents (widget, list, size - 1);
94 setCDKScrollCurrentTop (widget->scrollField, save);
95 setCDKFselectCurrentItem (widget, first);
96 drawCDKFselect (widget, BorderOf (widget));
97 result = TRUE;
98 }
99 }
100 return result;
101 }
102
103 static int do_help (CB_PARAMS)
104 {
105 static char *message[] =
106 {
107 "File Selection tests:",
108 "",
109 "F1 = help (this message)",
110 "F2 = delete current item",
111 "F3 = delete previous item",
112 "F4 = reload all items",
113 "F5 = undo deletion",
114 0
115 };
116 popupLabel (cdkscreen, message, CDKcountStrings (message));
117 return TRUE;
118 }
119
120 static int do_reload (CB_PARAMS)
121 {
122 int result = FALSE;
123
124 if (userSize)
125 {
126 CDKFSELECT *widget = (CDKFSELECT *)clientdata;
127 setCDKFselectContents (widget, myUserList, userSize);
128 setCDKFselectCurrentItem (widget, 0);
129 drawCDKFselect (widget, BorderOf (widget));
130 result = TRUE;
131 }
132 return result;
133 }
134
135 static int do_undo (CB_PARAMS)
136 {
137 int result = FALSE;
138
139 if (undoSize > 0)
140 {
141 CDKFSELECT *widget = (CDKFSELECT *)clientdata;
142 int size;
143 int n;
144 char **oldlist = getCDKFselectContents (widget, &size);
145 char **newlist = (char **)malloc ((++size + 1) * sizeof (char *));
146
147 --undoSize;
148 newlist[size] = 0;
149 for (n = size - 1; n > myUndoList[undoSize].deleted; --n)
150 {
151 newlist[n] = copyChar (oldlist[n - 1]);
152 }
153 newlist[n--] = copyChar (myUserList[myUndoList[undoSize].original]);
154 while (n >= 0)
155 {
156 newlist[n] = copyChar (oldlist[n]);
157 --n;
158 }
159 setCDKFselectContents (widget, newlist, size);
160 setCDKScrollCurrentTop (widget->scrollField, myUndoList[undoSize].topline);
161 setCDKFselectCurrentItem (widget, myUndoList[undoSize].position);
162 drawCDKFselect (widget, BorderOf (widget));
163 result = TRUE;
164 }
165 return result;
166 }
167
168 int main (int argc, char **argv)
169 {
170 CDKVIEWER *example = 0;
171 CDKFSELECT *fSelect = 0;
172 WINDOW *cursesWin = 0;
173 char *title = "<C>Pick\n<C>A\n<C>File";
174 char *label = "File: ";
175 char **info = 0;
176 char *button[5], *filename, vTitle[256], *mesg[4], temp[256];
177 int selected, lines;
178
179 CDK_PARAMS params;
180 char *directory;
181
182 CDKparseParams (argc, argv, &params, "d:" CDK_CLI_PARAMS);
183 directory = CDKparamString2 (&params, 'd', ".");
184
185 /* Create the viewer buttons. */
186 button[0] = "</5><OK><!5>";
187 button[1] = "</5><Cancel><!5>";
188
189 /* Set up CDK. */
190 cursesWin = initscr ();
191 cdkscreen = initCDKScreen (cursesWin);
192
193 /* Start color. */
194 initCDKColor ();
195
196 /* Get the filename. */
197 fSelect = newCDKFselect (cdkscreen,
198 CDKparamValue (&params, 'X', CENTER),
199 CDKparamValue (&params, 'Y', CENTER),
200 CDKparamValue (&params, 'H', 20),
201 CDKparamValue (&params, 'W', 65),
202 title, label, A_NORMAL, '_', A_REVERSE,
203 "</5>", "</48>", "</N>", "</N>",
204 CDKparamValue (&params, 'N', TRUE),
205 CDKparamValue (&params, 'S', FALSE));
206
207 if (fSelect == 0)
208 {
209 destroyCDKScreen (cdkscreen);
210 endCDK ();
211
212 fprintf (stderr, "Cannot create widget\n");
213 ExitProgram (EXIT_FAILURE);
214 }
215
216 bindCDKObject (vFSELECT, fSelect, '?', do_help, NULL);
217 bindCDKObject (vFSELECT, fSelect, KEY_F1, do_help, NULL);
218 bindCDKObject (vFSELECT, fSelect, KEY_F2, do_delete, fSelect);
219 bindCDKObject (vFSELECT, fSelect, KEY_F3, do_delete1, fSelect);
220 bindCDKObject (vFSELECT, fSelect, KEY_F4, do_reload, fSelect);
221 bindCDKObject (vFSELECT, fSelect, KEY_F5, do_undo, fSelect);
222
223 /*
224 * Set the starting directory. This is not necessary because when
225 * the file selector starts it uses the present directory as a default.
226 */
227 setCDKFselect (fSelect, directory, A_NORMAL, ' ', A_REVERSE,
228 "</5>", "</48>", "</N>", "</N>", ObjOf (fSelect)->box);
229 myUserList = copyCharList (getCDKFselectContents (fSelect, &userSize));
230 myUndoList = (UNDO *) malloc (userSize * sizeof (UNDO));
231 undoSize = 0;
232
233 /* Activate the file selector. */
234 filename = activateCDKFselect (fSelect, 0);
235
236 /* Check how the person exited from the widget. */
237 if (fSelect->exitType == vESCAPE_HIT)
238 {
239 /* Pop up a message for the user. */
240 mesg[0] = "<C>Escape hit. No file selected.";
241 mesg[1] = "";
242 mesg[2] = "<C>Press any key to continue.";
243 popupLabel (cdkscreen, mesg, 3);
244
245 /* Exit CDK. */
246 destroyCDKFselect (fSelect);
247 destroyCDKScreen (cdkscreen);
248 endCDK ();
249
250 ExitProgram (EXIT_SUCCESS);
251 }
252
253 /* Create the file viewer to view the file selected. */
254 example = newCDKViewer (cdkscreen, CENTER, CENTER, 20, -2,
255 button, 2, A_REVERSE, TRUE, FALSE);
256
257 /* Could we create the viewer widget? */
258 if (example == 0)
259 {
260 /* Exit CDK. */
261 destroyCDKFselect (fSelect);
262 destroyCDKScreen (cdkscreen);
263 endCDK ();
264
265 /* Print out a message and exit. */
266 printf ("Oops. Can't seem to create viewer. Is the window too small?\n");
267 ExitProgram (EXIT_SUCCESS);
268 }
269
270 /* Open the file and read the contents. */
271 lines = CDKreadFile (filename, &info);
272 if (lines == -1)
273 {
274 filename = copyChar (filename);
275
276 destroyCDKFselect (fSelect);
277 destroyCDKScreen (cdkscreen);
278 endCDK ();
279
280 printf ("Could not open \"%s\"\n", filename);
281
282 ExitProgram (EXIT_FAILURE);
283 }
284
285 /* Set up the viewer title, and the contents to the widget. */
286 sprintf (vTitle, "<C></B/21>Filename:<!21></22>%20s<!22!B>", filename);
287 setCDKViewer (example, vTitle, info, lines, A_REVERSE, TRUE, TRUE, TRUE);
288
289 CDKfreeStrings (info);
290
291 /* Destroy the file selector widget. */
292 destroyCDKFselect (fSelect);
293
294 /* Activate the viewer widget. */
295 selected = activateCDKViewer (example, 0);
296
297 /* Check how the person exited from the widget. */
298 if (example->exitType == vESCAPE_HIT)
299 {
300 mesg[0] = "<C>Escape hit. No Button selected.";
301 mesg[1] = "";
302 mesg[2] = "<C>Press any key to continue.";
303 popupLabel (cdkscreen, mesg, 3);
304 }
305 else if (example->exitType == vNORMAL)
306 {
307 sprintf (temp, "<C>You selected button %d", selected);
308 mesg[0] = temp;
309 mesg[1] = "";
310 mesg[2] = "<C>Press any key to continue.";
311 popupLabel (cdkscreen, mesg, 3);
312 }
313
314 /* Clean up. */
315 destroyCDKViewer (example);
316 destroyCDKScreen (cdkscreen);
317 endCDK ();
318 ExitProgram (EXIT_SUCCESS);
319 }
0 /* $Id: fslider_ex.c,v 1.1 2005/12/27 19:16:29 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "slider_ex";
6 #endif
7
8 /*
9 * This program demonstrates the Cdk slider widget.
10 */
11 int main (int argc, char **argv)
12 {
13 /* Declare variables. */
14 CDKSCREEN *cdkscreen = 0;
15 CDKFSLIDER *widget = 0;
16 WINDOW *cursesWin = 0;
17 char *title = "<C></U>Enter a value:";
18 char *label = "</B>Current Value:";
19 char temp[256], *mesg[5];
20 float selection;
21
22 CDK_PARAMS params;
23 float high;
24 float inc;
25 float low;
26
27 float scale;
28 int n, digits;
29
30 CDKparseParams(argc, argv, &params, "h:i:l:w:p:" CDK_MIN_PARAMS);
31 digits = CDKparamNumber2(&params, 'p', 0);
32
33 scale = 1.0;
34 for (n = 0; n < digits; ++n) {
35 scale = scale * 10.0;
36 }
37
38 high = CDKparamNumber2(&params, 'h', 100) / scale;
39 inc = CDKparamNumber2(&params, 'i', 1) / scale;
40 low = CDKparamNumber2(&params, 'l', 1) / scale;
41
42 /* Set up CDK. */
43 cursesWin = initscr();
44 cdkscreen = initCDKScreen (cursesWin);
45
46 /* Start CDK Colors. */
47 initCDKColor();
48
49 /* Create the widget. */
50 widget = newCDKFSlider (cdkscreen,
51 CDKparamValue(&params, 'X', CENTER),
52 CDKparamValue(&params, 'Y', CENTER),
53 title, label,
54 A_REVERSE | COLOR_PAIR (29) | ' ',
55 CDKparamNumber2(&params, 'w', 50),
56 low, low, high,
57 inc, (inc*2),
58 digits,
59 CDKparamValue(&params, 'N', TRUE),
60 CDKparamValue(&params, 'S', FALSE));
61
62 /* Is the widget null? */
63 if (widget == 0)
64 {
65 /* Exit CDK. */
66 destroyCDKScreen (cdkscreen);
67 endCDK();
68
69 /* Print out a message. */
70 printf ("Oops. Can't make the widget. Is the window too small?\n");
71 ExitProgram (EXIT_FAILURE);
72 }
73
74 /* Activate the widget. */
75 selection = activateCDKFSlider (widget, 0);
76
77 /* Check the exit value of the widget. */
78 if (widget->exitType == vESCAPE_HIT)
79 {
80 mesg[0] = "<C>You hit escape. No value selected.";
81 mesg[1] = "",
82 mesg[2] = "<C>Press any key to continue.";
83 popupLabel (cdkscreen, mesg, 3);
84 }
85 else if (widget->exitType == vNORMAL)
86 {
87 sprintf (temp, "<C>You selected %.*f", digits, selection);
88 mesg[0] = copyChar (temp);
89 mesg[1] = "",
90 mesg[2] = "<C>Press any key to continue.";
91 popupLabel (cdkscreen, mesg, 3);
92 freeChar (mesg[0]);
93 }
94
95 /* Clean up.*/
96 destroyCDKFSlider (widget);
97 destroyCDKScreen (cdkscreen);
98 endCDK();
99 ExitProgram (EXIT_SUCCESS);
100 }
+0
-37
examples/graph less more
0 #!/usr/bin/perl -w
1 # $Id: graph,v 1.2 2002/07/27 20:12:08 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Graph Widget.
6
7 #
8 # Load in the Cdk Extension.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Create the graph values.
14 my @values = qw (50 0 25 66 41 42 30 49 27);
15 my $chars = "123456789";
16
17 # Create the graph object.
18 my $graph = new Cdk::Graph ('Title' => "<C></3>Total Breakins",
19 'Xtitle' => "<C></2>Count",
20 'Ytitle' => '<C></5>Time Period',
21 'Height' => -4,
22 'Width' => -4);
23
24 # Load the object up.
25 $graph->set ('Values' => \@values,
26 'GraphChars' => $chars,
27 'Box' => "FALSE");
28
29 # Draw the graph.
30 $graph->draw();
31
32 # Wait until the user hits a key.
33 getc(STDIN);
34
35 # End Cdk.
36 Cdk::end();
0 /* $Id: graph_ex.c,v 1.12 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "graph_ex";
6 #endif
7
8 int main(int argc, char **argv)
9 {
10 /* Declare vars. */
11 CDKSCREEN *cdkscreen = 0;
12 CDKGRAPH *graph = 0;
13 CDKLABEL *pausep = 0;
14 WINDOW *cursesWin = 0;
15 char *title = 0;
16 char *xtitle = 0;
17 char *ytitle = 0;
18 char *graphChars = 0;
19 char *mesg[2];
20 int values[20], colors[20];
21 int count;
22
23 CDK_PARAMS params;
24
25 CDKparseParams(argc, argv, &params, CDK_CLI_PARAMS); /* -N, -S unused */
26
27 /* Set up CDK. */
28 cursesWin = initscr();
29 cdkscreen = initCDKScreen (cursesWin);
30
31 /* Start CDK Colors. */
32 initCDKColor();
33
34 /* Create the graph values. */
35 values[0] = 10; colors[0] = 5;
36 values[1] = 15; colors[1] = 5;
37 values[2] = 20; colors[2] = 5;
38 values[3] = 25; colors[3] = 5;
39 values[4] = 30; colors[4] = 5;
40 values[5] = 35; colors[5] = 5;
41 values[6] = 40; colors[6] = 5;
42 values[7] = 45; colors[7] = 5;
43 values[8] = 50; colors[8] = 5;
44 values[9] = 55; colors[9] = 5;
45 count = 10;
46 title = "<C>Test Graph";
47 xtitle = "<C>X AXIS TITLE";
48 ytitle = "<C>Y AXIS TITLE";
49 graphChars = "0123456789";
50
51 /* Create the label values. */
52 mesg[0] = "Press any key when done viewing the graph.";
53
54 /* Create the graph widget. */
55 graph = newCDKGraph (cdkscreen,
56 CDKparamValue(&params, 'X', CENTER),
57 CDKparamValue(&params, 'Y', CENTER),
58 CDKparamValue(&params, 'H', 10),
59 CDKparamValue(&params, 'W', 20),
60 title, xtitle, ytitle);
61
62 /* Is the graph null? */
63 if (graph == 0)
64 {
65 /* Shut down CDK. */
66 destroyCDKScreen (cdkscreen);
67 endCDK();
68
69 /* Print out a message and exit. */
70 printf ("Oops. Can not make the graph widget. Is the window too small?\n");
71 ExitProgram (EXIT_FAILURE);
72 }
73
74 /* Create the label widget. */
75 pausep = newCDKLabel (cdkscreen, CENTER, BOTTOM, mesg, 1, TRUE, FALSE);
76 if (pausep == 0)
77 {
78 /* Shut down CDK. */
79 destroyCDKGraph (graph);
80 destroyCDKScreen (cdkscreen);
81 endCDK();
82
83 /* Print out a message and exit. */
84 printf ("Oops. Can not make the label widget. Is the window too small?\n");
85 ExitProgram (EXIT_FAILURE);
86 }
87
88 /* Set the graph values. */
89 setCDKGraph (graph, values, count, graphChars, FALSE, vPLOT);
90
91 /* Draw the screen. */
92 refreshCDKScreen (cdkscreen);
93 drawCDKGraph (graph, FALSE);
94 drawCDKLabel (pausep, TRUE);
95
96 /* Pause until the user says so... */
97 waitCDKLabel (pausep, 0);
98
99 /* Clean up. */
100 destroyCDKGraph (graph);
101 destroyCDKLabel (pausep);
102 destroyCDKScreen (cdkscreen);
103 endCDK();
104 ExitProgram (EXIT_SUCCESS);
105 }
0 /* $Id: hello_ex.c,v 1.9 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "hello_ex";
6 #endif
7
8 int main(int argc, char **argv)
9 {
10 /* Declare variables. */
11 CDKSCREEN *cdkscreen;
12 CDKLABEL *demo;
13 WINDOW *cursesWin;
14 char *mesg[4];
15
16 CDK_PARAMS params;
17
18 CDKparseParams(argc, argv, &params, CDK_MIN_PARAMS);
19
20 /* Set up CDK. */
21 cursesWin = initscr();
22 cdkscreen = initCDKScreen (cursesWin);
23
24 /* Start CDK Colors. */
25 initCDKColor();
26
27 /* Set the labels up. */
28 mesg[0] = "</5><#UL><#HL(30)><#UR>";
29 mesg[1] = "</5><#VL(10)>Hello World!<#VL(10)>";
30 mesg[2] = "</5><#LL><#HL(30)><#LR>";
31
32 /* Declare the labels. */
33 demo = newCDKLabel (cdkscreen,
34 CDKparamValue(&params, 'X', CENTER),
35 CDKparamValue(&params, 'Y', CENTER),
36 mesg, 3,
37 CDKparamValue(&params, 'N', TRUE),
38 CDKparamValue(&params, 'S', TRUE));
39
40 setCDKLabelBackgroundAttrib (demo, COLOR_PAIR(2));
41
42 /* Is the label null? */
43 if (demo == 0)
44 {
45 /* Clean up the memory. */
46 destroyCDKScreen (cdkscreen);
47
48 /* End curses... */
49 endCDK();
50
51 /* Spit out a message. */
52 printf ("Oops. Can't seem to create the label. Is the window too small?\n");
53 ExitProgram (EXIT_FAILURE);
54 }
55
56 /* Draw the CDK screen. */
57 refreshCDKScreen (cdkscreen);
58 waitCDKLabel (demo, ' ');
59
60 /* Clean up. */
61 destroyCDKLabel (demo);
62 destroyCDKScreen (cdkscreen);
63 endCDK();
64 ExitProgram (EXIT_SUCCESS);
65 }
+0
-45
examples/histogram less more
0 #!/usr/bin/perl -w
1 # $Id: histogram,v 1.3 2002/07/24 10:04:32 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Histogram Widget.
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 my $x;
14
15 #
16 # Create the histogram.
17 #
18 my $histogram = new Cdk::Histogram ('Title' => "<C>Dum De Dummmm",
19 'Height' => 3,
20 'Width' => 0,
21 'Orient' => "HORIZONTAL");
22
23 #
24 # Set some properties of the histogram.
25 #
26 $histogram->set ('StatsType' => "PERCENT",
27 'StatsPos' => "CENTER",
28 'FillerChar' => "</R>.");
29
30 # Set the values.
31 for ($x=1; $x <= 100; $x += 2)
32 {
33 # Set the values of the histogram.
34 $histogram->set ('Value' => $x,
35 'Low' => 1,
36 'High' => 100);
37
38 # Draw the histogram.
39 $histogram->draw ();
40 sleep (1);
41 }
42
43 # Exit Cdk.
44 Cdk::end();
0 /* $Id: histogram_ex.c,v 1.9 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "histogram_ex";
6 #endif
7
8 int main(int argc, char **argv)
9 {
10 /* Declare vars. */
11 CDKSCREEN *cdkscreen = 0;
12 CDKHISTOGRAM *volume = 0;
13 CDKHISTOGRAM *bass = 0;
14 CDKHISTOGRAM *treble = 0;
15 WINDOW *cursesWin = 0;
16 char *volumeTitle = "<C></5>Volume<!5>";
17 char *bassTitle = "<C></5>Bass <!5>";
18 char *trebleTitle = "<C></5>Treble<!5>";
19
20 CDK_PARAMS params;
21 boolean Box;
22
23 CDKparseParams(argc, argv, &params, CDK_CLI_PARAMS);
24 Box = CDKparamValue(&params, 'N', TRUE);
25
26 /* Set up CDK. */
27 cursesWin = initscr();
28 cdkscreen = initCDKScreen (cursesWin);
29
30 /* Start CDK Color. */
31 initCDKColor();
32
33 /* Create the histogram objects. */
34 volume = newCDKHistogram (cdkscreen,
35 CDKparamValue(&params, 'X', 10),
36 CDKparamValue(&params, 'Y', 10),
37 CDKparamValue(&params, 'H', 1),
38 CDKparamValue(&params, 'W', -2),
39 HORIZONTAL, volumeTitle,
40 Box,
41 CDKparamValue(&params, 'S', FALSE));
42 if (volume == 0)
43 {
44 /* Exit CDK. */
45 destroyCDKScreen (cdkscreen);
46 endCDK();
47
48 /* Print out a message and exit. */
49 printf ("Oops. Can not make volume histogram. Is the window big enough??\n");
50 ExitProgram (EXIT_FAILURE);
51 }
52
53 bass = newCDKHistogram (cdkscreen,
54 CDKparamValue(&params, 'X', 10),
55 CDKparamValue(&params, 'Y', 14),
56 CDKparamValue(&params, 'H', 1),
57 CDKparamValue(&params, 'W', -2),
58 HORIZONTAL, bassTitle,
59 Box,
60 CDKparamValue(&params, 'S', FALSE));
61 if (bass == 0)
62 {
63 /* Exit CDK. */
64 destroyCDKHistogram (volume);
65 destroyCDKScreen (cdkscreen);
66 endCDK();
67
68 /* Print out a message and exit. */
69 printf ("Oops. Can not make bass histogram. Is the window big enough??\n");
70 ExitProgram (EXIT_FAILURE);
71 }
72
73 treble = newCDKHistogram (cdkscreen,
74 CDKparamValue(&params, 'X', 10),
75 CDKparamValue(&params, 'Y', 18),
76 CDKparamValue(&params, 'H', 1),
77 CDKparamValue(&params, 'W', -2),
78 HORIZONTAL, trebleTitle,
79 Box,
80 CDKparamValue(&params, 'S', FALSE));
81 if (treble == 0)
82 {
83 /* Exit CDK. */
84 destroyCDKHistogram (volume);
85 destroyCDKHistogram (bass);
86 destroyCDKScreen (cdkscreen);
87 endCDK();
88
89 /* Print out a message and exit. */
90 printf ("Oops. Can not make treble histogram. Is the window big enough??\n");
91 ExitProgram (EXIT_FAILURE);
92 }
93
94 #define BAR(a,b,c) A_BOLD, a, b, c, ' '|A_REVERSE|COLOR_PAIR(3), Box
95
96 /* Set the histogram values. */
97 setCDKHistogram (volume, vPERCENT, CENTER, BAR(0, 10, 6));
98 setCDKHistogram (bass , vPERCENT, CENTER, BAR(0, 10, 3));
99 setCDKHistogram (treble, vPERCENT, CENTER, BAR(0, 10, 7));
100 refreshCDKScreen (cdkscreen);
101 sleep (4);
102
103 /* Set the histogram values. */
104 setCDKHistogram (volume, vPERCENT, CENTER, BAR(0, 10, 8));
105 setCDKHistogram (bass , vPERCENT, CENTER, BAR(0, 10, 1));
106 setCDKHistogram (treble, vPERCENT, CENTER, BAR(0, 10, 9));
107 refreshCDKScreen (cdkscreen);
108 sleep (4);
109
110 /* Set the histogram values. */
111 setCDKHistogram (volume, vPERCENT, CENTER, BAR(0, 10, 10));
112 setCDKHistogram (bass , vPERCENT, CENTER, BAR(0, 10, 7));
113 setCDKHistogram (treble, vPERCENT, CENTER, BAR(0, 10, 10));
114 refreshCDKScreen (cdkscreen);
115 sleep (4);
116
117 /* Set the histogram values. */
118 setCDKHistogram (volume, vPERCENT, CENTER, BAR(0, 10, 1));
119 setCDKHistogram (bass , vPERCENT, CENTER, BAR(0, 10, 8));
120 setCDKHistogram (treble, vPERCENT, CENTER, BAR(0, 10, 3));
121 refreshCDKScreen (cdkscreen);
122 sleep (4);
123
124 /* Set the histogram values. */
125 setCDKHistogram (volume, vPERCENT, CENTER, BAR(0, 10, 3));
126 setCDKHistogram (bass , vPERCENT, CENTER, BAR(0, 10, 3));
127 setCDKHistogram (treble, vPERCENT, CENTER, BAR(0, 10, 3));
128 refreshCDKScreen (cdkscreen);
129 sleep (4);
130
131 /* Set the histogram values. */
132 setCDKHistogram (volume, vPERCENT, CENTER, BAR(0, 10, 10));
133 setCDKHistogram (bass , vPERCENT, CENTER, BAR(0, 10, 10));
134 setCDKHistogram (treble, vPERCENT, CENTER, BAR(0, 10, 10));
135 refreshCDKScreen (cdkscreen);
136 sleep (4);
137
138 /* Clean up. */
139 destroyCDKHistogram (volume);
140 destroyCDKHistogram (bass);
141 destroyCDKHistogram (treble);
142 destroyCDKScreen (cdkscreen);
143 endCDK();
144 ExitProgram (EXIT_SUCCESS);
145 }
+0
-40
examples/itemlist less more
0 #!/usr/bin/perl -w
1 # $Id: itemlist,v 1.3 2002/07/24 10:04:33 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Itemlist Widget.
6
7 #
8 # Load in the Cdk Extension.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Create a list of the months of the year.
14 my @months = (
15 "<C></B>January", "<C></B>February", "<C></B>March",
16 "<C></U>April", "<C></U>May", "<C></U>June",
17 "<C></K>July", "<C></K>August", "<C></K>September",
18 "<C></R>October", "<C></R>November", "<C></R>December");
19
20 # Create an itemlist widget.
21 my $itemlist = new Cdk::Itemlist ('List' => \@months,
22 'Label' => "Month >>",
23 'Title' => ["<C>Pick A Month"]);
24
25 # Activate the object.
26 my $choice = $itemlist->activate();
27
28 # Check the results
29 if (!defined $choice)
30 {
31 popupLabel (["<C>Escape hit. No item selected."]);
32 }
33 else
34 {
35 popupLabel (["<C>You selected ($months[$choice])"]);
36 }
37
38 # Exit Cdk.
39 Cdk::end();
0 /* $Id: itemlist_ex.c,v 1.13 2005/12/28 00:31:12 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "itemlist_ex";
6 #endif
7
8 #define MONTHS 12
9
10 /*
11 * This program demonstrates the Cdk itemlist widget.
12 *
13 * Options (in addition to minimal CLI parameters):
14 * -c create the data after the widget
15 */
16 int main(int argc, char **argv)
17 {
18 /* Declare local variables. */
19 CDKSCREEN *cdkscreen = 0;
20 CDKITEMLIST *monthlist = 0;
21 WINDOW *cursesWin = 0;
22 char *title = "<C>Pick A Month";
23 char *label = "</U/5>Month:";
24 char *info[MONTHS], temp[256], *mesg[10];
25 int choice, startMonth;
26 struct tm *dateInfo;
27 time_t clck;
28
29 CDK_PARAMS params;
30
31 CDKparseParams(argc, argv, &params, "c" CDK_MIN_PARAMS);
32
33 /*
34 * Get the current date and set the default month to the
35 * current month.
36 */
37 time (&clck);
38 dateInfo = localtime (&clck);
39 startMonth = dateInfo->tm_mon;
40
41 /* Set up CDK. */
42 cursesWin = initscr();
43 cdkscreen = initCDKScreen (cursesWin);
44
45 /* Start CDK colors. */
46 initCDKColor();
47
48 /* Create the choice list. */
49 info[0] = "<C></5>January";
50 info[1] = "<C></5>February";
51 info[2] = "<C></B/19>March";
52 info[3] = "<C></5>April";
53 info[4] = "<C></5>May";
54 info[5] = "<C></K/5>June";
55 info[6] = "<C></12>July";
56 info[7] = "<C></5>August";
57 info[8] = "<C></5>September";
58 info[9] = "<C></32>October";
59 info[10] = "<C></5>November";
60 info[11] = "<C></11>December";
61
62 /* Create the itemlist widget. */
63 monthlist = newCDKItemlist (cdkscreen,
64 CDKparamValue(&params, 'X', CENTER),
65 CDKparamValue(&params, 'Y', CENTER),
66 title,
67 label,
68 CDKparamNumber(&params, 'c') ? 0 : info,
69 CDKparamNumber(&params, 'c') ? 0 : MONTHS,
70 startMonth,
71 CDKparamValue(&params, 'N', TRUE),
72 CDKparamValue(&params, 'S', FALSE));
73
74 /* Is the widget null? */
75 if (monthlist == 0)
76 {
77 /* Clean up. */
78 destroyCDKScreen (cdkscreen);
79 endCDK();
80
81 /* Print out a little message. */
82 printf ("Oops. Can't seem to create the itemlist box. Is the window too small?\n");
83 ExitProgram (EXIT_FAILURE);
84 }
85
86 if (CDKparamNumber(&params, 'c'))
87 {
88 setCDKItemlistValues (monthlist, info, MONTHS, 0);
89 }
90
91 /* Activate the widget. */
92 choice = activateCDKItemlist (monthlist, 0);
93
94 /* Check how they exited from the widget. */
95 if (monthlist->exitType == vESCAPE_HIT)
96 {
97 mesg[0] = "<C>You hit escape. No item selected.";
98 mesg[1] = "";
99 mesg[2] = "<C>Press any key to continue.";
100 popupLabel (ScreenOf(monthlist), mesg, 3);
101 }
102 else if (monthlist->exitType == vNORMAL)
103 {
104 sprintf (temp, "<C>You selected the %dth item which is", choice);
105 mesg[0] = copyChar (temp);
106 mesg[1] = info[choice];
107 mesg[2] = "";
108 mesg[3] = "<C>Press any key to continue.";
109 popupLabel (ScreenOf(monthlist), mesg, 4);
110 freeChar (mesg[0]);
111 }
112
113 /* Clean up. */
114 destroyCDKItemlist (monthlist);
115 destroyCDKScreen (cdkscreen);
116 endCDK();
117 ExitProgram (EXIT_SUCCESS);
118 }
+0
-29
examples/label less more
0 #!/usr/bin/perl -w
1 # $Id: label,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Label Widget.
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Set up the label rows.
14 my @mesg = ("<C>This is a test of the Perl Cdk extension.",
15 "", "",
16 "<L></22>Written by...",
17 "<C></5/R>Mike Glover");
18
19 # Create the label object.
20 my $title = new Cdk::Label ('Message' => \@mesg);
21
22 # Draw the label.
23 $title->set ('BoxAttribute' => "</B>");
24 $title->draw ();
25 $title->wait();
26
27 # Exit Cdk.
28 Cdk::end();
0 /* $Id: label_ex.c,v 1.9 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "label_ex";
6 #endif
7
8 int main(int argc, char **argv)
9 {
10 /* Declare variables. */
11 CDKSCREEN *cdkscreen;
12 CDKLABEL *demo;
13 WINDOW *cursesWin;
14 char *mesg[10];
15
16 CDK_PARAMS params;
17
18 CDKparseParams(argc, argv, &params, CDK_MIN_PARAMS);
19
20 /* Set up CDK. */
21 cursesWin = initscr();
22 cdkscreen = initCDKScreen (cursesWin);
23
24 /* Start CDK Colors. */
25 initCDKColor();
26
27 /* Set the labels up. */
28 mesg[0] = "</29/B>This line should have a yellow foreground and a blue background.";
29 mesg[1] = "</5/B>This line should have a white foreground and a blue background.";
30 mesg[2] = "</26/B>This line should have a yellow foreground and a red background.";
31 mesg[3] = "<C>This line should be set to whatever the screen default is.";
32
33 /* Declare the labels. */
34 demo = newCDKLabel (cdkscreen,
35 CDKparamValue(&params, 'X', CENTER),
36 CDKparamValue(&params, 'Y', CENTER),
37 mesg, 4,
38 CDKparamValue(&params, 'N', TRUE),
39 CDKparamValue(&params, 'S', TRUE));
40
41 /* Is the label null? */
42 if (demo == 0)
43 {
44 /* Clean up the memory. */
45 destroyCDKScreen (cdkscreen);
46
47 /* End curses... */
48 endCDK();
49
50 /* Spit out a message. */
51 printf ("Oops. Can't seem to create the label. Is the window too small?\n");
52 ExitProgram (EXIT_FAILURE);
53 }
54
55 /* Draw the CDK screen. */
56 refreshCDKScreen (cdkscreen);
57 waitCDKLabel (demo, ' ');
58
59 /* Clean up. */
60 destroyCDKLabel (demo);
61 destroyCDKScreen (cdkscreen);
62 endCDK();
63 ExitProgram (EXIT_SUCCESS);
64 }
0 /* $Id: lowerCDKObject_ex.c,v 1.7 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "lowerCDKObject_ex";
6 #endif
7
8 int main (int argc, char **argv)
9 {
10 char ch;
11
12 char *mesg[1];
13 char *mesg1[10];
14 char *mesg2[10];
15
16 WINDOW *cursesWin;
17 CDKSCREEN *cdkscreen;
18 CDKLABEL *label1, *label2, *instruct;
19
20 CDK_PARAMS params;
21
22 CDKparseParams (argc, argv, &params, CDK_MIN_PARAMS);
23
24 /* Set up CDK. */
25 cursesWin = initscr ();
26 cdkscreen = initCDKScreen (cursesWin);
27
28 mesg1[0] = "label1 label1 label1 label1 label1 label1 label1";
29 mesg1[1] = "label1 label1 label1 label1 label1 label1 label1";
30 mesg1[2] = "label1 label1 label1 label1 label1 label1 label1";
31 mesg1[3] = "label1 label1 label1 label1 label1 label1 label1";
32 mesg1[4] = "label1 label1 label1 label1 label1 label1 label1";
33 mesg1[5] = "label1 label1 label1 label1 label1 label1 label1";
34 mesg1[6] = "label1 label1 label1 label1 label1 label1 label1";
35 mesg1[7] = "label1 label1 label1 label1 label1 label1 label1";
36 mesg1[8] = "label1 label1 label1 label1 label1 label1 label1";
37 mesg1[9] = "label1 label1 label1 label1 label1 label1 label1";
38 label1 = newCDKLabel (cdkscreen, 8, 5, mesg1, 10, TRUE, FALSE);
39
40 mesg2[0] = "label2 label2 label2 label2 label2 label2 label2";
41 mesg2[1] = "label2 label2 label2 label2 label2 label2 label2";
42 mesg2[2] = "label2 label2 label2 label2 label2 label2 label2";
43 mesg2[3] = "label2 label2 label2 label2 label2 label2 label2";
44 mesg2[4] = "label2 label2 label2 label2 label2 label2 label2";
45 mesg2[5] = "label2 label2 label2 label2 label2 label2 label2";
46 mesg2[6] = "label2 label2 label2 label2 label2 label2 label2";
47 mesg2[7] = "label2 label2 label2 label2 label2 label2 label2";
48 mesg2[8] = "label2 label2 label2 label2 label2 label2 label2";
49 mesg2[9] = "label2 label2 label2 label2 label2 label2 label2";
50 label2 = newCDKLabel (cdkscreen, 14, 9, mesg2, 10, TRUE, FALSE);
51
52 mesg[0] = "</B>1<!B> - lower </U>label1<!U>, </B>2<!B> - lower </U>label2<!U>, </B>q<!B> - </U>quit<!U>";
53 instruct = newCDKLabel (cdkscreen,
54 CDKparamValue (&params, 'X', CENTER),
55 CDKparamValue (&params, 'Y', BOTTOM),
56 mesg, 1,
57 CDKparamValue (&params, 'N', FALSE),
58 CDKparamValue (&params, 'S', FALSE));
59
60 refreshCDKScreen (cdkscreen);
61
62 while ((ch = getch ()) != 'q')
63 {
64 switch (ch)
65 {
66 case '1':
67 lowerCDKObject (vLABEL, label1);
68 break;
69 case '2':
70 lowerCDKObject (vLABEL, label2);
71 break;
72 default:
73 continue;
74 }
75 refreshCDKScreen (cdkscreen);
76 }
77
78 /* Clean up. */
79 destroyCDKLabel (label1);
80 destroyCDKLabel (label2);
81 destroyCDKLabel (instruct);
82 destroyCDKScreen (cdkscreen);
83 endCDK ();
84 ExitProgram (EXIT_SUCCESS);
85 }
+0
-26
examples/marquee less more
0 #!/usr/bin/perl -w
1 # $Id: marquee,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Marquee Widget.
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Create the message to scroll.
14 my $message = "</5>Hello there</K>!!!<!K> How are you today?<!5> ";
15
16 # Create the marquee object.
17 my $marquee = new Cdk::Marquee ('Width' => 20);
18
19 # Activate the marquee object.
20 $marquee->activate ('Message' => $message,
21 'Delay' => 3,
22 'Repeat' => 3);
23
24 # Exit Cdk.
25 Cdk::end();
0 /* $Id: marquee_ex.c,v 1.9 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "marquee_ex";
6 #endif
7
8 static char startAttr[100];
9 static char endAttr[100];
10
11 /*
12 * This spits out help about this demo program.
13 */
14 static void help (char *programName)
15 {
16 char *USAGE = "[-m Message] [-R repeat value] [-d delay value] [-b|r|u|k] [-h]";
17
18 printf ("Usage: %s %s\n", programName, USAGE);
19 printf (" -m Message - Sets the message to display in the marquee\n");
20 printf (" If no message is provided, one will be created.\n");
21 printf (" -R Repeat - Tells the marquee how many time to repeat the message.\n");
22 printf (" A value of -1 tells the marquee to repeat the message forever.\n");
23 printf (" -d Delay - Sets the number of milli seconds to delay beyween repeats.\n");
24 printf (" -b - Tells the marquee to display the message with the bold attribute.\n");
25 printf (" -r - Tells the marquee to display the message with a revered attribute.\n");
26 printf (" -u - Tells the marquee to display the message with an underline attribute.\n");
27 printf (" -k - Tells the marquee to display the message with the blinking attribute.\n");
28 }
29
30 static void myParseAttr(CDK_PARAMS *params, int lower, int upper)
31 {
32 if (CDKparamString(params, lower) != 0)
33 {
34 char starting[3];
35 char ending[3];
36
37 if (startAttr[0] == '\0')
38 {
39 startAttr[0] = '<';
40 endAttr[0] = '<';
41 }
42 sprintf (starting, "/%c", upper);
43 sprintf (ending, "!%c", upper);
44 strcat (startAttr, starting);
45 strcat (endAttr, ending);
46 }
47 }
48
49 int main (int argc, char **argv)
50 {
51 /* Declare vars. */
52 CDKSCREEN *cdkscreen;
53 CDKMARQUEE *scrollMessage;
54 WINDOW *cursesWin;
55 char message[1024];
56 char *currentTime;
57 time_t clck;
58
59 CDK_PARAMS params;
60 char *mesg;
61 int delay;
62 int repeat;
63
64 CDKparseParams (argc, argv, &params, "brkud:R:m:hw:" CDK_MIN_PARAMS);
65 myParseAttr(&params, 'b', 'B');
66 myParseAttr(&params, 'r', 'R');
67 myParseAttr(&params, 'k', 'K');
68 myParseAttr(&params, 'u', 'U');
69 repeat = CDKparamNumber2 (&params, 'R', 3);
70 delay = CDKparamNumber2 (&params, 'd', 5);
71 mesg = CDKparamString (&params, 'm');
72
73 if (CDKparamString(&params, 'h') != 0)
74 help (argv[0]);
75
76 /* Clean up the strings. */
77 cleanChar (message, sizeof(message), '\0');
78 cleanChar (startAttr, sizeof(startAttr), '\0');
79 cleanChar (endAttr, sizeof(endAttr), '\0');
80
81 /* Put the end of the attributes if they asked for then. */
82 if (startAttr[0] == '<')
83 {
84 strcat (startAttr, ">");
85 strcat (endAttr, ">");
86 }
87
88 /* Set up CDK. */
89 cursesWin = initscr();
90 cdkscreen = initCDKScreen (cursesWin);
91 curs_set(0);
92
93 /* Start CDK Colors. */
94 initCDKColor();
95
96 /* Create the marquee. */
97 scrollMessage = newCDKMarquee (cdkscreen,
98 CDKparamValue(&params, 'X', CENTER),
99 CDKparamValue(&params, 'Y', TOP),
100 CDKparamValue(&params, 'w', 30),
101 CDKparamValue(&params, 'N', FALSE),
102 CDKparamValue(&params, 'S', TRUE));
103
104 /* Check if the marquee is null. */
105 if (scrollMessage == 0)
106 {
107 /* Exit Cdk. */
108 destroyCDKScreen (cdkscreen);
109 endCDK();
110
111 /* Print out a message. */
112 printf ("Oops. Can't seem to create the marquee window. Is the window too small?\n");
113 ExitProgram (EXIT_FAILURE);
114 }
115
116 /* Draw the CDK screen. */
117 refreshCDKScreen (cdkscreen);
118
119 /* Create the marquee message. */
120 if (mesg == 0)
121 {
122 /* Get the current time and chop off the newline. */
123 time (&clck);
124 currentTime = ctime (&clck);
125 currentTime[strlen(currentTime)-1] = 0;
126
127 if (startAttr[0] != '\0')
128 {
129 currentTime[strlen(currentTime)-1] = '\0';
130 sprintf (message, "%s%s%s (This Space For Rent) ", startAttr, currentTime, endAttr);
131 }
132 else
133 {
134 sprintf (message, "%s (This Space For Rent) ", currentTime);
135 }
136 }
137 else
138 {
139 if (startAttr[0] != '\0')
140 {
141 sprintf (message, "%s%s%s ", startAttr, mesg, endAttr);
142 }
143 else
144 {
145 sprintf (message, "%s ", mesg);
146 }
147 }
148
149 /* Run the marquee. */
150 activateCDKMarquee (scrollMessage, message, delay, repeat, TRUE);
151
152 /* Clean up. */
153 destroyCDKMarquee (scrollMessage);
154 destroyCDKScreen (cdkscreen);
155 endCDK();
156 ExitProgram (EXIT_SUCCESS);
157 }
+0
-72
examples/matrix less more
0 #!/usr/bin/perl -w
1 # $Id: matrix,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Matrix Widget
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Set up the matrix field attibutes.
14 my @rowtitles = ("Course 1", "Course 2", "Course 3", "Course 4", "Course 5");
15 my @coltitles = ("Course", "Lec 1", "Lec 2", "Lec 3", "Flag");
16 my @colwidths = (7,5,5,5,1);
17 my @coltypes = ("UMIXED", "UMIXED", "UMIXED", "UMIXED", "UMIXED");
18 my $title = ["<C>Course Selection Matrix", "", "<C><#HL(30)>"];
19 my $x;
20
21 # Create the matrix object.
22 my $matrix = new Cdk::Matrix ('Title' => $title,
23 'RowTitles' => \@rowtitles,
24 'ColTitles' => \@coltitles,
25 'ColWidths' => \@colwidths,
26 'ColTypes' => \@coltypes,
27 'Vrows' => 3,
28 'Vcols' => $#coltitles+1,
29 'BoxCell' => "TRUE",
30 'BoxMatrix' => "TRUE");
31
32 # Using this array, we will load up the matrix.
33 my @matrixValues = (["PSY340Y", "L0101", "L0201", "", ""],
34 ["PSY340H", "L0101", "L0201", "", ""],
35 ["PSY440Y", "L0101", "L0201", "", ""],
36 ["PSY201Y", "L0101", "L0201", "", ""]);
37
38 # Load up the matrix.
39 $matrix->set ('Values' => \@matrixValues);
40
41 # Draw the matrix.
42 $matrix->draw();
43
44 # Activate the matrix.
45 my ($rows, $cols, $info) = $matrix->activate();
46
47 # Check the results.
48 if (!defined $rows)
49 {
50 popupLabel (["<C>Escape hit. No information in the matrix."]);
51 }
52 else
53 {
54 my @info = ("<C>Rows: $rows Cols: $cols");
55
56 for ($x=0; $x < $rows; $x++)
57 {
58 my $row = "";
59 for ($y=0; $y < $cols; $y++)
60 {
61 $row .= "($x,$y) = $info->[$x][$y], ";
62 }
63 chomp $row; chomp $row;
64 push (@info, $row);
65 }
66 popupLabel (\@info);
67 }
68
69 # Exit Cdk.
70 Cdk::end();
71
0 /* $Id: matrix_ex.c,v 1.14 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "matrix_ex";
6 #endif
7
8 /*
9 * This program demonstrates the Cdk matrix widget.
10 */
11 int main (int argc, char **argv)
12 {
13 /* Declare local variables. */
14 CDKSCREEN *cdkscreen = 0;
15 CDKMATRIX *courseList = 0;
16 WINDOW *cursesWin = 0;
17 char *title = 0;
18 int rows = 8;
19 int cols = 5;
20 int vrows = 3;
21 int vcols = 5;
22 char *coltitle[10], *rowtitle[10], *mesg[10];
23 int colwidth[10], colvalue[10];
24
25 CDK_PARAMS params;
26
27 CDKparseParams (argc, argv, &params, CDK_MIN_PARAMS);
28
29 /* Set up CDK. */
30 cursesWin = initscr();
31 cdkscreen = initCDKScreen (cursesWin);
32
33 /* Start CDK Colors. */
34 initCDKColor();
35
36 /* Create the horizontal and vertical matrix labels. */
37 #define set_col(n, width, string) \
38 coltitle[n] = string; colwidth[n] = width ; colvalue[n] = vUMIXED
39
40 set_col(1, 7, "</B/5>Course");
41 set_col(2, 7, "</B/33>Lec 1");
42 set_col(3, 7, "</B/33>Lec 2");
43 set_col(4, 7, "</B/33>Lec 3");
44 set_col(5, 1, "</B/7>Flag");
45
46 #define set_row(n, string) \
47 rowtitle[n] = "<C></B/6>" string
48
49 set_row(1, "Course 1");
50 set_row(2, "Course 2");
51 set_row(3, "Course 3");
52 set_row(4, "Course 4");
53 set_row(5, "Course 5");
54 set_row(6, "Course 6");
55 set_row(7, "Course 7");
56 set_row(8, "Course 8");
57
58 /* Create the title. */
59 title = "<C>This is the CDK\n<C>matrix widget.\n<C><#LT><#HL(30)><#RT>";
60
61 /* Create the matrix object. */
62 courseList = newCDKMatrix (cdkscreen,
63 CDKparamValue(&params, 'X', CENTER),
64 CDKparamValue(&params, 'Y', CENTER),
65 rows, cols, vrows, vcols,
66 title, rowtitle, coltitle,
67 colwidth, colvalue,
68 -1, -1, '.',
69 COL, TRUE,
70 CDKparamValue(&params, 'N', TRUE),
71 CDKparamValue(&params, 'S', TRUE));
72
73 /* Check to see if the matrix is null. */
74 if (courseList == 0)
75 {
76 /* Clean up. */
77 destroyCDKScreen (cdkscreen);
78 endCDK();
79
80 /* Print out a little message. */
81 printf ("Oops. Can't seem to create the matrix widget. Is the window too small ?\n");
82 ExitProgram (EXIT_FAILURE);
83 }
84
85 /* Activate the matrix. */
86 activateCDKMatrix (courseList, 0);
87
88 /* Check if the user hit escape or not. */
89 if (courseList->exitType == vESCAPE_HIT)
90 {
91 mesg[0] = "<C>You hit escape. No information passed back.";
92 mesg[1] = "",
93 mesg[2] = "<C>Press any key to continue.";
94 popupLabel (cdkscreen, mesg, 3);
95 }
96 else if (courseList->exitType == vNORMAL)
97 {
98 char temp[80];
99
100 sprintf(temp, "Current cell (%d,%d)", courseList->crow, courseList->ccol);
101 mesg[0] = "<L>You exited the matrix normally.";
102 mesg[1] = temp;
103 mesg[2] = "<L>To get the contents of the matrix cell, you can";
104 mesg[3] = "<L>use getCDKMatrixCell():";
105 mesg[4] = getCDKMatrixCell(courseList, courseList->crow, courseList->ccol);
106 mesg[5] = "";
107 mesg[6] = "<C>Press any key to continue.";
108 popupLabel (cdkscreen, mesg, 7);
109 }
110
111 /* Clean up. */
112 destroyCDKMatrix (courseList);
113 destroyCDKScreen (cdkscreen);
114 endCDK();
115 ExitProgram (EXIT_SUCCESS);
116 }
+0
-38
examples/mentry less more
0 #!/usr/bin/perl -w
1 # $Id: mentry,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Mentry Widget
6
7 #
8 # Load in the Cdk Extension.
9 #
10 use Cdk;
11
12 #
13 # Initialize Cdk.
14 #
15 Cdk::init();
16
17 # Create the multi-line entry object.
18 $mentry = new Cdk::Mentry ('Label' => "</5>Filename: ",
19 'Width' => 20,
20 'Prows' => 5,
21 'Lrows' => 10);
22
23 # Activate the object.
24 my $filename = $mentry->activate();
25
26 # Check the results.
27 if (!defined $filename)
28 {
29 popupLabel (["<C>Escape hit. No information returned."]);
30 }
31 else
32 {
33 popupLabel (["<C>You typed in", "<C>$filename"]);
34 }
35
36 # Shut down Cdk.
37 Cdk::end();
0 /* $Id: mentry_ex.c,v 1.9 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "mentry_ex";
6 #endif
7
8 int main (int argc, char **argv)
9 {
10 /* Declare variables. */
11 CDKSCREEN *cdkscreen = 0;
12 CDKMENTRY *widget = 0;
13 WINDOW *cursesWin = 0;
14 char *info = 0;
15 char *label = "</R>Message";
16 char *title = "<C></5>Enter a message.<!5>";
17
18 CDK_PARAMS params;
19
20 CDKparseParams (argc, argv, &params, "w:h:l:" CDK_MIN_PARAMS);
21
22 /* Set up CDK. */
23 cursesWin = initscr ();
24 cdkscreen = initCDKScreen (cursesWin);
25
26 /* Start CDK Colors. */
27 initCDKColor ();
28
29 /* Set up the multi-line entry field. */
30 widget = newCDKMentry (cdkscreen,
31 CDKparamValue (&params, 'X', CENTER),
32 CDKparamValue (&params, 'Y', CENTER),
33 title, label, A_BOLD, '.', vMIXED,
34 CDKparamValue (&params, 'w', 20),
35 CDKparamValue (&params, 'h', 5),
36 CDKparamValue (&params, 'l', 20),
37 0,
38 CDKparamValue (&params, 'N', TRUE),
39 CDKparamValue (&params, 'S', FALSE));
40
41 /* Is the object null? */
42 if (widget == 0)
43 {
44 /* Shut down CDK. */
45 destroyCDKScreen (cdkscreen);
46 endCDK ();
47
48 /* Print out a message. */
49 printf ("Oops. Can not create CDK object. Is the window too small?\n");
50 ExitProgram (EXIT_FAILURE);
51 }
52
53 /* Draw the CDK screen. */
54 refreshCDKScreen (cdkscreen);
55
56 /* Set what ever was given from the command line. */
57 setCDKMentry (widget, argv[optind], 0, TRUE);
58
59 /* Activate this thing. */
60 activateCDKMentry (widget, 0);
61 info = strdup (widget->info);
62
63 /* Clean up. */
64 destroyCDKMentry (widget);
65 destroyCDKScreen (cdkscreen);
66 endCDK ();
67
68 /* Spit out the results. */
69 printf ("\n\n\n");
70 printf ("Your message was : <%s>\n", info);
71 free (info);
72 ExitProgram (EXIT_SUCCESS);
73 }
+0
-39
examples/menu less more
0 #!/usr/bin/perl -w
1 # $Id: menu,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Menu Widget
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Create the menu list items.
14 my @fMenu = ("File", "Save", "Open", "Delete", "Exit");
15 my @eMenu = ("Edit", "Cut", "Copy", "Delete", "Paste");
16 my @hMenu = ("Help", "Help", "About...");
17 my @menulist = (\@fMenu, \@eMenu, \@hMenu);
18 my @menuloc = ("LEFT", "LEFT", "RIGHT");
19
20 # Create the menu object.
21 my $menu = new Cdk::Menu ('Menulist' => \@menulist,
22 'Menuloc' => \@menuloc);
23
24 # Activate the object.
25 my ($menuItem, $submenuItem) = $menu->activate();
26
27 # Check the results.
28 if (!defined $menuItem)
29 {
30 popupLabel (["<C>Escape hit. No menu item selected."]);
31 }
32 else
33 {
34 popupLabel (["<C>Item Selected </R>$menulist[$menuItem]->[$submenuItem]"]);
35 }
36
37 # End Cdk.
38 Cdk::end();
0 /* $Id: menu_ex.c,v 1.11 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "menu_ex";
6 #endif
7
8 static int displayCallback (EObjectType cdktype, void *object, void *clientData, chtype input);
9 static char *menulist[MAX_MENU_ITEMS][MAX_SUB_ITEMS];
10 static char *menuInfo[3][4] = {
11 {"", "This saves the current info.", "This exits the program.", ""},
12 {"", "This cuts text", "This copies text", "This pastes text"},
13 {"", "Help for editing", "Help for file management", "Info about the program"}};
14
15 /*
16 * This program demonstratres the Cdk menu widget.
17 */
18 int main (void)
19 {
20 /* Declare variables. */
21 CDKSCREEN *cdkscreen = 0;
22 CDKLABEL *infoBox = 0;
23 CDKMENU*menu = 0;
24 WINDOW*cursesWin = 0;
25 int submenusize[3], menuloc[4];
26 char *mesg[5], temp[256];
27 int selection;
28
29 /* Set up CDK. */
30 cursesWin = initscr();
31 cdkscreen = initCDKScreen (cursesWin);
32
33 /* Start CDK color. */
34 initCDKColor();
35
36 /* Set up the menu. */
37 menulist[0][0] = "</B>File<!B>" ; menulist[1][0] = "</B>Edit<!B>"; menulist[2][0] = "</B>Help<!B>";
38 menulist[0][1] = "</B>Save<!B>" ; menulist[1][1] = "</B>Cut<!B> "; menulist[2][1] = "</B>On Edit <!B>";
39 menulist[0][2] = "</B>Exit<!B>" ; menulist[1][2] = "</B>Copy<!B>"; menulist[2][2] = "</B>On File <!B>";
40 menulist[1][3] = "</B>Paste<!B>"; menulist[2][3] = "</B>About...<!B>";
41 submenusize[0] = 3; menuloc[0] = LEFT;
42 submenusize[1] = 4; menuloc[1] = LEFT;
43 submenusize[2] = 4; menuloc[2] = RIGHT;
44
45 /* Create the label window. */
46 mesg[0] = " ";
47 mesg[1] = " ";
48 mesg[2] = " ";
49 mesg[3] = " ";
50 infoBox = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 4, TRUE, TRUE);
51
52 /* Create the menu. */
53 menu = newCDKMenu (cdkscreen, menulist, 3, submenusize, menuloc,
54 TOP, A_UNDERLINE, A_REVERSE);
55
56 /* Create the post process function. */
57 setCDKMenuPostProcess (menu, displayCallback, infoBox);
58
59 /* Draw the CDK screen. */
60 refreshCDKScreen (cdkscreen);
61
62 /* Activate the menu. */
63 selection = activateCDKMenu (menu, 0);
64
65 /* Determine how the user exited from the widget. */
66 if (menu->exitType == vEARLY_EXIT)
67 {
68 mesg[0] = "<C>You hit escape. No menu item was selected.";
69 mesg[1] = "",
70 mesg[2] = "<C>Press any key to continue.";
71 popupLabel (cdkscreen, mesg, 3);
72 }
73 else if (menu->exitType == vNORMAL)
74 {
75 sprintf (temp, "<C>You selected menu #%d, submenu #%d", selection/100, selection%100);
76 mesg[0] = copyChar (temp);
77 mesg[1] = "",
78 mesg[2] = "<C>Press any key to continue.";
79 popupLabel (cdkscreen, mesg, 3);
80 freeChar (mesg[0]);
81 }
82
83 /* Clean up. */
84 destroyCDKMenu (menu);
85 destroyCDKLabel (infoBox);
86 destroyCDKScreen (cdkscreen);
87 endCDK();
88 ExitProgram (EXIT_SUCCESS);
89 }
90
91 /*
92 * This gets called after every movement.
93 */
94 static int displayCallback (EObjectType cdktype GCC_UNUSED, void *object, void *clientData, chtype input GCC_UNUSED)
95 {
96 CDKMENU *menu = (CDKMENU *)object;
97 CDKLABEL *infoBox = (CDKLABEL *)clientData;
98 char *mesg[10];
99 char temp[256];
100
101 /* Recreate the label message. */
102 sprintf (temp, "Title: %.*s", (int)(sizeof(temp) - 20), menulist[menu->currentTitle][0]);
103 mesg[0] = strdup (temp);
104 sprintf (temp, "Sub-Title: %.*s", (int)(sizeof(temp) - 20), menulist[menu->currentTitle][menu->currentSubtitle+1]);
105 mesg[1] = strdup (temp);
106 mesg[2] = "";
107 sprintf (temp, "<C>%.*s", (int)(sizeof(temp) - 20), menuInfo[menu->currentTitle][menu->currentSubtitle+1]);
108 mesg[3] = strdup (temp);
109
110 /* Set the message of the label. */
111 setCDKLabel (infoBox, mesg, 4, TRUE);
112 drawCDKLabel (infoBox, TRUE);
113
114 /* Clean up. */
115 freeChar (mesg[0]);
116 freeChar (mesg[1]);
117 freeChar (mesg[3]);
118 return 0;
119 }
0 /* $Id: position_ex.c,v 1.13 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "position_ex";
6 #endif
7
8 /*
9 * This demonstrates the positioning of a Cdk entry field widget.
10 */
11 int main(int argc, char **argv)
12 {
13 /* Declare local variables.*/
14 CDKSCREEN *cdkscreen = 0;
15 CDKENTRY *directory = 0;
16 WINDOW *cursesWin = 0;
17 char *label = "</U/5>Directory:<!U!5> ";
18 char *info = 0;
19 char *mesg[10];
20 char temp[256];
21
22 CDK_PARAMS params;
23
24 CDKparseParams(argc, argv, &params, "w:" CDK_MIN_PARAMS);
25
26 /* Set up CDK. */
27 cursesWin = initscr();
28 cdkscreen = initCDKScreen (cursesWin);
29
30 /* Start CDK colors. */
31 initCDKColor();
32
33 /* Create the entry field widget. */
34 directory = newCDKEntry (cdkscreen,
35 CDKparamValue(&params, 'X', CENTER),
36 CDKparamValue(&params, 'Y', CENTER),
37 0, label, A_NORMAL, '.', vMIXED,
38 CDKparamValue(&params, 'w', 40),
39 0, 256,
40 CDKparamValue(&params, 'N', TRUE),
41 CDKparamValue(&params, 'S', FALSE));
42
43 /* Is the widget null? */
44 if (directory == 0)
45 {
46 /* Clean up. */
47 destroyCDKScreen (cdkscreen);
48 endCDK();
49
50 /* Print out a little message. */
51 printf ("Oops. Can't seem to create the entry box. Is the window too small?\n");
52 ExitProgram (EXIT_FAILURE);
53 }
54
55 /* Let the user move the widget around the window. */
56 drawCDKEntry (directory, ObjOf(directory)->box);
57 positionCDKEntry (directory);
58
59 /* Activate the entry field. */
60 info = activateCDKEntry (directory, 0);
61
62 /* Tell them what they typed. */
63 if (directory->exitType == vESCAPE_HIT)
64 {
65 mesg[0] = "<C>You hit escape. No information passed back.";
66 mesg[1] = "",
67 mesg[2] = "<C>Press any key to continue.";
68 popupLabel (cdkscreen, mesg, 3);
69 }
70 else if (directory->exitType == vNORMAL)
71 {
72 mesg[0] = "<C>You typed in the following";
73 sprintf (temp, "<C>(%.*s)", (int)(sizeof(temp) - 20), info);
74 mesg[1] = copyChar (temp);
75 mesg[2] = "";
76 mesg[3] = "<C>Press any key to continue.";
77 popupLabel (cdkscreen, mesg, 4);
78 freeChar (mesg[1]);
79 }
80
81 /* Clean up and exit. */
82 destroyCDKEntry (directory);
83 destroyCDKScreen (cdkscreen);
84 endCDK();
85 ExitProgram (EXIT_SUCCESS);
86 }
+0
-80
examples/postProcess less more
0 #!/usr/bin/perl -w
1 # $Id: postProcess,v 1.3 2002/07/27 20:15:12 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the postProcess method.
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Set up the scrolling list.
14 my @commandItems = ("Add Account ",
15 "Delete Account ",
16 "Account Information ",
17 "Change Account Password ",
18 "Change Account Shell ",
19 "Change Account Directory",
20 "Quit ");
21 my @commandInfo = ("<C>Adds a new account to the system.",
22 "<C>Deletes an exiting account from the system.",
23 "<C>Provides information about a given account.",
24 "<C>Changes a given account's current password.",
25 "<C>Changes a given account's login shell.",
26 "<C>Changes a given account's login directory.",
27 "<C>Exits this interface.");
28 my @initMessage = ("******************************************************");
29
30 # Create the title.
31 my $title = new Cdk::Label ('Message' => ["<C></B/5>Unix System Admin Interface."],
32 'Ypos' => "TOP",
33 'Xpos' => "LEFT");
34
35 # Create the scrolling list object.
36 my $scroll = new Cdk::Scroll ('Title' => "<C></U/5>Pick An Option",
37 'Highlight' => "</B/R/24>",
38 'Height' => 10,
39 'Width' => 35,
40 'Numbers' => "TRUE",
41 'List' => \@commandItems);
42
43 # Set the post-process for the scrolling list.
44 $scroll->postProcess ('Function' => sub { setInfoLabelCB();} );
45
46 # Create the scrolling list item label.
47 my $infoLabel = new Cdk::Label ('Message' => \@initMessage, 'Xpos' => 1, 'Ypos' => 3);
48
49 # Set the contents of the info label.
50 $infoLabel->set ('Message' => ["$commandInfo[0]"]);
51 $infoLabel->draw();
52
53 # Draw the screen.
54 $title->draw();
55 $infoLabel->draw();
56
57 # Do this forever.
58 for (;;)
59 {
60 # Activate the scrolling list.
61 my $item = $scroll->activate();
62 }
63
64 # Exit Cdk.
65 Cdk::end();
66
67 #
68 #
69 #
70 sub setInfoLabelCB
71 {
72 # Get the current itrm from the scrolling list.
73 my ($size, $currentItem) = $scroll->info();
74
75 # Set the info in the label.
76 $infoLabel->set ('Message' => ["$commandInfo[$currentItem]"]);
77 $infoLabel->draw();
78 return 1;
79 }
+0
-58
examples/preProcess less more
0 #!/usr/bin/perl -w
1 # $Id: preProcess,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the preProcess method.
6
7 #
8 # Load in the Cdk Extension.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Create a new entry object.
14 my $title = ["", "Type in anything but the dreaded letter 'G'!", ""];
15 my $entry = new Cdk::Entry ('Label' => "Type Anything: ",
16 'Title' => $title,
17 'Width' => 20,
18 'Min' => 0,
19 'Max' => 256);
20
21 # Set up the pre and post processing.
22 $entry->preProcess ('Function' => sub {preProcessCB (@_, $entry);});
23
24 # Activate the object.
25 my $info = $entry->activate();
26
27 # Check the results.
28 if (!defined $info)
29 {
30 popupLabel (["<C>You hit escape, nothing returned."]);
31 }
32 else
33 {
34 popupLabel (["<C>You typed in ($info)"]);
35 }
36
37 # Exit Cdk.
38 Cdk::end();
39
40 #
41 # This example will set the pre process function so it
42 # will not accept the letter g.
43 #
44 sub preProcessCB
45 {
46 my ($input, $entry) = @_;
47
48 # Check the letter.
49 if (uc $input eq "G")
50 {
51 Cdk::Beep();
52 popupLabel (["<C>I Told You </B>NOT<!B> To Do That"]);
53 $entry->draw();
54 return 0;
55 }
56 return 1;
57 }
0 /* $Id: preprocess_ex.c,v 1.17 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "preprocess_ex";
6 #endif
7
8 static BINDFN_PROTO(entryPreProcessCB);
9
10 /*
11 * This demonstrates the Cdk preprocess feature.
12 */
13 int main (void)
14 {
15 /* Declare local variables. */
16 CDKSCREEN *cdkscreen = 0;
17 CDKENTRY *widget = 0;
18 WINDOW *cursesWin = 0;
19 char *title = "<C>Type in anything you want\n<C>but the dreaded letter </B>G<!B>!";
20 char *info, *mesg[10], temp[256];
21
22 /* Set up CDK. */
23 cursesWin = initscr();
24 cdkscreen = initCDKScreen (cursesWin);
25
26 /* Start CDK colors. */
27 initCDKColor();
28
29 /* Create the entry field widget. */
30 widget = newCDKEntry (cdkscreen, CENTER, CENTER,
31 title, 0, A_NORMAL, '.', vMIXED,
32 40, 0, 256, TRUE, FALSE);
33
34 /* Is the widget null? */
35 if (widget == 0)
36 {
37 /* Clean up. */
38 destroyCDKScreen (cdkscreen);
39 endCDK();
40
41 /* Print out a little message. */
42 printf ("Oops. Can't seem to create the entry box. Is the window too small?\n");
43 ExitProgram (EXIT_FAILURE);
44 }
45
46 setCDKEntryPreProcess (widget, entryPreProcessCB, 0);
47
48 /* Activate the entry field. */
49 info = activateCDKEntry (widget, 0);
50
51 /* Tell them what they typed. */
52 if (widget->exitType == vESCAPE_HIT)
53 {
54 mesg[0] = "<C>You hit escape. No information passed back.";
55 mesg[1] = "",
56 mesg[2] = "<C>Press any key to continue.";
57 popupLabel (cdkscreen, mesg, 3);
58 }
59 else if (widget->exitType == vNORMAL)
60 {
61 mesg[0] = "<C>You typed in the following";
62 sprintf (temp, "<C>(%.*s)", (int)(sizeof(temp) - 20), info);
63 mesg[1] = copyChar (temp);
64 mesg[2] = "";
65 mesg[3] = "<C>Press any key to continue.";
66 popupLabel (cdkscreen, mesg, 4);
67 freeChar (mesg[1]);
68 }
69
70 /* Clean up and exit. */
71 destroyCDKEntry (widget);
72 destroyCDKScreen (cdkscreen);
73 endCDK();
74 ExitProgram (EXIT_SUCCESS);
75 }
76
77 static int entryPreProcessCB (EObjectType cdkType GCC_UNUSED, void *object, void *clientData GCC_UNUSED, chtype input)
78 {
79 CDKENTRY *entry = (CDKENTRY *)object;
80 CDKDIALOG *widget = 0;
81 char *buttons[] = {"OK"};
82 int buttonCount = 1;
83 int lines = 0;
84 char *mesg[5];
85
86 /* Check the input. */
87 if ((input == 'g') || (input == 'G'))
88 {
89 mesg[lines++] = "<C><#HL(30)>";
90 mesg[lines++] = "<C>I told you </B>NOT<!B> to type G";
91 mesg[lines++] = "<C><#HL(30)>";
92
93 widget = newCDKDialog (ScreenOf(entry), CENTER, CENTER,
94 mesg, lines, buttons, buttonCount,
95 A_REVERSE, FALSE, TRUE, FALSE);
96 activateCDKDialog (widget, 0);
97 destroyCDKDialog (widget);
98 drawCDKEntry (entry, ObjOf(entry)->box);
99 return 0;
100 }
101 return 1;
102 }
+0
-41
examples/radio less more
0 #!/usr/bin/perl -w
1 # $Id: radio,v 1.3 2002/07/24 10:04:33 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Radio Widget.
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Set up the radio list.
14 my @radioList = ("Item 1", "Item 2", "Item 3",
15 "Item 4", "Item 5", "Item 6",
16 "Item 7", "Item 8", "Item 9",
17 "Item 10", "Item 11", "Item 12");
18
19 # Create the radio list object.
20 my $radioWidget = new Cdk::Radio ('Title' => ["<C></5>Radio List"],
21 'List' => \@radioList,
22 'Height' => 10,
23 'Width' => 20);
24
25 # Activate the radio object.
26 $radioWidget->set ('Choice' => "#");
27 my $choice = $radioWidget->activate ();
28
29 # Check the results.
30 if (!defined $choice)
31 {
32 popupLabel (["<C>Escape hit. No item selected."]);
33 }
34 else
35 {
36 popupLabel (["<C>You selected $radioList[$choice]."]);
37 }
38
39 # Exit Cdk.
40 Cdk::end();
0 /* $Id: radio1_ex.c,v 1.10 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "radio_ex";
6 #endif
7
8 /*
9 * This program demonstrates the Cdk radio widget.
10 */
11 int main(int argc, char **argv)
12 {
13 /* Declare variables. */
14 CDKSCREEN *cdkscreen = (CDKSCREEN *) NULL;
15 CDKRADIO *radio = (CDKRADIO *) NULL;
16 WINDOW *cursesWin = (WINDOW *) NULL;
17 char *item[5] =
18 {"Choice A", "Choice B", "Choice C"};
19 char *mesg[5], temp[100];
20 int selection;
21
22 CDK_PARAMS params;
23
24 CDKparseParams(argc, argv, &params, "s:t:" CDK_CLI_PARAMS);
25
26 /* Set up CDK. */
27 cursesWin = initscr ();
28 cdkscreen = initCDKScreen (cursesWin);
29
30 /* Set up CDK Colors. */
31 initCDKColor ();
32
33 /* Create the radio list. */
34 radio = newCDKRadio (cdkscreen,
35 CDKparamValue(&params, 'X', CENTER),
36 CDKparamValue(&params, 'Y', CENTER),
37 CDKparsePosition(CDKparamString2(&params, 's', "NONE")),
38 CDKparamValue(&params, 'H', 5),
39 CDKparamValue(&params, 'W', 20),
40 CDKparamString(&params, 't'),
41 item, 3,
42 '#' | A_REVERSE, 1,
43 A_REVERSE,
44 CDKparamValue(&params, 'N', TRUE),
45 CDKparamValue(&params, 'S', FALSE));
46
47 /* Check if the radio list is NULL. */
48 if (radio == (CDKRADIO *) NULL)
49 {
50 /* Exit CDK. */
51 destroyCDKScreen (cdkscreen);
52 endCDK ();
53
54 /* Print out a message and exit. */
55 printf ("Oops. Can't seem to create the radio widget. ");
56 printf ("Is the window too small??\n");
57 ExitProgram (EXIT_FAILURE);
58 }
59
60 /* Activate the radio list. */
61 selection = activateCDKRadio (radio, (chtype *) NULL);
62
63 /* Check the exit status of the widget. */
64 if (radio->exitType == vESCAPE_HIT)
65 {
66 mesg[0] = "<C>You hit escape. No item selected.";
67 mesg[1] = "",
68 mesg[2] = "<C>Press any key to continue.";
69 popupLabel (cdkscreen, mesg, 3);
70 }
71 else if (radio->exitType == vNORMAL)
72 {
73 mesg[0] = "<C>You selected the filename";
74 sprintf (temp, "<C>%.*s", (int)(sizeof(temp) - 20), item[selection]);
75 mesg[1] = copyChar (temp);
76 mesg[2] = "";
77 mesg[3] = "<C>Press any key to continue.";
78 popupLabel (cdkscreen, mesg, 4);
79 freeChar (mesg[1]);
80 }
81
82 destroyCDKRadio (radio);
83 destroyCDKScreen (cdkscreen);
84 endCDK ();
85 ExitProgram (EXIT_SUCCESS);
86 }
0 /* $Id: radio_ex.c,v 1.16 2005/12/28 01:43:29 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "radio_ex";
6 #endif
7
8 /*
9 * This program demonstrates the Cdk radio widget.
10 *
11 * Options (in addition to normal CLI parameters):
12 * -c create the data after the widget
13 * -s SPOS location for the scrollbar
14 * -t TEXT title for the widget
15 *
16 */
17 int main(int argc, char **argv)
18 {
19 /* Declare variables. */
20 CDKSCREEN *cdkscreen = 0;
21 CDKRADIO *radio = 0;
22 WINDOW *cursesWin = 0;
23 char *title = "<C></5>Select a filename";
24 char **item = 0;
25 char *mesg[5], temp[256];
26 int selection, count;
27
28 CDK_PARAMS params;
29
30 CDKparseParams(argc, argv, &params, "cs:t:" CDK_CLI_PARAMS);
31
32 /* Use the current diretory list to fill the radio list. */
33 count = CDKgetDirectoryContents (".", &item);
34 if (count <= 0)
35 {
36 fprintf(stderr, "Cannot get directory list\n");
37 ExitProgram (EXIT_FAILURE);
38 }
39
40 /* Set up CDK. */
41 cursesWin = initscr();
42 cdkscreen = initCDKScreen (cursesWin);
43
44 /* Set up CDK Colors. */
45 initCDKColor();
46
47 /* Create the radio list. */
48 radio = newCDKRadio (cdkscreen,
49 CDKparamValue(&params, 'X', CENTER),
50 CDKparamValue(&params, 'Y', CENTER),
51 CDKparsePosition(CDKparamString2(&params, 's', "RIGHT")),
52 CDKparamValue(&params, 'H', 10),
53 CDKparamValue(&params, 'W', 40),
54 CDKparamString2(&params, 't', title),
55 CDKparamNumber(&params, 'c') ? 0 : item,
56 CDKparamNumber(&params, 'c') ? 0 : count,
57 '#'|A_REVERSE, 1,
58 A_REVERSE,
59 CDKparamValue(&params, 'N', TRUE),
60 CDKparamValue(&params, 'S', FALSE));
61
62 /* Check if the radio list is null. */
63 if (radio == 0)
64 {
65 /* Exit CDK. */
66 destroyCDKScreen (cdkscreen);
67 endCDK();
68
69 /* Print out a message and exit. */
70 printf ("Oops. Can't seem to create the radio widget. Is the window too small??\n");
71 ExitProgram (EXIT_FAILURE);
72 }
73
74 if (CDKparamNumber(&params, 'c'))
75 {
76 setCDKRadioItems (radio, item, count);
77 }
78
79 /* loop until user selects a file, or cancels */
80 for (;;)
81 {
82 /* Activate the radio list. */
83 selection = activateCDKRadio (radio, 0);
84
85 /* Check the exit status of the widget. */
86 if (radio->exitType == vESCAPE_HIT)
87 {
88 mesg[0] = "<C>You hit escape. No item selected.";
89 mesg[1] = "",
90 mesg[2] = "<C>Press any key to continue.";
91 popupLabel (cdkscreen, mesg, 3);
92 break;
93 }
94 else if (radio->exitType == vNORMAL)
95 {
96 struct stat sb;
97
98 if (stat(item[selection], &sb) == 0
99 && (sb.st_mode & S_IFMT) == S_IFDIR) {
100 char **nitem = 0;
101
102 mesg[0] = "<C>You selected a directory";
103 sprintf (temp, "<C>%.*s", (int)(sizeof(temp) - 20), item[selection]);
104 mesg[1] = temp;
105 mesg[2] = "";
106 mesg[3] = "<C>Press any key to continue.";
107 popupLabel (cdkscreen, mesg, 4);
108 if ((count = CDKgetDirectoryContents (item[selection], &nitem)) > 0)
109 {
110 CDKfreeStrings(item);
111 item = nitem;
112 chdir(item[selection]);
113 setCDKRadioItems (radio, item, count);
114 }
115 } else {
116 mesg[0] = "<C>You selected the filename";
117 sprintf (temp, "<C>%.*s", (int)(sizeof(temp) - 20), item[selection]);
118 mesg[1] = temp;
119 mesg[2] = "";
120 mesg[3] = "<C>Press any key to continue.";
121 popupLabel (cdkscreen, mesg, 4);
122 break;
123 }
124 }
125 }
126
127 /* Clean up. */
128 CDKfreeStrings (item);
129 destroyCDKRadio (radio);
130 destroyCDKScreen (cdkscreen);
131 endCDK();
132 ExitProgram (EXIT_SUCCESS);
133 }
0 /* $Id: raiseCDKObject_ex.c,v 1.8 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "raiseCDKObject_ex";
6 #endif
7
8 #define MY_LABEL(p) ObjOf(p)->screenIndex | 0x30 | A_UNDERLINE | A_BOLD
9
10 int main(int argc, char **argv)
11 {
12 char ch;
13
14 char *mesg[1];
15 char *mesg1[10];
16 char *mesg2[10];
17 char *mesg3[10];
18 char *mesg4[10];
19
20 WINDOW *cursesWin;
21 CDKSCREEN *cdkscreen;
22 CDKLABEL *label1, *label2, *label3, *label4, *instruct;
23
24 CDK_PARAMS params;
25
26 CDKparseParams(argc, argv, &params, CDK_MIN_PARAMS);
27
28 /* Set up CDK. */
29 cursesWin = initscr ();
30 cdkscreen = initCDKScreen (cursesWin);
31
32 mesg1[0] = "label1 label1 label1 label1 label1 label1 label1";
33 mesg1[1] = "label1 label1 label1 label1 label1 label1 label1";
34 mesg1[2] = "label1 label1 label1 label1 label1 label1 label1";
35 mesg1[3] = "label1 label1 label1 label1 label1 label1 label1";
36 mesg1[4] = "label1 label1 label1 label1 label1 label1 label1";
37 mesg1[5] = "label1 label1 label1 label1 label1 label1 label1";
38 mesg1[6] = "label1 label1 label1 label1 label1 label1 label1";
39 mesg1[7] = "label1 label1 label1 label1 label1 label1 label1";
40 mesg1[8] = "label1 label1 label1 label1 label1 label1 label1";
41 mesg1[9] = "label1 label1 label1 label1 label1 label1 label1";
42 label1 = newCDKLabel (cdkscreen, 10, 4, mesg1, 10, TRUE, FALSE);
43 setCDKLabelULChar (label1, '1' | A_BOLD);
44
45 mesg2[0] = "label2 label2 label2 label2 label2 label2 label2";
46 mesg2[1] = "label2 label2 label2 label2 label2 label2 label2";
47 mesg2[2] = "label2 label2 label2 label2 label2 label2 label2";
48 mesg2[3] = "label2 label2 label2 label2 label2 label2 label2";
49 mesg2[4] = "label2 label2 label2 label2 label2 label2 label2";
50 mesg2[5] = "label2 label2 label2 label2 label2 label2 label2";
51 mesg2[6] = "label2 label2 label2 label2 label2 label2 label2";
52 mesg2[7] = "label2 label2 label2 label2 label2 label2 label2";
53 mesg2[8] = "label2 label2 label2 label2 label2 label2 label2";
54 mesg2[9] = "label2 label2 label2 label2 label2 label2 label2";
55 label2 = newCDKLabel (cdkscreen, 8, 8, mesg2, 10, TRUE, FALSE);
56 setCDKLabelULChar (label2, '2' | A_BOLD);
57
58 mesg3[0] = "label3 label3 label3 label3 label3 label3 label3";
59 mesg3[1] = "label3 label3 label3 label3 label3 label3 label3";
60 mesg3[2] = "label3 label3 label3 label3 label3 label3 label3";
61 mesg3[3] = "label3 label3 label3 label3 label3 label3 label3";
62 mesg3[4] = "label3 label3 label3 label3 label3 label3 label3";
63 mesg3[5] = "label3 label3 label3 label3 label3 label3 label3";
64 mesg3[6] = "label3 label3 label3 label3 label3 label3 label3";
65 mesg3[7] = "label3 label3 label3 label3 label3 label3 label3";
66 mesg3[8] = "label3 label3 label3 label3 label3 label3 label3";
67 mesg3[9] = "label3 label3 label3 label3 label3 label3 label3";
68 label3 = newCDKLabel (cdkscreen, 6, 12, mesg3, 10, TRUE, FALSE);
69 setCDKLabelULChar (label3, '3' | A_BOLD);
70
71 mesg4[0] = "label4 label4 label4 label4 label4 label4 label4";
72 mesg4[1] = "label4 label4 label4 label4 label4 label4 label4";
73 mesg4[2] = "label4 label4 label4 label4 label4 label4 label4";
74 mesg4[3] = "label4 label4 label4 label4 label4 label4 label4";
75 mesg4[4] = "label4 label4 label4 label4 label4 label4 label4";
76 mesg4[5] = "label4 label4 label4 label4 label4 label4 label4";
77 mesg4[6] = "label4 label4 label4 label4 label4 label4 label4";
78 mesg4[7] = "label4 label4 label4 label4 label4 label4 label4";
79 mesg4[8] = "label4 label4 label4 label4 label4 label4 label4";
80 mesg4[9] = "label4 label4 label4 label4 label4 label4 label4";
81 label4 = newCDKLabel (cdkscreen, 4, 16, mesg4, 10, TRUE, FALSE);
82 setCDKLabelULChar (label4, '4' | A_BOLD);
83
84 mesg[0] = "</B>#<!B> - raise </U>label#<!U>, </B>r<!B> - </U>redraw<!U>, </B>q<!B> - </U>quit<!U>";
85 instruct = newCDKLabel (cdkscreen,
86 CDKparamValue(&params, 'X', CENTER),
87 CDKparamValue(&params, 'Y', BOTTOM),
88 mesg, 1,
89 CDKparamValue(&params, 'N', TRUE),
90 CDKparamValue(&params, 'S', FALSE));
91 setCDKLabelULChar (instruct, ' ' | A_NORMAL);
92 setCDKLabelURChar (instruct, ' ' | A_NORMAL);
93 setCDKLabelLLChar (instruct, ' ' | A_NORMAL);
94 setCDKLabelVerticalChar (instruct, ' ' | A_NORMAL);
95 setCDKLabelHorizontalChar (instruct, ' ' | A_NORMAL);
96
97 setCDKLabelLRChar (label1, MY_LABEL (label1));
98 setCDKLabelLRChar (label2, MY_LABEL (label2));
99 setCDKLabelLRChar (label3, MY_LABEL (label3));
100 setCDKLabelLRChar (label4, MY_LABEL (label4));
101 setCDKLabelLRChar (instruct, MY_LABEL (instruct));
102 refreshCDKScreen (cdkscreen);
103
104 while ((ch = getch ()) != 'q')
105 {
106 switch (ch)
107 {
108 case '1':
109 raiseCDKObject (vLABEL, label1);
110 break;
111 case '2':
112 raiseCDKObject (vLABEL, label2);
113 break;
114 case '3':
115 raiseCDKObject (vLABEL, label3);
116 break;
117 case '4':
118 raiseCDKObject (vLABEL, label4);
119 break;
120 case 'r':
121 refreshCDKScreen (cdkscreen);
122 break;
123 default:
124 continue;
125 }
126
127 setCDKLabelLRChar (label1, MY_LABEL (label1));
128 setCDKLabelLRChar (label2, MY_LABEL (label2));
129 setCDKLabelLRChar (label3, MY_LABEL (label3));
130 setCDKLabelLRChar (label4, MY_LABEL (label4));
131 setCDKLabelLRChar (instruct, MY_LABEL (instruct));
132 refreshCDKScreen (cdkscreen);
133 }
134
135 /* Clean up. */
136 destroyCDKLabel (label1);
137 destroyCDKLabel (label2);
138 destroyCDKLabel (label3);
139 destroyCDKLabel (label4);
140 destroyCDKLabel (instruct);
141 destroyCDKScreen (cdkscreen);
142 endCDK ();
143 ExitProgram (EXIT_SUCCESS);
144 }
+0
-37
examples/scale less more
0 #!/usr/bin/perl -w
1 # $Id: scale,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Scale Widget
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Create the scale object.
14 my $scale = new Cdk::Scale ('Label' => "</5>Pick A Number: ",
15 'Low' => 1,
16 'High' => 10);
17
18 # Activate the object.
19 my $number = $scale->activate ();
20
21 # Check the results.
22 if (!defined $number)
23 {
24 popupLabel (["<C>Escape hit. No number selected."]);
25 }
26 else
27 {
28 popupLabel (["<C>You selected $number"]);
29 }
30
31 # Exit Cdk.
32 Cdk::end();
33
34 # Print out the info.
35 print "\n\n\n";
36 print "Number Chosen: $number\n";
0 /* $Id: scale_ex.c,v 1.9 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "scale_ex";
6 #endif
7
8 /*
9 * This program demonstrates the Cdk scale widget.
10 */
11 int main (int argc, char **argv)
12 {
13 /* Declare variables. */
14 CDKSCREEN *cdkscreen = 0;
15 CDKSCALE *widget = 0;
16 WINDOW *cursesWin = 0;
17 char *title = "<C>Select a value";
18 char *label = "</5>Current value";
19 char temp[256], *mesg[5];
20 int selection;
21
22 CDK_PARAMS params;
23 int high;
24 int inc;
25 int low;
26
27 CDKparseParams(argc, argv, &params, "h:i:l:w:" CDK_MIN_PARAMS);
28 high = CDKparamNumber2(&params, 'h', 100);
29 inc = CDKparamNumber2(&params, 'i', 1);
30 low = CDKparamNumber2(&params, 'l', 0);
31
32 /* Set up CDK. */
33 cursesWin = initscr();
34 cdkscreen = initCDKScreen (cursesWin);
35
36 /* Start CDK Colors. */
37 initCDKColor();
38
39 /* Create the widget. */
40 widget = newCDKScale (cdkscreen,
41 CDKparamValue(&params, 'X', CENTER),
42 CDKparamValue(&params, 'Y', CENTER),
43 title, label,
44 A_NORMAL,
45 CDKparamNumber2(&params, 'w', 5),
46 low, low, high,
47 inc, (inc*2),
48 CDKparamValue(&params, 'N', TRUE),
49 CDKparamValue(&params, 'S', FALSE));
50
51 /* Is the widget null? */
52 if (widget == 0)
53 {
54 /* Exit CDK. */
55 destroyCDKScreen (cdkscreen);
56 endCDK();
57
58 /* Print out a message. */
59 printf ("Oops. Can't make the widget. Is the window too small?\n");
60 ExitProgram (EXIT_FAILURE);
61 }
62
63 /* Activate the widget. */
64 selection = activateCDKScale (widget, 0);
65
66 /* Check the exit value of the widget. */
67 if (widget->exitType == vESCAPE_HIT)
68 {
69 mesg[0] = "<C>You hit escape. No value selected.";
70 mesg[1] = "",
71 mesg[2] = "<C>Press any key to continue.";
72 popupLabel (cdkscreen, mesg, 3);
73 }
74 else if (widget->exitType == vNORMAL)
75 {
76 sprintf (temp, "<C>You selected %d", selection);
77 mesg[0] = copyChar (temp);
78 mesg[1] = "",
79 mesg[2] = "<C>Press any key to continue.";
80 popupLabel (cdkscreen, mesg, 3);
81 freeChar (mesg[0]);
82 }
83
84 /* Clean up. */
85 destroyCDKScale (widget);
86 destroyCDKScreen (cdkscreen);
87 endCDK();
88 ExitProgram (EXIT_SUCCESS);
89 }
+0
-42
examples/scroll less more
0 #!/usr/bin/perl -w
1 # $Id: scroll,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Scroll Widget
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Set up the scrolling list.
14 @listItems = ("Item 1", "Item 2", "Item 3",
15 "Item 4", "Item 5", "Item 6",
16 "Item 7", "Item 8", "Item 9");
17
18 # Create the scrolling list object.
19 my $scroll = new Cdk::Scroll ('Title' => "<C>Scroll Title",
20 'Height' => -10,
21 'Width' => -10,
22 'Numbers' => "TRUE",
23 'Spos' => "RIGHT",
24 'List' => \@listItems);
25 $scroll->add ('Item' => "HELLO");
26
27 # Activate the scrolling list.
28 my $itemPicked = $scroll->activate ();
29
30 # Check the results.
31 if (!defined $itemPicked)
32 {
33 popupLabel (["<C>Escape hit. No menu item selected."]);
34 }
35 else
36 {
37 popupLabel (["<C>You selected </R>$listItems[$itemPicked]"]);
38 }
39
40 # Exit Cdk.
41 Cdk::end();
0 /* $Id: scroll_ex.c,v 1.22 2005/12/28 02:01:48 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "scroll_ex";
6 #endif
7
8 static char *newLabel (char *prefix)
9 {
10 static int count;
11 static char result[80];
12 sprintf (result, "%s%d", prefix, ++count);
13 return result;
14 }
15
16 static int addItemCB (EObjectType cdktype GCC_UNUSED, void *object,
17 void *clientData GCC_UNUSED,
18 chtype input GCC_UNUSED)
19 {
20 CDKSCROLL *s = (CDKSCROLL *)object;
21
22 addCDKScrollItem (s, newLabel ("add"));
23
24 refreshCDKScreen (ScreenOf (s));
25
26 return (TRUE);
27 }
28
29 static int insItemCB (EObjectType cdktype GCC_UNUSED, void *object,
30 void *clientData GCC_UNUSED,
31 chtype input GCC_UNUSED)
32 {
33 CDKSCROLL *s = (CDKSCROLL *)object;
34
35 insertCDKScrollItem (s, newLabel ("insert"));
36
37 refreshCDKScreen (ScreenOf (s));
38
39 return (TRUE);
40 }
41
42 static int delItemCB (EObjectType cdktype GCC_UNUSED, void *object,
43 void *clientData GCC_UNUSED,
44 chtype input GCC_UNUSED)
45 {
46 CDKSCROLL *s = (CDKSCROLL *)object;
47
48 deleteCDKScrollItem (s, getCDKScrollCurrent (s));
49
50 refreshCDKScreen (ScreenOf (s));
51
52 return (TRUE);
53 }
54
55 /*
56 * This program demonstrates the Cdk scrolling list widget.
57 *
58 * Options (in addition to normal CLI parameters):
59 * -c create the data after the widget
60 * -s SPOS location for the scrollbar
61 * -t TEXT title for the widget
62 */
63 int main (int argc, char **argv)
64 {
65 /* Declare variables. */
66 CDKSCREEN *cdkscreen = 0;
67 CDKSCROLL *scrollList = 0;
68 WINDOW *cursesWin = 0;
69 char *title = "<C></5>Pick a file";
70 char **item = 0;
71 char *mesg[5], temp[256];
72 int selection, count;
73
74 CDK_PARAMS params;
75
76 CDKparseParams (argc, argv, &params, "cs:t:" CDK_CLI_PARAMS);
77
78 /* Set up CDK. */
79 cursesWin = initscr ();
80 cdkscreen = initCDKScreen (cursesWin);
81
82 /* Set up CDK Colors. */
83 initCDKColor ();
84
85 /* Use the current diretory list to fill the radio list. */
86 count = CDKgetDirectoryContents (".", &item);
87
88 /* Create the scrolling list. */
89 scrollList = newCDKScroll (cdkscreen,
90 CDKparamValue (&params, 'X', CENTER),
91 CDKparamValue (&params, 'Y', CENTER),
92 CDKparsePosition(CDKparamString2(&params, 's', "RIGHT")),
93 CDKparamValue (&params, 'H', 10),
94 CDKparamValue (&params, 'W', 50),
95 CDKparamString2(&params, 't', title),
96 CDKparamNumber(&params, 'c') ? 0 : item,
97 CDKparamNumber(&params, 'c') ? 0 : count,
98 TRUE,
99 A_REVERSE,
100 CDKparamValue (&params, 'N', TRUE),
101 CDKparamValue (&params, 'S', FALSE));
102
103 /* Is the scrolling list null? */
104 if (scrollList == 0)
105 {
106 /* Exit CDK. */
107 destroyCDKScreen (cdkscreen);
108 endCDK ();
109
110 /* Print out a message and exit. */
111 printf
112 ("Oops. Could not make scrolling list. Is the window too small?\n");
113 ExitProgram (EXIT_FAILURE);
114 }
115
116 if (CDKparamNumber(&params, 'c'))
117 {
118 setCDKScrollItems (scrollList, item, count, TRUE);
119 }
120 #if 0
121 drawCDKScroll (scrollList, 1);
122
123 setCDKScrollPosition (scrollList, 10);
124 drawCDKScroll (scrollList, 1);
125 sleep (3);
126
127 setCDKScrollPosition (scrollList, 20);
128 drawCDKScroll (scrollList, 1);
129 sleep (3);
130
131 setCDKScrollPosition (scrollList, 30);
132 drawCDKScroll (scrollList, 1);
133 sleep (3);
134
135 setCDKScrollPosition (scrollList, 70);
136 drawCDKScroll (scrollList, 1);
137 sleep (3);
138 #endif
139 bindCDKObject (vSCROLL, scrollList, 'a', addItemCB, NULL);
140 bindCDKObject (vSCROLL, scrollList, 'i', insItemCB, NULL);
141 bindCDKObject (vSCROLL, scrollList, 'd', delItemCB, NULL);
142
143 /* Activate the scrolling list. */
144
145 selection = activateCDKScroll (scrollList, 0);
146
147 /* Determine how the widget was exited. */
148 if (scrollList->exitType == vESCAPE_HIT)
149 {
150 mesg[0] = "<C>You hit escape. No file selected.";
151 mesg[1] = "",
152 mesg[2] = "<C>Press any key to continue.";
153 popupLabel (cdkscreen, mesg, 3);
154 }
155 else if (scrollList->exitType == vNORMAL)
156 {
157 char *theItem = chtype2Char (scrollList->item[selection]);
158 mesg[0] = "<C>You selected the following file";
159 sprintf (temp, "<C>%.*s", (int)(sizeof (temp) - 20), theItem);
160 mesg[1] = temp;
161 mesg[2] = "<C>Press any key to continue.";
162 popupLabel (cdkscreen, mesg, 3);
163 freeChar (theItem);
164 }
165
166 /* Clean up. */
167 CDKfreeStrings (item);
168 destroyCDKScroll (scrollList);
169 destroyCDKScreen (cdkscreen);
170 endCDK ();
171 ExitProgram (EXIT_SUCCESS);
172 }
+0
-47
examples/selection less more
0 #!/usr/bin/perl -w
1 # $Id: selection,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Selection Widget.
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Set up the selection list.
14 my @listItems = ("Item 1", "Item 2", "Item 3",
15 "Item 4", "Item 5", "Item 6",
16 "Item 7", "Item 8", "Item 9");
17
18 my @choices = ("Yes", "No", "Maybe");
19
20 # Create the selection list object.
21 my $selection = new Cdk::Selection ('Title' => "</5>Selection List",
22 'List' => \@listItems,
23 'Choices' => \@choices,
24 'Height' => 10,
25 'Width' => 20);
26
27 # Activate the object.
28 my @info = $selection->activate ();
29
30 # Check the results.
31 if (!defined @info)
32 {
33 popupLabel (["<C>Escape hit. No menu item selected."]);
34 }
35 else
36 {
37 my @list = ("<C></R>Items Selected");
38 for ($x=0; $x < $#info; $x++)
39 {
40 push (@list, "<C>$listItems[$x]") if $info[$x] == 0;
41 }
42 popupLabel (\@list);
43 }
44
45 # Exit Cdk.
46 Cdk::end();
0 /* $Id: selection_ex.c,v 1.15 2005/12/28 01:46:34 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "selection_ex";
6 #endif
7
8 /*
9 * This program demonstrates the Cdk selection widget.
10 *
11 * Options (in addition to normal CLI parameters):
12 * -c create the data after the widget
13 * -s SPOS location for the scrollbar
14 * -t TEXT title for the widget
15 *
16 */
17 int main (int argc, char **argv)
18 {
19 /* Declare variables. */
20 CDKSCREEN *cdkscreen = 0;
21 CDKSELECTION *selection = 0;
22 WINDOW *cursesWin = 0;
23 char *title = "<C></5>Pick one or more accounts.";
24 char *choices[] = {" ", "-->"};
25 char **item = 0;
26 char temp[256], *mesg[200];
27 struct passwd *ent;
28 unsigned x, y;
29 unsigned used = 0;
30 unsigned count = 0;
31
32 CDK_PARAMS params;
33
34 CDKparseParams(argc, argv, &params, "cs:t:" CDK_CLI_PARAMS);
35
36 /* Use the account names to create a list. */
37 count = 0;
38 while ((ent = getpwent ()) != 0)
39 {
40 used = CDKallocStrings(&item, ent->pw_name, count++, used);
41 }
42 endpwent();
43 count--;
44
45 /* Set up CDK. */
46 cursesWin = initscr();
47 cdkscreen = initCDKScreen (cursesWin);
48
49 /* Set up CDK Colors. */
50 initCDKColor();
51
52 /* Create the selection list. */
53 selection = newCDKSelection (cdkscreen,
54 CDKparamValue(&params, 'X', CENTER),
55 CDKparamValue(&params, 'Y', CENTER),
56 CDKparsePosition(CDKparamString2(&params, 's', "RIGHT")),
57 CDKparamValue(&params, 'H', 10),
58 CDKparamValue(&params, 'W', 50),
59 CDKparamString2(&params, 't', title),
60 CDKparamNumber(&params, 'c') ? 0 : item,
61 CDKparamNumber(&params, 'c') ? 0 : count,
62 choices, 2,
63 A_REVERSE,
64 CDKparamValue(&params, 'N', TRUE),
65 CDKparamValue(&params, 'S', FALSE));
66
67 /* Is the selection list null? */
68 if (selection == 0)
69 {
70 /* Exit CDK. */
71 destroyCDKScreen (cdkscreen);
72 endCDK();
73
74 /* Print out a message and exit. */
75 printf ("Oops. Can;t seem to create the selection list. Is the window too small?\n");
76 ExitProgram (EXIT_FAILURE);
77 }
78
79 if (CDKparamNumber(&params, 'c'))
80 {
81 setCDKSelectionItems (selection, item, count);
82 }
83
84 /* Activate the selection list. */
85 activateCDKSelection (selection, 0);
86
87 /* Check the exit status of the widget. */
88 if (selection->exitType == vESCAPE_HIT)
89 {
90 mesg[0] = "<C>You hit escape. No items selected.";
91 mesg[1] = "",
92 mesg[2] = "<C>Press any key to continue.";
93 popupLabel (cdkscreen, mesg, 3);
94 }
95 else if (selection->exitType == vNORMAL)
96 {
97 mesg[0] = "<C>Here are the accounts you selected.";
98 y = 1;
99 for (x=0; x < count; x++)
100 {
101 if (selection->selections[x] == 1)
102 {
103 sprintf (temp, "<C></5>%.*s", (int)(sizeof(temp) - 20), item[x]);
104 mesg[y++] = copyChar (temp);
105 }
106 }
107 popupLabel (cdkscreen, mesg, y);
108
109 /* Clean up. */
110 for (x=1; x < y; x++)
111 {
112 freeChar (mesg[x]);
113 }
114 }
115
116 /* Clean up. */
117 CDKfreeStrings (item);
118 destroyCDKSelection (selection);
119 destroyCDKScreen (cdkscreen);
120 endCDK();
121 ExitProgram (EXIT_SUCCESS);
122 }
+0
-35
examples/slider less more
0 #!/usr/bin/perl -w
1 # $Id: slider,v 1.3 2002/07/24 10:04:32 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Slider Widget
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Create the slider object.
14 my $slider = new Cdk::Slider ('Label' => "</5>Pick A Number: ",
15 'Filler' => "</R>*",
16 'Low' => 1,
17 'High' => 10,
18 'Width' => 50);
19
20 # Activate the object.
21 my $number = $slider->activate ();
22
23 # Check the results.
24 if (!defined $number)
25 {
26 popupLabel (["<C>Escape hit. No menu item selected."]);
27 }
28 else
29 {
30 popupLabel (["<C>You chose $number"]);
31 }
32
33 # Exit Cdk.
34 Cdk::end();
0 /* $Id: slider_ex.c,v 1.9 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "slider_ex";
6 #endif
7
8 /*
9 * This program demonstrates the Cdk slider widget.
10 */
11 int main (int argc, char **argv)
12 {
13 /* Declare variables. */
14 CDKSCREEN *cdkscreen = 0;
15 CDKSLIDER *widget = 0;
16 WINDOW *cursesWin = 0;
17 char *title = "<C></U>Enter a value:";
18 char *label = "</B>Current Value:";
19 char temp[256], *mesg[5];
20 int selection;
21
22 CDK_PARAMS params;
23 int high;
24 int inc;
25 int low;
26
27 CDKparseParams(argc, argv, &params, "h:i:l:w:" CDK_MIN_PARAMS);
28 high = CDKparamNumber2(&params, 'h', 100);
29 inc = CDKparamNumber2(&params, 'i', 1);
30 low = CDKparamNumber2(&params, 'l', 1);
31
32 /* Set up CDK. */
33 cursesWin = initscr();
34 cdkscreen = initCDKScreen (cursesWin);
35
36 /* Start CDK Colors. */
37 initCDKColor();
38
39 /* Create the widget. */
40 widget = newCDKSlider (cdkscreen,
41 CDKparamValue(&params, 'X', CENTER),
42 CDKparamValue(&params, 'Y', CENTER),
43 title, label,
44 A_REVERSE | COLOR_PAIR (29) | ' ',
45 CDKparamNumber2(&params, 'w', 50),
46 low, low, high,
47 inc, (inc*2),
48 CDKparamValue(&params, 'N', TRUE),
49 CDKparamValue(&params, 'S', FALSE));
50
51 /* Is the widget null? */
52 if (widget == 0)
53 {
54 /* Exit CDK. */
55 destroyCDKScreen (cdkscreen);
56 endCDK();
57
58 /* Print out a message. */
59 printf ("Oops. Can't make the widget. Is the window too small?\n");
60 ExitProgram (EXIT_FAILURE);
61 }
62
63 /* Activate the widget. */
64 selection = activateCDKSlider (widget, 0);
65
66 /* Check the exit value of the widget. */
67 if (widget->exitType == vESCAPE_HIT)
68 {
69 mesg[0] = "<C>You hit escape. No value selected.";
70 mesg[1] = "",
71 mesg[2] = "<C>Press any key to continue.";
72 popupLabel (cdkscreen, mesg, 3);
73 }
74 else if (widget->exitType == vNORMAL)
75 {
76 sprintf (temp, "<C>You selected %d", selection);
77 mesg[0] = copyChar (temp);
78 mesg[1] = "",
79 mesg[2] = "<C>Press any key to continue.";
80 popupLabel (cdkscreen, mesg, 3);
81 freeChar (mesg[0]);
82 }
83
84 /* Clean up.*/
85 destroyCDKSlider (widget);
86 destroyCDKScreen (cdkscreen);
87 endCDK();
88 ExitProgram (EXIT_SUCCESS);
89 }
0 /* $Id: subwindow_ex.c,v 1.10 2005/12/27 00:55:46 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "subwindow_ex";
6 #endif
7
8 /*
9 * This demo displays the ability to put widgets within a curses subwindow.
10 */
11 int main (int argc, char **argv)
12 {
13 /* Declare vars. */
14 CDKSCREEN *cdkscreen;
15 CDKSCROLL *dowList;
16 CDKLABEL *title;
17 WINDOW *mainWindow, *subWindow;
18 char *dow[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
19 char *mesg[5];
20 int pick;
21
22 CDK_PARAMS params;
23
24 CDKparseParams(argc, argv, &params, "s:" CDK_CLI_PARAMS);
25
26 /* Start curses. */
27 mainWindow = initscr();
28 curs_set(0);
29
30 /* Create a basic window. */
31 subWindow = newwin (LINES-5, COLS-10, 2, 5);
32
33 /* Start Cdk. */
34 cdkscreen = initCDKScreen (subWindow);
35
36 /* Box our window. */
37 box (subWindow, ACS_VLINE, ACS_HLINE);
38 wrefresh (subWindow);
39
40 /* Create a basic scrolling list inside the window. */
41 dowList = newCDKScroll (cdkscreen,
42 CDKparamValue(&params, 'X', CENTER),
43 CDKparamValue(&params, 'Y', CENTER),
44 CDKparsePosition(CDKparamString2(&params, 's', "RIGHT")),
45 CDKparamValue(&params, 'H', 10),
46 CDKparamValue(&params, 'W', 15),
47 "<C></U>Pick a Day", dow, 7, NONUMBERS,
48 A_REVERSE,
49 CDKparamValue(&params, 'N', TRUE),
50 CDKparamValue(&params, 'S', FALSE));
51
52 /* Put a title within the window. */
53 mesg[0] = "<C><#HL(30)>";
54 mesg[1] = "<C>This is a Cdk scrolling list";
55 mesg[2] = "<C>inside a curses window.";
56 mesg[3] = "<C><#HL(30)>";
57 title = newCDKLabel (cdkscreen, CENTER, 0, mesg, 4, FALSE, FALSE);
58
59 /* Refresh the screen. */
60 refreshCDKScreen (cdkscreen);
61
62 /* Let the user play. */
63 pick = activateCDKScroll (dowList, 0);
64
65 /* Clean up. */
66 destroyCDKScroll (dowList);
67 destroyCDKLabel (title);
68 eraseCursesWindow (subWindow);
69 destroyCDKScreen (cdkscreen);
70 endCDK();
71
72 /* Tell them what they picked. */
73 printf ("You picked %s\n", dow[pick]);
74 ExitProgram (EXIT_SUCCESS);
75 }
+0
-33
examples/swindow less more
0 #!/usr/bin/perl -w
1 # $Id: swindow,v 1.3 2002/07/24 10:04:33 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Scrolling Window Widget.
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Create the scrolling window.
14 my $swindow = new Cdk::Swindow ('Title' => "<C></U>Scrolling Window",
15 'Lines' => 200,
16 'Height' => 20,
17 'Width' => -4);
18
19 # Open this file and read myself in.
20 my @info = qx (cat $0); chomp @info;
21 my $line;
22
23 $swindow->draw();
24 # Line by line, add the info.
25 foreach $line (@info)
26 {
27 $swindow->addline ('Info' => $line);
28 sleep 1;
29 }
30
31 # Exit Cdk.
32 Cdk::end();
0 /* $Id: swindow_ex.c,v 1.11 2005/12/26 22:04:35 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "swindow_ex";
6 #endif
7
8 /*
9 * Demonstrate a scrolling-window.
10 */
11 int main (int argc, char **argv)
12 {
13 /* Declare variables. */
14 CDKSCREEN *cdkscreen = 0;
15 CDKSWINDOW *swindow = 0;
16 WINDOW *cursesWin = 0;
17 char *title = "<C></5>Error Log";
18 char *mesg[5];
19
20 CDK_PARAMS params;
21
22 CDKparseParams(argc, argv, &params, CDK_CLI_PARAMS);
23
24 /* Set up CDK. */
25 cursesWin = initscr();
26 cdkscreen = initCDKScreen (cursesWin);
27
28 /* Start CDK colors. */
29 initCDKColor();
30
31 /* Create the scrolling window. */
32 swindow = newCDKSwindow (cdkscreen,
33 CDKparamValue(&params, 'X', CENTER),
34 CDKparamValue(&params, 'Y', CENTER),
35 CDKparamValue(&params, 'H', 6),
36 CDKparamValue(&params, 'W', 65),
37 title, 100,
38 CDKparamValue(&params, 'N', TRUE),
39 CDKparamValue(&params, 'S', FALSE));
40
41 /* Is the window null. */
42 if (swindow == 0)
43 {
44 /* Exit CDK. */
45 destroyCDKScreen (cdkscreen);
46 endCDK();
47
48 /* Print out a message and exit. */
49 printf ("Oops. Can not seem to create the scrolling window. Is the window too small??\n");
50 ExitProgram (EXIT_FAILURE);
51 }
52
53 /* Draw the scrolling window. */
54 drawCDKSwindow (swindow, ObjOf(swindow)->box);
55
56 /* Load up the scrolling window. */
57 addCDKSwindow (swindow, "<C></11>TOP: This is the first line.", BOTTOM);
58 addCDKSwindow (swindow, "<C>Sleeping for 1 second.", BOTTOM);
59 sleep (1);
60
61 addCDKSwindow (swindow, "<L></11>1: This is another line.", BOTTOM);
62 addCDKSwindow (swindow, "<C>Sleeping for 1 second.", BOTTOM);
63 sleep (1);
64
65 addCDKSwindow (swindow, "<C></11>2: This is another line.", BOTTOM);
66 addCDKSwindow (swindow, "<C>Sleeping for 1 second.", BOTTOM);
67 sleep (1);
68
69 addCDKSwindow (swindow, "<R></11>3: This is another line.", BOTTOM);
70 addCDKSwindow (swindow, "<C>Sleeping for 1 second.", BOTTOM);
71 sleep (1);
72
73 addCDKSwindow (swindow, "<C></11>4: This is another line.", BOTTOM);
74 addCDKSwindow (swindow, "<C>Sleeping for 1 second.", BOTTOM);
75 sleep (1);
76
77 addCDKSwindow (swindow, "<L></11>5: This is another line.", BOTTOM);
78 addCDKSwindow (swindow, "<C>Sleeping for 1 second.", BOTTOM);
79 sleep (1);
80
81 addCDKSwindow (swindow, "<C></11>6: This is another line.", BOTTOM);
82 addCDKSwindow (swindow, "<C>Sleeping for 1 second.", BOTTOM);
83 sleep (1);
84
85 addCDKSwindow (swindow, "<C>Done. You can now play.", BOTTOM);
86
87 addCDKSwindow (swindow, "<C>This is being added to the top.", TOP);
88
89 /* Activate the scrolling window. */
90 activateCDKSwindow (swindow, 0);
91
92 /* Check how the user exited this widget. */
93 if (swindow->exitType == vESCAPE_HIT)
94 {
95 mesg[0] = "<C>You hit escape to leave this widget.";
96 mesg[1] = "";
97 mesg[2] = "<C>Press any key to continue.";
98 popupLabel (cdkscreen, mesg, 3);
99 }
100 else if (swindow->exitType == vNORMAL)
101 {
102 mesg[0] = "<C>You hit return to exit this widget.";
103 mesg[1] = "";
104 mesg[2] = "<C>Press any key to continue.";
105 popupLabel (cdkscreen, mesg, 3);
106 }
107
108 /* Clean up. */
109 destroyCDKSwindow (swindow);
110 destroyCDKScreen (cdkscreen);
111 endCDK();
112 ExitProgram (EXIT_SUCCESS);
113 }
+0
-37
examples/template less more
0 #!/usr/bin/perl -w
1 # $Id: template,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Template Widget.
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Create the template object.
14 my $template = new Cdk::Template ('Label' => 'Type in a date:',
15 'Plate' => '## ## ####',
16 'Overlay' => 'DD-MM-YYYY');
17
18 # Activate the widget.
19 my $date = $template->activate();
20
21 # Get the mixed date back.
22 my $mixedDate = $template->mix();
23
24 # Check the results.
25 if (!defined $date)
26 {
27 popupLabel (["<C>Escape hit. No information to return."]);
28 }
29 else
30 {
31 popupLabel (["<C>With Overlay Mixing : $mixedDate",
32 "<C>Without Overlay Mixing: $date"]);
33 }
34
35 # Exit Cdk.
36 Cdk::end();
0 /* $Id: template_ex.c,v 1.11 2005/12/27 00:58:27 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "template_ex";
6 #endif
7
8 /*
9 * This program demonstrates the Cdk template widget.
10 */
11 int main (int argc, char **argv)
12 {
13 /* Declare variables. */
14 CDKSCREEN *cdkscreen = 0;
15 CDKTEMPLATE *phoneNumber = 0;
16 WINDOW *cursesWin = 0;
17 char *title = "<C>Title";
18 char *label = "</5>Phone Number:<!5>";
19 char *Overlay = "</B/6>(___)<!6> </5>___-____";
20 char *plate = "(###) ###-####";
21 char *info, *mixed, temp[256], *mesg[5];
22
23 CDK_PARAMS params;
24
25 CDKparseParams(argc, argv, &params, CDK_MIN_PARAMS);
26
27 /* Set up CDK*/
28 cursesWin = initscr();
29 cdkscreen = initCDKScreen (cursesWin);
30
31 /* Start CDK Colors. */
32 initCDKColor();
33
34 /* Declare the template. */
35 phoneNumber = newCDKTemplate (cdkscreen,
36 CDKparamValue(&params, 'X', CENTER),
37 CDKparamValue(&params, 'Y', CENTER),
38 title, label,
39 plate, Overlay,
40 CDKparamValue(&params, 'N', TRUE),
41 CDKparamValue(&params, 'S', FALSE));
42
43 /* Is the template pointer null? */
44 if (phoneNumber == 0)
45 {
46 /* Exit CDK. */
47 destroyCDKScreen (cdkscreen);
48 endCDK();
49
50 /* Print out a message and exit. */
51 printf ("Oops. Can;'t seem to create template. Is the window too small?");
52 ExitProgram (EXIT_FAILURE);
53 }
54
55 /* Activate the template. */
56 info = activateCDKTemplate (phoneNumber, 0);
57
58 /* Tell them what they typed. */
59 if (phoneNumber->exitType == vESCAPE_HIT)
60 {
61 mesg[0] = "<C>You hit escape. No information typed in.";
62 mesg[1] = "",
63 mesg[2] = "<C>Press any key to continue.";
64 popupLabel (cdkscreen, mesg, 3);
65 }
66 else if (phoneNumber->exitType == vNORMAL)
67 {
68 /* Mix the plate and the number. */
69 mixed = mixCDKTemplate (phoneNumber);
70
71 /* Create the message to display. */
72 sprintf (temp, "Phone Number with out plate mixing : %.*s", (int)(sizeof(temp) - 50), info);
73 mesg[0] = copyChar (temp);
74 sprintf (temp, "Phone Number with the plate mixed in: %.*s", (int)(sizeof(temp) - 50), mixed);
75 mesg[1] = copyChar (temp);
76 mesg[2] = "";
77 mesg[3] = "<C>Press any key to continue.";
78 popupLabel (cdkscreen, mesg, 4);
79
80 freeChar (mesg[0]);
81 freeChar (mesg[1]);
82 freeChar (mixed);
83 }
84
85 /* Clean up. */
86 destroyCDKTemplate (phoneNumber);
87 destroyCDKScreen (cdkscreen);
88 endCDK();
89 ExitProgram (EXIT_SUCCESS);
90 }
0 /* $Id: traverse_ex.c,v 1.21 2005/12/29 22:50:10 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "entry_ex";
6 #endif
7
8 #define NumElements(a) ((sizeof a)/(sizeof a[0]))
9
10 #define MY_MAX 3
11
12 static CDKOBJS *all_objects[MY_MAX];
13
14 static char *yes_no[] =
15 {
16 "Yes", "NO"
17 };
18 static char *months[] =
19 {
20 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
21 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
22 };
23 static char *choices[] =
24 {
25 "[ ]", "[*]"
26 };
27
28 /*
29 * Exercise all widgets except
30 * CDKMENU
31 * CDKTRAVERSE
32 * The names in parentheses do not accept input, so they will never have
33 * focus for traversal. The names with leading "*" have some limitation
34 * that makes them not useful in traversal.
35 */
36 /* *INDENT-OFF* */
37 static const struct
38 {
39 char *name;
40 EObjectType type;
41 }
42 menu_table[] =
43 {
44 { "(CDKGRAPH)", vGRAPH }, /* no traversal (not active) */
45 { "(CDKHISTOGRAM)", vHISTOGRAM }, /* no traversal (not active) */
46 { "(CDKLABEL)", vLABEL }, /* no traversal (not active) */
47 { "(CDKMARQUEE)", vMARQUEE }, /* hangs (leaves trash) */
48 { "*CDKVIEWER", vVIEWER }, /* traversal out-only on OK */
49 { "CDKALPHALIST", vALPHALIST },
50 { "CDKBUTTON", vBUTTON },
51 { "CDKBUTTONBOX", vBUTTONBOX },
52 { "CDKCALENDAR", vCALENDAR },
53 { "CDKDIALOG", vDIALOG },
54 { "CDKDSCALE", vDSCALE },
55 { "CDKENTRY", vENTRY },
56 { "CDKFSCALE", vFSCALE },
57 { "CDKFSELECT", vFSELECT },
58 { "CDKFSLIDER", vFSLIDER },
59 { "CDKITEMLIST", vITEMLIST },
60 { "CDKMATRIX", vMATRIX },
61 { "CDKMENTRY", vMENTRY },
62 { "CDKRADIO", vRADIO },
63 { "CDKSCALE", vSCALE },
64 { "CDKSCROLL", vSCROLL },
65 { "CDKSELECTION", vSELECTION },
66 { "CDKSLIDER", vSLIDER },
67 { "CDKSWINDOW", vSWINDOW },
68 { "CDKTEMPLATE", vTEMPLATE },
69 { "CDKUSCALE", vUSCALE },
70 { "CDKUSLIDER", vUSLIDER },
71 };
72 /* *INDENT-ON* */
73
74 static CDKOBJS *make_alphalist (CDKSCREEN *cdkscreen, int x, int y)
75 {
76 CDKALPHALIST *widget = newCDKAlphalist (cdkscreen,
77 x, y, 10, 15,
78 "AlphaList",
79 "->",
80 months, NumElements (months),
81 '_', A_REVERSE,
82 TRUE, FALSE);
83 return ObjPtr (widget);
84 }
85
86 static CDKOBJS *make_button (CDKSCREEN *cdkscreen, int x, int y)
87 {
88 CDKBUTTON *widget = newCDKButton (cdkscreen, x, y,
89 "A Button!", NULL,
90 TRUE, FALSE);
91 return ObjPtr (widget);
92 }
93
94 static CDKOBJS *make_buttonbox (CDKSCREEN *cdkscreen, int x, int y)
95 {
96 CDKBUTTONBOX *widget = newCDKButtonbox (cdkscreen, x, y,
97 10, 16,
98 "ButtonBox", 6, 2,
99 months, NumElements (months),
100 A_REVERSE,
101 TRUE, FALSE);
102 return ObjPtr (widget);
103 }
104
105 static CDKOBJS *make_calendar (CDKSCREEN *cdkscreen, int x, int y)
106 {
107 CDKCALENDAR *widget = newCDKCalendar (cdkscreen, x, y,
108 "Calendar", 25, 1, 2000,
109 COLOR_PAIR (16) | A_BOLD,
110 COLOR_PAIR (24) | A_BOLD,
111 COLOR_PAIR (32) | A_BOLD,
112 COLOR_PAIR (40) | A_REVERSE,
113 TRUE,
114 FALSE);
115 return ObjPtr (widget);
116 }
117
118 static CDKOBJS *make_dialog (CDKSCREEN *cdkscreen, int x, int y)
119 {
120 static char *message[] =
121 {
122 "This is a simple dialog box"
123 ,"Is it simple enough?"
124 };
125
126 CDKDIALOG *widget = newCDKDialog (cdkscreen, x, y,
127 message, NumElements (message),
128 yes_no, NumElements (yes_no),
129 COLOR_PAIR (2) | A_REVERSE,
130 TRUE,
131 TRUE, FALSE);
132 return ObjPtr (widget);
133 }
134
135 static CDKOBJS *make_dscale (CDKSCREEN *cdkscreen, int x, int y)
136 {
137 CDKDSCALE *widget = newCDKDScale (cdkscreen, x, y,
138 "DScale", "Value", A_NORMAL,
139 15,
140 0.0, 0.0, 100.0,
141 1.0, (1.0 * 2.), 1,
142 TRUE,
143 FALSE);
144 return ObjPtr (widget);
145 }
146
147 static CDKOBJS *make_entry (CDKSCREEN *cdkscreen, int x, int y)
148 {
149 CDKENTRY *widget = newCDKEntry (cdkscreen, x, y,
150 NULL, "Entry: ", A_NORMAL,
151 '.', vMIXED, 40, 0, 256, TRUE, FALSE);
152 return ObjPtr (widget);
153 }
154
155 static CDKOBJS *make_fscale (CDKSCREEN *cdkscreen, int x, int y)
156 {
157 CDKFSCALE *widget = newCDKFScale (cdkscreen, x, y,
158 "FScale", "Value", A_NORMAL,
159 15,
160 0.0, 0.0, 100.0,
161 1.0, (1.0 * 2.), 1,
162 TRUE,
163 FALSE);
164 return ObjPtr (widget);
165 }
166
167 static CDKOBJS *make_fslider (CDKSCREEN *cdkscreen, int x, int y)
168 {
169 float low = -32;
170 float high = 64;
171 float inc = 0.1;
172 CDKFSLIDER *widget = newCDKFSlider (cdkscreen,
173 x,
174 y,
175 "FSlider", "Label",
176 A_REVERSE | COLOR_PAIR (29) | ' ',
177 20,
178 low, low, high, inc, (inc * 2),
179 3,
180 TRUE,
181 FALSE);
182 /* selection = activateCDKSlider (widget, 0); */
183 return ObjPtr (widget);
184 }
185
186 static CDKOBJS *make_fselect (CDKSCREEN *cdkscreen, int x, int y)
187 {
188 CDKFSELECT *widget = newCDKFselect (cdkscreen,
189 x,
190 y,
191 15,
192 25,
193 "FSelect", "->", A_NORMAL, '_', A_REVERSE,
194 "</5>", "</48>", "</N>", "</N>",
195 TRUE,
196 FALSE);
197 return ObjPtr (widget);
198 }
199
200 static CDKOBJS *make_graph (CDKSCREEN *cdkscreen, int x, int y)
201 {
202 static int values[] =
203 {10, 15, 20, 25, 30, 35, 40, 45, 50, 55};
204 static char *graphChars = "0123456789";
205 CDKGRAPH *widget = newCDKGraph (cdkscreen, x, y,
206 10, 25,
207 "title", "X-axis", "Y-axis");
208 setCDKGraph (widget, values, NumElements (values), graphChars, TRUE, vPLOT);
209 return ObjPtr (widget);
210 }
211
212 static CDKOBJS *make_histogram (CDKSCREEN *cdkscreen, int x, int y)
213 {
214 CDKHISTOGRAM *widget = newCDKHistogram (cdkscreen,
215 x,
216 y,
217 1,
218 20,
219 HORIZONTAL, "Histogram",
220 TRUE,
221 FALSE);
222 setCDKHistogram (widget, vPERCENT, CENTER, A_BOLD, 0, 10, 6, ' ' |
223 A_REVERSE, TRUE);
224 return ObjPtr (widget);
225 }
226
227 static CDKOBJS *make_itemlist (CDKSCREEN *cdkscreen, int x, int y)
228 {
229 CDKITEMLIST *widget = newCDKItemlist (cdkscreen, x, y,
230 NULL, "Month ",
231 months,
232 NumElements (months),
233 1, TRUE, FALSE);
234 return ObjPtr (widget);
235 }
236
237 static CDKOBJS *make_label (CDKSCREEN *cdkscreen, int x, int y)
238 {
239 static char *message[] =
240 {
241 "This is a simple label."
242 ,"Is it simple enough?"
243 };
244 CDKLABEL *widget = newCDKLabel (cdkscreen,
245 x,
246 y,
247 message, NumElements (message),
248 TRUE,
249 TRUE);
250 return ObjPtr (widget);
251 }
252
253 static CDKOBJS *make_marquee (CDKSCREEN *cdkscreen, int x, int y)
254 {
255 CDKMARQUEE *widget = newCDKMarquee (cdkscreen,
256 x,
257 y,
258 30,
259 TRUE,
260 TRUE);
261 activateCDKMarquee (widget, "This is a message", 5, 3, TRUE);
262 destroyCDKMarquee (widget);
263 return 0;
264 }
265
266 static CDKOBJS *make_matrix (CDKSCREEN *cdkscreen, int x, int y)
267 {
268 #define NUMROWS 8
269 #define NUMCOLS 5
270
271 CDKMATRIX *widget;
272 char *coltitle[NUMCOLS + 1];
273 char *rowtitle[NUMROWS + 1];
274 char temp[80];
275 int cols = NUMCOLS;
276 int colwidth[NUMCOLS + 1];
277 int coltypes[NUMCOLS + 1];
278 int maxwidth = 0;
279 int n;
280 int rows = NUMROWS;
281 int vcols = 3;
282 int vrows = 3;
283
284 for (n = 0; n <= NUMROWS; ++n)
285 {
286 sprintf (temp, "row%d", n);
287 rowtitle[n] = copyChar (temp);
288 }
289 for (n = 0; n <= NUMCOLS; ++n)
290 {
291 sprintf (temp, "col%d", n);
292 coltitle[n] = copyChar (temp);
293 colwidth[n] = strlen (temp);
294 coltypes[n] = vUCHAR;
295 if (colwidth[n] > maxwidth)
296 maxwidth = colwidth[n];
297 }
298
299 widget = newCDKMatrix (cdkscreen,
300 x,
301 y,
302 rows, cols, vrows, vcols,
303 "Matrix", rowtitle, coltitle,
304 colwidth, coltypes,
305 -1, -1, '.',
306 COL, TRUE,
307 TRUE,
308 FALSE);
309 return ObjPtr (widget);
310 }
311
312 static CDKOBJS *make_mentry (CDKSCREEN *cdkscreen, int x, int y)
313 {
314 CDKMENTRY *widget = newCDKMentry (cdkscreen,
315 x,
316 y,
317 "MEntry", "Label", A_BOLD, '.', vMIXED,
318 20,
319 5,
320 20,
321 0,
322 TRUE,
323 FALSE);
324 return ObjPtr (widget);
325 }
326
327 static CDKOBJS *make_radio (CDKSCREEN *cdkscreen, int x, int y)
328 {
329 CDKRADIO *widget = newCDKRadio (cdkscreen,
330 x,
331 y,
332 RIGHT,
333 10,
334 20,
335 "Radio",
336 months, NumElements (months),
337 '#' | A_REVERSE, 1,
338 A_REVERSE,
339 TRUE,
340 FALSE);
341 return ObjPtr (widget);
342 }
343
344 static CDKOBJS *make_scale (CDKSCREEN *cdkscreen, int x, int y)
345 {
346 int low = 2;
347 int high = 25;
348 int inc = 1;
349 CDKSCALE *widget = newCDKScale (cdkscreen,
350 x,
351 y,
352 "Scale", "Label", A_NORMAL,
353 5,
354 low, low, high,
355 inc, (inc * 2),
356 TRUE,
357 FALSE);
358 return ObjPtr (widget);
359 }
360
361 static CDKOBJS *make_scroll (CDKSCREEN *cdkscreen, int x, int y)
362 {
363 CDKSCROLL *widget = newCDKScroll (cdkscreen,
364 x,
365 y,
366 RIGHT,
367 10,
368 20,
369 "Scroll",
370 months, NumElements (months),
371 TRUE,
372 A_REVERSE,
373 TRUE,
374 FALSE);
375 return ObjPtr (widget);
376 }
377
378 static CDKOBJS *make_slider (CDKSCREEN *cdkscreen, int x, int y)
379 {
380 int low = 2;
381 int high = 25;
382 int inc = 1;
383 CDKSLIDER *widget = newCDKSlider (cdkscreen,
384 x,
385 y,
386 "Slider", "Label",
387 A_REVERSE | COLOR_PAIR (29) | ' ',
388 20,
389 low, low, high, inc, (inc * 2),
390 TRUE,
391 FALSE);
392 /* selection = activateCDKSlider (widget, 0); */
393 return ObjPtr (widget);
394 }
395
396 static CDKOBJS *make_selection (CDKSCREEN *cdkscreen, int x, int y)
397 {
398 CDKSELECTION *widget = newCDKSelection (cdkscreen, x, y,
399 NONE, 8, 20, "Selection",
400 months, NumElements (months),
401 choices, NumElements (choices),
402 A_REVERSE, TRUE, FALSE);
403 return ObjPtr (widget);
404 }
405
406 static CDKOBJS *make_swindow (CDKSCREEN *cdkscreen, int x, int y)
407 {
408 CDKSWINDOW *widget = newCDKSwindow (cdkscreen,
409 x,
410 y,
411 6,
412 25,
413 "SWindow", 100,
414 TRUE,
415 FALSE);
416 int n;
417 for (n = 0; n < 30; ++n)
418 {
419 char temp[80];
420 sprintf (temp, "Line %d", n);
421 addCDKSwindow (widget, temp, BOTTOM);
422 }
423 activateCDKSwindow (widget, 0);
424 return ObjPtr (widget);
425 }
426
427 static CDKOBJS *make_template (CDKSCREEN *cdkscreen, int x, int y)
428 {
429 char *Overlay = "</B/6>(___)<!6> </5>___-____";
430 char *plate = "(###) ###-####";
431 CDKTEMPLATE *widget = newCDKTemplate (cdkscreen,
432 x,
433 y,
434 "Template", "Label",
435 plate, Overlay,
436 TRUE,
437 FALSE);
438 activateCDKTemplate (widget, 0);
439 return ObjPtr (widget);
440 }
441
442 static CDKOBJS *make_uscale (CDKSCREEN *cdkscreen, int x, int y)
443 {
444 int low = 0;
445 int high = 65535;
446 int inc = 1;
447 CDKUSCALE *widget = newCDKUScale (cdkscreen,
448 x,
449 y,
450 "UScale", "Label", A_NORMAL,
451 5,
452 low, low, high,
453 inc, (inc * 32),
454 TRUE,
455 FALSE);
456 return ObjPtr (widget);
457 }
458
459 static CDKOBJS *make_uslider (CDKSCREEN *cdkscreen, int x, int y)
460 {
461 int low = 0;
462 int high = 65535;
463 int inc = 1;
464 CDKUSLIDER *widget = newCDKUSlider (cdkscreen,
465 x,
466 y,
467 "USlider", "Label",
468 A_REVERSE | COLOR_PAIR (29) | ' ',
469 20,
470 low, low, high, inc, (inc * 32),
471 TRUE,
472 FALSE);
473 /* selection = activateCDKSlider (widget, 0); */
474 return ObjPtr (widget);
475 }
476
477 static CDKOBJS *make_viewer (CDKSCREEN *cdkscreen, int x, int y)
478 {
479 static char *button[1] =
480 {"Ok"};
481 CDKVIEWER *widget = newCDKViewer (cdkscreen,
482 x,
483 y,
484 10,
485 20,
486 button, 1, A_REVERSE,
487 TRUE,
488 FALSE);
489 setCDKViewer (widget, "Viewer",
490 months, NumElements (months),
491 A_REVERSE, FALSE, TRUE, TRUE);
492 activateCDKViewer (widget, 0);
493 return ObjPtr (widget);
494 }
495
496 static void rebind_esc (CDKOBJS *obj)
497 {
498 bindCDKObject (ObjTypeOf (obj), obj, KEY_F (1), getcCDKBind, (void *)KEY_ESC);
499 }
500
501 static void make_any (CDKSCREEN *cdkscreen, int menu, EObjectType type)
502 {
503 CDKOBJS *(*func) (CDKSCREEN *, int, int) = 0;
504 CDKOBJS *prior = 0;
505 int x;
506 int y;
507
508 /* setup positions, staggered a little */
509 switch (menu)
510 {
511 case 0:
512 x = LEFT;
513 y = 2;
514 break;
515 case 1:
516 x = CENTER;
517 y = 4;
518 break;
519 case 2:
520 x = RIGHT;
521 y = 6;
522 break;
523 default:
524 beep ();
525 return;
526 }
527
528 /* find the function to make a widget of the given type */
529 switch (type)
530 {
531 case vALPHALIST:
532 func = make_alphalist;
533 break;
534 case vBUTTON:
535 func = make_button;
536 break;
537 case vBUTTONBOX:
538 func = make_buttonbox;
539 break;
540 case vCALENDAR:
541 func = make_calendar;
542 break;
543 case vDIALOG:
544 func = make_dialog;
545 break;
546 case vDSCALE:
547 func = make_dscale;
548 break;
549 case vENTRY:
550 func = make_entry;
551 break;
552 case vFSCALE:
553 func = make_fscale;
554 break;
555 case vFSELECT:
556 func = make_fselect;
557 break;
558 case vFSLIDER:
559 func = make_fslider;
560 break;
561 case vGRAPH:
562 func = make_graph;
563 break;
564 case vHISTOGRAM:
565 func = make_histogram;
566 break;
567 case vITEMLIST:
568 func = make_itemlist;
569 break;
570 case vLABEL:
571 func = make_label;
572 break;
573 case vMARQUEE:
574 func = make_marquee;
575 break;
576 case vMATRIX:
577 func = make_matrix;
578 break;
579 case vMENTRY:
580 func = make_mentry;
581 break;
582 case vRADIO:
583 func = make_radio;
584 break;
585 case vSCALE:
586 func = make_scale;
587 break;
588 case vSCROLL:
589 func = make_scroll;
590 break;
591 case vSELECTION:
592 func = make_selection;
593 break;
594 case vSLIDER:
595 func = make_slider;
596 break;
597 case vSWINDOW:
598 func = make_swindow;
599 break;
600 case vTEMPLATE:
601 func = make_template;
602 break;
603 case vUSCALE:
604 func = make_uscale;
605 break;
606 case vUSLIDER:
607 func = make_uslider;
608 break;
609 case vVIEWER:
610 func = make_viewer;
611 break;
612 case vMENU:
613 case vTRAVERSE:
614 case vNULL:
615 if (type > 0)
616 beep ();
617 return;
618 }
619
620 /* erase the old widget */
621 if ((prior = all_objects[menu]) != 0)
622 {
623 EraseObj (prior);
624 _destroyCDKObject (prior);
625 all_objects[menu] = 0;
626 }
627
628 /* create the new widget */
629 if (func != 0)
630 {
631 CDKOBJS *widget = func (cdkscreen, x, y);
632 if (widget != 0)
633 {
634 all_objects[menu] = widget;
635 rebind_esc (widget);
636 }
637 else
638 flash ();
639 }
640 else
641 {
642 beep ();
643 }
644 }
645
646 /*
647 * Whenever we get a menu selection, create the selected widget.
648 */
649 static int preHandler (EObjectType cdktype GCC_UNUSED, void *object,
650 void *clientData GCC_UNUSED,
651 chtype input GCC_UNUSED)
652 {
653 int mp, sp;
654 CDKSCREEN *screen;
655 WINDOW *window;
656
657 switch (input)
658 {
659 case KEY_ENTER:
660 getCDKMenuCurrentItem ((CDKMENU *)object, &mp, &sp);
661
662 screen = ScreenOf ((CDKMENU *)object);
663 window = screen->window;
664 mvwprintw (window, getmaxy (window) - 1, 0, "selection %d/%d", mp, sp);
665 clrtoeol ();
666 refresh ();
667 if (sp >= 0 && sp < (int)NumElements (menu_table))
668 make_any (screen, mp, menu_table[sp].type);
669 break;
670 }
671 return 1;
672 }
673
674 /*
675 * This demonstrates the Cdk widget-traversal.
676 */
677 int main (int argc GCC_UNUSED, char **argv GCC_UNUSED)
678 {
679 unsigned j, k;
680
681 /* Declare local variables. */
682 CDKSCREEN *cdkscreen = NULL;
683 CDKMENU *menu = NULL;
684 WINDOW *cursesWin = NULL;
685 char *mesg[3];
686 static char *menulist[MAX_MENU_ITEMS][MAX_SUB_ITEMS] =
687 {
688 {"Left"},
689 {"Center"},
690 {"Right"},
691 };
692 static int submenusize[] =
693 {
694 NumElements (menu_table) + 1,
695 NumElements (menu_table) + 1,
696 NumElements (menu_table) + 1
697 };
698 static int menuloc[] =
699 {LEFT, LEFT, RIGHT};
700
701 for (j = 0; j < MY_MAX; ++j)
702 {
703 for (k = 0; k < NumElements (menu_table); ++k)
704 {
705 menulist[j][k + 1] = menu_table[k].name;
706 }
707 }
708
709 /* Set up CDK. */
710 cursesWin = initscr ();
711 cdkscreen = initCDKScreen (cursesWin);
712
713 /* Start CDK colors. */
714 initCDKColor ();
715
716
717 menu = newCDKMenu (cdkscreen, menulist, MY_MAX, submenusize, menuloc,
718 TOP, A_UNDERLINE, A_REVERSE);
719 if (menu == 0)
720 {
721 destroyCDKScreen (cdkscreen);
722 endCDK ();
723
724 printf ("? Cannot create menus\n");
725 ExitProgram (EXIT_FAILURE);
726 }
727 rebind_esc (ObjOf (menu));
728
729 setCDKMenuPreProcess (menu, preHandler, 0);
730
731 /* setup the initial display */
732 make_any (cdkscreen, 0, vENTRY);
733 #if MY_MAX > 1
734 make_any (cdkscreen, 1, vITEMLIST);
735 #if MY_MAX > 2
736 make_any (cdkscreen, 2, vSELECTION);
737 #endif
738 #endif
739
740 /* Draw the screen. */
741 refreshCDKScreen (cdkscreen);
742
743 /* Traverse the screen */
744 traverseCDKScreen (cdkscreen);
745
746 mesg[0] = "Done";
747 mesg[1] = "";
748 mesg[2] = "<C>Press any key to continue.";
749 popupLabel (cdkscreen, mesg, 3);
750
751 /* Clean up and exit. */
752 for (j = 0; j < MY_MAX; ++j)
753 {
754 if (all_objects[j] != 0)
755 _destroyCDKObject (all_objects[j]);
756 }
757 destroyCDKMenu (menu);
758 destroyCDKScreen (cdkscreen);
759 endCDK ();
760
761 ExitProgram (EXIT_SUCCESS);
762 }
0 /* $Id: uslider_ex.c,v 1.2 2005/12/27 19:47:43 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "uslider_ex";
6 #endif
7
8 /*
9 * This program demonstrates the Cdk unsigned-slider widget.
10 */
11 int main (int argc, char **argv)
12 {
13 /* Declare variables. */
14 CDKSCREEN *cdkscreen = 0;
15 CDKUSLIDER *widget = 0;
16 WINDOW *cursesWin = 0;
17 char title[256];
18 char *label = "</B>Current Value:";
19 char temp[256], *mesg[5];
20 unsigned selection;
21
22 CDK_PARAMS params;
23 unsigned high;
24 unsigned inc;
25 unsigned low;
26
27 CDKparseParams(argc, argv, &params, "h:i:l:w:" CDK_MIN_PARAMS);
28 high = CDKparamNumber2(&params, 'h', 100);
29 inc = CDKparamNumber2(&params, 'i', 1);
30 low = CDKparamNumber2(&params, 'l', 1);
31
32 sprintf(title, "<C></U>Enter a value:\nLow %#x\nHigh %#x", low, high);
33
34 /* Set up CDK. */
35 cursesWin = initscr();
36 cdkscreen = initCDKScreen (cursesWin);
37
38 /* Start CDK Colors. */
39 initCDKColor();
40
41 /* Create the widget. */
42 widget = newCDKUSlider (cdkscreen,
43 CDKparamValue(&params, 'X', CENTER),
44 CDKparamValue(&params, 'Y', CENTER),
45 title, label,
46 A_REVERSE | COLOR_PAIR (29) | ' ',
47 CDKparamNumber2(&params, 'w', 50),
48 low, low, high,
49 inc, (inc*2),
50 CDKparamValue(&params, 'N', TRUE),
51 CDKparamValue(&params, 'S', FALSE));
52
53 /* Is the widget null? */
54 if (widget == 0)
55 {
56 /* Exit CDK. */
57 destroyCDKScreen (cdkscreen);
58 endCDK();
59
60 /* Print out a message. */
61 printf ("Oops. Can't make the widget. Is the window too small?\n");
62 ExitProgram (EXIT_FAILURE);
63 }
64
65 /* Activate the widget. */
66 selection = activateCDKUSlider (widget, 0);
67
68 /* Check the exit value of the widget. */
69 if (widget->exitType == vESCAPE_HIT)
70 {
71 mesg[0] = "<C>You hit escape. No value selected.";
72 mesg[1] = "",
73 mesg[2] = "<C>Press any key to continue.";
74 popupLabel (cdkscreen, mesg, 3);
75 }
76 else if (widget->exitType == vNORMAL)
77 {
78 sprintf (temp, "<C>You selected %u", selection);
79 mesg[0] = copyChar (temp);
80 mesg[1] = "",
81 mesg[2] = "<C>Press any key to continue.";
82 popupLabel (cdkscreen, mesg, 3);
83 freeChar (mesg[0]);
84 }
85
86 /* Clean up.*/
87 destroyCDKUSlider (widget);
88 destroyCDKScreen (cdkscreen);
89 endCDK();
90 ExitProgram (EXIT_SUCCESS);
91 }
+0
-53
examples/viewer less more
0 #!/usr/bin/perl -w
1 # $Id: viewer,v 1.2 2002/07/27 20:11:17 tom Exp $
2
3 #
4 # Purpose:
5 # To demonstrate the Perl5 Cdk Viewer Widget.
6
7 #
8 # Initialize Cdk.
9 #
10 use Cdk;
11 use Getopt::Long;
12
13 Cdk::init();
14
15 # Get the screen dimensions.
16 my ($rows, $cols) = Cdk::getCdkScreenDim ();
17
18 # Parse the command line options.
19 my $ret = GetOptions ('f|file:s', 'h|height:i', 'w|width:i');
20 my $height = $opt_h || $rows-2;
21 my $width = $opt_w || $cols;
22 my $filename = $opt_f;
23
24 # Activate the object.
25 if (!defined $filename)
26 {
27 # Create a file selector widget to get the filename.
28 my $fselect = new Cdk::Fselect ('Label' => "Filename:",
29 'Height' => $height,
30 'Width' => $width);
31
32 # Get the filename.
33 $filename = $fselect->activate();
34 }
35
36 # Open the file and load it up.
37 my @info = qx (cat $filename); chomp @info;
38
39 # Create the viewer object.
40 my $viewer = new Cdk::Viewer ('Buttons' => [ "<<OK>>" ],
41 'Height' => $height,
42 'Width' => $width);
43
44 # Set the contents of the viewer.
45 $viewer->set ('Title' => "<C></5>File: $filename",
46 'Info' => \@info);
47
48 # Activate the viewer.
49 my $selection = $viewer->activate();
50
51 # End Cdk.
52 Cdk::end();
0 /* $Id: viewer_ex.c,v 1.19 2005/12/30 09:48:32 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "viewer_ex";
6 #endif
7
8 /*
9 * This program demonstrates the file selector and the viewer widget.
10 */
11 int main (int argc, char **argv)
12 {
13 /* Declare variables. */
14 CDKSCREEN *cdkscreen = 0;
15 CDKVIEWER *example = 0;
16 CDKFSELECT *fSelect = 0;
17 WINDOW *cursesWin = 0;
18 char *title = "<C>Pick\n<C>A\n<C>File";
19 char *label = "File: ";
20 char **info = 0;
21 char *button[5];
22 char vTitle[256];
23 char *mesg[4];
24 char temp[256];
25 int selected, lines;
26
27 CDK_PARAMS params;
28 char *filename; /* specify filename, bypassing fselect */
29 char *directory; /* specify starting directory for fselect */
30 int interp_it; /* interpret embedded markup */
31 int link_it; /* load file via embedded link */
32
33 CDKparseParams(argc, argv, &params, "f:d:il" CDK_CLI_PARAMS);
34 filename = CDKparamString (&params, 'f');
35 directory = CDKparamString2 (&params, 'd', ".");
36 interp_it = CDKparamNumber2 (&params, 'i', FALSE);
37 link_it = CDKparamNumber2 (&params, 'l', FALSE);
38
39 /* Create the viewer buttons. */
40 button[0] = "</5><OK><!5>";
41 button[1] = "</5><Cancel><!5>";
42
43 /* Set up CDK. */
44 cursesWin = initscr();
45 cdkscreen = initCDKScreen (cursesWin);
46
47 /* Start color. */
48 initCDKColor();
49
50 /* Get the filename. */
51 if (filename == 0)
52 {
53 fSelect = newCDKFselect (cdkscreen,
54 CDKparamValue(&params, 'X', CENTER),
55 CDKparamValue(&params, 'Y', CENTER),
56 CDKparamValue(&params, 'H', 20),
57 CDKparamValue(&params, 'W', 65),
58 title, label, A_NORMAL, '_', A_REVERSE,
59 "</5>", "</48>", "</N>", "</N>",
60 CDKparamValue(&params, 'N', TRUE),
61 CDKparamValue(&params, 'S', FALSE));
62 if (fSelect == 0)
63 {
64 destroyCDKScreen (cdkscreen);
65 endCDK();
66
67 fprintf(stderr, "Cannot create fselect-widget\n");
68 ExitProgram (EXIT_FAILURE);
69 }
70
71 /*
72 * Set the starting directory. This is not necessary because when
73 * the file selector starts it uses the present directory as a default.
74 */
75 setCDKFselect (fSelect, directory, A_NORMAL, '.', A_REVERSE,
76 "</5>", "</48>", "</N>", "</N>", ObjOf(fSelect)->box);
77
78 /* Activate the file selector. */
79 filename = activateCDKFselect (fSelect, 0);
80
81 /* Check how the person exited from the widget. */
82 if (fSelect->exitType == vESCAPE_HIT)
83 {
84 /* Pop up a message for the user. */
85 mesg[0] = "<C>Escape hit. No file selected.";
86 mesg[1] = "";
87 mesg[2] = "<C>Press any key to continue.";
88 popupLabel (cdkscreen, mesg, 3);
89
90 /* Exit CDK. */
91 destroyCDKFselect (fSelect);
92 destroyCDKScreen (cdkscreen);
93 endCDK();
94 ExitProgram (EXIT_SUCCESS);
95 }
96 }
97
98 /* Create the file viewer to view the file selected.*/
99 example = newCDKViewer (cdkscreen,
100 CDKparamValue(&params, 'X', CENTER),
101 CDKparamValue(&params, 'Y', CENTER),
102 CDKparamValue(&params, 'H', 20),
103 CDKparamValue(&params, 'W', -2),
104 button, 2, A_REVERSE,
105 CDKparamValue(&params, 'N', TRUE),
106 CDKparamValue(&params, 'S', FALSE));
107
108 /* Could we create the viewer widget? */
109 if (example == 0)
110 {
111 /* Exit CDK. */
112 destroyCDKFselect (fSelect);
113 destroyCDKScreen (cdkscreen);
114 endCDK();
115
116 /* Print out a message and exit. */
117 printf ("Oops. Can't seem to create viewer. Is the window too small?\n");
118 ExitProgram (EXIT_SUCCESS);
119 }
120
121 if (link_it)
122 {
123 info = (char **) calloc(2, sizeof(char *));
124 info[0] = (char *) malloc(5 + strlen(filename));
125 sprintf (info[0], "<F=%s>", filename);
126 lines = -1;
127 interp_it = TRUE;
128 }
129 else
130 {
131 setCDKViewer (example, "reading...", 0, 0, A_REVERSE, TRUE, TRUE, TRUE);
132 /* Open the file and read the contents. */
133 lines = CDKreadFile (filename, &info);
134 if (lines == -1)
135 {
136 endCDK();
137 printf ("Could not open \"%s\"\n", filename);
138 ExitProgram (EXIT_FAILURE);
139 }
140 }
141
142 /* Set up the viewer title, and the contents to the widget. */
143 sprintf (vTitle, "<C></B/21>Filename:<!21></22>%20s<!22!B>", filename);
144 setCDKViewer (example, vTitle, info, lines, A_REVERSE, interp_it, TRUE, TRUE);
145
146 CDKfreeStrings (info);
147
148 /* Destroy the file selector widget. */
149 destroyCDKFselect (fSelect);
150
151 /* Activate the viewer widget. */
152 selected = activateCDKViewer (example, 0);
153
154 /* Check how the person exited from the widget.*/
155 if (example->exitType == vESCAPE_HIT)
156 {
157 mesg[0] = "<C>Escape hit. No Button selected.";
158 mesg[1] = "";
159 mesg[2] = "<C>Press any key to continue.";
160 popupLabel (cdkscreen, mesg, 3);
161 }
162 else if (example->exitType == vNORMAL)
163 {
164 sprintf (temp, "<C>You selected button %d", selected);
165 mesg[0] = temp;
166 mesg[1] = "";
167 mesg[2] = "<C>Press any key to continue.";
168 popupLabel (cdkscreen, mesg, 3);
169 }
170
171 /* Clean up. */
172 destroyCDKViewer (example);
173 destroyCDKScreen (cdkscreen);
174 endCDK();
175 ExitProgram (EXIT_SUCCESS);
176 }
0 /* $Id: viewer_ex2.c,v 1.5 2005/12/30 09:49:08 tom Exp $ */
1
2 #include <cdk_test.h>
3
4 #ifdef HAVE_XCURSES
5 char *XCursesProgramName = "viewer_ex";
6 #endif
7
8 /*
9 * This program demonstrates the viewFile() function.
10 */
11 int main (int argc, char **argv)
12 {
13 /* Declare variables. */
14 CDKSCREEN *cdkscreen = 0;
15 CDKFSELECT *fSelect = 0;
16 WINDOW *cursesWin = 0;
17 char *title = "<C>Pick\n<C>A\n<C>File";
18 char *label = "File: ";
19 char *button[5];
20 char vTitle[256];
21 char *mesg[4];
22 char temp[256];
23 int selected;
24
25 CDK_PARAMS params;
26 char *filename; /* specify filename, bypassing fselect */
27 char *directory; /* specify starting directory for fselect */
28 int interp_it; /* interpret embedded markup */
29
30 CDKparseParams(argc, argv, &params, "f:d:i" CDK_CLI_PARAMS);
31 filename = CDKparamString (&params, 'f');
32 directory = CDKparamString2 (&params, 'd', ".");
33 interp_it = CDKparamNumber2 (&params, 'i', FALSE);
34
35 /* Create the viewer buttons. */
36 button[0] = "</5><OK><!5>";
37 button[1] = "</5><Cancel><!5>";
38
39 /* Set up CDK. */
40 cursesWin = initscr();
41 cdkscreen = initCDKScreen (cursesWin);
42
43 /* Start color. */
44 initCDKColor();
45
46 /* Get the filename. */
47 if (filename == 0)
48 {
49 fSelect = newCDKFselect (cdkscreen,
50 CDKparamValue(&params, 'X', CENTER),
51 CDKparamValue(&params, 'Y', CENTER),
52 CDKparamValue(&params, 'H', 20),
53 CDKparamValue(&params, 'W', 65),
54 title, label, A_NORMAL, '_', A_REVERSE,
55 "</5>", "</48>", "</N>", "</N>",
56 CDKparamValue(&params, 'N', TRUE),
57 CDKparamValue(&params, 'S', FALSE));
58 if (fSelect == 0)
59 {
60 destroyCDKScreen (cdkscreen);
61 endCDK();
62
63 fprintf(stderr, "Cannot create fselect-widget\n");
64 ExitProgram (EXIT_FAILURE);
65 }
66
67 /*
68 * Set the starting directory. This is not necessary because when
69 * the file selector starts it uses the present directory as a default.
70 */
71 setCDKFselect (fSelect, directory, A_NORMAL, '.', A_REVERSE,
72 "</5>", "</48>", "</N>", "</N>", ObjOf(fSelect)->box);
73
74 /* Activate the file selector. */
75 filename = activateCDKFselect (fSelect, 0);
76
77 /* Check how the person exited from the widget. */
78 if (fSelect->exitType == vESCAPE_HIT)
79 {
80 /* Pop up a message for the user. */
81 mesg[0] = "<C>Escape hit. No file selected.";
82 mesg[1] = "";
83 mesg[2] = "<C>Press any key to continue.";
84 popupLabel (cdkscreen, mesg, 3);
85
86 /* Exit CDK. */
87 destroyCDKFselect (fSelect);
88 destroyCDKScreen (cdkscreen);
89 endCDK();
90
91 ExitProgram (EXIT_SUCCESS);
92 }
93 }
94
95 /* Set up the viewer title, and the contents to the widget. */
96 sprintf (vTitle, "<C></B/21>Filename:<!21></22>%20s<!22!B>", filename);
97
98 selected = viewFile (cdkscreen, vTitle, filename, button, 2);
99
100 /* Destroy the file selector widget (do not need filename anymore) */
101 destroyCDKFselect (fSelect);
102
103 /* Check how the person exited from the widget.*/
104 sprintf (temp, "<C>You selected button %d", selected);
105 mesg[0] = temp;
106 mesg[1] = "";
107 mesg[2] = "<C>Press any key to continue.";
108 popupLabel (cdkscreen, mesg, 3);
109
110 /* Clean up. */
111 destroyCDKScreen (cdkscreen);
112 endCDK();
113 ExitProgram (EXIT_SUCCESS);
114 }
+0
-34
fixpaths less more
0 #!/bin/sh
1 # $Id: fixpaths,v 1.1 2002/07/24 23:00:32 tom Exp $
2 #
3 # Run this script to update the paths in scripts under the current directory
4 # which have perl's pathname, so they can be run in your configuration.
5 #
6 PERL=`which perl`
7 TEXT="#!$PERL -w"
8 for name in `find . -type f -print`
9 do
10 case $name in
11 *~) ;;
12 *)
13 head=`head -1 $name`
14 case $head in #(vi
15 \#!*perl*) #(vi
16 echo process $name
17 if test "$TEXT" != "$head" ; then
18 echo "...updating "
19 rm -f ${name}~
20 mv ${name} ${name}~
21 sed -e "s@$head@$TEXT@" ${name}~ >${name}
22 chmod +x ${name}
23 else
24 echo "...unchanged"
25 fi
26 ;;
27 *)
28 # echo ignored $name
29 ;;
30 esac
31 ;;
32 esac
33 done
0 #define TRACE
1 #include <cdk_int.h>
2
3 /*
4 * $Author: tom $
5 * $Date: 2006/05/07 00:22:25 $
6 * $Revision: 1.68 $
7 */
8
9 /*
10 * Declare file local prototypes.
11 */
12 static BINDFN_PROTO (completeFilenameCB);
13 static BINDFN_PROTO (displayFileInfoCB);
14 static BINDFN_PROTO (fselectAdjustScrollCB);
15 static char *contentToPath (CDKFSELECT *fselect, char *content);
16 static char *errorMessage (char *format);
17 static char *expandTilde (char *filename);
18 static char *format1Date (char *format, time_t value);
19 static char *format1Number (char *format, long value);
20 static char *format1String (char *format, char *string);
21 static char *format3String (char *format, char *s1, char *s2, char *s3);
22 static char *format1StrVal (char *format, char *string, int value);
23 static char *trim1Char (char *source);
24 static int createList (CDKFSELECT *widget, char **list, int listSize);
25 static void setPWD (CDKFSELECT *fselect);
26
27 DeclareSetXXchar (static, _setMy);
28 DeclareCDKObjects (FSELECT, Fselect, _setMy, String);
29
30 /*
31 * This creates a file selection widget.
32 */
33 CDKFSELECT *newCDKFselect (CDKSCREEN *cdkscreen,
34 int xplace,
35 int yplace,
36 int height,
37 int width,
38 char *title,
39 char *label,
40 chtype fieldAttribute,
41 chtype fillerChar,
42 chtype highlight,
43 char *dAttribute,
44 char *fAttribute,
45 char *lAttribute,
46 char *sAttribute,
47 boolean Box,
48 boolean shadow)
49 {
50 CDKFSELECT *fselect = 0;
51 int parentWidth = getmaxx (cdkscreen->window);
52 int parentHeight = getmaxy (cdkscreen->window);
53 int boxWidth = width;
54 int boxHeight = height;
55 int xpos = xplace;
56 int ypos = yplace;
57 int tempWidth = 0;
58 int tempHeight = 0;
59 int labelLen, junk;
60 chtype *chtypeString;
61 int x;
62
63 static const struct
64 {
65 int from;
66 int to;
67 } bindings[] =
68 {
69 { CDK_BACKCHAR, KEY_PPAGE },
70 { CDK_FORCHAR, KEY_NPAGE },
71 };
72
73 if ((fselect = newCDKObject (CDKFSELECT, &my_funcs)) == 0)
74 return (0);
75
76 setCDKFselectBox (fselect, Box);
77
78 /*
79 * If the height is a negative value, the height will
80 * be ROWS-height, otherwise, the height will be the
81 * given height.
82 */
83 boxHeight = setWidgetDimension (parentHeight, height, 0);
84
85 /*
86 * If the width is a negative value, the width will
87 * be COLS-width, otherwise, the width will be the
88 * given width.
89 */
90 boxWidth = setWidgetDimension (parentWidth, width, 0);
91
92 /* Rejustify the x and y positions if we need to. */
93 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
94
95 /* Make sure the box isn't too small. */
96 boxWidth = (boxWidth < 15 ? 15 : boxWidth);
97 boxHeight = (boxHeight < 6 ? 6 : boxHeight);
98
99 /* Make the file selector window. */
100 fselect->win = newwin (boxHeight, boxWidth, ypos, xpos);
101
102 /* Is the window null? */
103 if (fselect->win == 0)
104 {
105 destroyCDKObject (fselect);
106 return (0);
107 }
108 keypad (fselect->win, TRUE);
109
110 /* Set some variables. */
111 ScreenOf (fselect) = cdkscreen;
112 fselect->parent = cdkscreen->window;
113 fselect->dirAttribute = copyChar (dAttribute);
114 fselect->fileAttribute = copyChar (fAttribute);
115 fselect->linkAttribute = copyChar (lAttribute);
116 fselect->sockAttribute = copyChar (sAttribute);
117 fselect->highlight = highlight;
118 fselect->fillerCharacter = fillerChar;
119 fselect->fieldAttribute = fieldAttribute;
120 fselect->boxHeight = boxHeight;
121 fselect->boxWidth = boxWidth;
122 fselect->fileCounter = 0;
123 fselect->pwd = 0;
124 initExitType (fselect);
125 ObjOf (fselect)->inputWindow = fselect->win;
126 fselect->shadow = shadow;
127 fselect->shadowWin = 0;
128
129 /* Get the present working directory. */
130 setPWD (fselect);
131
132 /* Get the contents of the current directory. */
133 setCDKFselectDirContents (fselect);
134
135 /* Create the entry field in the selector. */
136 chtypeString = char2Chtype (label, &labelLen, &junk);
137 freeChtype (chtypeString);
138 tempWidth = (isFullWidth (width)
139 ? FULL
140 : boxWidth - 2 - labelLen);
141 fselect->entryField = newCDKEntry (cdkscreen,
142 getbegx (fselect->win),
143 getbegy (fselect->win),
144 title, label,
145 fieldAttribute, fillerChar,
146 vMIXED, tempWidth, 0, 512,
147 Box, FALSE);
148
149 /* Make sure the widget was created. */
150 if (fselect->entryField == 0)
151 {
152 destroyCDKObject (fselect);
153 return (0);
154 }
155
156 /* Set the lower left/right characters of the entry field. */
157 setCDKEntryLLChar (fselect->entryField, ACS_LTEE);
158 setCDKEntryLRChar (fselect->entryField, ACS_RTEE);
159
160 /* Define the callbacks for the entry field. */
161 bindCDKObject (vENTRY, fselect->entryField, KEY_UP, fselectAdjustScrollCB, fselect);
162 bindCDKObject (vENTRY, fselect->entryField, KEY_PPAGE, fselectAdjustScrollCB, fselect);
163 bindCDKObject (vENTRY, fselect->entryField, KEY_DOWN, fselectAdjustScrollCB, fselect);
164 bindCDKObject (vENTRY, fselect->entryField, KEY_NPAGE, fselectAdjustScrollCB, fselect);
165 bindCDKObject (vENTRY, fselect->entryField, KEY_TAB, completeFilenameCB, fselect);
166 bindCDKObject (vENTRY, fselect->entryField, CTRL ('^'), displayFileInfoCB, fselect);
167
168 /* Put the current working directory in the entry field. */
169 setCDKEntryValue (fselect->entryField, fselect->pwd);
170
171 /* Create the scrolling list in the selector. */
172 tempHeight = getmaxy (fselect->entryField->win) - BorderOf (fselect);
173 tempWidth = (isFullWidth (width)
174 ? FULL
175 : boxWidth - 1);
176 fselect->scrollField = newCDKScroll (cdkscreen,
177 getbegx (fselect->win),
178 getbegy (fselect->win) + tempHeight,
179 RIGHT,
180 boxHeight - tempHeight,
181 tempWidth,
182 0,
183 fselect->dirContents,
184 fselect->fileCounter,
185 NONUMBERS, fselect->highlight,
186 Box, FALSE);
187
188 /* Set the lower left/right characters of the entry field. */
189 setCDKScrollULChar (fselect->scrollField, ACS_LTEE);
190 setCDKScrollURChar (fselect->scrollField, ACS_RTEE);
191
192 /* Do we want a shadow? */
193 if (shadow)
194 {
195 fselect->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
196 }
197
198 /* Setup the key bindings. */
199 for (x = 0; x < (int) SIZEOF (bindings); ++x)
200 bindCDKObject (vFSELECT, fselect, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to);
201
202 registerCDKObject (cdkscreen, vFSELECT, fselect);
203
204 return (fselect);
205 }
206
207 /*
208 * This erases the file selector from the screen.
209 */
210 static void _eraseCDKFselect (CDKOBJS *object)
211 {
212 if (validCDKObject (object))
213 {
214 CDKFSELECT *fselect = (CDKFSELECT *)object;
215
216 eraseCDKScroll (fselect->scrollField);
217 eraseCDKEntry (fselect->entryField);
218 eraseCursesWindow (fselect->win);
219 }
220 }
221
222 /*
223 * This moves the fselect field to the given location.
224 */
225 static void _moveCDKFselect (CDKOBJS *object,
226 int xplace,
227 int yplace,
228 boolean relative,
229 boolean refresh_flag)
230 {
231 CDKFSELECT *fselect = (CDKFSELECT *)object;
232 int currentX = getbegx (fselect->win);
233 int currentY = getbegy (fselect->win);
234 int xpos = xplace;
235 int ypos = yplace;
236 int xdiff = 0;
237 int ydiff = 0;
238
239 /*
240 * If this is a relative move, then we will adjust where we want
241 * to move to.
242 */
243 if (relative)
244 {
245 xpos = getbegx (fselect->win) + xplace;
246 ypos = getbegy (fselect->win) + yplace;
247 }
248
249 /* Adjust the window if we need to. */
250 alignxy (WindowOf (fselect), &xpos, &ypos, fselect->boxWidth, fselect->boxHeight);
251
252 /* Get the difference. */
253 xdiff = currentX - xpos;
254 ydiff = currentY - ypos;
255
256 /* Move the window to the new location. */
257 moveCursesWindow (fselect->win, -xdiff, -ydiff);
258 moveCursesWindow (fselect->shadowWin, -xdiff, -ydiff);
259
260 /* Move the sub-widgets. */
261 moveCDKEntry (fselect->entryField, xplace, yplace, relative, FALSE);
262 moveCDKScroll (fselect->scrollField, xplace, yplace, relative, FALSE);
263
264 /* Redraw the window, if they asked for it. */
265 if (refresh_flag)
266 {
267 drawCDKFselect (fselect, ObjOf (fselect)->box);
268 }
269 }
270
271 /*
272 * The fselect's focus resides in the entry widget. But the scroll widget
273 * will not draw items highlighted unless it has focus. Temporarily adjust the
274 * focus of the scroll widget when drawing on it to get the right highlighting.
275 */
276 #define SaveFocus(widget) \
277 boolean save = HasFocusObj (ObjOf (widget->scrollField)); \
278 HasFocusObj (ObjOf (widget->scrollField)) = \
279 HasFocusObj (ObjOf (widget->entryField))
280
281 #define RestoreFocus(widget) \
282 HasFocusObj (ObjOf (widget->scrollField)) = save
283
284 static void drawMyScroller (CDKFSELECT *widget)
285 {
286 SaveFocus (widget);
287 drawCDKScroll (widget->scrollField, ObjOf (widget->scrollField)->box);
288 RestoreFocus (widget);
289 }
290
291 static void injectMyScroller (CDKFSELECT *widget, chtype key)
292 {
293 SaveFocus (widget);
294 injectCDKScroll (widget->scrollField, key);
295 RestoreFocus (widget);
296 }
297
298 /*
299 * This draws the file selector widget.
300 */
301 static void _drawCDKFselect (CDKOBJS *object, boolean Box GCC_UNUSED)
302 {
303 CDKFSELECT *fselect = (CDKFSELECT *)object;
304
305 /* Draw in the shadow if we need to. */
306 if (fselect->shadowWin != 0)
307 {
308 drawShadow (fselect->shadowWin);
309 }
310
311 /* Draw in the entry field. */
312 drawCDKEntry (fselect->entryField, ObjOf (fselect->entryField)->box);
313
314 /* Draw in the scroll field. */
315 drawMyScroller (fselect);
316 }
317
318 /*
319 * This means you want to use the given file selector. It takes input
320 * from the keyboard, and when it's done, it fills the entry info
321 * element of the structure with what was typed.
322 */
323 char *activateCDKFselect (CDKFSELECT *fselect, chtype *actions)
324 {
325 chtype input = 0;
326 boolean functionKey;
327 char *ret = 0;
328
329 /* Draw the widget. */
330 drawCDKFselect (fselect, ObjOf (fselect)->box);
331
332 if (actions == 0)
333 {
334 for (;;)
335 {
336 input = getchCDKObject (ObjOf (fselect->entryField), &functionKey);
337
338 /* Inject the character into the widget. */
339 ret = injectCDKFselect (fselect, input);
340 if (fselect->exitType != vEARLY_EXIT)
341 {
342 return ret;
343 }
344 }
345 }
346 else
347 {
348 int length = chlen (actions);
349 int x = 0;
350
351 /* Inject each character one at a time. */
352 for (x = 0; x < length; x++)
353 {
354 ret = injectCDKFselect (fselect, actions[x]);
355 if (fselect->exitType != vEARLY_EXIT)
356 {
357 return ret;
358 }
359 }
360 }
361
362 /* Set the exit type and exit. */
363 setExitType (fselect, 0);
364 return 0;
365 }
366
367 /*
368 * This injects a single character into the file selector.
369 */
370 static int _injectCDKFselect (CDKOBJS *object, chtype input)
371 {
372 CDKFSELECT *fselect = (CDKFSELECT *)object;
373 char *filename;
374 boolean file;
375 char *ret = unknownString;
376 bool complete = FALSE;
377
378 /* Let the user play. */
379 filename = injectCDKEntry (fselect->entryField, input);
380
381 /* Copy the entry field exitType to the fileselector. */
382 copyExitType (fselect, fselect->entryField);
383
384 /* If we exited early, make sure we don't interpret it as a file. */
385 if (fselect->exitType == vEARLY_EXIT)
386 {
387 return 0;
388 }
389
390 /* Can we change into the directory? */
391 file = chdir (filename);
392 chdir (fselect->pwd);
393
394 /* If it's not a directory, return the filename. */
395 if (file != 0)
396 {
397 /* It's a regular file, create the full path. */
398 fselect->pathname = copyChar (filename);
399
400 /* Return the complete pathname. */
401 ret = (fselect->pathname);
402 complete = TRUE;
403 }
404 else
405 {
406 /* Set the file selector information. */
407 setCDKFselect (fselect, filename,
408 fselect->fieldAttribute, fselect->fillerCharacter,
409 fselect->highlight,
410 fselect->dirAttribute, fselect->fileAttribute,
411 fselect->linkAttribute, fselect->sockAttribute,
412 ObjOf (fselect)->box);
413
414 /* Redraw the scrolling list. */
415 drawMyScroller (fselect);
416 }
417
418 if (!complete)
419 setExitType (fselect, 0);
420
421 ResultOf (fselect).valueString = ret;
422 return (ret != unknownString);
423 }
424
425 /*
426 * This function sets the information inside the file selector.
427 */
428 void setCDKFselect (CDKFSELECT *fselect,
429 char *directory,
430 chtype fieldAttrib,
431 chtype filler,
432 chtype highlight,
433 char *dirAttribute,
434 char *fileAttribute,
435 char *linkAttribute,
436 char *sockAttribute,
437 boolean Box GCC_UNUSED)
438 {
439 CDKSCROLL *fscroll = fselect->scrollField;
440 CDKENTRY *fentry = fselect->entryField;
441 char *tempDir = 0;
442 char *mesg[10];
443 char *newDirectory;
444
445 /* Keep the info sent to us. */
446 fselect->fieldAttribute = fieldAttrib;
447 fselect->fillerCharacter = filler;
448 fselect->highlight = highlight;
449
450 /* Set the attributes of the entry field/scrolling list. */
451 setCDKEntryFillerChar (fentry, filler);
452 setCDKScrollHighlight (fscroll, highlight);
453
454 /* Only do the directory stuff if the directory is not null. */
455 if (directory != 0)
456 {
457 /* Try to expand the directory if it starts with a ~ */
458 if ((tempDir = expandTilde (directory)) != 0)
459 {
460 newDirectory = tempDir;
461 }
462 else
463 {
464 newDirectory = copyChar (directory);
465 }
466
467 /* Change directories. */
468 if (chdir (newDirectory) != 0)
469 {
470 Beep ();
471
472 /* Could not get into the directory, pop up a little message. */
473 mesg[0] = format1String ("<C>Could not change into %s", newDirectory);
474 mesg[1] = errorMessage ("<C></U>%s");
475 mesg[2] = copyChar (" ");
476 mesg[3] = copyChar ("<C>Press Any Key To Continue.");
477
478 /* Pop Up a message. */
479 popupLabel (ScreenOf (fselect), mesg, 4);
480
481 /* Clean up some memory. */
482 freeCharList (mesg, 4);
483
484 /* Get out of here. */
485 eraseCDKFselect (fselect);
486 drawCDKFselect (fselect, ObjOf (fselect)->box);
487 freeChar (newDirectory);
488 return;
489 }
490 freeChar (newDirectory);
491 }
492
493 /*
494 * If the information coming in is the same as the information
495 * that is already there, there is no need to destroy it.
496 */
497 if (fselect->pwd != directory)
498 {
499 setPWD (fselect);
500 }
501 if (fselect->fileAttribute != fileAttribute)
502 {
503 /* Remove the old pointer and set the new value. */
504 freeChar (fselect->fileAttribute);
505 fselect->fileAttribute = copyChar (fileAttribute);
506 }
507 if (fselect->dirAttribute != dirAttribute)
508 {
509 /* Remove the old pointer and set the new value. */
510 freeChar (fselect->dirAttribute);
511 fselect->dirAttribute = copyChar (dirAttribute);
512 }
513 if (fselect->linkAttribute != linkAttribute)
514 {
515 /* Remove the old pointer and set the new value. */
516 freeChar (fselect->linkAttribute);
517 fselect->linkAttribute = copyChar (linkAttribute);
518 }
519 if (fselect->sockAttribute != sockAttribute)
520 {
521 /* Remove the old pointer and set the new value. */
522 freeChar (fselect->sockAttribute);
523 fselect->sockAttribute = copyChar (sockAttribute);
524 }
525
526 /* Set the contents of the entry field. */
527 setCDKEntryValue (fentry, fselect->pwd);
528 drawCDKEntry (fentry, ObjOf (fentry)->box);
529
530 /* Get the directory contents. */
531 if (setCDKFselectDirContents (fselect) == 0)
532 {
533 Beep ();
534 return;
535 }
536
537 /* Set the values in the scrolling list. */
538 setCDKScrollItems (fscroll,
539 fselect->dirContents,
540 fselect->fileCounter,
541 FALSE);
542 }
543
544 /*
545 * This creates a list of the files in the current directory.
546 */
547 int setCDKFselectDirContents (CDKFSELECT *fselect)
548 {
549 struct stat fileStat;
550 char **dirList = 0;
551 char *oldItem;
552 int fileCount;
553 int x = 0;
554
555 /* Get the directory contents. */
556 fileCount = CDKgetDirectoryContents (fselect->pwd, &dirList);
557 if (fileCount <= 0)
558 {
559 /* We couldn't read the directory. Return. */
560 CDKfreeStrings (dirList);
561 return 0;
562 }
563
564 /* Clean out the old directory list. */
565 CDKfreeStrings (fselect->dirContents);
566 fselect->dirContents = dirList;
567 fselect->fileCounter = fileCount;
568
569 /* Set the properties of the files. */
570 for (x = 0; x < fselect->fileCounter; x++)
571 {
572 char *attr = "";
573 char *mode = "?";
574
575 /* FIXME: access() would give a more correct answer */
576 if (lstat (dirList[x], &fileStat) == 0)
577 {
578 mode = " ";
579 if (((fileStat.st_mode & S_IXUSR) != 0) ||
580 ((fileStat.st_mode & S_IXGRP) != 0) ||
581 ((fileStat.st_mode & S_IXOTH) != 0))
582 {
583 mode = "*";
584 }
585 }
586
587 switch (mode2Filetype (fileStat.st_mode))
588 {
589 case 'l':
590 attr = fselect->linkAttribute;
591 mode = "@";
592 break;
593 case '@':
594 attr = fselect->sockAttribute;
595 mode = "&";
596 break;
597 case '-':
598 attr = fselect->fileAttribute;
599 break;
600 case 'd':
601 attr = fselect->dirAttribute;
602 mode = "/";
603 break;
604 default:
605 break;
606 }
607 oldItem = dirList[x];
608 fselect->dirContents[x] = format3String ("%s%s%s", attr, dirList[x], mode);
609 free (oldItem);
610 }
611 return 1;
612 }
613
614 char **getCDKFselectDirContents (CDKFSELECT *fselect, int *count)
615 {
616 (*count) = fselect->fileCounter;
617 return fselect->dirContents;
618 }
619
620 /*
621 * This sets the current directory of the file selector.
622 */
623 int setCDKFselectDirectory (CDKFSELECT *fselect, char *directory)
624 {
625 CDKENTRY *fentry = fselect->entryField;
626 CDKSCROLL *fscroll = fselect->scrollField;
627 int result = 1;
628
629 /*
630 * If the directory supplied is the same as what is already
631 * there, return.
632 */
633 if (fselect->pwd != directory)
634 {
635 /* Try to chdir into the given directory. */
636 if (chdir (directory) != 0)
637 {
638 result = 0;
639 }
640 else
641 {
642 setPWD (fselect);
643
644 /* Set the contents of the entry field. */
645 setCDKEntryValue (fentry, fselect->pwd);
646 drawCDKEntry (fentry, ObjOf (fentry)->box);
647
648 /* Get the directory contents. */
649 if (setCDKFselectDirContents (fselect) == 0)
650 {
651 result = 0;
652 }
653 else
654 {
655 /* Set the values in the scrolling list. */
656 setCDKScrollItems (fscroll,
657 fselect->dirContents,
658 fselect->fileCounter,
659 FALSE);
660 }
661 }
662 }
663 return result;
664 }
665 char *getCDKFselectDirectory (CDKFSELECT *fselect)
666 {
667 return fselect->pwd;
668 }
669
670 /*
671 * This sets the filler character of the entry field.
672 */
673 void setCDKFselectFillerChar (CDKFSELECT *fselect, chtype filler)
674 {
675 CDKENTRY *fentry = fselect->entryField;
676 fselect->fillerCharacter = filler;
677 setCDKEntryFillerChar (fentry, filler);
678 }
679 chtype getCDKFselectFillerChar (CDKFSELECT *fselect)
680 {
681 return fselect->fillerCharacter;
682 }
683
684 /*
685 * This sets the highlight bar of the scrolling list.
686 */
687 void setCDKFselectHighlight (CDKFSELECT *fselect, chtype highlight)
688 {
689 CDKSCROLL *fscroll = (CDKSCROLL *)fselect->scrollField;
690 fselect->highlight = highlight;
691 setCDKScrollHighlight (fscroll, highlight);
692
693 }
694 chtype getCDKFselectHighlight (CDKFSELECT *fselect)
695 {
696 return fselect->highlight;
697 }
698
699 /*
700 * This sets the attribute of the directory attribute in the
701 * scrolling list.
702 */
703 void setCDKFselectDirAttribute (CDKFSELECT *fselect, char *attribute)
704 {
705 /* Make sure they are not the same. */
706 if (fselect->dirAttribute != attribute)
707 {
708 freeChar (fselect->dirAttribute);
709 fselect->dirAttribute = copyChar (attribute);
710
711 setCDKFselectDirContents (fselect);
712 }
713 }
714 char *getCDKFselectDirAttribute (CDKFSELECT *fselect)
715 {
716 return fselect->dirAttribute;
717 }
718
719 /*
720 * This sets the attribute of the link attribute in the
721 * scrolling list.
722 */
723 void setCDKFselectLinkAttribute (CDKFSELECT *fselect, char *attribute)
724 {
725 /* Make sure they are not the same. */
726 if (fselect->linkAttribute != attribute)
727 {
728 freeChar (fselect->linkAttribute);
729 fselect->linkAttribute = copyChar (attribute);
730
731 setCDKFselectDirContents (fselect);
732 }
733 }
734 char *getCDKFselectLinkAttribute (CDKFSELECT *fselect)
735 {
736 return fselect->linkAttribute;
737 }
738
739 /*
740 * This sets the attribute of the link attribute in the
741 * scrolling list.
742 */
743 void setCDKFselectSocketAttribute (CDKFSELECT *fselect, char *attribute)
744 {
745 /* Make sure they are not the same. */
746 if (fselect->sockAttribute != attribute)
747 {
748 freeChar (fselect->sockAttribute);
749 fselect->sockAttribute = copyChar (attribute);
750
751 setCDKFselectDirContents (fselect);
752 }
753 }
754 char *getCDKFselectSocketAttribute (CDKFSELECT *fselect)
755 {
756 return fselect->sockAttribute;
757 }
758
759 /*
760 * This sets the attribute of the link attribute in the
761 * scrolling list.
762 */
763 void setCDKFselectFileAttribute (CDKFSELECT *fselect, char *attribute)
764 {
765 /* Make sure they are not the same. */
766 if (fselect->fileAttribute != attribute)
767 {
768 freeChar (fselect->fileAttribute);
769 fselect->fileAttribute = copyChar (attribute);
770
771 setCDKFselectDirContents (fselect);
772 }
773 }
774 char *getCDKFselectFileAttribute (CDKFSELECT *fselect)
775 {
776 return fselect->fileAttribute;
777 }
778
779 /*
780 * This sets the box attribute of the widget.
781 */
782 void setCDKFselectBox (CDKFSELECT *fselect, boolean Box)
783 {
784 ObjOf (fselect)->box = Box;
785 ObjOf (fselect)->borderSize = Box ? 1 : 0;
786 }
787 boolean getCDKFselectBox (CDKFSELECT *fselect)
788 {
789 return ObjOf (fselect)->box;
790 }
791
792 /*
793 * This sets the contents of the widget
794 */
795 void setCDKFselectContents (CDKFSELECT *widget,
796 char **list,
797 int listSize)
798 {
799 CDKSCROLL *scrollp = widget->scrollField;
800 CDKENTRY *entry = widget->entryField;
801
802 if (!createList (widget, list, listSize))
803 return;
804
805 /* Set the information in the scrolling list. */
806 setCDKScroll (scrollp,
807 widget->dirContents,
808 widget->fileCounter,
809 NONUMBERS,
810 scrollp->highlight,
811 ObjOf (scrollp)->box);
812
813 /* Clean out the entry field. */
814 setCDKFselectCurrentItem (widget, 0);
815 cleanCDKEntry (entry);
816
817 /* Redraw the widget. */
818 eraseCDKFselect (widget);
819 drawCDKFselect (widget, ObjOf (widget)->box);
820 }
821
822 char **getCDKFselectContents (CDKFSELECT *widget,
823 int *size)
824 {
825 (*size) = widget->fileCounter;
826 return widget->dirContents;
827 }
828
829 /*
830 * Get/set the current position in the scroll-widget.
831 */
832 int getCDKFselectCurrentItem (CDKFSELECT *widget)
833 {
834 return getCDKScrollCurrent (widget->scrollField);
835 }
836
837 void setCDKFselectCurrentItem (CDKFSELECT *widget,
838 int item)
839 {
840 if (widget->fileCounter != 0)
841 {
842 char *data;
843
844 setCDKScrollCurrent (widget->scrollField, item);
845
846 data = contentToPath (widget,
847 widget->dirContents[getCDKScrollCurrentItem (widget->scrollField)]);
848 setCDKEntryValue (widget->entryField, data);
849
850 free (data);
851 }
852 }
853
854 /*
855 * These functions set the drawing characters of the widget.
856 */
857 static void _setMyULchar (CDKOBJS *object, chtype character)
858 {
859 CDKFSELECT *fselect = (CDKFSELECT *)object;
860
861 setCDKEntryULChar (fselect->entryField, character);
862 }
863 static void _setMyURchar (CDKOBJS *object, chtype character)
864 {
865 CDKFSELECT *fselect = (CDKFSELECT *)object;
866
867 setCDKEntryURChar (fselect->entryField, character);
868 }
869 static void _setMyLLchar (CDKOBJS *object, chtype character)
870 {
871 CDKFSELECT *fselect = (CDKFSELECT *)object;
872
873 setCDKScrollLLChar (fselect->scrollField, character);
874 }
875 static void _setMyLRchar (CDKOBJS *object, chtype character)
876 {
877 CDKFSELECT *fselect = (CDKFSELECT *)object;
878
879 setCDKScrollLRChar (fselect->scrollField, character);
880 }
881 static void _setMyVTchar (CDKOBJS *object, chtype character)
882 {
883 CDKFSELECT *fselect = (CDKFSELECT *)object;
884
885 setCDKEntryVerticalChar (fselect->entryField, character);
886 setCDKScrollVerticalChar (fselect->scrollField, character);
887 }
888 static void _setMyHZchar (CDKOBJS *object, chtype character)
889 {
890 CDKFSELECT *fselect = (CDKFSELECT *)object;
891
892 setCDKEntryHorizontalChar (fselect->entryField, character);
893 setCDKScrollHorizontalChar (fselect->scrollField, character);
894 }
895 static void _setMyBXattr (CDKOBJS *object, chtype character)
896 {
897 CDKFSELECT *fselect = (CDKFSELECT *)object;
898
899 setCDKEntryBoxAttribute (fselect->entryField, character);
900 setCDKScrollBoxAttribute (fselect->scrollField, character);
901 }
902
903 /*
904 * This sets the background attribute of the widget.
905 */
906 static void _setBKattrFselect (CDKOBJS *object, chtype attrib)
907 {
908 if (object != 0)
909 {
910 CDKFSELECT *widget = (CDKFSELECT *)object;
911
912 setCDKEntryBackgroundAttrib (widget->entryField, attrib);
913 setCDKScrollBackgroundAttrib (widget->scrollField, attrib);
914 }
915 }
916
917 /*
918 * This destroys the file selector.
919 */
920 static void _destroyCDKFselect (CDKOBJS *object)
921 {
922 if (object != 0)
923 {
924 CDKFSELECT *fselect = (CDKFSELECT *)object;
925
926 cleanCDKObjectBindings (vFSELECT, fselect);
927
928 /* Free up the character pointers. */
929 freeChar (fselect->pwd);
930 freeChar (fselect->pathname);
931 freeChar (fselect->dirAttribute);
932 freeChar (fselect->fileAttribute);
933 freeChar (fselect->linkAttribute);
934 freeChar (fselect->sockAttribute);
935 CDKfreeStrings (fselect->dirContents);
936
937 /* Destroy the other Cdk objects. */
938 destroyCDKScroll (fselect->scrollField);
939 destroyCDKEntry (fselect->entryField);
940
941 /* Free up the window pointers. */
942 deleteCursesWindow (fselect->shadowWin);
943 deleteCursesWindow (fselect->win);
944
945 /* Clean the key bindings. */
946 /* Unregister the object. */
947 unregisterCDKObject (vFSELECT, fselect);
948 }
949 }
950
951 /*
952 ********************************
953 * Callback functions.
954 ********************************
955 */
956
957 /*
958 * This is a callback to the scrolling list which displays information
959 * about the current file. (and the whole directory as well)
960 */
961 static int displayFileInfoCB (EObjectType objectType GCC_UNUSED,
962 void *object,
963 void *clientData,
964 chtype key GCC_UNUSED)
965 {
966 CDKENTRY *entry = (CDKENTRY *)object;
967 CDKFSELECT *fselect = (CDKFSELECT *)clientData;
968 CDKLABEL *infoLabel;
969 struct stat fileStat;
970 struct passwd *pwEnt;
971 struct group *grEnt;
972 char *filename;
973 char *filetype;
974 char *mesg[10];
975 char stringMode[15];
976 int intMode;
977 boolean functionKey;
978
979 /* Get the file name. */
980 filename = fselect->entryField->info;
981
982 /* Get specific information about the files. */
983 lstat (filename, &fileStat);
984
985 /* Determine the file type. */
986 switch (mode2Filetype (fileStat.st_mode))
987 {
988 case 'l':
989 filetype = "Symbolic Link";
990 break;
991 case '@':
992 filetype = "Socket";
993 break;
994 case '-':
995 filetype = "Regular File";
996 break;
997 case 'd':
998 filetype = "Directory";
999 break;
1000 case 'c':
1001 filetype = "Character Device";
1002 break;
1003 case 'b':
1004 filetype = "Block Device";
1005 break;
1006 case '&':
1007 filetype = "FIFO Device";
1008 break;
1009 default:
1010 filetype = "Unknown";
1011 break;
1012 }
1013
1014 /* Get the user name and group name. */
1015 pwEnt = getpwuid (fileStat.st_uid);
1016 grEnt = getgrgid (fileStat.st_gid);
1017
1018 /* Convert the mode_t type to both string and int. */
1019 intMode = mode2Char (stringMode, fileStat.st_mode);
1020
1021 /* Create the message. */
1022 mesg[0] = format1String ("Directory : </U>%s", fselect->pwd);
1023 mesg[1] = format1String ("Filename : </U>%s", filename);
1024 mesg[2] = format1StrVal ("Owner : </U>%s<!U> (%d)", pwEnt->pw_name, (int)fileStat.st_uid);
1025 mesg[3] = format1StrVal ("Group : </U>%s<!U> (%d)", grEnt->gr_name, (int)fileStat.st_gid);
1026 mesg[4] = format1StrVal ("Permissions: </U>%s<!U> (%o)", stringMode, intMode);
1027 mesg[5] = format1Number ("Size : </U>%ld<!U> bytes", (long) fileStat.st_size);
1028 mesg[6] = format1Date ("Last Access: </U>%s", fileStat.st_atime);
1029 mesg[7] = format1Date ("Last Change: </U>%s", fileStat.st_ctime);
1030 mesg[8] = format1String ("File Type : </U>%s", filetype);
1031
1032 /* Create the pop up label. */
1033 infoLabel = newCDKLabel (entry->obj.screen,
1034 CENTER, CENTER,
1035 mesg, 9,
1036 TRUE, FALSE);
1037 drawCDKLabel (infoLabel, TRUE);
1038 getchCDKObject (ObjOf (infoLabel), &functionKey);
1039
1040 /* Clean up some memory. */
1041 destroyCDKLabel (infoLabel);
1042 freeCharList (mesg, 9);
1043
1044 /* Redraw the file selector. */
1045 drawCDKFselect (fselect, ObjOf (fselect)->box);
1046 return (TRUE);
1047 }
1048
1049 static char *make_pathname (char *directory, char *filename)
1050 {
1051 unsigned need = strlen (filename) + 2;
1052 bool root = (strcmp (directory, "/") == 0);
1053 char *result;
1054
1055 if (!root)
1056 need += strlen (directory);
1057 if ((result = (char *)malloc (need)) != 0)
1058 {
1059 if (root)
1060 sprintf (result, "/%s", filename);
1061 else
1062 sprintf (result, "%s/%s", directory, filename);
1063 }
1064 return result;
1065 }
1066
1067 /*
1068 * Return the plain string that corresponds to an item in dirContents[].
1069 */
1070 static char *contentToPath (CDKFSELECT *fselect, char *content)
1071 {
1072 chtype *tempChtype;
1073 char *tempChar;
1074 char *result;
1075 int j, j2;
1076
1077 tempChtype = char2Chtype (content, &j, &j2);
1078 tempChar = chtype2Char (tempChtype);
1079 trim1Char (tempChar); /* trim the 'mode' stored on the end */
1080
1081 /* Create the pathname. */
1082 result = make_pathname (fselect->pwd, tempChar);
1083
1084 /* Clean up. */
1085 freeChtype (tempChtype);
1086 freeChar (tempChar);
1087 return result;
1088 }
1089
1090 /*
1091 * This tries to complete the filename.
1092 */
1093 static int completeFilenameCB (EObjectType objectType GCC_UNUSED,
1094 void *object GCC_UNUSED,
1095 void *clientData,
1096 chtype key GCC_UNUSED)
1097 {
1098 CDKFSELECT *fselect = (CDKFSELECT *)clientData;
1099 CDKSCROLL *scrollp = fselect->scrollField;
1100 CDKENTRY *entry = fselect->entryField;
1101 char *filename = copyChar (entry->info);
1102 char *mydirname = dirName (filename);
1103 char *newFilename = 0;
1104 unsigned filenameLen = 0;
1105 int currentIndex = 0;
1106 int matches = 0;
1107 int baseChars = 0;
1108 int secondaryMatches = 0;
1109 int isDirectory;
1110 char **list;
1111 int Index, pos, x;
1112 int difference, absoluteDifference;
1113
1114 /* Make sure the filename is not null/empty. */
1115 if (filename == 0 ||
1116 (filenameLen = strlen (filename)) == 0)
1117 {
1118 Beep ();
1119 freeChar (filename);
1120 return (TRUE);
1121 }
1122
1123 /* Try to expand the filename if it starts with a ~ */
1124 if ((newFilename = expandTilde (filename)) != 0)
1125 {
1126 freeChar (filename);
1127 filename = newFilename;
1128 setCDKEntryValue (entry, filename);
1129 drawCDKEntry (entry, ObjOf (entry)->box);
1130 }
1131
1132 /* Make sure we can change into the directory. */
1133 isDirectory = chdir (filename);
1134 chdir (fselect->pwd);
1135
1136 setCDKFselect (fselect,
1137 isDirectory ? mydirname : filename,
1138 fselect->fieldAttribute,
1139 fselect->fillerCharacter,
1140 fselect->highlight,
1141 fselect->dirAttribute,
1142 fselect->fileAttribute,
1143 fselect->linkAttribute,
1144 fselect->sockAttribute,
1145 ObjOf (fselect)->box);
1146 freeChar (mydirname);
1147
1148 /* If we can, change into the directory. */
1149 if (isDirectory)
1150 {
1151 /*
1152 * Set the entry field with the filename so the current
1153 * filename selection shows up.
1154 */
1155 setCDKEntryValue (entry, filename);
1156 drawCDKEntry (entry, ObjOf (entry)->box);
1157 }
1158
1159 /* Create the file list. */
1160 if ((list = typeMallocN (char *, fselect->fileCounter)) != 0)
1161 {
1162 for (x = 0; x < fselect->fileCounter; x++)
1163 {
1164 list[x] = contentToPath (fselect, fselect->dirContents[x]);
1165 }
1166
1167 /* Look for a unique filename match. */
1168 Index = searchList (list, fselect->fileCounter, filename);
1169
1170 /* If the index is less than zero, return we didn't find a match. */
1171 if (Index < 0)
1172 {
1173 Beep ();
1174 }
1175 else
1176 {
1177 /* Move to the current item in the scrolling list. */
1178 difference = Index - scrollp->currentItem;
1179 absoluteDifference = abs (difference);
1180 if (difference < 0)
1181 {
1182 for (x = 0; x < absoluteDifference; x++)
1183 {
1184 injectMyScroller (fselect, KEY_UP);
1185 }
1186 }
1187 else if (difference > 0)
1188 {
1189 for (x = 0; x < absoluteDifference; x++)
1190 {
1191 injectMyScroller (fselect, KEY_DOWN);
1192 }
1193 }
1194 drawMyScroller (fselect);
1195
1196 /* Ok, we found a match, is the next item similar? */
1197 if (Index+1 < fselect->fileCounter &&
1198 0 != list[Index+1] &&
1199 0 == strncmp (list[Index + 1], filename, filenameLen))
1200 {
1201 currentIndex = Index;
1202 baseChars = filenameLen;
1203 matches = 0;
1204 pos = 0;
1205
1206 /* Determine the number of files which match. */
1207 while (currentIndex < fselect->fileCounter)
1208 {
1209 if (list[currentIndex] != 0)
1210 {
1211 if (strncmp (list[currentIndex], filename, filenameLen) == 0)
1212 {
1213 matches++;
1214 }
1215 }
1216 currentIndex++;
1217 }
1218
1219 /* Start looking for the common base characters. */
1220 for (;;)
1221 {
1222 secondaryMatches = 0;
1223 for (x = Index; x < Index + matches; x++)
1224 {
1225 if (list[Index][baseChars] == list[x][baseChars])
1226 {
1227 secondaryMatches++;
1228 }
1229 }
1230
1231 if (secondaryMatches != matches)
1232 {
1233 Beep ();
1234 break;
1235 }
1236
1237 /* Inject the character into the entry field. */
1238 injectCDKEntry (fselect->entryField, list[Index][baseChars]);
1239 baseChars++;
1240 }
1241 }
1242 else
1243 {
1244 /* Set the entry field with the found item. */
1245 setCDKEntryValue (entry, list[Index]);
1246 drawCDKEntry (entry, ObjOf (entry)->box);
1247 }
1248 }
1249 freeCharList (list, fselect->fileCounter);
1250 free (list);
1251 }
1252 freeChar (filename);
1253 return (TRUE);
1254 }
1255
1256 /*
1257 * This allows the user to delete a file.
1258 */
1259 void deleteFileCB (EObjectType objectType GCC_UNUSED, void *object, void *clientData)
1260 {
1261 CDKSCROLL *fscroll = (CDKSCROLL *)object;
1262 CDKFSELECT *fselect = (CDKFSELECT *)clientData;
1263 char *buttons[] = {"No", "Yes"};
1264 CDKDIALOG *question;
1265 char *mesg[10], *filename;
1266
1267 /* Get the filename which is to be deleted. */
1268 filename = chtype2Char (fscroll->item[fscroll->currentItem]);
1269 trim1Char (filename);
1270
1271 /* Create the dialog message. */
1272 mesg[0] = copyChar ("<C>Are you sure you want to delete the file:");
1273 mesg[1] = format1String ("<C></U>\"%s\"?", filename);
1274
1275 /* Create the dialog box. */
1276 question = newCDKDialog (ScreenOf (fselect), CENTER, CENTER,
1277 mesg, 2, buttons, 2, A_REVERSE,
1278 TRUE, TRUE, FALSE);
1279 freeCharList (mesg, 2);
1280
1281 /* If the said yes then try to nuke it. */
1282 if (activateCDKDialog (question, 0) == 1)
1283 {
1284 /* If we were successful, reload the scrolling list. */
1285 if (unlink (filename) == 0)
1286 {
1287 /* Set the file selector information. */
1288 setCDKFselect (fselect, fselect->pwd,
1289 fselect->fieldAttribute,
1290 fselect->fillerCharacter,
1291 fselect->highlight,
1292 fselect->dirAttribute,
1293 fselect->fileAttribute,
1294 fselect->linkAttribute,
1295 fselect->sockAttribute,
1296 ObjOf (fselect)->box);
1297 }
1298 else
1299 {
1300 /* Pop up a message. */
1301 mesg[0] = copyChar (errorMessage ("<C>Cannot delete file: %s"));
1302 mesg[1] = copyChar (" ");
1303 mesg[2] = copyChar ("<C>Press any key to continue.");
1304 popupLabel (ScreenOf (fselect), mesg, 3);
1305 freeCharList (mesg, 3);
1306 }
1307 }
1308
1309 /* Clean up. */
1310 destroyCDKDialog (question);
1311
1312 /* Redraw the file selector. */
1313 drawCDKFselect (fselect, ObjOf (fselect)->box);
1314 }
1315
1316 /*
1317 * This function sets the pre-process function.
1318 */
1319 void setCDKFselectPreProcess (CDKFSELECT *fselect, PROCESSFN callback, void *data)
1320 {
1321 setCDKEntryPreProcess (fselect->entryField, callback, data);
1322 setCDKScrollPreProcess (fselect->scrollField, callback, data);
1323 }
1324
1325 /*
1326 * This function sets the post-process function.
1327 */
1328 void setCDKFselectPostProcess (CDKFSELECT *fselect, PROCESSFN callback, void *data)
1329 {
1330 setCDKEntryPostProcess (fselect->entryField, callback, data);
1331 setCDKScrollPostProcess (fselect->scrollField, callback, data);
1332 }
1333
1334 /*
1335 * Start of callback functions.
1336 */
1337 static int fselectAdjustScrollCB (EObjectType objectType GCC_UNUSED,
1338 void *object GCC_UNUSED,
1339 void *clientData,
1340 chtype key)
1341 {
1342 CDKFSELECT *fselect = (CDKFSELECT *)clientData;
1343 CDKSCROLL *scrollp = (CDKSCROLL *)fselect->scrollField;
1344 CDKENTRY *entry = (CDKENTRY *)fselect->entryField;
1345 char *current;
1346 char *temp;
1347
1348 if (scrollp->listSize > 0)
1349 {
1350 /* Move the scrolling list. */
1351 injectMyScroller (fselect, key);
1352
1353 /* Get the currently highlighted filename. */
1354 current = chtype2Char (scrollp->item[scrollp->currentItem]);
1355 trim1Char (current);
1356
1357 temp = make_pathname (fselect->pwd, current);
1358
1359 /* Set the value in the entry field. */
1360 setCDKEntryValue (entry, temp);
1361 drawCDKEntry (entry, ObjOf (entry)->box);
1362
1363 freeChar (current);
1364 freeChar (temp);
1365 return (TRUE);
1366 }
1367 Beep ();
1368 return (FALSE);
1369 }
1370
1371 /*
1372 * trim the 'mode' from a copy of a dirContents[] entry.
1373 */
1374 static char *trim1Char (char *source)
1375 {
1376 unsigned len;
1377
1378 if ((len = strlen (source)) != 0)
1379 source[--len] = '\0';
1380 return source;
1381 }
1382
1383 static char *format1Date (char *format, time_t value)
1384 {
1385 char *result;
1386 char *temp = ctime (&value);
1387
1388 if ((result = (char *)malloc (strlen (format) + strlen (temp))) != 0)
1389 {
1390 sprintf (result, format, trim1Char (temp));
1391 }
1392 return result;
1393 }
1394
1395 static char *format1Number (char *format, long value)
1396 {
1397 char *result;
1398
1399 if ((result = (char *)malloc (strlen (format) + 20)) != 0)
1400 sprintf (result, format, value);
1401 return result;
1402 }
1403
1404 static char *format3String (char *format, char *s1, char *s2, char *s3)
1405 {
1406 char *result;
1407
1408 if ((result = (char *)malloc (strlen (format) +
1409 strlen (s1) +
1410 strlen (s2) +
1411 strlen (s3))) != 0)
1412 sprintf (result, format, s1, s2, s3);
1413 return result;
1414 }
1415
1416 static char *format1String (char *format, char *string)
1417 {
1418 char *result;
1419
1420 if ((result = (char *)malloc (strlen (format) + strlen (string))) != 0)
1421 sprintf (result, format, string);
1422 return result;
1423 }
1424
1425 static char *format1StrVal (char *format, char *string, int value)
1426 {
1427 char *result;
1428
1429 if ((result = (char *)malloc (strlen (format) + strlen (string) + 20)) != 0)
1430 sprintf (result, format, string, value);
1431 return result;
1432 }
1433
1434 static char *errorMessage (char *format)
1435 {
1436 char *message;
1437 #ifdef HAVE_STRERROR
1438 message = strerror (errno);
1439 #else
1440 message = "Unknown reason.";
1441 #endif
1442 return format1String (format, message);
1443 }
1444
1445 /*
1446 * This takes a ~ type account name and returns the full pathname.
1447 */
1448 static char *expandTilde (char *filename)
1449 {
1450 char *result = 0;
1451 char *account;
1452 char *pathname;
1453 int len;
1454
1455 /* Make sure the filename is not null/empty, and begins with a tilde */
1456 if ((filename != 0) &&
1457 (len = strlen (filename)) != 0 &&
1458 filename[0] == '~' &&
1459 (account = copyChar (filename)) != 0 &&
1460 (pathname = copyChar (filename)) != 0)
1461 {
1462 bool slash = FALSE;
1463 char *home;
1464 int x;
1465 int len_a = 0;
1466 int len_p = 0;
1467 struct passwd *accountInfo;
1468
1469 /* Find the account name in the filename. */
1470 for (x = 1; x < len; x++)
1471 {
1472 if (filename[x] == '/' && !slash)
1473 {
1474 slash = TRUE;
1475 }
1476 else if (slash)
1477 {
1478 pathname[len_p++] = filename[x];
1479 }
1480 else
1481 {
1482 account[len_a++] = filename[x];
1483 }
1484 }
1485 account[len_a] = '\0';
1486 pathname[len_p] = '\0';
1487
1488 home = 0;
1489 if (strlen (account) != 0 &&
1490 (accountInfo = getpwnam (account)) != 0)
1491 {
1492 home = accountInfo->pw_dir;
1493 }
1494 if (home == 0 || *home == '\0')
1495 home = getenv ("HOME");
1496 if (home == 0 || *home == '\0')
1497 home = "/";
1498
1499 /*
1500 * Construct the full pathname. We do this because someone
1501 * may have a pathname at the end of the account name
1502 * and we want to keep it.
1503 */
1504 result = make_pathname (home, pathname);
1505
1506 freeChar (account);
1507 freeChar (pathname);
1508 }
1509 return result;
1510 }
1511
1512 /*
1513 * Store the name of the current working directory.
1514 */
1515 static void setPWD (CDKFSELECT *fselect)
1516 {
1517 char buffer[512];
1518 freeChar (fselect->pwd);
1519 if (getcwd (buffer, sizeof (buffer)) == 0)
1520 strcpy (buffer, ".");
1521 fselect->pwd = copyChar (buffer);
1522 }
1523
1524 static void destroyInfo (CDKFSELECT *widget)
1525 {
1526 CDKfreeStrings (widget->dirContents);
1527 widget->dirContents = 0;
1528
1529 widget->fileCounter = 0;
1530 }
1531
1532 static int createList (CDKFSELECT *widget, char **list, int listSize)
1533 {
1534 int status = 0;
1535
1536 if (listSize > 0)
1537 {
1538 char **newlist = typeCallocN (char *, listSize + 1);
1539
1540 if (newlist != 0)
1541 {
1542 int x;
1543
1544 /* Copy in the new information. */
1545 status = 1;
1546 for (x = 0; x < listSize; x++)
1547 {
1548 if ((newlist[x] = copyChar (list[x])) == 0)
1549 {
1550 status = 0;
1551 break;
1552 }
1553 }
1554 if (status)
1555 {
1556 destroyInfo (widget);
1557 widget->fileCounter = listSize;
1558 widget->dirContents = newlist;
1559 }
1560 else
1561 {
1562 CDKfreeStrings (newlist);
1563 }
1564 }
1565 }
1566 else
1567 {
1568 destroyInfo (widget);
1569 status = TRUE;
1570 }
1571 return status;
1572 }
1573
1574 static void _focusCDKFselect (CDKOBJS *object)
1575 {
1576 CDKFSELECT *widget = (CDKFSELECT *)object;
1577
1578 FocusObj (ObjOf (widget->entryField));
1579 }
1580
1581 static void _unfocusCDKFselect (CDKOBJS *object)
1582 {
1583 CDKFSELECT *widget = (CDKFSELECT *)object;
1584
1585 UnfocusObj (ObjOf (widget->entryField));
1586 }
1587
1588 dummyRefreshData (Fselect)
1589
1590 dummySaveData (Fselect)
+0
-1152
fulldemo/cdkdemo less more
0 #!/usr/bin/perl -w
1 # $Id: cdkdemo,v 1.5 2002/07/28 19:06:32 tom Exp $
2 #
3 # Purpose:
4 # This script demonstrates the Cdk widget set and how you can use them.
5 #
6
7 #
8 # Use the Cdk module.
9 #
10 use Cdk;
11 Cdk::init();
12
13 # Set up the label rows.
14 my @titleMessage = ("<C></5>This is a CDK demo script<!5>",
15 "<C></5>It will demonstrate all of the<!5>",
16 "<C></5>widgets available with the<!5>",
17 "<C></5/U>Cdk Perl 5 extension.<!5>");
18
19 # Create the title.
20 my $title = new Cdk::Label ('Message' => \@titleMessage, 'Box' => "FALSE");
21
22 # Set some global vars
23 my $CONTINUE = "</B/48>Press Any Key To Continue.<!B!48>";
24 my $HOME = $ENV{'HOME'};
25
26 # Create the menu.
27 my $currentLoc = 0;
28 my @mLoc = ("Switch to Pull-Up Menu ", "Switch to Pull-Down Menu");
29 my @fMenu = ("</5>File<!5>", "</5>Quit<!5>");
30
31 my @iMenu = ("</5>Info<!5>",
32 "</5>Calendar <!5>",
33 "</5>Date <!5>",
34 "</5>Label <!5>",
35 "</5>Scrolling Window<!5>",
36 "</5>Viewer <!5>");
37
38 my @eMenu = ("</5>Entry<!5>",
39 "</5>Entry Field <!5>",
40 "</5>Item List <!5>",
41 "</5>Matrix <!5>",
42 "</5>Multiple Line Entry Field<!5>",
43 "</5>Scale <!5>",
44 "</5>Slider <!5>",
45 "</5>Template <!5>");
46
47 my @lMenu = ("</5>Lists<!5>",
48 "</5>Alpha List <!5>",
49 "</5>Dialog <!5>",
50 "</5>Radio List <!5>",
51 "</5>Scrolling List<!5>",
52 "</5>Selection List<!5>");
53
54 my @mMenu = ("</5>Misc<!5>",
55 "</5>Histogram <!5>",
56 "</5>Graph <!5>",
57 "</5>Marquee <!5>",
58 "</5>Menu <!5>",
59 "</5>$mLoc[$currentLoc]");
60
61 my @hMenu = ("</5>Help<!5>",
62 "</5>General Help<!5>",
63 "</5>Widget Help <!5>",
64 "</5>About... <!5>");
65
66 # Create the pulldown menu menu lists.
67 my @menulist = (\@fMenu, \@iMenu, \@eMenu, \@lMenu, \@mMenu, \@hMenu);
68
69 # Set the location of the menus
70 my @menuloc = ("LEFT", "LEFT", "LEFT", "LEFT", "LEFT", "RIGHT");
71
72 # Create the menu
73 my $menu = new Cdk::Menu ('Menulist' => \@menulist, 'Menuloc' => \@menuloc);
74
75 # Create the callback for the menu.
76 $menu->bind ('Key' => '?', 'Function' => sub { main::menuCallback($menu); });
77
78 # Create the scrolling window.
79 my $swindow = new Cdk::Swindow ('Title' => "<C></U>Menu Selection History<!U>",
80 'Lines' => 200,
81 'Height' => 6,
82 'Width' => 60,
83 'Ypos' => "BOTTOM");
84 my $menuItemCount = 0;
85
86 # Let the user play.
87 for (;;)
88 {
89 # Redraw the screen.
90 Cdk::refreshCdkScreen();
91
92 # Get the selection.
93 my ($submenu, $submenuItem) = $menu->activate();
94 my $menuSelection = $menulist[$submenu]->[$submenuItem];
95
96 # I'm going to use the name, instead of the numeric value to
97 # determine what was picked. But either way is acceptable.
98 if ($menuSelection =~ "Label")
99 {
100 my @mesg = ("<C></B/32>You just selected the Cdk label widget<!B!32>",
101 "<C></B/32>demo. The labels have many personalities<!B!32>",
102 "<C></B/32>To discover them all, use the help option<!B!32>",
103 "<C></B/32>and pick the Label item.<!B!32>", "",
104 "<C>$CONTINUE");
105 labelDemo (@mesg);
106 }
107 elsif ($menuSelection =~ "Calendar")
108 {
109 itemlistDemo();
110 }
111 elsif ($menuSelection =~ "Date")
112 {
113 my $date = qx (date); chomp $date;
114 my @mesg = ("<C>The current time is:", "",
115 "<C></B/24>$date<!B!24>", "",
116 "<C>$CONTINUE");
117 labelDemo (@mesg);
118 }
119 elsif ($menuSelection =~ "Scrolling Window")
120 {
121 # Put a message inside the scrolling window.
122 $swindow->addline ('Info' => "<C></R>This is the scrolling window.<!R> It's purpose");
123 $swindow->addline ('Info' => "<C>is to act as an information window. It also");
124 $swindow->addline ('Info' => "<C>has the ability to display </15>colors<!15>");
125 $swindow->addline ('Info' => "<C>and </B>attributes<!B>.");
126 $swindow->addline ('Info' => "<C>Hit return, tab, or escape to exit this window.");
127 $swindow->activate();
128 }
129 elsif ($menuSelection =~ "Viewer")
130 {
131 viewerDemo();
132 }
133 elsif ($menuSelection =~ "Multiple Line Entry Field")
134 {
135 mentryDemo();
136 }
137 elsif ($menuSelection =~ "Entry Field")
138 {
139 entryDemo();
140 }
141 elsif ($menuSelection =~ "Item List")
142 {
143 itemlistDemo();
144 }
145 elsif ($menuSelection =~ "Template")
146 {
147 templateDemo();
148 }
149 elsif ($menuSelection =~ "Matrix")
150 {
151 matrixDemo();
152 }
153 elsif ($menuSelection =~ "$mLoc[$currentLoc]")
154 {
155 # We are going to switch the menu type.
156 if ($currentLoc == 0)
157 {
158 # Pull-Down to Pull-Up
159 $currentLoc = 1;
160 @mMenu = ("</5>Misc<!5>",
161 "</5>Histogram <!5>",
162 "</5>Graph <!5>",
163 "</5>Marquee <!5>",
164 "</5>Menu <!5>",
165 "</5>$mLoc[$currentLoc]");
166 @menulist = (\@fMenu, \@iMenu, \@eMenu, \@lMenu, \@mMenu, \@hMenu);
167 undef $menu;
168 $menu = new Cdk::Menu ('Menulist' => \@menulist,
169 'Menuloc' => \@menuloc,
170 'Tattrib' => $highlight,
171 'Menupos' => "BOTTOM",
172 'SubTattrib' => $highlight);
173 }
174 elsif ($currentLoc == 1)
175 {
176 # Pull-Up to Pull-Down
177 $currentLoc = 0;
178 @mMenu = ("</5>Misc<!5>",
179 "</5>Histogram <!5>",
180 "</5>Graph <!5>",
181 "</5>Marquee <!5>",
182 "</5>Menu <!5>",
183 "</5>$mLoc[$currentLoc]");
184 @menulist = (\@fMenu, \@iMenu, \@eMenu, \@lMenu, \@mMenu, \@hMenu);
185 undef $menu;
186 $menu = new Cdk::Menu ('Menulist' => \@menulist,
187 'Menuloc' => \@menuloc,
188 'Tattrib' => $highlight,
189 'Menupos' => "TOP",
190 'SubTattrib' => $highlight);
191 }
192 }
193 elsif ($menuSelection =~ "Menu")
194 {
195 # Pop up a message stating what we got.
196 my @mesg = ("<C>The Cdk Menu widget is what",
197 "is driving this application.", "",
198 "<C>$CONTINUE");
199 labelDemo (@mesg);
200 }
201 elsif ($menuSelection =~ "Dialog")
202 {
203 dialogDemo();
204 }
205 elsif ($menuSelection =~ "Scrolling List")
206 {
207 scrollDemo();
208 }
209 elsif ($menuSelection =~ "Selection List")
210 {
211 selectionDemo();
212 }
213 elsif ($menuSelection =~ "Radio List")
214 {
215 radioDemo();
216 }
217 elsif ($menuSelection =~ "Histogram")
218 {
219 histogramDemo();
220 }
221 elsif ($menuSelection =~ "Graph")
222 {
223 graphDemo();
224 }
225 elsif ($menuSelection =~ "Scale")
226 {
227 scaleDemo();
228 }
229 elsif ($menuSelection =~ "Slider")
230 {
231 sliderDemo();
232 }
233 elsif ($menuSelection =~ "Marquee")
234 {
235 marqueeDemo();
236 }
237 elsif ($menuSelection =~ "Alpha List")
238 {
239 alphalistDemo();
240 }
241 elsif ($menuSelection =~ "General Help")
242 {
243 generalHelp();
244 }
245 elsif ($menuSelection =~ "Widget Help")
246 {
247 widgetHelp();
248 }
249 elsif ($menuSelection =~ "About...")
250 {
251 # Pop up a message about this script.
252 my @mesg = ("<C></U/40>Cdk Perl 5 Extension<!U!40>",
253 "<C></32>Written by Mike Glover<!32>", "",
254 "</16>Created : December, 1995<!16>",
255 "</16>Last Updated: April, 1997<!16>", "",
256 $CONTINUE);
257 my $label = new Cdk::Label ('Message' => \@mesg, 'Shadow' => "TRUE");
258 $label->draw();
259 $label->wait();
260 }
261 elsif ($menuSelection =~ "Quit")
262 {
263 # Add a message to the scrolling window.
264 $swindow->addline ('Info' => "<C>Goodbye...");
265 sleep 2;
266
267 # Exit.
268 Cdk::end();
269 exit (1);
270 }
271
272 # Add the chosen item to the scrolling window.
273 my $item = $menulist[$submenu]->[0] . "->" . $menuSelection;
274 $swindow->addline ('Info' => "$menuItemCount : $item");
275 $menuItemCount++;
276 }
277
278 ##############################################################################
279 #
280 # This demonstrates the Cdk label widget.
281 #
282 sub labelDemo
283 {
284 my @mesg = @_;
285
286 # Create the label.
287 my $label = new Cdk::Label ('Message' => \@mesg);
288
289 # Draw the label and wait.
290 $label->draw();
291 $label->wait();
292 }
293
294 ##############################################################################
295 #
296 # This demostrates the Cdk viewer widget.
297 #
298 sub viewerDemo
299 {
300 # Use the file selector widget to get a filename.
301 my $fselect = new Cdk::Fselect ('Label' => "Filename:",
302 'Height' => 20,
303 'Width' => 50,
304 'Dattrib' => "</16/B>",
305 'Lattrib' => "</39>",
306 'Fattrib' => "</40>");
307 my $fname = $fselect->activate ();
308 $fselect->erase ();
309
310 # Check if the person hit escape.
311 if (!defined $fname)
312 {
313 return;
314 }
315
316 # Popup a file viewer.
317 my $viewer = new Cdk::Viewer ('Buttons' => ["OK"],
318 'Height' => 0,
319 'Width' => -2);
320
321 # Load in the file.
322 my @info = qx (cat $fname); chomp (@info);
323
324 # Set the contents of the viewer.
325 $viewer->set ('Info' => \@info,
326 'Interpret' => "TRUE",
327 'Title' => "<R></29>Viewing filename:<!29></38>$fname<!38>");
328
329 # Activate the viewer.
330 $viewer->activate();
331 }
332
333 ##############################################################################
334 #
335 # This demonstrates the Cdk entry widget.
336 #
337 sub entryDemo
338 {
339 my $continue;
340
341 my $entry = new Cdk::Entry ('Label' => "</B/56>Enter a new pause prompt: ",
342 'Max' => 125,
343 'Width' => 30);
344 $continue = $entry->activate ();
345 $entry->erase ();
346
347 # Check if they hit escape.
348 if (! defined $continue)
349 {
350 popupLabel (["<C></U>Escape Hit",
351 "<C>Pause prompt not changed.", "",
352 "<C>$CONTINUE"]);
353 return;
354 }
355
356 # Pop up a message stating what we got.
357 $CONTINUE = $continue;
358 my @mesg = ("<C>The new pause prompt is now set to",
359 "<C>what is below this message",
360 "<C>$CONTINUE");
361 labelDemo (@mesg);
362 }
363
364 ##############################################################################
365 #
366 # This demonstrates the Cdk itemlist widget.
367 #
368 sub itemlistDemo
369 {
370 # Declare locals.
371 my $row;
372
373 # Create the list.
374 my @months = ("<C>January", "<C>February", "<C>March", "<C>April",
375 "<C>May", "<C>June", "<C></2>July<!2>", "<C>August",
376 "<C>September", "<C></32>October<!32>", "<C>November",
377 "<C></18>December<!18>");
378
379 # Get the current date info.
380 my $info = qx (date +"%d,%m,%Y"); chomp $info;
381 my ($currentDay, $currentMonth, $currentYear) = split (/,/, $info);
382 $currentMonth--;
383
384 # Create n itemlist to get the month.
385 my $monthList = new Cdk::Itemlist ('Label' => '</B/5>Pick a month ',
386 'Default' => $currentMonth,
387 'List' => \@months);
388
389 # Get the month name.
390 my $choice = $monthList->activate();
391 undef $monthList;
392
393 # Did they hit escape?
394 return if ! defined $choice;
395 $choice++;
396
397 # Create a scale to get the year.
398 my $yearScale = new Cdk::Scale ('Label' => '</B/5>Pick a year',
399 'Width' => 6,
400 'Low' => "1900",
401 'High' => "2200");
402
403 # Set the limits of the years to select from.
404 $yearScale->set ('Low' => 1900,
405 'High' => '2200',
406 'Value' => "$currentYear");
407
408 # Get the year.
409 my $year = $yearScale->activate();
410 undef $yearScale;
411
412 # Did they hit escape?
413 return if ! defined $year;
414
415 # Get the day
416 my $dayScale = new Cdk::Scale ('Label' => '</5/B>Pick a day',
417 'Width' => 5,
418 'Low' => 1,
419 'High' => 31);
420
421 # Set the limits of the days to select from.
422 $dayScale->set ('Low' => 1,
423 'High' => '31',
424 'Value' => "$currentDay");
425
426 # Get the day.
427 my $day = $dayScale->activate();
428 undef $dayScale;
429
430 # Did they hit escape?
431 return if ! defined $day;
432
433 # Create the calander.
434 my $cal = new Cdk::Calendar ('Day' => $day,
435 'Month' => $month,
436 'Year' => $year,
437 'Dattrib' => "</40>",
438 'Mattrib' => "</24>",
439 'Yattrib' => "</16>");
440 $cal->activate();
441 }
442
443 ##############################################################################
444 #
445 # This demonstrates the Cdk Template widget.
446 #
447 sub templateDemo
448 {
449 # Create the template widget.
450 my $birthday = new Cdk::Template ('Label' => 'Enter your birthday: ',
451 'Plate' => '##/##/####',
452 'Overlay' => '</5>DD<!5>-</15>MM<!15>-</20>YYYY<!20>');
453
454 # Get the birthday.
455 my $bday = $birthday->activate();
456
457 # Did the user hit escape?
458 return if ! defined $bday;
459
460 # Get the mixed value from the template.
461 my $bday2 = $birthday->mix();
462
463 # Display the results.
464 my @mesg = ("<C>Birthday without plate mixing: </U>$bday<!U>",
465 "<C>Birthday with plate mixing: </U>$bday2<!U>", "",
466 "<C>$CONTINUE");
467 labelDemo (@mesg);
468 }
469
470 ##############################################################################
471 #
472 # This demonstrates the Cdk multiple line entry widget.
473 #
474 sub mentryDemo
475 {
476 # Create the mentry widget.
477 my $mentry = new Cdk::Mentry ('Label' => "</B/16>Enter Anything:",
478 'Width' => 20,
479 'Lrows' => 10,
480 'Prows' => 5);
481
482 # Activate the mentry widget.
483 my $info = $mentry->activate ();
484
485 # Did the user hit escape?
486 return if ! defined $info;
487
488 # Display the results.
489 my @mesg = ("<C>You just typed:",
490 "<C>$info", "",
491 "<C>$CONTINUE");
492 labelDemo (@mesg);
493 }
494
495 ##############################################################################
496 #
497 # This demonstrates the Cdk matrix widget.
498 #
499 sub matrixDemo
500 {
501 my @colTitles = ("Item Name", "Base Price", "% Markup");
502 my @rowTitles = ("Item 1", "Item 2", "Item 3");
503 my @colWidths = (30, 10, 10);
504 my @colTypes = ("VIEWONLY", "VIEWONLY", "INT");
505 my @matrixValues = (["Flabberit", "10.99", ""],
506 ["Whatzit", "102.99", ""],
507 ["Albatross", "99.99", ""]);
508 my (@newlist, $x);
509
510 # Create the matrix widget.
511 my $matrix = new Cdk::Matrix ('Title' => ["<C>Flabberjabbit Sales", ""],
512 'RowTitles' => \@rowTitles,
513 'ColTitles' => \@colTitles,
514 'ColWidths' => \@colWidths,
515 'ColTypes' => \@colTypes,
516 'Vrows' => 3,
517 'Vcols' => 3);
518
519 # Set the values of the matrix.
520 $matrix->set ('Values' => \@matrixValues);
521
522 # Activate the matrix.
523 my ($rows, $cols, $info) = $matrix->activate ();
524
525 # Did the user hit escape?
526 return if ! defined $rows;
527
528 # Take the information from the matrix and redisplay it.
529 push (@newlist, "</U>Name Base Percent Price");
530 for ($x=0; $x < $rows; $x++)
531 {
532 if ($info->[$x][2] ne "")
533 {
534 my $name = $info->[$x][0];
535 my $base = $info->[$x][1];
536 my $perc = $info->[$x][2];
537 my $price = $base + ($base * $perc) / 100;
538 push (@newlist, sprintf ("%-10s %4.2f %4.2f %4.2f", $name, $base, $perc, $price));
539 }
540 }
541
542 # Create the file viewer.
543 my $viewer = new Cdk::Viewer ('Buttons' => ["OK"],
544 'Height' => 8,
545 'Width' => 60);
546
547 # Set the contents of the viewer.
548 $viewer->set ('Title' => "Adjusted Price List",
549 'Info' => \@newlist);
550
551 # Activate the viewer.
552 $viewer->activate();
553 }
554
555 ##############################################################################
556 #
557 # This demonstrates the Cdk Dialog widget.
558 #
559 sub dialogDemo
560 {
561 my @mesg = ("<C></U>Cheesy Unix Command Interface<!U>",
562 "<C>Select a command from the buttons.");
563
564 # Create the buutons for the dialog box.
565 my @buttons = ("date", "pwd", "whoami", "ls -l");
566
567 # Create the dialog widget.
568 my $dialog = new Cdk::Dialog ('Message' => \@mesg, 'Buttons' => \@buttons);
569
570 # Activate the dialog box.
571 my $pick = $dialog->activate ();
572 $dialog->erase ();
573
574 # Did the user hit escape?
575 return if ! defined $pick;
576
577 # Check what we want to run.
578 if ($buttons[$pick] =~ "ls -l")
579 {
580 # Get the directory listing.
581 my @info = qx (ls -l ${HOME}); chomp (@info);
582
583 # Create the file viewer.
584 my $viewer = new Cdk::Viewer ('Buttons' => ["OK"],
585 'Height' => 15,
586 'Width' => 60);
587
588 # Set the contents of the viewer.
589 $viewer->set ('Title' => "<C>Listing $HOME", 'Info' => \@info);
590 $viewer->activate();
591 }
592 else
593 {
594 # We want to run anything but ls -l
595 my $result = qx ($buttons[$pick]); chomp $result;
596
597 # Display the result.
598 my @mesg = ("<C>The command </R>$buttons[$pick]<!R> produced the following:",
599 "<C>$result",
600 "<C>$CONTINUE");
601 labelDemo ( @mesg );
602 }
603 }
604
605 ##############################################################################
606 #
607 # This demonstrates the Cdk Scrolling widget.
608 #
609 sub scrollDemo
610 {
611 my ($x, @items);
612
613 # Create an itemlist widget to determine if the user wants numbers or not.
614 my $boolean = new Cdk::Itemlist ('Label' => 'Do You Want Numbers?:',
615 'Default' => 0,
616 'List' => ["No", "Yes"]);
617
618 # Create a scale widget for the number of elements.
619 my $size = new Cdk::Scale ('Label' => 'How Many Items?',
620 'Width' => 5,
621 'Low' => 10,
622 'High' => 100);
623
624 # Create an entry field for the title of the scrolling list.
625 my $entry = new Cdk::Entry ('Label' => 'Title: ',
626 'Max' => 100,
627 'Min' => 2,
628 'Width' => 20);
629
630 # Get whether they want numbers or not.
631 my $nums = $boolean->activate ();
632 return if ! defined $nums;
633
634 # Get the number of elements.
635 my $count = $size->activate ();
636
637 # Get the title of the scrolling list.
638 my $title = $entry->activate ();
639
640 # Create the item list
641 for ($x=1; $x <= $count ; $x++)
642 {
643 push (@items, "This is item #</U>$x");
644 }
645
646 # Create the scrolling list.
647 my $scrollDemo = new Cdk::Scroll ('Title' => "$title",
648 'Highlight' => "</B/5>",
649 'List' => \@items,
650 'Numbers' => $nums,
651 'Height' => 14,
652 'Width' => 20);
653
654 # Activate the scrolling list.
655 my $selection = $scrollDemo->activate ();
656 return if ! defined $selection;
657
658 # Spit out the results.
659 my @mesg = ("<C>You selected",
660 "<C>$items[$selection]",
661 "<C>$CONTINUE");
662 labelDemo (@mesg);
663 }
664
665 ##############################################################################
666 #
667 # This demonstrates the Cdk Selection widget.
668 #
669 sub selectionDemo
670 {
671 my ($x, @result);
672
673 # Create the list of commands to choose from.
674 my @commands = ("date", "whoami", "pwd", "hostname", "uname -a");
675
676 # Create the selection scrolling list.
677 my $select = new Cdk::Selection ('Title' => "<C></B>Select Commands<!B>",
678 'List' => \@commands,
679 'Choices' => ["</24>Yep<!24>", "</16>Nope<!16>"],
680 'Height' => 8,
681 'Width' => 20);
682
683 # Activate the selection widget.
684 my @info = $select->activate ();
685
686 # Did the user hit escape?
687 return if ! defined @info;
688
689 # Create the result message.
690 @result = ("<L>Here are the results from the commands you selected:", "");
691 for ($x=0; $x <= $#info; $x++)
692 {
693 if ($info[$x] eq 0)
694 {
695 my $tmp = qx ($commands[$x]); chomp $tmp;
696 my $fmt = sprintf ("</40>%10s<!40></16>...<!16></48>%-30s<!48>", $commands[$x], $tmp);
697 push (@result, $fmt);
698 }
699 }
700 push (@result, "");
701 push (@result, "<C>$CONTINUE");
702
703 # Spit the results out.
704 labelDemo (@result);
705 }
706
707 ##############################################################################
708 #
709 # This demonstrates the Cdk Radio widget.
710 #
711 sub radioDemo
712 {
713 # Create the radio list
714 my @colors = ("</B/8>White",
715 "</B/16>Red",
716 "</B/24>Green",
717 "</B/32>Yellow",
718 "</B/40>Blue",
719 "</B/48>Purple",
720 "</B/56>Cyan");
721
722 # Create the radio widget.
723 my $radio = new Cdk::Radio ('Title' => "Pick A Color",
724 'List' => \@colors,
725 'Highlight' => "A_REVERSE",
726 'Height' => 7,
727 'Width' => 10);
728
729 # Activate the radio list.
730 my $color = $radio->activate ();
731
732 # Did the user hit escape?
733 return if ! defined $color;
734
735 # Display the results.
736 my @mesg = ("<C>You Selected",
737 "<C> $colors[$color]",
738 "<C>$CONTINUE");
739 labelDemo (@mesg);
740 }
741
742 ##############################################################################
743 #
744 # This demonstrates the Cdk Histogram widget.
745 #
746 sub histogramDemo
747 {
748 my ($x);
749
750 # Create the histogram label.
751 my $histLabel = "<C>Time In Seconds This Demo Has Run";
752
753 # Create the histogram widget.
754 my $hist = new Cdk::Histogram ('Title' => $histLabel,
755 'Orient' => "HORIZONTAL",
756 'Height' => 5,
757 'Width' => 0);
758
759 # Take the current time - the start time of this script.
760 my $diff = time - $;
761
762 # Redraw the histogram every second.
763 for ($x=0; $x < 5; $x++)
764 {
765 # Set the values of the histogram.
766 $hist->set ('Low' => 1,
767 'FillerChar' => "</R/24> ",
768 'High' => $diff + 25,
769 'Value' => $diff+$x,
770 'Statstype' => "REAL",
771 'Statspos' => "CENTER");
772
773 # Redraw the histogram.
774 $hist->draw();
775
776 # Sleep for a sec.
777 sleep (1);
778 }
779 }
780
781 ##############################################################################
782 #
783 # This demonstrates the Cdk Marquee widget.
784 #
785 sub marqueeDemo
786 {
787 # Create an entry widget to get the user's message.
788 my $entry = new Cdk::Entry ('Label' => 'Enter a Message: ',
789 'Max' => 100,
790 'Min' => 2,
791 'Width' => 20);
792
793 # Activate the widget to get the message.
794 my $message = $entry->activate ();
795 $entry->erase ();
796 return if ! defined $message;
797
798 # Create the widget to get the number times to repeat the message.
799 my $rvalue = new Cdk::Scale ('Label' => 'Repeat Value:',
800 'Width' => 5,
801 'Low' => 1,
802 'High' => 20);
803
804 # Get the repeat value from the user.
805 my $repeat = $rvalue->activate();
806 $rvalue->erase ();
807
808 # Create the widget to get the delay.
809 my $dvalue = new Cdk::Scale ('Label' => 'Delay Value:',
810 'Width' => 5,
811 'Low' => 1,
812 'High' => 20);
813
814 # Get the delay value.
815 my $delay = $dvalue->activate() * 10;
816 $dvalue->erase ();
817
818 # Create the widget to get the width of the marquee widget.
819 my $mWidth = new Cdk::Scale ('Label' => 'Marquee Width:',
820 'Width' => 5,
821 'Low' => length($message),
822 'High' => 50);
823
824 # Get the width of the marquee widget.
825 my $width = $mWidth->activate();
826 $mWidth->erase ();
827
828 # Create the marquee widget.
829 my $marquee = new Cdk::Marquee ('Width' => $width);
830
831 # Activate the marquee widget.
832 $marquee->activate ('Message' => $message,
833 'Delay' => $delay,
834 'Repeat' => $repeat);
835 }
836
837 ##############################################################################
838 #
839 # This demonstrates the Cdk Graph widget.
840 #
841 sub graphDemo
842 {
843 # Create the graph.
844 my $graph = new Cdk::Graph ('Title' => "<C>Camel Count",
845 'Xtitle' => "<C>Quantity",
846 'Ytitle' => "<C>Months",
847 'Height' => -4,
848 'Width' => -20);
849
850 # Set the graph values.
851 my @numberList = qw (10 12 14 16 17 22 31);
852 my $graphChars = "ooooooo";
853 $graph->set ('Values' => \@numberList,
854 'DisplayType' => "PLOT",
855 'GraphChars' => $graphChars);
856
857 # Draw the graph.
858 $graph->draw();
859
860 # Prompt the user.
861 my @mesg = ("When done looking at your Camels", "<C>$CONTINUE");
862 my $label = new Cdk::Label ('Message' => \@mesg, 'Xpos' => "BOTTOM");
863 $label->draw();
864 $label->wait();
865 }
866
867 ##############################################################################
868 #
869 # This demonstrates the Cdk Scale widget.
870 #
871 sub scaleDemo
872 {
873 # Create the scale widget.
874 my $scale = new Cdk::Scale ('Label' => 'Pick a number:',
875 'Width' => 5,
876 'Low' => 10,
877 'High' => 100);
878
879 # Activate the widget.
880 my $num = $scale->activate();
881
882 # Display the results.
883 my @mesg = ("<C>You chose $num.", "<C>$CONTINUE");
884 labelDemo (@mesg);
885 }
886
887 ##############################################################################
888 #
889 # This demonstrates the Cdk Slider widget.
890 #
891 sub sliderDemo
892 {
893 # Create the scale widget.
894 my $slider = new Cdk::Slider ('Label' => '</B/16>Pick a number:',
895 'Filler' => "</R/24> ",
896 'Width' => 50,
897 'Low' => 10,
898 'High' => 100);
899
900 # Activate the widget.
901 my $num = $slider->activate();
902 undef $slider;
903
904 # Display the results.
905 my @mesg = ("<C>You chose $num.", "<C>$CONTINUE");
906 labelDemo (@mesg);
907 }
908
909 ##############################################################################
910 #
911 # This demonstrates the Cdk Alpha List widget.
912 #
913 sub alphalistDemo
914 {
915 my @acctList = ();
916
917 # Reset the password entry pointer.
918 setpwent();
919
920 # Get a list of all the accounts on this box.
921 while ($tmp = getpwent)
922 {
923 push (@acctList, $tmp);
924 }
925
926 # Create the scale widget.
927 my $alpha = new Cdk::Alphalist ('Label' => '</B/16>Select an account:',
928 'List' => \@acctList,
929 'Width' => 50,
930 'Height' => 10);
931
932 # Activate the widget.
933 my $acct = $alpha->activate();
934 $alpha->erase();
935
936 # Display the results.
937 my @mesg = ("<C>You chose $acct.", "<C>$CONTINUE");
938 labelDemo (@mesg);
939 }
940
941 ##############################################################################
942 #
943 # This is the help menu option under help.
944 #
945 sub generalHelp
946 {
947 my $choice = 0;
948 my $helpdir = $ENV{'CDKHELPDIR'} || "./help";
949
950 # Define the names of the help files.
951 my @helpFiles = ("general.help",
952 "concepts.help",
953 "binding.help",
954 "preprocess.help",
955 "postprocess.help",
956 "display.help",
957 "special.help",
958 "charfile.help",
959 "colors.help",
960 "debug.help",
961 "future.help",
962 "bugs.help");
963
964 # Define the concepts.
965 my @conceptList = ("</24>General Information About Cdk<!24>",
966 "</24>Cdk Concepts <!24>",
967 "</24>Creating a key binding. <!24>",
968 "</24>Creating a pre-process. <!24>",
969 "</24>Creating a post-process. <!24>",
970 "</24>Cdk Display Types <!24>",
971 "</24>Special Display Attributes <!24>",
972 "</24>Special Character Formats <!24>",
973 "</24>Predefined Colors <!24>",
974 "</24>Debugging Cdk Code <!24>",
975 "</24>The Future of Cdk <!24>",
976 "</24>Known Bugs <!24>",
977 "</24>Exit Help <!24>");
978
979 # Get the screen dimensions.
980 my ($rows, $cols) = Cdk::getCdkScreenDim();
981
982 # Create the scrolling list ...
983 my $helplist = new Cdk::Scroll ('Title' => "<C></U/B/29>Pick A Topic",
984 'Highlight' => "</R>",
985 'List' => \@conceptList,
986 'Numbers' => "TRUE",
987 'Height' => $#conceptList+4,
988 'Width' => 40);
989
990 # Keep doing this until we are told to leave.
991 for (;;)
992 {
993 # Redraw the screen.
994 Cdk::refreshCdkScreen();
995
996 # Get the choice from the user.
997 my $choice = $helplist->activate();
998
999 # Exit if we have to .
1000 return if ! defined $choice;
1001 return if $choice == $#conceptList;
1002
1003 # Create the help filename
1004 $helpfile = "${helpdir}/$helpFiles[$choice]";
1005 $topic = "$conceptList[$choice]";
1006
1007 # Check if the file exists.
1008 if (! -e $helpfile)
1009 {
1010 my @error = (
1011 "<C></16>Can not seem to find the help file on the topic </U>$topic<!U><!16>",
1012 "<C></16>Try setting the CDKHELPDIR environment variable<!16>",
1013 "<C></16>or check if the help file '$helpfile' exists<!16>", "",
1014 "<C>$CONTINUE");
1015 labelDemo (@error);
1016 }
1017 else
1018 {
1019 # Display the file.
1020 my @info = ();
1021 undef $helpviewer;
1022 my $helpviewer = new Cdk::Viewer ('Buttons' => ["OK"],
1023 'Height' => $rows-3,
1024 'Width' => $cols-2);
1025
1026 chop (@info = `cat $helpfile`);
1027 $helpviewer->set ('Title' => "<C></18>Help: </U>$topic<!18U>",
1028 'Info' => \@info);
1029 $helpviewer->activate();
1030 }
1031 }
1032 }
1033
1034 sub widgetHelp
1035 {
1036 my ($helpfile, $topic, $helpviewer);
1037 my $helpdir = $ENV{'CDKHELPDIR'} || "./help";
1038
1039 # Define the widget help files.
1040 my @helpFiles = ("alphalist.help",
1041 "calendar.help",
1042 "dialog.help",
1043 "entry.help",
1044 "fselect.help",
1045 "graph.help",
1046 "histogram.help",
1047 "itemlist.help",
1048 "label.help",
1049 "marquee.help",
1050 "matrix.help",
1051 "menu.help",
1052 "mentry.help",
1053 "radio.help",
1054 "scale.help",
1055 "scroll.help",
1056 "swindow.help",
1057 "selection.help",
1058 "slider.help",
1059 "template.help",
1060 "viewer.help");
1061
1062 # Define the widget help entries.
1063 my @widgetList = ("</B/40>Alphalist Widget <!40>",
1064 "</B/40>Calendar Widget <!40>",
1065 "</B/40>Dialog Widget <!40>",
1066 "</B/40>Entry Field Widget <!40>",
1067 "</B/40>File Selector Widget <!40>",
1068 "</B/40>Graph Widget <!40>",
1069 "</B/40>Histogram Widget <!40>",
1070 "</B/40>Item List Widget <!40>",
1071 "</B/40>Label Widget <!40>",
1072 "</B/40>Marquee Widget <!40>",
1073 "</B/40>Matrix Widget <!40>",
1074 "</B/40>Menu Widget <!40>",
1075 "</B/40>Multiple Line Entry Widget <!40>",
1076 "</B/40>Radio List Widget <!40>",
1077 "</B/40>Scale Widget <!40>",
1078 "</B/40>Scrolling List Widget <!40>",
1079 "</B/40>Scrolling Window Widget <!40>",
1080 "</B/40>Selection List Widget <!40>",
1081 "</B/40>Slider Widget <!40>",
1082 "</B/40>Template Widget <!40>",
1083 "</B/40>Viewer Widget <!40>",
1084 "</B/40>Exit Help <!40>");
1085
1086 # Get the screen dimensions.
1087 my ($rows, $cols) = Cdk::getCdkScreenDim();
1088
1089 # Create the scrolling list ...
1090 my $helplist = new Cdk::Scroll ('Title' => "<C></U/B/29>Pick A Topic",
1091 'Highlight' => "</R>",
1092 'List' => \@widgetList,
1093 'Numbers' => "TRUE",
1094 'Height' => $#widgetList+4,
1095 'Width' => 40);
1096
1097 # Keep doing this until we are told to leave.
1098 for (;;)
1099 {
1100 # Redraw the screen.
1101 Cdk::refreshCdkScreen();
1102
1103 my $choice = $helplist->activate();
1104
1105 # Exit if we have to .
1106 return if ! defined $choice;
1107 return if ($choice == $#widgetList);
1108
1109 # Create the help filename
1110 $helpfile = "${helpdir}/$helpFiles[$choice]";
1111 $topic = "$widgetList[$choice]";
1112
1113 # Does the help file exist?
1114 if (! -e $helpfile)
1115 {
1116 my @error = (
1117 "<C></16>Can not seem to find the help file on the topic </U>$topic<!U><!16>",
1118 "<C></16>Try setting the CDKHELPDIR environment variable<!16>",
1119 "<C></16>or check if the help file '$helpfile' exists<!16>", "",
1120 "<C>$CONTINUE");
1121 labelDemo (@error);
1122 }
1123 else
1124 {
1125 # Display the file.
1126 my @info = ();
1127 my $helpviewer = new Cdk::Viewer ('Buttons' => ["OK"],
1128 'Height' => $rows-3,
1129 'Width' => $cols-2);
1130 chop (@info = `cat $helpfile`);
1131 $helpviewer->set ('Title' => "<C></18>Help: </U>$topic<!18U>",
1132 'Info' => \@info);
1133 $helpviewer->activate();
1134 }
1135 }
1136 }
1137
1138 #
1139 # This is the callback function for the menu.
1140 #
1141 sub menuCallback
1142 {
1143 my $menu = shift;
1144
1145 # Call the help function.
1146 main::help();
1147
1148 # Refresh the screen.
1149 Cdk::refreshCdkScreen();
1150 return 1;
1151 }
+0
-252
fulldemo/help/alphalist.help less more
0 </R>Purpose<!R>
1 The Cdk alphalist widget allows the user to select an item in a list. This
2 widget allows the user to type in letters to refine and narrow the search. When
3 a character is typed into the entry field, the scrolling list looks for the
4 first word which matches the string in the entry field. You can continue to
5 narrow the search by typing in more letters.
6
7 </R>Construction Options<!R>
8 The alphalist widget is defined using the following syntax. The variable
9 </B>$alphalistObject<!B> contains the reference to the entry object.
10 <C></B>$alphalistObject = new Cdk::Alphalist ( options );
11
12 The options are defined in the following table.
13
14 </U>Option Default Value Type Purpose<!U>
15 Label Required Scalar This is the label of the widget.
16 List Required Array Ref This is the list of words to choose from.
17 Height Required Scalar The height of the widget.
18 Width Required Scalar The width of the widget.
19 Highlight Reverse Scalar The highlight attribute of the scrolling list.
20 Filler . Scalar The default field character.
21 Xpos Center Scalar This is the position of the window on the X axis.
22 Ypos Center Scalar This is the position of the window on the Y axis.
23 Box True Scalar This Boolean states whether the dialog box will have a box drawn around it.
24 Shadow False Scalar This Boolean states whether the dialog box will have a shadow on the box.
25
26 </R>Available Methods<!R>
27 </B>activate<!B>
28 Activation of an object means to make the object available for use. The
29 following example demonstrates how to activate a entry widget.
30 <C></B>$returnValue = $alphalistObject->activate ();
31
32 The variable </B>$returnValue<!B> contains a scalar value of what was typed into
33 the entry field.
34
35 </B>inject<!B>
36 This function injects a single character into the widget. The following
37 examples demonstrates how to call the inject method.
38 <C></B>$alphalistObject->inject ( options );
39
40 The options are defined in the following table.
41 </U>Option Default Value Type Purpose<!U>
42 Shadow Required Scalar The character to inject into the widget.
43
44 If you are injecting a special character into the widget, then you can
45 use a pre-defined value to represent the key.
46
47 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
48 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
49 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
50 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
51 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
52 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
53 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
54 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
55 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
56 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
57 <C><#VL>Home <#VL>KEY_HOME <#VL>
58 <C><#VL>End <#VL>KEY_END <#VL>
59 <C><#VL>Escape <#VL>KEY_ESC <#VL>
60 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
61
62 </B>set<!B>
63 Sets or resets certain attributes or features of the widget. The following
64 demonstrates how to call the set method from the entry field.
65 <C></B>$alphalistObject->set ( options );
66
67 The options are defined in the following table.
68
69 </U>Option Default Value Type Purpose<!U>
70 List Required Array Ref This is the list of words to choose from.
71 Highlight Reverse Scalar The highlight attribute of the scrolling list.
72 Filler . Scalar The default field character.
73 Box True Scalar Changes the current value of the box flag.
74
75 </B>bind<!B>
76 The bind method binds keys to events. The binding is specific to the individual
77 objects. The following example demonstrates how to call the bind method.
78 <C></B>$alphalistObject->bind ( options );
79
80 The options are defined in the following table.
81
82 </U>Option Default Value Type Purpose<!U>
83 Key Required Scalar This is the character to bind the event to.
84 Function Required Scalar This is the name of the callback function.
85
86 </B>preProcess<!B>
87 The </B>preProcess<!B> function sets a process to be run before the key entered
88 is processed. If this function returns a value of 0, then the key injected
89 into the widget will not be processed; otherwise the character will be
90 processed as normal. The following example demonstrates how to call the
91 preProcess method.
92 <C></B>$alphalistObject->preProcess ( options );
93
94 The options are defined in the following table.
95
96 </U>Option Default Value Type Purpose<!U>
97 Function Required Scalar This is the name of the
98 callback function.
99
100 To create a pre-process callback the following code segment demonstrates
101 how to do it properly.
102
103 <C></B>$alphalistObject->preProcess ('Function' => sub { callback (@_); });
104
105 Notice that the array </B>@_<!B> is passed into the function called
106 </B>callback<!B>. This is done because when the callback process is
107 called the key which was pressed is passed into the perl subroutine.
108 Since we nest the call-back function inside an anonymous subroutine,
109 we need to pass the array </B>@_<!B> to the call-back function. If
110 the key given to the call-back function is a non alphanumeric key
111 then a predefined value will be given to the function. The following
112 table describes the values passed into the function.
113
114 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
115 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
116 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
117 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
118 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
119 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
120 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
121 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
122 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
123 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
124 <C><#VL>Home <#VL>KEY_HOME <#VL>
125 <C><#VL>End <#VL>KEY_END <#VL>
126 <C><#VL>Escape <#VL>KEY_ESC <#VL>
127 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
128
129 If the pre-process function returns a value of 0 the key hit will
130 not be injected into the widget. This allows the programmer to
131 selectively pick which characters will or will not get injected
132 into the widget.
133
134 The </B>postProcess<!B> function sets a process to be run before the key entered
135 is processed. If this function returns a value of 0, then the key injected
136 into the widget will not be processed; otherwise the character will be
137 processed as normal. The following example demonstrates how to call the
138 postProcess method.
139 <C></B>$alphalistObject->postProcess ( options );
140
141 The options are defined in the following table.
142
143 </U>Option Default Value Type Purpose<!U>
144 Function Required Scalar This is the name of the
145 callback function.
146
147 To create a post-process callback the following code segment demonstrates
148 how to do it properly.
149
150 <C></B>$alphalistObject->postProcess ('Function' => sub { callback (@_); });
151
152 Notice that the array </B>@_<!B> is passed into the function called
153 </B>callback<!B>. This is done because when the callback process is
154 called the key which was pressed is passed into the perl subroutine.
155 Since we nest the call-back function inside an anonymous subroutine,
156 we need to pass the array </B>@_<!B> to the call-back function. If
157 the key given to the call-back function is a non alphanumeric key
158 then a predefined value will be given to the function. The following
159 table describes the values passed into the function.
160
161 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
162 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
163 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
164 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
165 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
166 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
167 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
168 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
169 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
170 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
171 <C><#VL>Home <#VL>KEY_HOME <#VL>
172 <C><#VL>End <#VL>KEY_END <#VL>
173 <C><#VL>Escape <#VL>KEY_ESC <#VL>
174 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
175 </B>draw<!B>
176 This method draws the object on the screen. The following example demonstrates
177 how to call the draw method.
178 <C></B>$alphalistObject->draw ( options );
179
180 The options are defined in the following table.
181
182 </U>Option Default Value Type Purpose<!U>
183 Box True Scalar Draws the window with a box around it.
184
185 </B>erase<!B>
186 This method removes the object from the screen. This does </B/U>NOT<!B!U>
187 destroy the object. The following example demonstrates how to call the erase
188 method.
189 <C></B>$alphalistObject->erase ();
190
191 </B>raise<!B>
192 The raise method raises the widget to the top of the screen. This means if there
193 were any widgets obscuring part of the view, raising the object would bring the
194 complete object into view. The following example demonstrates how to call the
195 raise method.
196 <C></B>$alphalistObject->raise();
197
198 </B>lower<!B>
199 The lower method lowers the object so it doesn't obscure the view of any other
200 objects. The following example demonstrates how to call the lower method.
201 <C></B>$alphalistObject->lower();
202
203 </B>register<!B>
204 The register method registers the object to the default screen. This does </R>NOT<!R>
205 have to be called since the objects are registered automatically. This method
206 should be called if the </B>unregister<!B> method was called. The following
207 example demonstrates how to call the register method.
208 <C></B>$alphalistObject->register();
209
210 </B>unregister<!B>
211 The unregister method should be called when a widget, which is part of the
212 default screen, needs to be taken away temporarily. This does not delete or free
213 the object, it just unmaps it from any future screen refreshes. The object can
214 be registered by calling the </B>register<!B> method. The following example
215 demonstrates how to call the unregister method.
216 <C></B>$alphalistObject->unregister();
217
218 </B>getwin<!B>
219 This method returns a pointer to the window of the object. Not much use for this
220 yet. It will be useful in the future when the drawing methods are added. The
221 following example demonstrates how to call the getwin method.
222 <C></B>$alphalistObject->getwin();
223
224 </R>Default Key Bindings<!R>
225 Since this widget is 'driven' by the entry field, the default key bindings
226 of the entry field apply to this widget. There are however extra bindings
227 which have been applied. They are as follows:
228
229 </U>Key Action<!U>
230 TAB Tries to complete the word in the entry field.
231 Key Up Scrolls the list one item backward.
232 Page Up Scrolls the list one page backward.
233 CTRL-B Scrolls the list one page backward.
234 Key Down Scrolls the list one line forward.
235 Page Down Scrolls the list one page forward.
236 CTRL-F Scrolls the list one page forward.
237 Return Returns what is currently displayed in the entry field.
238 Escape Exits the widget and returns undef.
239
240 </R>Tips & Tricks<!R>
241 None.
242
243 </R>Physical Restrictions<!R>
244 Same as the scrolling list.
245
246 </R>Example Use Of The Widget<!R>
247 <F=../examples/alphalist>
248
249 <C><#HL(70)>
250 <C>Document Created: June, 1996
251 <C>Document Revised: July, 1996
+0
-17
fulldemo/help/binding.help less more
0 All interactive widgets have the ability to bind specific keys to specific
1 functions. This allows programmers to customize the widgets to perform
2 specific actions when a key is hit. The following example demonstrates how
3 to call the bind function.
4 <C></B>$widget->bind ( options );
5
6 The options are defined in the following table.
7
8 </U>Option Default Value Type Purpose<!U>
9 Function Required Scalar This is the name of the callback function.
10
11 </R>Example Use Of The Bind Method<!R>
12 <F=../examples/bind>
13
14 <C><#HL(70)>
15 <C>Document Created: June, 1995
16 <C>Document Revised: November, 1995
+0
-9
fulldemo/help/bugs.help less more
0 <C></U>Known Bugs<!U>
1 Currently there are no bugs that I know of. I'm sure once people start
2 playing with this extension, bugs will be found.
3
4 Happy hunting. :)
5
6 <C>(of course the documentation may be a wee bit out of date. :) )
7 <C><#HL(70)>
8 <C>Document Created: November, 1995
+0
-250
fulldemo/help/calendar.help less more
0 </R>Purpose<!R>
1 The Cdk calendar widget is a simple little widget which allows a user to
2 play with a calendar.
3
4 </R>Construction Options<!R>
5 The calendar widget is defined using the following syntax. The variable
6 </B>$calendarObject<!B> contains the reference to the entry object.
7 <C></B>$calendarObject = new Cdk::Calendar ( options );
8
9 The options are defined in the following table.
10
11 </U>Option Default Value Type Purpose<!U>
12 Day The current day Scalar The day of the calendar.
13 of the month.
14 Month The current month Scalar The month of the calendar.
15 Year The current year Scalar The year of the calendar.
16 Dattrib Normal Scalar The attribute of the days.
17 Mattrib Normal Scalar The attribute of the month name.
18 Yattrib Normal Scalar The attribute of the year.
19 Highlight Reverse Scalar The highlight attribute of the cursor.
20 Filler . Scalar The default field character.
21 Xpos Center Scalar This is the position of the window on the X axis.
22 Ypos Center Scalar This is the position of the window on the Y axis.
23 Box True Scalar This Boolean states whether the dialog box will have a box drawn around it.
24 Shadow False Scalar This Boolean states whether the dialog box will have a shadow on the box.
25
26 </R>Available Methods<!R>
27 </B>activate<!B>
28 Activation of an object means to make the object available for use. The
29 following example demonstrates how to activate a entry widget.
30 <C></B>($day, $month, $year) = $calendarObject->activate ();
31
32 The variables </B>$day<!B>, </B>$month<!B>, </B>$year<!B> is the date
33 of the calendar when it exited.
34
35 </B>inject<!B>
36 This function injects a single character into the widget. The following
37 examples demonstrates how to call the inject method.
38 <C></B>$calendarObject->inject ( options );
39
40 The options are defined in the following table.
41 </U>Option Default Value Type Purpose<!U>
42 Shadow Required Scalar The character to inject into the widget.
43
44 If you are injecting a special character into the widget, then you can
45 use a pre-defined value to represent the key.
46
47 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
48 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
49 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
50 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
51 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
52 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
53 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
54 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
55 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
56 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
57 <C><#VL>Home <#VL>KEY_HOME <#VL>
58 <C><#VL>End <#VL>KEY_END <#VL>
59 <C><#VL>Escape <#VL>KEY_ESC <#VL>
60 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
61
62 </B>setDate<!B>
63 Sets the current date of the calendar field.
64 <C></B>$calendarObject->setDate ( options );
65
66 The options are defined in the following table.
67
68 </U>Option Default Value Type Purpose<!U>
69 Day Required Scalar The day of the calendar.
70 Month Required Scalar The month of the calendar.
71 Year Required Scalar The year of the calendar.
72
73 </B>bind<!B>
74 The bind method binds keys to events. The binding is specific to the individual
75 objects. The following example demonstrates how to call the bind method.
76 <C></B>$calendarObject->bind ( options );
77
78 The options are defined in the following table.
79
80 </U>Option Default Value Type Purpose<!U>
81 Key Required Scalar This is the character to bind the event to.
82 Function Required Scalar This is the name of the callback function.
83
84 </B>preProcess<!B>
85 The </B>preProcess<!B> function sets a process to be run before the key entered
86 is processed. If this function returns a value of 0, then the key injected
87 into the widget will not be processed; otherwise the character will be
88 processed as normal. The following example demonstrates how to call the
89 preProcess method.
90 <C></B>$calendarObject->preProcess ( options );
91
92 The options are defined in the following table.
93
94 </U>Option Default Value Type Purpose<!U>
95 Function Required Scalar This is the name of the
96 callback function.
97
98 To create a pre-process callback the following code segment demonstrates
99 how to do it properly.
100
101 <C></B>$alphalistObject->preProcess ('Function' => sub { callback (@_); });
102
103 Notice that the array </B>@_<!B> is passed into the function called
104 </B>callback<!B>. This is done because when the callback process is
105 called the key which was pressed is passed into the perl subroutine.
106 Since we nest the call-back function inside an anonymous subroutine,
107 we need to pass the array </B>@_<!B> to the call-back function. If
108 the key given to the call-back function is a non alphanumeric key
109 then a predefined value will be given to the function. The following
110 table describes the values passed into the function.
111
112 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
113 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
114 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
115 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
116 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
117 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
118 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
119 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
120 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
121 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
122 <C><#VL>Home <#VL>KEY_HOME <#VL>
123 <C><#VL>End <#VL>KEY_END <#VL>
124 <C><#VL>Escape <#VL>KEY_ESC <#VL>
125 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
126
127 If the pre-process function returns a value of 0 the key hit will
128 not be injected into the widget. This allows the programmer to
129 selectively pick which characters will or will not get injected
130 into the widget.
131
132 The </B>postProcess<!B> function sets a process to be run before the key entered
133 is processed. If this function returns a value of 0, then the key injected
134 into the widget will not be processed; otherwise the character will be
135 processed as normal. The following example demonstrates how to call the
136 postProcess method.
137 <C></B>$calendarObject->postProcess ( options );
138
139 The options are defined in the following table.
140
141 </U>Option Default Value Type Purpose<!U>
142 Function Required Scalar This is the name of the
143 callback function.
144
145 To create a post-process callback the following code segment demonstrates
146 how to do it properly.
147
148 <C></B>$alphalistObject->postProcess ('Function' => sub { callback (@_); });
149
150 Notice that the array </B>@_<!B> is passed into the function called
151 </B>callback<!B>. This is done because when the callback process is
152 called the key which was pressed is passed into the perl subroutine.
153 Since we nest the call-back function inside an anonymous subroutine,
154 we need to pass the array </B>@_<!B> to the call-back function. If
155 the key given to the call-back function is a non alphanumeric key
156 then a predefined value will be given to the function. The following
157 table describes the values passed into the function.
158
159 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
160 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
161 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
162 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
163 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
164 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
165 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
166 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
167 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
168 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
169 <C><#VL>Home <#VL>KEY_HOME <#VL>
170 <C><#VL>End <#VL>KEY_END <#VL>
171 <C><#VL>Escape <#VL>KEY_ESC <#VL>
172 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
173 </B>draw<!B>
174 This method draws the object on the screen. The following example demonstrates
175 how to call the draw method.
176 <C></B>$calendarObject->draw ( options );
177
178 The options are defined in the following table.
179
180 </U>Option Default Value Type Purpose<!U>
181 Box True Scalar Draws the window with a box around it.
182
183 </B>erase<!B>
184 This method removes the object from the screen. This does </B/U>NOT<!B!U>
185 destroy the object. The following example demonstrates how to call the erase
186 method.
187 <C></B>$calendarObject->erase ();
188
189 </B>raise<!B>
190 The raise method raises the widget to the top of the screen. This means if there
191 were any widgets obscuring part of the view, raising the object would bring the
192 complete object into view. The following example demonstrates how to call the
193 raise method.
194 <C></B>$calendarObject->raise();
195
196 </B>lower<!B>
197 The lower method lowers the object so it doesn't obscure the view of any other
198 objects. The following example demonstrates how to call the lower method.
199 <C></B>$calendarObject->lower();
200
201 </B>register<!B>
202 The register method registers the object to the default screen. This does </R>NOT<!R>
203 have to be called since the objects are registered automatically. This method
204 should be called if the </B>unregister<!B> method was called. The following
205 example demonstrates how to call the register method.
206 <C></B>$calendarObject->register();
207
208 </B>unregister<!B>
209 The unregister method should be called when a widget, which is part of the
210 default screen, needs to be taken away temporarily. This does not delete or free
211 the object, it just unmaps it from any future screen refreshes. The object can
212 be registered by calling the </B>register<!B> method. The following example
213 demonstrates how to call the unregister method.
214 <C></B>$calendarObject->unregister();
215
216 </B>getwin<!B>
217 This method returns a pointer to the window of the object. Not much use for this
218 yet. It will be useful in the future when the drawing methods are added. The
219 following example demonstrates how to call the getwin method.
220 <C></B>$calendarObject->getwin();
221
222 </R>Default Key Bindings<!R>
223 Since this widget is 'driven' by the entry field, the default key bindings
224 of the entry field apply to this widget. There are however extra bindings
225 which have been applied. They are as follows:
226
227 </U>Key Action<!U>
228 TAB Tries to complete the word in the entry field.
229 Key Up Scrolls the list one item backward.
230 Page Up Scrolls the list one page backward.
231 CTRL-B Scrolls the list one page backward.
232 Key Down Scrolls the list one line forward.
233 Page Down Scrolls the list one page forward.
234 CTRL-F Scrolls the list one page forward.
235 Return Returns what is currently displayed in the entry field.
236 Escape Exits the widget and returns undef.
237
238 </R>Tips & Tricks<!R>
239 None.
240
241 </R>Physical Restrictions<!R>
242 Same as the scrolling list.
243
244 </R>Example Use Of The Widget<!R>
245 <F=../examples/calendar>
246
247 <C><#HL(70)>
248 <C>Document Created: June, 1996
249 <C>Document Revised: July, 1996
+0
-35
fulldemo/help/charfile.help less more
0
1 Cdk has the ability to add in special drawing characters into basic text
2 using format commands. The characters and their respective format commands
3 are listed in the following table.
4
5 <C></U>Table of Cdk's Drawing Characters
6 <C><#UL><#HL(17)><#TT><#HL(4)><#TT><#HL(6)><#UR>
7 <C><#VL></U>Description <#VL>Code <#VL>Display<!U><#VL>
8 <C><#VL>Horizontal Line <#VL>\<\#HL><#VL> <#HL> <#VL>
9 <C><#VL>Vertical Line <#VL>\<\#VL><#VL> <#VL> <#VL>
10 <C><#VL>Upper Left Corner <#VL>\<\#UL><#VL> <#UL> <#VL>
11 <C><#VL>Upper Right Corner<#VL>\<\#UR><#VL> <#UR> <#VL>
12 <C><#VL>Lower Left Corner <#VL>\<\#LL><#VL> <#LL> <#VL>
13 <C><#VL>Lower Right Corner<#VL>\<\#LR><#VL> <#LR> <#VL>
14 <C><#VL>Left Tee <#VL>\<\#LT><#VL> <#LT> <#VL>
15 <C><#VL>Right Tee <#VL>\<\#RT><#VL> <#RT> <#VL>
16 <C><#VL>Bottom Tee <#VL>\<\#BT><#VL> <#BT> <#VL>
17 <C><#VL>Top Tee <#VL>\<\#TT><#VL> <#TT> <#VL>
18 <C><#VL>Plus <#VL>\<\#PL><#VL> <#PL> <#VL>
19 <C><#VL>Plus/Minus <#VL>\<\#PM><#VL> <#PM> <#VL>
20 <C><#VL>Degree <#VL>\<\#DG><#VL> <#DG> <#VL>
21 <C><#VL>Checker Board <#VL>\<\#CB><#VL> <#CB> <#VL>
22 <C><#VL>Diamond <#VL>\<\#DI><#VL> <#DI> <#VL>
23 <C><#VL>Bullet <#VL>\<\#BU><#VL> <#BU> <#VL>
24 <C><#LL><#HL(17)><#BT><#HL(4)><#BT><#HL(6)><#LR>
25
26 If you want more than one special character to appear, an optional numeric
27 repeat argument can be used. For example, if you wanted to draw 70
28 horizontal line characters in a row, typing in \<\#HL> 70 times is excessive.
29 To do this use a numeric repeat value like \<\#HL(70)>. This tells Cdk to
30 draw the horizontal line character 70 times. This is how the line below is
31 drawn.
32
33 <C><#HL(70)>
34 <C>Document Created: January, 1996
+0
-85
fulldemo/help/colors.help less more
0 </R>Starting Colors in Cdk<!R>
1 When Cdk is initialized with the </B>Cdk::init()<!B> function call, Cdk also
2 initializes the color chart. This saves the programmer the trouble of doing
3 this. When the color table is initialized, 64 color pairs are created. A
4 color pair is a combination of foreground colors and background colors.
5
6 </R>Using Colors<!R>
7 To turn on a color pair use the syntax \<\/XX> where XX is a numeric value
8 from 0 to 64. To turn off a color pair use the syntax \<\!XX> where XX is
9 a numeric value from 0 to 64.
10
11 The following table lists all the color pairs defined.
12
13 <C><#UL><#HL(4)><#TT><#HL(11)><#TT><#HL(11)><#UR>
14 <C><#VL></U>Pair <#VL> Foreground <#VL> Background <!U><#VL>
15 <C><#VL> 0 <#VL></B/0> Default <!B!0><#VL></B/0> Default <!B!0><#VL>
16 <C><#VL> 1 <#VL></B/1> White <!B!1><#VL></B/1> White <!B!1><#VL>
17 <C><#VL> 2 <#VL></B/2> White <!B!2><#VL></B/2> Red <!B!2><#VL>
18 <C><#VL> 3 <#VL></B/3> White <!B!3><#VL></B/3> Green <!B!3><#VL>
19 <C><#VL> 4 <#VL></B/4> White <!B!4><#VL></B/4> Yellow <!B!4><#VL>
20 <C><#VL> 5 <#VL></B/5> White <!B!5><#VL></B/5> Blue <!B!5><#VL>
21 <C><#VL> 6 <#VL></B/6> White <!B!6><#VL></B/6> Purple <!B!6><#VL>
22 <C><#VL> 7 <#VL></B/7> White <!B!7><#VL></B/7> Cyan <!B!7><#VL>
23 <C><#VL></U> 8 <#VL></B/8> White <!B!8><#VL></B/8> Black <!B!8><!U><#VL>
24 <C><#VL> 9 <#VL></B/9> Red <!B!9><#VL></B/9> White <!B!9><#VL>
25 <C><#VL> 10 <#VL></B/10> Red <!B!10><#VL></B/10> Red <!B!10><#VL>
26 <C><#VL> 11 <#VL></B/11> Red <!B!11><#VL></B/11> Green <!B!11><#VL>
27 <C><#VL> 12 <#VL></B/12> Red <!B!12><#VL></B/12> Yellow <!B!12><#VL>
28 <C><#VL> 13 <#VL></B/13> Red <!B!13><#VL></B/13> Blue <!B!13><#VL>
29 <C><#VL> 14 <#VL></B/14> Red <!B!14><#VL></B/14> Purple <!B!14><#VL>
30 <C><#VL> 15 <#VL></B/15> Red <!B!15><#VL></B/15> Cyan <!B!15><#VL>
31 <C><#VL></U> 16 <#VL></B/16> Red <!B!16><#VL></B/16> Black <!B!16><!U><#VL>
32 <C><#VL> 17 <#VL></B/17> Green <!B!17><#VL></B/17> White <!B!17><#VL>
33 <C><#VL> 18 <#VL></B/18> Green <!B!18><#VL></B/18> Red <!B!18><#VL>
34 <C><#VL> 19 <#VL></B/19> Green <!B!19><#VL></B/19> Green <!B!19><#VL>
35 <C><#VL> 20 <#VL></B/20> Green <!B!20><#VL></B/20> Yellow <!B!20><#VL>
36 <C><#VL> 21 <#VL></B/21> Green <!B!21><#VL></B/21> Blue <!B!21><#VL>
37 <C><#VL> 22 <#VL></B/22> Green <!B!22><#VL></B/22> Purple <!B!22><#VL>
38 <C><#VL> 23 <#VL></B/23> Green <!B!23><#VL></B/23> Cyan <!B!23><#VL>
39 <C><#VL></U> 24 <#VL></B/24> Green <!B!24><#VL></B/24> Black <!B!24><!U><#VL>
40 <C><#VL> 25 <#VL></B/25> Yellow <!B!25><#VL></B/25> White <!B!25><#VL>
41 <C><#VL> 26 <#VL></B/26> Yellow <!B!26><#VL></B/26> Red <!B!26><#VL>
42 <C><#VL> 27 <#VL></B/27> Yellow <!B!27><#VL></B/27> Green <!B!27><#VL>
43 <C><#VL> 28 <#VL></B/28> Yellow <!B!28><#VL></B/28> Yellow <!B!28><#VL>
44 <C><#VL> 29 <#VL></B/29> Yellow <!B!29><#VL></B/29> Blue <!B!29><#VL>
45 <C><#VL> 30 <#VL></B/30> Yellow <!B!30><#VL></B/30> Purple <!B!30><#VL>
46 <C><#VL> 31 <#VL></B/31> Yellow <!B!31><#VL></B/31> Cyan <!B!31><#VL>
47 <C><#VL></U> 32 <#VL></B/32> Yellow <!B!32><#VL></B/32> Black <!B!32><!U><#VL>
48 <C><#VL> 33 <#VL></B/33> Blue <!B!33><#VL></B/33> White <!B!33><#VL>
49 <C><#VL> 34 <#VL></B/34> Blue <!B!34><#VL></B/34> Red <!B!34><#VL>
50 <C><#VL> 35 <#VL></B/35> Blue <!B!35><#VL></B/35> Green <!B!35><#VL>
51 <C><#VL> 36 <#VL></B/36> Blue <!B!36><#VL></B/36> Yellow <!B!36><#VL>
52 <C><#VL> 37 <#VL></B/37> Blue <!B!37><#VL></B/37> Blue <!B!37><#VL>
53 <C><#VL> 38 <#VL></B/38> Blue <!B!38><#VL></B/38> Purple <!B!38><#VL>
54 <C><#VL> 39 <#VL></B/39> Blue <!B!39><#VL></B/39> Cyan <!B!39><#VL>
55 <C><#VL></U> 40 <#VL></B/40> Blue <!B!40><#VL></B/40> Black <!B!40><!U><#VL>
56 <C><#VL> 41 <#VL></B/41> Purple <!B!41><#VL></B/41> White <!B!41><#VL>
57 <C><#VL> 42 <#VL></B/42> Purple <!B!42><#VL></B/42> Red <!B!42><#VL>
58 <C><#VL> 43 <#VL></B/43> Purple <!B!43><#VL></B/43> Green <!B!43><#VL>
59 <C><#VL> 44 <#VL></B/44> Purple <!B!44><#VL></B/44> Yellow <!B!44><#VL>
60 <C><#VL> 45 <#VL></B/45> Purple <!B!45><#VL></B/45> Blue <!B!45><#VL>
61 <C><#VL> 46 <#VL></B/46> Purple <!B!46><#VL></B/46> Purple <!B!46><#VL>
62 <C><#VL> 47 <#VL></B/47> Purple <!B!47><#VL></B/47> Cyan <!B!47><#VL>
63 <C><#VL></U> 48 <#VL></B/48> Purple <!B!48><#VL></B/48> Black <!B!48><!U><#VL>
64 <C><#VL> 49 <#VL></B/49> Cyan <!B!49><#VL></B/49> White <!B!49><#VL>
65 <C><#VL> 50 <#VL></B/50> Cyan <!B!50><#VL></B/50> Red <!B!50><#VL>
66 <C><#VL> 51 <#VL></B/51> Cyan <!B!51><#VL></B/51> Green <!B!51><#VL>
67 <C><#VL> 52 <#VL></B/52> Cyan <!B!52><#VL></B/52> Yellow <!B!52><#VL>
68 <C><#VL> 53 <#VL></B/53> Cyan <!B!53><#VL></B/53> Blue <!B!53><#VL>
69 <C><#VL> 54 <#VL></B/54> Cyan <!B!54><#VL></B/54> Purple <!B!54><#VL>
70 <C><#VL> 55 <#VL></B/55> Cyan <!B!55><#VL></B/55> Cyan <!B!55><#VL>
71 <C><#VL></U> 56 <#VL></B/56> Cyan <!B!56><#VL></B/56> Black <!B!56><!U><#VL>
72 <C><#VL> 57 <#VL></B/57> Black <!B!57><#VL></B/57> White <!B!57><#VL>
73 <C><#VL> 58 <#VL></B/58> Black <!B!58><#VL></B/58> Red <!B!58><#VL>
74 <C><#VL> 59 <#VL></B/59> Black <!B!59><#VL></B/59> Green <!B!59><#VL>
75 <C><#VL> 60 <#VL></B/60> Black <!B!60><#VL></B/60> Yellow <!B!60><#VL>
76 <C><#VL> 61 <#VL></B/61> Black <!B!61><#VL></B/61> Blue <!B!61><#VL>
77 <C><#VL> 62 <#VL></B/62> Black <!B!62><#VL></B/62> Purple <!B!62><#VL>
78 <C><#VL> 63 <#VL></B/63> Black <!B!63><#VL></B/63> Cyan <!B!63><#VL>
79 <C><#VL> 64 <#VL></B/64> Black <!B!64><#VL></B/64> Black <!B!64><#VL>
80 <C><#LL><#HL(4)><#BT><#HL(11)><#BT><#HL(11)><#LR>
81
82 <C><#HL(70)>
83 <C>Document Created: November, 1995
84 <C>Document Revised: January, 1996
+0
-38
fulldemo/help/concepts.help less more
0 There are a few concepts that have to be understood before effecitively
1 writing applications using the Perl5 Cdk extension. This document will try
2 to clear the air on any 'funny' behavior you may experience using Cdk.
3
4 </U>Screens<!U>
5 Cdk uses a concept of a screen. When a widget is created it
6 automagically registers itself with the screen. When it dies it
7 automagically removes itself from the screen. If at any time you refresh
8 the screen, and a widget appears that you don't want, it means it is still
9 registered.
10
11 </U>Stricter Variable Localization<!U>
12 If you want a widget to remove itself from the screen, you can use the
13 Perl command </R>undef<!R> to destroy the widget object by hand. The easiest
14 method to do this is to use strict variable localization. (ie: only have the
15 widget variables exist as long as you need them to)
16
17 </U>Widget Mapping<!U>
18 Widget mapping is performed by the Cdk function </R>Cdk::refreshCdkScreen()<!R>.
19 This function remaps all the widgets it knows about. This almost
20 eradicates the need to call the object methods draw and erase. These are
21 included to remain as consistent and flexible as the C version.
22
23 </U>Character Input<!U>
24 To get character input yourself, the function </R>Cdk::getch()<!R> was
25 added. Though it is not meant to replace the standard method of getting
26 characters in Perl, it can be used still. The main reason why I included
27 this was to be consistent with Curses.
28
29 </U>Raw Mode<!U>
30 You can put the terminal into raw mode by calling </R>Cdk::raw()<!R>. This
31 allows you to interrupt special control characters like <CTRL>c, <CTRL>d
32 and <CTRL>z. To get out of raw mode call </R>Cdk::noraw()<!R>. This will
33 restore the terminal back.
34
35 <C><#HL(70)>
36 <C>Document Created: June, 1995
37 <C>Document Revised: November, 1995
+0
-26
fulldemo/help/debug.help less more
0 The Cdk Perl5 extension has a somewhat powerful diagnostics element
1 associated with it. It really needs it because of the behavior of Cdk. Cdk
2 was written using curses; and one of the behaviors set when using Cdk is
3 that </R>noecho<!R> is turned on. This means that whenever a character is printed
4 to the screen using </R>print<!R> or </R>printf<!R> they won't show up. This means another
5 method of diagnostics must be provided.
6
7 </U>Cdk::Diag Module:<!U>
8 The Cdk::Diag module currently only has one method: Log. It writes to the
9 log file if diagnostics has been turned on. If diagnostics has been turned
10 on, the performance of the Cdk Perl script will take a severe performance
11 hit, depending on how many diagnostics are turned on.
12
13 </U>Turning on the Diagnostics:<!U>
14 To turn the diagnostics on, there is an environment variable called
15 </R>CDKDIAG<!R> which needs to be set. This currently only really supports one
16 value: </B>ALL<!B>. There is work being done right now so diagnostics can be turned
17 on by method name, class name, required values only, default values only,
18 methods called....
19
20 </U>Diagnostic File:<!U>
21 The default diagnostic filename is </R>cdkdiag.log<!R> but can be changed by
22 setting the environment variable </R>CDKLOGFILE<!R>.
23
24 <C><#HL(70)>
25 <C>Document Created: June, 1995
+0
-267
fulldemo/help/dialog.help less more
0 </R>Purpose<!R>
1 The Cdk Dialog widget allows the user to pick from a number of options
2 using buttons provided. The dialog box presents a message, and a list of
3 options using the buttons.
4
5 </R>Construction Options<!R>
6 A dialog widget is defined using the following syntax. The variable
7 </B>$dialogObject<!B> contains the reference to the dialog object.
8 <C></B>$dialogObject = new Cdk::Dialog ( options );
9
10 The options are defined in the following table.
11
12 </U>Option Default Value Type Purpose<!U>
13 Mesg Required List Ref This is the message which is displayed
14 in the dialog box.
15 Buttons Required List Ref This is a list of the button labels.
16 Xpos Center Scalar This is the position of the window on
17 the X axis.
18 Ypos Center Scalar This is the position of the window on
19 the Y axis.
20 Highlight Reverse Scalar The highlight attribute of the
21 currently selected button.
22 Separator True Scalar This Boolean value states whether a
23 separator will be drawn between the
24 message and the buttons.
25 Box True Scalar This Boolean states whether the dialog
26 box will have a box drawn around it.
27 Shadow False Scalar This Boolean states whether the dialog
28 box will have a shadow on the box.
29
30 </R>Available Methods<!R>
31
32 </B>activate<!B>
33 Activation of an object means to make the object available for use. The
34 following example demonstrates how to activate a dialog widget.
35 <C></B>$returnValue = $dialogObject->activate ();
36
37 The variable </B>$returnValue<!B> contains an integer value representing which
38 button was actually selected. The value starts at zero and goes up.
39
40 </B>inject<!B>
41 This function injects a single character into the widget. The following
42 examples demonstrates how to call the inject method.
43 <C></B>$dialogObject->inject ( options );
44
45 The options are defined in the following table.
46 </U>Option Default Value Type Purpose<!U>
47 Shadow Required Scalar The character to inject into the widget.
48
49 If you are injecting a special character into the widget, then you can
50 use a pre-defined value to represent the key.
51
52 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
53 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
54 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
55 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
56 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
57 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
58 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
59 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
60 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
61 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
62 <C><#VL>Home <#VL>KEY_HOME <#VL>
63 <C><#VL>End <#VL>KEY_END <#VL>
64 <C><#VL>Escape <#VL>KEY_ESC <#VL>
65 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
66
67 </B>set<!B>
68 Sets or resets certain attributes or features of the widget. The following
69 example demonstrates how to call the set method.
70 <C></B>$dialogObject->set ( options );
71
72 The options are defined in the following table.
73
74 </U>Option Default Value Type Purpose<!U>
75 Highlight Required Scalar Changes the current highlight attribute.
76 Separator Required Scalar Changes the current value for the
77 separator flag.
78 Box True Scalar Changes the current value for the box
79 flag.
80
81 </B>draw<!B>
82 This method draws the object on the screen. The following example
83 demonstrates how to call the draw method.
84 <C></B>$dialogObject->draw ( options );
85
86 The options are defined in the following table.
87
88 </U>Option Default Value Type Purpose<!U>
89 Box True Scalar Draws the window with a box.
90
91 </B>erase<!B>
92 This method removes the object from the screen. This does </B/U>NOT<!B!U> destroy
93 the object. The following example demonstrates how to call the erase
94 method.
95 <C></B>$dialogObject->erase ();
96
97 </B>bind<!B>
98 The bind method binds keys to events. The binding is specific to the
99 individual objects. The following example demonstrates how to call the
100 bind method.
101 <C></B>$dialogObject->bind ( options );
102
103 The options are defined in the following table.
104
105 </U>Option Default Value Type Purpose<!U>
106 Key Required Scalar This is the character to bind the
107 event to.
108 Function Required Scalar This is the name of the callback
109 function.
110
111 </B>preProcess<!B>
112 The </B>preProcess<!B> function sets a process to be run before the key entered
113 is processed. If this function returns a value of 0, then the key injected
114 into the widget will not be processed; otherwise the character will be
115 processed as normal. The following example demonstrates how to call the
116 preProcess method.
117 <C></B>$dialogObject->preProcess ( options );
118
119 The options are defined in the following table.
120
121 </U>Option Default Value Type Purpose<!U>
122 Function Required Scalar This is the name of the
123 callback function.
124
125 To create a pre-process callback the following code segment demonstrates
126 how to do it properly.
127
128 <C></B>$alphalistObject->preProcess ('Function' => sub { callback (@_); });
129
130 Notice that the array </B>@_<!B> is passed into the function called
131 </B>callback<!B>. This is done because when the callback process is
132 called the key which was pressed is passed into the perl subroutine.
133 Since we nest the call-back function inside an anonymous subroutine,
134 we need to pass the array </B>@_<!B> to the call-back function. If
135 the key given to the call-back function is a non alphanumeric key
136 then a predefined value will be given to the function. The following
137 table describes the values passed into the function.
138
139 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
140 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
141 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
142 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
143 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
144 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
145 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
146 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
147 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
148 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
149 <C><#VL>Home <#VL>KEY_HOME <#VL>
150 <C><#VL>End <#VL>KEY_END <#VL>
151 <C><#VL>Escape <#VL>KEY_ESC <#VL>
152 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
153
154 If the pre-process function returns a value of 0 the key hit will
155 not be injected into the widget. This allows the programmer to
156 selectively pick which characters will or will not get injected
157 into the widget.
158
159 The </B>postProcess<!B> function sets a process to be run before the key entered
160 is processed. If this function returns a value of 0, then the key injected
161 into the widget will not be processed; otherwise the character will be
162 processed as normal. The following example demonstrates how to call the
163 postProcess method.
164 <C></B>$dialogObject->postProcess ( options );
165
166 The options are defined in the following table.
167
168 </U>Option Default Value Type Purpose<!U>
169 Function Required Scalar This is the name of the
170 callback function.
171
172 To create a post-process callback the following code segment demonstrates
173 how to do it properly.
174
175 <C></B>$alphalistObject->postProcess ('Function' => sub { callback (@_); });
176
177 Notice that the array </B>@_<!B> is passed into the function called
178 </B>callback<!B>. This is done because when the callback process is
179 called the key which was pressed is passed into the perl subroutine.
180 Since we nest the call-back function inside an anonymous subroutine,
181 we need to pass the array </B>@_<!B> to the call-back function. If
182 the key given to the call-back function is a non alphanumeric key
183 then a predefined value will be given to the function. The following
184 table describes the values passed into the function.
185
186 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
187 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
188 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
189 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
190 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
191 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
192 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
193 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
194 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
195 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
196 <C><#VL>Home <#VL>KEY_HOME <#VL>
197 <C><#VL>End <#VL>KEY_END <#VL>
198 <C><#VL>Escape <#VL>KEY_ESC <#VL>
199 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
200 </B>raise<!B>
201 The raise method raises the widget to the top of the screen. This means if
202 there were any widgets obscuring part of the view, raising the object would
203 bring the complete object into view. The following example demonstrates how
204 to call the raise method.
205 <C></B>$dialogObject->raise();
206
207 </B>lower<!B>
208 The lower method lowers the object so it doesn't obscure the view of any
209 other objects. The following example demonstrates how to call the lower
210 method.
211 <C></B>$dialogObject->lower();
212
213 </B>register<!B>
214 The register method registers the object to the default screen. This does </R>NOT<!R>
215 have to be called since the objects are registered automatically. This method
216 should be called if the </B>unregister<!B> method was called. The following
217 example demonstrates how to call the register method.
218 <C></B>$dialogObject->register();
219
220 </B>unregister<!B>
221 The unregister method should be called when a widget, which is part of the
222 default screen, needs to be taken away temporarily. This does not delete or
223 free the object, it just unmaps it from any future screen refreshes. The
224 object can be registered by calling the </B>register<!B> method. The
225 following example demonstrates how to call the unregister method.
226 <C></B>$dialogObject->unregister();
227
228 </B>getwin<!B>
229 This method returns a pointer to the window of the object. Not much use for
230 this yet. It will be useful in the future when the drawing methods are added.
231 The following example demonstrates how to call the getwin method.
232 <C></B>$dialogObject->getwin();
233
234 </R>Default Key Bindings<!R>
235 </U>Key Action<!U>
236 Left Arrow Highlights the button to the left of the currently
237 highlighted button.
238 Right Arrow Highlights the button to the right of the currently
239 highlighted button.
240 Space Highlights the button to the right of the currently
241 highlighted button.
242 Return Exits the widget and returns a value representing the
243 selected button. The range of the value is from 0 to
244 the number of buttons -1.
245 Tab Exits the widget and returns a value representing the
246 selected button. The range of the value is from 0 to
247 the number of buttons -1.
248 Escape Exits the dialog widget and returns undef.
249 CTRL-R Refreshes the screen.
250
251 </R>Tips & Tricks<!R>
252 <B=*>If you pass the dialog with no message and no separator, the
253 dialog box appears be a tool bar.
254
255 </R>Physical Restrictions<!R>
256 </U>Restriction Value<!U>
257 Maximum message rows. 50
258 Maximum dialog buttons. 25
259
260 </R>Example Use Of The Widget<!R>
261 <F=../examples/dialog>
262 <C><#HL(70)>
263 <C>Document Created: June, 1995
264 <C>Document Revised: November, 1995
265 <C>Document Revised: January, 1996
266 <C>Document Revised: June, 1996
+0
-67
fulldemo/help/display.help less more
0 There are a number of display types and position types that should be
1 explained. These names can be used to both position the widget itself
2 and the contents within the widget.
3
4 </R>Widget Positioning<!R>
5 There are five pre-defined position names that help location either a
6 widget or a widgets title, or any other element of a widget. They are
7 listed in the table below.
8
9 <C><#UL><#HL(7)><#TT><#HL(46)><#UR>
10 <C><#VL></U>Name <#VL>Purpose <!U><#VL>
11 <C><#VL>TOP <#VL>Positions a widget to the top of the screen. <#VL>
12 <C><#VL>BOTTOM <#VL>Positions a widget to the bottom of the screen.<#VL>
13 <C><#VL>LEFT <#VL>Positions a widget to the left of the screen. <#VL>
14 <C><#VL>RIGHT <#VL>Positions a widget to the right of the screen. <#VL>
15 <C><#VL>CENTER <#VL>Positions a widget to the center of the screen.<#VL>
16 <C><#LL><#HL(7)><#BT><#HL(46)><#LR>
17
18 If the names are not used, then a numeric value can be used for location.
19
20 </R>Entry Field Display Types<!R>
21 The entry fields, Matrix, Entry and Multiple Line Entry, can define the
22 type of input defined. They are specified with the following pre-defined
23 display type variables.
24
25 <C><#UL><#HL(8)><#TT><#HL(39)><#UR>
26 <C><#VL></U>Name <#VL>Result <!U><#VL>
27 <C><#VL>CHAR <#VL> Character only. <#VL>
28 <C><#VL>HCHAR <#VL> Hidden Character Only. <#VL>
29 <C><#VL>INT <#VL> Integer only. <#VL>
30 <C><#VL>HINT <#VL> Hidden Integer Only. <#VL>
31 <C><#VL>MIXED <#VL> Mixed Input. <#VL>
32 <C><#VL>HMIXED <#VL> Hidden Mixed Input. <#VL>
33 <C><#VL>UCHAR <#VL> Upper Case Character Input. <#VL>
34 <C><#VL>LCHAR <#VL> Lower Case Character Input. <#VL>
35 <C><#VL>UHCHAR <#VL> Upper Case Hidden Character Input. <#VL>
36 <C><#VL>LHCHAR <#VL> Lower Case Hidden Character Input. <#VL>
37 <C><#VL>UMIXED <#VL> Upper Case Mixed Input. <#VL>
38 <C><#VL>LMIXED <#VL> Lower Case Mixed Input. <#VL>
39 <C><#VL>UHMIXED <#VL> Upper Case Hidden Mixed Input. <#VL>
40 <C><#VL>LHMIXED <#VL> Lower Case Hidden Mixed Input. <#VL>
41 <C><#VL>VIEWONLY <#VL> View only field. (uneditable) <#VL>
42 <C><#LL><#HL(8)><#BT><#HL(39)><#LR>
43
44 </K>NOTE<!K> When the above says Upper/Lower Case that means all the input
45 auto-magically gets mapped to Upper/Lower case. When it says hidden
46 it means the input is taken and stored; only a . is presented for
47 each key hit. This is useful for password or hidden entries.
48
49 </R>Special Types<!R>
50 Special types exist for certain widgets. Below is a list of the current
51 widgets that have a special type, its name and description.
52
53 <C><#UL<#HL(9)><#TT><#HL(10)><#TT><#HL(43)><#UR>
54 <C><#VL></U>Widget <#VL>Type Name <#VL>Result <!U><#VL>
55 <C><#VL>Histogram <#VL>NONE <#VL>Turns off the statistics for the histogram. <#VL>
56 <C><#VL> <#VL>PERCENT <#VL>Sets the statistics to a percentage. <#VL>
57 <C><#VL> <#VL>REAL <#VL>Sets the statistics to the real value. <#VL>
58 <C><#VL> <#VL>HORIZONTAL <#VL>Specifies a horizontal histogram. <#VL>
59 <C><#VL> <#VL>VERTICAL <#VL>Specifies a vertical histogram. <#VL>
60 <C><#VL>Graph <#VL>PLOT <#VL>Specifies the graph will draw a plot graph. <#VL>
61 <C><#VL> <#VL>LINE <#VL>Specifies the graph will draw a line graph. <#VL>
62 <C><#LL<#HL(9)><#BT><#HL(10)><#BT><#HL(43)><#LR>
63
64 <C><#HL(70)>
65 <C>Document Created: June, 1995
66 <C>Document Revised: November, 1995
+0
-273
fulldemo/help/entry.help less more
0 </R>Purpose<!R>
1 The Cdk Entry widget allows the user to type in input within a widget. The
2 entry field has a solid basis of editing features.
3
4 </R>Construction Options<!R>
5 A entry widget is defined using the following syntax. The variable
6 </B>$entryObject<!B> contains the reference to the entry object.
7 <C></B>$entryObject = new Cdk::Entry ( options );
8
9 The options are defined in the following table.
10
11 </U>Option Default Value Type Purpose<!U>
12 Label Required Scalar The label of the entry field.
13 Max Required Scalar The maximum length of the value
14 entered.
15 Min 0 Scalar The minimum length of the value
16 entered.
17 Width Required Scalar The width of the field on the
18 screen.
19 Filler . Scalar The default field character.
20 Dtype Mixed Scalar The display type. (See Display Help)
21 Xpos Center Scalar This is the position of the window
22 on the X axis.
23 Ypos Center Scalar This is the position of the window
24 on the Y axis.
25 Lpos Left Scalar This is the position of the label
26 in the widget.
27 Fieldattr Normal Scalar The attribute of the characters
28 typed in.
29 Box True Scalar This Boolean states whether the
30 dialog box will have a box drawn
31 around it.
32 Shadow False Scalar This Boolean states whether the
33 dialog box will have a shadow on
34 the box.
35
36 </R>Available Methods<!R>
37 </B>activate<!B>
38 Activation of an object means to make the object available for use. The
39 following example demonstrates how to activate a entry widget.
40 <C></B>$returnValue = $entryObject->activate ();
41
42 The variable </B>$returnValue<!B> contains a scalar value of what was typed
43 into the entry field.
44
45 </B>inject<!B>
46 This function injects a single character into the widget. The following
47 examples demonstrates how to call the inject method.
48 <C></B>$entryObject->inject ( options );
49
50 The options are defined in the following table.
51 </U>Option Default Value Type Purpose<!U>
52 Shadow Required Scalar The character to inject into the widget.
53
54 If you are injecting a special character into the widget, then you can
55 use a pre-defined value to represent the key.
56
57 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
58 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
59 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
60 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
61 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
62 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
63 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
64 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
65 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
66 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
67 <C><#VL>Home <#VL>KEY_HOME <#VL>
68 <C><#VL>End <#VL>KEY_END <#VL>
69 <C><#VL>Escape <#VL>KEY_ESC <#VL>
70 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
71
72 </B>set<!B>
73 Sets or resets certain attributes or features of the widget. The following
74 demonstrates how to call the set method from the entry field.
75 <C></B>$entryObject->set ( options );
76
77 The options are defined in the following table.
78
79 </U>Option Default Value Type Purpose<!U>
80 Value Required Scalar Sets the value of the entry field.
81 Min Same as set value Scalar Sets the size of the minimum
82 length of the information typed in.
83 Max Same as set value Scalar Sets the size of the maximum
84 length of the information typed in.
85 Box True Scalar Changes the current value of the
86 box flag.
87
88 </B>bind<!B>
89 The bind method binds keys to events. The binding is specific to the individual
90 objects. The following example demonstrates how to call the bind method.
91 <C></B>$entryObject->bind ( options );
92
93 The options are defined in the following table.
94
95 </U>Option Default Value Type Purpose<!U>
96 Key Required Scalar This is the character to bind the
97 event to.
98 Function Required Scalar This is the name of the callback
99 function.
100
101 </B>preProcess<!B>
102 The </B>preProcess<!B> function sets a process to be run before the key entered
103 is processed. If this function returns a value of 0, then the key injected
104 into the widget will not be processed; otherwise the character will be
105 processed as normal. The following example demonstrates how to call the
106 preProcess method.
107 <C></B>$entryObject->preProcess ( options );
108
109 The options are defined in the following table.
110
111 </U>Option Default Value Type Purpose<!U>
112 Function Required Scalar This is the name of the
113 callback function.
114
115 To create a pre-process callback the following code segment demonstrates
116 how to do it properly.
117
118 <C></B>$entryObject->preProcess ('Function' => sub { callback (@_); });
119
120 Notice that the array </B>@_<!B> is passed into the function called
121 </B>callback<!B>. This is done because when the callback process is
122 called the key which was pressed is passed into the perl subroutine.
123 Since we nest the call-back function inside an anonymous subroutine,
124 we need to pass the array </B>@_<!B> to the call-back function. If
125 the key given to the call-back function is a non alphanumeric key
126 then a predefined value will be given to the function. The following
127 table describes the values passed into the function.
128
129 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
130 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
131 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
132 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
133 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
134 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
135 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
136 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
137 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
138 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
139 <C><#VL>Home <#VL>KEY_HOME <#VL>
140 <C><#VL>End <#VL>KEY_END <#VL>
141 <C><#VL>Escape <#VL>KEY_ESC <#VL>
142 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
143
144 If the pre-process function returns a value of 0 the key hit will
145 not be injected into the widget. This allows the programmer to
146 selectively pick which characters will or will not get injected
147 into the widget.
148
149 The </B>postProcess<!B> function sets a process to be run before the key entered
150 is processed. If this function returns a value of 0, then the key injected
151 into the widget will not be processed; otherwise the character will be
152 processed as normal. The following example demonstrates how to call the
153 postProcess method.
154 <C></B>$entryObject->postProcess ( options );
155
156 The options are defined in the following table.
157
158 </U>Option Default Value Type Purpose<!U>
159 Function Required Scalar This is the name of the
160 callback function.
161
162 To create a post-process callback the following code segment demonstrates
163 how to do it properly.
164
165 <C></B>$entryObject->postProcess ('Function' => sub { callback (@_); });
166
167 Notice that the array </B>@_<!B> is passed into the function called
168 </B>callback<!B>. This is done because when the callback process is
169 called the key which was pressed is passed into the perl subroutine.
170 Since we nest the call-back function inside an anonymous subroutine,
171 we need to pass the array </B>@_<!B> to the call-back function. If
172 the key given to the call-back function is a non alphanumeric key
173 then a predefined value will be given to the function. The following
174 table describes the values passed into the function.
175
176 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
177 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
178 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
179 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
180 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
181 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
182 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
183 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
184 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
185 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
186 <C><#VL>Home <#VL>KEY_HOME <#VL>
187 <C><#VL>End <#VL>KEY_END <#VL>
188 <C><#VL>Escape <#VL>KEY_ESC <#VL>
189 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
190 </B>draw<!B>
191 This method draws the object on the screen. The following example demonstrates
192 how to call the draw method.
193 <C></B>$entryObject->draw ( options );
194
195 The options are defined in the following table.
196
197 </U>Option Default Value Type Purpose<!U>
198 Box True Scalar Draws the window with a box around it.
199
200 </B>erase<!B>
201 This method removes the object from the screen. This does </B/U>NOT<!B!U>
202 destroy the object. The following example demonstrates how to call the erase
203 method.
204 <C></B>$entryObject->erase ();
205
206 </B>clean<!B>
207 This method cleans the information from inside the entry object. The following
208 example demonstrates how to call the clean method.
209 <C></B>$entryObject->clean();
210
211 </B>raise<!B>
212 The raise method raises the widget to the top of the screen. This means if there
213 were any widgets obscuring part of the view, raising the object would bring the
214 complete object into view. The following example demonstrates how to call the
215 raise method.
216 <C></B>$entryObject->raise();
217
218 </B>lower<!B>
219 The lower method lowers the object so it doesn't obscure the view of any other
220 objects. The following example demonstrates how to call the lower method.
221 <C></B>$entryObject->lower();
222
223 </B>register<!B>
224 The register method registers the object to the default screen. This does </R>NOT<!R>
225 have to be called since the objects are registered automatically. This method
226 should be called if the </B>unregister<!B> method was called. The following
227 example demonstrates how to call the register method.
228 <C></B>$entryObject->register();
229
230 </B>unregister<!B>
231 The unregister method should be called when a widget, which is part of the
232 default screen, needs to be taken away temporarily. This does not delete or free
233 the object, it just unmaps it from any future screen refreshes. The object can
234 be registered by calling the </B>register<!B> method. The following example
235 demonstrates how to call the unregister method.
236 <C></B>$entryObject->unregister();
237
238 </B>getwin<!B>
239 This method returns a pointer to the window of the object. Not much use for this
240 yet. It will be useful in the future when the drawing methods are added. The
241 following example demonstrates how to call the getwin method.
242 <C></B>$entryObject->getwin();
243
244 </R>Default Key Bindings<!R>
245 </U>Key Action<!U>
246 Left Arrow Moves the cursor one character to the left.
247 Right Arrow Moves the cursor one character to the right.
248 Delete Deletes the character to the left of the cursor.
249 Backspace Deletes the character to the left of the cursor.
250 Return Exits the widget and returns a scalar representing
251 the informarion which was typed into the field.
252 Tab Exits the widget and returns a scalar representing
253 the informarion which was typed into the field.
254 Escape Exits the widget and returns undef.
255 CTRL-R Refreshes the screen.
256
257 </R>Tips & Tricks<!R>
258 <B=*>The label can be put on the left, right, top or bottom of the field,
259 <I=5>allowing for a more dynamic placement of the label itself.
260 <B=*>Setting the Dtype variable to a hidden type creates an entry field
261 <I=5>suitable for a password.
262
263 </R>Physical Restrictions<!R>
264 None.
265
266 </R>Example Use Of The Widget<!R>
267 <F=../examples/entry>
268 <C><#HL(70)>
269 <C>Document Created: June, 1995
270 <C>Document Revised: November, 1995
271 <C>Document Revised: March, 1996
272 <C>Document Revised: June, 1996
+0
-279
fulldemo/help/fselect.help less more
0 </R>Purpose<!R>
1 The Cdk file selector widget allows the user to select a valid file using
2 a full screen interface.
3
4 </R>Construction Options<!R>
5 The file selector widget is defined using the following syntax. The variable
6 </B>$fselectObject<!B> contains the reference to the entry object.
7 <C></B>$fselectObject = new Cdk::Fselect ( options );
8
9 The options are defined in the following table.
10
11 </U>Option Default Value Type Purpose<!U>
12 Label Required Scalar The label of the widget.
13 Height Required Scalar The height of the widget.
14 Width Required Scalar The width of the widget.
15 Dattrib Normal Scalar The display attributes of a directory
16 inside the scroll region.
17 Fattrib Normal Scalar The display attributes of a file
18 inside the scroll region.
19 Lattrib Normal Scalar The display attributes of a link
20 inside the scroll region.
21 Sattrib Normal Scalar The display attributes of a socket
22 inside the scroll region.
23 Highlight Reverse Scalar The highlight attribute of the
24 scrolling list.
25 Fieldattr Normal Scalar The attribute of the characters
26 typed in.
27 Filler . Scalar The default field character.
28 Xpos Center Scalar This is the position of the window
29 on the X axis.
30 Ypos Center Scalar This is the position of the window
31 on the Y axis.
32 Box True Scalar This Boolean states whether the
33 dialog box will have a box drawn
34 around it.
35 Shadow False Scalar This Boolean states whether the
36 dialog box will have a shadow on
37 the box.
38
39 </R>Available Methods<!R>
40 </B>activate<!B>
41 Activation of an object means to make the object available for use. The
42 following example demonstrates how to activate a entry widget.
43 <C></B>$returnValue = $fselectObject->activate ();
44
45 The variable </B>$returnValue<!B> contains a scalar value of what was typed into
46 the entry field.
47
48 </B>inject<!B>
49 This function injects a single character into the widget. The following
50 examples demonstrates how to call the inject method.
51 <C></B>$fselectObject->inject ( options );
52
53 The options are defined in the following table.
54 </U>Option Default Value Type Purpose<!U>
55 Shadow Required Scalar The character to inject into the widget.
56
57 If you are injecting a special character into the widget, then you can
58 use a pre-defined value to represent the key.
59
60 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
61 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
62 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
63 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
64 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
65 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
66 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
67 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
68 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
69 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
70 <C><#VL>Home <#VL>KEY_HOME <#VL>
71 <C><#VL>End <#VL>KEY_END <#VL>
72 <C><#VL>Escape <#VL>KEY_ESC <#VL>
73 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
74
75 </B>set<!B>
76 Sets or resets certain attributes or features of the widget. The following
77 demonstrates how to call the set method from the entry field.
78 <C></B>$fselectObject->set ( options );
79
80 The options are defined in the following table.
81
82 </U>Option Default Value Type Purpose<!U>
83 Directory Required Scalar The directory to display.
84 Dattrib Normal Scalar The display attributes of a directory
85 inside the scroll region.
86 Fattrib Normal Scalar The display attributes of a file
87 inside the scroll region.
88 Lattrib Normal Scalar The display attributes of a link
89 inside the scroll region.
90 Sattrib Normal Scalar The display attributes of a socket
91 inside the scroll region.
92 Highlight Reverse Scalar The highlight attribute of the
93 scrolling list.
94 Fieldattr Normal Scalar The attribute of the characters
95 typed in.
96 Filler . Scalar The default field character.
97 Box True Scalar Changes the current value of the
98 box flag.
99
100 </B>bind<!B>
101 The bind method binds keys to events. The binding is specific to the individual
102 objects. The following example demonstrates how to call the bind method.
103 <C></B>$fselectObject->bind ( options );
104
105 The options are defined in the following table.
106
107 </U>Option Default Value Type Purpose<!U>
108 Key Required Scalar This is the character to bind the event to.
109 Function Required Scalar This is the name of the callback function.
110
111 </B>preProcess<!B>
112 The </B>preProcess<!B> function sets a process to be run before the key entered
113 is processed. If this function returns a value of 0, then the key injected
114 into the widget will not be processed; otherwise the character will be
115 processed as normal. The following example demonstrates how to call the
116 preProcess method.
117 <C></B>$fselectObject->preProcess ( options );
118
119 The options are defined in the following table.
120
121 </U>Option Default Value Type Purpose<!U>
122 Function Required Scalar This is the name of the
123 callback function.
124
125 To create a pre-process callback the following code segment demonstrates
126 how to do it properly.
127
128 <C></B>$fselectObject->preProcess ('Function' => sub { callback (@_); });
129
130 Notice that the array </B>@_<!B> is passed into the function called
131 </B>callback<!B>. This is done because when the callback process is
132 called the key which was pressed is passed into the perl subroutine.
133 Since we nest the call-back function inside an anonymous subroutine,
134 we need to pass the array </B>@_<!B> to the call-back function. If
135 the key given to the call-back function is a non alphanumeric key
136 then a predefined value will be given to the function. The following
137 table describes the values passed into the function.
138
139 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
140 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
141 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
142 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
143 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
144 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
145 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
146 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
147 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
148 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
149 <C><#VL>Home <#VL>KEY_HOME <#VL>
150 <C><#VL>End <#VL>KEY_END <#VL>
151 <C><#VL>Escape <#VL>KEY_ESC <#VL>
152 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
153
154 If the pre-process function returns a value of 0 the key hit will
155 not be injected into the widget. This allows the programmer to
156 selectively pick which characters will or will not get injected
157 into the widget.
158
159 The </B>postProcess<!B> function sets a process to be run before the key entered
160 is processed. If this function returns a value of 0, then the key injected
161 into the widget will not be processed; otherwise the character will be
162 processed as normal. The following example demonstrates how to call the
163 postProcess method.
164 <C></B>$fselectObject->postProcess ( options );
165
166 The options are defined in the following table.
167
168 </U>Option Default Value Type Purpose<!U>
169 Function Required Scalar This is the name of the
170 callback function.
171
172 To create a post-process callback the following code segment demonstrates
173 how to do it properly.
174
175 <C></B>$fselectObject->postProcess ('Function' => sub { callback (@_); });
176
177 Notice that the array </B>@_<!B> is passed into the function called
178 </B>callback<!B>. This is done because when the callback process is
179 called the key which was pressed is passed into the perl subroutine.
180 Since we nest the call-back function inside an anonymous subroutine,
181 we need to pass the array </B>@_<!B> to the call-back function. If
182 the key given to the call-back function is a non alphanumeric key
183 then a predefined value will be given to the function. The following
184 table describes the values passed into the function.
185
186 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
187 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
188 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
189 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
190 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
191 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
192 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
193 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
194 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
195 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
196 <C><#VL>Home <#VL>KEY_HOME <#VL>
197 <C><#VL>End <#VL>KEY_END <#VL>
198 <C><#VL>Escape <#VL>KEY_ESC <#VL>
199 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
200 </B>draw<!B>
201 This method draws the object on the screen. The following example demonstrates
202 how to call the draw method.
203 <C></B>$fselectObject->draw ( options );
204
205 The options are defined in the following table.
206
207 </U>Option Default Value Type Purpose<!U>
208 Box True Scalar Draws the window with a box around it.
209
210 </B>erase<!B>
211 This method removes the object from the screen. This does </B/U>NOT<!B!U>
212 destroy the object. The following example demonstrates how to call the erase
213 method.
214 <C></B>$fselectObject->erase ();
215
216 </B>raise<!B>
217 The raise method raises the widget to the top of the screen. This means if there
218 were any widgets obscuring part of the view, raising the object would bring the
219 complete object into view. The following example demonstrates how to call the
220 raise method.
221 <C></B>$fselectObject->raise();
222
223 </B>lower<!B>
224 The lower method lowers the object so it doesn't obscure the view of any other
225 objects. The following example demonstrates how to call the lower method.
226 <C></B>$fselectObject->lower();
227
228 </B>register<!B>
229 The register method registers the object to the default screen. This does </R>NOT<!R>
230 have to be called since the objects are registered automatically. This method
231 should be called if the </B>unregister<!B> method was called. The following
232 example demonstrates how to call the register method.
233 <C></B>$fselectObject->register();
234
235 </B>unregister<!B>
236 The unregister method should be called when a widget, which is part of the
237 default screen, needs to be taken away temporarily. This does not delete or free
238 the object, it just unmaps it from any future screen refreshes. The object can
239 be registered by calling the </B>register<!B> method. The following example
240 demonstrates how to call the unregister method.
241 <C></B>$fselectObject->unregister();
242
243 </B>getwin<!B>
244 This method returns a pointer to the window of the object. Not much use for this
245 yet. It will be useful in the future when the drawing methods are added. The
246 following example demonstrates how to call the getwin method.
247 <C></B>$fselectObject->getwin();
248
249 </R>Default Key Bindings<!R>
250 Since this widget is 'driven' by the entry field the default key bindings
251 of that widget apply. There are others which have been applied, they are
252 listed below.
253
254 </U>Key Action<!U>
255 Return If the file is a directory, then the file selector will
256 change directories. Otherwise the widget will return the
257 full pathname of the selected file.
258 TAB Displays intformation about the currnetly highlighted file.
259 Key Up Scrolls the list one item backward.
260 Page Up Scrolls the list one page backward.
261 CTRL-B Scrolls the list one page backward.
262 Key Down Scrolls the list one line forward.
263 Page Down Scrolls the list one page forward.
264 CTRL-F Scrolls the list one page forward.
265 Escape Exits the widget and returns undef.
266
267 </R>Tips & Tricks<!R>
268 None.
269
270 </R>Physical Restrictions<!R>
271 Same as the scrolling list.
272
273 </R>Example Use Of The Widget<!R>
274 <F=../examples/fselect>
275 <C><#HL(70)>
276 <C>Document Created: December, 1995
277 <C>Document Revised: March, 1996
278 <C>Document Revised: June, 1996
+0
-16
fulldemo/help/future.help less more
0 The future of Cdk has in it a number of additions. Here is a composite list
1 of things to come:
2
3 </R>General<!R>
4 <B=*>Would like to have a captive shell, so commands can be spawned via Cdk.
5 This would allow Cdk to run commands and trap the output.
6 <B=*>I am presently working on creating a tree widget.
7
8 </R>New Features/Widgets<!R>
9 <B=*>Possible Editor to place widgets...
10 <B=*>Full range of drawing routines.
11
12 <C><#HL(70)>
13 <C>Document Created: June, 1995
14 <C>Document Revised: November, 1995
15 <C>Document Revised: June, 1996
+0
-104
fulldemo/help/general.help less more
0 <C></U>Preamble:<!U>
1 The Cdk curses widget set was written by myself (Mike Glover). It started
2 as a small pet project to test how compatible my new Linux box was to other
3 flavours of Unix. As it turned out I discovered Ncurses, and played with
4 that a whole lot. This constant playing with Ncurses created what is
5 currently known as Cdk. Cdk has evolved many times since its first inception
6 and has evolved to what you are currently looking at. One day I finally told
7 myself that the C version was 'done'. I quickly looked in other directions
8 for the Cdk widget set. One day I told myself:
9
10 <C>"Cdk would be really cool if it was
11 <C> interpreted instead of compiled! "
12
13 Enter Mike's love of Perl. It finally dawned on me that I could extend Perl5
14 to include the Cdk widget set. So I started to play with Perl5. The more I
15 played with Perl5, the more I really started to like the additions. I
16 finally read the manual pages on how to extend Perl5 to include other
17 libraries. As time passed I entrenched myself deeper into extending Perl5 to
18 what I currently call the Cdk Perl5 extension. After about 2 months of work,
19 Cdk was finally extended into Perl5. (crowd cheers...)
20
21 </R>Info:<!R>
22 I'm sure the first question being asked is, 'What does Cdk
23 stand for?'. In response I say : (fanfare please)
24
25 <C></B/U>Curses Development Kit<!B!U>
26
27 There are currently 22 widgets available in Cdk, with more coming. What they
28 are and what they do is in the following table.
29
30 <C><#UL><#HL(13)><#TT><#HL(51)><#UR>
31 <C><#VL></R> Widget Name <!R></U><#VL><!U></R>Purpose <!R><#VL>
32 <C><#VL>Alphalist <#VL>Provides a list of words which the user can select <#VL>
33 <C><#VL> <#VL>from. Allows you to narrow the seach by entering <#VL>
34 <C><#VL> <#VL>a few initial characters of thw words being <#VL>
35 <C><#VL></U> <#VL>sought after to narrow the search. <!U><#VL>
36 <C><#VL></U>Buttonbox <#VL>Creates a widget with numerous buttons. <!U><#VL>
37 <C><#VL></U>Calendar <#VL>Creates a simple calendar widget. <!U><#VL>
38 <C><#VL>Dialog <#VL>Prompts the user with a message, and the user <#VL>
39 <C><#VL></U> <#VL>can pick an answer from the buttons provided. <!U><#VL>
40 <C><#VL></U>Entry <#VL>Allows the user to enter information. <!U><#VL>
41 <C><#VL>File Selector <#VL>A file selector built from Cdk base widgets. <#VL>
42 <C><#VL> <#VL>This example shows how to create more complicated <#VL>
43 <C><#VL></U> <#VL>widgets using the Cdk widget library. <!U><#VL>
44 <C><#VL></U>Graph <#VL>Draws a graph. <!U><#VL>
45 <C><#VL></U>Histogram <#VL>Draws a histogram. <!U><#VL>
46 <C><#VL>Item List <#VL>Creates a pop up field which allows the user to <#VL>
47 <C><#VL> <#VL>select one of several choices in a small field. Very<#VL>
48 <C><#VL> <#VL>useful for things like days of the week or month <#VL>
49 <C><#VL></U> <#VL>names. <!U><#VL>
50 <C><#VL>Label <#VL>Displays messages in a pop up box, or the label can <#VL>
51 <C><#VL></U> <#VL>be considered part of the screen. <!U><#VL>
52 <C><#VL></U>Marquee <#VL>Displays a message in a scrolling marquee. <!U><#VL>
53 <C><#VL></U>Matrix <#VL>Creates a complex matrix with lots of options. <!U><#VL>
54 <C><#VL></U>Menu <#VL>Creates a pull-down menu interface. <!U><#VL>
55 <C><#VL>Multiple Line <#VL>A multiple line entry field. Very useful for long <#VL>
56 <C><#VL></U>Entry Field <#VL>fields. (like a description field) <!U><#VL>
57 <C><#VL></U>Radio List <#VL>Creates a radio button list. <!U><#VL>
58 <C><#VL>Scale <#VL>Creates a numeric scale. Allows a user to pick a <#VL>
59 <C><#VL> <#VL>numeric value and restrict them to a range of <#VL>
60 <C><#VL></U> <#VL>values. <!U><#VL>
61 <C><#VL></U>Scrolling List<#VL>Creates a scrolling list/menu list. <!U><#VL>
62 <C><#VL>Scrolling <#VL>Creates a scrolling log file viewer. Can add <#VL>
63 <C><#VL>Window <#VL>information into the window while its running. <#VL>
64 <C><#VL> <#VL>A good widget for displaying the progress of <#VL>
65 <C><#VL></U> <#VL>something. (akin to a console window) <!U><#VL>
66 <C><#VL></U>Selection List<#VL>Creates a multiple option selection list. <!U><#VL>
67 <C><#VL></U>Slider <#VL>Akin to the Scale widget but provides a visual <!U><#VL>
68 <C><#VL></U> <#VL>representation of the current numeric value. <!U><#VL>
69 <C><#VL>Template <#VL>Creates a entry field with character sensitive <#VL>
70 <C><#VL> <#VL>positions. Used for pre-formatted fields like dates <#VL>
71 <C><#VL></U> <#VL>and phone numbers. <!U><#VL>
72 <C><#VL>Viewer <#VL>Creates an information viewer. You are currently <#VL>
73 <C><#VL> <#VL>using the viewer by the way. <#VL>
74 <C><#LL><#HL(13)><#BT><#HL(51)><#LR>
75
76 Each help subsection outlines certain features of each widget. They are
77 broken up into the following sections:
78
79 <B=*>Purpose
80 <B=*>Construction Options
81 <B=*>Available Methods
82 <B=*>Key bindings
83 <B=*>Tips & Tricks
84 <B=*>Physical Restrictions
85 <B=*>Example Use Of The Widget
86
87 The documentation supplied with the demo is more than enough information
88 to get any user off the ground and flying with the Cdk Perl5 extension.
89
90 Have fun.
91
92 Just in case, there is a subdirectory named examples which provides
93 individual examples of each Cdk widget.
94
95 ttfn,
96 Mike
97
98 <C><#HL(70)>
99 <C>Document Created: June, 1995
100 <C>Document Revised: November, 1995
101 <C>Document Revised: January, 1996
102 <C>Document Revised: June, 1996
103 <C>Document Revised: April, 1997
+0
-99
fulldemo/help/graph.help less more
0 </R>Purpose<!R>
1 The graph widget allows the programmer to create X/Y graphs easily.
2
3 </R>Construction Options<!R>
4 A graph widget is defined using the following syntax. The variable
5 </B>$graphObject<!B> contains the reference to the graph object.
6 <C></B>$graphObject = new Cdk::Graph ( options );
7
8 The options are defined in the following table.
9
10 </U>Option Default Value Type Purpose<!U>
11 Title Required Scalar The title of the whole graph.
12 Xtitle Required Scalar The title of the X axis.
13 Ytitle Required Scalar The title of the Y axis.
14 Height Required Scalar The height of the graph.
15 Width Required Scalar The width of the graph.
16 Xpos Center Scalar This is the position of the window on the X axis.
17 Ypos Center Scalar This is the position of the window on the Y axis.
18
19 </R>Available Methods<!R>
20 </B>set<!B>
21 Sets or resets certain attributes or features of the widget. The following
22 example demonstrates how to call the set method.
23 <C></B>$graphObject->set ( options );
24
25 The options are defined in the following table.
26
27 </U>Option Default Value Type Purpose<!U>
28 Values Required List Ref This is the list of values to display.
29 GraphChars List of Characters Scalar This is a scalar variable containing characters for each plot point.
30 StartAtZero True Scalar This states whether the graph should start at zero or not.
31 Plottype Line Scalar This is the type of graph to draw; line or plot.
32
33 </B>draw<!B>
34 This method draws the object on the screen. The following example demonstrates
35 how to call the draw method.
36 <C></B>$graphObject->draw ( options );
37
38 The options are defined in the following table.
39
40 </U>Option Default Value Type Purpose<!U>
41 Box True Scalar Draws the window with a box around it.
42
43 </B>erase<!B>
44 This method removes the object from the screen. This does </B/U>NOT<!B!U>
45 destroy the object. The following example demonstrates how to call the erase
46 method.
47 <C></B>$graphObject->erase ();
48
49 </B>raise<!B>
50 The raise method raises the widget to the top of the screen. This means if there
51 were any widgets obscuring part of the view, raising the object would bring the
52 complete object into view. The following example demonstrates how to call the
53 raise method.
54 <C></B>$graphObject->raise();
55
56 </B>lower<!B>
57 The lower method lowers the object so it doesn't obscure the view of any other
58 objects. The following example demonstrates how to call the lower method.
59 <C></B>$graphObject->lower();
60
61 </B>register<!B>
62 The register method registers the object to the default screen. This does </R>NOT<!R>
63 have to be called since the objects are registered automatically. This method
64 should be called if the </B>unregister<!B> method was called. The following
65 example demonstrates how to call the register method.
66 <C></B>$graphObject->register();
67
68 </B>unregister<!B>
69 The unregister method should be called when a widget, which is part of the
70 default screen, needs to be taken away temporarily. This does not delete or free
71 the object, it just unmaps it from any future screen refreshes. The object can
72 be registered by calling the </B>register<!B> method. The following example
73 demonstrates how to call the unregister method.
74 <C></B>$graphObject->unregister();
75
76 </B>getwin<!B>
77 This method returns a pointer to the window of the object. Not much use for this
78 yet. It will be useful in the future when the drawing methods are added. The
79 following example demonstrates how to call the getwin method.
80 <C></B>$graphObject->getwin();
81
82 </R>Default Key Bindings<!R>
83 None.
84
85 </R>Tips & Tricks<!R>
86 None.
87
88 </R>Physical Restrictions<!R>
89 </U>Restriction Value<!U>
90 Maximum number of values 10000
91
92 </R>Example Use Of The Widget<!R>
93 <F=../examples/fselect>
94 <C><#HL(70)>
95 <C>Document Created: June, 1995
96 <C>Document Revised: November, 1995
97 <C>Document Revised: March, 1996
98 <C>Document Revised: March, 1996
+0
-101
fulldemo/help/histogram.help less more
0 </R>Purpose<!R>
1 The histogram widget allows the programmer to create a histogram on the screen.
2 The histogram can be aligned either horizontally or vertically.
3
4 </R>Construction Options<!R>
5 A histogram widget is defined using the following syntax. The variable
6 </B>$histogramObject<!B> contains the reference to the histogram object.
7 <C></B>$histogramObject = new Cdk::histogram ( options );
8
9 The options are defined in the following table.
10
11 </U>Option Default Value Type Purpose<!U>
12 Label Required Scalar The label which is attached to the histogram.
13 Height Required Scalar The height of the histogram.
14 Width Required Scalar The width of the histogram.
15 Orient Required Scalar The orientation of the object.
16 Lpos Left Scalar This is the position of the label in the histogram.
17 Xpos Center Scalar This is the position of the window on the X axis.
18 Ypos Center Scalar This is the position of the window on the Y axis.
19 Box True Scalar This Boolean states whether the dialog box will have a box drawn around it.
20 Shadow False Scalar This Boolean states whether the dialog box will have a shadow on the box.
21
22 </R>Available Methods<!R>
23 </B>set<!B>
24 Sets or resets certain attributes or features of the widget. The following
25 example demonstrates how to call the set method.
26 <C></B>$histogramObject->set ( options );
27
28 The options are defined in the following table.
29
30 </U>Option Default Value Type Purpose<!U>
31 Low Required Scalar The low value of the histogram.
32 High Required Scalar The high value of the histogram.
33 Value Required Scalar The current value of the histogram.
34 Filler Space Scalar The fill character of the histogram.
35 Fillattr Reverse Scalar The attribute of the fill character.
36 Statspos Top Scalar The position of the statistics.
37 Sattrib Bold Scalar The attribute of the statistics.
38 Box True Scalar Draws the window with a box around it.
39
40 </B>draw<!B>
41 This method draws the object on the screen. The following example demonstrates
42 how to call the draw method.
43 <C></B>$histogramObject->draw ( options );
44
45 The options are defined in the following table.
46
47 </U>Option Default Value Type Purpose<!U>
48 Box True Scalar Draws the window with a box around it.
49
50 </B>erase<!B>
51 This method removes the object from the screen. This does </B/U>NOT<!B!U>
52 destroy the object. The following example demonstrates how to call the erase
53 method.
54 <C></B>$histogramObject->erase ();
55
56 </R>Tips & Tricks<!R>
57 <B=*>Try putting the statistics inside the histogram by setting the Statspos value to CENTER.
58
59 </B>raise<!B>
60 The raise method raises the widget to the top of the screen. This means if there
61 were any widgets obscuring part of the view, raising the object would bring the
62 complete object into view. The following example demonstrates how to call the
63 raise method.
64 <C></B>$histogramObject->raise();
65
66 </B>lower<!B>
67 The lower method lowers the object so it doesn't obscure the view of any other
68 objects. The following example demonstrates how to call the lower method.
69 <C></B>$histogramObject->lower();
70
71 </B>register<!B>
72 The register method registers the object to the default screen. This does </R>NOT<!R>
73 have to be called since the objects are registered automatically. This method
74 should be called if the </B>unregister<!B> method was called. The following
75 example demonstrates how to call the register method.
76 <C></B>$histogramObject->register();
77
78 </B>unregister<!B>
79 The unregister method should be called when a widget, which is part of the
80 default screen, needs to be taken away temporarily. This does not delete or free
81 the object, it just unmaps it from any future screen refreshes. The object can
82 be registered by calling the </B>register<!B> method. The following example
83 demonstrates how to call the unregister method.
84 <C></B>$histogramObject->unregister();
85
86 </B>getwin<!B>
87 This method returns a pointer to the window of the object. Not much use for this
88 yet. It will be useful in the future when the drawing methods are added. The
89 following example demonstrates how to call the getwin method.
90 <C></B>$histogramObject->getwin();
91
92 </R>Physical Restrictions<!R>
93 None.
94
95 </R>Example Use Of The Widget<!R>
96 <F=../examples/histogram>
97 <C><#HL(70)>
98 <C>Document Created: June, 1995
99 <C>Document Revised: November, 1995
100 <C>Document Revised: March, 1996
+0
-271
fulldemo/help/itemlist.help less more
0 </R>Purpose<!R>
1 The Cdk Itemlist widget allows the user to select a value from a list. This
2 widget is very much like a 1 line scrolling list.
3
4 </R>Construction Options<!R>
5 A itemlist widget is defined using the following syntax. The variable
6 </B>$itemlistObject<!B> contains the reference to the itemlist object.
7 $itemlistObject = new Cdk::Itemlist ( options );
8
9 The options are defined in the following table.
10
11 </U>Option Default Value Type Purpose<!U>
12 Label Required Scalar The label of the itemlist field.
13 List Required Array Ref The list of items to choose from.
14 Default 0 Scalar The default choice.
15 Xpos Center Scalar This is the position of the window on the X axis.
16 Ypos Center Scalar This is the position of the window on the Y axis.
17 Lpos Left Scalar This is the position of the label in the window.
18 Box True Scalar This boolean states whether the dialog box will have a box drawn around it.
19 Shadow False Scalar This boolean states whether the dialog box will have a shadow on the box.
20
21 </R>Available Methods<!R>
22 </B>activate<!B>
23 Activation of an object means to make the object available for use. The
24 following example demonstrates how to activate a itemlist widget.
25 $returnValue = $itemlistObject->activate ();
26
27 The variable </B>$returnValue<!B> contains a scalar value which represents the
28 integer value of the corresponding item from the list.
29
30 </B>inject<!B>
31 This function injects a single character into the widget. The following
32 examples demonstrates how to call the inject method.
33 <C></B>$itemlistObject->inject ( options );
34
35 The options are defined in the following table.
36 </U>Option Default Value Type Purpose<!U>
37 Shadow Required Scalar The character to inject into the widget.
38
39 If you are injecting a special character into the widget, then you can
40 use a pre-defined value to represent the key.
41
42 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
43 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
44 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
45 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
46 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
47 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
48 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
49 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
50 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
51 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
52 <C><#VL>Home <#VL>KEY_HOME <#VL>
53 <C><#VL>End <#VL>KEY_END <#VL>
54 <C><#VL>Escape <#VL>KEY_ESC <#VL>
55 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
56
57 </B>set<!B>
58 Sets or resets certain attributes or features of the widget. The following
59 demonstrates how to call the set method from the itemlist field.
60 $itemlistObject->set ( options );
61
62 The options are defined in the following table.
63
64 </U>Option Default Value Type Purpose<!U>
65 List Required Arry Ref The list of items to choose from.
66 Default 0 Scalar The default choice.
67 Box True Scalar Changes the current value of the box flag.
68
69 </B>bind<!B>
70 The bind method binds keys to events. The binding is specific to the individual
71 objects. The following example demonstrates how to call the bind method.
72 $itemlistObject->bind ( options );
73
74 The options are defined in the following table.
75
76 </U>Option Default Value Type Purpose<!U>
77 Key Required Scalar This is the character to bind the event to.
78 Function Required Scalar This is the name of the callback function.
79
80 </B>preProcess<!B>
81 The </B>preProcess<!B> function sets a process to be run before the key entered
82 is processed. If this function returns a value of 0, then the key injected
83 into the widget will not be processed; otherwise the character will be
84 processed as normal. The following example demonstrates how to call the
85 preProcess method.
86 <C></B>$itemlistObject->preProcess ( options );
87
88 The options are defined in the following table.
89
90 </U>Option Default Value Type Purpose<!U>
91 Function Required Scalar This is the name of the
92 callback function.
93
94 To create a pre-process callback the following code segment demonstrates
95 how to do it properly.
96
97 <C></B>$itemlistObject->preProcess ('Function' => sub { callback (@_); });
98
99 Notice that the array </B>@_<!B> is passed into the function called
100 </B>callback<!B>. This is done because when the callback process is
101 called the key which was pressed is passed into the perl subroutine.
102 Since we nest the call-back function inside an anonymous subroutine,
103 we need to pass the array </B>@_<!B> to the call-back function. If
104 the key given to the call-back function is a non alphanumeric key
105 then a predefined value will be given to the function. The following
106 table describes the values passed into the function.
107
108 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
109 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
110 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
111 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
112 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
113 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
114 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
115 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
116 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
117 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
118 <C><#VL>Home <#VL>KEY_HOME <#VL>
119 <C><#VL>End <#VL>KEY_END <#VL>
120 <C><#VL>Escape <#VL>KEY_ESC <#VL>
121 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
122
123 If the pre-process function returns a value of 0 the key hit will
124 not be injected into the widget. This allows the programmer to
125 selectively pick which characters will or will not get injected
126 into the widget.
127
128 The </B>postProcess<!B> function sets a process to be run before the key entered
129 is processed. If this function returns a value of 0, then the key injected
130 into the widget will not be processed; otherwise the character will be
131 processed as normal. The following example demonstrates how to call the
132 postProcess method.
133 <C></B>$itemlistObject->postProcess ( options );
134
135 The options are defined in the following table.
136
137 </U>Option Default Value Type Purpose<!U>
138 Function Required Scalar This is the name of the
139 callback function.
140
141 To create a post-process callback the following code segment demonstrates
142 how to do it properly.
143
144 <C></B>$itemlistObject->postProcess ('Function' => sub { callback (@_); });
145
146 Notice that the array </B>@_<!B> is passed into the function called
147 </B>callback<!B>. This is done because when the callback process is
148 called the key which was pressed is passed into the perl subroutine.
149 Since we nest the call-back function inside an anonymous subroutine,
150 we need to pass the array </B>@_<!B> to the call-back function. If
151 the key given to the call-back function is a non alphanumeric key
152 then a predefined value will be given to the function. The following
153 table describes the values passed into the function.
154
155 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
156 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
157 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
158 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
159 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
160 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
161 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
162 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
163 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
164 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
165 <C><#VL>Home <#VL>KEY_HOME <#VL>
166 <C><#VL>End <#VL>KEY_END <#VL>
167 <C><#VL>Escape <#VL>KEY_ESC <#VL>
168 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
169 </B>draw<!B>
170 This method draws the object on the screen. The following example demonstrates
171 how to call the draw method.
172 $itemlistObject->draw ( options );
173
174 The options are defined in the following table.
175
176 </U>Option Default Value Type Purpose<!U>
177 Box True Scalar Draws the window with a box around it.
178
179 </B>erase<!B>
180 This method removes the object from the screen. This does </B/U>NOT<!B!U>
181 destroy the object. The following example demonstrates how to call the erase
182 method.
183 $itemlistObject->erase ();
184
185 </B>raise<!B>
186 The raise method raises the widget to the top of the screen. This means if there
187 were any widgets obscuring part of the view, raising the object would bring the
188 complete object into view. The following example demonstrates how to call the
189 raise method.
190 $itemlistObject->raise();
191
192 </B>lower<!B>
193 The lower method lowers the object so it doesn't obscure the view of any other
194 objects. The following example demonstrates how to call the lower method.
195 $itemlistObject->lower();
196
197 </B>register<!B>
198 The register method registers the object to the default screen. This does </R>NOT<!R>
199 have to be called since the objects are registered automatically. This method
200 should be called if the </B>unregister<!B> method was called. The following
201 example demonstrates how to call the register method.
202 $itemlistObject->register();
203
204 </B>unregister<!B>
205 The unregister method should be called when a widget, which is part of the
206 default screen, needs to be taken away temporarily. This does not delete or free
207 the object, it just unmaps it from any future screen refreshes. The object can
208 be registered by calling the </B>register<!B> method. The following example
209 demonstrates how to call the unregister method.
210 $itemlistObject->unregister();
211
212 </B>getwin<!B>
213 This method returns a pointer to the window of the object. Not much use for this
214 yet. It will be useful in the future when the drawing methods are added. The
215 following example demonstrates how to call the getwin method.
216 $itemlistObject->getwin();
217
218 </R>Default Key Bindings<!R>
219 </U>Key Action<!U>
220 Up Arrow Displays the next item in the list.
221 Right Arrow Displays the next item in the list.
222 Space Displays the next item in the list.
223 + Displays the next item in the list.
224 n Displays the next item in the list.
225 Down Arrow Displays the previous item in the list.
226 Left Arrow Displays the previous item in the list.
227 - Displays the previous item in the list.
228 p Displays the previous item in the list.
229 d Sets the list to the default choice.
230 D Sets the list to the default choice.
231 0 Sets the list to the first choice in the list.
232 $ Sets the list to the last choice in the list.
233 Return Returns the current information in the field and exits the widget.
234 Tab Returns the current information in the field and exits the widget.
235 CTRL-N Returns the current information in the field and exits the widget.
236 CTRL-R Refreshes the screen.
237
238 </R>Tips & Tricks<!R>
239 None.
240
241 </R>Physical Restrictions<!R>
242 </U>Restriction Value<!U>
243 Maximum number of items. 500
244
245 </R>Example Use Of The Widget<!R>
246
247 #!/usr/local/bin/perl
248
249 #
250 # Load in the Cdk Extension.
251 #
252 use Cdk;
253 Cdk::init();
254
255 # Create a new itemlist object.
256 @list = qw (January Feburary March April May June July August September November December);
257 $month = new Cdk::Itemlist ( 'Label' => "Pick a month: ", 'List' => \@list);
258
259 # Activate the object.
260 $choice = $month->activate();
261
262 # Exit Cdk.
263 Cdk::end();
264
265 # Print out the results.
266 print "\n\n\n\n";
267 print "You selected: <$choice>\n";
268 --------------------------------------------------------------------------------
269 Document Created: June, 1995
270 Document Revised: November, 1995
+0
-92
fulldemo/help/label.help less more
0 </R>Purpose<!R>
1 The label widget allows a programmer to create a message box. This message box
2 can be part of the screen or a temporary pop up message box.
3
4 </R>Construction Options<!R>
5 A label widget is defined using the following syntax. The variable
6 </B>$labelObject<!B> contains the reference to the label object.
7 <C></B>$labelObject = new Cdk::Label ( options );
8
9 The options are defined in the following table.
10
11 </U>Option Default Value Type Purpose<!U>
12 Mesg Required Array Ref This is the contents of the message inside the window.
13 Xpos Center Scalar This is the position of the window on the X axis.
14 Ypos Center Scalar This is the position of the window on the Y axis.
15 Box True Scalar This Boolean states whether the dialog box will have a box drawn around it.
16 Shadow False Scalar This Boolean states whether the dialog box will have a shadow on the box.
17
18 </R>Available Methods<!R>
19 </B>draw<!B>
20 This method draws the object on the screen. The following example demonstrates
21 how to call the draw method.
22 <C></B>$labelObject->draw ( options );
23
24 The options are defined in the following table.
25
26 </U>Option Default Value Type Purpose<!U>
27 Box True Scalar Draws the window with a box around it.
28
29 </B>erase<!B>
30 This method removes the object from the screen. This does </B/U>NOT<!B!U>
31 destroy the object. The following example demonstrates how to call the erase
32 method.
33 <C></B>$labelObject->erase ();
34
35 </B>wait<!B>
36 This method freezes until a key has been hit. This allows the user to put a
37 message inside the label telling the user to hit any key when ready. The
38 following example demonstrates how to call the wait method.
39 <C></B>$labelObject->wait( options );
40
41 The options are defined in the following table.
42
43 </U>Option Default Value Type Purpose<!U>
44 Key NULL Scalar Tells the object which key to hit to exit the object.
45
46 </B>raise<!B>
47 The raise method raises the widget to the top of the screen. This means if there
48 were any widgets obscuring part of the view, raising the object would bring the
49 complete object into view. The following example demonstrates how to call the
50 raise method.
51 <C></B>$labelObject->raise();
52
53 </B>lower<!B>
54 The lower method lowers the object so it doesn't obscure the view of any other
55 objects. The following example demonstrates how to call the lower method.
56 <C></B>$labelObject->lower();
57
58 </B>register<!B>
59 The register method registers the object to the default screen. This does </R>NOT<!R>
60 have to be called since the objects are registered automatically. This method
61 should be called if the </B>unregister<!B> method was called. The following
62 example demonstrates how to call the register method.
63 <C></B>$labelObject->register();
64
65 </B>unregister<!B>
66 The unregister method should be called when a widget, which is part of the
67 default screen, needs to be taken away temporarily. This does not delete or free
68 the object, it just unmaps it from any future screen refreshes. The object can
69 be registered by calling the </B>register<!B> method. The following example
70 demonstrates how to call the unregister method.
71 <C></B>$labelObject->unregister();
72
73 </B>getwin<!B>
74 This method returns a pointer to the window of the object. Not much use for this
75 yet. It will be useful in the future when the drawing methods are added. The
76 following example demonstrates how to call the getwin method.
77 <C></B>$labelObject->getwin();
78
79 </R>Tips & Tricks<!R>
80 <B=*>A title can be added to the label widget by using the formatting commands available with Cdk.
81
82 </R>Physical Restrictions<!R>
83 </U>Restriction Value<!U>
84 Maximum Rows 300
85
86 </R>Example Use Of The Widget<!R>
87 <F=../examples/label>
88 <C><#HL(70)>
89 <C>Document Created: June, 1995
90 <C>Document Revised: November, 1995
91 <C>Document Revised: March, 1996
+0
-92
fulldemo/help/marquee.help less more
0 </R>Purpose<!R>
1 The marquee widget creates a scrolling marquee on the screen. This helps to
2 emphasize a point or draw attention to something.
3
4 </R>Construction Options<!R>
5 A marquee widget is defined using the following syntax. The variable
6 </B>$marqueeObject<!B> contains the reference to the marquee object.
7 <C></B>$marqueeObject = new Cdk::Marquee ( options );
8
9 The options are defined in the following table.
10
11 </U>Option Default Value Type Purpose<!U>
12 Width Required Scalar This is the actual width of the marquee window.
13 Xpos Center Scalar This is the position of the window on the X axis.
14 Ypos Center Scalar This is the position of the window on the Y axis.
15 Shadow False Scalar This Boolean states whether the dialog box will have a shadow on the box.
16
17 </R>Available Methods<!R>
18 </B>activate<!B>
19 Activation of an object means to make the object available for use. The
20 following example demonstrates how to activate a marquee widget.
21 <C></B>$marqueeObject->activate ( options );
22
23 The options are defined in the following table.
24
25 </U>Option Default Value Type Purpose<!U>
26 Mesg Required Scalar This is the message to display in the marquee.
27 Delay Required Scalar This is a value telling the marquee how long to wait before moving the message.
28 Repeat Required Scalar This states how many times the message will scroll across the marquee.
29 Box True Scalar This Boolean states whether the dialog box will have a box drawn around it.
30
31 </B>draw<!B>
32 This method draws the object on the screen. The following example demonstrates
33 how to call the draw method.
34 <C></B>$marqueeObject->draw ( options );
35
36 The options are defined in the following table.
37
38 </U>Option Default Value Type Purpose<!U>
39 Box True Scalar Draws the window with a box around it.
40
41 </B>erase<!B>
42 This method removes the object from the screen. This does </B/U>NOT<!B!U>
43 destroy the object. The following example demonstrates how to call the erase
44 method.
45 <C></B>$marqueeObject->erase ();
46
47 </B>raise<!B>
48 The raise method raises the widget to the top of the screen. This means if there
49 were any widgets obscuring part of the view, raising the object would bring the
50 complete object into view. The following example demonstrates how to call the
51 raise method.
52 <C></B>$marqueeObject->raise();
53
54 </B>lower<!B>
55 The lower method lowers the object so it doesn't obscure the view of any other
56 objects. The following example demonstrates how to call the lower method.
57 <C></B>$marqueeObject->lower();
58
59 </B>register<!B>
60 The register method registers the object to the default screen. This does </R>NOT<!R>
61 have to be called since the objects are registered automatically. This method
62 should be called if the </B>unregister<!B> method was called. The following
63 example demonstrates how to call the register method.
64 <C></B>$marqueeObject->register();
65
66 </B>unregister<!B>
67 The unregister method should be called when a widget, which is part of the
68 default screen, needs to be taken away temporarily. This does not delete or free
69 the object, it just unmaps it from any future screen refreshes. The object can
70 be registered by calling the </B>register<!B> method. The following example
71 demonstrates how to call the unregister method.
72 <C></B>$marqueeObject->unregister();
73
74 </B>getwin<!B>
75 This method returns a pointer to the window of the object. Not much use for this
76 yet. It will be useful in the future when the drawing methods are added. The
77 following example demonstrates how to call the getwin method.
78 <C></B>$marqueeObject->getwin();
79
80 </R>Tips & Tricks<!R>
81 None.
82
83 </R>Physical Restrictions<!R>
84 None.
85
86 </R>Example Use Of The Widget<!R>
87 <F=../examples/marquee>
88 <C><#HL(70)>
89 <C>Document Created: June, 1995
90 <C>Document Revised: November, 1995
91 <C>Document Revised: March, 1996
+0
-263
fulldemo/help/matrix.help less more
0 </R>Purpose<!R>
1 The matrix widget allows a programmer to create and use a complex matrix. The
2 matrix allows the user to enter in information in each cell and have all of the
3 information returned.
4
5 </R>Construction Options<!R>
6 A matrix widget is defined using the following syntax. The variable
7 </B>$matrixObject<!B> contains the reference to the matrix object.
8 <C></B>$matrixObject = new Cdk::Matrix ( options );
9
10 The options are defined in the following table.
11
12 </U>Option Default Value Type Purpose<!U>
13 Rowtitles Required Array Ref The row titles.
14 Coltitles Required Array Ref The column titles.
15 Colwidths Required Array Ref The column widths.
16 Coltypes Required Array Ref The display types of the columns. (see display help for more information)
17 Vrows Required Scalar The number of rows seen on the screen.
18 Vcols Required Scalar The number of columns seen on the screen.
19 Rowspace 1 Scalar The amount of space between the rows.
20 Colspace 1 Scalar The amount of space between the columns.
21 Filler . Scalar The default cell fill character.
22 Fillattr Normal Scalar The attribute of the default fill character.
23 Dominant None Scalar The dominant row. This applies to when colors are applied to rows and columns. If there is a conflict, one takes precedence over the other.
24 Xpos Center Scalar This is the position of the window on the X axis.
25 Ypos Center Scalar This is the position of the window on the Y axis.
26 Boxcell True Scalar This states that the individual cells are to be boxed.
27 Boxmatrix False Scalar This states that the whole matrix is to be boxed.
28 Shadow False Scalar This Boolean states whether the dialog box will have a shadow on the box.
29
30 </R>Available Methods<!R>
31 </B>activate<!B>
32 Activation of an object means to make the object available for use. The
33 following example demonstrates how to activate a matrix widget.
34 <C></B>$listReference = $matrixObject->activate ();
35
36 The variable </B>$listReference<!B> contains a reference to a list of lists
37 which contains the information within the matrix.
38
39 </B>inject<!B>
40 This function injects a single character into the widget. The following
41 examples demonstrates how to call the inject method.
42 <C></B>$matrixObject->inject ( options );
43
44 The options are defined in the following table.
45 </U>Option Default Value Type Purpose<!U>
46 Shadow Required Scalar The character to inject into the widget.
47
48 If you are injecting a special character into the widget, then you can
49 use a pre-defined value to represent the key.
50
51 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
52 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
53 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
54 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
55 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
56 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
57 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
58 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
59 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
60 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
61 <C><#VL>Home <#VL>KEY_HOME <#VL>
62 <C><#VL>End <#VL>KEY_END <#VL>
63 <C><#VL>Escape <#VL>KEY_ESC <#VL>
64 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
65
66 </B>set<!B>
67 Sets or resets certain attributes or features of the widget. The following
68 example demonstrates how to call the set method.
69 <C></B>$matrixObject->set ( options );
70
71 The options are defined in the following table.
72
73 </U>Option Default Value Type Purpose<!U>
74 Values Required Array Ref This is a reference to an array of new values to be stored in the matrix.
75
76 </B>bind<!B>
77 The bind method binds keys to events. The binding is specific to the individual
78 objects. The following example demonstrates how to call the bind method.
79 <C></B>$matrixObject->bind ( options );
80
81 The options are defined in the following table.
82
83 </U>Option Default Value Type Purpose<!U>
84 Key Required Scalar This is the character to bind the event to.
85 Function Required Scalar This is the name of the callback function.
86
87 </B>preProcess<!B>
88 The </B>preProcess<!B> function sets a process to be run before the key entered
89 is processed. If this function returns a value of 0, then the key injected
90 into the widget will not be processed; otherwise the character will be
91 processed as normal. The following example demonstrates how to call the
92 preProcess method.
93 <C></B>$matrixObject->preProcess ( options );
94
95 The options are defined in the following table.
96
97 </U>Option Default Value Type Purpose<!U>
98 Function Required Scalar This is the name of the
99 callback function.
100
101 To create a pre-process callback the following code segment demonstrates
102 how to do it properly.
103
104 <C></B>$matrixObject->preProcess ('Function' => sub { callback (@_); });
105
106 Notice that the array </B>@_<!B> is passed into the function called
107 </B>callback<!B>. This is done because when the callback process is
108 called the key which was pressed is passed into the perl subroutine.
109 Since we nest the call-back function inside an anonymous subroutine,
110 we need to pass the array </B>@_<!B> to the call-back function. If
111 the key given to the call-back function is a non alphanumeric key
112 then a predefined value will be given to the function. The following
113 table describes the values passed into the function.
114
115 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
116 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
117 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
118 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
119 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
120 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
121 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
122 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
123 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
124 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
125 <C><#VL>Home <#VL>KEY_HOME <#VL>
126 <C><#VL>End <#VL>KEY_END <#VL>
127 <C><#VL>Escape <#VL>KEY_ESC <#VL>
128 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
129
130 If the pre-process function returns a value of 0 the key hit will
131 not be injected into the widget. This allows the programmer to
132 selectively pick which characters will or will not get injected
133 into the widget.
134
135 The </B>postProcess<!B> function sets a process to be run before the key entered
136 is processed. If this function returns a value of 0, then the key injected
137 into the widget will not be processed; otherwise the character will be
138 processed as normal. The following example demonstrates how to call the
139 postProcess method.
140 <C></B>$matrixObject->postProcess ( options );
141
142 The options are defined in the following table.
143
144 </U>Option Default Value Type Purpose<!U>
145 Function Required Scalar This is the name of the
146 callback function.
147
148 To create a post-process callback the following code segment demonstrates
149 how to do it properly.
150
151 <C></B>$matrixObject->postProcess ('Function' => sub { callback (@_); });
152
153 Notice that the array </B>@_<!B> is passed into the function called
154 </B>callback<!B>. This is done because when the callback process is
155 called the key which was pressed is passed into the perl subroutine.
156 Since we nest the call-back function inside an anonymous subroutine,
157 we need to pass the array </B>@_<!B> to the call-back function. If
158 the key given to the call-back function is a non alphanumeric key
159 then a predefined value will be given to the function. The following
160 table describes the values passed into the function.
161
162 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
163 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
164 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
165 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
166 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
167 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
168 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
169 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
170 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
171 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
172 <C><#VL>Home <#VL>KEY_HOME <#VL>
173 <C><#VL>End <#VL>KEY_END <#VL>
174 <C><#VL>Escape <#VL>KEY_ESC <#VL>
175 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
176 </B>draw<!B>
177 This method draws the object on the screen. The following example demonstrates
178 how to call the draw method.
179 <C></B>$matrixObject->draw ( options );
180
181 The options are defined in the following table.
182
183 </U>Option Default Value Type Purpose<!U>
184 Box True Scalar Draws the window with a box around it.
185
186 </B>erase<!B>
187 This method removes the object from the screen. This does </B/U>NOT<!B!U>
188 destroy the object. The following example demonstrates how to call the erase
189 method.
190 <C></B>$matrixObject->erase ();
191
192 </B>raise<!B>
193 The raise method raises the widget to the top of the screen. This means if there
194 were any widgets obscuring part of the view, raising the object would bring the
195 complete object into view. The following example demonstrates how to call the
196 raise method.
197 <C></B>$matrixObject->raise();
198
199 </B>lower<!B>
200 The lower method lowers the object so it doesn't obscure the view of any other
201 objects. The following example demonstrates how to call the lower method.
202 <C></B>$matrixObject->lower();
203
204 </B>register<!B>
205 The register method registers the object to the default screen. This does </R>NOT<!R>
206 have to be called since the objects are registered automatically. This method
207 should be called if the </B>unregister<!B> method was called. The following
208 example demonstrates how to call the register method.
209 <C></B>$matrixObject->register();
210
211 </B>unregister<!B>
212 The unregister method should be called when a widget, which is part of the
213 default screen, needs to be taken away temporarily. This does not delete or free
214 the object, it just unmaps it from any future screen refreshes. The object can
215 be registered by calling the </B>register<!B> method. The following example
216 demonstrates how to call the unregister method.
217 <C></B>$matrixObject->unregister();
218
219 </B>getwin<!B>
220 This method returns a pointer to the window of the object. Not much use for this
221 yet. It will be useful in the future when the drawing methods are added. The
222 following example demonstrates how to call the getwin method.
223 <C></B>$matrixObject->getwin();
224
225 </R>Default Key Bindings<!R>
226 </U>Key Action<!U>
227 Backspace Deletes the last character in the current cell.
228 Delete Deletes the last character in the current cell.
229 Right Arrow Moves the to the next cell on the right.
230 Return Moves the to the next cell on the right.
231 Left Arrow Moves the to the next cell on the left.
232 Up Arrow Moves the to the next cell one row up.
233 Down Arrow Moves the to the next cell one row down.
234 Next Page Moves to the next screen of cells.
235 CTRL-F Moves to the next screen of cells.
236 Prev Page Moves to the previous screen of cells.
237 CTRL-B Moves to the previous screen of cells.
238 CTRL-G Jumps to a specific cell.
239 CTRL-P Pastes the contents of the paste buffer in the current cell.
240 CTRL-T Copies the contents of the current cell in the paste buffer.
241 CTRL-E Erases the complete cell.
242 CTRL-K Cuts the contents of the current cell and stores it in the paste buffer.
243 CTRL-R Refreshes the screen.
244 Tab Moves the to the next cell on the right.
245 Escape Exits the
246
247 </R>Tips & Tricks<!R>
248 <B=*>You can have more than one column of row titles by setting certain
249 columns to ViewOnly. This makes it appear like there are actually 2
250 matrices in one.
251
252 </R>Physical Restrictions<!R>
253 </U>Restriction Value<!U>
254 Maximum Number of Rows 1000
255 Maximum Number of Columns 1000
256
257 </R>Example Use Of The Widget<!R>
258 <F=../examples/matrix>
259 <C><#HL(70)>
260 <C>Document Created: June, 1995
261 <C>Document Revised: November, 1995
262 <C>Document Revised: March, 1996
+0
-258
fulldemo/help/mentry.help less more
0 </R>Purpose<!R>
1 The mentry widget is a multiple line entry field. This allows the programmer
2 to put widgets in the scripts which have long or lengthy fields. This is
3 very appropriate for a description field.
4
5 </R>Construction Options<!R>
6 A mentry widget is defined using the following syntax. The variable
7 </B>$mentryObject<!B> contains a reference to the mentry object.
8 <C></B>$mentryObject = new Cdk::Mentry ( options );
9
10 The options are defined in the following table.
11
12 </U>Option Default Value Type Purpose<!U>
13 Label Required Scalar This is the label to the widget.
14 Width Required Scalar This is the field width.
15 Prows Required Scalar This specifies the number of physical rows to the widget.
16 Lrows Required Scalar This specifies the number of logical rows to the widget.
17 Min 0 Scalar The minimum number of characters that need to be entered.
18 Dtype Mixed Scalar This is the display type of the entry field. (see display help for more information)
19 Filler . Scalar This is the default character in the field.
20 Fillattr Normal Scalar This sets the attributes of the filler character.
21 Lpos Left Scalar This is the position of the label.
22 Xpos Center Scalar This is the position of the window on the X axis.
23 Ypos Center Scalar This is the position of the window on the Y axis.
24 Box True Scalar This Boolean states whether the dialog box will have a box drawn around it.
25 Shadow False Scalar This Boolean states whether the dialog box will have a shadow on the box.
26
27 </R>Available Methods<!R>
28 </B>activate<!B>
29 Activation of an object means to make the object available for use. The
30 following example demonstrates how to activate a mentry widget.
31 <C></B>$returnValue = $mentryObject->activate ();
32
33 The variable </B>$returnValue<!B> will contain the value typed into the entry
34 field.
35
36 </B>inject<!B>
37 This function injects a single character into the widget. The following
38 examples demonstrates how to call the inject method.
39 <C></B>$mentryObject->inject ( options );
40
41 The options are defined in the following table.
42 </U>Option Default Value Type Purpose<!U>
43 Shadow Required Scalar The character to inject into the widget.
44
45 If you are injecting a special character into the widget, then you can
46 use a pre-defined value to represent the key.
47
48 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
49 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
50 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
51 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
52 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
53 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
54 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
55 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
56 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
57 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
58 <C><#VL>Home <#VL>KEY_HOME <#VL>
59 <C><#VL>End <#VL>KEY_END <#VL>
60 <C><#VL>Escape <#VL>KEY_ESC <#VL>
61 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
62
63 </B>set<!B>
64 Sets or resets certain attributes or features of the widget. The following
65 example demonstrates how to call the set method.
66 <C></B>$mentryObject->set ( options );
67
68 The options are defined in the following table.
69
70 </U>Option Default Value Type Purpose<!U>
71 Value Required Scalar Sets the value in the entry field.
72 Min Same as set value Scalar Sets the minimum number of characters which need to be entered.
73 Box True Scalar Changes the Boolean value of the box flag.
74
75 </B>bind<!B>
76 The bind method binds keys to events. The binding is specific to the individual
77 objects. The following example demonstrates how to call the bind method.
78 <C></B>$mentryObject->bind ( options );
79
80 The options are defined in the following table.
81
82 </U>Option Default Value Type Purpose<!U>
83 Key Required Scalar This is the character to bind the event to.
84 Function Required Scalar This is the name of the callback function.
85
86 </B>preProcess<!B>
87 The </B>preProcess<!B> function sets a process to be run before the key entered
88 is processed. If this function returns a value of 0, then the key injected
89 into the widget will not be processed; otherwise the character will be
90 processed as normal. The following example demonstrates how to call the
91 preProcess method.
92 <C></B>$mentryObject->preProcess ( options );
93
94 The options are defined in the following table.
95
96 </U>Option Default Value Type Purpose<!U>
97 Function Required Scalar This is the name of the
98 callback function.
99
100 To create a pre-process callback the following code segment demonstrates
101 how to do it properly.
102
103 <C></B>$mentryObject->preProcess ('Function' => sub { callback (@_); });
104
105 Notice that the array </B>@_<!B> is passed into the function called
106 </B>callback<!B>. This is done because when the callback process is
107 called the key which was pressed is passed into the perl subroutine.
108 Since we nest the call-back function inside an anonymous subroutine,
109 we need to pass the array </B>@_<!B> to the call-back function. If
110 the key given to the call-back function is a non alphanumeric key
111 then a predefined value will be given to the function. The following
112 table describes the values passed into the function.
113
114 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
115 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
116 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
117 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
118 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
119 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
120 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
121 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
122 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
123 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
124 <C><#VL>Home <#VL>KEY_HOME <#VL>
125 <C><#VL>End <#VL>KEY_END <#VL>
126 <C><#VL>Escape <#VL>KEY_ESC <#VL>
127 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
128
129 If the pre-process function returns a value of 0 the key hit will
130 not be injected into the widget. This allows the programmer to
131 selectively pick which characters will or will not get injected
132 into the widget.
133
134 The </B>postProcess<!B> function sets a process to be run before the key entered
135 is processed. If this function returns a value of 0, then the key injected
136 into the widget will not be processed; otherwise the character will be
137 processed as normal. The following example demonstrates how to call the
138 postProcess method.
139 <C></B>$mentryObject->postProcess ( options );
140
141 The options are defined in the following table.
142
143 </U>Option Default Value Type Purpose<!U>
144 Function Required Scalar This is the name of the
145 callback function.
146
147 To create a post-process callback the following code segment demonstrates
148 how to do it properly.
149
150 <C></B>$mentryObject->postProcess ('Function' => sub { callback (@_); });
151
152 Notice that the array </B>@_<!B> is passed into the function called
153 </B>callback<!B>. This is done because when the callback process is
154 called the key which was pressed is passed into the perl subroutine.
155 Since we nest the call-back function inside an anonymous subroutine,
156 we need to pass the array </B>@_<!B> to the call-back function. If
157 the key given to the call-back function is a non alphanumeric key
158 then a predefined value will be given to the function. The following
159 table describes the values passed into the function.
160
161 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
162 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
163 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
164 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
165 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
166 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
167 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
168 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
169 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
170 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
171 <C><#VL>Home <#VL>KEY_HOME <#VL>
172 <C><#VL>End <#VL>KEY_END <#VL>
173 <C><#VL>Escape <#VL>KEY_ESC <#VL>
174 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
175 </B>draw<!B>
176 This method draws the object on the screen. The following example demonstrates
177 how to call the draw method.
178 <C></B>$mentryObject->draw ( options );
179
180 The options are defined in the following table.
181
182 </U>Option Default Value Type Purpose<!U>
183 Box True Scalar Draws the window with a box around it.
184
185 </B>erase<!B>
186 This method removes the object from the screen. This does </B/U>NOT<!B!U>
187 destroy the object. The following example demonstrates how to call the erase
188 method.
189 <C></B>$mentryObject->erase ();
190
191 </B>clean<!B>
192 This method cleans the information from the entry field. The following example
193 demonstrates how to call the clean method.
194 <C></B>$mentryObject->clean();
195
196 </B>raise<!B>
197 The raise method raises the widget to the top of the screen. This means if there
198 were any widgets obscuring part of the view, raising the object would bring the
199 complete object into view. The following example demonstrates how to call the
200 raise method.
201 <C></B>$mentryObject->raise();
202
203 </B>lower<!B>
204 The lower method lowers the object so it doesn't obscure the view of any other
205 objects. The following example demonstrates how to call the lower method.
206 <C></B>$mentryObject->lower();
207
208 </B>register<!B>
209 The register method registers the object to the default screen. This does </R>NOT<!R>
210 have to be called since the objects are registered automatically. This method
211 should be called if the </B>unregister<!B> method was called. The following
212 example demonstrates how to call the register method.
213 <C></B>$mentryObject->register();
214
215 </B>unregister<!B>
216 The unregister method should be called when a widget, which is part of the
217 default screen, needs to be taken away temporarily. This does not delete or free
218 the object, it just unmaps it from any future screen refreshes. The object can
219 be registered by calling the </B>register<!B> method. The following example
220 demonstrates how to call the unregister method.
221 <C></B>$mentryObject->unregister();
222
223 </B>getwin<!B>
224 This method returns a pointer to the window of the object. Not much use for this
225 yet. It will be useful in the future when the drawing methods are added. The
226 following example demonstrates how to call the getwin method.
227 <C></B>$mentryObject->getwin();
228
229 </R>Default Key Bindings<!R>
230 </U>Key Action<!U>
231 Left Arrow Moves the cursor left one character.
232 Right Arrow Moves the cursor right one character.
233 Down Arrow Moves the cursor up down row.
234 Up Arrow Moves the cursor up one row.
235 Backspace Deletes the character to the left of the cursor.
236 Delete Deletes the character to the left of the cursor.
237 Return Exits the widget and returns the contents of the field.
238 Tab Exits the widget and returns the contents of the field.
239 Escape Exits the widget and returns undef.
240 CTRL-R Refreshes the screen.
241
242 </R>Tips & Tricks<!R>
243 <B=*>The label can be put on the left, right, top or bottom of the field,
244 allowing for a more dynamic placement of the label itself.
245 <B=*>Setting the Dtype variable to a hidden type creates an entry field
246 suitable for a password.
247
248 </R>Physical Restrictions<!R>
249 </U>Restriction Value<!U>
250 Maximum number of rows 1000
251
252 </R>Example Use Of The Widget<!R>
253 <F=../examples/mentry>
254 <#HL(70)>
255 <C>Document Created: June, 1995
256 <C>Document Revised: November, 1995
257 <C>Document Revised: March, 1996
+0
-201
fulldemo/help/menu.help less more
0 </R>Purpose<!R>
1 The menu widget allows the programmer to create a pull-down menu widget.
2 Complete with sub-menu items.
3
4 </R>Construction Options<!R>
5 A menu widget is defined using the following syntax. The variable
6 </B>$menuObject<!B> contains a reference to the menu object.
7 <C></B>$menuObject = new Cdk::Menu ( options );
8
9 The options are defined in the following table.
10
11 </U>Option Default Value Type Purpose<!U>
12 Menulist Required Array Ref This is the menu title list.
13 Menuloc Required Array Ref This is the menu title location list.
14 Tattrib Reverse Scalar This is the attribute of the currently highlighted menu title.
15 SubTattrib Reverse Scalar This is the attribute of the currently highlighted menu item.
16
17 </R>Available Methods<!R>
18 </B>activate<!B>
19 Activation of an object means to make the object available for use. The
20 following example demonstrates how to activate a menu widget.
21 <C></B>$returnValue = $menuObject->activate ();
22
23 The variable </B>$returnValue<!B> is an integer value which represents the
24 selected item. The calculation of this value is determined as follows:
25 (100 * Current Title ) + Current Subtitle
26
27 To extract the correct menu item from this value use the following formula:
28 $menuList = int ( $returnValue / 100 );
29 $menuItem = ($returnValue % 100 );
30
31 You can then dereference the string value from the array using the above two
32 calculations.
33
34 </B>inject<!B>
35 This function injects a single character into the widget. The following
36 examples demonstrates how to call the inject method.
37 <C></B>$menuObject->inject ( options );
38
39 The options are defined in the following table.
40 </U>Option Default Value Type Purpose<!U>
41 Shadow Required Scalar The character to inject into the widget.
42
43 If you are injecting a special character into the widget, then you can
44 use a pre-defined value to represent the key.
45
46 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
47 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
48 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
49 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
50 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
51 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
52 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
53 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
54 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
55 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
56 <C><#VL>Home <#VL>KEY_HOME <#VL>
57 <C><#VL>End <#VL>KEY_END <#VL>
58 <C><#VL>Escape <#VL>KEY_ESC <#VL>
59 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
60
61 </B>bind<!B>
62 The bind method binds keys to events. The binding is specific to the individual
63 objects. The following example demonstrates how to call the bind method.
64 <C></B>$menuObject->bind ( options );
65
66 The options are defined in the following table.
67
68 </U>Option Default Value Type Purpose<!U>
69 Key Required Scalar This is the character to bind the
70 event to.
71 Function Required Scalar This is the name of the callback
72 function.
73
74 </B>preProcess<!B>
75 The </B>preProcess<!B> function sets a process to be run before the key entered
76 is processed. If this function returns a value of 0, then the key injected
77 into the widget will not be processed; otherwise the character will be
78 processed as normal. The following example demonstrates how to call the
79 preProcess method.
80 <C></B>$menuObject->preProcess ( options );
81
82 The options are defined in the following table.
83
84 </U>Option Default Value Type Purpose<!U>
85 Function Required Scalar This is the name of the
86 callback function.
87
88 To create a pre-process callback the following code segment demonstrates
89 how to do it properly.
90
91 <C></B>$menuObject->preProcess ('Function' => sub { callback (@_); });
92
93 Notice that the array </B>@_<!B> is passed into the function called
94 </B>callback<!B>. This is done because when the callback process is
95 called the key which was pressed is passed into the perl subroutine.
96 Since we nest the call-back function inside an anonymous subroutine,
97 we need to pass the array </B>@_<!B> to the call-back function. If
98 the key given to the call-back function is a non alphanumeric key
99 then a predefined value will be given to the function. The following
100 table describes the values passed into the function.
101
102 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
103 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
104 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
105 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
106 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
107 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
108 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
109 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
110 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
111 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
112 <C><#VL>Home <#VL>KEY_HOME <#VL>
113 <C><#VL>End <#VL>KEY_END <#VL>
114 <C><#VL>Escape <#VL>KEY_ESC <#VL>
115 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
116
117 If the pre-process function returns a value of 0 the key hit will
118 not be injected into the widget. This allows the programmer to
119 selectively pick which characters will or will not get injected
120 into the widget.
121
122 The </B>postProcess<!B> function sets a process to be run before the key entered
123 is processed. If this function returns a value of 0, then the key injected
124 into the widget will not be processed; otherwise the character will be
125 processed as normal. The following example demonstrates how to call the
126 postProcess method.
127 <C></B>$menuObject->postProcess ( options );
128
129 The options are defined in the following table.
130
131 </U>Option Default Value Type Purpose<!U>
132 Function Required Scalar This is the name of the
133 callback function.
134
135 To create a post-process callback the following code segment demonstrates
136 how to do it properly.
137
138 <C></B>$menuObject->postProcess ('Function' => sub { callback (@_); });
139
140 Notice that the array </B>@_<!B> is passed into the function called
141 </B>callback<!B>. This is done because when the callback process is
142 called the key which was pressed is passed into the perl subroutine.
143 Since we nest the call-back function inside an anonymous subroutine,
144 we need to pass the array </B>@_<!B> to the call-back function. If
145 the key given to the call-back function is a non alphanumeric key
146 then a predefined value will be given to the function. The following
147 table describes the values passed into the function.
148
149 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
150 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
151 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
152 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
153 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
154 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
155 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
156 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
157 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
158 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
159 <C><#VL>Home <#VL>KEY_HOME <#VL>
160 <C><#VL>End <#VL>KEY_END <#VL>
161 <C><#VL>Escape <#VL>KEY_ESC <#VL>
162 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
163 </B>draw<!B>
164 This method draws the object on the screen. The following example demonstrates
165 how to call the draw method.
166 <C></B>$menuObject->draw ();
167
168 </B>erase<!B>
169 This method removes the object from the screen. This does </B/U>NOT<!B!U>
170 destroy the object. The following example demonstrates how to call the erase
171 method.
172 <C></B>$menuObject->erase ();
173
174 </R>Default Key Bindings<!R>
175 </U>Key Action<!U>
176 Left Arrow Moves to the menu list on the left.
177 Right Arrow Moves to the menu list on the right.
178 Up Arrow Moves the cursor up one menu item.
179 Down Arrow Moves the cursor up one menu item.
180 Space Moves the cursor up down menu item.
181 Return Selects the current menu item.
182 Tab Moves to the menu list on the right.
183 Escape Exits the widget and returns undef.
184 CTRL-R Refreshes the screen.
185
186 </R>Tips & Tricks<!R>
187 None.
188
189 </R>Physical Restrictions<!R>
190 </U>Restriction Value<!U>
191 Max number of menu items. 30
192 Max number of sub-menu items. 98
193
194 </R>Example Use Of The Widget<!R>
195 <F=../examples/menu>
196 <C><#HL(70)>
197 <C>Document Created: June, 1995
198 <C>Document Revised: November, 1995
199 <C>Document Revised: March, 1996
200 <C>Document Revised: June, 1996
+0
-49
fulldemo/help/postprocess.help less more
0 The </B>postProcess<!B> function sets a process to be run before the key entered
1 is processed. If this function returns a value of 0, then the key injected
2 into the widget will not be processed; otherwise the character will be
3 processed as normal. The following example demonstrates how to call the
4 postProcess method.
5 <C></B>$alphalistObject->postProcess ( options );
6
7 The options are defined in the following table.
8
9 </U>Option Default Value Type Purpose<!U>
10 Function Required Scalar This is the name of the
11 callback function.
12
13 To create a post-process callback the following code segment demonstrates
14 how to do it properly.
15
16 <C></B>$widget->postProcess ('Function' => sub { callback (@_); });
17
18 Notice that the array </B>@_<!B> is passed into the function called
19 </B>callback<!B>. This is done because when the callback process is
20 called the key which was pressed is passed into the perl subroutine.
21 Since we nest the call-back function inside an anonymous subroutine,
22 we need to pass the array </B>@_<!B> to the call-back function. If
23 the key given to the call-back function is a non alphanumeric key
24 then a predefined value will be given to the function. The following
25 table describes the values passed into the function.
26
27 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
28 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
29 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
30 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
31 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
32 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
33 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
34 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
35 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
36 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
37 <C><#VL>Home <#VL>KEY_HOME <#VL>
38 <C><#VL>End <#VL>KEY_END <#VL>
39 <C><#VL>Escape <#VL>KEY_ESC <#VL>
40 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
41
42 The following code segment demonstrates how to use the post-process
43 method.
44
45 <F=../examples/postProcess>
46
47 <C><#HL(70)>
48 <C>Document Created: July, 1996
+0
-52
fulldemo/help/preprocess.help less more
0 The </B>preProcess<!B> function sets a process to be run before the key entered
1 is processed. If this function returns a value of 0, then the key injected
2 into the widget will not be processed; otherwise the character will be
3 processed as normal. The following example demonstrates how to call the
4 preProcess method.
5 <C></B>$alphalistObject->preProcess ( options );
6
7 The options are defined in the following table.
8
9 </U>Option Default Value Type Purpose<!U>
10 Function Required Scalar This is the name of the
11 callback function.
12
13 To create a pre-process callback the following code segment demonstrates
14 how to do it properly.
15
16 <C></B>$widget->preProcess ('Function' => sub { callback (@_); });
17
18 Notice that the array </B>@_<!B> is passed into the function called
19 </B>callback<!B>. This is done because when the callback process is
20 called the key which was pressed is passed into the perl subroutine.
21 Since we nest the call-back function inside an anonymous subroutine,
22 we need to pass the array </B>@_<!B> to the call-back function. If
23 the key given to the call-back function is a non alphanumeric key
24 then a predefined value will be given to the function. The following
25 table describes the values passed into the function.
26
27 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
28 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
29 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
30 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
31 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
32 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
33 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
34 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
35 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
36 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
37 <C><#VL>Home <#VL>KEY_HOME <#VL>
38 <C><#VL>End <#VL>KEY_END <#VL>
39 <C><#VL>Escape <#VL>KEY_ESC <#VL>
40 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
41
42 If the pre-process function returns a value of 0 the key hit will
43 not be injected into the widget. This allows the programmer to
44 selectively pick which characters will or will not get injected
45 into the widget. The following code segment demonstrates this
46 principle.
47
48 <F=../examples/preProcess>
49
50 <C><#HL(70)>
51 <C>Document Created: July, 1996
+0
-257
fulldemo/help/radio.help less more
0 </R>Purpose<!R>
1 The radio widget allows the programmer to create a radio list. The radio widget
2 acts very similar to the scrolling list. In fact the radio list is a scrolling
3 list, just with the extra feature of a visual selection.
4
5 </R>Construction Options<!R>
6 A radio widget is defined using the following syntax. The variable
7 </B>$radioObject<!B> contains a reference to the radio object.
8 <C></B>$radioObject = new Cdk::Radio ( options );
9
10 The options are defined in the following table.
11
12 </U>Option Default Value Type Purpose<!U>
13 Title Required Scalar The title of the radio list.
14 List Required Array Ref The list of items in the list.
15 Height Required Scalar The height of the radio list.
16 Width Required Scalar The width of the radio list.
17 Choice X Scalar The choice character.
18 Cattr Normal Scalar The attribute of the choice character.
19 Default 0 Scalar The default item in the list.
20 Highlight Reverse Scalar The attribute of the currently highlighted item.
21 Xpos Center Scalar This is the position of the window on the X axis.
22 Ypos Center Scalar This is the position of the window on the Y axis.
23 Box True Scalar This Boolean states whether the dialog box will have a box drawn around it.
24 Shadow False Scalar This Boolean states whether the dialog box will have a shadow on the box.
25
26 </R>Available Methods<!R>
27 </B>activate<!B>
28 Activation of an object means to make the object available for use. The
29 following example demonstrates how to activate a radio widget.
30 <C></B>$returnValue = $radioObject->activate ();
31
32 The variable </B>$returnValue<!B> will contain a integer value representing
33 the number of the chosen item. The numbers start at zero and go up.
34
35 </B>inject<!B>
36 This function injects a single character into the widget. The following
37 examples demonstrates how to call the inject method.
38 <C></B>$radioObject->inject ( options );
39
40 The options are defined in the following table.
41 </U>Option Default Value Type Purpose<!U>
42 Shadow Required Scalar The character to inject into the widget.
43
44 If you are injecting a special character into the widget, then you can
45 use a pre-defined value to represent the key.
46
47 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
48 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
49 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
50 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
51 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
52 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
53 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
54 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
55 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
56 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
57 <C><#VL>Home <#VL>KEY_HOME <#VL>
58 <C><#VL>End <#VL>KEY_END <#VL>
59 <C><#VL>Escape <#VL>KEY_ESC <#VL>
60 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
61
62 </B>set<!B>
63 Sets or resets certain attributes or features of the widget. The following
64 example demonstrates how to call the set method.
65 <C></B>$radioObject->set ( options );
66
67 The options are defined in the following table.
68
69 </U>Option Default Value Type Purpose<!U>
70 Highlight Required Scalar The attribute of the currently highlighted item.
71 Choice Required Scalar The choice character.
72 Box True Scalar Changes the current value of the box flag.
73
74 </B>bind<!B>
75 The bind method binds keys to events. The binding is specific to the individual
76 objects. The following example demonstrates how to call the bind method.
77 <C></B>$radioObject->bind ( options );
78
79 The options are defined in the following table.
80
81 </U>Option Default Value Type Purpose<!U>
82 Key Required Scalar This is the character to bind the event to.
83 Function Required Scalar This is the name of the callback function.
84
85 </B>preProcess<!B>
86 The </B>preProcess<!B> function sets a process to be run before the key entered
87 is processed. If this function returns a value of 0, then the key injected
88 into the widget will not be processed; otherwise the character will be
89 processed as normal. The following example demonstrates how to call the
90 preProcess method.
91 <C></B>$radioObject->preProcess ( options );
92
93 The options are defined in the following table.
94
95 </U>Option Default Value Type Purpose<!U>
96 Function Required Scalar This is the name of the
97 callback function.
98
99 To create a pre-process callback the following code segment demonstrates
100 how to do it properly.
101
102 <C></B>$radioObject->preProcess ('Function' => sub { callback (@_); });
103
104 Notice that the array </B>@_<!B> is passed into the function called
105 </B>callback<!B>. This is done because when the callback process is
106 called the key which was pressed is passed into the perl subroutine.
107 Since we nest the call-back function inside an anonymous subroutine,
108 we need to pass the array </B>@_<!B> to the call-back function. If
109 the key given to the call-back function is a non alphanumeric key
110 then a predefined value will be given to the function. The following
111 table describes the values passed into the function.
112
113 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
114 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
115 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
116 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
117 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
118 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
119 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
120 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
121 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
122 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
123 <C><#VL>Home <#VL>KEY_HOME <#VL>
124 <C><#VL>End <#VL>KEY_END <#VL>
125 <C><#VL>Escape <#VL>KEY_ESC <#VL>
126 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
127
128 If the pre-process function returns a value of 0 the key hit will
129 not be injected into the widget. This allows the programmer to
130 selectively pick which characters will or will not get injected
131 into the widget.
132
133 The </B>postProcess<!B> function sets a process to be run before the key entered
134 is processed. If this function returns a value of 0, then the key injected
135 into the widget will not be processed; otherwise the character will be
136 processed as normal. The following example demonstrates how to call the
137 postProcess method.
138 <C></B>$radioObject->postProcess ( options );
139
140 The options are defined in the following table.
141
142 </U>Option Default Value Type Purpose<!U>
143 Function Required Scalar This is the name of the
144 callback function.
145
146 To create a post-process callback the following code segment demonstrates
147 how to do it properly.
148
149 <C></B>$radioObject->postProcess ('Function' => sub { callback (@_); });
150
151 Notice that the array </B>@_<!B> is passed into the function called
152 </B>callback<!B>. This is done because when the callback process is
153 called the key which was pressed is passed into the perl subroutine.
154 Since we nest the call-back function inside an anonymous subroutine,
155 we need to pass the array </B>@_<!B> to the call-back function. If
156 the key given to the call-back function is a non alphanumeric key
157 then a predefined value will be given to the function. The following
158 table describes the values passed into the function.
159
160 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
161 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
162 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
163 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
164 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
165 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
166 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
167 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
168 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
169 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
170 <C><#VL>Home <#VL>KEY_HOME <#VL>
171 <C><#VL>End <#VL>KEY_END <#VL>
172 <C><#VL>Escape <#VL>KEY_ESC <#VL>
173 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
174 </B>draw<!B>
175 This method draws the object on the screen. The following example demonstrates
176 how to call the draw method.
177 <C></B>$radioObject->draw ( options );
178
179 The options are defined in the following table.
180
181 </U>Option Default Value Type Purpose<!U>
182 Box True Scalar Draws the window with a box around it.
183
184 </B>erase<!B>
185 This method removes the object from the screen. This does </B/U>NOT<!B!U>
186 destroy the object. The following example demonstrates how to call the erase
187 method.
188 <C></B>$radioObject->erase ();
189
190 </B>raise<!B>
191 The raise method raises the widget to the top of the screen. This means if there
192 were any widgets obscuring part of the view, raising the object would bring the
193 complete object into view. The following example demonstrates how to call the
194 raise method.
195 <C></B>$radioObject->raise();
196
197 </B>lower<!B>
198 The lower method lowers the object so it doesn't obscure the view of any other
199 objects. The following example demonstrates how to call the lower method.
200 <C></B>$radioObject->lower();
201
202 </B>register<!B>
203 The register method registers the object to the default screen. This does </R>NOT<!R>
204 have to be called since the objects are registered automatically. This method
205 should be called if the </B>unregister<!B> method was called. The following
206 example demonstrates how to call the register method.
207 <C></B>$radioObject->register();
208
209 </B>unregister<!B>
210 The unregister method should be called when a widget, which is part of the
211 default screen, needs to be taken away temporarily. This does not delete or free
212 the object, it just unmaps it from any future screen refreshes. The object can
213 be registered by calling the </B>register<!B> method. The following example
214 demonstrates how to call the unregister method.
215 <C></B>$radioObject->unregister();
216
217 </B>getwin<!B>
218 This method returns a pointer to the window of the object. Not much use for this
219 yet. It will be useful in the future when the drawing methods are added. The
220 following example demonstrates how to call the getwin method.
221 <C></B>$radioObject->getwin();
222
223 </R>Default Key Bindings<!R>
224 </U>Key Action<!U>
225 Up Arrow Moves the cursor to one item up.
226 Down Arrow Moves the cursor to one item down.
227 Tab Moves the cursor to one item down.
228 Right Arrow Scrolls the whole list one character to the right.
229 Left Arrow Scrolls the whole list one character to the left.
230 Previous Page Moves the complete list one screen backwards.
231 CTRL-B Moves the complete list one screen backwards
232 Next Page Moves the complete list one screen forwards.
233 CTRL-F Moves the complete list one screen forwards.
234 g Moves to the top of the list.
235 1 Moves to the top of the list.
236 G Moves to the bottom of the list.
237 $ Scrolls complete list as far left as possible.
238 | Scrolls complete list as far right as possible.
239 Space Selects the current item.
240 Return Exits the widget and returns the current selection.
241 CTRL-R Refreshes the screen.
242
243 </R>Tips & Tricks<!R>
244 <B=*>Setting the default value sets that value on when the radio list is
245 activated.
246
247 </R>Physical Restrictions<!R>
248 </U>Restriction Value<!U>
249 Maximum number of items. 500
250
251 </R>Example Use Of The Widget<!R>
252 <F=../examples/radio>
253 <C><#HL(70)>
254 <C>Document Created: June, 1995
255 <C>Document Revised: November, 1995
256 <C>Document Revised: March, 1996
+0
-264
fulldemo/help/scale.help less more
0 </R>Purpose<!R>
1 The scale widget is a widget which allows a user to select an integer value. The
2 scale widget forces the user to choose a value between a predetermined high
3 and low, which eliminates the need to check if the person has typed in a valid
4 value.
5
6 </R>Construction Options<!R>
7 A scale widget is defined using the following syntax. The variable
8 </B>$scaleObject<!B> contains a reference to the scale object.
9 <C></B>$scaleObject = new Cdk::Scale ( options );
10
11 The options are defined in the following table.
12
13 </U>Option Default Value Type Purpose<!U>
14 Label Required Scalar The label to the scale widget.
15 Low Required Scalar The low value of the scale widget.
16 High Required Scalar The high value of the scale widget.
17 Width Width of High Scalar The width of the field.
18 Inc 1 Scalar The increment value.
19 Fastinc 5 Scalar The accelerated increment value.
20 Start Low Value Scalar The starting value.
21 Fattrib Normal Scalar The attribute of the field value.
22 Xpos Center Scalar This is the position of the window on the X axis.
23 Ypos Center Scalar This is the position of the window on the Y axis.
24 Box True Scalar This Boolean states whether the dialog box will have a box drawn around it.
25 Shadow False Scalar This Boolean states whether the dialog box will have a shadow on the box.
26
27 </R>Available Methods<!R>
28 </B>activate<!B>
29 Activation of an object means to make the object available for use. The
30 following example demonstrates how to activate a scale widget.
31 <C></B>$returnValue = $scaleObject->activate ();
32
33 The variable </B>$returnValue<!B> is the value of the field when the widget
34 exits.
35
36 </B>inject<!B>
37 This function injects a single character into the widget. The following
38 examples demonstrates how to call the inject method.
39 <C></B>$scaleObject->inject ( options );
40
41 The options are defined in the following table.
42 </U>Option Default Value Type Purpose<!U>
43 Shadow Required Scalar The character to inject into the widget.
44
45 If you are injecting a special character into the widget, then you can
46 use a pre-defined value to represent the key.
47
48 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
49 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
50 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
51 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
52 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
53 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
54 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
55 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
56 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
57 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
58 <C><#VL>Home <#VL>KEY_HOME <#VL>
59 <C><#VL>End <#VL>KEY_END <#VL>
60 <C><#VL>Escape <#VL>KEY_ESC <#VL>
61 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
62
63 </B>set<!B>
64 Sets or resets certain attributes or features of the widget. The following
65 example demonstrates how to call the set method.
66 <C></B>$scaleObject->set ( options );
67
68 The options are defined in the following table.
69
70 </U>Option Default Value Type Purpose<!U>
71 Low Required Scalar Sets the low value of the widget.
72 High Required Scalar Sets the high value of the widget.
73 Value Required Scalar Sets the current value of the widget.
74 Box True Scalar Changes the current value of the box flag.
75
76 </B>bind<!B>
77 The bind method binds keys to events. The binding is specific to the individual
78 objects. The following example demonstrates how to call the bind method.
79 <C></B>$scaleObject->bind ( options );
80
81 The options are defined in the following table.
82
83 </U>Option Default Value Type Purpose<!U>
84 Key Required Scalar This is the character to bind the event to.
85 Function Required Scalar This is the name of the callback function.
86
87 </B>preProcess<!B>
88 The </B>preProcess<!B> function sets a process to be run before the key entered
89 is processed. If this function returns a value of 0, then the key injected
90 into the widget will not be processed; otherwise the character will be
91 processed as normal. The following example demonstrates how to call the
92 preProcess method.
93 <C></B>$scaleObject->preProcess ( options );
94
95 The options are defined in the following table.
96
97 </U>Option Default Value Type Purpose<!U>
98 Function Required Scalar This is the name of the
99 callback function.
100
101 To create a pre-process callback the following code segment demonstrates
102 how to do it properly.
103
104 <C></B>$scaleObject->preProcess ('Function' => sub { callback (@_); });
105
106 Notice that the array </B>@_<!B> is passed into the function called
107 </B>callback<!B>. This is done because when the callback process is
108 called the key which was pressed is passed into the perl subroutine.
109 Since we nest the call-back function inside an anonymous subroutine,
110 we need to pass the array </B>@_<!B> to the call-back function. If
111 the key given to the call-back function is a non alphanumeric key
112 then a predefined value will be given to the function. The following
113 table describes the values passed into the function.
114
115 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
116 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
117 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
118 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
119 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
120 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
121 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
122 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
123 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
124 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
125 <C><#VL>Home <#VL>KEY_HOME <#VL>
126 <C><#VL>End <#VL>KEY_END <#VL>
127 <C><#VL>Escape <#VL>KEY_ESC <#VL>
128 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
129
130 If the pre-process function returns a value of 0 the key hit will
131 not be injected into the widget. This allows the programmer to
132 selectively pick which characters will or will not get injected
133 into the widget.
134
135 The </B>postProcess<!B> function sets a process to be run before the key entered
136 is processed. If this function returns a value of 0, then the key injected
137 into the widget will not be processed; otherwise the character will be
138 processed as normal. The following example demonstrates how to call the
139 postProcess method.
140 <C></B>$scaleObject->postProcess ( options );
141
142 The options are defined in the following table.
143
144 </U>Option Default Value Type Purpose<!U>
145 Function Required Scalar This is the name of the
146 callback function.
147
148 To create a post-process callback the following code segment demonstrates
149 how to do it properly.
150
151 <C></B>$scaleObject->postProcess ('Function' => sub { callback (@_); });
152
153 Notice that the array </B>@_<!B> is passed into the function called
154 </B>callback<!B>. This is done because when the callback process is
155 called the key which was pressed is passed into the perl subroutine.
156 Since we nest the call-back function inside an anonymous subroutine,
157 we need to pass the array </B>@_<!B> to the call-back function. If
158 the key given to the call-back function is a non alphanumeric key
159 then a predefined value will be given to the function. The following
160 table describes the values passed into the function.
161
162 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
163 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
164 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
165 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
166 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
167 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
168 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
169 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
170 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
171 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
172 <C><#VL>Home <#VL>KEY_HOME <#VL>
173 <C><#VL>End <#VL>KEY_END <#VL>
174 <C><#VL>Escape <#VL>KEY_ESC <#VL>
175 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
176 </B>draw<!B>
177 This method draws the object on the screen. The following example demonstrates
178 how to call the draw method.
179 <C></B>$scaleObject->draw ( options );
180
181 The options are defined in the following table.
182
183 </U>Option Default Value Type Purpose<!U>
184 Box True Scalar Draws the window with a box around it.
185
186 </B>erase<!B>
187 This method removes the object from the screen. This does </B/U>NOT<!B!U>
188 destroy the object. The following example demonstrates how to call the erase
189 method.
190 <C></B>$scaleObject->erase ();
191
192 </B>raise<!B>
193 The raise method raises the widget to the top of the screen. This means if there
194 were any widgets obscuring part of the view, raising the object would bring the
195 complete object into view. The following example demonstrates how to call the
196 raise method.
197 <C></B>$scaleObject->raise();
198
199 </B>lower<!B>
200 The lower method lowers the object so it doesn't obscure the view of any other
201 objects. The following example demonstrates how to call the lower method.
202 <C></B>$scaleObject->lower();
203
204 </B>register<!B>
205 The register method registers the object to the default screen. This does </R>NOT<!R>
206 have to be called since the objects are registered automatically. This method
207 should be called if the </B>unregister<!B> method was called. The following
208 example demonstrates how to call the register method.
209 <C></B>$scaleObject->register();
210
211 </B>unregister<!B>
212 The unregister method should be called when a widget, which is part of the
213 default screen, needs to be taken away temporarily. This does not delete or free
214 the object, it just unmaps it from any future screen refreshes. The object can
215 be registered by calling the </B>register<!B> method. The following example
216 demonstrates how to call the unregister method.
217 <C></B>$scaleObject->unregister();
218
219 </B>getwin<!B>
220 This method returns a pointer to the window of the object. Not much use for this
221 yet. It will be useful in the future when the drawing methods are added. The
222 following example demonstrates how to call the getwin method.
223 <C></B>$scaleObject->getwin();
224
225 </R>Default Key Bindings<!R>
226 </U>Key Action<!U>
227 Left Arrow Decrements the current value by the standard value.
228 Down Arrow Decrements the current value by the standard value.
229 d Decrements the current value by the standard value.
230 - Decrements the current value by the standard value.
231 Right Arrow Increments the current value by the standard value.
232 Up Arrow Increments the current value by the standard value.
233 u Increments the current value by the standard value.
234 + Increments the current value by the standard value.
235 Prev Page Decrements the current value by the accelerated value.
236 U Decrements the current value by the accelerated value.
237 CTRL-B Decrements the current value by the accelerated value.
238 Next Page Increments the current value by the accelerated value.
239 D Increments the current value by the accelerated value.
240 CTRL-F Increments the current value by the accelerated value.
241 Home Sets the field value to the low value.
242 g Sets the field value to the low value.
243 0 Sets the field value to the low value.
244 End Sets the field value to the high value.
245 G Sets the field value to the high value.
246 $ Sets the field value to the high value.
247 Return Exits the widget and returns the field value.
248 Tab Exits the widget and returns the field value.
249 Escape Exits the widget and returns undef.
250 CTRL-R Refreshes the screen.
251
252 </R>Tips & Tricks<!R>
253 None.
254
255 </R>Physical Restrictions<!R>
256 None.
257
258 </R>Example Use Of The Widget<!R>
259 <F=../examples/scale>
260 <C><#HL(70)>
261 <C>Document Created: June, 1995
262 <C>Document Revised: November, 1995
263 <C>Document Revised: March, 1996
+0
-253
fulldemo/help/scroll.help less more
0 </R>Purpose<!R>
1 The scroll widget allows the user to add a scrolling list in their script.
2
3 </R>Construction Options<!R>
4 A scroll widget is defined using the following syntax. The variable
5 </B>$scrollObject<!B> contains a reference to the scroll object.
6 <C></B>$scrollObject = new Cdk::Radio ( options );
7
8 The options are defined in the following table.
9
10 </U>Option Default Value Type Purpose<!U>
11 Title Required Scalar The title of the scroll list.
12 List Required Array Ref The list of items in the list.
13 Height Required Scalar The height of the scroll list.
14 Width Required Scalar The width of the scroll list.
15 Numbers False Scalar Adds numbers to the items in the list.
16 Highlight Reverse Scalar The attribute of the currently highlighted item.
17 Xpos Center Scalar This is the position of the window on the X axis.
18 Ypos Center Scalar This is the position of the window on the Y axis.
19 Box True Scalar This Boolean states whether the dialog box will have a box drawn around it.
20 Shadow False Scalar This Boolean states whether the dialog box will have a shadow on the box.
21
22 </R>Available Methods<!R>
23 </B>activate<!B>
24 Activation of an object means to make the object available for use. The
25 following example demonstrates how to activate a scroll widget.
26 <C></B>$returnValue = $scrollObject->activate ();
27
28 The variable </B>$returnValue<!B> will contain a integer value representing
29 the number of the chosen item. The numbers start at zero and go up.
30
31 </B>inject<!B>
32 This function injects a single character into the widget. The following
33 examples demonstrates how to call the inject method.
34 <C></B>$scrollObject->inject ( options );
35
36 The options are defined in the following table.
37 </U>Option Default Value Type Purpose<!U>
38 Shadow Required Scalar The character to inject into the widget.
39
40 If you are injecting a special character into the widget, then you can
41 use a pre-defined value to represent the key.
42
43 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
44 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
45 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
46 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
47 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
48 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
49 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
50 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
51 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
52 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
53 <C><#VL>Home <#VL>KEY_HOME <#VL>
54 <C><#VL>End <#VL>KEY_END <#VL>
55 <C><#VL>Escape <#VL>KEY_ESC <#VL>
56 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
57
58 </B>set<!B>
59 Sets or resets certain attributes or features of the widget. The following
60 example demonstrates how to call the set method.
61 <C></B>$scrollObject->set ( options );
62
63 The options are defined in the following table.
64
65 </U>Option Default Value Type Purpose<!U>
66 Highlight Required Scalar The attribute of the currently highlighted item.
67 Box True Scalar Changes the current value of the box flag.
68
69 </B>bind<!B>
70 The bind method binds keys to events. The binding is specific to the individual
71 objects. The following example demonstrates how to call the bind method.
72 <C></B>$scrollObject->bind ( options );
73
74 The options are defined in the following table.
75
76 </U>Option Default Value Type Purpose<!U>
77 Key Required Scalar This is the character to bind the event to.
78 Function Required Scalar This is the name of the callback function.
79
80 </B>preProcess<!B>
81 The </B>preProcess<!B> function sets a process to be run before the key entered
82 is processed. If this function returns a value of 0, then the key injected
83 into the widget will not be processed; otherwise the character will be
84 processed as normal. The following example demonstrates how to call the
85 preProcess method.
86 <C></B>$scrollObject->preProcess ( options );
87
88 The options are defined in the following table.
89
90 </U>Option Default Value Type Purpose<!U>
91 Function Required Scalar This is the name of the
92 callback function.
93
94 To create a pre-process callback the following code segment demonstrates
95 how to do it properly.
96
97 <C></B>$scrollObject->preProcess ('Function' => sub { callback (@_); });
98
99 Notice that the array </B>@_<!B> is passed into the function called
100 </B>callback<!B>. This is done because when the callback process is
101 called the key which was pressed is passed into the perl subroutine.
102 Since we nest the call-back function inside an anonymous subroutine,
103 we need to pass the array </B>@_<!B> to the call-back function. If
104 the key given to the call-back function is a non alphanumeric key
105 then a predefined value will be given to the function. The following
106 table describes the values passed into the function.
107
108 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
109 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
110 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
111 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
112 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
113 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
114 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
115 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
116 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
117 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
118 <C><#VL>Home <#VL>KEY_HOME <#VL>
119 <C><#VL>End <#VL>KEY_END <#VL>
120 <C><#VL>Escape <#VL>KEY_ESC <#VL>
121 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
122
123 If the pre-process function returns a value of 0 the key hit will
124 not be injected into the widget. This allows the programmer to
125 selectively pick which characters will or will not get injected
126 into the widget.
127
128 The </B>postProcess<!B> function sets a process to be run before the key entered
129 is processed. If this function returns a value of 0, then the key injected
130 into the widget will not be processed; otherwise the character will be
131 processed as normal. The following example demonstrates how to call the
132 postProcess method.
133 <C></B>$scrollObject->postProcess ( options );
134
135 The options are defined in the following table.
136
137 </U>Option Default Value Type Purpose<!U>
138 Function Required Scalar This is the name of the
139 callback function.
140
141 To create a post-process callback the following code segment demonstrates
142 how to do it properly.
143
144 <C></B>$scrollObject->postProcess ('Function' => sub { callback (@_); });
145
146 Notice that the array </B>@_<!B> is passed into the function called
147 </B>callback<!B>. This is done because when the callback process is
148 called the key which was pressed is passed into the perl subroutine.
149 Since we nest the call-back function inside an anonymous subroutine,
150 we need to pass the array </B>@_<!B> to the call-back function. If
151 the key given to the call-back function is a non alphanumeric key
152 then a predefined value will be given to the function. The following
153 table describes the values passed into the function.
154
155 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
156 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
157 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
158 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
159 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
160 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
161 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
162 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
163 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
164 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
165 <C><#VL>Home <#VL>KEY_HOME <#VL>
166 <C><#VL>End <#VL>KEY_END <#VL>
167 <C><#VL>Escape <#VL>KEY_ESC <#VL>
168 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
169 </B>draw<!B>
170 This method draws the object on the screen. The following example demonstrates
171 how to call the draw method.
172 <C></B>$scrollObject->draw ( options );
173
174 The options are defined in the following table.
175
176 </U>Option Default Value Type Purpose<!U>
177 Box True Scalar Draws the window with a box around it.
178
179 </B>erase<!B>
180 This method removes the object from the screen. This does </B/U>NOT<!B!U>
181 destroy the object. The following example demonstrates how to call the erase
182 method.
183 <C></B>$scrollObject->erase ();
184
185 </B>raise<!B>
186 The raise method raises the widget to the top of the screen. This means if there
187 were any widgets obscuring part of the view, raising the object would bring the
188 complete object into view. The following example demonstrates how to call the
189 raise method.
190 <C></B>$scrollObject->raise();
191
192 </B>lower<!B>
193 The lower method lowers the object so it doesn't obscure the view of any other
194 objects. The following example demonstrates how to call the lower method.
195 <C></B>$scrollObject->lower();
196
197 </B>register<!B>
198 The register method registers the object to the default screen. This does </R>NOT<!R>
199 have to be called since the objects are registered automatically. This method
200 should be called if the </B>unregister<!B> method was called. The following
201 example demonstrates how to call the register method.
202 <C></B>$scrollObject->register();
203
204 </B>unregister<!B>
205 The unregister method should be called when a widget, which is part of the
206 default screen, needs to be taken away temporarily. This does not delete or free
207 the object, it just unmaps it from any future screen refreshes. The object can
208 be registered by calling the </B>register<!B> method. The following example
209 demonstrates how to call the unregister method.
210 <C></B>$scrollObject->unregister();
211
212 </B>getwin<!B>
213 This method returns a pointer to the window of the object. Not much use for this
214 yet. It will be useful in the future when the drawing methods are added. The
215 following example demonstrates how to call the getwin method.
216 <C></B>$scrollObject->getwin();
217
218 </R>Default Key Bindings<!R>
219 </U>Key Action<!U>
220 Up Arrow Moves the cursor to one item up.
221 Down Arrow Moves the cursor to one item down.
222 Right Arrow Scrolls the whole list one character to the right.
223 Left Arrow Scrolls the whole list one character to the left.
224 Previous Page Moves the complete list one screen backwards.
225 CTRL-B Moves the complete list one screen backwards
226 Next Page Moves the complete list one screen forwards.
227 CTRL-F Moves the complete list one screen forwards.
228 g Moves to the top of the list.
229 1 Moves to the top of the list.
230 G Moves to the bottom of the list.
231 $ Scrolls complete list as far left as possible.
232 | Scrolls complete list as far right as possible.
233 Return Exits the widget and returns the current selection.
234 Tab Exits the widget and returns the current selection.
235 Escape Exits the widget and returns undef.
236 CTRL-R Refreshes the screen.
237
238 </R>Tips & Tricks<!R>
239 <B=*>You can make the scrolling list look like a menu list by turning on
240 the numbers option and creating the window the size of the list. This
241 works best if the list isn't too long so the whole list can be shown.
242
243 </R>Physical Restrictions<!R>
244 </U>Restriction Value<!U>
245 Maximum number of items. 500
246
247 </R>Example Use Of The Widget<!R>
248 <F=../examples/scroll>
249 <C><#HL(70)>
250 <C>Document Created: June, 1995
251 <C>Document Revised: November, 1995
252 <C>Document Revised: March, 1996
+0
-254
fulldemo/help/selection.help less more
0 </R>Purpose<!R>
1 The selection widget allows the user to add a selection list in their script.
2
3 </R>Construction Options<!R>
4 A selection widget is defined using the following syntax. The variable
5 </B>$selectionObject<!B> contains a reference to the selection object.
6 <C></B>$selectionObject = new Cdk::Radio ( options );
7
8 The options are defined in the following table.
9
10 </U>Option Default Value Type Purpose<!U>
11 Title Required Scalar The title of the selection list.
12 List Required Array Ref The list of items in the list.
13 Choices Required Array Ref The list of choices for each item in the list.
14 Height Required Scalar The height of the selection list.
15 Width Required Scalar The width of the selection list.
16 Highlight Reverse Scalar The attribute of the currently highlighted item.
17 Xpos Center Scalar This is the position of the window on the X axis.
18 Ypos Center Scalar This is the position of the window on the Y axis.
19 Box True Scalar This Boolean states whether the dialog box will have a box drawn around it.
20 Shadow False Scalar This Boolean states whether the dialog box will have a shadow on the box.
21
22 </R>Available Methods<!R>
23 </B>activate<!B>
24 Activation of an object means to make the object available for use. The
25 following example demonstrates how to activate a selection widget.
26 <C></B>$returnValue = $selectionObject->activate ();
27
28 The variable </B>$returnValue<!B> will contain a integer value representing
29 the number of the chosen item. The numbers start at zero and go up.
30
31 </B>inject<!B>
32 This function injects a single character into the widget. The following
33 examples demonstrates how to call the inject method.
34 <C></B>$selectionObject->inject ( options );
35
36 The options are defined in the following table.
37 </U>Option Default Value Type Purpose<!U>
38 Shadow Required Scalar The character to inject into the widget.
39
40 If you are injecting a special character into the widget, then you can
41 use a pre-defined value to represent the key.
42
43 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
44 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
45 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
46 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
47 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
48 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
49 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
50 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
51 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
52 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
53 <C><#VL>Home <#VL>KEY_HOME <#VL>
54 <C><#VL>End <#VL>KEY_END <#VL>
55 <C><#VL>Escape <#VL>KEY_ESC <#VL>
56 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
57
58 </B>set<!B>
59 Sets or resets certain attributes or features of the widget. The following
60 example demonstrates how to call the set method.
61 <C></B>$selectionObject->set ( options );
62
63 The options are defined in the following table.
64
65 </U>Option Default Value Type Purpose<!U>
66 Defaults Required Array Ref A list of values stating which items are to be given which value.
67 Highlight Required Scalar The attribute of the currently highlighted item.
68 Box True Scalar Changes the current value of the box flag.
69
70 </B>bind<!B>
71 The bind method binds keys to events. The binding is specific to the individual
72 objects. The following example demonstrates how to call the bind method.
73 <C></B>$selectionObject->bind ( options );
74
75 The options are defined in the following table.
76
77 </U>Option Default Value Type Purpose<!U>
78 Key Required Scalar This is the character to bind the event to.
79 Function Required Scalar This is the name of the callback function.
80
81 </B>preProcess<!B>
82 The </B>preProcess<!B> function sets a process to be run before the key entered
83 is processed. If this function returns a value of 0, then the key injected
84 into the widget will not be processed; otherwise the character will be
85 processed as normal. The following example demonstrates how to call the
86 preProcess method.
87 <C></B>$selectionObject->preProcess ( options );
88
89 The options are defined in the following table.
90
91 </U>Option Default Value Type Purpose<!U>
92 Function Required Scalar This is the name of the
93 callback function.
94
95 To create a pre-process callback the following code segment demonstrates
96 how to do it properly.
97
98 <C></B>$selectionObject->preProcess ('Function' => sub { callback (@_); });
99
100 Notice that the array </B>@_<!B> is passed into the function called
101 </B>callback<!B>. This is done because when the callback process is
102 called the key which was pressed is passed into the perl subroutine.
103 Since we nest the call-back function inside an anonymous subroutine,
104 we need to pass the array </B>@_<!B> to the call-back function. If
105 the key given to the call-back function is a non alphanumeric key
106 then a predefined value will be given to the function. The following
107 table describes the values passed into the function.
108
109 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
110 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
111 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
112 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
113 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
114 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
115 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
116 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
117 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
118 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
119 <C><#VL>Home <#VL>KEY_HOME <#VL>
120 <C><#VL>End <#VL>KEY_END <#VL>
121 <C><#VL>Escape <#VL>KEY_ESC <#VL>
122 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
123
124 If the pre-process function returns a value of 0 the key hit will
125 not be injected into the widget. This allows the programmer to
126 selectively pick which characters will or will not get injected
127 into the widget.
128
129 The </B>postProcess<!B> function sets a process to be run before the key entered
130 is processed. If this function returns a value of 0, then the key injected
131 into the widget will not be processed; otherwise the character will be
132 processed as normal. The following example demonstrates how to call the
133 postProcess method.
134 <C></B>$selectionObject->postProcess ( options );
135
136 The options are defined in the following table.
137
138 </U>Option Default Value Type Purpose<!U>
139 Function Required Scalar This is the name of the
140 callback function.
141
142 To create a post-process callback the following code segment demonstrates
143 how to do it properly.
144
145 <C></B>$selectionObject->postProcess ('Function' => sub { callback (@_); });
146
147 Notice that the array </B>@_<!B> is passed into the function called
148 </B>callback<!B>. This is done because when the callback process is
149 called the key which was pressed is passed into the perl subroutine.
150 Since we nest the call-back function inside an anonymous subroutine,
151 we need to pass the array </B>@_<!B> to the call-back function. If
152 the key given to the call-back function is a non alphanumeric key
153 then a predefined value will be given to the function. The following
154 table describes the values passed into the function.
155
156 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
157 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
158 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
159 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
160 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
161 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
162 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
163 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
164 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
165 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
166 <C><#VL>Home <#VL>KEY_HOME <#VL>
167 <C><#VL>End <#VL>KEY_END <#VL>
168 <C><#VL>Escape <#VL>KEY_ESC <#VL>
169 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
170 </B>draw<!B>
171 This method draws the object on the screen. The following example demonstrates
172 how to call the draw method.
173 <C></B>$selectionObject->draw ( options );
174
175 The options are defined in the following table.
176
177 </U>Option Default Value Type Purpose<!U>
178 Box True Scalar Draws the window with a box around it.
179
180 </B>erase<!B>
181 This method removes the object from the screen. This does </B/U>NOT<!B!U>
182 destroy the object. The following example demonstrates how to call the erase
183 method.
184 <C></B>$selectionObject->erase ();
185
186 </B>raise<!B>
187 The raise method raises the widget to the top of the screen. This means if there
188 were any widgets obscuring part of the view, raising the object would bring the
189 complete object into view. The following example demonstrates how to call the
190 raise method.
191 <C></B>$selectionObject->raise();
192
193 </B>lower<!B>
194 The lower method lowers the object so it doesn't obscure the view of any other
195 objects. The following example demonstrates how to call the lower method.
196 <C></B>$selectionObject->lower();
197
198 </B>register<!B>
199 The register method registers the object to the default screen. This does </R>NOT<!R>
200 have to be called since the objects are registered automatically. This method
201 should be called if the </B>unregister<!B> method was called. The following
202 example demonstrates how to call the register method.
203 <C></B>$selectionObject->register();
204
205 </B>unregister<!B>
206 The unregister method should be called when a widget, which is part of the
207 default screen, needs to be taken away temporarily. This does not delete or free
208 the object, it just unmaps it from any future screen refreshes. The object can
209 be registered by calling the </B>register<!B> method. The following example
210 demonstrates how to call the unregister method.
211 <C></B>$selectionObject->unregister();
212
213 </B>getwin<!B>
214 This method returns a pointer to the window of the object. Not much use for this
215 yet. It will be useful in the future when the drawing methods are added. The
216 following example demonstrates how to call the getwin method.
217 <C></B>$selectionObject->getwin();
218
219 </R>Default Key Bindings<!R>
220 </U>Key Action<!U>
221 Space Cycles the selection for the current item, to the next selection.
222 Up Arrow Moves the cursor to one item up.
223 Down Arrow Moves the cursor to one item down.
224 Right Arrow Scrolls the whole list one character to the right.
225 Left Arrow Scrolls the whole list one character to the left.
226 Previous Page Moves the complete list one screen backwards.
227 CTRL-B Moves the complete list one screen backwards
228 Next Page Moves the complete list one screen forwards.
229 CTRL-F Moves the complete list one screen forwards.
230 g Moves to the top of the list.
231 1 Moves to the top of the list.
232 G Moves to the bottom of the list.
233 $ Scrolls complete list as far left as possible.
234 | Scrolls complete list as far right as possible.
235 Return Exits the widget and returns the current selection.
236 Tab Exits the widget and returns the current selection.
237 Escape Exits the widget and returns undef.
238 CTRL-R Refreshes the screen.
239
240 </R>Tips & Tricks<!R>
241 <B=*>Calling the set method with the Defaults parameter will set the values of
242 the selection list before activation.
243
244 </R>Physical Restrictions<!R>
245 </U>Restriction Value<!U>
246 Maximum number of items. 500
247
248 </R>Example Use Of The Widget<!R>
249 <F=../examples/selection>
250 <C><#HL(70)>
251 <C>Document Created: June, 1995
252 <C>Document Revised: November, 1995
253 <C>Document Revised: March, 1996
+0
-264
fulldemo/help/slider.help less more
0 </R>Purpose<!R>
1 The slider widget is a widget which allows a user to select an integer value. The
2 slider widget forces the user to choose a value between a predetermined high
3 and low, which eliminates the need to check if the person has typed in a valid
4 value. The difference between this widget and the slider widget is this widget
5 displays a bar which represents the current value.
6
7 </R>Construction Options<!R>
8 A slider widget is defined using the following syntax. The variable
9 </B>$sliderObject<!B> contains a reference to the slider object.
10 <C></B>$sliderObject = new Cdk::Slider ( options );
11
12 The options are defined in the following table.
13
14 </U>Option Default Value Type Purpose<!U>
15 Label Required Scalar The label to the slider widget.
16 Low Required Scalar The low value of the slider widget.
17 High Required Scalar The high value of the slider widget.
18 Width Required Scalar The width of the field.
19 Inc 1 Scalar The increment value.
20 Fastinc 5 Scalar The accelerated increment value.
21 Start Low Value Scalar The starting value.
22 Filler Reverse Space Scalar The character which will be used for the scale.
23 Xpos Center Scalar This is the position of the window on the X axis.
24 Ypos Center Scalar This is the position of the window on the Y axis.
25 Lpos Left Scalar This is the position of the label in the widget.
26 Box True Scalar This Boolean states whether the dialog box will have a box drawn around it.
27 Shadow False Scalar This Boolean states whether the dialog box will have a shadow on the box.
28
29 </R>Available Methods<!R>
30 </B>activate<!B>
31 Activation of an object means to make the object available for use. The
32 following example demonstrates how to activate a slider widget.
33 <C></B>$returnValue = $sliderObject->activate ();
34
35 The variable </B>$returnValue<!B> is the value of the field when the widget
36 exits.
37
38 </B>inject<!B>
39 This function injects a single character into the widget. The following
40 examples demonstrates how to call the inject method.
41 <C></B>$sliderObject->inject ( options );
42
43 The options are defined in the following table.
44 </U>Option Default Value Type Purpose<!U>
45 Shadow Required Scalar The character to inject into the widget.
46
47 If you are injecting a special character into the widget, then you can
48 use a pre-defined value to represent the key.
49
50 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
51 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
52 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
53 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
54 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
55 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
56 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
57 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
58 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
59 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
60 <C><#VL>Home <#VL>KEY_HOME <#VL>
61 <C><#VL>End <#VL>KEY_END <#VL>
62 <C><#VL>Escape <#VL>KEY_ESC <#VL>
63 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
64
65 </B>set<!B>
66 Sets or resets certain attributes or features of the widget. The following
67 example demonstrates how to call the set method.
68 $sliderObject->set ( options );
69
70 The options are defined in the following table.
71
72 </U>Option Default Value Type Purpose<!U>
73 Low Required Scalar Sets the low value of the widget.
74 High Required Scalar Sets the high value of the widget.
75 Value Required Scalar Sets the current value of the widget.
76 Box True Scalar Changes the current value of the box flag.
77
78 </B>bind<!B>
79 The bind method binds keys to events. The binding is specific to the individual
80 objects. The following example demonstrates how to call the bind method.
81 <C></B>$sliderObject->bind ( options );
82
83 The options are defined in the following table.
84
85 </B>preProcess<!B>
86 The </B>preProcess<!B> function sets a process to be run before the key entered
87 is processed. If this function returns a value of 0, then the key injected
88 into the widget will not be processed; otherwise the character will be
89 processed as normal. The following example demonstrates how to call the
90 preProcess method.
91 <C></B>$sliderObject->preProcess ( options );
92
93 The options are defined in the following table.
94
95 </U>Option Default Value Type Purpose<!U>
96 Function Required Scalar This is the name of the
97 callback function.
98
99 To create a pre-process callback the following code segment demonstrates
100 how to do it properly.
101
102 <C></B>$sliderObject->preProcess ('Function' => sub { callback (@_); });
103
104 Notice that the array </B>@_<!B> is passed into the function called
105 </B>callback<!B>. This is done because when the callback process is
106 called the key which was pressed is passed into the perl subroutine.
107 Since we nest the call-back function inside an anonymous subroutine,
108 we need to pass the array </B>@_<!B> to the call-back function. If
109 the key given to the call-back function is a non alphanumeric key
110 then a predefined value will be given to the function. The following
111 table describes the values passed into the function.
112
113 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
114 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
115 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
116 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
117 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
118 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
119 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
120 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
121 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
122 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
123 <C><#VL>Home <#VL>KEY_HOME <#VL>
124 <C><#VL>End <#VL>KEY_END <#VL>
125 <C><#VL>Escape <#VL>KEY_ESC <#VL>
126 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
127
128 If the pre-process function returns a value of 0 the key hit will
129 not be injected into the widget. This allows the programmer to
130 selectively pick which characters will or will not get injected
131 into the widget.
132
133 The </B>postProcess<!B> function sets a process to be run before the key entered
134 is processed. If this function returns a value of 0, then the key injected
135 into the widget will not be processed; otherwise the character will be
136 processed as normal. The following example demonstrates how to call the
137 postProcess method.
138 <C></B>$sliderObject->postProcess ( options );
139
140 The options are defined in the following table.
141
142 </U>Option Default Value Type Purpose<!U>
143 Function Required Scalar This is the name of the
144 callback function.
145
146 To create a post-process callback the following code segment demonstrates
147 how to do it properly.
148
149 <C></B>$sliderObject->postProcess ('Function' => sub { callback (@_); });
150
151 Notice that the array </B>@_<!B> is passed into the function called
152 </B>callback<!B>. This is done because when the callback process is
153 called the key which was pressed is passed into the perl subroutine.
154 Since we nest the call-back function inside an anonymous subroutine,
155 we need to pass the array </B>@_<!B> to the call-back function. If
156 the key given to the call-back function is a non alphanumeric key
157 then a predefined value will be given to the function. The following
158 table describes the values passed into the function.
159
160 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
161 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
162 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
163 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
164 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
165 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
166 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
167 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
168 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
169 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
170 <C><#VL>Home <#VL>KEY_HOME <#VL>
171 <C><#VL>End <#VL>KEY_END <#VL>
172 <C><#VL>Escape <#VL>KEY_ESC <#VL>
173 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
174 </U>Option Default Value Type Purpose<!U>
175 Key Required Scalar This is the character to bind the event to.
176 Function Required Scalar This is the name of the callback function.
177
178 </B>draw<!B>
179 This method draws the object on the screen. The following example demonstrates
180 how to call the draw method.
181 <C></B>$sliderObject->draw ( options );
182
183 The options are defined in the following table.
184
185 </U>Option Default Value Type Purpose<!U>
186 Box True Scalar Draws the window with a box around it.
187
188 </B>erase<!B>
189 This method removes the object from the screen. This does </B/U>NOT<!B!U>
190 destroy the object. The following example demonstrates how to call the erase
191 method.
192 <C></B>$sliderObject->erase ();
193
194 </B>raise<!B>
195 The raise method raises the widget to the top of the screen. This means if there
196 were any widgets obscuring part of the view, raising the object would bring the
197 complete object into view. The following example demonstrates how to call the
198 raise method.
199 <C></B>$sliderObject->raise();
200
201 </B>lower<!B>
202 The lower method lowers the object so it doesn't obscure the view of any other
203 objects. The following example demonstrates how to call the lower method.
204 <C></B>$sliderObject->lower();
205
206 </B>register<!B>
207 The register method registers the object to the default screen. This does </R>NOT<!R>
208 have to be called since the objects are registered automatically. This method
209 should be called if the </B>unregister<!B> method was called. The following
210 example demonstrates how to call the register method.
211 <C></B>$sliderObject->register();
212
213 </B>unregister<!B>
214 The unregister method should be called when a widget, which is part of the
215 default screen, needs to be taken away temporarily. This does not delete or free
216 the object, it just unmaps it from any future screen refreshes. The object can
217 be registered by calling the </B>register<!B> method. The following example
218 demonstrates how to call the unregister method.
219 <C></B>$sliderObject->unregister();
220
221 </B>getwin<!B>
222 This method returns a pointer to the window of the object. Not much use for this
223 yet. It will be useful in the future when the drawing methods are added. The
224 following example demonstrates how to call the getwin method.
225 <C></B>$sliderObject->getwin();
226
227 </R>Default Key Bindings<!R>
228 </U>Key Action<!U>
229 Left Arrow Decrements the current value by the standard value.
230 Down Arrow Decrements the current value by the standard value.
231 d Decrements the current value by the standard value.
232 - Decrements the current value by the standard value.
233 Right Arrow Increments the current value by the standard value.
234 Up Arrow Increments the current value by the standard value.
235 u Increments the current value by the standard value.
236 + Increments the current value by the standard value.
237 Prev Page Decrements the current value by the accelerated value.
238 U Decrements the current value by the accelerated value.
239 CTRL-B Decrements the current value by the accelerated value.
240 Next Page Increments the current value by the accelerated value.
241 D Increments the current value by the accelerated value.
242 CTRL-F Increments the current value by the accelerated value.
243 Home Sets the field value to the low value.
244 g Sets the field value to the low value.
245 0 Sets the field value to the low value.
246 End Sets the field value to the high value.
247 G Sets the field value to the high value.
248 $ Sets the field value to the high value.
249 Return Exits the widget and returns the field value.
250 Tab Exits the widget and returns the field value.
251 Escape Exits the widget and returns undef.
252 CTRL-R Refreshes the screen.
253
254 </R>Tips & Tricks<!R>
255 None.
256
257 </R>Physical Restrictions<!R>
258 None.
259
260 </R>Example Use Of The Widget<!R>
261 <F=../examples/slider>
262 <C><#HL(70)>
263 <C>Document Created: June, 1996
+0
-22
fulldemo/help/special.help less more
0 </U>Special Display Keywords<!U>
1 There are a number of special keywords which can be added into any string in
2 Cdk which will highlight characters. Cdk has the ability to </B>BOLD<!B>, </U>UNDERLINE<!U>,
3 </R>Reverse<!R>, </K>Blink<!K>, </S>Standout<!S>, </D>Dim<!D>, and </1>m<!1></2>a<!2></3>n<!3></4>y<!4></5> <!5></6>c<!6></7>o<!7></8>l<!8></9>o<!9></10>r<!10></11>s<!11>
4
5 To turn on highlighting the format command \<\/XX> is used. To turn off
6 formatting the command \<\!XX> is used. The following table lists all of the
7 display attributes available through Cdk, and how to turn them on.
8
9 <C><#UL><#HL(7)><#TT><#HL(10)><#UR>
10 <C><#VL></U>Command <#VL> Attribute <!U><#VL>
11 <C><#VL>\<\/N> <#VL> </N>Normal<!N> <#VL>
12 <C><#VL>\<\/B> <#VL> </B>Bold<!B> <#VL>
13 <C><#VL>\<\/R> <#VL> </R>Reverse<!R> <#VL>
14 <C><#VL>\<\/U> <#VL> </U>Underline<!U> <#VL>
15 <C><#VL>\<\/K> <#VL> </K>Blink<!K> <#VL>
16 <C><#VL>\<\/S> <#VL> </S>Standout<!S> <#VL>
17 <C><#VL>\<\/D> <#VL> </D>Dim<!D> <#VL>
18 <C><#LL><#HL(7)><#BT><#HL(10)><#LR>
19
20 <C><#HL(70)>
21 <C>Document Created: January, 1996
+0
-284
fulldemo/help/swindow.help less more
0 </R>Purpose<!R>
1 A scrolling window widget allows the programmer to display a scrolling message
2 window. This widget allows a programmer to add current messages to the window.
3 This type of widget is best used for a log file.
4
5 </R>Construction Options<!R>
6 A swindow widget is defined using the following syntax. The variable
7 </B>$swindowObject<!B> contains a reference to the swindow object.
8 <C></B>$swindowObject = new Cdk::Swindow ( options );
9
10 The options are defined in the following table.
11
12 </U>Option Default Value Type Purpose<!U>
13 Title Required Scalar The title of the scrolling window.
14 Lines Required Scalar The number of lines to keep.
15 Height Required Scalar The height of the scrolling window.
16 Width Required Scalar The width of the scrolling window.
17 Xpos Center Scalar This is the position of the window on the X axis.
18 Ypos Center Scalar This is the position of the window on the Y axis.
19 Box True Scalar This boolean states whether the dialog box will have a box drawn around it.
20 Shadow False Scalar This boolean states whether the dialog box will have a shadow on the box.
21
22 </R>Available Methods<!R>
23 </B>activate<!B>
24 Activation of an object means to make the object available for use. The
25 following example demonstrates how to activate a swindow widget.
26 <C></B>$swindowObject->activate ();
27
28 </B>inject<!B>
29 This function injects a single character into the widget. The following
30 examples demonstrates how to call the inject method.
31 <C></B>$swindowObject->inject ( options );
32
33 The options are defined in the following table.
34 </U>Option Default Value Type Purpose<!U>
35 Shadow Required Scalar The character to inject into the widget.
36
37 If you are injecting a special character into the widget, then you can
38 use a pre-defined value to represent the key.
39
40 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
41 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
42 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
43 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
44 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
45 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
46 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
47 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
48 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
49 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
50 <C><#VL>Home <#VL>KEY_HOME <#VL>
51 <C><#VL>End <#VL>KEY_END <#VL>
52 <C><#VL>Escape <#VL>KEY_ESC <#VL>
53 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
54
55 </B>set<!B>
56 Sets or resets certain attributes or features of the widget. The following
57 example demonstrates how to call the set method.
58 <C></B>$swindowObject->set ( options );
59
60 The options are defined in the following table.
61
62 </U>Option Default Value Type Purpose<!U>
63 Info Required Array Ref Sets the contents of the window.
64 Lines Required Scalar Sets the number of lines to keep.
65 Box True Scalar Changes the current value of the box flag.
66
67 </B>bind<!B>
68 The bind method binds keys to events. The binding is specific to the individual
69 objects. The following example demonstrates how to call the bind method.
70 <C></B>$swindowObject->bind ( options );
71
72 The options are defined in the following table.
73
74 </U>Option Default Value Type Purpose<!U>
75 Key Required Scalar This is the character to bind the event to.
76 Function Required Scalar This is the name of the callback function.
77
78 </B>preProcess<!B>
79 The </B>preProcess<!B> function sets a process to be run before the key entered
80 is processed. If this function returns a value of 0, then the key injected
81 into the widget will not be processed; otherwise the character will be
82 processed as normal. The following example demonstrates how to call the
83 preProcess method.
84 <C></B>$swindowObject->preProcess ( options );
85
86 The options are defined in the following table.
87
88 </U>Option Default Value Type Purpose<!U>
89 Function Required Scalar This is the name of the
90 callback function.
91
92 To create a pre-process callback the following code segment demonstrates
93 how to do it properly.
94
95 <C></B>$swindowObject->preProcess ('Function' => sub { callback (@_); });
96
97 Notice that the array </B>@_<!B> is passed into the function called
98 </B>callback<!B>. This is done because when the callback process is
99 called the key which was pressed is passed into the perl subroutine.
100 Since we nest the call-back function inside an anonymous subroutine,
101 we need to pass the array </B>@_<!B> to the call-back function. If
102 the key given to the call-back function is a non alphanumeric key
103 then a predefined value will be given to the function. The following
104 table describes the values passed into the function.
105
106 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
107 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
108 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
109 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
110 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
111 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
112 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
113 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
114 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
115 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
116 <C><#VL>Home <#VL>KEY_HOME <#VL>
117 <C><#VL>End <#VL>KEY_END <#VL>
118 <C><#VL>Escape <#VL>KEY_ESC <#VL>
119 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
120
121 If the pre-process function returns a value of 0 the key hit will
122 not be injected into the widget. This allows the programmer to
123 selectively pick which characters will or will not get injected
124 into the widget.
125
126 The </B>postProcess<!B> function sets a process to be run before the key entered
127 is processed. If this function returns a value of 0, then the key injected
128 into the widget will not be processed; otherwise the character will be
129 processed as normal. The following example demonstrates how to call the
130 postProcess method.
131 <C></B>$swindowObject->postProcess ( options );
132
133 The options are defined in the following table.
134
135 </U>Option Default Value Type Purpose<!U>
136 Function Required Scalar This is the name of the
137 callback function.
138
139 To create a post-process callback the following code segment demonstrates
140 how to do it properly.
141
142 <C></B>$swindowObject->postProcess ('Function' => sub { callback (@_); });
143
144 Notice that the array </B>@_<!B> is passed into the function called
145 </B>callback<!B>. This is done because when the callback process is
146 called the key which was pressed is passed into the perl subroutine.
147 Since we nest the call-back function inside an anonymous subroutine,
148 we need to pass the array </B>@_<!B> to the call-back function. If
149 the key given to the call-back function is a non alphanumeric key
150 then a predefined value will be given to the function. The following
151 table describes the values passed into the function.
152
153 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
154 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
155 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
156 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
157 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
158 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
159 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
160 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
161 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
162 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
163 <C><#VL>Home <#VL>KEY_HOME <#VL>
164 <C><#VL>End <#VL>KEY_END <#VL>
165 <C><#VL>Escape <#VL>KEY_ESC <#VL>
166 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
167 </B>draw<!B>
168 This method draws the object on the screen. The following example demonstrates
169 how to call the draw method.
170 <C></B>$swindowObject->draw ( options );
171
172 The options are defined in the following table.
173
174 </U>Option Default Value Type Purpose<!U>
175 Box True Scalar Draws the window with a box around it.
176
177 </B>addline<!B>
178 This method adds a line to the scrolling window. The following example
179 demonstrates how to call the addline method.
180 <C></B>$swindowObject->addline ( options );
181
182 The options are defined in the following table.
183
184 </U>Option Default Value Type Purpose<!U>
185 Info Required Scalar The information to add to the window.
186 Position Bottom Scalar The location where the information is to be added.
187
188 </B>trim<!B>
189 This method trims the information maintained by the srolling window. The following
190 example demonstrates how to call the trim method.
191 <C></B>$swindowObject->trim ( options );
192
193 The options are defined in the following table.
194
195 </U>Option Default Value Type Purpose<!U>
196 Start Required Scalar This is the first line to trim from.
197 Finish Required Scalar This is the last line to trim from.
198
199 </B>get<!B>
200 This method returns the information currently in the srolling window. The
201 following example demonstrates how to call the get method.
202 <C></B>@information = $swindowObject->get ();
203
204 </B>erase<!B>
205 This method removes the object from the screen. This does </B/U>NOT<!B!U>
206 destroy the object. The following example demonstrates how to call the erase
207 method.
208 <C></B>$swindowObject->erase ();
209
210 </B>raise<!B>
211 The raise method raises the widget to the top of the screen. This means if there
212 were any widgets obscuring part of the view, raising the object would bring the
213 complete object into view. The following example demonstrates how to call the
214 raise method.
215 <C></B>$swindowObject->raise();
216
217 </B>lower<!B>
218 The lower method lowers the object so it doesn't obscure the view of any other
219 objects. The following example demonstrates how to call the lower method.
220 <C></B>$swindowObject->lower();
221
222 </B>register<!B>
223 The register method registers the object to the default screen. This does </R>NOT<!R>
224 have to be called since the objects are registered automatically. This method
225 should be called if the </B>unregister<!B> method was called. The following
226 example demonstrates how to call the register method.
227 <C></B>$swindowObject->register();
228
229 </B>unregister<!B>
230 The unregister method should be called when a widget, which is part of the
231 default screen, needs to be taken away temporarily. This does not delete or free
232 the object, it just unmaps it from any future screen refreshes. The object can
233 be registered by calling the </B>register<!B> method. The following example
234 demonstrates how to call the unregister method.
235 <C></B>$swindowObject->unregister();
236
237 </B>getwin<!B>
238 This method returns a pointer to the window of the object. Not much use for this
239 yet. It will be useful in the future when the drawing methods are added. The
240 following example demonstrates how to call the getwin method.
241 <C></B>$swindowObject->getwin();
242
243 </R>Default Key Bindings<!R>
244 </U>Key Action<!U>
245 Up Arrow Scrolls the window up by one line.
246 Down Arrow Scrolls the window down by one line.
247 Right Arrow Scrolls the window right by one line.
248 Left Arrow Scrolls the window left by one line.
249 Prev Page Displays the previous page.
250 CTRL-B Displays the previous page.
251 B Displays the previous page.
252 b Displays the previous page.
253 Next Page Displays the next page.
254 CTRL-F Displays the next page.
255 Space Displays the next page.
256 F Displays the next page.
257 f Displays the next page.
258 Home Moves to the far left of the window.
259 | Moves to the far left of the window.
260 End Moves to the far right of the window.
261 $ Moves to the far right of the window.
262 g Moves to the top of the window.
263 1 Moves to the top of the window.
264 G Moves to the bottom of the window.
265 L Moves halfway to the bottom of the scrolling window.
266 l Moves halfway to the top of the scrolling window.
267 Return Exits the scrolling window.
268 Tab Exits the scrolling window.
269 CTRL-R Refreshes the screen.
270
271 </R>Tips & Tricks<!R>
272 None.
273
274 </R>Physical Restrictions<!R>
275 </U>Restriction Value<!U>
276 Maximum number of lines. 300
277
278 </R>Example Use Of The Widget<!R>
279 <F=../examples/swindow>
280 <C><#HL(70)>
281 <C>Document Created: June, 1995
282 <C>Document Revised: November, 1995
283 <C>Document Revised: June, 1995
+0
-288
fulldemo/help/template.help less more
0 </R>Purpose<!R>
1 The template widget allows the programmer to present a user with an entry field
2 which has a strict format requirement. This widget is best used to retrieve
3 date fields or phone numbers, both of which have a specific format.
4
5 </R>Construction Options<!R>
6 A template widget is defined using the following syntax. The variable
7 </B>$templateObject<!B> contains a reference to the template object.
8 $templateObject = new Cdk::Template ( options );
9
10 The options are defined in the following table.
11
12 </U>Option Default Value Type Purpose<!U>
13 Label Required Scalar This is the label of the widget.
14 Plate Required Scalar This is the format plate for the entry field. The accepted characters for the plate are listed below.
15 Overlay Required Scalar This is the default background of the template field. For a date field it could be DD/MM/YYYY
16 Lpos Center Scalar This is the position of the label in the widget.
17 Xpos Center Scalar This is the position of the window on the X axis.
18 Ypos Center Scalar This is the position of the window on the Y axis.
19 Box True Scalar This boolean states whether the dialog box will have a box drawn around it.
20 Shadow False Scalar This boolean states whether the dialog box will have a shadow on the box.
21
22 The </B>Plate<!B> option takes a specific format to state which type of character
23 will be accepted at each location. The following table lists the characters and what they mean.
24
25 </U>Character Meaning<!U>
26 # Accepts numeric values only. (0-9)
27 A Alphabetic characters only. (a-zA-Z)
28 C Alphabetic characters only. This will force the character to upper case.
29 c Alphabetic characters only. This will force the character to lower case.
30 X Mixed upper case characters.
31 x Mixed lower case characters.
32 Anything else. Used as plate information.
33
34 </R>Available Methods<!R>
35 </B>activate<!B>
36 Activation of an object means to make the object available for use. The
37 following example demonstrates how to activate a template widget.
38 $returnValue = $templateObject->activate ();
39
40 The variable </B>$returnValue<!B> is the string value of what was typed in
41 the field. It does </U>not<!U> have the overlay characters mixed in with it.
42 This means that if a date field were used and the plate looked like
43 <C>##/##/####
44 and the overlay looked like
45 <C>DD-MM-YYYY
46 and the date June 1 1968 were typed in, then the resultant value would be
47 <C>01061968
48 To mix the field value and the overlay, call the mix method. Calling the mix
49 method on the above example would result in
50 <C>01-06-1968
51
52 </B>inject<!B>
53 This function injects a single character into the widget. The following
54 examples demonstrates how to call the inject method.
55 <C></B>$templateObject->inject ( options );
56
57 The options are defined in the following table.
58 </U>Option Default Value Type Purpose<!U>
59 Shadow Required Scalar The character to inject into the widget.
60
61 If you are injecting a special character into the widget, then you can
62 use a pre-defined value to represent the key.
63
64 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
65 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
66 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
67 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
68 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
69 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
70 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
71 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
72 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
73 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
74 <C><#VL>Home <#VL>KEY_HOME <#VL>
75 <C><#VL>End <#VL>KEY_END <#VL>
76 <C><#VL>Escape <#VL>KEY_ESC <#VL>
77 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
78
79 </B>set<!B>
80 Sets or resets certain attributes or features of the widget. The following
81 example demonstrates how to call the set method.
82 $templateObject->set ( options );
83
84 The options are defined in the following table.
85
86 </U>Option Default Value Type Purpose<!U>
87 Value Required Scalar Sets the value of the field.
88
89 </B>bind<!B>
90 The bind method binds keys to events. The binding is specific to the individual
91 objects. The following example demonstrates how to call the bind method.
92 $templateObject->bind ( options );
93
94 The options are defined in the following table.
95
96 </U>Option Default Value Type Purpose<!U>
97 Key Required Scalar This is the character to bind the event to.
98 Function Required Scalar This is the name of the callback function.
99
100 </B>preProcess<!B>
101 The </B>preProcess<!B> function sets a process to be run before the key entered
102 is processed. If this function returns a value of 0, then the key injected
103 into the widget will not be processed; otherwise the character will be
104 processed as normal. The following example demonstrates how to call the
105 preProcess method.
106 <C></B>$templateObject->preProcess ( options );
107
108 The options are defined in the following table.
109
110 </U>Option Default Value Type Purpose<!U>
111 Function Required Scalar This is the name of the
112 callback function.
113
114 To create a pre-process callback the following code segment demonstrates
115 how to do it properly.
116
117 <C></B>$templateObject->preProcess ('Function' => sub { callback (@_); });
118
119 Notice that the array </B>@_<!B> is passed into the function called
120 </B>callback<!B>. This is done because when the callback process is
121 called the key which was pressed is passed into the perl subroutine.
122 Since we nest the call-back function inside an anonymous subroutine,
123 we need to pass the array </B>@_<!B> to the call-back function. If
124 the key given to the call-back function is a non alphanumeric key
125 then a predefined value will be given to the function. The following
126 table describes the values passed into the function.
127
128 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
129 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
130 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
131 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
132 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
133 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
134 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
135 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
136 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
137 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
138 <C><#VL>Home <#VL>KEY_HOME <#VL>
139 <C><#VL>End <#VL>KEY_END <#VL>
140 <C><#VL>Escape <#VL>KEY_ESC <#VL>
141 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
142
143 If the pre-process function returns a value of 0 the key hit will
144 not be injected into the widget. This allows the programmer to
145 selectively pick which characters will or will not get injected
146 into the widget.
147
148 The </B>postProcess<!B> function sets a process to be run before the key entered
149 is processed. If this function returns a value of 0, then the key injected
150 into the widget will not be processed; otherwise the character will be
151 processed as normal. The following example demonstrates how to call the
152 postProcess method.
153 <C></B>$templateObject->postProcess ( options );
154
155 The options are defined in the following table.
156
157 </U>Option Default Value Type Purpose<!U>
158 Function Required Scalar This is the name of the
159 callback function.
160
161 To create a post-process callback the following code segment demonstrates
162 how to do it properly.
163
164 <C></B>$templateObject->postProcess ('Function' => sub { callback (@_); });
165
166 Notice that the array </B>@_<!B> is passed into the function called
167 </B>callback<!B>. This is done because when the callback process is
168 called the key which was pressed is passed into the perl subroutine.
169 Since we nest the call-back function inside an anonymous subroutine,
170 we need to pass the array </B>@_<!B> to the call-back function. If
171 the key given to the call-back function is a non alphanumeric key
172 then a predefined value will be given to the function. The following
173 table describes the values passed into the function.
174
175 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
176 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
177 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
178 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
179 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
180 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
181 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
182 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
183 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
184 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
185 <C><#VL>Home <#VL>KEY_HOME <#VL>
186 <C><#VL>End <#VL>KEY_END <#VL>
187 <C><#VL>Escape <#VL>KEY_ESC <#VL>
188 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
189 </B>draw<!B>
190 This method draws the object on the screen. The following example demonstrates
191 how to call the draw method.
192 $templateObject->draw ( options );
193
194 The options are defined in the following table.
195
196 </U>Option Default Value Type Purpose<!U>
197 Box True Scalar Draws the window with a box around it.
198
199 </B>erase<!B>
200 This method removes the object from the screen. This does </B/U>NOT<!B!U>
201 destroy the object. The following example demonstrates how to call the erase
202 method.
203 $templateObject->erase ();
204
205 </B>mix<!B>
206 This method returns a mixed value of the template field value and the overlay.
207 The following example demonstrates how to call the mix method.
208 $mixedValue = $templateObject();
209
210 </B>raise<!B>
211 The raise method raises the widget to the top of the screen. This means if there
212 were any widgets obscuring part of the view, raising the object would bring the
213 complete object into view. The following example demonstrates how to call the
214 raise method.
215 $templateObject->raise();
216
217 </B>lower<!B>
218 The lower method lowers the object so it doesn't obscure the view of any other
219 objects. The following example demonstrates how to call the lower method.
220 $templateObject->lower();
221
222 </B>register<!B>
223 The register method registers the object to the default screen. This does </R>NOT<!R>
224 have to be called since the objects are registered automatically. This method
225 should be called if the </B>unregister<!B> method was called. The following
226 example demonstrates how to call the register method.
227 $templateObject->register();
228
229 </B>unregister<!B>
230 The unregister method should be called when a widget, which is part of the
231 default screen, needs to be taken away temporarily. This does not delete or free
232 the object, it just unmaps it from any future screen refreshes. The object can
233 be registered by calling the </B>register<!B> method. The following example
234 demonstrates how to call the unregister method.
235 $templateObject->unregister();
236
237 </B>getwin<!B>
238 This method returns a pointer to the window of the object. Not much use for this
239 yet. It will be useful in the future when the drawing methods are added. The
240 following example demonstrates how to call the getwin method.
241 $templateObject->getwin();
242
243 </R>Default Key Bindings<!R>
244 </U>Key Action<!U>
245 Delete Deletes the last character in the field.
246 Backspace Deletes the last character in the field.
247 Return Leaves the widget and returns the field value.
248 Tab Leaves the widget and returns the field value.
249 CTRL-N Leaves the widget and returns the field value.
250 CTRL-R Refreshes the screen.
251
252 </R>Tips & Tricks<!R>
253 None.
254
255 </R>Physical Restrictions<!R>
256 None.
257
258 </R>Example Use Of The Widget<!R>
259
260 #!/usr/local/bin/perl
261
262 #
263 # Load in the Cdk Extension.
264 #
265 use Cdk;
266 Cdk::init();
267
268 # Create the template object.
269 $template = new Cdk::Template (
270 'Label' => 'Type in a date:',
271 'Plate' => '## ## ####',
272 'Overlay' => 'DD-MM-YYYY');
273
274 # Activate the widget.
275 $date = $template->activate();
276 $mixedDate = $template->mix();
277
278 # Exit Cdk.
279 Cdk::end();
280
281 # Print out the info.
282 print "\n\n\n";
283 print "Without Overlay Mixing: $date\n";
284 print "With Overlay Mixing : $mixedDate\n";
285 --------------------------------------------------------------------------------
286 Document Created: June, 1995
287 Document Revised: November, 1995
+0
-182
fulldemo/help/viewer.help less more
0 </R>Purpose<!R>
1 This widget provides a way to view any text file. The text file can contain
2 Cdk display commands, or be a regular text file.
3
4 </R>Construction Options<!R>
5 A viewer widget is defined using the following syntax. The variable
6 </B>$viewerObject<!B> contains a reference to the viewer object.
7 <C></B>$viewerObject = new Cdk::Viewer ( options );
8
9 The options are defined in the following table.
10
11 </U>Option Default Value Type Purpose<!U>
12 Buttons Required Array Ref This is an array of the button labels.
13 Height Required Scalar The height of the window.
14 Width Required Scalar The width of the window.
15 Xpos Center Scalar This is the position of the window on the X axis.
16 Ypos Center Scalar This is the position of the window on the Y axis.
17 Shadow False Scalar This Boolean states whether the dialog box will have a shadow on the box.
18
19 </R>Available Methods<!R>
20 </B>activate<!B>
21 Activation of an object means to make the object available for use. The
22 following example demonstrates how to activate a viewer widget.
23 <C></B>$returnValue = $viewerObject->activate ( options );
24
25 </U>Option Default Value Type Purpose<!U>
26 Title Required Scalar The title of the viewer widget.
27 Info Required Array Ref The information contained inside the viewer.
28 Highlight Reverse Scalar The attribute of the currently highlighted button.
29 Interp True Scalar This is a Boolean flag specifying whether or not the file being
30 read in should have the contents interpreted for the
31 Cdk display codes.
32 Box True Scalar This Boolean states whether the dialog box will have a box drawn around it.
33
34 The variable </B>$returnValue<!B> is the numeric value of the button chosen.
35 The value starts at 0 and goes up.
36
37 </B>inject<!B>
38 This function injects a single character into the widget. The following
39 examples demonstrates how to call the inject method.
40 <C></B>$viewerObject->inject ( options );
41
42 The options are defined in the following table.
43 </U>Option Default Value Type Purpose<!U>
44 Shadow Required Scalar The character to inject into the widget.
45
46 If you are injecting a special character into the widget, then you can
47 use a pre-defined value to represent the key.
48
49 <C><#UL><#HL(11)><#TT><#HL(14)><#UR>
50 <C><#VL></U>Key <#VL>Key Value <!U><#VL>
51 <C><#VL>Left Arrow <#VL>KEY_LEFT <#VL>
52 <C><#VL>Right Arrow <#VL>KEY_RIGHT <#VL>
53 <C><#VL>Up Arrow <#VL>KEY_UP <#VL>
54 <C><#VL>Down Arrow <#VL>KEY_DOWN <#VL>
55 <C><#VL>Delete <#VL>KEY_DELETE <#VL>
56 <C><#VL>Backspace <#VL>KEY_BACKSPACE <#VL>
57 <C><#VL>Page Up <#VL>KEY_PPAGE <#VL>
58 <C><#VL>Page Down <#VL>KEY_NPAGE <#VL>
59 <C><#VL>Home <#VL>KEY_HOME <#VL>
60 <C><#VL>End <#VL>KEY_END <#VL>
61 <C><#VL>Escape <#VL>KEY_ESC <#VL>
62 <C><#LL><#HL(11)><#BT><#HL(14)><#LR>
63
64 </B>set<!B>
65 Sets or resets certain attributes or features of the widget. The following
66 example demonstrates how to call the set method.
67 <C></B>$viewerObject->set ( options );
68
69 The options are defined in the following table.
70
71 </U>Option Default Value Type Purpose<!U>
72 Highlight Reverse Scalar The attribute of the currently highlighted button.
73 Box True Scalar This Boolean states whether the dialog box will have a box drawn around it.
74
75 </B>bind<!B>
76 The bind method binds keys to events. The binding is specific to the individual
77 objects. The following example demonstrates how to call the bind method.
78 <C></B>$viewerObject->bind ( options );
79
80 The options are defined in the following table.
81
82 </U>Option Default Value Type Purpose<!U>
83 Key Required Scalar This is the character to bind the event to.
84 Function Required Scalar This is the name of the callback function.
85
86 </B>draw<!B>
87 This method draws the object on the screen. The following example demonstrates
88 how to call the draw method.
89 <C></B>$viewerObject->draw ( options );
90
91 The options are defined in the following table.
92
93 </U>Option Default Value Type Purpose<!U>
94 Box True Scalar Draws the window with a box around it.
95
96 </B>erase<!B>
97 This method removes the object from the screen. This does </B/U>NOT<!B!U>
98 destroy the object. The following example demonstrates how to call the erase
99 method.
100 <C></B>$viewerObject->erase ();
101
102 </B>raise<!B>
103 The raise method raises the widget to the top of the screen. This means if there
104 were any widgets obscuring part of the view, raising the object would bring the
105 complete object into view. The following example demonstrates how to call the
106 raise method.
107 <C></B>$viewerObject->raise();
108
109 </B>lower<!B>
110 The lower method lowers the object so it doesn't obscure the view of any other
111 objects. The following example demonstrates how to call the lower method.
112 <C></B>$viewerObject->lower();
113
114 </B>register<!B>
115 The register method registers the object to the default screen. This does </R>NOT<!R>
116 have to be called since the objects are registered automatically. This method
117 should be called if the </B>unregister<!B> method was called. The following
118 example demonstrates how to call the register method.
119 <C></B>$viewerObject->register();
120
121 </B>unregister<!B>
122 The unregister method should be called when a widget, which is part of the
123 default screen, needs to be taken away temporarily. This does not delete or free
124 the object, it just unmaps it from any future screen refreshes. The object can
125 be registered by calling the </B>register<!B> method. The following example
126 demonstrates how to call the unregister method.
127 <C></B>$viewerObject->unregister();
128
129 </B>getwin<!B>
130 This method returns a pointer to the window of the object. Not much use for this
131 yet. It will be useful in the future when the drawing methods are added. The
132 following example demonstrates how to call the getwin method.
133 <C></B>$viewerObject->getwin();
134
135 </R>Default Key Bindings<!R>
136 </U>Key Action<!U>
137 Tab Selects the next button.
138 Up Arrow Moves the cursor to one line up.
139 Down Arrow Moves the cursor to one line down.
140 Tab Moves the cursor to one line down.
141 Right Arrow Scrolls the view one character to the right.
142 Left Arrow Scrolls the view list one character to the left.
143 Previous Page Moves one screen backwards.
144 CTRL-B Moves one screen backwards
145 Next Page Moves one screen forwards.
146 Space Moves one screen forwards.
147 CTRL-F Moves one screen forwards.
148 g Moves to the top of the viewer.
149 1 Moves to the top of the viewer.
150 G Moves to the bottom of the viewer.
151 End Scrolls complete viewer as far left as possible.
152 $ Scrolls complete viewer as far left as possible.
153 Home Scrolls complete viewer as far right as possible.
154 | Scrolls complete viewer as far right as possible.
155 L Moves halfway to the bottom of the viewer.
156 l Moves halfway to the top of the viewer.
157 ? Searches upwards for given text.
158 / Searches downwards for given text.
159 n Performs last search, in the same direction.
160 : Jumps to a given line.
161 i Displays information about the current file in viewer.
162 s Displays information about the current file in viewer.
163 Return Exits the widget and returns the current selection.
164 Tab Exits the widget and returns the current selection.
165 Escape Exits the widget and returns undef.
166 CTRL-R Refreshes the screen.
167
168 </R>Tips & Tricks<!R>
169 None.
170
171 </R>Physical Restrictions<!R>
172 </U>Restriction Value<!U>
173 Maximum number of lines. 10000
174 Maximum number of buttons. 50
175
176 </R>Example Use Of The Widget<!R>
177 <F=../examples/viewer>
178 <C><#HL(70)>
179 <C>Document Created: June, 1995
180 <C>Document Revised: November, 1995
181 <C>Document Revised: March, 1996
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:44 $
5 * $Revision: 1.19 $
6 */
7
8 /*
9 * Declare file local prototypes.
10 */
11 static void drawCDK<MIXED>Field (CDK<UPPER> *widget);
12
13 DeclareCDKObjects(<UPPER>, <MIXED>, setCdk, <DTYPE>);
14
15 /*
16 * This function creates a widget.
17 */
18 CDK<UPPER> *newCDK<MIXED> (CDKSCREEN *cdkscreen,
19 int xplace,
20 int yplace,
21 char *title,
22 char *label,
23 chtype fieldAttr,
24 int fieldWidth,
25 <CTYPE> start,
26 <CTYPE> low,
27 <CTYPE> high,
28 <CTYPE> inc,
29 <CTYPE> fastInc,
30 #if <FLOAT>
31 int digits,
32 #endif <FLOAT>
33 boolean Box,
34 boolean shadow)
35 {
36 CDK<UPPER> *widget = 0;
37 int parentWidth = getmaxx(cdkscreen->window);
38 int parentHeight = getmaxy(cdkscreen->window);
39 int boxHeight;
40 int boxWidth;
41 int horizontalAdjust, oldWidth;
42 int xpos = xplace;
43 int ypos = yplace;
44 int x, junk;
45
46 static const struct { int from; int to; } bindings[] = {
47 { 'u', KEY_UP },
48 { 'U', KEY_PPAGE },
49 { CDK_BACKCHAR, KEY_PPAGE },
50 { CDK_FORCHAR, KEY_NPAGE },
51 { 'g', KEY_HOME },
52 { '^', KEY_HOME },
53 { 'G', KEY_END },
54 { '$', KEY_END },
55 };
56
57 if ((widget = newCDKObject(CDK<UPPER>, &my_funcs)) == 0)
58 return (0);
59
60 setCDK<MIXED>Box (widget, Box);
61
62 boxHeight = (BorderOf(widget) * 2) + 1;
63 boxWidth = fieldWidth + 2*BorderOf(widget);
64
65 /* Set some basic values of the widget's data field. */
66 widget->label = 0;
67 widget->labelLen = 0;
68 widget->labelWin = 0;
69
70 /*
71 * If the fieldWidth is a negative value, the fieldWidth will
72 * be COLS-fieldWidth, otherwise, the fieldWidth will be the
73 * given width.
74 */
75 fieldWidth = setWidgetDimension (parentWidth, fieldWidth, 0);
76 boxWidth = fieldWidth + 2*BorderOf(widget);
77
78 /* Translate the label char *pointer to a chtype pointer. */
79 if (label != 0)
80 {
81 widget->label = char2Chtype (label, &widget->labelLen, &junk);
82 boxWidth = widget->labelLen + fieldWidth + 2;
83 }
84
85 oldWidth = boxWidth;
86 boxWidth = setCdkTitle(ObjOf(widget), title, boxWidth);
87 horizontalAdjust = (boxWidth - oldWidth) / 2;
88
89 boxHeight += TitleLinesOf(widget);
90
91 /*
92 * Make sure we didn't extend beyond the dimensions of the window.
93 */
94 boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth);
95 boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight);
96 fieldWidth = (fieldWidth > (boxWidth - widget->labelLen - 2*BorderOf(widget))
97 ? (boxWidth - widget->labelLen - 2*BorderOf(widget))
98 : fieldWidth);
99
100 /* Rejustify the x and y positions if we need to. */
101 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
102
103 /* Make the widget's window. */
104 widget->win = newwin (boxHeight, boxWidth, ypos, xpos);
105
106 /* Is the main window null??? */
107 if (widget->win == 0)
108 {
109 destroyCDKObject(widget);
110 return (0);
111 }
112
113 /* Create the widget's label window. */
114 if (widget->label != 0)
115 {
116 widget->labelWin = subwin (widget->win,
117 1, widget->labelLen,
118 ypos + TitleLinesOf(widget) + BorderOf(widget),
119 xpos + horizontalAdjust + BorderOf(widget));
120 if (widget->labelWin == 0)
121 {
122 destroyCDKObject(widget);
123 return (0);
124 }
125 }
126
127 /* Create the widget's data field window. */
128 widget->fieldWin = subwin (widget->win,
129 1, fieldWidth,
130 ypos + TitleLinesOf(widget) + BorderOf(widget),
131 xpos + widget->labelLen + horizontalAdjust + BorderOf(widget));
132 if (widget->fieldWin == 0)
133 {
134 destroyCDKObject(widget);
135 return (0);
136 }
137 keypad (widget->fieldWin, TRUE);
138 keypad (widget->win, TRUE);
139
140 /* Create the widget's data field. */
141 ScreenOf(widget) = cdkscreen;
142 widget->parent = cdkscreen->window;
143 widget->shadowWin = 0;
144 widget->boxWidth = boxWidth;
145 widget->boxHeight = boxHeight;
146 widget->fieldWidth = fieldWidth;
147 widget->fieldAttr = (chtype)fieldAttr;
148 widget->current = low;
149 widget->low = low;
150 widget->high = high;
151 widget->current = start;
152 widget->inc = inc;
153 widget->fastinc = fastInc;
154 #if <FLOAT>
155 widget->digits = digits;
156 #endif <FLOAT>
157 initExitType(widget);
158 ObjOf(widget)->acceptsFocus = TRUE;
159 ObjOf(widget)->inputWindow = widget->win;
160 widget->shadow = shadow;
161
162 /* Do we want a shadow??? */
163 if (shadow)
164 {
165 widget->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
166 if (widget->shadowWin == 0)
167 {
168 destroyCDKObject(widget);
169 return (0);
170 }
171 }
172
173 /* Setup the key bindings. */
174 for (x = 0; x < (int) SIZEOF(bindings); ++x)
175 bindCDKObject (v<UPPER>, widget, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to);
176
177 registerCDKObject (cdkscreen, v<UPPER>, widget);
178
179 return (widget);
180 }
181
182 /*
183 * This allows the person to use the widget's data field.
184 */
185 <CTYPE> activateCDK<MIXED> (CDK<UPPER> *widget, chtype *actions)
186 {
187 <CTYPE> ret;
188
189 /* Draw the widget. */
190 drawCDK<MIXED> (widget, ObjOf(widget)->box);
191
192 if (actions == 0)
193 {
194 chtype input = 0;
195 boolean functionKey;
196
197 for (;;)
198 {
199 input = getchCDKObject (ObjOf(widget), &functionKey);
200
201 /* Inject the character into the widget. */
202 ret = injectCDK<MIXED> (widget, input);
203 if (widget->exitType != vEARLY_EXIT)
204 {
205 return ret;
206 }
207 }
208 }
209 else
210 {
211 int length = chlen (actions);
212 int x = 0;
213
214 /* Inject each character one at a time. */
215 for (x=0; x < length; x++)
216 {
217 ret = injectCDK<MIXED> (widget, actions[x]);
218 if (widget->exitType != vEARLY_EXIT)
219 {
220 return ret;
221 }
222 }
223 }
224
225 /* Set the exit type and return. */
226 setExitType(widget, 0);
227 return unknown<DTYPE>;
228 }
229
230 /*
231 * Check if the value lies outside the low/high range. If so, force it in.
232 */
233 static void limitCurrentValue (CDK<UPPER> *widget)
234 {
235 if (widget->current < widget->low)
236 {
237 widget->current = widget->low;
238 Beep();
239 }
240 else if (widget->current > widget->high)
241 {
242 widget->current = widget->high;
243 Beep();
244 }
245 }
246
247 /*
248 * Move the cursor to the given edit-position.
249 */
250 static int moveToEditPosition(CDK<UPPER> *widget, int newPosition)
251 {
252 return wmove(widget->fieldWin, 0, widget->fieldWidth - newPosition - 1);
253 }
254
255 /*
256 * Check if the cursor is on a valid edit-position. This must be one of
257 * the non-blank cells in the field.
258 */
259 static int validEditPosition(CDK<UPPER> *widget, int newPosition)
260 {
261 chtype ch;
262 if (newPosition <= 0 || newPosition >= widget->fieldWidth)
263 return FALSE;
264 if (moveToEditPosition(widget, newPosition) == ERR)
265 return FALSE;
266 ch = winch(widget->fieldWin);
267 if (CharOf(ch) != ' ')
268 return TRUE;
269 if (newPosition > 1)
270 {
271 /* don't use recursion - only one level is wanted */
272 if (moveToEditPosition(widget, newPosition - 1) == ERR)
273 return FALSE;
274 ch = winch(widget->fieldWin);
275 return CharOf(ch) != ' ';
276 }
277 return FALSE;
278 }
279
280 /*
281 * Set the edit position. Normally the cursor is one cell to the right of
282 * the editable field. Moving it left, over the field allows the user to
283 * modify cells by typing in replacement characters for the field's value.
284 */
285 static void setEditPosition(CDK<UPPER> *widget, int newPosition)
286 {
287 if (newPosition < 0)
288 {
289 Beep();
290 }
291 else if (newPosition == 0)
292 {
293 widget->fieldEdit = newPosition;
294 }
295 else if (validEditPosition(widget, newPosition))
296 {
297 widget->fieldEdit = newPosition;
298 }
299 else
300 {
301 Beep();
302 }
303 }
304
305 /*
306 * Remove the character from the string at the given column, if it is blank.
307 * Returns true if a change was made.
308 */
309 static bool removeChar(char *string, int col)
310 {
311 bool result = FALSE;
312
313 if ((col >= 0) && (string[col] != ' '))
314 {
315 while (string[col] != '\0')
316 {
317 string[col] = string[col + 1];
318 ++col;
319 }
320 result = TRUE;
321 }
322 return result;
323 }
324
325 /*
326 * Perform an editing function for the field.
327 */
328 static bool performEdit(CDK<UPPER> *widget, chtype input)
329 {
330 bool result = FALSE;
331 bool modify = TRUE;
332 int base = 0;
333 int need = widget->fieldWidth;
334 char *temp = (char *)malloc(need + 2);
335 char test;
336 int col = need - widget->fieldEdit - 1;
337 #if <FLOAT>
338 double value;
339 #define SCANF_FMT "%lg%c"
340 #endif <FLOAT>
341 #if <INT>
342 <CTYPE> value;
343 #define SCANF_FMT "%<PRINT>%c"
344 #endif <INT>
345
346 if (temp != 0)
347 {
348 wmove(widget->fieldWin, 0, base);
349 winnstr(widget->fieldWin, temp, need);
350 strcpy(temp + need, " ");
351 if (isChar(input)) /* replace the char at the cursor */
352 {
353 temp[col] = CharOf(input);
354 }
355 else if (input == KEY_BACKSPACE) /* delete the char before the cursor */
356 {
357 modify = removeChar(temp, col - 1);
358 }
359 else if (input == KEY_DC) /* delete the char at the cursor */
360 {
361 modify = removeChar(temp, col);
362 }
363 else
364 {
365 modify = FALSE;
366 }
367 if (modify
368 && sscanf(temp, SCANF_FMT, &value, &test) == 2
369 && test == ' '
370 && value >= widget->low
371 && value <= widget->high)
372 {
373 setCDK<MIXED>Value(widget, value);
374 result = TRUE;
375 }
376 free(temp);
377 }
378 return result;
379 }
380
381 #define Decrement(value,by) if (value - by < value) value -= by
382 #define Increment(value,by) if (value + by > value) value += by
383
384 /*
385 * This function injects a single character into the widget.
386 */
387 static int _injectCDK<MIXED> (CDKOBJS *object, chtype input)
388 {
389 CDK<UPPER> *widget = (CDK<UPPER> *)object;
390 int ppReturn = 1;
391 <CTYPE> ret = unknown<DTYPE>;
392 bool complete = FALSE;
393
394 /* Set the exit type. */
395 setExitType(widget, 0);
396
397 /* Draw the field. */
398 drawCDK<MIXED>Field (widget);
399
400 /* Check if there is a pre-process function to be called. */
401 if (PreProcessFuncOf(widget) != 0)
402 {
403 /* Call the pre-process function. */
404 ppReturn = PreProcessFuncOf(widget) (v<UPPER>, widget, PreProcessDataOf(widget), input);
405 }
406
407 /* Should we continue? */
408 if (ppReturn != 0)
409 {
410 /* Check for a key binding. */
411 if (checkCDKObjectBind(v<UPPER>, widget, input) != 0)
412 {
413 checkEarlyExit(widget);
414 complete = TRUE;
415 }
416 else
417 {
418 switch (input)
419 {
420 case KEY_LEFT :
421 setEditPosition(widget, widget->fieldEdit + 1);
422 break;
423
424 case KEY_RIGHT :
425 setEditPosition(widget, widget->fieldEdit - 1);
426 break;
427
428 case KEY_DOWN :
429 Decrement(widget->current, widget->inc);
430 break;
431
432 case KEY_UP :
433 Increment(widget->current, widget->inc);
434 break;
435
436 case KEY_PPAGE :
437 Increment(widget->current, widget->fastinc);
438 break;
439
440 case KEY_NPAGE :
441 Decrement(widget->current, widget->fastinc);
442 break;
443
444 case KEY_HOME :
445 widget->current = widget->low;
446 break;
447
448 case KEY_END :
449 widget->current = widget->high;
450 break;
451
452 case KEY_TAB : case KEY_ENTER :
453 setExitType(widget, input);
454 ret = (widget->current);
455 complete = TRUE;
456 break;
457
458 case KEY_ESC :
459 setExitType(widget, input);
460 complete = TRUE;
461 break;
462
463 case CDK_REFRESH :
464 eraseCDKScreen (ScreenOf(widget));
465 refreshCDKScreen (ScreenOf(widget));
466 break;
467
468 default :
469 if (widget->fieldEdit)
470 {
471 if (!performEdit(widget, input))
472 Beep();
473 }
474 else
475 {
476 /*
477 * The cursor is not within the editable text. Interpret
478 * input as commands.
479 */
480 switch (input)
481 {
482 case 'd':
483 case '-':
484 return _injectCDK<MIXED>(object, KEY_DOWN);
485 case '+':
486 return _injectCDK<MIXED>(object, KEY_UP);
487 case 'D':
488 return _injectCDK<MIXED>(object, KEY_NPAGE);
489 case '0':
490 return _injectCDK<MIXED>(object, KEY_HOME);
491 default:
492 Beep();
493 break;
494 }
495 }
496 break;
497 }
498 }
499 limitCurrentValue(widget);
500
501 /* Should we call a post-process? */
502 if (!complete && (PostProcessFuncOf(widget) != 0))
503 {
504 PostProcessFuncOf(widget) (v<UPPER>, widget, PostProcessDataOf(widget), input);
505 }
506 }
507
508 if (!complete) {
509 drawCDK<MIXED>Field (widget);
510 setExitType(widget, 0);
511 }
512
513 ResultOf(widget).value<DTYPE> = ret;
514 return (ret != unknown<DTYPE>);
515 }
516
517 /*
518 * This moves the widget's data field to the given location.
519 */
520 static void _moveCDK<MIXED> (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag)
521 {
522 CDK<UPPER> *widget = (CDK<UPPER> *)object;
523 int currentX = getbegx(widget->win);
524 int currentY = getbegy(widget->win);
525 int xpos = xplace;
526 int ypos = yplace;
527 int xdiff = 0;
528 int ydiff = 0;
529
530 /*
531 * If this is a relative move, then we will adjust where we want
532 * to move to.
533 */
534 if (relative)
535 {
536 xpos = getbegx(widget->win) + xplace;
537 ypos = getbegy(widget->win) + yplace;
538 }
539
540 /* Adjust the window if we need to. */
541 alignxy (WindowOf(widget), &xpos, &ypos, widget->boxWidth, widget->boxHeight);
542
543 /* Get the difference. */
544 xdiff = currentX - xpos;
545 ydiff = currentY - ypos;
546
547 /* Move the window to the new location. */
548 moveCursesWindow(widget->win, -xdiff, -ydiff);
549 moveCursesWindow(widget->labelWin, -xdiff, -ydiff);
550 moveCursesWindow(widget->fieldWin, -xdiff, -ydiff);
551 moveCursesWindow(widget->shadowWin, -xdiff, -ydiff);
552
553 /* Touch the windows so they 'move'. */
554 refreshCDKWindow (WindowOf(widget));
555
556 /* Redraw the window, if they asked for it. */
557 if (refresh_flag)
558 {
559 drawCDK<MIXED> (widget, ObjOf(widget)->box);
560 }
561 }
562
563 /*
564 * This function draws the widget.
565 */
566 static void _drawCDK<MIXED> (CDKOBJS *object, boolean Box)
567 {
568 CDK<UPPER> *widget = (CDK<UPPER> *)object;
569
570 /* Draw the shadow. */
571 if (widget->shadowWin != 0)
572 {
573 drawShadow (widget->shadowWin);
574 }
575
576 /* Box the widget if asked. */
577 if (Box)
578 {
579 drawObjBox (widget->win, ObjOf(widget));
580 }
581
582 drawCdkTitle (widget->win, object);
583
584 /* Draw the label. */
585 if (widget->labelWin != 0)
586 {
587 writeChtype (widget->labelWin, 0, 0,
588 widget->label,
589 HORIZONTAL, 0,
590 widget->labelLen);
591 wrefresh (widget->labelWin);
592 }
593 wrefresh (widget->win);
594
595 /* Draw the field window. */
596 drawCDK<MIXED>Field (widget);
597 }
598
599 /*
600 * This draws the widget.
601 */
602 static void drawCDK<MIXED>Field (CDK<UPPER> *widget)
603 {
604 char temp[256];
605
606 werase (widget->fieldWin);
607
608 /* Draw the value in the field. */
609 #if <FLOAT>
610 {
611 char format[256];
612 int digits = MINIMUM(widget->digits, 30);
613 sprintf (format, "%%.%i<PRINT>", digits);
614 sprintf (temp, format, widget->current);
615 }
616 #endif <FLOAT>
617 #if <INT>
618 sprintf (temp, "%<PRINT>", widget->current);
619 #endif <INT>
620 writeCharAttrib (widget->fieldWin,
621 widget->fieldWidth - (int)strlen(temp) - 1,
622 0,
623 temp,
624 widget->fieldAttr,
625 HORIZONTAL,
626 0,
627 (int)strlen(temp));
628
629 moveToEditPosition(widget, widget->fieldEdit);
630 wrefresh (widget->fieldWin);
631 }
632
633 /*
634 * This sets the background attribute of the widget.
635 */
636 static void _setBKattr<MIXED> (CDKOBJS *object, chtype attrib)
637 {
638 if (object != 0)
639 {
640 CDK<UPPER> *widget = (CDK<UPPER> *)object;
641
642 wbkgd (widget->win, attrib);
643 wbkgd (widget->fieldWin, attrib);
644 if (widget->labelWin != 0)
645 {
646 wbkgd (widget->labelWin, attrib);
647 }
648 }
649 }
650
651 /*
652 * This function destroys the widget.
653 */
654 static void _destroyCDK<MIXED> (CDKOBJS *object)
655 {
656 if (object != 0)
657 {
658 CDK<UPPER> *widget = (CDK<UPPER> *)object;
659
660 cleanCdkTitle (object);
661 freeChtype (widget->label);
662
663 /* Clean up the windows. */
664 deleteCursesWindow (widget->fieldWin);
665 deleteCursesWindow (widget->labelWin);
666 deleteCursesWindow (widget->shadowWin);
667 deleteCursesWindow (widget->win);
668
669 /* Clean the key bindings. */
670 cleanCDKObjectBindings (v<UPPER>, widget);
671
672 /* Unregister this object. */
673 unregisterCDKObject (v<UPPER>, widget);
674 }
675 }
676
677 /*
678 * This function erases the widget from the screen.
679 */
680 static void _eraseCDK<MIXED> (CDKOBJS *object)
681 {
682 if (validCDKObject (object))
683 {
684 CDK<UPPER> *widget = (CDK<UPPER> *)object;
685
686 eraseCursesWindow (widget->labelWin);
687 eraseCursesWindow (widget->fieldWin);
688 eraseCursesWindow (widget->win);
689 eraseCursesWindow (widget->shadowWin);
690 }
691 }
692
693 /*
694 * This function sets the low/high/current values of the widget.
695 */
696 void setCDK<MIXED> (CDK<UPPER> *widget, <CTYPE> low, <CTYPE> high, <CTYPE> value, boolean Box)
697 {
698 setCDK<MIXED>LowHigh (widget, low, high);
699 setCDK<MIXED>Value (widget, value);
700 setCDK<MIXED>Box (widget, Box);
701 }
702
703 /*
704 * This sets the digits.
705 */
706 #if <FLOAT>
707 void setCDK<MIXED>Digits (CDK<UPPER> *widget, int digits)
708 {
709 widget->digits = MAXIMUM (0, digits);
710 }
711
712 int getCDK<MIXED>Digits (CDK<UPPER> *widget)
713 {
714 return widget->digits;
715 }
716 #endif <FLOAT>
717
718 /*
719 * This sets the widget's value.
720 */
721 void setCDK<MIXED>Value (CDK<UPPER> *widget, <CTYPE> value)
722 {
723 widget->current = value;
724 limitCurrentValue(widget);
725 }
726 <CTYPE> getCDK<MIXED>Value (CDK<UPPER> *widget)
727 {
728 return widget->current;
729 }
730
731 /*
732 * This function sets the low/high values of the widget.
733 */
734 void setCDK<MIXED>LowHigh (CDK<UPPER> *widget, <CTYPE> low, <CTYPE> high)
735 {
736 /* Make sure the values aren't out of bounds. */
737 if (low <= high)
738 {
739 widget->low = low;
740 widget->high = high;
741 }
742 else if (low > high)
743 {
744 widget->low = high;
745 widget->high = low;
746 }
747
748 /* Make sure the user hasn't done something silly. */
749 limitCurrentValue(widget);
750 }
751 <CTYPE> getCDK<MIXED>LowValue (CDK<UPPER> *widget)
752 {
753 return widget->low;
754 }
755 <CTYPE> getCDK<MIXED>HighValue (CDK<UPPER> *widget)
756 {
757 return widget->high;
758 }
759
760 /*
761 * This sets the widget's box attribute.
762 */
763 void setCDK<MIXED>Box (CDK<UPPER> *widget, boolean Box)
764 {
765 ObjOf(widget)->box = Box;
766 ObjOf(widget)->borderSize = Box ? 1 : 0;
767 }
768 boolean getCDK<MIXED>Box (CDK<UPPER> *widget)
769 {
770 return ObjOf(widget)->box;
771 }
772
773 static void _focusCDK<MIXED>(CDKOBJS *object)
774 {
775 CDK<UPPER> *widget = (CDK<UPPER> *)object;
776
777 drawCDK<MIXED> (widget, ObjOf(widget)->box);
778 }
779
780 static void _unfocusCDK<MIXED>(CDKOBJS *object)
781 {
782 CDK<UPPER> *widget = (CDK<UPPER> *)object;
783
784 drawCDK<MIXED> (widget, ObjOf(widget)->box);
785 }
786
787 dummyRefreshData(<MIXED>)
788
789 dummySaveData(<MIXED>)
0 #! /bin/sh
1 # $Id: gen-scale.sh,v 1.6 2005/12/28 22:51:52 tom Exp $
2 #
3 # This script generates source variations from scale.c for different datatypes.
4
5 UPPER="$1"
6 MIXED="$2"
7 DTYPE="$3"
8 CTYPE="$4"
9
10 # The widget provides for setting the digits. Turn on/off the corresponding
11 # ifdef.
12 case $CTYPE in
13 float|*double)
14 float=1
15 print=f
16 ;;
17 long*long)
18 float=0
19 print=ll
20 ;;
21 unsigned*long)
22 float=0
23 print=lu
24 ;;
25 unsigned)
26 float=0
27 print=u
28 ;;
29 long)
30 float=0
31 print=l
32 ;;
33 *)
34 float=0
35 print=d
36 ;;
37 esac
38
39 if test "$print" = "d" ; then
40 MODEL=
41 elif test $CTYPE = double; then
42 MODEL="d"
43 else
44 MODEL=$print
45 fi
46
47 if test $float = 0 ; then
48 sed -e '/^#if <FLOAT>/,/^#endif <FLOAT>/d' \
49 -e '/^#if <INT>/d' \
50 -e '/^#endif <INT>/d' \
51 -e 's/<UPPER>/'"$UPPER"'/g' \
52 -e 's/<MIXED>/'"$MIXED"'/g' \
53 -e 's/<DTYPE>/'"$DTYPE"'/g' \
54 -e 's/<CTYPE>/'"$CTYPE"'/g' \
55 -e 's/<MODEL>/'"$MODEL"'/g' \
56 -e 's/<PRINT>/'"$print"'/g' \
57 $5
58 else
59 sed -e '/^#if <INT>/,/^#endif <INT>/d' \
60 -e '/^#if <FLOAT>/d' \
61 -e '/^#endif <FLOAT>/d' \
62 -e 's/<UPPER>/'"$UPPER"'/g' \
63 -e 's/<MIXED>/'"$MIXED"'/g' \
64 -e 's/<DTYPE>/'"$DTYPE"'/g' \
65 -e 's/<CTYPE>/'"$CTYPE"'/g' \
66 -e 's/<MODEL>/'"$MODEL"'/g' \
67 -e 's/<PRINT>/'"$print"'/g' \
68 $5
69 fi
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:44 $
5 * $Revision: 1.19 $
6 */
7
8 /*
9 * Declare file local prototypes.
10 */
11 static void drawCDK<MIXED>Field (CDK<UPPER> *widget);
12 static int formattedSize (CDK<UPPER> *widget, <CTYPE> value);
13
14 DeclareCDKObjects(<UPPER>, <MIXED>, setCdk, <DTYPE>);
15
16 /*
17 * This function creates a widget.
18 */
19 CDK<UPPER> *newCDK<MIXED> (CDKSCREEN *cdkscreen,
20 int xplace,
21 int yplace,
22 char *title,
23 char *label,
24 chtype filler,
25 int fieldWidth,
26 <CTYPE> start,
27 <CTYPE> low,
28 <CTYPE> high,
29 <CTYPE> inc,
30 <CTYPE> fastInc,
31 #if <FLOAT>
32 int digits,
33 #endif <FLOAT>
34 boolean Box,
35 boolean shadow)
36 {
37 CDK<UPPER> *widget = 0;
38 int parentWidth = getmaxx(cdkscreen->window);
39 int parentHeight = getmaxy(cdkscreen->window);
40 int boxHeight;
41 int boxWidth = 0;
42 int horizontalAdjust, oldWidth;
43 int xpos = xplace;
44 int ypos = yplace;
45 int highValueLen;
46 int x, junk;
47
48 static const struct { int from; int to; } bindings[] = {
49 { 'u', KEY_UP },
50 { 'U', KEY_PPAGE },
51 { CDK_BACKCHAR, KEY_PPAGE },
52 { CDK_FORCHAR, KEY_NPAGE },
53 { 'g', KEY_HOME },
54 { '^', KEY_HOME },
55 { 'G', KEY_END },
56 { '$', KEY_END },
57 };
58
59 if ((widget = newCDKObject(CDK<UPPER>, &my_funcs)) == 0)
60 return (0);
61
62 setCDK<MIXED>Box (widget, Box);
63 boxHeight = (BorderOf(widget) * 2) + 1;
64
65 /* Set some basic values of the widget's data field. */
66 widget->label = 0;
67 widget->labelLen = 0;
68 widget->labelWin = 0;
69 #if <FLOAT>
70 widget->digits = digits;
71 #endif <FLOAT>
72 highValueLen = formattedSize (widget, high);
73
74 /*
75 * If the fieldWidth is a negative value, the fieldWidth will
76 * be COLS-fieldWidth, otherwise, the fieldWidth will be the
77 * given width.
78 */
79 fieldWidth = setWidgetDimension (parentWidth, fieldWidth, 0);
80
81 /* Translate the label char *pointer to a chtype pointer. */
82 if (label != 0)
83 {
84 widget->label = char2Chtype (label, &widget->labelLen, &junk);
85 boxWidth = widget->labelLen + fieldWidth + highValueLen + 2 * BorderOf(widget);
86 }
87 else
88 {
89 boxWidth = fieldWidth + highValueLen + 2*BorderOf(widget);
90 }
91
92 oldWidth = boxWidth;
93 boxWidth = setCdkTitle(ObjOf(widget), title, boxWidth);
94 horizontalAdjust = (boxWidth - oldWidth) / 2;
95
96 boxHeight += TitleLinesOf(widget);
97
98 /*
99 * Make sure we didn't extend beyond the dimensions of the window.
100 */
101 boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth);
102 boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight);
103 fieldWidth = (fieldWidth > (boxWidth - widget->labelLen - highValueLen - 1)
104 ? (boxWidth - widget->labelLen - highValueLen - 1)
105 : fieldWidth);
106
107 /* Rejustify the x and y positions if we need to. */
108 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
109
110 /* Make the widget's window. */
111 widget->win = newwin (boxHeight, boxWidth, ypos, xpos);
112
113 /* Is the main window null??? */
114 if (widget->win == 0)
115 {
116 destroyCDKObject(widget);
117 return (0);
118 }
119
120 /* Create the widget's label window. */
121 if (widget->label != 0)
122 {
123 widget->labelWin = subwin (widget->win,
124 1, widget->labelLen,
125 ypos + TitleLinesOf(widget) + BorderOf(widget),
126 xpos + horizontalAdjust + BorderOf(widget));
127 if (widget->labelWin == 0)
128 {
129 destroyCDKObject(widget);
130 return (0);
131 }
132 }
133
134 /* Create the widget's data field window. */
135 widget->fieldWin = subwin (widget->win,
136 1, fieldWidth + highValueLen - 1,
137 ypos + TitleLinesOf(widget) + BorderOf(widget),
138 xpos + widget->labelLen + horizontalAdjust + BorderOf(widget));
139 if (widget->fieldWin == 0)
140 {
141 destroyCDKObject(widget);
142 return (0);
143 }
144 keypad (widget->fieldWin, TRUE);
145 keypad (widget->win, TRUE);
146
147 /* Create the widget's data field. */
148 ScreenOf(widget) = cdkscreen;
149 widget->parent = cdkscreen->window;
150 widget->shadowWin = 0;
151 widget->boxWidth = boxWidth;
152 widget->boxHeight = boxHeight;
153 widget->fieldWidth = fieldWidth-1;
154 widget->filler = filler;
155 widget->low = low;
156 widget->high = high;
157 widget->current = start;
158 widget->inc = inc;
159 widget->fastinc = fastInc;
160 initExitType(widget);
161 ObjOf(widget)->acceptsFocus = TRUE;
162 ObjOf(widget)->inputWindow = widget->win;
163 widget->shadow = shadow;
164
165 /* Set the start value. */
166 if (start < low)
167 {
168 widget->current = low;
169 }
170
171 /* Do we want a shadow??? */
172 if (shadow)
173 {
174 widget->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
175 if (widget->shadowWin == 0)
176 {
177 destroyCDKObject(widget);
178 return (0);
179 }
180 }
181
182 /* Setup the key bindings. */
183 for (x = 0; x < (int) SIZEOF(bindings); ++x)
184 bindCDKObject (v<UPPER>, widget, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to);
185
186 registerCDKObject (cdkscreen, v<UPPER>, widget);
187
188 return (widget);
189 }
190
191 /*
192 * This allows the person to use the widget's data field.
193 */
194 <CTYPE> activateCDK<MIXED> (CDK<UPPER> *widget, chtype *actions)
195 {
196 <CTYPE> ret;
197
198 /* Draw the widget. */
199 drawCDK<MIXED> (widget, ObjOf(widget)->box);
200
201 if (actions == 0)
202 {
203 chtype input = 0;
204 boolean functionKey;
205
206 for (;;)
207 {
208 input = getchCDKObject (ObjOf(widget), &functionKey);
209
210 /* Inject the character into the widget. */
211 ret = injectCDK<MIXED> (widget, input);
212 if (widget->exitType != vEARLY_EXIT)
213 {
214 return ret;
215 }
216 }
217 }
218 else
219 {
220 int length = chlen (actions);
221 int x = 0;
222
223 /* Inject each character one at a time. */
224 for (x=0; x < length; x++)
225 {
226 ret = injectCDK<MIXED> (widget, actions[x]);
227 if (widget->exitType != vEARLY_EXIT)
228 {
229 return ret;
230 }
231 }
232 }
233
234 /* Set the exit type and return. */
235 setExitType(widget, 0);
236 return unknown<DTYPE>;
237 }
238
239 /*
240 * Check if the value lies outside the low/high range. If so, force it in.
241 */
242 static void limitCurrentValue (CDK<UPPER> *widget)
243 {
244 if (widget->current < widget->low)
245 {
246 widget->current = widget->low;
247 Beep();
248 }
249 else if (widget->current > widget->high)
250 {
251 widget->current = widget->high;
252 Beep();
253 }
254 }
255
256 /*
257 * Move the cursor to the given edit-position.
258 */
259 static int moveToEditPosition(CDK<UPPER> *widget, int newPosition)
260 {
261 return wmove(widget->fieldWin,
262 0,
263 widget->fieldWidth +
264 formattedSize(widget, widget->current) -
265 newPosition);
266 }
267
268 /*
269 * Check if the cursor is on a valid edit-position. This must be one of
270 * the non-blank cells in the field.
271 */
272 static int validEditPosition(CDK<UPPER> *widget, int newPosition)
273 {
274 chtype ch;
275 if (newPosition <= 0 || newPosition >= widget->fieldWidth)
276 return FALSE;
277 if (moveToEditPosition(widget, newPosition) == ERR)
278 return FALSE;
279 ch = winch(widget->fieldWin);
280 if (CharOf(ch) != ' ')
281 return TRUE;
282 if (newPosition > 1)
283 {
284 /* don't use recursion - only one level is wanted */
285 if (moveToEditPosition(widget, newPosition - 1) == ERR)
286 return FALSE;
287 ch = winch(widget->fieldWin);
288 return CharOf(ch) != ' ';
289 }
290 return FALSE;
291 }
292
293 /*
294 * Set the edit position. Normally the cursor is one cell to the right of
295 * the editable field. Moving it left, over the field allows the user to
296 * modify cells by typing in replacement characters for the field's value.
297 */
298 static void setEditPosition(CDK<UPPER> *widget, int newPosition)
299 {
300 if (newPosition < 0)
301 {
302 Beep();
303 }
304 else if (newPosition == 0)
305 {
306 widget->fieldEdit = newPosition;
307 }
308 else if (validEditPosition(widget, newPosition))
309 {
310 widget->fieldEdit = newPosition;
311 }
312 else
313 {
314 Beep();
315 }
316 }
317
318 /*
319 * Remove the character from the string at the given column, if it is blank.
320 * Returns true if a change was made.
321 */
322 static bool removeChar(char *string, int col)
323 {
324 bool result = FALSE;
325
326 if ((col >= 0) && (string[col] != ' '))
327 {
328 while (string[col] != '\0')
329 {
330 string[col] = string[col + 1];
331 ++col;
332 }
333 result = TRUE;
334 }
335 return result;
336 }
337
338 /*
339 * Perform an editing function for the field.
340 */
341 static bool performEdit(CDK<UPPER> *widget, chtype input)
342 {
343 bool result = FALSE;
344 bool modify = TRUE;
345 int base = widget->fieldWidth;
346 int need = formattedSize(widget, widget->current);
347 char *temp = (char *)malloc(need + 5);
348 char *data = temp;
349 char test;
350 int col = need - widget->fieldEdit;
351 #if <FLOAT>
352 double value;
353 #define SCANF_FMT "%lg%c"
354 #endif <FLOAT>
355 #if <INT>
356 <CTYPE> value;
357 #define SCANF_FMT "%<PRINT>%c"
358 #endif <INT>
359
360 if (temp != 0)
361 {
362 int adj = (col < 0) ? (-col) : 0;
363 if (adj)
364 {
365 memset(temp, ' ', adj);
366 temp += adj;
367 }
368 wmove(widget->fieldWin, 0, base);
369 winnstr(widget->fieldWin, temp, need);
370 strcpy(temp + need, " ");
371 if (isChar(input)) /* replace the char at the cursor */
372 {
373 temp[col] = CharOf(input);
374 }
375 else if (input == KEY_BACKSPACE) /* delete the char before the cursor */
376 {
377 modify = removeChar(temp, col - 1);
378 }
379 else if (input == KEY_DC) /* delete the char at the cursor */
380 {
381 modify = removeChar(temp, col);
382 }
383 else
384 {
385 modify = FALSE;
386 }
387 if (modify
388 && sscanf(temp, SCANF_FMT, &value, &test) == 2
389 && test == ' '
390 && value >= widget->low
391 && value <= widget->high)
392 {
393 setCDK<MIXED>Value(widget, value);
394 result = TRUE;
395 }
396 free(data);
397 }
398 return result;
399 }
400
401 #define Decrement(value,by) if (value - by < value) value -= by
402 #define Increment(value,by) if (value + by > value) value += by
403
404 /*
405 * This function injects a single character into the widget.
406 */
407 static int _injectCDK<MIXED> (CDKOBJS *object, chtype input)
408 {
409 CDK<UPPER> *widget = (CDK<UPPER> *)object;
410 int ppReturn = 1;
411 <CTYPE> ret = unknown<DTYPE>;
412 bool complete = FALSE;
413
414 /* Set the exit type. */
415 setExitType(widget, 0);
416
417 /* Draw the field. */
418 drawCDK<MIXED>Field (widget);
419
420 /* Check if there is a pre-process function to be called. */
421 if (PreProcessFuncOf(widget) != 0)
422 {
423 /* Call the pre-process function. */
424 ppReturn = PreProcessFuncOf(widget) (v<UPPER>, widget, PreProcessDataOf(widget), input);
425 }
426
427 /* Should we continue? */
428 if (ppReturn != 0)
429 {
430 /* Check for a key binding. */
431 if (checkCDKObjectBind(v<UPPER>, widget, input) != 0)
432 {
433 checkEarlyExit(widget);
434 complete = TRUE;
435 }
436 else
437 {
438 switch (input)
439 {
440 case KEY_LEFT :
441 setEditPosition(widget, widget->fieldEdit + 1);
442 break;
443
444 case KEY_RIGHT :
445 setEditPosition(widget, widget->fieldEdit - 1);
446 break;
447
448 case KEY_DOWN :
449 Decrement(widget->current, widget->inc);
450 break;
451
452 case KEY_UP :
453 Increment(widget->current, widget->inc);
454 break;
455
456 case KEY_PPAGE :
457 Increment(widget->current, widget->fastinc);
458 break;
459
460 case KEY_NPAGE :
461 Decrement(widget->current, widget->fastinc);
462 break;
463
464 case KEY_HOME :
465 widget->current = widget->low;
466 break;
467
468 case KEY_END :
469 widget->current = widget->high;
470 break;
471
472 case KEY_TAB : case KEY_ENTER :
473 setExitType(widget, input);
474 ret = (widget->current);
475 complete = TRUE;
476 break;
477
478 case KEY_ESC :
479 setExitType(widget, input);
480 complete = TRUE;
481 break;
482
483 case CDK_REFRESH :
484 eraseCDKScreen (ScreenOf(widget));
485 refreshCDKScreen (ScreenOf(widget));
486 break;
487
488 default :
489 if (widget->fieldEdit)
490 {
491 if (!performEdit(widget, input))
492 Beep();
493 }
494 else
495 {
496 /*
497 * The cursor is not within the editable text. Interpret
498 * input as commands.
499 */
500 switch (input)
501 {
502 case 'd':
503 case '-':
504 return _injectCDK<MIXED>(object, KEY_DOWN);
505 case '+':
506 return _injectCDK<MIXED>(object, KEY_UP);
507 case 'D':
508 return _injectCDK<MIXED>(object, KEY_NPAGE);
509 case '0':
510 return _injectCDK<MIXED>(object, KEY_HOME);
511 default:
512 Beep();
513 break;
514 }
515 }
516 break;
517 }
518 }
519 limitCurrentValue(widget);
520
521 /* Should we call a post-process? */
522 if (!complete && (PostProcessFuncOf(widget) != 0))
523 {
524 PostProcessFuncOf(widget) (v<UPPER>, widget, PostProcessDataOf(widget), input);
525 }
526 }
527
528 if (!complete) {
529 drawCDK<MIXED>Field (widget);
530 setExitType(widget, 0);
531 }
532
533 ResultOf(widget).value<DTYPE> = ret;
534 return (ret != unknown<DTYPE>);
535 }
536
537 /*
538 * This moves the widget's data field to the given location.
539 */
540 static void _moveCDK<MIXED> (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag)
541 {
542 CDK<UPPER> *widget = (CDK<UPPER> *)object;
543 int currentX = getbegx(widget->win);
544 int currentY = getbegy(widget->win);
545 int xpos = xplace;
546 int ypos = yplace;
547 int xdiff = 0;
548 int ydiff = 0;
549
550 /*
551 * If this is a relative move, then we will adjust where we want
552 * to move to.
553 */
554 if (relative)
555 {
556 xpos = getbegx(widget->win) + xplace;
557 ypos = getbegy(widget->win) + yplace;
558 }
559
560 /* Adjust the window if we need to. */
561 alignxy (WindowOf(widget), &xpos, &ypos, widget->boxWidth, widget->boxHeight);
562
563 /* Get the difference. */
564 xdiff = currentX - xpos;
565 ydiff = currentY - ypos;
566
567 /* Move the window to the new location. */
568 moveCursesWindow(widget->win, -xdiff, -ydiff);
569 moveCursesWindow(widget->labelWin, -xdiff, -ydiff);
570 moveCursesWindow(widget->fieldWin, -xdiff, -ydiff);
571 moveCursesWindow(widget->shadowWin, -xdiff, -ydiff);
572
573 /* Touch the windows so they 'move'. */
574 refreshCDKWindow (WindowOf(widget));
575
576 /* Redraw the window, if they asked for it. */
577 if (refresh_flag)
578 {
579 drawCDK<MIXED> (widget, ObjOf(widget)->box);
580 }
581 }
582
583 /*
584 * This function draws the widget.
585 */
586 static void _drawCDK<MIXED> (CDKOBJS *object, boolean Box)
587 {
588 CDK<UPPER> *widget = (CDK<UPPER> *)object;
589
590 /* Draw the shadow. */
591 if (widget->shadowWin != 0)
592 {
593 drawShadow (widget->shadowWin);
594 }
595
596 /* Box the widget if asked. */
597 if (Box)
598 {
599 drawObjBox (widget->win, ObjOf(widget));
600 }
601
602 drawCdkTitle (widget->win, object);
603
604 /* Draw the label. */
605 if (widget->labelWin != 0)
606 {
607 writeChtype (widget->labelWin, 0, 0,
608 widget->label,
609 HORIZONTAL, 0,
610 widget->labelLen);
611 wrefresh (widget->labelWin);
612 }
613 wrefresh (widget->win);
614
615 /* Draw the field window. */
616 drawCDK<MIXED>Field (widget);
617 }
618
619 /*
620 * This draws the widget.
621 */
622 static void drawCDK<MIXED>Field (CDK<UPPER> *widget)
623 {
624 int fillerCharacters, x;
625 char temp[256];
626 float step = ((float)widget->fieldWidth
627 / (float)(widget->high - widget->low));
628
629 /* Determine how many filler characters need to be drawn. */
630 fillerCharacters = (int)((widget->current - widget->low) * step);
631
632 werase (widget->fieldWin);
633
634 /* Add the character to the window. */
635 for (x=0; x < fillerCharacters; x++)
636 {
637 mvwaddch (widget->fieldWin, 0, x, widget->filler);
638 }
639
640 /* Draw the value in the field. */
641 #if <FLOAT>
642 {
643 char format[256];
644 int digits = MINIMUM(widget->digits, 30);
645 sprintf (format, "%%.%i<PRINT>", digits);
646 sprintf (temp, format, widget->current);
647 }
648 #endif <FLOAT>
649 #if <INT>
650 sprintf (temp, "%<PRINT>", widget->current);
651 #endif <INT>
652 writeCharAttrib (widget->fieldWin,
653 widget->fieldWidth,
654 0,
655 temp,
656 A_NORMAL,
657 HORIZONTAL,
658 0,
659 (int)strlen(temp));
660
661 moveToEditPosition(widget, widget->fieldEdit);
662 wrefresh (widget->fieldWin);
663 }
664
665 /*
666 * This sets the background attribute of the widget.
667 */
668 static void _setBKattr<MIXED> (CDKOBJS *object, chtype attrib)
669 {
670 if (object != 0)
671 {
672 CDK<UPPER> *widget = (CDK<UPPER> *)object;
673
674 /* Set the widgets background attribute. */
675 wbkgd (widget->win, attrib);
676 wbkgd (widget->fieldWin, attrib);
677 if (widget->labelWin != 0)
678 {
679 wbkgd (widget->labelWin, attrib);
680 }
681 }
682 }
683
684 /*
685 * This function destroys the widget.
686 */
687 static void _destroyCDK<MIXED> (CDKOBJS *object)
688 {
689 if (object != 0)
690 {
691 CDK<UPPER> *widget = (CDK<UPPER> *)object;
692
693 cleanCdkTitle (object);
694 freeChtype (widget->label);
695
696 /* Clean up the windows. */
697 deleteCursesWindow (widget->fieldWin);
698 deleteCursesWindow (widget->labelWin);
699 deleteCursesWindow (widget->shadowWin);
700 deleteCursesWindow (widget->win);
701
702 /* Clean the key bindings. */
703 cleanCDKObjectBindings (v<UPPER>, widget);
704
705 /* Unregister this object. */
706 unregisterCDKObject (v<UPPER>, widget);
707 }
708 }
709
710 /*
711 * This function erases the widget from the screen.
712 */
713 static void _eraseCDK<MIXED> (CDKOBJS *object)
714 {
715 if (validCDKObject (object))
716 {
717 CDK<UPPER> *widget = (CDK<UPPER> *)object;
718
719 eraseCursesWindow (widget->labelWin);
720 eraseCursesWindow (widget->fieldWin);
721 eraseCursesWindow (widget->win);
722 eraseCursesWindow (widget->shadowWin);
723 }
724 }
725
726 static int formattedSize (CDK<UPPER> *widget, <CTYPE> value)
727 {
728 char temp[256];
729 #if <FLOAT>
730 char format[256];
731 int digits = MINIMUM(widget->digits, 30);
732 sprintf (format, "%%.%i<PRINT>", digits);
733 sprintf (temp, format, value);
734 #endif <FLOAT>
735 #if <INT>
736 (void) widget;
737 sprintf (temp, "%<PRINT>", value);
738 #endif <INT>
739 return strlen (temp);
740 }
741
742 /*
743 * This function sets the low/high/current values of the widget.
744 */
745 void setCDK<MIXED> (CDK<UPPER> *widget, <CTYPE> low, <CTYPE> high, <CTYPE> value, boolean Box)
746 {
747 setCDK<MIXED>LowHigh (widget, low, high);
748 setCDK<MIXED>Value (widget, value);
749 setCDK<MIXED>Box (widget, Box);
750 }
751
752 /*
753 * This sets the digits.
754 */
755 #if <FLOAT>
756 void setCDK<MIXED>Digits (CDK<UPPER> *widget, int digits)
757 {
758 widget->digits = MAXIMUM (0, digits);
759 }
760
761 int getCDK<MIXED>Digits (CDK<UPPER> *widget)
762 {
763 return widget->digits;
764 }
765 #endif <FLOAT>
766
767 /*
768 * This sets the widget's value.
769 */
770 void setCDK<MIXED>Value (CDK<UPPER> *widget, <CTYPE> value)
771 {
772 widget->current = value;
773 limitCurrentValue(widget);
774 }
775 <CTYPE> getCDK<MIXED>Value (CDK<UPPER> *widget)
776 {
777 return widget->current;
778 }
779
780 /*
781 * This function sets the low/high values of the widget.
782 */
783 void setCDK<MIXED>LowHigh (CDK<UPPER> *widget, <CTYPE> low, <CTYPE> high)
784 {
785 /* Make sure the values aren't out of bounds. */
786 if (low <= high)
787 {
788 widget->low = low;
789 widget->high = high;
790 }
791 else if (low > high)
792 {
793 widget->low = high;
794 widget->high = low;
795 }
796
797 /* Make sure the user hasn't done something silly. */
798 limitCurrentValue(widget);
799 }
800 <CTYPE> getCDK<MIXED>LowValue (CDK<UPPER> *widget)
801 {
802 return widget->low;
803 }
804 <CTYPE> getCDK<MIXED>HighValue (CDK<UPPER> *widget)
805 {
806 return widget->high;
807 }
808
809 /*
810 * This sets the widget's box attribute.
811 */
812 void setCDK<MIXED>Box (CDK<UPPER> *widget, boolean Box)
813 {
814 ObjOf(widget)->box = Box;
815 ObjOf(widget)->borderSize = Box ? 1 : 0;
816 }
817 boolean getCDK<MIXED>Box (CDK<UPPER> *widget)
818 {
819 return ObjOf(widget)->box;
820 }
821
822 static void _focusCDK<MIXED>(CDKOBJS *object)
823 {
824 CDK<UPPER> *widget = (CDK<UPPER> *)object;
825
826 drawCDK<MIXED> (widget, ObjOf(widget)->box);
827 }
828
829 static void _unfocusCDK<MIXED>(CDKOBJS *object)
830 {
831 CDK<UPPER> *widget = (CDK<UPPER> *)object;
832
833 drawCDK<MIXED> (widget, ObjOf(widget)->box);
834 }
835
836 dummyRefreshData(<MIXED>)
837
838 dummySaveData(<MIXED>)
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2003/11/27 22:13:46 $
5 * $Revision: 1.1 $
6 */
7
8 /*
9 * This returns a selected value in a list.
10 */
11 int getListIndex (CDKSCREEN *screen, char *title, char **list, int listSize, boolean numbers)
12 {
13 CDKSCROLL *scrollp = 0;
14 int selected = -1;
15 int height = 10;
16 int width = -1;
17 int len = 0;
18 int x;
19
20 /* Determine the height of the list. */
21 if (listSize < 10)
22 {
23 height = listSize + (title == 0 ? 2 : 3);
24 }
25
26 /* Determine the width of the list. */
27 for (x=0; x < listSize; x++)
28 {
29 int temp = strlen (list[x]) + 10;
30 width = MAXIMUM (width, temp);
31 }
32 if (title != 0)
33 {
34 len = strlen (title);
35 }
36 width = MAXIMUM (width, len);
37 width += 5;
38
39 /* Create the scrolling list. */
40 scrollp = newCDKScroll (screen, CENTER, CENTER, RIGHT,
41 height, width, title,
42 list, listSize, numbers,
43 A_REVERSE, TRUE, FALSE);
44
45 /* Check if we made the list. */
46 if (scrollp == 0)
47 {
48 refreshCDKScreen (screen);
49 return -1;
50 }
51
52 /* Let the user play. */
53 selected = activateCDKScroll (scrollp, 0);
54
55 /* Check how they exited. */
56 if (scrollp->exitType != vNORMAL)
57 {
58 selected = -1;
59 }
60
61 /* Clean up. */
62 destroyCDKScroll (scrollp);
63 refreshCDKScreen (screen);
64 return selected;
65 }
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2003/11/27 22:13:28 $
5 * $Revision: 1.1 $
6 */
7
8 /*
9 * This gets information from a user.
10 */
11 char *getString (CDKSCREEN *screen, char *title, char *label, char *initValue)
12 {
13 CDKENTRY *widget = 0;
14 char *value = 0;
15
16 /* Create the widget. */
17 widget = newCDKEntry (screen, CENTER, CENTER, title, label,
18 A_NORMAL, '.', vMIXED, 40, 0,
19 5000, TRUE, FALSE);
20
21 /* Set the default value. */
22 setCDKEntryValue (widget, initValue);
23
24 /* Get the string. */
25 value = activateCDKEntry (widget, 0);
26
27 /* Make sure they exited normally. */
28 if (widget->exitType != vNORMAL)
29 {
30 destroyCDKEntry (widget);
31 return 0;
32 }
33
34 /* Return a copy of the string typed in. */
35 value = copyChar (getCDKEntryValue (widget));
36 destroyCDKEntry (widget);
37 return value;
38 }
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:44 $
5 * $Revision: 1.82 $
6 */
7
8 DeclareCDKObjects (GRAPH, Graph, setCdk, Unknown);
9
10 #define TITLE_LM 3
11
12 /*
13 * Create a graph widget.
14 */
15 CDKGRAPH *newCDKGraph (CDKSCREEN *cdkscreen,
16 int xplace,
17 int yplace,
18 int height,
19 int width,
20 char *title,
21 char *xtitle,
22 char *ytitle)
23 {
24 CDKGRAPH *widget = 0;
25 int parentWidth = getmaxx (cdkscreen->window);
26 int parentHeight = getmaxy (cdkscreen->window);
27 int boxWidth = width;
28 int boxHeight = height;
29 int xpos = xplace;
30 int ypos = yplace;
31
32 if ((widget = newCDKObject (CDKGRAPH, &my_funcs)) == 0)
33 return (0);
34
35 setCDKGraphBox (widget, FALSE);
36
37 boxHeight = setWidgetDimension (parentHeight, height, 3);
38 boxWidth = setWidgetDimension (parentWidth, width, 0);
39
40 boxWidth = setCdkTitle (ObjOf (widget), title, boxWidth);
41
42 boxHeight += TitleLinesOf (widget);
43
44 boxWidth = MINIMUM (boxWidth, parentWidth);
45 boxHeight = MINIMUM (boxHeight, parentHeight);
46
47 /* Rejustify the x and y positions if we need to. */
48 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
49
50 /* Create the widget pointer. */
51 ScreenOf (widget) = cdkscreen;
52 widget->parent = cdkscreen->window;
53 widget->win = newwin (boxHeight, boxWidth, ypos, xpos);
54 widget->boxHeight = boxHeight;
55 widget->boxWidth = boxWidth;
56 widget->minx = 0;
57 widget->maxx = 0;
58 widget->xscale = 0;
59 widget->yscale = 0;
60 widget->count = 0;
61 widget->displayType = vLINE;
62
63 if (widget->win == 0)
64 {
65 destroyCDKObject (widget);
66 return (0);
67 }
68 keypad (widget->win, TRUE);
69
70 /* Translate the X Axis title char * to a chtype * */
71 if (xtitle != 0)
72 {
73 widget->xtitle = char2Chtype (xtitle, &widget->xtitleLen, &widget->xtitlePos);
74 widget->xtitlePos = justifyString (widget->boxHeight, widget->xtitleLen, widget->xtitlePos);
75 }
76 else
77 {
78 widget->xtitle = char2Chtype ("<C></5>X Axis", &widget->xtitleLen, &widget->xtitlePos);
79 widget->xtitlePos = justifyString (widget->boxHeight, widget->xtitleLen, widget->xtitlePos);
80 }
81
82 /* Translate the Y Axis title char * to a chtype * */
83 if (ytitle != 0)
84 {
85 widget->ytitle = char2Chtype (ytitle, &widget->ytitleLen, &widget->ytitlePos);
86 widget->ytitlePos = justifyString (widget->boxWidth, widget->ytitleLen, widget->ytitlePos);
87 }
88 else
89 {
90 widget->ytitle = char2Chtype ("<C></5>Y Axis", &widget->ytitleLen, &widget->ytitlePos);
91 widget->ytitlePos = justifyString (widget->boxWidth, widget->ytitleLen, widget->ytitlePos);
92 }
93
94 widget->graphChar = 0;
95
96 registerCDKObject (cdkscreen, vGRAPH, widget);
97
98 return (widget);
99 }
100
101 /*
102 * This was added for the builder.
103 */
104 void activateCDKGraph (CDKGRAPH *widget, chtype *actions GCC_UNUSED)
105 {
106 drawCDKGraph (widget, ObjOf (widget)->box);
107 }
108
109 /*
110 * Set multiple attributes of the widget.
111 */
112 int setCDKGraph (CDKGRAPH *widget,
113 int *values,
114 int count,
115 char *graphChar,
116 boolean startAtZero,
117 EGraphDisplayType displayType)
118 {
119 int ret;
120
121 ret = setCDKGraphValues (widget, values, count, startAtZero);
122 setCDKGraphCharacters (widget, graphChar);
123 setCDKGraphDisplayType (widget, displayType);
124 return ret;
125 }
126
127 /*
128 * Set the scale factors for the graph after we have loaded new values.
129 */
130 static void setScales (CDKGRAPH *widget)
131 {
132 widget->xscale = ((widget->maxx - widget->minx)
133 / MAXIMUM (1, (widget->boxHeight - TitleLinesOf (widget) - 5)));
134 if (widget->xscale <= 0)
135 widget->xscale = 1;
136
137 widget->yscale = ((widget->boxWidth-4) / MAXIMUM (1, widget->count));
138 if (widget->yscale <= 0)
139 widget->yscale = 1;
140 }
141
142 /*
143 * Set the values of the graph.
144 */
145 int setCDKGraphValues (CDKGRAPH *widget, int *values, int count, boolean startAtZero)
146 {
147 int min = INT_MAX;
148 int max = INT_MIN;
149 int x;
150
151 /* Make sure everything is happy. */
152 if (count < 0)
153 return (FALSE);
154
155 if (widget->values != 0)
156 {
157 free (widget->values);
158 widget->values = 0;
159 widget->count = 0;
160 }
161 if ((widget->values = typeCallocN (int, count + 1)) == 0)
162 return FALSE;
163
164 /* Copy the X values. */
165 for (x = 0; x < count; x++)
166 {
167 /* Determine the min/max values of the graph. */
168 min = MINIMUM (values[x], widget->minx);
169 max = MAXIMUM (values[x], widget->maxx);
170
171 /* Copy the value. */
172 widget->values[x] = values[x];
173 }
174
175 /* Keep the count and min/max values. */
176 widget->count = count;
177 widget->minx = min;
178 widget->maxx = max;
179
180 /* Check the start at zero status. */
181 if (startAtZero)
182 {
183 widget->minx = 0;
184 }
185
186 setScales (widget);
187
188 return (TRUE);
189 }
190 int *getCDKGraphValues (CDKGRAPH *widget, int *size)
191 {
192 (*size) = widget->count;
193 return widget->values;
194 }
195
196 /*
197 * Set the value of the graph at the given index.
198 */
199 int setCDKGraphValue (CDKGRAPH *widget, int Index, int value, boolean startAtZero)
200 {
201 /* Make sure the index is within range. */
202 if (Index < 0 || Index >= widget->count)
203 {
204 return (FALSE);
205 }
206
207 /* Set the min, max, and value for the graph. */
208 widget->minx = MINIMUM (value, widget->minx);
209 widget->maxx = MAXIMUM (value, widget->maxx);
210 widget->values[Index] = value;
211
212 /* Check the start at zero status. */
213 if (startAtZero)
214 {
215 widget->minx = 0;
216 }
217
218 setScales (widget);
219
220 return (TRUE);
221 }
222 int getCDKGraphValue (CDKGRAPH *widget, int Index)
223 {
224 return Index >= 0 && Index < widget->count ? widget->values[Index] : 0;
225 }
226
227 /*
228 * Set the characters of the graph widget.
229 */
230 int setCDKGraphCharacters (CDKGRAPH *widget, char *characters)
231 {
232 chtype *newTokens = 0;
233 int charCount, junk;
234
235 newTokens = char2Chtype (characters, &charCount, &junk);
236
237 if (charCount != widget->count)
238 {
239 freeChtype (newTokens);
240 return (FALSE);
241 }
242
243 freeChtype (widget->graphChar);
244 widget->graphChar = newTokens;
245 return (TRUE);
246 }
247 chtype *getCDKGraphCharacters (CDKGRAPH *widget)
248 {
249 return widget->graphChar;
250 }
251
252 /*
253 * Set the character of the graph widget of the given index.
254 */
255 int setCDKGraphCharacter (CDKGRAPH *widget, int Index, char *character)
256 {
257 chtype *newTokens = 0;
258 int charCount, junk;
259
260 /* Make sure the index is within range. */
261 if (Index < 0 || Index > widget->count)
262 {
263 return (FALSE);
264 }
265
266 /* Convert the string given to us. */
267 newTokens = char2Chtype (character, &charCount, &junk);
268
269 /*
270 * Check if the number of characters back is the same as the number
271 * of elements in the list.
272 */
273 if (charCount != widget->count)
274 {
275 freeChtype (newTokens);
276 return (FALSE);
277 }
278
279 /* Everything OK so far. Set the value of the array. */
280 widget->graphChar[Index] = newTokens[0];
281 freeChtype (newTokens);
282 return (TRUE);
283 }
284 chtype getCDKGraphCharacter (CDKGRAPH *widget, int Index)
285 {
286 return widget->graphChar[Index];
287 }
288
289 /*
290 * Set the display type of the graph.
291 */
292 void setCDKGraphDisplayType (CDKGRAPH *widget, EGraphDisplayType type)
293 {
294 widget->displayType = type;
295 }
296 EGraphDisplayType getCDKGraphDisplayType (CDKGRAPH *widget)
297 {
298 return widget->displayType;
299 }
300
301 /*
302 * Set the background attribute of the widget.
303 */
304 static void _setBKattrGraph (CDKOBJS *object, chtype attrib)
305 {
306 if (object != 0)
307 {
308 CDKGRAPH *widget = (CDKGRAPH *)object;
309
310 wbkgd (widget->win, attrib);
311 }
312 }
313
314 /*
315 * Move the graph field to the given location.
316 */
317 static void _moveCDKGraph (CDKOBJS *object,
318 int xplace,
319 int yplace,
320 boolean relative,
321 boolean refresh_flag)
322 {
323 CDKGRAPH *widget = (CDKGRAPH *)object;
324 int currentX = getbegx (widget->win);
325 int currentY = getbegy (widget->win);
326 int xpos = xplace;
327 int ypos = yplace;
328 int xdiff = 0;
329 int ydiff = 0;
330
331 /*
332 * If this is a relative move, then we will adjust where we want
333 * to move to.
334 */
335 if (relative)
336 {
337 xpos = getbegx (widget->win) + xplace;
338 ypos = getbegy (widget->win) + yplace;
339 }
340
341 /* Adjust the window if we need to. */
342 alignxy (WindowOf (widget), &xpos, &ypos, widget->boxWidth, widget->boxHeight);
343
344 /* Get the difference. */
345 xdiff = currentX - xpos;
346 ydiff = currentY - ypos;
347
348 /* Move the window to the new location. */
349 moveCursesWindow (widget->win, -xdiff, -ydiff);
350 moveCursesWindow (widget->shadowWin, -xdiff, -ydiff);
351
352 /* Touch the windows so they 'move'. */
353 refreshCDKWindow (WindowOf (widget));
354
355 /* Redraw the window, if they asked for it. */
356 if (refresh_flag)
357 {
358 drawCDKGraph (widget, ObjOf (widget)->box);
359 }
360 }
361
362 /*
363 * Set whether or not the graph will be boxed.
364 */
365 void setCDKGraphBox (CDKGRAPH *widget, boolean Box)
366 {
367 ObjOf (widget)->box = Box;
368 ObjOf (widget)->borderSize = Box ? 1 : 0;
369 }
370 boolean getCDKGraphBox (CDKGRAPH *widget)
371 {
372 return ObjOf (widget)->box;
373 }
374
375 /*
376 * Draw the graph widget.
377 */
378 static void _drawCDKGraph (CDKOBJS *object, boolean Box)
379 {
380 CDKGRAPH *widget = (CDKGRAPH *)object;
381 int adj = 2 + (widget->xtitle == 0 ? 0 : 1);
382 int spacing = 0;
383 chtype attrib = ' ' | A_REVERSE;
384 char temp[100];
385 int x, y, xpos, ypos, len;
386
387 /* Box it if needed. */
388 if (Box)
389 {
390 drawObjBox (widget->win, ObjOf (widget));
391 }
392
393 /* Draw in the vertical axis. */
394 drawLine (widget->win, 2, TitleLinesOf (widget) + 1, 2, widget->boxHeight - 3, ACS_VLINE);
395
396 /* Draw in the horizontal axis. */
397 drawLine (widget->win, 3, widget->boxHeight-3, widget->boxWidth, widget->boxHeight - 3, ACS_HLINE);
398
399 drawCdkTitle (widget->win, object);
400
401 /* Draw in the X axis title. */
402 if (widget->xtitle != 0)
403 {
404 writeChtype (widget->win, 0, widget->xtitlePos, widget->xtitle, VERTICAL, 0, widget->xtitleLen);
405 attrib = widget->xtitle[0] & A_ATTRIBUTES;
406 }
407
408 /* Draw in the X axis high value. */
409 sprintf (temp, "%d", widget->maxx);
410 len = (int)strlen (temp);
411 writeCharAttrib (widget->win, 1, TitleLinesOf (widget) + 1, temp, attrib, VERTICAL, 0, len);
412
413 /* Draw in the X axis low value. */
414 sprintf (temp, "%d", widget->minx);
415 len = (int)strlen (temp);
416 writeCharAttrib (widget->win, 1, widget->boxHeight - 2 - len, temp, attrib, VERTICAL, 0, len);
417
418 /* Draw in the Y axis title. */
419 if (widget->ytitle != 0)
420 {
421 writeChtype (widget->win, widget->ytitlePos, widget->boxHeight-1, widget->ytitle, HORIZONTAL, 0, widget->ytitleLen);
422 attrib = widget->ytitle[0] & A_ATTRIBUTES;
423 }
424
425 /* Draw in the Y axis high value. */
426 sprintf (temp, "%d", widget->count);
427 len = (int)strlen (temp);
428 writeCharAttrib (widget->win, widget->boxWidth - len - adj, widget->boxHeight-2, temp, attrib, HORIZONTAL, 0, len);
429
430 /* Draw in the Y axis low value. */
431 sprintf (temp, "0");
432 writeCharAttrib (widget->win, 3, widget->boxHeight - 2, temp, attrib, HORIZONTAL, 0, (int)strlen (temp));
433
434 /* If the count is zero, then there aren't any points. */
435 if (widget->count == 0)
436 {
437 wrefresh (widget->win);
438 return;
439 }
440 spacing = (widget->boxWidth - TITLE_LM) / widget->count;
441
442 /* Draw in the graph line/plot points. */
443 for (y = 0; y < widget->count; y++)
444 {
445 int colheight = (widget->values[y] / widget->xscale) - 1;
446 /* Add the marker on the Y axis. */
447 mvwaddch (widget->win, widget->boxHeight - 3, (y + 1)*spacing + adj, ACS_TTEE);
448
449 /* If this is a plot graph, all we do is draw a dot. */
450 if (widget->displayType == vPLOT)
451 {
452 xpos = widget->boxHeight - 4 - colheight;
453 ypos = (y + 1) * spacing + adj;
454 mvwaddch (widget->win, xpos, ypos, widget->graphChar[y]);
455 }
456 else
457 {
458 for (x = 0; x <= widget->yscale; x++)
459 {
460 xpos = widget->boxHeight - 3;
461 ypos = (y + 1) * spacing + adj;
462 drawLine (widget->win, ypos, xpos - colheight, ypos, xpos, widget->graphChar[y]);
463 }
464 }
465 }
466
467 /* Draw in the axis corners. */
468 mvwaddch (widget->win, TitleLinesOf (widget), 2, ACS_URCORNER);
469 mvwaddch (widget->win, widget->boxHeight - 3, 2, ACS_LLCORNER);
470 mvwaddch (widget->win, widget->boxHeight - 3, widget->boxWidth, ACS_URCORNER);
471
472 /* Refresh and lets see 'er. */
473 wrefresh (widget->win);
474 }
475
476 /*
477 * Destroy the graph widget.
478 */
479 static void _destroyCDKGraph (CDKOBJS *object)
480 {
481 if (object != 0)
482 {
483 CDKGRAPH *widget = (CDKGRAPH *)object;
484
485 cleanCdkTitle (object);
486
487 freeChtype (widget->xtitle);
488 freeChtype (widget->ytitle);
489 freeChtype (widget->graphChar);
490
491 freeChecked (widget->values);
492
493 /* Clean the key bindings. */
494 cleanCDKObjectBindings (vGRAPH, widget);
495
496 /* Unregister this object. */
497 unregisterCDKObject (vGRAPH, widget);
498
499 /* Clean up the windows. */
500 deleteCursesWindow (widget->win);
501 }
502 }
503
504 /*
505 * Erase the graph widget from the screen.
506 */
507 static void _eraseCDKGraph (CDKOBJS *object)
508 {
509 if (validCDKObject (object))
510 {
511 CDKGRAPH *widget = (CDKGRAPH *)object;
512
513 eraseCursesWindow (widget->win);
514 }
515 }
516
517 dummyInject (Graph)
518
519 dummyFocus (Graph)
520
521 dummyUnfocus (Graph)
522
523 dummyRefreshData (Graph)
524
525 dummySaveData (Graph)
0 #! /bin/sh
1 # $Id: headers.sh,v 1.9 2005/12/31 01:59:54 tom Exp $
2 #
3 # Adjust includes for header files that reside in a subdirectory of
4 # /usr/include, etc.
5 #
6 # Options:
7 # -c CFG specify an alternate name for config.h
8 # -d DIR target directory
9 # -e FILE extra editing commands, e.g., for manpage references
10 # -i create/update the headers.sed script
11 # -p PKG specify the package name
12 # -s DIR source directory
13 # -t TYPE renaming for manpage-sections
14 # -x PRG install-program (plus options, the whole value in quotes)
15 #
16 # Other parameters are assumed to be provided only for the install scenario.
17
18 SCRIPT=headers.sed
19 MYFILE=headers.tmp
20
21 OPT_C=config.h
22 OPT_D=
23 OPT_E=
24 OPT_I=n
25 OPT_P=
26 OPT_S=
27 OPT_T=
28 OPT_X=install
29
30 while test $# != 0
31 do
32 case $1 in
33 -c) # CFG specify an alternate name for config.h
34 shift
35 OPT_C="$1"
36 ;;
37 -d) # DIR target directory
38 shift
39 OPT_D="$1"
40 ;;
41 -e) # FILE extra sed-commands
42 shift
43 OPT_E="$OPT_E -f $1"
44 ;;
45 -i) # create the headers.sed script
46 if test "$OPT_I" = n
47 then
48 rm -f $SCRIPT
49 fi
50 OPT_I=y
51
52 if ( test -n "$OPT_D" && test -d "$OPT_D" )
53 then
54 if ( test -n "$OPT_S" && test -d "$OPT_S" )
55 then
56 LEAF=`basename $OPT_D`
57 case $OPT_D in
58 /*/include/$LEAF)
59 END=`basename $OPT_D`
60 for i in $OPT_S/*.h
61 do
62 NAME=`basename $i`
63 echo "s%<$NAME>%<$END/$NAME>%g" >> $SCRIPT
64 done
65 ;;
66 *)
67 echo "" >> $SCRIPT
68 ;;
69 esac
70 OPT_S=
71 if test -f $SCRIPT ; then
72 sort -u $SCRIPT >$MYFILE
73 rm -f $SCRIPT
74 mv $MYFILE $SCRIPT
75 fi
76 fi
77 fi
78
79 if test -n "$OPT_P"
80 then
81 for name in `
82 egrep "#define[ ][ ]*[A-Z]" $OPT_C \
83 | sed -e 's/^#define[ ][ ]*//' \
84 -e 's/[ ].*//' \
85 | fgrep -v GCC_ \
86 | sort -u \
87 | egrep -v "^${OPT_P}_"`
88 do
89 echo "s%\\<$name\\>%${OPT_P}_$name%g" >>$SCRIPT
90 done
91 if test -f $SCRIPT ; then
92 sort -u $SCRIPT >$MYFILE
93 rm -f $SCRIPT
94 mv $MYFILE $SCRIPT
95 fi
96 OPT_P=
97 fi
98 ;;
99 -p) # PKG specify the package name
100 shift
101 OPT_P="$1"
102 ;;
103 -s) # DIR source directory
104 shift
105 OPT_S="$1"
106 ;;
107 -t) # rename suffix of target
108 shift
109 OPT_T="$1"
110 ;;
111 -x) # PRG install-program (plus options, the whole value in quotes)
112 shift
113 OPT_X="$1"
114 ;;
115 *)
116 FILE=$1
117
118 SHOW=`basename $FILE`
119 TMPSRC=${TMPDIR-/tmp}/${SHOW}$$
120
121 echo " ... $SHOW"
122 test -f $OPT_S/$FILE && FILE="$OPT_S/$FILE"
123
124 if test -f "$FILE"
125 then
126 rm -f $TMPSRC
127 sed -f $SCRIPT $OPT_E $FILE > $TMPSRC
128 NAME=`basename $FILE`
129 if test -n "$OPT_T" ; then
130 NAME=`echo "$NAME" | sed -e 's/\.[^.]*$//'`.$OPT_T
131 fi
132
133 # Just in case someone gzip'd manpages, remove the conflicting copy.
134 test -f $OPT_D/$NAME.gz && rm -f $OPT_D/$NAME.gz
135
136 eval $OPT_X $TMPSRC $OPT_D/$NAME
137 rm -f $TMPSRC
138 fi
139 ;;
140 esac
141 shift
142 done
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:44 $
5 * $Revision: 1.86 $
6 */
7
8 DeclareCDKObjects (HISTOGRAM, Histogram, setCdk, Unknown);
9
10 /*
11 * Create a histogram widget.
12 */
13 CDKHISTOGRAM *newCDKHistogram (CDKSCREEN *cdkscreen,
14 int xplace,
15 int yplace,
16 int height,
17 int width,
18 int orient,
19 char *title,
20 boolean Box,
21 boolean shadow)
22 {
23 CDKHISTOGRAM *widget = 0;
24 int parentWidth = getmaxx (cdkscreen->window);
25 int parentHeight = getmaxy (cdkscreen->window);
26 int boxWidth = width;
27 int boxHeight = height;
28 int xpos = xplace;
29 int ypos = yplace;
30 int oldWidth = 0;
31 int oldHeight = 0;
32
33 if ((widget = newCDKObject (CDKHISTOGRAM, &my_funcs)) == 0)
34 return (0);
35
36 setCDKHistogramBox (widget, Box);
37
38 boxHeight = setWidgetDimension (parentHeight, height, 2);
39 oldHeight = boxHeight;
40
41 boxWidth = setWidgetDimension (parentWidth, width, 0);
42 oldWidth = boxWidth;
43
44 boxWidth = setCdkTitle (ObjOf (widget), title, -(boxWidth + 1));
45
46 /* Increment the height by the number of lines in the title. */
47 boxHeight += TitleLinesOf (widget);
48
49 /*
50 * Make sure we didn't extend beyond the dimensions of the window.
51 */
52 boxWidth = (boxWidth > parentWidth ? oldWidth : boxWidth);
53 boxHeight = (boxHeight > parentHeight ? oldHeight : boxHeight);
54
55 /* Rejustify the x and y positions if we need to. */
56 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
57
58 /* Create the histogram pointer. */
59 ScreenOf (widget) = cdkscreen;
60 widget->parent = cdkscreen->window;
61 widget->win = newwin (boxHeight, boxWidth, ypos, xpos);
62 widget->shadowWin = 0;
63 widget->boxWidth = boxWidth;
64 widget->boxHeight = boxHeight;
65 widget->fieldWidth = boxWidth - 2 * BorderOf (widget);
66 widget->fieldHeight = boxHeight - TitleLinesOf (widget) - 2 * BorderOf (widget);
67 widget->orient = orient;
68 widget->shadow = shadow;
69
70 /* Is the window null. */
71 if (widget->win == 0)
72 {
73 destroyCDKObject (widget);
74 return (0);
75 }
76 keypad (widget->win, TRUE);
77
78 /* Set up some default values. */
79 widget->filler = '#' | A_REVERSE;
80 widget->statsAttr = A_NORMAL;
81 widget->statsPos = TOP;
82 widget->viewType = vREAL;
83 widget->high = 0;
84 widget->low = 0;
85 widget->value = 0;
86 widget->lowx = 0;
87 widget->lowy = 0;
88 widget->highx = 0;
89 widget->highy = 0;
90 widget->curx = 0;
91 widget->cury = 0;
92 widget->lowString = 0;
93 widget->highString = 0;
94 widget->curString = 0;
95
96 /* Do we want a shadow? */
97 if (shadow)
98 {
99 widget->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
100 }
101
102 registerCDKObject (cdkscreen, vHISTOGRAM, widget);
103
104 return (widget);
105 }
106
107 /*
108 * This was added for the builder.
109 */
110 void activateCDKHistogram (CDKHISTOGRAM *widget, chtype *actions GCC_UNUSED)
111 {
112 drawCDKHistogram (widget, ObjOf (widget)->box);
113 }
114
115 /*
116 * Set various widget attributes.
117 */
118 void setCDKHistogram (CDKHISTOGRAM *widget,
119 EHistogramDisplayType viewType,
120 int statsPos,
121 chtype statsAttr,
122 int low,
123 int high,
124 int value,
125 chtype filler,
126 boolean Box)
127 {
128 setCDKHistogramDisplayType (widget, viewType);
129 setCDKHistogramStatsPos (widget, statsPos);
130 setCDKHistogramValue (widget, low, high, value);
131 setCDKHistogramFillerChar (widget, filler);
132 setCDKHistogramStatsAttr (widget, statsAttr);
133 setCDKHistogramBox (widget, Box);
134 }
135
136 /*
137 * Set the values for the widget.
138 */
139 void setCDKHistogramValue (CDKHISTOGRAM *widget, int low, int high, int value)
140 {
141 char string[100];
142 int len;
143
144 /* We should error check the information we have. */
145 widget->low = (low <= high ? low : 0);
146 widget->high = (low <= high ? high : 0);
147 widget->value = (low <= value && value <= high ? value : 0);
148
149 /* Determine the percentage of the given value. */
150 widget->percent = ((widget->high == 0)
151 ? 0
152 : ((float)widget->value / (float)widget->high));
153
154 /* Determine the size of the histogram bar. */
155 if (widget->orient == VERTICAL)
156 {
157 widget->barSize = (int)(widget->percent * (float)widget->fieldHeight);
158 }
159 else
160 {
161 widget->barSize = (int)(widget->percent * (float)widget->fieldWidth);
162 }
163
164 /*
165 * We have a number of variables which determine the personality of the
166 * histogram. We have to go through each one methodically, and set them
167 * correctly. This section does this.
168 */
169 if (widget->viewType != vNONE)
170 {
171 if (widget->orient == VERTICAL)
172 {
173 if (widget->statsPos == LEFT || widget->statsPos == BOTTOM)
174 {
175 /* Free the space used by the character strings. */
176 freeChar (widget->lowString);
177 freeChar (widget->highString);
178 freeChar (widget->curString);
179
180 /* Set the low label attributes. */
181 sprintf (string, "%d", widget->low);
182 len = (int)strlen (string);
183 widget->lowString = copyChar (string);
184 widget->lowx = 1;
185 widget->lowy = widget->boxHeight - len - 1;
186
187 /* Set the high label attributes. */
188 sprintf (string, "%d", widget->high);
189 widget->highString = copyChar (string);
190 widget->highx = 1;
191 widget->highy = TitleLinesOf (widget) + 1;
192
193 /* Set the current value attributes. */
194 if (widget->viewType == vPERCENT)
195 {
196 sprintf (string, "%3.1f%%", (float) (widget->percent * 100));
197 }
198 else if (widget->viewType == vFRACTION)
199 {
200 sprintf (string, "%d/%d", widget->value, widget->high);
201 }
202 else
203 {
204 sprintf (string, "%d", widget->value);
205 }
206 len = (int)strlen (string);
207 widget->curString = copyChar (string);
208 widget->curx = 1;
209 widget->cury = (((widget->fieldHeight - len) / 2)
210 + TitleLinesOf (widget) + 1);
211 }
212 else if (widget->statsPos == CENTER)
213 {
214 /* Set the character strings correctly. */
215 freeChar (widget->lowString);
216 freeChar (widget->highString);
217 freeChar (widget->curString);
218
219 /* Set the low label attributes. */
220 sprintf (string, "%d", widget->low);
221 len = (int)strlen (string);
222 widget->lowString = copyChar (string);
223 widget->lowx = (widget->fieldWidth/2) + 1;
224 widget->lowy = widget->boxHeight - len - 1;
225
226 /* Set the high label attributes. */
227 sprintf (string, "%d", widget->high);
228 widget->highString = copyChar (string);
229 widget->highx = (widget->fieldWidth/2) + 1;
230 widget->highy = TitleLinesOf (widget) + 1;
231
232 /* Set the stats label attributes. */
233 if (widget->viewType == vPERCENT)
234 {
235 sprintf (string, "%3.2f%%", (float) (widget->percent * 100));
236 }
237 else if (widget->viewType == vFRACTION)
238 {
239 sprintf (string, "%d/%d", widget->value, widget->high);
240 }
241 else
242 {
243 sprintf (string, "%d", widget->value);
244 }
245 len = (int)strlen (string);
246 widget->curString = copyChar (string);
247 widget->curx = (widget->fieldWidth/2) + 1;
248 widget->cury = (((widget->fieldHeight - len)/2)
249 + TitleLinesOf (widget) + 1);
250 }
251 else if (widget->statsPos == RIGHT || widget->statsPos == TOP)
252 {
253 /* Set the character strings correctly. */
254 freeChar (widget->lowString);
255 freeChar (widget->highString);
256 freeChar (widget->curString);
257
258 /* Set the low label attributes. */
259 sprintf (string, "%d", widget->low);
260 len = (int)strlen (string);
261 widget->lowString = copyChar (string);
262 widget->lowx = widget->fieldWidth;
263 widget->lowy = widget->boxHeight - len - 1;
264
265 /* Set the high label attributes. */
266 sprintf (string, "%d", widget->high);
267 widget->highString = copyChar (string);
268 widget->highx = widget->fieldWidth;
269 widget->highy = TitleLinesOf (widget) + 1;
270
271 /* Set the stats label attributes. */
272 if (widget->viewType == vPERCENT)
273 {
274 sprintf (string, "%3.2f%%", (float) (widget->percent * 100));
275 }
276 else if (widget->viewType == vFRACTION)
277 {
278 sprintf (string, "%d/%d", widget->value, widget->high);
279 }
280 else
281 {
282 sprintf (string, "%d", widget->value);
283 }
284 len = (int)strlen (string);
285 widget->curString = copyChar (string);
286 widget->curx = widget->fieldWidth;
287 widget->cury = (((widget->fieldHeight - len)/2)
288 + TitleLinesOf (widget) + 1);
289 }
290 }
291 else
292 {
293 /* Alignment is HORIZONTAL. */
294 if (widget->statsPos == TOP || widget->statsPos == RIGHT)
295 {
296 /* Set the character strings correctly. */
297 freeChar (widget->lowString);
298 freeChar (widget->highString);
299 freeChar (widget->curString);
300
301 /* Set the low label attributes. */
302 sprintf (string, "%d", widget->low);
303 widget->lowString = copyChar (string);
304 widget->lowx = 1;
305 widget->lowy = TitleLinesOf (widget) + 1;
306
307 /* Set the high label attributes. */
308 sprintf (string, "%d", widget->high);
309 len = (int)strlen (string);
310 widget->highString = copyChar (string);
311 widget->highx = widget->boxWidth - len - 1;
312 widget->highy = TitleLinesOf (widget) + 1;
313
314 /* Set the stats label attributes. */
315 if (widget->viewType == vPERCENT)
316 {
317 sprintf (string, "%3.1f%%", (float) (widget->percent * 100));
318 }
319 else if (widget->viewType == vFRACTION)
320 {
321 sprintf (string, "%d/%d", widget->value, widget->high);
322 }
323 else
324 {
325 sprintf (string, "%d", widget->value);
326 }
327 len = (int)strlen (string);
328 widget->curString = copyChar (string);
329 widget->curx = (widget->fieldWidth - len)/2 + 1;
330 widget->cury = TitleLinesOf (widget) + 1;
331 }
332 else if (widget->statsPos == CENTER)
333 {
334 /* Set the character strings correctly. */
335 freeChar (widget->lowString);
336 freeChar (widget->highString);
337 freeChar (widget->curString);
338
339 /* Set the low label attributes. */
340 sprintf (string, "%d", widget->low);
341 widget->lowString = copyChar (string);
342 widget->lowx = 1;
343 widget->lowy = ((widget->fieldHeight / 2)
344 + TitleLinesOf (widget) + 1);
345
346 /* Set the high label attributes. */
347 sprintf (string, "%d", widget->high);
348 len = (int)strlen (string);
349 widget->highString = copyChar (string);
350 widget->highx = widget->boxWidth - len - 1;
351 widget->highy = ((widget->fieldHeight / 2)
352 + TitleLinesOf (widget) + 1);
353
354 /* Set the stats label attributes. */
355 if (widget->viewType == vPERCENT)
356 {
357 sprintf (string, "%3.1f%%", (float) (widget->percent * 100));
358 }
359 else if (widget->viewType == vFRACTION)
360 {
361 sprintf (string, "%d/%d", widget->value, widget->high);
362 }
363 else
364 {
365 sprintf (string, "%d", widget->value);
366 }
367 len = (int)strlen (string);
368 widget->curString = copyChar (string);
369 widget->curx = (widget->fieldWidth - len)/2 + 1;
370 widget->cury = ((widget->fieldHeight / 2)
371 + TitleLinesOf (widget) + 1);
372 }
373 else if (widget->statsPos == BOTTOM || widget->statsPos == LEFT)
374 {
375 /* Set the character strings correctly. */
376 freeChar (widget->lowString);
377 freeChar (widget->highString);
378 freeChar (widget->curString);
379
380 /* Set the low label attributes. */
381 sprintf (string, "%d", widget->low);
382 widget->lowString = copyChar (string);
383 widget->lowx = 1;
384 widget->lowy = widget->boxHeight - 2 * BorderOf (widget);
385
386 /* Set the high label attributes. */
387 sprintf (string, "%d", widget->high);
388 len = (int)strlen (string);
389 widget->highString = copyChar (string);
390 widget->highx = widget->boxWidth - len - 1;
391 widget->highy = widget->boxHeight - 2 * BorderOf (widget);
392
393 /* Set the stats label attributes. */
394 if (widget->viewType == vPERCENT)
395 {
396 sprintf (string, "%3.1f%%", (float) (widget->percent * 100));
397 }
398 else if (widget->viewType == vFRACTION)
399 {
400 sprintf (string, "%d/%d", widget->value, widget->high);
401 }
402 else
403 {
404 sprintf (string, "%d", widget->value);
405 }
406 widget->curString = copyChar (string);
407 widget->curx = (widget->fieldWidth - len)/2 + 1;
408 widget->cury = widget->boxHeight - 2 * BorderOf (widget);
409 }
410 }
411 }
412 }
413 int getCDKHistogramValue (CDKHISTOGRAM *widget)
414 {
415 return widget->value;
416 }
417 int getCDKHistogramLowValue (CDKHISTOGRAM *widget)
418 {
419 return widget->low;
420 }
421 int getCDKHistogramHighValue (CDKHISTOGRAM *widget)
422 {
423 return widget->high;
424 }
425
426 /*
427 * Set the histogram display type.
428 */
429 void setCDKHistogramDisplayType (CDKHISTOGRAM *widget, EHistogramDisplayType viewType)
430 {
431 widget->viewType = viewType;
432 }
433 EHistogramDisplayType getCDKHistogramViewType (CDKHISTOGRAM *widget)
434 {
435 return widget->viewType;
436 }
437
438 /*
439 * Set the position of the statistics information.
440 */
441 void setCDKHistogramStatsPos (CDKHISTOGRAM *widget, int statsPos)
442 {
443 widget->statsPos = statsPos;
444 }
445 int getCDKHistogramStatsPos (CDKHISTOGRAM *widget)
446 {
447 return widget->statsPos;
448 }
449
450 /*
451 * Set the attribute of the statistics.
452 */
453 void setCDKHistogramStatsAttr (CDKHISTOGRAM *widget, chtype statsAttr)
454 {
455 widget->statsAttr = statsAttr;
456 }
457 chtype getCDKHistogramStatsAttr (CDKHISTOGRAM *widget)
458 {
459 return widget->statsAttr;
460 }
461
462 /*
463 * Set the character to use when drawing the widget.
464 */
465 void setCDKHistogramFillerChar (CDKHISTOGRAM *widget, chtype character)
466 {
467 widget->filler = character;
468 }
469 chtype getCDKHistogramFillerChar (CDKHISTOGRAM *widget)
470 {
471 return widget->filler;
472 }
473
474 /*
475 * Set the widget box attribute.
476 */
477 void setCDKHistogramBox (CDKHISTOGRAM *widget, boolean Box)
478 {
479 ObjOf (widget)->box = Box;
480 ObjOf (widget)->borderSize = Box ? 1 : 0;
481 }
482 boolean getCDKHistogramBox (CDKHISTOGRAM *widget)
483 {
484 return ObjOf (widget)->box;
485 }
486
487 /*
488 * Set the background attribute of the widget.
489 */
490 static void _setBKattrHistogram (CDKOBJS *object, chtype attrib)
491 {
492 if (object != 0)
493 {
494 CDKHISTOGRAM *widget = (CDKHISTOGRAM *) object;
495 wbkgd (widget->win, attrib);
496 }
497 }
498
499 /*
500 * Move the histogram field to the given location.
501 */
502 static void _moveCDKHistogram (CDKOBJS *object,
503 int xplace,
504 int yplace,
505 boolean relative,
506 boolean refresh_flag)
507 {
508 CDKHISTOGRAM *widget = (CDKHISTOGRAM *)object;
509 int currentX = getbegx (widget->win);
510 int currentY = getbegy (widget->win);
511 int xpos = xplace;
512 int ypos = yplace;
513 int xdiff = 0;
514 int ydiff = 0;
515
516 /*
517 * If this is a relative move, then we will adjust where we want
518 * to move to.
519 */
520 if (relative)
521 {
522 xpos = getbegx (widget->win) + xplace;
523 ypos = getbegy (widget->win) + yplace;
524 }
525
526 /* Adjust the window if we need to. */
527 alignxy (WindowOf (widget), &xpos, &ypos, widget->boxWidth, widget->boxHeight);
528
529 /* Get the difference. */
530 xdiff = currentX - xpos;
531 ydiff = currentY - ypos;
532
533 /* Move the window to the new location. */
534 moveCursesWindow (widget->win, -xdiff, -ydiff);
535 moveCursesWindow (widget->shadowWin, -xdiff, -ydiff);
536
537 /* Touch the windows so they 'move'. */
538 refreshCDKWindow (WindowOf (widget));
539
540 /* Redraw the window, if they asked for it. */
541 if (refresh_flag)
542 {
543 drawCDKHistogram (widget, ObjOf (widget)->box);
544 }
545 }
546
547 /*
548 * Draw the widget.
549 */
550 static void _drawCDKHistogram (CDKOBJS *object, boolean Box)
551 {
552 CDKHISTOGRAM *widget = (CDKHISTOGRAM *)object;
553 chtype battr = 0;
554 chtype bchar = 0;
555 chtype fattr = widget->filler & A_ATTRIBUTES;
556 chtype fchar = CharOf (widget->filler);
557 int histX = TitleLinesOf (widget) + 1;
558 int histY = widget->barSize;
559 int len, x, y;
560
561 /* Erase the window. */
562 werase (widget->win);
563
564 /* Box the widget if asked. */
565 if (Box)
566 {
567 drawObjBox (widget->win, ObjOf (widget));
568 }
569
570 /* Do we have a shadow to draw? */
571 if (widget->shadowWin != 0)
572 {
573 drawShadow (widget->shadowWin);
574 }
575
576 drawCdkTitle (widget->win, object);
577
578 /* If the user asked for labels, draw them in. */
579 if (widget->viewType != vNONE)
580 {
581 /* Draw in the low label. */
582 if (widget->lowString != 0)
583 {
584 len = (int)strlen (widget->lowString);
585 writeCharAttrib (widget->win,
586 widget->lowx,
587 widget->lowy,
588 widget->lowString,
589 widget->statsAttr,
590 widget->orient,
591 0, len);
592 }
593
594 /* Draw in the current value label. */
595 if (widget->curString != 0)
596 {
597 len = (int)strlen (widget->curString);
598 writeCharAttrib (widget->win,
599 widget->curx,
600 widget->cury,
601 widget->curString,
602 widget->statsAttr,
603 widget->orient,
604 0, len);
605 }
606
607 /* Draw in the high label. */
608 if (widget->highString != 0)
609 {
610 len = (int)strlen (widget->highString);
611 writeCharAttrib (widget->win,
612 widget->highx,
613 widget->highy,
614 widget->highString,
615 widget->statsAttr,
616 widget->orient,
617 0, len);
618 }
619 }
620
621 if (widget->orient == VERTICAL)
622 {
623 histX = widget->boxHeight - widget->barSize - 1;
624 histY = widget->fieldWidth;
625 }
626
627 /* Draw the histogram bar. */
628 for (x = histX; x < widget->boxHeight - 1; x++)
629 {
630 for (y = 1; y <= histY; y++)
631 {
632 battr = mvwinch (widget->win, x, y);
633 fchar = battr & A_ATTRIBUTES;
634 bchar = CharOf (battr);
635
636 if (bchar == ' ')
637 {
638 mvwaddch (widget->win, x, y, widget->filler);
639 }
640 else
641 {
642 mvwaddch (widget->win, x, y, battr | fattr);
643 }
644 }
645 }
646
647 /* Refresh the window. */
648 wrefresh (widget->win);
649 }
650
651 /*
652 * Destroy the widget.
653 */
654 static void _destroyCDKHistogram (CDKOBJS *object)
655 {
656 if (object != 0)
657 {
658 CDKHISTOGRAM *widget = (CDKHISTOGRAM *)object;
659
660 freeChar (widget->curString);
661 freeChar (widget->lowString);
662 freeChar (widget->highString);
663 cleanCdkTitle (object);
664
665 /* Clean up the windows. */
666 deleteCursesWindow (widget->shadowWin);
667 deleteCursesWindow (widget->win);
668
669 /* Clean the key bindings. */
670 cleanCDKObjectBindings (vHISTOGRAM, widget);
671
672 /* Unregister this object. */
673 unregisterCDKObject (vHISTOGRAM, widget);
674 }
675 }
676
677 /*
678 * Erase the widget from the screen.
679 */
680 static void _eraseCDKHistogram (CDKOBJS *object)
681 {
682 if (validCDKObject (object))
683 {
684 CDKHISTOGRAM *widget = (CDKHISTOGRAM *)object;
685
686 eraseCursesWindow (widget->win);
687 eraseCursesWindow (widget->shadowWin);
688 }
689 }
690
691 dummyInject (Histogram)
692
693 dummyFocus (Histogram)
694
695 dummyUnfocus (Histogram)
696
697 dummyRefreshData (Histogram)
698
699 dummySaveData (Histogram)
0 /*
1 * $Id: alphalist.h,v 1.23 2006/04/23 19:22:36 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKALPHALIST_H
6 #define CDKALPHALIST_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2005,2006 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 #include <entry.h>
57 #include <scroll.h>
58
59 /*
60 * Define the CDK alphalist widget structure.
61 */
62 struct SAlphalist {
63 CDKOBJS obj;
64 WINDOW * parent;
65 WINDOW * win;
66 WINDOW * shadowWin;
67 CDKENTRY * entryField;
68 CDKSCROLL * scrollField;
69 char ** list;
70 int listSize;
71 int xpos;
72 int ypos;
73 int height;
74 int width;
75 int boxHeight;
76 int boxWidth;
77 chtype highlight;
78 chtype fillerChar;
79 boolean shadow;
80 EExitType exitType;
81 };
82 typedef struct SAlphalist CDKALPHALIST;
83
84 /*
85 * This creates a pointer to a new CDK alphalist widget.
86 */
87 CDKALPHALIST *newCDKAlphalist (
88 CDKSCREEN * /* cdkscreen */,
89 int /* xpos */,
90 int /* ypos */,
91 int /* height */,
92 int /* width */,
93 char * /* title */,
94 char * /* label */,
95 char ** /* list */,
96 int /* listSize */,
97 chtype /* fillerChar */,
98 chtype /* highlight */,
99 boolean /* Box */,
100 boolean /* shadow */);
101
102 /*
103 * This allows the user to interact with the widget.
104 */
105 char *activateCDKAlphalist (
106 CDKALPHALIST * /* alphalist */,
107 chtype * /* actions */);
108
109 /*
110 * This injects a single character into the widget.
111 */
112 #define injectCDKAlphalist(obj,input) injectCDKObject(obj,input,String)
113
114 /*
115 * This sets multiple attributes of the alphalist widget.
116 */
117 void setCDKAlphalist (
118 CDKALPHALIST * /* alphalist */,
119 char ** /* list */,
120 int /* listSize */,
121 chtype /* fillerChar */,
122 chtype /* highlight */,
123 boolean /* Box */);
124
125 /*
126 * This sets the contents of the alpha list.
127 */
128 void setCDKAlphalistContents (
129 CDKALPHALIST * /* alphalist */,
130 char ** /* list */,
131 int /* listSize */);
132
133 char **getCDKAlphalistContents (
134 CDKALPHALIST * /* alphalist */,
135 int * /* size */);
136
137 /*
138 * Get/set the current position in the scroll-widget.
139 */
140 int getCDKAlphalistCurrentItem(
141 CDKALPHALIST * /* widget */);
142
143 void setCDKAlphalistCurrentItem(
144 CDKALPHALIST * /* widget */,
145 int /* item */);
146
147 /*
148 * This sets the filler character of the entry field of the alphalist.
149 */
150 void setCDKAlphalistFillerChar (
151 CDKALPHALIST * /* alphalist */,
152 chtype /* fillerCharacter */);
153
154 chtype getCDKAlphalistFillerChar (
155 CDKALPHALIST * /* alphalist */);
156
157 /*
158 * This sets the highlight bar attributes.
159 */
160 void setCDKAlphalistHighlight (
161 CDKALPHALIST * /* alphalist */,
162 chtype /* highlight */);
163
164 chtype getCDKAlphalistHighlight (
165 CDKALPHALIST * /* alphalist */);
166
167 /*
168 * This sets the box attribute of the widget.
169 */
170 void setCDKAlphalistBox (
171 CDKALPHALIST * /* alphalist */,
172 boolean /* Box */);
173
174 boolean getCDKAlphalistBox (
175 CDKALPHALIST * /* alphalist */);
176
177 /*
178 * These functions set the drawing characters of the widget.
179 */
180 #define setCDKAlphalistULChar(w,c) setULCharOf(w,c)
181 #define setCDKAlphalistURChar(w,c) setURCharOf(w,c)
182 #define setCDKAlphalistLLChar(w,c) setLLCharOf(w,c)
183 #define setCDKAlphalistLRChar(w,c) setLRCharOf(w,c)
184 #define setCDKAlphalistVerticalChar(w,c) setVTCharOf(w,c)
185 #define setCDKAlphalistHorizontalChar(w,c) setHZCharOf(w,c)
186 #define setCDKAlphalistBoxAttribute(w,c) setBXAttrOf(w,c)
187
188 /*
189 * This sets the background color of the widget.
190 */
191 #define setCDKAlphalistBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
192
193 /*
194 * This sets the background attribute of the widget.
195 */
196 #define setCDKAlphalistBackgroundAttrib(w,c) setBKAttrOf(w,c)
197
198 /*
199 * This draws the widget on the screen.
200 */
201 #define drawCDKAlphalist(obj,box) drawCDKObject(obj,box)
202
203 /*
204 * This removes the widget from the screen.
205 */
206 #define eraseCDKAlphalist(obj) eraseCDKObject(obj)
207
208 /*
209 * This moves the widget to the location specified.
210 */
211 #define moveCDKAlphalist(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
212
213 /*
214 * This allows the user to interactively position the widget.
215 */
216 #define positionCDKAlphalist(widget) positionCDKObject(ObjOf(widget),widget->win)
217
218 /*
219 * This destroys the widget and all the memory associated with it.
220 */
221 #define destroyCDKAlphalist(obj) destroyCDKObject(obj)
222
223 /*
224 * These functions set the pre and post process functions for the widget.
225 */
226 void setCDKAlphalistPreProcess (
227 CDKALPHALIST * /* alphalist */,
228 PROCESSFN /* callback */,
229 void * /* data */);
230
231 void setCDKAlphalistPostProcess (
232 CDKALPHALIST * /* alphalist */,
233 PROCESSFN /* callback */,
234 void * /* data */);
235
236 #ifdef __cplusplus
237 }
238 #endif
239
240 #endif /* CDKALPHALIST_H */
241 #endif /* CDKINCLUDES */
0 /*
1 * $Id: binding.h,v 1.14 2005/03/08 23:44:25 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKBINDING_H
6 #define CDKBINDING_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #endif
17
18 /*
19 * Changes 1999-2004,2005 copyright Thomas E. Dickey
20 *
21 * Copyright 1999, Mike Glover
22 * All rights reserved.
23 *
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
26 * are met:
27 * 1. Redistributions of source code must retain the above copyright
28 * notice, this list of conditions and the following disclaimer.
29 * 2. Redistributions in binary form must reproduce the above copyright
30 * notice, this list of conditions and the following disclaimer in the
31 * documentation and/or other materials provided with the distribution.
32 * 3. All advertising materials mentioning features or use of this software
33 * must display the following acknowledgment:
34 * This product includes software developed by Mike Glover
35 * and contributors.
36 * 4. Neither the name of Mike Glover, nor the names of contributors
37 * may be used to endorse or promote products derived from this software
38 * without specific prior written permission.
39 *
40 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
41 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
44 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50 * SUCH DAMAGE.
51 */
52
53 /*
54 * Create definitions for the key bindings.
55 */
56
57 /*
58 * This is the key binding prototype, typed for use with Perl.
59 */
60 #define BINDFN_PROTO(func) \
61 int (func) ( \
62 EObjectType /* cdktype */, \
63 void * /* object */, \
64 void * /* clientData */, \
65 chtype /* input */)
66
67 typedef BINDFN_PROTO(*BINDFN);
68
69 /*
70 * Bind to this function to simply translate keys without doing anything else,
71 * in getcCDKObject().
72 */
73 extern BINDFN_PROTO(getcCDKBind);
74
75 /*
76 * This is the prototype for the process callback functions.
77 */
78 typedef int (*PROCESSFN) (
79 EObjectType /* cdktype */,
80 void * /* object */,
81 void * /* clientData */,
82 chtype /* input */);
83
84 /*
85 * This binds the key to the event.
86 */
87 void bindCDKObject (
88 EObjectType /* cdktype */,
89 void * /* object */,
90 chtype /* key */,
91 BINDFN /* function */,
92 void * /* data */);
93
94 /*
95 * This unbinds the key from the event.
96 */
97 void unbindCDKObject (
98 EObjectType /* cdktype */,
99 void * /* object */,
100 chtype /* key */);
101
102 /*
103 * This checks if the given key has an event 'attached' to it, executes the
104 * bound function if so.
105 */
106 int checkCDKObjectBind (
107 EObjectType /* cdktype */,
108 void * /* object */,
109 chtype /* key */);
110
111 /*
112 * This checks if the given key has an event 'attached' to it.
113 */
114 bool isCDKObjectBind (
115 EObjectType /* cdktype */,
116 void * /* object */,
117 chtype /* key */);
118
119 /*
120 * This cleans out all of the key bindings.
121 */
122 void cleanCDKObjectBindings (
123 EObjectType /* cdktype */,
124 void * /* object */);
125
126 #ifdef __cplusplus
127 }
128 #endif
129
130 #endif /* CDKBINDING_H */
131 #endif /* CDKINCLUDES */
0 /*
1 * $Id: button.h,v 1.10 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKBUTTON_H
6 #define CDKBUTTON_H 1
7
8 #include "cdk.h"
9
10 #ifndef CDK_H
11 #define CDKINCLUDES
12 #include <cdk.h>
13 #undef CDKINCLUDES
14 #include <binding.h>
15 #include <cdkscreen.h>
16 #include <cdk_objs.h>
17 #endif
18
19 /*
20 * Changes 2002,2003 copyright Thomas E. Dickey
21 *
22 * Copyright 1999, Grant Edwards
23 * All rights reserved.
24 *
25 * Redistribution and use in source and binary forms, with or without
26 * modification, are permitted provided that the following conditions
27 * are met:
28 * 1. Redistributions of source code must retain the above copyright
29 * notice, this list of conditions and the following disclaimer.
30 * 2. Redistributions in binary form must reproduce the above copyright
31 * notice, this list of conditions and the following disclaimer in the
32 * documentation and/or other materials provided with the distribution.
33 * 3. All advertising materials mentioning features or use of this software
34 * must display the following acknowledgment:
35 * This product includes software developed by Grant Edwards
36 * and contributors.
37 * 4. Neither the name of Grant Edwards, nor the names of contributors
38 * may be used to endorse or promote products derived from this software
39 * without specific prior written permission.
40 *
41 * THIS SOFTWARE IS PROVIDED BY GRANT EDWARDS AND CONTRIBUTORS ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL GRANT EDWARDS OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 */
53
54 /*
55 * Declare any definitions you need to make.
56 */
57
58 /*
59 * Declare the CDK label structure.
60 */
61 struct SButton {
62 CDKOBJS obj;
63 WINDOW * parent;
64 WINDOW * win;
65 WINDOW * shadowWin;
66 chtype * info;
67 void (*callback)(struct SButton *button);
68 int infoLen;
69 int infoPos;
70 int boxWidth;
71 int boxHeight;
72 int xpos;
73 int ypos;
74 int rows;
75 EExitType exitType;
76 boolean shadow;
77 };
78
79 typedef struct SButton CDKBUTTON;
80
81 typedef void (*tButtonCallback)(struct SButton *button);
82
83 /*
84 * This creates a new CDK button widget.
85 */
86 CDKBUTTON *newCDKButton (
87 CDKSCREEN * /* screen */,
88 int /* xPos */,
89 int /* yPos */,
90 char * /* button text */,
91 tButtonCallback /* callback function */,
92 boolean /* Box */,
93 boolean /* shadow */);
94
95 /*
96 * This was added to make the builder simpler. All this will
97 * do is call drawCDKLabel.
98 */
99 int activateCDKButton (
100 CDKBUTTON * /* button */,
101 chtype * /* actions */);
102
103 /*
104 * This injects a single character into the widget.
105 */
106 #define injectCDKButton(obj,input) injectCDKObject(obj,input,Int)
107
108 /*
109 * This sets multiple attributes of the widget.
110 */
111 void setCDKButton (
112 CDKBUTTON * /* button */,
113 char * /* text */,
114 boolean /* Box */);
115
116 /*
117 * This sets the contents of the label.
118 */
119 void setCDKButtonMessage (
120 CDKBUTTON * /* button */,
121 char * /* mesg */);
122
123 chtype *getCDKButtonMessage (
124 CDKBUTTON *);
125
126 /*
127 * This sets the box attribute of the widget.
128 */
129 void setCDKButtonBox (
130 CDKBUTTON * /* button */,
131 boolean /* Box */);
132
133 boolean getCDKButtonBox (
134 CDKBUTTON * /* button */);
135
136 /*
137 * This draws the label.
138 */
139 #define drawCDKButton(obj,Box) drawCDKObject(obj,Box)
140
141 /*
142 * These set the drawing characters of the widget.
143 */
144 #define setCDKButtonULChar(w,c) setULCharOf(w,c)
145 #define setCDKButtonURChar(w,c) setURCharOf(w,c)
146 #define setCDKButtonLLChar(w,c) setLLCharOf(w,c)
147 #define setCDKButtonLRChar(w,c) setLRCharOf(w,c)
148 #define setCDKButtonVerticalChar(w,c) setVTCharOf(w,c)
149 #define setCDKButtonHorizontalChar(w,c) setHZCharOf(w,c)
150 #define setCDKButtonBoxAttribute(w,c) setBXAttrOf(w,c)
151
152 /*
153 * This sets the background color of the widget.
154 */
155 #define setCDKButtonBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
156
157 /*
158 * This sets the background attribute of the widget.
159 */
160 #define setCDKButtonBackgroundAttrib(w,c) setBKAttrOf(w,c)
161
162 /*
163 * This erases the button.
164 */
165 #define eraseCDKButton(obj) eraseCDKObject(obj)
166
167 /*
168 * This destroys the button and the memory used by it.
169 */
170 #define destroyCDKButton(obj) destroyCDKObject(obj)
171
172 /*
173 * This moves the button to a new screen location.
174 */
175 #define moveCDKButton(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
176
177 /*
178 * This allows the user to interactively position the button.
179 */
180 void positionCDKButton (CDKBUTTON *);
181
182 #endif /* CDKBUTTON_H */
183 #endif /* CDKINCLUDES */
0 /*
1 * $Id: buttonbox.h,v 1.26 2005/12/28 12:59:18 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKBUTTONBOX_H
6 #define CDKBUTTONBOX_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2004,2005 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Define the CDK buttonbox structure.
58 */
59 struct SButtonBox {
60 CDKOBJS obj;
61 WINDOW * parent;
62 WINDOW * win;
63 WINDOW * shadowWin;
64 int titleAdj;
65 chtype ** button;
66 int * buttonLen;
67 int * buttonPos;
68 int * columnWidths;
69 int buttonCount;
70 int buttonWidth;
71 int currentButton;
72 int rows;
73 int cols;
74 int colAdjust;
75 int rowAdjust;
76 int boxWidth;
77 int boxHeight;
78 chtype ButtonAttrib;
79 EExitType exitType;
80 boolean shadow;
81 chtype highlight;
82 };
83 typedef struct SButtonBox CDKBUTTONBOX;
84
85 /*
86 * This returns a CDK buttonbox widget pointer.
87 */
88 CDKBUTTONBOX *newCDKButtonbox (
89 CDKSCREEN * /* cdkscreen */,
90 int /* xPos */,
91 int /* yPos */,
92 int /* height */,
93 int /* width */,
94 char * /* title */,
95 int /* rows */,
96 int /* cols */,
97 char ** /* buttons */,
98 int /* buttonCount */,
99 chtype /* highlight */,
100 boolean /* Box */,
101 boolean /* shadow */);
102
103 /*
104 * This activates the widget.
105 */
106 int activateCDKButtonbox (
107 CDKBUTTONBOX * /* buttonbox */,
108 chtype * /* actions */);
109
110 /*
111 * This injects a single character into the widget.
112 */
113 #define injectCDKButtonbox(obj,input) injectCDKObject(obj,input,Int)
114
115 /*
116 * This sets multiple attributes of the widget.
117 */
118 void setCDKButtonbox (
119 CDKBUTTONBOX * /* buttonbox */,
120 chtype /* highlight */,
121 boolean /* Box */);
122
123 void setCDKButtonboxCurrentButton (
124 CDKBUTTONBOX * /* buttonbox */,
125 int /* button */);
126
127 int getCDKButtonboxCurrentButton (
128 CDKBUTTONBOX * /* buttonbox */);
129
130 int getCDKButtonboxButtonCount (
131 CDKBUTTONBOX * /* buttonbox */);
132
133 /*
134 * This sets the highlight attribute for the buttonbox.
135 */
136 void setCDKButtonboxHighlight (
137 CDKBUTTONBOX * /* buttonbox */,
138 chtype /* highlight */);
139
140 chtype getCDKButtonboxHighlight (
141 CDKBUTTONBOX * /* buttonbox */);
142
143 /*
144 * This sets the box attribute of the widget.
145 */
146 void setCDKButtonboxBox (
147 CDKBUTTONBOX * /* buttonbox */,
148 boolean /* Box */);
149
150 boolean getCDKButtonboxBox (
151 CDKBUTTONBOX * /* buttonbox */);
152
153 /*
154 * These set the drawing characters of the widget.
155 */
156 #define setCDKButtonboxULChar(w,c) setULCharOf(w,c)
157 #define setCDKButtonboxURChar(w,c) setURCharOf(w,c)
158 #define setCDKButtonboxLLChar(w,c) setLLCharOf(w,c)
159 #define setCDKButtonboxLRChar(w,c) setLRCharOf(w,c)
160 #define setCDKButtonboxVerticalChar(w,c) setVTCharOf(w,c)
161 #define setCDKButtonboxHorizontalChar(w,c) setHZCharOf(w,c)
162 #define setCDKButtonboxBoxAttribute(w,c) setBXAttrOf(w,c)
163
164 /*
165 * This sets the background color of the widget.
166 */
167 #define setCDKButtonboxBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
168
169 /*
170 * This sets the background attribute of the widget.
171 */
172 #define setCDKButtonboxBackgroundAttrib(w,c) setBKAttrOf(w,c)
173
174 /*
175 * This draws the buttonbox box widget.
176 */
177 #define drawCDKButtonbox(obj,box) drawCDKObject(obj,box)
178
179 void drawCDKButtonboxButtons (
180 CDKBUTTONBOX * /* buttonbox */);
181
182 /*
183 * This erases the buttonbox box from the screen.
184 */
185 #define eraseCDKButtonbox(obj) eraseCDKObject(obj)
186
187 /*
188 * This moves the buttonbox box to a new screen location.
189 */
190 #define moveCDKButtonbox(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
191
192 /*
193 * This allows the user to position the widget on the screen interactively.
194 */
195 #define positionCDKButtonbox(widget) positionCDKObject(ObjOf(widget),widget->win)
196
197 /*
198 * This destroys the widget and all the memory associated with it.
199 */
200 #define destroyCDKButtonbox(obj) destroyCDKObject(obj)
201
202 /*
203 * This redraws the buttonbox box buttonboxs.
204 */
205 void redrawCDKButtonboxButtonboxs (
206 CDKBUTTONBOX * /* buttonbox */);
207
208 /*
209 * These set the pre/post process functions of the buttonbox widget.
210 */
211 #define setCDKButtonboxPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
212 #define setCDKButtonboxPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
213
214 #ifdef __cplusplus
215 }
216 #endif
217
218 #endif /* CDKBUTTONBOX_H */
219 #endif /* CDKINCLUDES */
0 /*
1 * $Id: calendar.h,v 1.29 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKCALENDAR_H
6 #define CDKCALENDAR_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 2000-2002,2003 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Declare some definitions needed for this widget.
58 */
59 #define MAX_DAYS 32 /* maximum number of days in any month */
60 #define MAX_MONTHS 13 /* month[0] is unused */
61 #define MAX_YEARS 140 /* years [1901..2140] */
62
63 #define CALENDAR_LIMIT (MAX_DAYS * MAX_MONTHS * MAX_YEARS)
64
65 #define CALENDAR_INDEX(d,m,y) ((((y) * MAX_MONTHS) + (m)) * MAX_DAYS + (d))
66 #define CALENDAR_CELL(c,d,m,y) ((c)->marker[CALENDAR_INDEX(d,m,y)])
67
68 /*
69 * Define the CDK calendar widget structure.
70 */
71 struct SCalendar {
72 CDKOBJS obj;
73 WINDOW * parent;
74 WINDOW * win;
75 WINDOW * labelWin;
76 WINDOW * fieldWin;
77 WINDOW * shadowWin;
78 int titleAdj;
79 int xpos;
80 int ypos;
81 int height;
82 int width;
83 int fieldWidth;
84 int labelLen;
85 chtype yearAttrib;
86 chtype monthAttrib;
87 chtype dayAttrib;
88 chtype highlight;
89 chtype * marker;
90 int day;
91 int month;
92 int year;
93 int weekDay;
94 int boxWidth;
95 int boxHeight;
96 int xOffset;
97 EExitType exitType;
98 boolean shadow;
99 char * DayName;
100 char * MonthName[MAX_MONTHS];
101 };
102 typedef struct SCalendar CDKCALENDAR;
103
104 /*
105 * This creates a pointer to a new calendar widget.
106 */
107 CDKCALENDAR *newCDKCalendar (
108 CDKSCREEN * /* screen */,
109 int /* xPos */,
110 int /* yPos */,
111 char * /* title */,
112 int /* day */,
113 int /* month */,
114 int /* year */,
115 chtype /* dayAttrib */,
116 chtype /* monthAttrib */,
117 chtype /* yearAttrib */,
118 chtype /* highlight */,
119 boolean /* Box */,
120 boolean /* shadow */);
121
122 /*
123 * This activates the calendar widget.
124 */
125 time_t activateCDKCalendar (
126 CDKCALENDAR * /* calendar */,
127 chtype * /* actions */);
128
129 /*
130 * This injects a single character into the widget.
131 */
132 #define injectCDKCalendar(obj,input) injectCDKObject(obj,input,Int)
133
134 /*
135 * This sets multiple attributes of the widget.
136 */
137 void setCDKCalendar (
138 CDKCALENDAR * /* calendar */,
139 int /* day */,
140 int /* month */,
141 int /* year */,
142 chtype /* dayAttrib */,
143 chtype /* monthAttrib */,
144 chtype /* yearAttrib */,
145 chtype /* highlight */,
146 boolean /* Box */);
147
148 /*
149 * This sets the date of the calendar.
150 */
151 void setCDKCalendarDate (
152 CDKCALENDAR * /* calendar */,
153 int /* day */,
154 int /* month */,
155 int /* year */);
156
157 void getCDKCalendarDate (
158 CDKCALENDAR * /* calendar */,
159 int * /* day */,
160 int * /* month */,
161 int * /* year */);
162
163 /*
164 * This sets the attribute of the days in the calendar.
165 */
166 void setCDKCalendarDayAttribute (
167 CDKCALENDAR * /* calendar */,
168 chtype /* attribute */);
169
170 chtype getCDKCalendarDayAttribute (
171 CDKCALENDAR * /* calendar */);
172
173 /*
174 * This sets the attribute of the month names in the calendar.
175 */
176 void setCDKCalendarMonthAttribute (
177 CDKCALENDAR * /* calendar */,
178 chtype /* attribute */);
179
180 chtype getCDKCalendarMonthAttribute (
181 CDKCALENDAR * /* calendar */);
182
183 /*
184 * This sets the attribute of the year in the calendar.
185 */
186 void setCDKCalendarYearAttribute (
187 CDKCALENDAR * /* calendar */,
188 chtype /* attribute */);
189
190 chtype getCDKCalendarYearAttribute (
191 CDKCALENDAR * /* calendar */);
192
193 /*
194 * This sets the attribute of the highlight bar.
195 */
196 void setCDKCalendarHighlight (
197 CDKCALENDAR * /* calendar */,
198 chtype /* highlight */);
199
200 chtype getCDKCalendarHighlight (
201 CDKCALENDAR * /* calendar */);
202
203 /*
204 * This sets the box attribute of the widget.
205 */
206 void setCDKCalendarBox (
207 CDKCALENDAR * /* calendar */,
208 boolean /* Box */);
209
210 boolean getCDKCalendarBox (
211 CDKCALENDAR * /* calendar */);
212
213 /*
214 * These set the drawing characters of the widget.
215 */
216 #define setCDKCalendarULChar(w,c) setULCharOf(w,c)
217 #define setCDKCalendarURChar(w,c) setURCharOf(w,c)
218 #define setCDKCalendarLLChar(w,c) setLLCharOf(w,c)
219 #define setCDKCalendarLRChar(w,c) setLRCharOf(w,c)
220 #define setCDKCalendarVerticalChar(w,c) setVTCharOf(w,c)
221 #define setCDKCalendarHorizontalChar(w,c) setHZCharOf(w,c)
222 #define setCDKCalendarBoxAttribute(w,c) setBXAttrOf(w,c)
223
224 /*
225 * This sets the background color of the widget.
226 */
227 #define setCDKCalendarBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
228
229 /*
230 * This sets the background attribute of the widget.
231 */
232 #define setCDKCalendarBackgroundAttrib(w,c) setBKAttrOf(w,c)
233
234 /*
235 * This sets a marker on the calendar.
236 */
237 void setCDKCalendarMarker (
238 CDKCALENDAR * /* calendar */,
239 int /* day */,
240 int /* month */,
241 int /* year */,
242 chtype /* markerChar */);
243 /*
244 * Return the marker set on the calendar.
245 */
246 chtype getCDKCalendarMarker (
247 CDKCALENDAR * /* calendar */,
248 int /* day */,
249 int /* month */,
250 int /* year */);
251
252 /*
253 * This removes a marker from the calendar.
254 */
255 void removeCDKCalendarMarker (
256 CDKCALENDAR * /* calendar */,
257 int /* day */,
258 int /* month */,
259 int /* year */);
260
261 /*
262 * This draws the widget on the screen.
263 */
264 #define drawCDKCalendar(obj,box) drawCDKObject(obj,box)
265
266 /*
267 * This removes the widget from the screen.
268 */
269 #define eraseCDKCalendar(obj) eraseCDKObject(obj)
270
271 /*
272 * This moves the widget to the given location.
273 */
274 #define moveCDKCalendar(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
275
276 /*
277 * This is an interactive method of moving the widget.
278 */
279 #define positionCDKCalendar(widget) positionCDKObject(ObjOf(widget),widget->win)
280
281 /*
282 * This destroys the calendar widget and all associated memory.
283 */
284 #define destroyCDKCalendar(obj) destroyCDKObject(obj)
285
286 /*
287 * This sets the pre and post process functions.
288 */
289 #define setCDKCalendarPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
290 #define setCDKCalendarPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
291
292 /*
293 * This sets days and months names
294 */
295 void setCDKCalendarMonthsNames (
296 CDKCALENDAR * /* calendar */,
297 char ** /* months */);
298
299 void setCDKCalendarDaysNames (
300 CDKCALENDAR * /* calendar */,
301 char * /* days - 1st is Sunday */);
302
303 #ifdef __cplusplus
304 }
305 #endif
306
307 #endif /* CDKCALENDAR_H */
308 #endif /* CDKINCLUDES */
0 /*
1 * $Id: cdk.h,v 1.34 2004/08/29 21:49:32 tom Exp $
2 */
3
4 #ifndef CDK_H
5 #define CDK_H
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 /*
12 * Changes 2000-2003,2004 copyright Thomas E. Dickey
13 *
14 * Copyright 1999, Mike Glover
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 * 3. All advertising materials mentioning features or use of this software
26 * must display the following acknowledgment:
27 * This product includes software developed by Mike Glover
28 * and contributors.
29 * 4. Neither the name of Mike Glover, nor the names of contributors
30 * may be used to endorse or promote products derived from this software
31 * without specific prior written permission.
32 *
33 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
34 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
35 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
36 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
37 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
41 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
42 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * SUCH DAMAGE.
44 */
45
46 #include <cdk_config.h>
47 #include <cdk_version.h>
48
49 #ifdef CDK_PERL_EXT
50 #undef instr
51 #endif
52
53 #ifdef HAVE_XCURSES
54 #include <xcurses.h>
55 #ifndef mvwhline
56 #define mvwhline(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : whline(win,c,n))
57 #endif
58 #ifndef mvwvline
59 #define mvwvline(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : wvline(win,c,n))
60 #endif
61 #elif defined(HAVE_NCURSESW_NCURSES_H)
62 #include <ncursesw/ncurses.h>
63 #elif defined(HAVE_NCURSES_NCURSES_H)
64 #include <ncurses/ncurses.h>
65 #elif defined(HAVE_NCURSES_H)
66 #include <ncurses.h>
67 #else
68 #include <curses.h>
69 #endif
70
71 #include <sys/types.h>
72 #include <sys/stat.h>
73
74 #include <stdlib.h>
75 #include <string.h>
76 #include <ctype.h>
77 #include <unistd.h>
78 #include <dirent.h>
79 #include <time.h>
80 #include <errno.h>
81 #include <pwd.h>
82 #include <grp.h>
83
84 #ifdef HAVE_LIMITS_H
85 #include <limits.h>
86 #endif
87
88 #ifdef HAVE_GETOPT_HEADER
89 #ifdef HAVE_GETOPT_H
90 #include <getopt.h>
91 #endif
92 #else
93 extern int optind;
94 extern char * optarg;
95 #endif
96
97 /*
98 * Definitions that we do not want if term.h does
99 */
100 #ifdef buttons
101 #undef buttons
102 #endif
103
104 #ifdef lines
105 #undef lines
106 #endif
107
108 #ifdef newline
109 #undef newline
110 #endif
111
112 /*
113 * Values we normally get from limits.h (assume 32-bits)
114 */
115 #ifndef INT_MIN
116 #define INT_MIN (-INT_MAX - 1)
117 #endif
118
119 #ifndef INT_MAX
120 #define INT_MAX 2147483647
121 #endif
122
123 #ifndef GCC_UNUSED
124 #define GCC_UNUSED /*nothing*/
125 #endif
126
127 #ifdef HAVE_LIBDMALLOC
128 #include <dmalloc.h> /* Gray Watson's library */
129 #else
130 #undef HAVE_LIBDMALLOC
131 #define HAVE_LIBDMALLOC 0
132 #endif
133
134 #ifdef HAVE_LIBDBMALLOC
135 #include <dbmalloc.h> /* Conor Cahill's library */
136 #else
137 #undef HAVE_LIBDBMALLOC
138 #define HAVE_LIBDBMALLOC 0
139 #endif
140
141 /*
142 * This enumerated typedef lists all of the CDK widget types.
143 */
144 typedef enum { vNULL = 0
145 ,vALPHALIST
146 ,vBUTTON
147 ,vBUTTONBOX
148 ,vCALENDAR
149 ,vDIALOG
150 ,vDSCALE
151 ,vENTRY
152 ,vFSCALE
153 ,vFSELECT
154 ,vFSLIDER
155 ,vGRAPH
156 ,vHISTOGRAM
157 ,vITEMLIST
158 ,vLABEL
159 ,vMARQUEE
160 ,vMATRIX
161 ,vMENTRY
162 ,vMENU
163 ,vRADIO
164 ,vSCALE
165 ,vSCROLL
166 ,vSELECTION
167 ,vSLIDER
168 ,vSWINDOW
169 ,vTEMPLATE
170 ,vTRAVERSE
171 ,vUSCALE
172 ,vUSLIDER
173 ,vVIEWER
174 } EObjectType;
175
176 /*
177 * This enumerated typedef lists all the valid display types for
178 * the entry, mentry, and template widgets.
179 */
180 typedef enum { vINVALID = 0
181 ,vCHAR
182 ,vHCHAR
183 ,vINT
184 ,vHINT
185 ,vMIXED
186 ,vHMIXED
187 ,vUCHAR
188 ,vLCHAR
189 ,vUHCHAR
190 ,vLHCHAR
191 ,vUMIXED
192 ,vLMIXED
193 ,vUHMIXED
194 ,vLHMIXED
195 ,vVIEWONLY
196 } EDisplayType;
197
198 /*
199 * This enumerated typedef lists all the display types for
200 * the histogram widget.
201 */
202 typedef enum {vNONE, vPERCENT, vFRACTION, vREAL} EHistogramDisplayType;
203
204 /*
205 * This enumerated typedef defines the display types for the graph.
206 */
207 typedef enum {vPLOT, vLINE} EGraphDisplayType;
208
209 /*
210 * This enumerated typedef defines where white space is to be
211 * stripped from in the function stripWhiteSpace.
212 */
213 typedef enum {vFRONT, vBACK, vBOTH} EStripType;
214
215 /*
216 * This enumerated typedef defines the type of exits the widgets
217 * recognize.
218 */
219 typedef enum {vEARLY_EXIT, vESCAPE_HIT, vNORMAL, vNEVER_ACTIVATED} EExitType;
220
221 /*
222 * This defines a boolean type.
223 */
224 typedef int boolean;
225
226 /*
227 * Declare miscellaneous defines.
228 */
229 #define LEFT 9000
230 #define RIGHT 9001
231 #define CENTER 9002
232 #define TOP 9003
233 #define BOTTOM 9004
234 #define HORIZONTAL 9005
235 #define VERTICAL 9006
236 #define FULL 9007
237
238 #define NONE 0
239 #define ROW 1
240 #define COL 2
241
242 #define MAX_BINDINGS 300 /* unused by widgets */
243 #define MAX_ITEMS 2000 /* unused by widgets */
244 #define MAX_BUTTONS 200 /* unused by widgets */
245
246 #define MAXIMUM(a,b) ((a) > (b) ? (a) : (b))
247 #define MINIMUM(a,b) ((a) < (b) ? (a) : (b))
248 #define HALF(a) ((a) >> 1)
249
250 #ifndef COLOR_PAIR
251 #define COLOR_PAIR(a) A_NORMAL
252 #endif
253
254 #define CONTROL(c) ((c) & 0x1f) /* obsolete: use CTRL() */
255
256 /* Define the 'GLOBAL DEBUG FILEHANDLE' */
257 extern FILE *CDKDEBUG;
258
259 /*
260 * =========================================================
261 * Declare Debugging Routines.
262 * =========================================================
263 */
264 #define START_DEBUG(a) (CDKDEBUG=startCDKDebug(a))
265 #define WRITE_DEBUGMESG(a,b) (writeCDKDebugMessage (CDKDEBUG,__FILE__,a,__LINE__,b))
266 #define END_DEBUG (stopCDKDebug(CDKDEBUG)
267 FILE *startCDKDebug(char *filename);
268 void writeCDKDebugMessage (FILE *fd, char *filename, char *function, int line, char *message);
269 void stopCDKDebug (FILE *fd);
270
271 /*
272 * These header files define miscellaneous values and prototypes.
273 */
274 #include <cdkscreen.h>
275 #include <curdefs.h>
276 #include <binding.h>
277 #include <cdk_util.h>
278 #include <cdk_objs.h>
279 #include <cdk_params.h>
280
281 /*
282 * Include the CDK widget header files.
283 */
284 #include <alphalist.h>
285 #include <buttonbox.h>
286 #include <calendar.h>
287 #include <dialog.h>
288 #include <entry.h>
289 #include <fselect.h>
290 #include <graph.h>
291 #include <histogram.h>
292 #include <itemlist.h>
293 #include <label.h>
294 #include <marquee.h>
295 #include <matrix.h>
296 #include <mentry.h>
297 #include <menu.h>
298 #include <radio.h>
299 #include <scroll.h>
300 #include <selection.h>
301 #include <swindow.h>
302 #include <template.h>
303 #include <viewer.h>
304 #include <traverse.h>
305 #include <button.h>
306
307 /*
308 * Generated headers:
309 */
310 #include <dscale.h>
311 #include <fscale.h>
312 #include <scale.h>
313 #include <uscale.h>
314
315 #include <fslider.h>
316 #include <slider.h>
317 #include <uslider.h>
318
319 /*
320 * Low-level object drawing
321 */
322 #include <draw.h>
323
324 #ifdef __cplusplus
325 }
326 #endif
327
328 #endif /* CDK_H */
0 /*
1 * $Id: cdk_compat.h,v 1.2 2005/12/28 21:45:45 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDK_COMPAT_H
6 #define CDK_COMPAT_H
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 /*
13 * Copyright 2004,2005 Thomas E. Dickey
14 * All rights reserved.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgment:
26 * This product includes software developed by Thomas Dickey
27 * and contributors.
28 * 4. Neither the name of Thomas Dickey, nor the names of contributors
29 * may be used to endorse or promote products derived from this software
30 * without specific prior written permission.
31 *
32 * THIS SOFTWARE IS PROVIDED BY THOMAS DICKEY AND CONTRIBUTORS ``AS IS'' AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 * ARE DISCLAIMED. IN NO EVENT SHALL THOMAS DICKEY OR CONTRIBUTORS BE LIABLE
36 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 * SUCH DAMAGE.
43 */
44
45 /*
46 * Renaming of struct members was done for consistency. Making old/new
47 * versions compatible with renaming is awkward (there may be inadvertant
48 * naming collisions), but this is mainly for demonstration purposes.
49 */
50 #define info list
51 #define infoSize listSize
52 #define itemCount listSize
53 #define boxMatrix box
54
55 /*
56 * Include the Cdk header file, which includes everything except for this file.
57 */
58 #include <cdk.h>
59
60 /*
61 * This is defined via the new header file:
62 */
63 #ifdef CDK_VERSION_PATCH
64
65 /*
66 * If we included the new Cdk header file, provide definitions for things
67 * which have been made obsolete.
68 */
69
70 #define MAX_LINES 5000
71
72 #define WIN_WIDTH(a) getmaxx(a)
73 #define WIN_HEIGHT(a) getmaxy(a)
74 #define WIN_XPOS(a) getbegx(a)
75 #define WIN_YPOS(a) getbegy(a)
76
77 extern int getDirectoryContents (char *directory, char **list, int maxListSize);
78 extern int readFile (char *filename, char **info, int maxlines);
79 extern int splitString (char *string, char **items, char splitChar);
80
81 #else
82
83 /*
84 * Provide definitions to allow the applications using the old header to
85 * compile using the new header's macros:
86 */
87 #define ObjOf(a) (a)
88 #define ScreenOf(a) (a)
89
90 #endif /* CDK_VERSION_PATCH */
91
92 #ifdef __cplusplus
93 }
94 #endif
95
96 #endif /* CDK_COMPAT_H */
97 #endif /* CDKINCLUDES */
0 /*
1 * $Id: cdk_int.h,v 1.19 2005/04/15 00:01:49 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDK_INT_H
6 #define CDK_INT_H
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #include <cdk.h>
13
14 /*
15 * Copyright 2003-2004,2005 Thomas E. Dickey
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 * 3. All advertising materials mentioning features or use of this software
27 * must display the following acknowledgment:
28 * This product includes software developed by Thomas Dickey
29 * and contributors.
30 * 4. Neither the name of Thomas Dickey, nor the names of contributors
31 * may be used to endorse or promote products derived from this software
32 * without specific prior written permission.
33 *
34 * THIS SOFTWARE IS PROVIDED BY THOMAS DICKEY AND CONTRIBUTORS ``AS IS'' AND
35 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 * ARE DISCLAIMED. IN NO EVENT SHALL THOMAS DICKEY OR CONTRIBUTORS BE LIABLE
38 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
43 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 * SUCH DAMAGE.
45 */
46
47 #define typeCallocN(type,n) (type*)calloc(n, sizeof(type))
48 #define typeCalloc(type) typeCallocN(type,1)
49
50 #define typeReallocN(type,p,n) (type*)realloc(p, (n) * sizeof(type))
51
52 #define typeMallocN(type,n) (type*)malloc((n) * sizeof(type))
53 #define typeMalloc(type) typeMallocN(type,1)
54
55 #define freeChecked(p) if ((p) != 0) free (p)
56 #define freeAndNull(p) if ((p) != 0) { free (p); p = 0; }
57
58 #define isChar(c) ((int)(c) >= 0 && (int)(c) < KEY_MIN)
59 #define CharOf(c) ((unsigned char)(c))
60
61 #define SIZEOF(v) (sizeof(v)/sizeof((v)[0]))
62
63 /*
64 * Macros to check if caller is attempting to make the widget as high (or wide)
65 * as the screen.
66 */
67 #define isFullWidth(n) ((n) == FULL || (COLS != 0 && ((n) >= COLS)))
68 #define isFullHeight(n) ((n) == FULL || (LINES != 0 && ((n) >= LINES)))
69
70 /*
71 * Hide details of modifying widget->exitType
72 */
73 #define storeExitType(d) ObjOf(d)->exitType = (d)->exitType
74 #define initExitType(d) storeExitType(d) = vNEVER_ACTIVATED
75 #define setExitType(w,c) setCdkExitType(ObjOf(w), &((w)->exitType), c)
76 #define copyExitType(d,s) storeExitType(d) = ExitTypeOf(s)
77
78 /*
79 * Use this if checkCDKObjectBind() returns true, use this function to
80 * decide if the exitType should be set as a side-effect.
81 */
82 #define checkEarlyExit(w) if (EarlyExitOf(w) != vNEVER_ACTIVATED) \
83 storeExitType(w) = EarlyExitOf(w)
84
85 /*
86 * Simplify case-statements for scrollers
87 */
88 #define scroller_KEY_UP(w) \
89 if ((w)->listSize > 0) { \
90 if ((w)->currentItem > 0) { \
91 if ((w)->currentHigh == 0) { \
92 if ((w)->currentTop != 0) { \
93 (w)->currentTop--; \
94 (w)->currentItem--; \
95 } else { \
96 Beep(); \
97 } \
98 } else { \
99 (w)->currentItem--; \
100 (w)->currentHigh--; \
101 } \
102 } else { \
103 Beep(); \
104 } \
105 } else { \
106 Beep(); \
107 }
108
109 #define scroller_KEY_DOWN(w) \
110 if ((w)->listSize > 0) { \
111 if ((w)->currentItem < (w)->listSize-1) { \
112 if ((w)->currentHigh == (w)->viewSize - 1) { \
113 if ((w)->currentTop < (w)->maxTopItem) { \
114 (w)->currentTop++; \
115 (w)->currentItem++; \
116 } else { \
117 Beep(); \
118 } \
119 } else { \
120 (w)->currentItem++; \
121 (w)->currentHigh++; \
122 } \
123 } else { \
124 Beep(); \
125 } \
126 } else { \
127 Beep(); \
128 }
129
130 #define scroller_KEY_LEFT(w) \
131 if ((w)->listSize > 0) { \
132 if ((w)->leftChar == 0) { \
133 Beep(); \
134 } else { \
135 (w)->leftChar --; \
136 } \
137 } else { \
138 Beep(); \
139 }
140
141 #define scroller_KEY_RIGHT(w) \
142 if ((w)->listSize > 0) { \
143 if ((w)->leftChar >= (w)->maxLeftChar) { \
144 Beep(); \
145 } else { \
146 (w)->leftChar ++; \
147 } \
148 } else { \
149 Beep(); \
150 }
151
152 #define scroller_KEY_PPAGE(w) \
153 if ((w)->listSize > 0) { \
154 if ((w)->currentTop > 0) { \
155 if ((w)->currentTop >= ((w)->viewSize -1)) { \
156 (w)->currentTop -= ((w)->viewSize - 1); \
157 (w)->currentItem -= ((w)->viewSize - 1); \
158 } else { \
159 scroller_KEY_HOME(w); \
160 } \
161 } else { \
162 Beep(); \
163 } \
164 } else { \
165 Beep(); \
166 }
167
168 #define scroller_KEY_NPAGE(w) \
169 if ((w)->listSize > 0) { \
170 if ((w)->currentTop < (w)->maxTopItem) { \
171 if (((w)->currentTop + (w)->viewSize - 1) <= (w)->maxTopItem) { \
172 (w)->currentTop += ((w)->viewSize - 1); \
173 (w)->currentItem += ((w)->viewSize - 1); \
174 } else { \
175 (w)->currentTop = (w)->maxTopItem; \
176 (w)->currentItem = (w)->lastItem; \
177 (w)->currentHigh = (w)->viewSize-1; \
178 } \
179 } else { \
180 Beep(); \
181 } \
182 } else { \
183 Beep(); \
184 }
185
186 #define scroller_KEY_HOME(w) \
187 (w)->currentTop = 0; \
188 (w)->currentItem = 0; \
189 (w)->currentHigh = 0
190
191 #define scroller_KEY_END(w) \
192 if ((w)->maxTopItem == -1) { \
193 (w)->currentTop = 0; \
194 (w)->currentItem = (w)->lastItem - 1; \
195 } else { \
196 (w)->currentTop = (w)->maxTopItem; \
197 (w)->currentItem = (w)->lastItem; \
198 } \
199 (w)->currentHigh = (w)->viewSize - 1
200
201 #define scroller_SetPosition(w, item) \
202 if (item <= 0) { \
203 scroller_KEY_HOME((w)); \
204 } else if (item > (w)->listSize-1) { \
205 (w)->currentTop = (w)->maxTopItem; \
206 (w)->currentItem = (w)->listSize - 1; \
207 (w)->currentHigh = (w)->viewSize - 1; \
208 } else if (item >= (w)->currentTop \
209 && item < (w)->currentTop + (w)->viewSize) { \
210 (w)->currentItem = item; \
211 (w)->currentHigh = item - (w)->currentTop; \
212 } else { \
213 (w)->currentTop = item; \
214 (w)->currentItem = item; \
215 (w)->currentHigh = 0; \
216 }
217
218 #define scroller_MaxViewSize(w) \
219 ((w)->boxHeight - (2*BorderOf(w) + TitleLinesOf(w)))
220
221 #define scroller_SetViewSize(w, size) \
222 (w)->viewSize = maxViewSize(w); \
223 (w)->listSize = listSize; \
224 (w)->lastItem = listSize - 1; \
225 (w)->maxTopItem = listSize - (w)->viewSize; \
226 \
227 if (listSize < (w)->viewSize) { \
228 (w)->viewSize = listSize; \
229 (w)->maxTopItem = 0; \
230 } \
231 \
232 if ((w)->listSize > 0 && maxViewSize((w)) > 0) { \
233 (w)->step = (maxViewSize((w)) / (float)(w)->listSize); \
234 (w)->toggleSize = ((w)->listSize > (maxViewSize((w))) ? 1 : ceilCDK((w)->step)); \
235 } else { \
236 (w)->step = 1; \
237 (w)->toggleSize = 1; \
238 }
239
240 /*
241 * Position within the data area of a widget, accounting for border and title.
242 */
243 #define SCREEN_XPOS(w,n) ((n) + BorderOf(w))
244 #define SCREEN_YPOS(w,n) ((n) + BorderOf(w) + TitleLinesOf(w))
245
246 /*
247 * Miscellaneous definitions.
248 */
249 #define CDK_PATHMAX 256
250
251 extern char *GPasteBuffer;
252
253 #ifdef __cplusplus
254 }
255 #endif
256
257 #endif /* CDK_INT_H */
258 #endif /* CDKINCLUDES */
0 /*
1 * $Id: cdk_objs.h,v 1.37 2005/12/29 23:58:35 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDK_OBJS_H
6 #define CDK_OBJS_H
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #endif
19
20 /*
21 * Copyright 1999-2004,2005 Thomas E. Dickey
22 * All rights reserved.
23 *
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
26 * are met:
27 * 1. Redistributions of source code must retain the above copyright
28 * notice, this list of conditions and the following disclaimer.
29 * 2. Redistributions in binary form must reproduce the above copyright
30 * notice, this list of conditions and the following disclaimer in the
31 * documentation and/or other materials provided with the distribution.
32 * 3. All advertising materials mentioning features or use of this software
33 * must display the following acknowledgment:
34 * This product includes software developed by Thomas Dickey
35 * and contributors.
36 * 4. Neither the name of Thomas Dickey, nor the names of contributors
37 * may be used to endorse or promote products derived from this software
38 * without specific prior written permission.
39 *
40 * THIS SOFTWARE IS PROVIDED BY THOMAS DICKEY AND CONTRIBUTORS ``AS IS'' AND
41 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43 * ARE DISCLAIMED. IN NO EVENT SHALL THOMAS DICKEY OR CONTRIBUTORS BE LIABLE
44 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50 * SUCH DAMAGE.
51 */
52
53 typedef struct CDKBINDING {
54 BINDFN bindFunction;
55 void * bindData;
56 PROCESSFN callbackfn;
57 } CDKBINDING;
58
59 struct CDKOBJS;
60
61 /*
62 * Types for CDKFUNCS.returnType
63 */
64 typedef enum {
65 DataTypeUnknown = 0
66 , DataTypeString
67 , DataTypeInt
68 , DataTypeFloat
69 , DataTypeDouble
70 , DataTypeUnsigned
71 } CDKDataType;
72
73 typedef union {
74 char * valueString;
75 int valueInt;
76 float valueFloat;
77 double valueDouble;
78 unsigned valueUnsigned;
79 } CDKDataUnion;
80
81 #define unknownString (char *)0
82 #define unknownInt (-1)
83 #define unknownFloat (0.0)
84 #define unknownDouble (0.0)
85 #define unknownUnsigned (0)
86
87 /*
88 * Methods common to all widgets.
89 */
90 typedef struct CDKFUNCS {
91 EObjectType objectType;
92 CDKDataType returnType;
93 void (*drawObj) (struct CDKOBJS *, boolean);
94 void (*eraseObj) (struct CDKOBJS *);
95 void (*moveObj) (struct CDKOBJS *, int, int, boolean, boolean);
96 int (*injectObj) (struct CDKOBJS *, chtype);
97 void (*focusObj) (struct CDKOBJS *);
98 void (*unfocusObj) (struct CDKOBJS *);
99 void (*saveDataObj) (struct CDKOBJS *);
100 void (*refreshDataObj) (struct CDKOBJS *);
101 void (*destroyObj) (struct CDKOBJS *);
102 /* line-drawing */
103 void (*setULcharObj) (struct CDKOBJS *, chtype);
104 void (*setURcharObj) (struct CDKOBJS *, chtype);
105 void (*setLLcharObj) (struct CDKOBJS *, chtype);
106 void (*setLRcharObj) (struct CDKOBJS *, chtype);
107 void (*setVTcharObj) (struct CDKOBJS *, chtype);
108 void (*setHZcharObj) (struct CDKOBJS *, chtype);
109 void (*setBXattrObj) (struct CDKOBJS *, chtype);
110 /* background attribute */
111 void (*setBKattrObj) (struct CDKOBJS *, chtype);
112 } CDKFUNCS;
113
114 /* The cast is needed because traverse.c wants to use CDKOBJS pointers */
115 #define ObjPtr(p) ((CDKOBJS*)(p))
116
117 #define MethodPtr(p,m) ((ObjPtr(p))->fn->m)
118
119 /* Use these when we're certain it is a CDKOBJS pointer */
120 #define ObjTypeOf(p) MethodPtr(p,objectType)
121 #define DataTypeOf(p) MethodPtr(p,returnType)
122 #define DrawObj(p) MethodPtr(p,drawObj) (p,p->box)
123 #define EraseObj(p) MethodPtr(p,eraseObj) (p)
124 #define DestroyObj(p) MethodPtr(p,destroyObj) (p)
125 #define InjectObj(p,k) MethodPtr(p,injectObj) (p,(k))
126 #define InputWindowObj(p) MethodPtr(p,inputWindowObj) (p)
127 #define FocusObj(p) MethodPtr(p,focusObj) (p)
128 #define UnfocusObj(p) MethodPtr(p,unfocusObj) (p)
129 #define SaveDataObj(p) MethodPtr(p,saveDataObj) (p)
130 #define RefreshDataObj(p) MethodPtr(p,refreshDataObj) (p)
131 #define SetBackAttrObj(p,c) MethodPtr(p,setBKattrObj) (p,c)
132
133 #define AcceptsFocusObj(p) (ObjPtr(p)->acceptsFocus)
134 #define HasFocusObj(p) (ObjPtr(p)->hasFocus)
135 #define IsVisibleObj(p) (ObjPtr(p)->isVisible)
136 #define InputWindowOf(p) (ObjPtr(p)->inputWindow)
137
138 /*
139 * Data common to all objects (widget instances). This appears first in
140 * each widget's struct to allow us to use generic functions in binding.c,
141 * cdkscreen.c, position.c, etc.
142 */
143 typedef struct CDKOBJS {
144 int screenIndex;
145 CDKSCREEN * screen;
146 const CDKFUNCS * fn;
147 boolean box;
148 int borderSize;
149 boolean acceptsFocus;
150 boolean hasFocus;
151 boolean isVisible;
152 WINDOW * inputWindow;
153 void * dataPtr;
154 CDKDataUnion resultData;
155 unsigned bindingCount;
156 CDKBINDING * bindingList;
157 /* title-drawing */
158 chtype ** title;
159 int * titlePos;
160 int * titleLen;
161 int titleLines;
162 /* line-drawing (see 'box') */
163 chtype ULChar; /* lines: upper-left */
164 chtype URChar; /* lines: upper-right */
165 chtype LLChar; /* lines: lower-left */
166 chtype LRChar; /* lines: lower-right */
167 chtype VTChar; /* lines: vertical */
168 chtype HZChar; /* lines: horizontal */
169 chtype BXAttr;
170 /* events */
171 EExitType exitType;
172 EExitType earlyExit;
173 /* pre/post-processing */
174 PROCESSFN preProcessFunction;
175 void * preProcessData;
176 PROCESSFN postProcessFunction;
177 void * postProcessData;
178 } CDKOBJS;
179
180 #define ObjOf(ptr) (&(ptr)->obj)
181 #define MethodOf(ptr) (ObjOf(ptr)->fn)
182 #define ScreenOf(ptr) (ObjOf(ptr)->screen)
183 #define WindowOf(ptr) (ScreenOf(ptr)->window)
184 #define BorderOf(p) (ObjOf(p)->borderSize)
185 #define ResultOf(p) (ObjOf(p)->resultData)
186 #define ExitTypeOf(p) (ObjOf(p)->exitType)
187 #define EarlyExitOf(p) (ObjOf(p)->earlyExit)
188
189 /* titles */
190 #define TitleOf(w) ObjOf(w)->title
191 #define TitlePosOf(w) ObjOf(w)->titlePos
192 #define TitleLenOf(w) ObjOf(w)->titleLen
193 #define TitleLinesOf(w) ObjOf(w)->titleLines
194
195 /* line-drawing characters */
196 #define ULCharOf(w) ObjOf(w)->ULChar
197 #define URCharOf(w) ObjOf(w)->URChar
198 #define LLCharOf(w) ObjOf(w)->LLChar
199 #define LRCharOf(w) ObjOf(w)->LRChar
200 #define VTCharOf(w) ObjOf(w)->VTChar
201 #define HZCharOf(w) ObjOf(w)->HZChar
202 #define BXAttrOf(w) ObjOf(w)->BXAttr
203
204 #define setULCharOf(o,c) MethodOf(o)->setULcharObj(ObjOf(o),c)
205 #define setURCharOf(o,c) MethodOf(o)->setURcharObj(ObjOf(o),c)
206 #define setLLCharOf(o,c) MethodOf(o)->setLLcharObj(ObjOf(o),c)
207 #define setLRCharOf(o,c) MethodOf(o)->setLRcharObj(ObjOf(o),c)
208 #define setVTCharOf(o,c) MethodOf(o)->setVTcharObj(ObjOf(o),c)
209 #define setHZCharOf(o,c) MethodOf(o)->setHZcharObj(ObjOf(o),c)
210 #define setBXAttrOf(o,c) MethodOf(o)->setBXattrObj(ObjOf(o),c)
211 #define setBKAttrOf(o,c) MethodOf(o)->setBKattrObj(ObjOf(o),c)
212
213 /* pre/post-processing */
214 #define PreProcessFuncOf(w) (ObjOf(w)->preProcessFunction)
215 #define PreProcessDataOf(w) (ObjOf(w)->preProcessData)
216 #define PostProcessFuncOf(w) (ObjOf(w)->postProcessFunction)
217 #define PostProcessDataOf(w) (ObjOf(w)->postProcessData)
218
219 /* FIXME - remove this */
220 #define ReturnOf(p) (ObjPtr(p)->dataPtr)
221
222 bool validCDKObject (CDKOBJS *);
223
224 void * _newCDKObject(unsigned, const CDKFUNCS *);
225 #define newCDKObject(type,funcs) (type *)_newCDKObject(sizeof(type),funcs)
226
227 void _destroyCDKObject (CDKOBJS *);
228 #define destroyCDKObject(o) _destroyCDKObject(ObjOf(o))
229
230 /* Use these for widgets that have an obj member which is a CDKOBJS struct */
231 #define drawCDKObject(o,box) MethodOf(o)->drawObj (ObjOf(o),box)
232 #define eraseCDKObject(o) MethodOf(o)->eraseObj (ObjOf(o))
233 #define moveCDKObject(o,x,y,rel,ref) MethodOf(o)->moveObj (ObjOf(o),x,y,rel,ref)
234 #define injectCDKObject(o,c,type) (MethodOf(o)->injectObj (ObjOf(o),c) ? ResultOf(o).value ## type : unknown ## type)
235
236 /* functions to set line-drawing are bound to cdk_objs.c if the widget is
237 * simple, but are built into the widget for complex widgets.
238 */
239 #define DeclareSetXXchar(storage,line) \
240 storage void line ## ULchar(struct CDKOBJS *, chtype); \
241 storage void line ## URchar(struct CDKOBJS *, chtype); \
242 storage void line ## LLchar(struct CDKOBJS *, chtype); \
243 storage void line ## LRchar(struct CDKOBJS *, chtype); \
244 storage void line ## VTchar(struct CDKOBJS *, chtype); \
245 storage void line ## HZchar(struct CDKOBJS *, chtype); \
246 storage void line ## BXattr(struct CDKOBJS *, chtype)
247
248 DeclareSetXXchar(extern,setCdk);
249
250 #define DeclareCDKObjects(upper, mixed, line, type) \
251 static int _injectCDK ## mixed (struct CDKOBJS *, chtype); \
252 static void _destroyCDK ## mixed (struct CDKOBJS *); \
253 static void _drawCDK ## mixed (struct CDKOBJS *, boolean); \
254 static void _eraseCDK ## mixed (struct CDKOBJS *); \
255 static void _focusCDK ## mixed (struct CDKOBJS *); \
256 static void _moveCDK ## mixed (struct CDKOBJS *, int, int, boolean, boolean); \
257 static void _refreshDataCDK ## mixed (struct CDKOBJS *); \
258 static void _saveDataCDK ## mixed (struct CDKOBJS *); \
259 static void _unfocusCDK ## mixed (struct CDKOBJS *); \
260 static void _setBKattr ## mixed (struct CDKOBJS *, chtype); \
261 static const CDKFUNCS my_funcs = { \
262 v ## upper, \
263 DataType ## type, \
264 _drawCDK ## mixed, \
265 _eraseCDK ## mixed, \
266 _moveCDK ## mixed, \
267 _injectCDK ## mixed, \
268 _focusCDK ## mixed, \
269 _unfocusCDK ## mixed, \
270 _saveDataCDK ## mixed, \
271 _refreshDataCDK ## mixed, \
272 _destroyCDK ## mixed, \
273 line ## ULchar, \
274 line ## URchar, \
275 line ## LLchar, \
276 line ## LRchar, \
277 line ## VTchar, \
278 line ## HZchar, \
279 line ## BXattr, \
280 _setBKattr ## mixed, \
281 }
282
283 /*
284 * Some methods are unused. Define macros to represent dummy methods
285 * to make it simple to maintain them.
286 */
287 #define dummyInject(mixed) \
288 static int _injectCDK ## mixed (CDKOBJS * object GCC_UNUSED, chtype input GCC_UNUSED) \
289 { \
290 return 0; \
291 }
292
293 #define dummyFocus(mixed) \
294 static void _focusCDK ## mixed (CDKOBJS * object GCC_UNUSED) \
295 { \
296 }
297
298 #define dummyUnfocus(mixed) \
299 static void _unfocusCDK ## mixed (CDKOBJS * object GCC_UNUSED) \
300 { \
301 }
302
303 #define dummySaveData(mixed) \
304 static void _saveDataCDK ## mixed (CDKOBJS * object GCC_UNUSED) \
305 { \
306 }
307
308 #define dummyRefreshData(mixed) \
309 static void _refreshDataCDK ## mixed (CDKOBJS * object GCC_UNUSED) \
310 { \
311 }
312
313 /*
314 * Read keycode from object, optionally translating bindings.
315 * Depcrecated: use getchCDKObject().
316 */
317 extern int getcCDKObject (
318 CDKOBJS * /* object */);
319
320 /*
321 * Read keycode from object, optionally translating bindings. Set a flag to
322 * tell if the keycode is a function key.
323 */
324 extern int getchCDKObject (
325 CDKOBJS * /* object */,
326 boolean * /* functionKey */);
327
328 /*
329 * Interactively reposition an object within a window.
330 */
331 extern void positionCDKObject (
332 CDKOBJS * /* object */,
333 WINDOW * /* win */);
334
335 /*
336 * Pre/postprocessing.
337 */
338 extern void setCDKObjectPreProcess (
339 CDKOBJS * /* object */,
340 PROCESSFN /* func */,
341 void * /* data */);
342
343 extern void setCDKObjectPostProcess (
344 CDKOBJS * /* object */,
345 PROCESSFN /* func */,
346 void * /* data */);
347
348 /*
349 * Background color.
350 */
351 extern void setCDKObjectBackgroundColor (
352 CDKOBJS * /* object */,
353 char * /* color */);
354
355 /* title-storage is implemented identically with all widgets */
356 extern int setCdkTitle (CDKOBJS *, char *, int);
357 extern void drawCdkTitle (WINDOW *, CDKOBJS *);
358 extern void cleanCdkTitle (CDKOBJS *);
359
360 #define setCdkEarlyExit(p,q) EarlyExitOf(p) = q
361
362 extern void setCdkExitType(
363 CDKOBJS * /* obj */,
364 EExitType * /* type */,
365 chtype /* ch */);
366
367 #ifdef __cplusplus
368 }
369 #endif
370
371 #endif /* CDK_OBJS_H */
372 #endif /* CDKINCLUDES */
0 /*
1 * $Id: cdk_params.h,v 1.6 2005/12/27 14:08:18 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDK_PARAMS_H
6 #define CDK_PARAMS_H
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #endif
17
18 /*
19 * Copyright 2003,2005 Thomas E. Dickey
20 * All rights reserved.
21 *
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
24 * are met:
25 * 1. Redistributions of source code must retain the above copyright
26 * notice, this list of conditions and the following disclaimer.
27 * 2. Redistributions in binary form must reproduce the above copyright
28 * notice, this list of conditions and the following disclaimer in the
29 * documentation and/or other materials provided with the distribution.
30 * 3. All advertising materials mentioning features or use of this software
31 * must display the following acknowledgment:
32 * This product includes software developed by Thomas Dickey
33 * and contributors.
34 * 4. Neither the name of Thomas Dickey, nor the names of contributors
35 * may be used to endorse or promote products derived from this software
36 * without specific prior written permission.
37 *
38 * THIS SOFTWARE IS PROVIDED BY THOMAS DICKEY AND CONTRIBUTORS ``AS IS'' AND
39 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
41 * ARE DISCLAIMED. IN NO EVENT SHALL THOMAS DICKEY OR CONTRIBUTORS BE LIABLE
42 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
44 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
46 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
47 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48 * SUCH DAMAGE.
49 */
50
51 #define MAX_CDK_PARAMS 256
52
53 /*
54 * CDKparseParams() knows about these options and will decode them into
55 * the CDK_PARAMS struct. They are the most generally useful for positioning
56 * a widget.
57 */
58 #define CDK_MIN_PARAMS "NSX:Y:"
59 #define CDK_CLI_PARAMS "NSX:Y:H:W:"
60
61 /*
62 * Use this exit code rather than -1 for cli programs which have reported an
63 * error. Actually EXIT_FAILURE would be better, but the shell script samples
64 * all are written to assume that the exit code can be used to indicate a
65 * button number, etc.
66 */
67 #define CLI_ERROR 255
68
69 /*
70 * This records the values that CDKparseParams() decodes using getopt():
71 */
72 typedef struct CDK_PARAMS {
73 char * allParams[MAX_CDK_PARAMS];
74 bool Box;
75 bool Shadow;
76 int hValue;
77 int wValue;
78 int xValue;
79 int yValue;
80 } CDK_PARAMS;
81
82 /*
83 * Parse the given argc/argv command-line, with the options passed to
84 * getopt()'s 3rd parameter.
85 */
86 void CDKparseParams (
87 int /* argc */,
88 char ** /* argv */,
89 CDK_PARAMS * /* params */,
90 char * /* options */);
91
92 /*
93 * Parse the string as one of CDK's positioning keywords, or an actual
94 * position.
95 */
96 int CDKparsePosition (
97 char * /* string */);
98
99 /*
100 * Retrieve an integer (or boolean) option value from the parsed command-line.
101 */
102 int CDKparamNumber (
103 CDK_PARAMS * /* params */,
104 int /* option */);
105
106 /*
107 * Retrieve an optional integer (or boolean) value from the parsed command-line.
108 */
109 int CDKparamNumber2 (
110 CDK_PARAMS * /* params */,
111 int /* option */,
112 int /* missing */);
113
114 /*
115 * Retrieve a string option value from the parsed command-line.
116 */
117 char * CDKparamString (
118 CDK_PARAMS * /* params */,
119 int /* option */);
120
121 /*
122 * Retrieve an optional string option value from the parsed command-line.
123 */
124 char * CDKparamString2 (
125 CDK_PARAMS * /* params */,
126 int /* option */,
127 char * /* missing */);
128
129 /*
130 * Retrieve an integer (or boolean) option value from the parsed command-line.
131 */
132 int CDKparamValue (
133 CDK_PARAMS * /* params */,
134 int /* option */,
135 int /* missing */);
136
137 #ifdef __cplusplus
138 }
139 #endif
140
141 #endif /* CDK_PARAMS_H */
142 #endif /* CDKINCLUDES */
0 /*
1 * $Id: cdk_test.h,v 1.2 2005/12/26 22:29:23 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDK_TEST_H
6 #define CDK_TEST_H
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #include <cdk.h>
13
14 /*
15 * Copyright 2005 Thomas E. Dickey
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 * 3. All advertising materials mentioning features or use of this software
27 * must display the following acknowledgment:
28 * This product includes software developed by Thomas Dickey
29 * and contributors.
30 * 4. Neither the name of Thomas Dickey, nor the names of contributors
31 * may be used to endorse or promote products derived from this software
32 * without specific prior written permission.
33 *
34 * THIS SOFTWARE IS PROVIDED BY THOMAS DICKEY AND CONTRIBUTORS ``AS IS'' AND
35 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 * ARE DISCLAIMED. IN NO EVENT SHALL THOMAS DICKEY OR CONTRIBUTORS BE LIABLE
38 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
43 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 * SUCH DAMAGE.
45 */
46
47 /*
48 * The whole point of this header is to define ExitProgram(), which is used for
49 * leak-checking when ncurses's _nc_free_and_exit() function is available.
50 * Invoking that rather than 'exit()' tells ncurses to free all of the
51 * "permanent" memory leaks, making analysis much simpler.
52 */
53 #ifdef HAVE_NC_ALLOC_H
54
55 #ifndef HAVE_LIBDBMALLOC
56 #define HAVE_LIBDBMALLOC 0
57 #endif
58
59 #ifndef HAVE_LIBDMALLOC
60 #define HAVE_LIBDMALLOC 0
61 #endif
62
63 #ifndef HAVE_LIBMPATROL
64 #define HAVE_LIBMPATROL 0
65 #endif
66
67 #include <nc_alloc.h>
68 #endif
69
70 #ifndef ExitProgram
71 #define ExitProgram(code) exit(code)
72 #endif
73
74 #ifdef __cplusplus
75 }
76 #endif
77
78 #endif /* CDK_TEST_H */
79 #endif /* CDKINCLUDES */
0 /*
1 * $Id: cdk_util.h,v 1.28 2006/04/22 16:17:32 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKUTIL_H
6 #define CDKUTIL_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #endif
19
20 /*
21 * Changes 1999-2005,2006 copyright Thomas E. Dickey
22 *
23 * Copyright 1999, Mike Glover
24 * All rights reserved.
25 *
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
28 * are met:
29 * 1. Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in the
33 * documentation and/or other materials provided with the distribution.
34 * 3. All advertising materials mentioning features or use of this software
35 * must display the following acknowledgment:
36 * This product includes software developed by Mike Glover
37 * and contributors.
38 * 4. Neither the name of Mike Glover, nor the names of contributors
39 * may be used to endorse or promote products derived from this software
40 * without specific prior written permission.
41 *
42 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
43 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
46 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52 * SUCH DAMAGE.
53 */
54
55 /*
56 * This beeps at the user. The standard curses beep() does not
57 * flush the stream, so it will only beep until a force is made.
58 * This forces a flush after issuing the beep command.
59 */
60 void Beep(void);
61
62 /*
63 * This aligns a 'box' on the given window with the height and
64 * width given.
65 */
66 void alignxy (
67 WINDOW * /* window */,
68 int * /* xpos */,
69 int * /* ypos */,
70 int /* boxWidth */,
71 int /* boxHeight */);
72
73 /*
74 * This takes a string, a field width and a justification type and returns the
75 * justification adjustment to make, to fill the justification requirement.
76 */
77 int justifyString (
78 int /* fieldWidth */,
79 int /* mesglen */,
80 int /* justify */);
81
82 /*
83 * This is a quick little popup label widget.
84 */
85 void popupLabel (
86 CDKSCREEN * /* win */,
87 char ** /* mesg */,
88 int /* count */);
89
90 /*
91 * This is a quick little popup label widget.
92 */
93 void popupLabelAttrib (
94 CDKSCREEN * /* win */,
95 char ** /* mesg */,
96 int /* count */,
97 chtype /* attribute */);
98
99 /*
100 * This is a quick little popup dialog box.
101 */
102 int popupDialog (
103 CDKSCREEN * /* screen */,
104 char ** /* mesg */,
105 int /* mesgCount */,
106 char ** /* buttons */,
107 int /* buttonCount */);
108
109 /*
110 * This pops up a scrolling list and returns the value selected.
111 */
112 int getListIndex (
113 CDKSCREEN * /* screen */,
114 char * /* title */,
115 char ** /* list */,
116 int /* listSize */,
117 boolean /* numbers */);
118
119 /*
120 * This gets a simple string value from a user.
121 */
122 char *getString (
123 CDKSCREEN * /* screen */,
124 char * /* title */,
125 char * /* label */,
126 char * /* init */);
127
128 /*
129 * This allows a user to view a file.
130 */
131 int viewFile (
132 CDKSCREEN * /* screen */,
133 char * /* title */,
134 char * /* filename */,
135 char ** /* buttons */,
136 int /* buttonCount */);
137
138 /*
139 * This allows a person to select a file.
140 */
141 char *selectFile (
142 CDKSCREEN * /* screen */,
143 char * /* title */);
144
145 /*
146 * This allows people to view information in an array.
147 */
148 int viewInfo (
149 CDKSCREEN * /* screen */,
150 char * /* title */,
151 char ** /* info */,
152 int /* size */,
153 char ** /* buttons */,
154 int /* buttonCount */,
155 boolean /* interpret */);
156
157 /*
158 * This is a wrapper for qsort.
159 */
160 void sortList (
161 char ** /* list */,
162 int /* length */);
163
164 /*
165 * This reads a file, loads the contents into info and
166 * returns the number of lines read.
167 */
168 int CDKreadFile (
169 char * /* filename */,
170 char *** /* info */);
171
172 /*
173 * This strips white space from the front/back of the given
174 * string. The stripType is one of: vFRONT, vBACK, vBOTH.
175 */
176 void stripWhiteSpace (
177 EStripType /* stripType */,
178 char * /* string */);
179
180 /*
181 * These functions are used to manage a string which is split into parts, e.g.,
182 * a file which is read into memory.
183 */
184 char **CDKsplitString(
185 char * /* string */,
186 int /* separator */);
187
188 unsigned CDKallocStrings(
189 char *** /* list */,
190 char * /* item */,
191 unsigned /* length */,
192 unsigned /* used */);
193
194 unsigned CDKcountStrings(
195 char ** /* list */);
196
197 void CDKfreeStrings(
198 char ** /* list */);
199
200 /*
201 * Free a list of chtype-strings, terminated by a null pointer.
202 */
203 void CDKfreeChtypes(
204 chtype ** /* list */);
205
206 /*
207 * This returns the length of an integer.
208 */
209 int intlen (
210 int /* value */);
211
212 /*
213 * This opens the given directory and reads in the contents. It stores
214 * the results in 'list' and returns the number of elements found.
215 */
216 int CDKgetDirectoryContents (
217 char * /* directory */,
218 char *** /* list */);
219
220 /*
221 * This looks for the given pattern in the given list.
222 */
223 int searchList (
224 char ** /* list */,
225 int /* listSize */,
226 char * /* pattern */);
227
228 /*
229 * This returns the basename of a file.
230 */
231 char *baseName (
232 char * /* filename */);
233
234 /*
235 * This returns the directory name of a file.
236 */
237 char *dirName (
238 char * /* filename */);
239
240 /*
241 * This frees the memory used by the given string.
242 */
243 void freeChar (
244 char * /* string */);
245
246 /*
247 * This frees the memory used by the given string.
248 */
249 void freeChtype (
250 chtype * /* string */);
251
252 /*
253 * This frees the memory used by the given list of strings.
254 */
255 void freeCharList (
256 char ** /* list */,
257 unsigned /* size */);
258
259 /*
260 * This frees the memory used by the given list of strings.
261 */
262 void freeChtypeList (
263 chtype ** /* list */,
264 unsigned /* size */);
265
266 /*
267 * This sets the elements of the given string to 'character'
268 */
269 void cleanChar (
270 char * /* string */,
271 int /* length */,
272 char /* character */);
273
274 /*
275 * This sets the elements of the given string to 'character'
276 */
277 void cleanChtype (
278 chtype * /* string */,
279 int /* length */,
280 chtype /* character */);
281
282 /*
283 * This takes a chtype pointer and returns a char pointer.
284 */
285 char *chtype2Char (
286 chtype * /* string */);
287
288 /*
289 * This takes a chtype pointer and returns a char pointer with embedded
290 * formatting information.
291 */
292 char *chtype2String (
293 chtype * /* string */);
294
295 /*
296 * This takes a char pointer and returns a chtype pointer.
297 */
298 chtype *char2Chtype (
299 char * /* string */,
300 int * /* length */,
301 int * /* align */);
302
303 /*
304 * Compare a char string to a chtype string
305 */
306 int cmpStrChstr(char * /* str */,
307 chtype * /* chstr */);
308
309 /*
310 * Copy from a chtype string to a char string
311 */
312
313 void chstrncpy(char * /* dest */,
314 chtype * /* src */,
315 int /* maxcount */);
316
317 /*
318 * Given a character pointer, returns the equivalent display type.
319 */
320 EDisplayType char2DisplayType (
321 char * /* string */);
322
323 /*
324 * Tell if a display type is "hidden"
325 */
326 boolean isHiddenDisplayType (
327 EDisplayType /* type */);
328
329 /*
330 * Filter an input character according to the display type.
331 */
332 int filterByDisplayType(
333 EDisplayType /* type */,
334 chtype /* input */);
335
336 /*
337 * Copy the given string.
338 */
339 chtype *copyChtype (
340 chtype * /* string */);
341
342 /*
343 * Copy the given string.
344 */
345 char *copyChar (
346 char * /* string */);
347
348 /*
349 * Copy the given list.
350 */
351 char **copyCharList (
352 char ** /* list */);
353
354 /*
355 * Copy the given list.
356 */
357 chtype **copyChtypeList (
358 chtype ** /* list */);
359
360 /*
361 * Return the length of the given string.
362 */
363 int chlen (
364 chtype * /* string */);
365
366 /*
367 * Return the length of the given list.
368 */
369 int lenCharList (
370 char ** /* list */);
371
372 int lenChtypeList (
373 chtype ** /* list */);
374
375 /*
376 * This takes a file mode and returns the first character of the file
377 * permissions string.
378 */
379 int mode2Filetype (
380 mode_t /* fileMode */);
381
382 /*
383 * This takes a file mode and stores the character representation
384 * of the mode in 'string'. This also returns the octal value
385 * of the file mode.
386 */
387 int mode2Char (
388 char * /* string */,
389 mode_t /* fileMode */);
390
391 /*
392 * This looks for a link. (used by the </L> pattern)
393 */
394 int checkForLink (
395 char * /* line */,
396 char * /* filename */);
397
398 /*
399 * This function help set the height/width values of a widget.
400 */
401 int setWidgetDimension (
402 int /* parentDim */,
403 int /* proposedDim */,
404 int /* adjustment */);
405
406 /*
407 * This safely erases a given window.
408 */
409 void eraseCursesWindow (
410 WINDOW * /* window */);
411
412 /*
413 * This safely deletes a given window.
414 */
415 void deleteCursesWindow (
416 WINDOW * /* window */);
417
418 /*
419 * This moves a given window
420 */
421 void moveCursesWindow (
422 WINDOW * /* window */,
423 int /* xdiff */,
424 int /* ydiff */);
425
426 /*
427 * Return an integer like 'floor()', which returns a double.
428 */
429 int floorCDK(double);
430
431 /*
432 * Return an integer like 'ceil()', which returns a double.
433 */
434 int ceilCDK(double);
435
436 #ifdef __cplusplus
437 }
438 #endif
439
440 #endif /* CDKUTIL_H */
441 #endif /* CDKINCLUDES */
0 /*
1 * $Id: cdk_version.hin,v 1.1 2002/07/20 00:26:36 tom Exp $
2 */
3
4 #ifndef CDK_VERSION_H
5 #define CDK_VERSION_H
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 #define CDK_VERSION_MAJOR "@VERSION_MAJOR@"
12 #define CDK_VERSION_MINOR "@VERSION_MINOR@"
13 #define CDK_VERSION_PATCH "@VERSION_PATCH@"
14
15 /*
16 * Runtime to return the same version information.
17 */
18 char * CDKVersion (void);
19
20 #ifdef __cplusplus
21 }
22 #endif
23
24 #endif /* CDK_VERSION_H */
0 /*
1 * $Id: cdkscreen.h,v 1.16 2005/12/30 01:53:30 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKSCREEN_H
6 #define CDKSCREEN_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #endif
17
18 /*
19 * Changes 1999-2004,2005 copyright Thomas E. Dickey
20 *
21 * Copyright 1999, Mike Glover
22 * All rights reserved.
23 *
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
26 * are met:
27 * 1. Redistributions of source code must retain the above copyright
28 * notice, this list of conditions and the following disclaimer.
29 * 2. Redistributions in binary form must reproduce the above copyright
30 * notice, this list of conditions and the following disclaimer in the
31 * documentation and/or other materials provided with the distribution.
32 * 3. All advertising materials mentioning features or use of this software
33 * must display the following acknowledgment:
34 * This product includes software developed by Mike Glover
35 * and contributors.
36 * 4. Neither the name of Mike Glover, nor the names of contributors
37 * may be used to endorse or promote products derived from this software
38 * without specific prior written permission.
39 *
40 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
41 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
44 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50 * SUCH DAMAGE.
51 */
52
53 /*
54 * Declare and definitions needed for the widget.
55 */
56 #define MAX_OBJECTS 1000 /* not used by widgets */
57
58 struct CDKOBJS;
59
60 typedef enum {
61 CDKSCREEN_NOEXIT = 0
62 , CDKSCREEN_EXITOK
63 , CDKSCREEN_EXITCANCEL
64 } EExitStatus;
65
66 /*
67 * Define the CDK screen structure.
68 */
69 struct SScreen {
70 WINDOW * window;
71 struct CDKOBJS ** object;
72 int objectCount; /* last-used index in object[] */
73 int objectLimit; /* sizeof(object[]) */
74 EExitStatus exitStatus;
75 int objectFocus; /* focus index in object[] */
76 };
77 typedef struct SScreen CDKSCREEN;
78
79 /*
80 * This function creates a CDKSCREEN pointer.
81 */
82 CDKSCREEN *initCDKScreen (
83 WINDOW * /* window */);
84
85 /*
86 * This sets which CDKSCREEN pointer will be the default screen
87 * in the list of managed screen.
88 */
89 CDKSCREEN *setDefaultCDKScreen (
90 int /* screenNumber */);
91
92 /*
93 * This function registers a CDK widget with a given screen.
94 */
95 void registerCDKObject (
96 CDKSCREEN * /* screen */,
97 EObjectType /* cdktype */,
98 void * /* object */);
99
100 /*
101 * This unregisters a CDK widget from a screen.
102 */
103 void unregisterCDKObject (
104 EObjectType /* cdktype */,
105 void * /* object */);
106
107 /*
108 * This function raises a widget on a screen to the top of the widget
109 * stack of the screen the widget is associated with. The side effect
110 * of doing this is the widget will be on 'top' of all the other
111 * widgets on their screens.
112 */
113 void raiseCDKObject (
114 EObjectType /* cdktype */,
115 void * /* object */);
116
117 /*
118 * This function lowers a widget on a screen to the bottom of the widget
119 * stack of the screen the widget is associated with. The side effect
120 * of doing this is that all the other widgets will be on 'top' of the
121 * widget on their screens.
122 */
123 void lowerCDKObject (
124 EObjectType /* cdktype */,
125 void * /* object */);
126
127 /*
128 * This redraws a window, forcing it to the top of the stack.
129 */
130 void refreshCDKWindow (
131 WINDOW * /* win */);
132
133 /*
134 * This redraws all the widgets associated with the given screen.
135 */
136 void refreshCDKScreen (
137 CDKSCREEN * /* screen */);
138
139 /*
140 * This calls refreshCDKScreen. (it is here to try to be consistent
141 * with the drawCDKXXX functions associated with the widgets)
142 */
143 void drawCDKScreen (
144 CDKSCREEN * /* screen */);
145
146 /*
147 * This removes all the widgets from the screen.
148 */
149 void eraseCDKScreen (
150 CDKSCREEN * /* screen */);
151
152 /*
153 * Destroy all of the widgets on a screen
154 */
155
156 void destroyCDKScreenObjects (CDKSCREEN *cdkscreen);
157
158 /*
159 * This frees up any memory the CDKSCREEN pointer used.
160 */
161 void destroyCDKScreen (
162 CDKSCREEN * /* screen */);
163
164 /*
165 * This shuts down curses and everything else needed to
166 * exit cleanly.
167 */
168 void endCDK(void);
169
170 /*
171 * This creates all the color pairs.
172 */
173 void initCDKColor(void);
174
175 #ifdef __cplusplus
176 }
177 #endif
178
179 #endif /* CDKSCREEN_H */
180 #endif /* CDKINCLUDES */
0 /*
1 * $Id: config.hin,v 1.2 2000/01/17 14:48:19 tom Exp $
2 */
3
4 #ifndef CDK_CONFIG_H
5 #define CDK_CONFIG_H 1
6
7 @DEFS@
8
9 #if !defined(HAVE_LSTAT) && !defined(lstat)
10 #define lstat(f,b) stat(f,b)
11 #endif
12
13 #endif /* CDK_CONFIG_H */
0 #ifndef CDKINCLUDES
1 #ifndef CURDEF_H
2 #define CURDEF_H
3
4 #ifndef CDK_H
5 #define CDKINCLUDES
6 #include <cdk.h>
7 #undef CDKINCLUDES
8 #endif
9
10 /*
11 * $Id: curdefs.h,v 1.13 2004/08/30 23:57:07 tom Exp $
12 *
13 * Changes 1999-2002,2004 copyright Thomas E. Dickey
14 * Copyright 1999, Mike Glover
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 * 3. All advertising materials mentioning features or use of this software
26 * must display the following acknowledgment:
27 * This product includes software developed by Mike Glover
28 * and contributors.
29 * 4. Neither the name of Mike Glover, nor the names of contributors
30 * may be used to endorse or promote products derived from this software
31 * without specific prior written permission.
32 *
33 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
34 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
35 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
36 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
37 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
41 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
42 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * SUCH DAMAGE.
44 */
45
46 /*
47 * This header file adds some useful curses-style definitions.
48 */
49
50 #undef CTRL
51 #define CTRL(c) ((c)&0x1f)
52
53 #undef CDK_REFRESH
54 #define CDK_REFRESH CTRL('L')
55 #undef CDK_PASTE
56 #define CDK_PASTE CTRL('V')
57 #undef CDK_COPY
58 #define CDK_COPY CTRL('Y')
59 #undef CDK_ERASE
60 #define CDK_ERASE CTRL('U')
61 #undef CDK_CUT
62 #define CDK_CUT CTRL('X')
63 #undef CDK_BEGOFLINE
64 #define CDK_BEGOFLINE CTRL('A')
65 #undef CDK_ENDOFLINE
66 #define CDK_ENDOFLINE CTRL('E')
67 #undef CDK_BACKCHAR
68 #define CDK_BACKCHAR CTRL('B')
69 #undef CDK_FORCHAR
70 #define CDK_FORCHAR CTRL('F')
71 #undef CDK_TRANSPOSE
72 #define CDK_TRANSPOSE CTRL('T')
73 #undef CDK_NEXT
74 #define CDK_NEXT CTRL('N')
75 #undef CDK_PREV
76 #define CDK_PREV CTRL('P')
77 #undef SPACE
78 #define SPACE ' '
79 #undef DELETE
80 #define DELETE '\177' /* Delete key */
81 #undef TAB
82 #define TAB '\t' /* Tab key. */
83 #undef KEY_ESC
84 #define KEY_ESC '\033' /* Escape Key. */
85 #undef KEY_RETURN
86 #define KEY_RETURN '\012' /* Return key */
87 #undef KEY_TAB
88 #define KEY_TAB '\t' /* Tab key */
89 #undef KEY_F1
90 #define KEY_F1 KEY_F(1)
91 #undef KEY_F2
92 #define KEY_F2 KEY_F(2)
93 #undef KEY_F3
94 #define KEY_F3 KEY_F(3)
95 #undef KEY_F4
96 #define KEY_F4 KEY_F(4)
97 #undef KEY_F5
98 #define KEY_F5 KEY_F(5)
99 #undef KEY_F6
100 #define KEY_F6 KEY_F(6)
101 #undef KEY_F7
102 #define KEY_F7 KEY_F(7)
103 #undef KEY_F8
104 #define KEY_F8 KEY_F(8)
105 #undef KEY_F9
106 #define KEY_F9 KEY_F(9)
107 #undef KEY_F10
108 #define KEY_F10 KEY_F(10)
109 #undef KEY_F11
110 #define KEY_F11 KEY_F(11)
111 #undef KEY_F12
112 #define KEY_F12 KEY_F(12)
113
114 /* these definitions may work for antique versions of curses */
115 #if !defined(HAVE_GETBEGYX) && !defined(getbegyx)
116 #define getbegyx(win,y,x) (y = (win)?(win)->_begy:ERR, x = (win)?(win)->_begx:ERR)
117 #endif
118
119 #if !defined(HAVE_GETMAXYX) && !defined(getmaxyx)
120 #define getmaxyx(win,y,x) (y = (win)?(win)->_maxy:ERR, x = (win)?(win)->_maxx:ERR)
121 #endif
122
123 /* these definitions may be needed for bleeding-edge curses implementations */
124 #if !(defined(HAVE_GETBEGX) && defined(HAVE_GETBEGY))
125 #undef getbegx
126 #undef getbegy
127 #define getbegx(win) cdk_getbegx(win)
128 #define getbegy(win) cdk_getbegy(win)
129 extern int cdk_getbegx(WINDOW *);
130 extern int cdk_getbegy(WINDOW *);
131 #endif
132
133 #if !(defined(HAVE_GETMAXX) && defined(HAVE_GETMAXY))
134 #undef getmaxx
135 #undef getmaxy
136 #define getmaxx(win) cdk_getmaxx(win)
137 #define getmaxy(win) cdk_getmaxy(win)
138 extern int cdk_getmaxx(WINDOW *);
139 extern int cdk_getmaxy(WINDOW *);
140 #endif
141
142 /*
143 * Derived macros
144 */
145 #define getendx(a) (getbegx(a) + getmaxx(a))
146 #define getendy(a) (getbegy(a) + getmaxy(a))
147
148 #endif /* CURDEF_H */
149 #endif /* CDKINCLUDES */
0 /*
1 * $Id: dialog.h,v 1.24 2005/12/28 13:39:16 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKDIALOG_H
6 #define CDKDIALOG_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2002,2003 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Declare definitions the dialog box may need.
58 */
59 #define MAX_DIALOG_ROWS 50 /* unused by widgets */
60 #define MAX_DIALOG_BUTTONS 25 /* unused by widgets */
61 #define MIN_DIALOG_WIDTH 10
62
63 /*
64 * Define the CDK dialog structure.
65 */
66 struct SDialogBox {
67 CDKOBJS obj;
68 WINDOW * parent;
69 WINDOW * win;
70 WINDOW * shadowWin;
71 chtype ** info;
72 int * infoLen;
73 int * infoPos;
74 chtype ** buttonLabel;
75 int * buttonLen;
76 int * buttonPos;
77 int messageRows;
78 int buttonCount;
79 int currentButton;
80 int boxWidth;
81 int boxHeight;
82 EExitType exitType;
83 boolean separator;
84 boolean shadow;
85 chtype highlight;
86 };
87 typedef struct SDialogBox CDKDIALOG;
88
89 /*
90 * This returns a CDK dialog widget pointer.
91 */
92 CDKDIALOG *newCDKDialog (
93 CDKSCREEN * /* cdkscreen */,
94 int /* xPos */,
95 int /* yPos */,
96 char ** /* message */,
97 int /* Rows */,
98 char ** /* buttons */,
99 int /* buttonCount */,
100 chtype /* highlight */,
101 boolean /* separator */,
102 boolean /* Box */,
103 boolean /* shadow */);
104
105 /*
106 * This activates the widget.
107 */
108 int activateCDKDialog (
109 CDKDIALOG * /* dialog */,
110 chtype * /* actions */);
111
112 /*
113 * This injects a single character into the widget.
114 */
115 #define injectCDKDialog(obj,input) injectCDKObject(obj,input,Int)
116
117 /*
118 * This sets multiple attributes of the widget.
119 */
120 void setCDKDialog (
121 CDKDIALOG * /* dialog */,
122 chtype /* highlight */,
123 boolean /* separator */,
124 boolean /* Box */);
125
126 /*
127 * This sets the highlight attribute for the buttons.
128 */
129 void setCDKDialogHighlight (
130 CDKDIALOG * /* dialog */,
131 chtype /* highlight */);
132
133 chtype getCDKDialogHighlight (
134 CDKDIALOG * /* dialog */);
135
136 /*
137 * This sets whether or not the dialog box will have a separator line.
138 */
139 void setCDKDialogSeparator (
140 CDKDIALOG * /* dialog */,
141 boolean /* separator */);
142
143 boolean getCDKDialogSeparator (
144 CDKDIALOG * /* dialog */);
145
146 /*
147 * This sets the box attribute of the widget.
148 */
149 void setCDKDialogBox (
150 CDKDIALOG * /* dialog */,
151 boolean /* Box */);
152
153 boolean getCDKDialogBox (
154 CDKDIALOG * /* dialog */);
155
156 /*
157 * These set the drawing characters of the widget.
158 */
159 #define setCDKDialogULChar(w,c) setULCharOf(w,c)
160 #define setCDKDialogURChar(w,c) setURCharOf(w,c)
161 #define setCDKDialogLLChar(w,c) setLLCharOf(w,c)
162 #define setCDKDialogLRChar(w,c) setLRCharOf(w,c)
163 #define setCDKDialogVerticalChar(w,c) setVTCharOf(w,c)
164 #define setCDKDialogHorizontalChar(w,c) setHZCharOf(w,c)
165 #define setCDKDialogBoxAttribute(w,c) setBXAttrOf(w,c)
166
167 /*
168 * This sets the background color of the widget.
169 */
170 #define setCDKDialogBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
171
172 /*
173 * This sets the background attribute of the widget.
174 */
175 #define setCDKDialogBackgroundAttrib(w,c) setBKAttrOf(w,c)
176
177 /*
178 * This draws the dialog box widget.
179 */
180 #define drawCDKDialog(obj,box) drawCDKObject(obj,box)
181
182 /*
183 * This erases the dialog box from the screen.
184 */
185 #define eraseCDKDialog(obj) eraseCDKObject(obj)
186
187 /*
188 * This moves the dialog box to a new screen location.
189 */
190 #define moveCDKDialog(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
191
192 /*
193 * This allows the user to position the widget on the screen interactively.
194 */
195 #define positionCDKDialog(widget) positionCDKObject(ObjOf(widget),widget->win)
196
197 /*
198 * This destroys the widget and all the memory associated with it.
199 */
200 #define destroyCDKDialog(obj) destroyCDKObject(obj)
201
202 /*
203 * This draws the dialog box buttons.
204 */
205 void drawCDKDialogButtons (
206 CDKDIALOG * /* dialog */);
207
208 /*
209 * These set the pre/post process functions of the dialog widget.
210 */
211 #define setCDKDialogPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
212 #define setCDKDialogPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
213
214 #ifdef __cplusplus
215 }
216 #endif
217
218 #endif /* CDKDIALOG_H */
219 #endif /* CDKINCLUDES */
0 /*
1 * $Id: draw.h,v 1.10 2004/10/05 00:05:32 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKDRAW_H
6 #define CDKDRAW_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2003,2004 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * This boxes a window.
58 */
59 void boxWindow (
60 WINDOW * /* window */,
61 chtype /* attr */);
62
63 /*
64 * This draws a single line with the character supplied by 'character'
65 */
66 void drawLine (
67 WINDOW * /* window */,
68 int /* startx */,
69 int /* starty */,
70 int /* endx */,
71 int /* endy */,
72 chtype /* character */);
73
74 /*
75 * This writes a blank string segment on the given window.
76 */
77 void writeBlanks (
78 WINDOW * /* window */,
79 int /* xpos */,
80 int /* ypos */,
81 int /* align */,
82 int /* start */,
83 int /* end */);
84
85 /*
86 * This writes a string segment on the given window.
87 */
88 void writeChar (
89 WINDOW * /* window */,
90 int /* xpos */,
91 int /* ypos */,
92 char * /* string */,
93 int /* align */,
94 int /* start */,
95 int /* end */);
96
97 /*
98 * This writes a string segment on the given window.
99 */
100 void writeCharAttrib (
101 WINDOW * /* window */,
102 int /* xpos */,
103 int /* ypos */,
104 char * /* string */,
105 chtype /* attr */,
106 int /* align */,
107 int /* start */,
108 int /* end */);
109
110 /*
111 * This writes a string segment on the given window.
112 */
113 void writeChtype (
114 WINDOW * /* window */,
115 int /* xpos */,
116 int /* ypos */,
117 chtype * /* string */,
118 int /* align */,
119 int /* start */,
120 int /* end */);
121
122 /*
123 * This writes a string segment on the given window.
124 */
125 void writeChtypeAttrib (
126 WINDOW * /* window */,
127 int /* xpos */,
128 int /* ypos */,
129 chtype * /* string */,
130 chtype /* attr */,
131 int /* align */,
132 int /* start */,
133 int /* end */);
134
135 /*
136 * This boxes a window using the given characters.
137 */
138 void attrbox (
139 WINDOW * /* window */,
140 chtype /* tlc */,
141 chtype /* trc */,
142 chtype /* blc */,
143 chtype /* brc */,
144 chtype /* hor */,
145 chtype /* vert */,
146 chtype /* type */);
147
148 /*
149 * This boxes a window using the object's characters.
150 */
151 void drawObjBox (
152 WINDOW * /* win */,
153 CDKOBJS * /* object */);
154
155 /*
156 * This draws the shadow window of the widget.
157 */
158 void drawShadow (
159 WINDOW * /* window */);
160
161 #ifdef __cplusplus
162 }
163 #endif
164
165 #endif /* CDKDRAW_H */
166 #endif /* CDKINCLUDES */
0 /*
1 * $Id: entry.h,v 1.24 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKENTRY_H
6 #define CDKENTRY_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2002,2003 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Define the CDK entry widget structure.
58 */
59 typedef struct SEntry CDKENTRY;
60 typedef void (*ENTRYCB) (struct SEntry *entry, chtype character);
61
62 struct SEntry {
63 CDKOBJS obj;
64 WINDOW * parent;
65 WINDOW * win;
66 WINDOW * shadowWin;
67 WINDOW * labelWin;
68 WINDOW * fieldWin;
69 chtype * label;
70 int labelLen;
71 int titleAdj;
72 chtype fieldAttr;
73 int fieldWidth;
74 char * info;
75 int infoWidth;
76 int screenCol;
77 int leftChar;
78 int min;
79 int max;
80 int boxWidth;
81 int boxHeight;
82 EExitType exitType;
83 EDisplayType dispType;
84 boolean shadow;
85 chtype filler;
86 chtype hidden;
87 ENTRYCB callbackfn;
88 };
89
90 /*
91 * This creates a pointer to a new CDK entry widget.
92 */
93 CDKENTRY *newCDKEntry (
94 CDKSCREEN * /* cdkscreen */,
95 int /* xpos */,
96 int /* ypos */,
97 char * /* title */,
98 char * /* label */,
99 chtype /* fieldAttrib */,
100 chtype /* filler */,
101 EDisplayType /* disptype */,
102 int /* fieldWidth */,
103 int /* min */,
104 int /* max */,
105 boolean /* Box */,
106 boolean /* shadow */);
107
108 /*
109 * This activates the entry widget.
110 */
111 char *activateCDKEntry (
112 CDKENTRY * /* entry */,
113 chtype * /* actions */);
114
115 /*
116 * This injects a single character into the widget.
117 */
118 #define injectCDKEntry(obj,input) injectCDKObject(obj,input,String)
119
120 /*
121 * This sets various attributes of the entry field.
122 */
123 void setCDKEntry (
124 CDKENTRY * /* entry */,
125 char * /* value */,
126 int /* min */,
127 int /* max */,
128 boolean /* Box */);
129
130 /*
131 * This sets the value of the entry field.
132 */
133 void setCDKEntryValue (
134 CDKENTRY * /* entry */,
135 char * /* value */);
136 char *getCDKEntryValue (
137 CDKENTRY * /* entry */);
138
139 /*
140 * This sets the maximum length of a string allowable for
141 * the given widget.
142 */
143 void setCDKEntryMax (
144 CDKENTRY * /* entry */,
145 int /* max */);
146 int getCDKEntryMax (
147 CDKENTRY * /* entry */);
148
149 /*
150 * This sets the minimum length of a string allowable for
151 * the given widget.
152 */
153 void setCDKEntryMin (
154 CDKENTRY * /* entry */,
155 int /* min */);
156 int getCDKEntryMin (
157 CDKENTRY * /* entry */);
158
159 /*
160 * This sets the filler character of the entry field.
161 */
162 void setCDKEntryFillerChar (
163 CDKENTRY * /* entry */,
164 chtype /* fillerCharacter */);
165 chtype getCDKEntryFillerChar (
166 CDKENTRY * /* entry */);
167
168 /*
169 * This sets the character to use when a hidden type is used.
170 */
171 void setCDKEntryHiddenChar (
172 CDKENTRY * /* entry */,
173 chtype /* hiddenCharacter */);
174 chtype getCDKEntryHiddenChar (
175 CDKENTRY * /* entry */);
176
177 /*
178 * This sets the box attribute of the widget.
179 */
180 void setCDKEntryBox (
181 CDKENTRY * /* entry */,
182 boolean /* Box */);
183 boolean getCDKEntryBox (
184 CDKENTRY * /* entry */);
185
186 /*
187 * These set the drawing characters of the widget.
188 */
189 #define setCDKEntryULChar(w,c) setULCharOf(w,c)
190 #define setCDKEntryURChar(w,c) setURCharOf(w,c)
191 #define setCDKEntryLLChar(w,c) setLLCharOf(w,c)
192 #define setCDKEntryLRChar(w,c) setLRCharOf(w,c)
193 #define setCDKEntryVerticalChar(w,c) setVTCharOf(w,c)
194 #define setCDKEntryHorizontalChar(w,c) setHZCharOf(w,c)
195 #define setCDKEntryBoxAttribute(w,c) setBXAttrOf(w,c)
196
197 /*
198 * This sets the background color of the widget.
199 */
200 #define setCDKEntryBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
201
202 /*
203 * This sets the background attribute of the widget.
204 */
205 #define setCDKEntryBackgroundAttrib(w,c) setBKAttrOf(w,c)
206
207 /*
208 * This sets the attribute of the entry field.
209 */
210 void setCDKEntryHighlight (
211 CDKENTRY * /* entry */,
212 chtype /* highlight */,
213 boolean /* cursor */);
214
215 /*
216 * This draws the entry field.
217 */
218 #define drawCDKEntry(obj,box) drawCDKObject(obj,box)
219
220 /*
221 * This erases the widget from the screen.
222 */
223 #define eraseCDKEntry(obj) eraseCDKObject(obj)
224
225 /*
226 * This cleans out the value of the entry field.
227 */
228 void cleanCDKEntry (
229 CDKENTRY * /* entry */);
230
231 /*
232 * This moves the widget to the given location.
233 */
234 #define moveCDKEntry(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
235
236 /*
237 * This is an interactive method of moving the widget.
238 */
239 #define positionCDKEntry(widget) positionCDKObject(ObjOf(widget),widget->win)
240
241 /*
242 * This destroys the widget and all the memory associated with the widget.
243 */
244 #define destroyCDKEntry(obj) destroyCDKObject(obj)
245
246 /*
247 * This sets the callback to the entry fields main handler
248 */
249 void setCDKEntryCB (
250 CDKENTRY * /* entry */,
251 ENTRYCB /* callback */);
252
253 /*
254 * These set the callbacks to the pre and post process functions.
255 */
256 #define setCDKEntryPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
257 #define setCDKEntryPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
258
259 #ifdef __cplusplus
260 }
261 #endif
262
263 #endif /* CDKENTRY_H */
264 #endif /* CDKINCLUDES */
0 /*
1 * $Id: fselect.h,v 1.23 2006/05/04 09:54:39 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKFSELECT_H
6 #define CDKFSELECT_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #include <entry.h>
20 #include <scroll.h>
21 #endif
22
23 /*
24 * Changes 1999-2003,2006 copyright Thomas E. Dickey
25 *
26 * Copyright 1999, Mike Glover
27 * All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 * 1. Redistributions of source code must retain the above copyright
33 * notice, this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright
35 * notice, this list of conditions and the following disclaimer in the
36 * documentation and/or other materials provided with the distribution.
37 * 3. All advertising materials mentioning features or use of this software
38 * must display the following acknowledgment:
39 * This product includes software developed by Mike Glover
40 * and contributors.
41 * 4. Neither the name of Mike Glover, nor the names of contributors
42 * may be used to endorse or promote products derived from this software
43 * without specific prior written permission.
44 *
45 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * SUCH DAMAGE.
56 */
57
58 /*
59 * Define the CDK file selector widget structure.
60 */
61 struct SFileSelector {
62 CDKOBJS obj;
63 WINDOW * parent;
64 WINDOW * win;
65 WINDOW * shadowWin;
66 CDKENTRY * entryField;
67 CDKSCROLL * scrollField;
68 char ** dirContents;
69 int fileCounter;
70 char * pwd;
71 char * pathname;
72 int xpos;
73 int ypos;
74 int boxHeight;
75 int boxWidth;
76 chtype fieldAttribute;
77 chtype fillerCharacter;
78 chtype highlight;
79 char * dirAttribute;
80 char * fileAttribute;
81 char * linkAttribute;
82 char * sockAttribute;
83 EExitType exitType;
84 boolean shadow;
85 };
86 typedef struct SFileSelector CDKFSELECT;
87
88 /*
89 * This creates a new CDK file selector widget.
90 */
91 CDKFSELECT *newCDKFselect (
92 CDKSCREEN * /* cdkscreen */,
93 int /* xpos */,
94 int /* ypos */,
95 int /* height */,
96 int /* width */,
97 char * /* title */,
98 char * /* label */,
99 chtype /* fieldAttribute */,
100 chtype /* fillerChar */,
101 chtype /* highlight */,
102 char * /* dirAttributes */,
103 char * /* fileAttributes */,
104 char * /* linkAttribute */,
105 char * /* sockAttribute */,
106 boolean /* Box */,
107 boolean /* shadow */);
108
109 /*
110 * This activates the file selector.
111 */
112 char *activateCDKFselect (
113 CDKFSELECT * /* fselect */,
114 chtype * /* actions */);
115
116 /*
117 * This injects a single character into the widget.
118 */
119 #define injectCDKFselect(obj,input) injectCDKObject(obj,input,String)
120
121 /*
122 * This sets various attributes of the file selector.
123 */
124 void setCDKFselect (
125 CDKFSELECT * /* fselect */,
126 char * /* directory */,
127 chtype /* fieldAttrib */,
128 chtype /* filler */,
129 chtype /* highlight */,
130 char * /* dirAttribute */,
131 char * /* fileAttribute */,
132 char * /* linkAttribute */,
133 char * /* sockAttribute */,
134 boolean /* Box */);
135
136 /*
137 * This sets the current directory of the file selector.
138 */
139 int setCDKFselectDirectory (
140 CDKFSELECT * /* fselect */,
141 char * /* directory */);
142
143 char *getCDKFselectDirectory (
144 CDKFSELECT * /* fselect */);
145
146 /*
147 * This sets the filler character of the entry field.
148 */
149 void setCDKFselectFillerChar (
150 CDKFSELECT * /* fselect */,
151 chtype /* fillerCharacter */);
152
153 chtype getCDKFselectFillerChar (
154 CDKFSELECT * /* fselect */);
155
156 /*
157 * This sets the highlight bar of the scrolling list.
158 */
159 void setCDKFselectHighlight (
160 CDKFSELECT * /* fselect */,
161 chtype /* highlight */);
162
163 chtype getCDKFselectHighlight (
164 CDKFSELECT * /* fselect */);
165
166 /*
167 * These functions set the attribute of the directories, links,
168 * files, and sockets in the scrolling list portion of the file
169 * selector widget.
170 */
171 void setCDKFselectDirAttribute (
172 CDKFSELECT * /* fselect */,
173 char * /* attribute */);
174
175 void setCDKFselectLinkAttribute (
176 CDKFSELECT * /* fselect */,
177 char * /* attribute */);
178
179 void setCDKFselectFileAttribute (
180 CDKFSELECT * /* fselect */,
181 char * /* attribute */);
182
183 void setCDKFselectSocketAttribute (
184 CDKFSELECT * /* fselect */,
185 char * /* attribute */);
186
187 /*
188 * These functions return the attribute of the directories, links,
189 * files, and sockets in the scrolling list portion of the file
190 * selector widget.
191 */
192 char *getCDKFselectDirAttribute (
193 CDKFSELECT * /* fselect */);
194
195 char *getCDKFselectLinkAttribute (
196 CDKFSELECT * /* fselect */);
197
198 char *getCDKFselectFileAttribute (
199 CDKFSELECT * /* fselect */);
200
201 char *getCDKFselectSocketAttribute (
202 CDKFSELECT * /* fselect */);
203
204 /*
205 * This sets the box attribute of the widget.
206 */
207 void setCDKFselectBox (
208 CDKFSELECT * /* fselect */,
209 boolean /* Box */);
210
211 boolean getCDKFselectBox (
212 CDKFSELECT * /* fselect */);
213
214 /*
215 * This sets the contents of the file selector.
216 */
217 int setCDKFselectDirContents (
218 CDKFSELECT * /* fselect */);
219
220 char **getCDKFselectDirContents (
221 CDKFSELECT * /* fselect */,
222 int * /* count */);
223
224 /*
225 * This sets the contents of the file selector.
226 */
227 void setCDKFselectContents (
228 CDKFSELECT * /* fselect */,
229 char ** /* list */,
230 int /* listSize */);
231
232 char **getCDKFselectContents (
233 CDKFSELECT * /* fselect */,
234 int * /* size */);
235
236 /*
237 * Get/set the current position in the scroll-widget.
238 */
239 int getCDKFselectCurrentItem(
240 CDKFSELECT * /* widget */);
241
242 void setCDKFselectCurrentItem(
243 CDKFSELECT * /* widget */,
244 int /* item */);
245
246 /*
247 * These functions set the drawing characters of the widget.
248 */
249 #define setCDKFselectULChar(w,c) setULCharOf(w,c)
250 #define setCDKFselectURChar(w,c) setURCharOf(w,c)
251 #define setCDKFselectLLChar(w,c) setLLCharOf(w,c)
252 #define setCDKFselectLRChar(w,c) setLRCharOf(w,c)
253 #define setCDKFselectVerticalChar(w,c) setVTCharOf(w,c)
254 #define setCDKFselectHorizontalChar(w,c) setHZCharOf(w,c)
255 #define setCDKFselectBoxAttribute(w,c) setBXAttrOf(w,c)
256
257 /*
258 * This sets the background color of the widget.
259 */
260 #define setCDKFselectBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
261
262 /*
263 * This sets the background attribute of the widget.
264 */
265 #define setCDKFselectBackgroundAttrib(w,c) setBKAttrOf(w,c)
266
267 /*
268 * This draws the widget.
269 */
270 #define drawCDKFselect(obj,Box) drawCDKObject(obj,Box)
271
272 /*
273 * This erases the widget.
274 */
275 #define eraseCDKFselect(obj) eraseCDKObject(obj)
276
277 /*
278 * This moves the widget to the given location.
279 */
280 #define moveCDKFselect(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
281
282 /*
283 * This allows the user to interactively position the widget.
284 */
285 #define positionCDKFselect(widget) positionCDKObject(ObjOf(widget),widget->win)
286
287 /*
288 * This destroys the widget and all the associated memory.
289 */
290 #define destroyCDKFselect(obj) destroyCDKObject(obj)
291
292 /*
293 * This is a callback which allows you to delete files from within the
294 * file selector. It is NOT an active default: it MUST be set by the
295 * user.
296 */
297 void deleteFileCB (
298 EObjectType /* objectType */,
299 void * /* object */,
300 void * /* clientData */);
301
302 /*
303 * This function sets the pre-process function.
304 */
305 void setCDKFselectPreProcess (
306 CDKFSELECT * /* fselect */,
307 PROCESSFN /* callback */,
308 void * /* data */);
309
310 /*
311 * This function sets the post-process function.
312 */
313 void setCDKFselectPostProcess (
314 CDKFSELECT * /* fselect */,
315 PROCESSFN /* callback */,
316 void * /* data */);
317
318 #ifdef __cplusplus
319 }
320 #endif
321
322 #endif /* CDKFSELECT_H */
323 #endif /* CDKINCLUDES */
0 /*
1 * $Id: gen-scale.h,v 1.7 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDK<UPPER>_H
6 #define CDK<UPPER>_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Copyright 2004, Thomas E. Dickey
23 * All rights reserved.
24 *
25 * Redistribution and use in source and binary forms, with or without
26 * modification, are permitted provided that the following conditions
27 * are met:
28 * 1. Redistributions of source code must retain the above copyright
29 * notice, this list of conditions and the following disclaimer.
30 * 2. Redistributions in binary form must reproduce the above copyright
31 * notice, this list of conditions and the following disclaimer in the
32 * documentation and/or other materials provided with the distribution.
33 * 3. All advertising materials mentioning features or use of this software
34 * must display the following acknowledgment:
35 * This product includes software developed by Thomas Dickey
36 * and contributors.
37 * 4. Neither the name of Thomas Dickey, nor the names of contributors
38 * may be used to endorse or promote products derived from this software
39 * without specific prior written permission.
40 *
41 * THIS SOFTWARE IS PROVIDED BY THOMAS DICKEY AND CONTRIBUTORS ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THOMAS DICKEY OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 */
53
54 /*
55 * Define the CDK widget <MIXED> structure.
56 */
57 struct S<MIXED> {
58 CDKOBJS obj;
59 WINDOW * parent;
60 WINDOW * win;
61 WINDOW * shadowWin;
62 WINDOW * fieldWin;
63 WINDOW * labelWin;
64 int titleAdj;
65 chtype * label;
66 int labelLen;
67 int boxHeight;
68 int boxWidth;
69 int fieldWidth;
70 int fieldEdit; /* offset from right-margin of field */
71 chtype fieldAttr;
72 <CTYPE> low;
73 <CTYPE> high;
74 <CTYPE> inc;
75 <CTYPE> fastinc;
76 <CTYPE> current;
77 #if <FLOAT>
78 int digits;
79 #endif <FLOAT>
80 EExitType exitType;
81 boolean shadow;
82 };
83 typedef struct S<MIXED> CDK<UPPER>;
84
85 /*
86 * This creates a new pointer to a CDK <CTYPE>-<MIXED> widget.
87 */
88 CDK<UPPER> *newCDK<MIXED> (
89 CDKSCREEN * /* cdkscreen */,
90 int /* xpos */,
91 int /* ypos */,
92 char * /* title */,
93 char * /* label */,
94 chtype /* fieldAttr */,
95 int /* fieldWidth */,
96 <CTYPE> /* start */,
97 <CTYPE> /* low */,
98 <CTYPE> /* high */,
99 <CTYPE> /* inc */,
100 <CTYPE> /* fastInc */,
101 #if <FLOAT>
102 int /* digits */,
103 #endif <FLOAT>
104 boolean /* Box */,
105 boolean /* shadow */);
106
107 /*
108 * This activates the widget.
109 */
110 <CTYPE> activateCDK<MIXED> (
111 CDK<UPPER> * /* widget */,
112 chtype * /* actions */);
113
114 /*
115 * This injects a single character into the widget.
116 */
117 #define injectCDK<MIXED>(obj,input) injectCDKObject(obj,input,<DTYPE>)
118
119 /*
120 * This sets various attributes of the widget.
121 */
122 void setCDK<MIXED> (
123 CDK<UPPER> * /* widget */,
124 <CTYPE> /* low */,
125 <CTYPE> /* high */,
126 <CTYPE> /* value */,
127 boolean /* Box */);
128
129 /*
130 * These set/get the low and high values.
131 */
132 void setCDK<MIXED>LowHigh (
133 CDK<UPPER> * /* widget */,
134 <CTYPE> /* low */,
135 <CTYPE> /* high */);
136
137 <CTYPE> getCDK<MIXED>LowValue (
138 CDK<UPPER> * /* widget */);
139
140 <CTYPE> getCDK<MIXED>HighValue (
141 CDK<UPPER> * /* widget */);
142
143 /*
144 * These set/get the digits.
145 */
146 #if <FLOAT>
147 void setCDK<MIXED>Digits (
148 CDK<UPPER> * /* widget */,
149 int /* digits */);
150
151 int getCDK<MIXED>Digits (
152 CDK<UPPER> * /* widget */);
153 #endif <FLOAT>
154
155 /*
156 * These set/get the current value.
157 */
158 void setCDK<MIXED>Value (
159 CDK<UPPER> * /* widget */,
160 <CTYPE> /* value */);
161
162 <CTYPE> getCDK<MIXED>Value (
163 CDK<UPPER> * /* widget */);
164
165 /*
166 * This sets the box attribute of the widget.
167 */
168 void setCDK<MIXED>Box (
169 CDK<UPPER> * /* widget */,
170 boolean /* Box */);
171
172 boolean getCDK<MIXED>Box (
173 CDK<UPPER> * /* widget */);
174
175 /*
176 * These set the drawing characters of the widget.
177 */
178 #define setCDK<MIXED>ULChar(w,c) setULCharOf(w,c)
179 #define setCDK<MIXED>URChar(w,c) setURCharOf(w,c)
180 #define setCDK<MIXED>LLChar(w,c) setLLCharOf(w,c)
181 #define setCDK<MIXED>LRChar(w,c) setLRCharOf(w,c)
182 #define setCDK<MIXED>VerticalChar(w,c) setVTCharOf(w,c)
183 #define setCDK<MIXED>HorizontalChar(w,c) setHZCharOf(w,c)
184 #define setCDK<MIXED>BoxAttribute(w,c) setBXAttrOf(w,c)
185
186 /*
187 * This sets the background color of the widget.
188 */
189 #define setCDK<MIXED>BackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
190
191 /*
192 * This sets the background attribute of the widget.
193 */
194 #define setCDK<MIXED>BackgroundAttrib(w,c) setBKAttrOf(w,c)
195
196 /*
197 * This draws the widget on the screen.
198 */
199 #define drawCDK<MIXED>(obj,Box) drawCDKObject(obj,Box)
200
201 /*
202 * This erases the widget from the screen.
203 */
204 #define eraseCDK<MIXED>(obj) eraseCDKObject(obj)
205
206 /*
207 * This moves the widget to the given location on the screen.
208 */
209 #define moveCDK<MIXED>(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
210
211 /*
212 * This allows the user to interactively position the widget on the screen.
213 */
214 #define positionCDK<MIXED>(widget) positionCDKObject(ObjOf(widget),widget->win)
215
216 /*
217 * This destroys the widget and associated memory.
218 */
219 #define destroyCDK<MIXED>(obj) destroyCDKObject(obj)
220
221 /*
222 * These set the pre/post process callback functions.
223 */
224 #define setCDK<MIXED>PreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
225 #define setCDK<MIXED>PostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
226
227 #ifdef __cplusplus
228 }
229 #endif
230
231 #endif /* CDK<UPPER>_H */
232 #endif /* CDKINCLUDES */
0 /*
1 * $Id: gen-slider.h,v 1.7 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDK<UPPER>_H
6 #define CDK<UPPER>_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Copyright 2004, Thomas E. Dickey
23 * All rights reserved.
24 *
25 * Redistribution and use in source and binary forms, with or without
26 * modification, are permitted provided that the following conditions
27 * are met:
28 * 1. Redistributions of source code must retain the above copyright
29 * notice, this list of conditions and the following disclaimer.
30 * 2. Redistributions in binary form must reproduce the above copyright
31 * notice, this list of conditions and the following disclaimer in the
32 * documentation and/or other materials provided with the distribution.
33 * 3. All advertising materials mentioning features or use of this software
34 * must display the following acknowledgment:
35 * This product includes software developed by Thomas Dickey
36 * and contributors.
37 * 4. Neither the name of Thomas Dickey, nor the names of contributors
38 * may be used to endorse or promote products derived from this software
39 * without specific prior written permission.
40 *
41 * THIS SOFTWARE IS PROVIDED BY THOMAS DICKEY AND CONTRIBUTORS ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THOMAS DICKEY OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 */
53
54 /*
55 * Define the CDK widget <MIXED> structure.
56 */
57 struct S<MIXED> {
58 CDKOBJS obj;
59 WINDOW * parent;
60 WINDOW * win;
61 WINDOW * shadowWin;
62 WINDOW * fieldWin;
63 WINDOW * labelWin;
64 int titleAdj;
65 chtype * label;
66 int labelLen;
67 int boxHeight;
68 int boxWidth;
69 int fieldWidth;
70 int fieldEdit; /* offset from right-margin of field */
71 chtype filler;
72 <CTYPE> low;
73 <CTYPE> high;
74 <CTYPE> inc;
75 <CTYPE> fastinc;
76 <CTYPE> current;
77 #if <FLOAT>
78 int digits;
79 #endif <FLOAT>
80 EExitType exitType;
81 boolean shadow;
82 };
83 typedef struct S<MIXED> CDK<UPPER>;
84
85 /*
86 * This creates a new pointer to a CDK <CTYPE>-<MIXED> widget.
87 */
88 CDK<UPPER> *newCDK<MIXED> (
89 CDKSCREEN * /* cdkscreen */,
90 int /* xpos */,
91 int /* ypos */,
92 char * /* title */,
93 char * /* label */,
94 chtype /* fieldAttr */,
95 int /* fieldWidth */,
96 <CTYPE> /* start */,
97 <CTYPE> /* low */,
98 <CTYPE> /* high */,
99 <CTYPE> /* inc */,
100 <CTYPE> /* fastInc */,
101 #if <FLOAT>
102 int /* digits */,
103 #endif <FLOAT>
104 boolean /* Box */,
105 boolean /* shadow */);
106
107 /*
108 * This activates the widget.
109 */
110 <CTYPE> activateCDK<MIXED> (
111 CDK<UPPER> * /* widget */,
112 chtype * /* actions */);
113
114 /*
115 * This injects a single character into the widget.
116 */
117 #define injectCDK<MIXED>(obj,input) injectCDKObject(obj,input,<DTYPE>)
118
119 /*
120 * This sets various attributes of the widget.
121 */
122 void setCDK<MIXED> (
123 CDK<UPPER> * /* widget */,
124 <CTYPE> /* low */,
125 <CTYPE> /* high */,
126 <CTYPE> /* value */,
127 boolean /* Box */);
128
129 /*
130 * These set/get the low and high values.
131 */
132 void setCDK<MIXED>LowHigh (
133 CDK<UPPER> * /* widget */,
134 <CTYPE> /* low */,
135 <CTYPE> /* high */);
136
137 <CTYPE> getCDK<MIXED>LowValue (
138 CDK<UPPER> * /* widget */);
139
140 <CTYPE> getCDK<MIXED>HighValue (
141 CDK<UPPER> * /* widget */);
142
143 /*
144 * These set/get the digits.
145 */
146 #if <FLOAT>
147 void setCDK<MIXED>Digits (
148 CDK<UPPER> * /* widget */,
149 int /* digits */);
150
151 int getCDK<MIXED>Digits (
152 CDK<UPPER> * /* widget */);
153 #endif <FLOAT>
154
155 /*
156 * These set/get the current value.
157 */
158 void setCDK<MIXED>Value (
159 CDK<UPPER> * /* widget */,
160 <CTYPE> /* value */);
161
162 <CTYPE> getCDK<MIXED>Value (
163 CDK<UPPER> * /* widget */);
164
165 /*
166 * This sets the box attribute of the widget.
167 */
168 void setCDK<MIXED>Box (
169 CDK<UPPER> * /* widget */,
170 boolean /* Box */);
171
172 boolean getCDK<MIXED>Box (
173 CDK<UPPER> * /* widget */);
174
175 /*
176 * These set the drawing characters of the widget.
177 */
178 #define setCDK<MIXED>ULChar(w,c) setULCharOf(w,c)
179 #define setCDK<MIXED>URChar(w,c) setURCharOf(w,c)
180 #define setCDK<MIXED>LLChar(w,c) setLLCharOf(w,c)
181 #define setCDK<MIXED>LRChar(w,c) setLRCharOf(w,c)
182 #define setCDK<MIXED>VerticalChar(w,c) setVTCharOf(w,c)
183 #define setCDK<MIXED>HorizontalChar(w,c) setHZCharOf(w,c)
184 #define setCDK<MIXED>BoxAttribute(w,c) setBXAttrOf(w,c)
185
186 /*
187 * This sets the background color of the widget.
188 */
189 #define setCDK<MIXED>BackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
190
191 /*
192 * This sets the background attribute of the widget.
193 */
194 #define setCDK<MIXED>BackgroundAttrib(w,c) setBKAttrOf(w,c)
195
196 /*
197 * This draws the widget on the screen.
198 */
199 #define drawCDK<MIXED>(obj,Box) drawCDKObject(obj,Box)
200
201 /*
202 * This erases the widget from the screen.
203 */
204 #define eraseCDK<MIXED>(obj) eraseCDKObject(obj)
205
206 /*
207 * This moves the widget to the given location on the screen.
208 */
209 #define moveCDK<MIXED>(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
210
211 /*
212 * This allows the user to interactively position the widget on the screen.
213 */
214 #define positionCDK<MIXED>(widget) positionCDKObject(ObjOf(widget),widget->win)
215
216 /*
217 * This destroys the widget and associated memory.
218 */
219 #define destroyCDK<MIXED>(obj) destroyCDKObject(obj)
220
221 /*
222 * These set the pre/post process callback functions.
223 */
224 #define setCDK<MIXED>PreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
225 #define setCDK<MIXED>PostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
226
227 #ifdef __cplusplus
228 }
229 #endif
230
231 #endif /* CDK<UPPER>_H */
232 #endif /* CDKINCLUDES */
0 /*
1 * $Id: graph.h,v 1.21 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKGRAPH_H
6 #define CDKGRAPH_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 2000-2002,2003 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Define the CDK graph structure.
58 */
59 struct SGraph {
60 CDKOBJS obj;
61 WINDOW * parent;
62 WINDOW * win;
63 WINDOW * shadowWin;
64 int titleAdj;
65 chtype * graphChar;
66 boolean shadow;
67 int boxHeight;
68 int boxWidth;
69 chtype * xtitle;
70 int xtitlePos;
71 int xtitleLen;
72 int * values;
73 int count;
74 int minx;
75 int maxx;
76 int xscale;
77 int txpos;
78 chtype * ytitle;
79 int ytitlePos;
80 int ytitleLen;
81 int yscale;
82 int typos;
83 EGraphDisplayType displayType;
84 };
85 typedef struct SGraph CDKGRAPH;
86
87 /*
88 * This creates a new CDK graph pointer.
89 */
90 CDKGRAPH *newCDKGraph (
91 CDKSCREEN * /* cdkscreen */,
92 int /* xpos */,
93 int /* ypos */,
94 int /* height */,
95 int /* width */,
96 char * /* title */,
97 char * /* xtitle */,
98 char * /* ytitle */);
99
100 /*
101 * This was added to make the builder simpler. All this will
102 * do is call drawCDKGraph.
103 */
104 void activateCDKGraph (
105 CDKGRAPH * /* graph */,
106 chtype * /* actions */);
107
108 /*
109 * This sets multiple attributes of the widget.
110 */
111 int setCDKGraph (
112 CDKGRAPH * /* graph */,
113 int * /* values */,
114 int /* count */,
115 char * /* graphChar */,
116 boolean /* startAtZero */,
117 EGraphDisplayType /* displayType */);
118
119 /*
120 * This sets the values of the graph widget.
121 */
122 int setCDKGraphValues (
123 CDKGRAPH * /* graph */,
124 int * /* values */,
125 int /* count */,
126 boolean /* startAtZero */);
127
128 int setCDKGraphValue (
129 CDKGRAPH * /* graph */,
130 int /* index */,
131 int /* value */,
132 boolean /* startAtZero */);
133
134 int *getCDKGraphValues (
135 CDKGRAPH * /* graph */,
136 int * /* size */);
137
138 int getCDKGraphValue (
139 CDKGRAPH * /* graph */,
140 int /* index */);
141
142 /*
143 * This sets the characters of the graph widget.
144 */
145 int setCDKGraphCharacters (
146 CDKGRAPH * /* graph */,
147 char * /* characters */);
148
149 int setCDKGraphCharacter (
150 CDKGRAPH * /* graph */,
151 int /* index */,
152 char * /* character */);
153
154 chtype *getCDKGraphCharacters (
155 CDKGRAPH * /* graph */);
156
157 chtype getCDKGraphCharacter (
158 CDKGRAPH * /* graph */,
159 int /* index */);
160
161 /*
162 * This sets the display type of the graph.
163 */
164 void setCDKGraphDisplayType (
165 CDKGRAPH * /* graph */,
166 EGraphDisplayType /* type */);
167
168 EGraphDisplayType getCDKGraphDisplayType (
169 CDKGRAPH * /* graph */);
170
171 /*
172 * This sets the box attribute of the widget.
173 */
174 void setCDKGraphBox (
175 CDKGRAPH * /* graph */,
176 boolean /* Box */);
177
178 boolean getCDKGraphBox (
179 CDKGRAPH * /* graph */);
180
181 /*
182 * These set the drawing characters of the widget.
183 */
184 #define setCDKGraphULChar(w,c) setULCharOf(w,c)
185 #define setCDKGraphURChar(w,c) setURCharOf(w,c)
186 #define setCDKGraphLLChar(w,c) setLLCharOf(w,c)
187 #define setCDKGraphLRChar(w,c) setLRCharOf(w,c)
188 #define setCDKGraphVerticalChar(w,c) setVTCharOf(w,c)
189 #define setCDKGraphHorizontalChar(w,c) setHZCharOf(w,c)
190 #define setCDKGraphBoxAttribute(w,c) setBXAttrOf(w,c)
191
192 /*
193 * This sets the background color of the widget.
194 */
195 #define setCDKGraphBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
196
197 /*
198 * This sets the background attribute of the widget.
199 */
200 #define setCDKGraphBackgroundAttrib(w,c) setBKAttrOf(w,c)
201
202 /*
203 * This draws the graph on the screen.
204 */
205 #define drawCDKGraph(obj,Box) drawCDKObject(obj,Box)
206
207 /*
208 * This removes the graph from the screen.
209 */
210 #define eraseCDKGraph(obj) eraseCDKObject(obj)
211
212 /*
213 * This moves the widget to the given location.
214 */
215 #define moveCDKGraph(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
216
217 /*
218 * This allows the user to interactively move the widget.
219 */
220 #define positionCDKGraph(widget) positionCDKObject(ObjOf(widget),widget->win)
221
222 /*
223 * This destroys the graph and all the associated memory.
224 */
225 #define destroyCDKGraph(obj) destroyCDKObject(obj)
226
227 #ifdef __cplusplus
228 }
229 #endif
230
231 #endif /* CDKGRAPH_H */
232 #endif /* CDKINCLUDES */
0 /*
1 * $Id: histogram.h,v 1.18 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKHISTOGRAM_H
6 #define CDKHISTOGRAM_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2002,2003 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Declare the histogram structure.
58 */
59 struct SHistogram {
60 CDKOBJS obj;
61 WINDOW * parent;
62 WINDOW * win;
63 WINDOW * shadowWin;
64 int titleAdj;
65 char * curString;
66 char * lowString;
67 char * highString;
68 chtype filler;
69 float percent;
70 int fieldHeight;
71 int fieldWidth;
72 int barSize;
73 int orient;
74 int statsPos;
75 chtype statsAttr;
76 EHistogramDisplayType viewType;
77 int high;
78 int low;
79 int value;
80 int lowx;
81 int lowy;
82 int curx;
83 int cury;
84 int highx;
85 int highy;
86 int boxWidth;
87 int boxHeight;
88 boolean shadow;
89 };
90 typedef struct SHistogram CDKHISTOGRAM;
91
92 /*
93 * This returns a new pointer to a histogram pointer.
94 */
95 CDKHISTOGRAM *newCDKHistogram (
96 CDKSCREEN * /* cdkscreen */,
97 int /* xpos */,
98 int /* ypos */,
99 int /* height */,
100 int /* width */,
101 int /* orient */,
102 char * /* title */,
103 boolean /* Box */,
104 boolean /* shadow */);
105
106 /*
107 * This was added to make the build simpler. All this will
108 * do is call drawCDKHistogram.
109 */
110 void activateCDKHistogram (
111 CDKHISTOGRAM * /* histogram */,
112 chtype * /* actions */);
113
114 /*
115 * These set specific attributes of the histogram.
116 */
117 void setCDKHistogram (
118 CDKHISTOGRAM * /* histogram */,
119 EHistogramDisplayType /* viewtype */,
120 int /* statsPos */,
121 chtype /* statsAttr */,
122 int /* low */,
123 int /* high */,
124 int /* value */,
125 chtype /* filler */,
126 boolean /* Box */);
127
128 /*
129 * This sets the low/high/current value of the histogram.
130 */
131 void setCDKHistogramValue (
132 CDKHISTOGRAM * /* histogram */,
133 int /* low */,
134 int /* high */,
135 int /* value */);
136
137 int getCDKHistogramValue (
138 CDKHISTOGRAM * /* histogram */);
139
140 int getCDKHistogramLowValue (
141 CDKHISTOGRAM * /* histogram */);
142
143 int getCDKHistogramHighValue (
144 CDKHISTOGRAM * /* histogram */);
145
146 /*
147 * This sets the view type of the histogram.
148 */
149 void setCDKHistogramDisplayType (
150 CDKHISTOGRAM * /* histogram */,
151 EHistogramDisplayType /* viewtype */);
152
153 EHistogramDisplayType getCDKHistogramViewType (
154 CDKHISTOGRAM * /* histogram */);
155
156 /*
157 * This returns the filler character used to draw the histogram.
158 */
159 void setCDKHistogramFillerChar (
160 CDKHISTOGRAM * /* histogram */,
161 chtype /* character */);
162
163 chtype getCDKHistogramFillerChar (
164 CDKHISTOGRAM * /* histogram */);
165
166 /*
167 * This states where the statistics value is to be located on the histogram.
168 */
169 void setCDKHistogramStatsPos (
170 CDKHISTOGRAM * /* histogram */,
171 int /* statsPos */);
172
173 int getCDKHistogramStatsPos (
174 CDKHISTOGRAM * /* histogram */);
175
176 /*
177 * This sets the attribute of the statistics.
178 */
179 void setCDKHistogramStatsAttr (
180 CDKHISTOGRAM * /* histogram */,
181 chtype /* statsAttr */);
182
183 chtype getCDKHistogramStatsAttr (
184 CDKHISTOGRAM * /* histogram */);
185
186 /*
187 * This sets the box attribute of the widget.
188 */
189 void setCDKHistogramBox (
190 CDKHISTOGRAM * /* histogram */,
191 boolean /* Box */);
192
193 boolean getCDKHistogramBox (
194 CDKHISTOGRAM * /* histogram */);
195
196 /*
197 * These set the drawing characters of the widget.
198 */
199 #define setCDKHistogramULChar(w,c) setULCharOf(w,c)
200 #define setCDKHistogramURChar(w,c) setURCharOf(w,c)
201 #define setCDKHistogramLLChar(w,c) setLLCharOf(w,c)
202 #define setCDKHistogramLRChar(w,c) setLRCharOf(w,c)
203 #define setCDKHistogramVerticalChar(w,c) setVTCharOf(w,c)
204 #define setCDKHistogramHorizontalChar(w,c) setHZCharOf(w,c)
205 #define setCDKHistogramBoxAttribute(w,c) setBXAttrOf(w,c)
206
207 /*
208 * This sets the background color of the widget.
209 */
210 #define setCDKHistogramBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
211
212 /*
213 * This sets the background attribute of the widget.
214 */
215 #define setCDKHistogramBackgroundAttrib(w,c) setBKAttrOf(w,c)
216
217 /*
218 * This draws the widget on the screen.
219 */
220 #define drawCDKHistogram(obj,Box) drawCDKObject(obj,Box)
221
222 /*
223 * This removes the widget from the screen.
224 */
225 #define eraseCDKHistogram(obj) eraseCDKObject(obj)
226
227 /*
228 * This moves the widget to the given location.
229 */
230 #define moveCDKHistogram(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
231
232 /*
233 * This allows the user to interactively position the widget on the screen.
234 */
235 #define positionCDKHistogram(widget) positionCDKObject(ObjOf(widget),widget->win)
236
237 /*
238 * This destroys the histogram and all related pointers.
239 */
240 #define destroyCDKHistogram(obj) destroyCDKObject(obj)
241
242 #ifdef __cplusplus
243 }
244 #endif
245
246 #endif /* CDKHISTOGRAM_H */
247 #endif /* CDKINCLUDES */
0 /*
1 * $Id: itemlist.h,v 1.23 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKITEMLIST_H
6 #define CDKITEMLIST_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2003 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Define the CDK itemlist widget structure.
58 */
59 struct SItemList {
60 CDKOBJS obj;
61 WINDOW * parent;
62 WINDOW * win;
63 WINDOW * shadowWin;
64 WINDOW * labelWin;
65 WINDOW * fieldWin;
66 int titleAdj;
67 chtype * label;
68 int labelLen;
69 int fieldWidth;
70 chtype ** item;
71 int * itemPos;
72 int * itemLen;
73 int listSize;
74 int currentItem;
75 int defaultItem;
76 int boxWidth;
77 int boxHeight;
78 EExitType exitType;
79 boolean shadow;
80 };
81 typedef struct SItemList CDKITEMLIST;
82
83 /*
84 * This creates a pointer to a CDK itemlist widget.
85 */
86 CDKITEMLIST *newCDKItemlist (
87 CDKSCREEN * /* cdkscreen */,
88 int /* xpos */,
89 int /* ypos */,
90 char * /* title */,
91 char * /* label */,
92 char ** /* itemlist */,
93 int /* count */,
94 int /* defaultItem */,
95 boolean /* Box */,
96 boolean /* shadow */);
97
98 /*
99 * This activates the itemlist widget.
100 */
101 int activateCDKItemlist (
102 CDKITEMLIST * /* itemlist */,
103 chtype * /* actions */);
104
105 /*
106 * This injects a single character into the itemlist widget.
107 */
108 #define injectCDKItemlist(obj,input) injectCDKObject(obj,input,Int)
109
110 /*
111 * These functions set specific elements of the itemlist widget.
112 */
113 void setCDKItemlist (
114 CDKITEMLIST * /* itemlist */,
115 char ** /* list */,
116 int /* count */,
117 int /* current */,
118 boolean /* Box */);
119
120 /*
121 * This function sets the values of the item list widget.
122 */
123 void setCDKItemlistValues (
124 CDKITEMLIST * /* itemlist */,
125 char ** /* list */,
126 int /* count */,
127 int /* defaultItem */);
128
129 chtype **getCDKItemlistValues (
130 CDKITEMLIST * /* itemlist */,
131 int * /* size */);
132
133 /*
134 * This sets the default item in the list.
135 */
136 void setCDKItemlistDefaultItem (
137 CDKITEMLIST * /* itemlist */,
138 int /* defaultItem */);
139
140 int getCDKItemlistDefaultItem (
141 CDKITEMLIST * /* itemlist */);
142
143 /*
144 * This returns an index to the current item in the list.
145 */
146 void setCDKItemlistCurrentItem (
147 CDKITEMLIST * /* itemlist */,
148 int /* currentItem */);
149
150 int getCDKItemlistCurrentItem (
151 CDKITEMLIST * /* itemlist */);
152
153 /*
154 * This sets the box attribute of the widget.
155 */
156 void setCDKItemlistBox (
157 CDKITEMLIST * /* itemlist */,
158 boolean /* Box */);
159
160 boolean getCDKItemlistBox (
161 CDKITEMLIST * /* itemlist */);
162
163 /*
164 * These set the drawing characters of the widget.
165 */
166 #define setCDKItemlistULChar(w,c) setULCharOf(w,c)
167 #define setCDKItemlistURChar(w,c) setURCharOf(w,c)
168 #define setCDKItemlistLLChar(w,c) setLLCharOf(w,c)
169 #define setCDKItemlistLRChar(w,c) setLRCharOf(w,c)
170 #define setCDKItemlistVerticalChar(w,c) setVTCharOf(w,c)
171 #define setCDKItemlistHorizontalChar(w,c) setHZCharOf(w,c)
172 #define setCDKItemlistBoxAttribute(w,c) setBXAttrOf(w,c)
173
174 /*
175 * This sets the background color of the widget.
176 */
177 #define setCDKItemlistBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
178
179 /*
180 * This sets the background attribute of the widget.
181 */
182 #define setCDKItemlistBackgroundAttrib(w,c) setBKAttrOf(w,c)
183
184 /*
185 * This draws the itemlist widget.
186 */
187 #define drawCDKItemlist(obj,Box) drawCDKObject(obj,Box)
188
189 /*
190 * This draws the itemlist field.
191 */
192 void drawCDKItemlistField (
193 CDKITEMLIST * /* itemlist */,
194 boolean /* highlight */);
195
196 /*
197 * This removes the widget from the screen.
198 */
199 #define eraseCDKItemlist(obj) eraseCDKObject(obj)
200
201 /*
202 * This moves the widget to the given position.
203 */
204 #define moveCDKItemlist(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
205
206 /*
207 * This allows the user to interactively move the widget.
208 */
209 #define positionCDKItemlist(widget) positionCDKObject(ObjOf(widget),widget->win)
210
211 /*
212 * This destroys the widget and all the associated memory.
213 */
214 #define destroyCDKItemlist(obj) destroyCDKObject(obj)
215
216 /*
217 * These functions set the pre/post process functions.
218 */
219 #define setCDKItemlistPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
220 #define setCDKItemlistPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
221
222 #ifdef __cplusplus
223 }
224 #endif
225
226 #endif /* CDKITEMLIST_H */
227 #endif /* CDKINCLUDES */
0 /*
1 * $Id: label.h,v 1.18 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKLABEL_H
6 #define CDKLABEL_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 2000-2002,2003 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Declare any definitions you need to make.
58 */
59 #define MAX_LABEL_ROWS 300 /* unused by widgets */
60
61 /*
62 * Declare the CDK label structure.
63 */
64 struct SLabel {
65 CDKOBJS obj;
66 WINDOW * parent;
67 WINDOW * win;
68 WINDOW * shadowWin;
69 chtype ** info;
70 int * infoLen;
71 int * infoPos;
72 int boxWidth;
73 int boxHeight;
74 int xpos;
75 int ypos;
76 int rows;
77 boolean shadow;
78 };
79 typedef struct SLabel CDKLABEL;
80
81 /*
82 * This creates a new CDK label widget.
83 */
84 CDKLABEL *newCDKLabel (
85 CDKSCREEN * /* screen */,
86 int /* xPos */,
87 int /* yPos */,
88 char ** /* mesg */,
89 int /* rows */,
90 boolean /* Box */,
91 boolean /* shadow */);
92
93 /*
94 * This was added to make the builder simpler. All this will
95 * do is call drawCDKLabel.
96 */
97 void activateCDKLabel (
98 CDKLABEL * /* label */,
99 chtype * /* actions */);
100
101 /*
102 * This sets multiple attributes of the widget.
103 */
104 void setCDKLabel (
105 CDKLABEL * /* label */,
106 char ** /* message */,
107 int /* lines */,
108 boolean /* Box */);
109
110 /*
111 * This sets the contents of the label.
112 */
113 void setCDKLabelMessage (
114 CDKLABEL * /* label */,
115 char ** /* mesg */,
116 int /* lines */);
117 chtype **getCDKLabelMessage (
118 CDKLABEL * /* label */,
119 int * /* size */);
120
121 /*
122 * This sets the box attribute of the widget.
123 */
124 void setCDKLabelBox (
125 CDKLABEL * /* label */,
126 boolean /* Box */);
127 boolean getCDKLabelBox (
128 CDKLABEL * /* label */);
129
130 /*
131 * This draws the label.
132 */
133 #define drawCDKLabel(obj,Box) drawCDKObject(obj,Box)
134
135 /*
136 * These set the drawing characters of the widget.
137 */
138 #define setCDKLabelULChar(w,c) setULCharOf(w,c)
139 #define setCDKLabelURChar(w,c) setURCharOf(w,c)
140 #define setCDKLabelLLChar(w,c) setLLCharOf(w,c)
141 #define setCDKLabelLRChar(w,c) setLRCharOf(w,c)
142 #define setCDKLabelVerticalChar(w,c) setVTCharOf(w,c)
143 #define setCDKLabelHorizontalChar(w,c) setHZCharOf(w,c)
144 #define setCDKLabelBoxAttribute(w,c) setBXAttrOf(w,c)
145
146 /*
147 * This sets the background color of the widget.
148 */
149 #define setCDKLabelBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
150
151 /*
152 * This sets the background attribute of the widget.
153 */
154 #define setCDKLabelBackgroundAttrib(w,c) setBKAttrOf(w,c)
155
156 /*
157 * This erases the label.
158 */
159 #define eraseCDKLabel(obj) eraseCDKObject(obj)
160
161 /*
162 * This destroys the label and the memory used by it.
163 */
164 #define destroyCDKLabel(obj) destroyCDKObject(obj)
165
166 /*
167 * This draws the label then waits for the user to press
168 * the key defined by the 'key' parameter.
169 */
170 char waitCDKLabel (
171 CDKLABEL * /* label */,
172 char /* key */);
173
174 /*
175 * This moves the label.
176 */
177 #define moveCDKLabel(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
178
179 /*
180 * This allows the user to interactively position the label.
181 */
182 #define positionCDKLabel(widget) positionCDKObject(ObjOf(widget),widget->win)
183
184 #ifdef __cplusplus
185 }
186 #endif
187
188 #endif /* CDKLABEL_H */
189 #endif /* CDKINCLUDES */
0 /*
1 * $Id: marquee.h,v 1.18 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKMARQUEE_H
6 #define CDKMARQUEE_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2002,2003 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Define the CDK marquee widget structure.
58 */
59 struct SMarquee {
60 CDKOBJS obj;
61 WINDOW * parent;
62 WINDOW * win;
63 WINDOW * shadowWin;
64 int active;
65 int width;
66 int boxWidth;
67 int boxHeight;
68 boolean shadow;
69 };
70 typedef struct SMarquee CDKMARQUEE;
71
72 /*
73 * This creates a new marquee widget pointer.
74 */
75 CDKMARQUEE *newCDKMarquee (
76 CDKSCREEN * /* cdkscreen */,
77 int /* xpos */,
78 int /* ypos */,
79 int /* width */,
80 boolean /* Box */,
81 boolean /* shadow */);
82
83 /*
84 * This turns the marquee 'on'.
85 */
86 int activateCDKMarquee (
87 CDKMARQUEE * /* marquee */,
88 char * /* message */,
89 int /* delay */,
90 int /* repeat */,
91 boolean /* Box */);
92
93 /*
94 * This turns 'off' the marquee.
95 */
96 void deactivateCDKMarquee (
97 CDKMARQUEE * /* marquee */);
98
99 /*
100 * This draws the marquee on the screen.
101 */
102 #define drawCDKMarquee(obj,Box) drawCDKObject(obj,Box)
103
104 /*
105 * This removes the widget from the screen.
106 */
107 #define eraseCDKMarquee(obj) eraseCDKObject(obj)
108
109 /*
110 * This moves the widget to the given location.
111 */
112 #define moveCDKMarquee(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
113
114 /*
115 * This interactively positions the widget on the screen.
116 */
117 #define positionCDKMarquee(widget) positionCDKObject(ObjOf(widget),widget->win)
118
119 /*
120 * This destroys the marquee widget.
121 */
122 #define destroyCDKMarquee(obj) destroyCDKObject(obj)
123
124 /*
125 * These set the drawing characters of the widget.
126 */
127 #define setCDKMarqueeULChar(w,c) setULCharOf(w,c)
128 #define setCDKMarqueeURChar(w,c) setURCharOf(w,c)
129 #define setCDKMarqueeLLChar(w,c) setLLCharOf(w,c)
130 #define setCDKMarqueeLRChar(w,c) setLRCharOf(w,c)
131 #define setCDKMarqueeVerticalChar(w,c) setVTCharOf(w,c)
132 #define setCDKMarqueeHorizontalChar(w,c) setHZCharOf(w,c)
133 #define setCDKMarqueeBoxAttribute(w,c) setBXAttrOf(w,c)
134
135 /*
136 * This sets the box attribute of the widget.
137 */
138 void setCDKMarqueeBox (
139 CDKMARQUEE * /* marquee */,
140 boolean /* Box */);
141
142 boolean getCDKMarqueeBox (
143 CDKMARQUEE * /* marquee */);
144
145 /*
146 * This sets the background color of the widget.
147 */
148 #define setCDKMarqueeBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
149
150 /*
151 * This sets the background attribute of the widget.
152 */
153 #define setCDKMarqueeBackgroundAttrib(w,c) setBKAttrOf(w,c)
154
155 #ifdef __cplusplus
156 }
157 #endif
158
159 #endif /* CDKMARQUEE_H */
160 #endif /* CDKINCLUDES */
0 /*
1 * $Id: matrix.h,v 1.28 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKMATRIX_H
6 #define CDKMATRIX_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2003 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Declare some matrix definitions.
58 */
59 #define MAX_MATRIX_ROWS 1000
60 #define MAX_MATRIX_COLS 1000
61
62 /*
63 * Define the CDK matrix widget structure.
64 */
65 typedef struct SMatrix CDKMATRIX;
66 typedef void (*MATRIXCB) (CDKMATRIX *matrix, chtype input);
67
68 #define CELL_LIMIT MAX_MATRIX_ROWS][MAX_MATRIX_COLS
69
70 #define NEW_CDKMATRIX 1
71
72 #if NEW_CDKMATRIX
73 #define CELL_INDEX(matrix, row,col) (((row) * ((matrix)->cols + 1)) + (col))
74 #else
75 #define CELL_INDEX(matrix, row,col) (row)][(col)
76 #endif
77
78 #define MATRIX_CELL(matrix,row,col) ((matrix)->cell[CELL_INDEX(matrix, row, col)])
79 #define MATRIX_INFO(matrix,row,col) ((matrix)->info[CELL_INDEX(matrix, row, col)])
80
81 struct SMatrix {
82 CDKOBJS obj;
83 WINDOW * parent;
84 WINDOW * win;
85 WINDOW * shadowWin;
86 #if NEW_CDKMATRIX
87 WINDOW ** cell;
88 char ** info;
89 #else
90 WINDOW * cell[CELL_LIMIT];
91 char * info[CELL_LIMIT];
92 #endif
93 int titleAdj;
94 int rows;
95 int cols;
96 int vrows;
97 int vcols;
98 int * colwidths;
99 int * colvalues;
100 chtype ** coltitle;
101 int * coltitleLen;
102 int * coltitlePos;
103 int maxct;
104 chtype ** rowtitle;
105 int * rowtitleLen;
106 int * rowtitlePos;
107 int maxrt;
108 int boxHeight;
109 int boxWidth;
110 int rowSpace;
111 int colSpace;
112 int row;
113 int col;
114 int crow; /* current row */
115 int ccol; /* current column */
116 int trow;
117 int lcol;
118 int oldcrow;
119 int oldccol;
120 int oldvrow;
121 int oldvcol;
122 EExitType exitType;
123 boolean boxCell;
124 boolean shadow;
125 chtype highlight;
126 int dominant;
127 chtype filler;
128 MATRIXCB callbackfn;
129 };
130
131 /*
132 * This creates a new pointer to a matrix widget.
133 */
134 CDKMATRIX *newCDKMatrix (
135 CDKSCREEN * /* cdkscreen */,
136 int /* xpos */,
137 int /* ypos */,
138 int /* rows */,
139 int /* cols */,
140 int /* vrows */,
141 int /* vcols */,
142 char * /* title */,
143 char ** /* rowtitles */,
144 char ** /* coltitles */,
145 int * /* colwidths */,
146 int * /* coltypes */,
147 int /* rowspace */,
148 int /* colspace */,
149 chtype /* filler */,
150 int /* dominantAttrib */,
151 boolean /* boxMatrix */,
152 boolean /* boxCell */,
153 boolean /* shadow */);
154
155 /*
156 * This activates the matrix.
157 */
158 int activateCDKMatrix (
159 CDKMATRIX * /* matrix */,
160 chtype * /* actions */);
161
162 /*
163 * This injects a single character into the matrix widget.
164 */
165 #define injectCDKMatrix(obj,input) injectCDKObject(obj,input,Int)
166
167 /*
168 * This sets the contents of the matrix widget from a fixed-size 2d array.
169 * The predefined array limits are very large.
170 * Use setCDKMatrixCells() instead.
171 */
172 #define setCDKMatrix(matrix, info, rows, subSize) \
173 setCDKMatrixCells(matrix, &info[0][0], rows, MAX_MATRIX_COLS, subSize)
174
175 /*
176 * This sets the contents of the matrix widget from an array defined by the
177 * caller. It may be any size. For compatibility with setCDKMatrix(), the
178 * info[][] array's subscripts start at 1.
179 */
180 void setCDKMatrixCells (
181 CDKMATRIX * /* matrix */,
182 char ** /* info */,
183 int /* rows */,
184 int /* cols */,
185 int * /* subSize */);
186
187 /*
188 * This sets the value of a given cell.
189 */
190 int setCDKMatrixCell (
191 CDKMATRIX * /* matrix */,
192 int /* row */,
193 int /* col */,
194 char * /* value */);
195
196 char *getCDKMatrixCell (
197 CDKMATRIX * /* matrix */,
198 int /* row */,
199 int /* col */);
200
201 /*
202 * This returns the row/col of the matrix.
203 */
204 int getCDKMatrixCol (
205 CDKMATRIX * /* matrix */);
206
207 int getCDKMatrixRow (
208 CDKMATRIX * /* matrix */);
209
210 /*
211 * These set the drawing characters of the widget.
212 */
213 #define setCDKMatrixULChar(w,c) setULCharOf(w,c)
214 #define setCDKMatrixURChar(w,c) setURCharOf(w,c)
215 #define setCDKMatrixLLChar(w,c) setLLCharOf(w,c)
216 #define setCDKMatrixLRChar(w,c) setLRCharOf(w,c)
217 #define setCDKMatrixVerticalChar(w,c) setVTCharOf(w,c)
218 #define setCDKMatrixHorizontalChar(w,c) setHZCharOf(w,c)
219 #define setCDKMatrixBoxAttribute(w,c) setBXAttrOf(w,c)
220
221 /*
222 * This sets the background color of the widget.
223 */
224 #define setCDKMatrixBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
225
226 /*
227 * This sets the background attribute of the widget.
228 */
229 #define setCDKMatrixBackgroundAttrib(w,c) setBKAttrOf(w,c)
230
231 /*
232 * This draws the matrix on the screen.
233 */
234 #define drawCDKMatrix(obj,Box) drawCDKObject(obj,Box)
235
236 /*
237 * This removes the matrix from the screen.
238 */
239 #define eraseCDKMatrix(obj) eraseCDKObject(obj)
240
241 /*
242 * This cleans out all the cells from the matrix.
243 */
244 void cleanCDKMatrix (
245 CDKMATRIX * /* matrix */);
246
247 /*
248 * This cleans one cell in the matrix.
249 */
250 void cleanCDKMatrixCell (
251 CDKMATRIX * /* matrix */,
252 int /* row */,
253 int /* col */);
254
255 /*
256 * This sets the main callback in the matrix.
257 */
258 void setCDKMatrixCB (
259 CDKMATRIX * /* matrix */,
260 MATRIXCB /* callback */);
261
262 /*
263 * This moves the matrix to the given cell.
264 */
265 int moveToCDKMatrixCell (
266 CDKMATRIX * /* matrix */,
267 int /* newrow */,
268 int /* newcol */);
269
270 /*
271 * This sets the box attribute of the matrix widget.
272 */
273 void setCDKMatrixBox (
274 CDKMATRIX * /* matrix */,
275 boolean /* Box */);
276
277 boolean getCDKMatrixBox (
278 CDKMATRIX * /* matrix */);
279
280 /*
281 * This moves the matrix on the screen to the given location.
282 */
283 #define moveCDKMatrix(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
284
285 /*
286 * This allows the user to interactively position the matrix.
287 */
288 #define positionCDKMatrix(widget) positionCDKObject(ObjOf(widget),widget->win)
289
290 /*
291 * This destroys the matrix widget and associated memory.
292 */
293 #define destroyCDKMatrix(obj) destroyCDKObject(obj)
294
295 /*
296 * This jumps to the given matrix cell. You can pass in
297 * -1 for both the row/col if you want to interactively
298 * pick the cell.
299 */
300 int jumpToCell (
301 CDKMATRIX * /* matrix */,
302 int /* row */,
303 int /* col */);
304
305 /*
306 * These set the pre/post process callback functions.
307 */
308 #define setCDKMatrixPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
309 #define setCDKMatrixPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
310
311 #ifdef __cplusplus
312 }
313 #endif
314
315 #endif /* CDKMATRIX_H */
316 #endif /* CDKINCLUDES */
0 /*
1 * $Id: mentry.h,v 1.22 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKMENTRY_H
6 #define CDKMENTRY_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2002,2003 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Define the CDK multiple line entry field widget.
58 */
59 typedef struct SMentry CDKMENTRY;
60 typedef void (*MENTRYCB) (CDKMENTRY *mentry, chtype character);
61
62 struct SMentry {
63 CDKOBJS obj;
64 WINDOW * parent;
65 WINDOW * win;
66 WINDOW * shadowWin;
67 WINDOW * labelWin;
68 WINDOW * fieldWin;
69 int titleAdj;
70 chtype * label;
71 int labelLen;
72 int labelPos;
73 chtype fieldAttr;
74 int fieldWidth;
75 int boxHeight;
76 int boxWidth;
77 char * info;
78 int totalWidth;
79 int rows;
80 int currentRow;
81 int currentCol;
82 int topRow;
83 EDisplayType dispType;
84 int min;
85 int logicalRows;
86 EExitType exitType;
87 boolean shadow;
88 chtype filler;
89 chtype hidden;
90 MENTRYCB callbackfn;
91 };
92
93 /*
94 * This creates a new CDK mentry field pointer.
95 */
96 CDKMENTRY *newCDKMentry (
97 CDKSCREEN * /* cdkscreen */,
98 int /* xpos */,
99 int /* ypos */,
100 char * /* title */,
101 char * /* label */,
102 chtype /* fieldAttr */,
103 chtype /* filler */,
104 EDisplayType /* disptype */,
105 int /* fieldWidth */,
106 int /* fieldrows */,
107 int /* logicalRows */,
108 int /* min */,
109 boolean /* Box */,
110 boolean /* shadow */);
111
112 /*
113 * This activates the widget.
114 */
115 char *activateCDKMentry (
116 CDKMENTRY * /* mentry */,
117 chtype * /* input */);
118
119 /*
120 * This injects a single character into the widget.
121 */
122 #define injectCDKMentry(obj,input) injectCDKObject(obj,input,String)
123
124 /*
125 * These set specific attributes of the widget.
126 */
127 void setCDKMentry (
128 CDKMENTRY * /* mentry */,
129 char * /* value */,
130 int /* min */,
131 boolean /* Box */);
132
133 /*
134 * This sets the value of the widget.
135 */
136 void setCDKMentryValue (
137 CDKMENTRY * /* mentry */,
138 char * /* value */);
139
140 char *getCDKMentryValue (
141 CDKMENTRY * /* mentry */);
142
143 /*
144 * This sets the minimum length of the value for the widget.
145 */
146 void setCDKMentryMin (
147 CDKMENTRY * /* mentry */,
148 int /* min */);
149
150 int getCDKMentryMin (
151 CDKMENTRY * /* mentry */);
152
153 /*
154 * This sets the filler character to use when drawing the widget.
155 */
156 void setCDKMentryFillerChar (
157 CDKMENTRY * /* mentry */,
158 chtype /* filler */);
159
160 chtype getCDKMentryFillerChar (
161 CDKMENTRY * /* mentry */);
162
163 /*
164 * This sets the character to use when a hidden character type is used.
165 */
166 void setCDKMentryHiddenChar (
167 CDKMENTRY * /* mentry */,
168 chtype /* character */);
169
170 chtype getCDKMentryHiddenChar (
171 CDKMENTRY * /* mentry */);
172
173 /*
174 * This sets the box attribute of the mentry widget.
175 */
176 void setCDKMentryBox (
177 CDKMENTRY * /* mentry */,
178 boolean /* Box */);
179
180 boolean getCDKMentryBox (
181 CDKMENTRY * /* mentry */);
182
183 /*
184 * These set the drawing characters of the widget.
185 */
186 #define setCDKMentryULChar(w,c) setULCharOf(w,c)
187 #define setCDKMentryURChar(w,c) setURCharOf(w,c)
188 #define setCDKMentryLLChar(w,c) setLLCharOf(w,c)
189 #define setCDKMentryLRChar(w,c) setLRCharOf(w,c)
190 #define setCDKMentryVerticalChar(w,c) setVTCharOf(w,c)
191 #define setCDKMentryHorizontalChar(w,c) setHZCharOf(w,c)
192 #define setCDKMentryBoxAttribute(w,c) setBXAttrOf(w,c)
193
194 /*
195 * This sets the background color of the widget.
196 */
197 #define setCDKMentryBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
198
199 /*
200 * This sets the background attribute of the widget.
201 */
202 #define setCDKMentryBackgroundAttrib(w,c) setBKAttrOf(w,c)
203
204 /*
205 * This draws the widget on the screen.
206 */
207 #define drawCDKMentry(obj,Box) drawCDKObject(obj,Box)
208
209 /*
210 * This erases the widget from the screen.
211 */
212 #define eraseCDKMentry(obj) eraseCDKObject(obj)
213
214 /*
215 * This cleans out the information in the widget.
216 */
217 void cleanCDKMentry (
218 CDKMENTRY * /* mentry */);
219
220 /*
221 * This moves the widget to the given location.
222 */
223 #define moveCDKMentry(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
224
225 /*
226 * This interactively moves the widget on the screen.
227 */
228 #define positionCDKMentry(widget) positionCDKObject(ObjOf(widget),widget->win)
229
230 /*
231 * This destroys the widget pointer.
232 */
233 #define destroyCDKMentry(obj) destroyCDKObject(obj)
234
235 /*
236 * This draws the field of the widget.
237 */
238 void drawCDKMentryField (
239 CDKMENTRY * /* mentry */);
240
241 /*
242 * This sets the widgets main callback.
243 */
244 void setCDKMentryCB (
245 CDKMENTRY * /* mentry */,
246 MENTRYCB /* callback */);
247
248 /*
249 * These set the pre/post process callback functions.
250 */
251 #define setCDKMentryPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
252 #define setCDKMentryPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
253
254 #ifdef __cplusplus
255 }
256 #endif
257
258 #endif /* CDKMENTRY_H */
259 #endif /* CDKINCLUDES */
0 /*
1 * $Id: menu.h,v 1.21 2005/12/26 17:35:19 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKMENU_H
6 #define CDKMENU_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2004,2005 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Define menu specific values.
58 */
59 #define MAX_MENU_ITEMS 30
60 #define MAX_SUB_ITEMS 98
61
62 /*
63 * Define the CDK menu widget structure.
64 */
65 struct SMenu {
66 CDKOBJS obj;
67 WINDOW * parent;
68 WINDOW * pullWin[MAX_MENU_ITEMS];
69 WINDOW * titleWin[MAX_MENU_ITEMS];
70 chtype * title[MAX_MENU_ITEMS];
71 int titleLen[MAX_MENU_ITEMS];
72 chtype * sublist[MAX_MENU_ITEMS][MAX_SUB_ITEMS];
73 int sublistLen[MAX_MENU_ITEMS][MAX_SUB_ITEMS];
74 int subsize[MAX_MENU_ITEMS];
75 int menuPos;
76 int menuItems;
77 chtype titleAttr;
78 chtype subtitleAttr;
79 int currentTitle;
80 int currentSubtitle;
81 int lastTitle;
82 int lastSubtitle;
83 EExitType exitType;
84 int lastSelection;
85 };
86 typedef struct SMenu CDKMENU;
87
88 /*
89 * This creates a new CDK menu widget pointer.
90 */
91 CDKMENU *newCDKMenu (
92 CDKSCREEN * /* cdkscreen */,
93 char * /* menulist */ [MAX_MENU_ITEMS][MAX_SUB_ITEMS],
94 int /* menuitems */,
95 int * /* subsize */,
96 int * /* menuloc */,
97 int /* menuPos */,
98 chtype /* titleattr */,
99 chtype /* subtitleattr */);
100
101 /*
102 * This activates the menu.
103 */
104 int activateCDKMenu (
105 CDKMENU * /* menu */,
106 chtype * /* actions */);
107
108 /*
109 * This injects a single character into the menu widget.
110 */
111 #define injectCDKMenu(obj,input) injectCDKObject(obj,input,Int)
112
113 /*
114 * These set specific attributes of the menu.
115 */
116 void setCDKMenu (
117 CDKMENU * /* menu */,
118 int /* menuItem */,
119 int /* subMenuItem */,
120 chtype /* titleHighlight */,
121 chtype /* subTitleHighlight */);
122
123 /*
124 * This returns the current item the menu is on.
125 */
126 void setCDKMenuCurrentItem (
127 CDKMENU * /* menu */,
128 int /* menuItem */,
129 int /* subMenuItem */);
130
131 void getCDKMenuCurrentItem (
132 CDKMENU * /* menu */,
133 int * /* menuItem */,
134 int * /* subMenuItem */);
135
136 /*
137 * This sets the highlight of the title.
138 */
139 void setCDKMenuTitleHighlight (
140 CDKMENU * /* menu */,
141 chtype /* highlight */);
142
143 chtype getCDKMenuTitleHighlight (
144 CDKMENU * /* menu */);
145
146 /*
147 * This sets the sub-menu title highlight.
148 */
149 void setCDKMenuSubTitleHighlight (
150 CDKMENU * /* menu */,
151 chtype /* highlight */);
152
153 chtype getCDKMenuSubTitleHighlight (
154 CDKMENU * /* menu */);
155
156 /*
157 * This draws the menu on the screen.
158 */
159 #define drawCDKMenu(obj,box) drawCDKObject(obj,box)
160
161 void drawCDKMenuSubwin (
162 CDKMENU * /* menu */);
163
164 /*
165 * This erases the complere menu widget from the screen.
166 */
167 #define eraseCDKMenu(obj) eraseCDKObject(obj)
168
169 void eraseCDKMenuSubwin (
170 CDKMENU * /* menu */);
171
172 /*
173 * This sets the background color of the widget.
174 */
175 #define setCDKMenuBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
176
177 /*
178 * This sets the background attribute of the widget.
179 */
180 #define setCDKMenuBackgroundAttrib(w,c) setBKAttrOf(w,c)
181
182 /*
183 * This destroys the menu widget.
184 */
185 #define destroyCDKMenu(obj) destroyCDKObject(obj)
186
187 /*
188 * These set the pre/post process callback functions.
189 */
190 #define setCDKMenuPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
191 #define setCDKMenuPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
192
193 #ifdef __cplusplus
194 }
195 #endif
196
197 #endif /* CDKMENU_H */
198 #endif /* CDKINCLUDES */
0 /*
1 * $Id: radio.h,v 1.28 2005/12/28 21:44:56 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKRADIO_H
6 #define CDKRADIO_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2004,2005 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Define the CDK radio list widget structure.
58 */
59 struct SRadio {
60 CDKOBJS obj;
61 WINDOW * parent;
62 WINDOW * win;
63 WINDOW * scrollbarWin;
64 WINDOW * shadowWin;
65 chtype ** item;
66 int * itemLen;
67 int * itemPos;
68 int titleAdj; /* unused */
69 chtype choiceChar;
70 chtype leftBoxChar;
71 chtype rightBoxChar;
72 int maxLeftChar;
73 int widestItem;
74 int leftChar;
75 int selectedItem;
76 int currentTop;
77 int currentItem;
78 int currentHigh;
79 int scrollbarPlacement;
80 boolean scrollbar;
81
82 int toggleSize;
83 int togglePos;
84 float step;
85 int listSize;
86 int lastItem;
87 int maxTopItem;
88 int boxWidth;
89 int boxHeight;
90 int viewSize;
91
92 int defItem;
93 EExitType exitType;
94 boolean shadow;
95 chtype highlight;
96 };
97 typedef struct SRadio CDKRADIO;
98
99 /*
100 * This creates a new radio widget pointer.
101 */
102 CDKRADIO *newCDKRadio (
103 CDKSCREEN * /* cdkscreen */,
104 int /* xpos */,
105 int /* ypos */,
106 int /* spos */,
107 int /* height */,
108 int /* width */,
109 char * /* title */,
110 char ** /* mesg */,
111 int /* items */,
112 chtype /* choiceChar */,
113 int /* defItem */,
114 chtype /* highlight */,
115 boolean /* Box */,
116 boolean /* shadow */);
117
118 /*
119 * This activates the widget.
120 */
121 int activateCDKRadio (
122 CDKRADIO * /* radio */,
123 chtype * /* actions */);
124
125 /*
126 * This injects a single character into the widget.
127 */
128 #define injectCDKRadio(obj,input) injectCDKObject(obj,input,Int)
129
130 /*
131 * These set various attributes of the widget.
132 */
133 void setCDKRadio (
134 CDKRADIO * /* radio */,
135 chtype /* highlight */,
136 chtype /* character */,
137 boolean /* Box */);
138
139 /*
140 * This sets the contents of the radio list.
141 */
142 void setCDKRadioItems (
143 CDKRADIO * /* radio */,
144 char ** /* list */,
145 int /* listSize */);
146
147 int getCDKRadioItems (
148 CDKRADIO * /* radio */,
149 char ** /* list */);
150
151 /*
152 * This sets the highlight bar attribute.
153 */
154 void setCDKRadioHighlight (
155 CDKRADIO * /* radio */,
156 chtype /* highlight */);
157
158 chtype getCDKRadioHighlight (
159 CDKRADIO * /* radio */);
160
161 /*
162 * This sets the 'selected' character.
163 */
164 void setCDKRadioChoiceCharacter (
165 CDKRADIO * /* radio */,
166 chtype /* character */);
167
168 chtype getCDKRadioChoiceCharacter (
169 CDKRADIO * /* radio */);
170
171 /*
172 * This sets the character to draw on the left/right side of
173 * the choice box.
174 */
175 void setCDKRadioLeftBrace (
176 CDKRADIO * /* radio */,
177 chtype /* character */);
178
179 chtype getCDKRadioLeftBrace (
180 CDKRADIO * /* radio */);
181
182 void setCDKRadioRightBrace (
183 CDKRADIO * /* radio */,
184 chtype /* character */);
185
186 chtype getCDKRadioRightBrace (
187 CDKRADIO * /* radio */);
188
189 /*
190 * This sets the box attribute of the widget.
191 */
192 void setCDKRadioBox (
193 CDKRADIO * /* radio */,
194 boolean /* Box */);
195
196 boolean getCDKRadioBox (
197 CDKRADIO * /* radio */);
198
199 /*
200 * This sets the current high lighted item of the widget
201 */
202 void setCDKRadioCurrentItem (
203 CDKRADIO * /* radio */,
204 int /* current item */);
205
206 int getCDKRadioCurrentItem (
207 CDKRADIO * /* radio */);
208
209 /*
210 * This sets the current selected item of the widget
211 */
212 void setCDKRadioSelectedItem (
213 CDKRADIO * /* radio */,
214 int /* current item */);
215
216 int getCDKRadioSelectedItem (
217 CDKRADIO * /* radio */);
218
219
220 /*
221 * These set the drawing characters of the widget.
222 */
223 #define setCDKRadioULChar(w,c) setULCharOf(w,c)
224 #define setCDKRadioURChar(w,c) setURCharOf(w,c)
225 #define setCDKRadioLLChar(w,c) setLLCharOf(w,c)
226 #define setCDKRadioLRChar(w,c) setLRCharOf(w,c)
227 #define setCDKRadioVerticalChar(w,c) setVTCharOf(w,c)
228 #define setCDKRadioHorizontalChar(w,c) setHZCharOf(w,c)
229 #define setCDKRadioBoxAttribute(w,c) setBXAttrOf(w,c)
230
231 /*
232 * This sets the background color of the widget.
233 */
234 #define setCDKRadioBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
235
236 /*
237 * This sets the background attribute of the widget.
238 */
239 #define setCDKRadioBackgroundAttrib(w,c) setBKAttrOf(w,c)
240
241 /*
242 * This draws the widget on the screen.
243 */
244 #define drawCDKRadio(obj,Box) drawCDKObject(obj,Box)
245
246 /*
247 * This erases the widget from the screen.
248 */
249 #define eraseCDKRadio(obj) eraseCDKObject(obj)
250
251 /*
252 * This moves the widget to the given screen location.
253 */
254 #define moveCDKRadio(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
255
256 /*
257 * This interactively moves the widget to a new location on the screen.
258 */
259 #define positionCDKRadio(widget) positionCDKObject(ObjOf(widget),widget->win)
260
261 /*
262 * This destroys a widget pointer.
263 */
264 #define destroyCDKRadio(obj) destroyCDKObject(obj)
265
266 /*
267 * These set the pre/post process callback functions.
268 */
269 #define setCDKRadioPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
270 #define setCDKRadioPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
271
272 #ifdef __cplusplus
273 }
274 #endif
275
276 #endif /* CDKRADIO_H */
277 #endif /* CDKINCLUDES */
0 /*
1 * $Id: scroll.h,v 1.30 2006/05/04 11:24:28 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKSCROLL_H
6 #define CDKSCROLL_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2005,2006 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Declare scrolling list definitions.
58 */
59 #define NUMBERS TRUE
60 #define NONUMBERS FALSE
61
62 /*
63 * Declare scrolling list definitions.
64 */
65 struct SScroll {
66 CDKOBJS obj;
67 WINDOW *parent;
68 WINDOW *win;
69 WINDOW *scrollbarWin;
70 WINDOW *listWin;
71 WINDOW *shadowWin;
72 int titleAdj; /* unused */
73 chtype ** item; /* */
74 int * itemPos; /* */
75 int * itemLen; /* */
76 int maxTopItem; /* */
77 int maxLeftChar; /* */
78 int leftChar; /* */
79 int lastItem; /* */
80 int currentTop; /* */
81 int currentItem; /* */
82 int currentHigh; /* */
83 int listSize; /* */
84 int boxWidth; /* */
85 int boxHeight; /* */
86 int viewSize; /* */
87
88 int scrollbarPlacement; /* UNUSED */
89 boolean scrollbar; /* UNUSED */
90 int toggleSize; /* size of scrollbar thumb/toggle */
91 int togglePos; /* position of scrollbar thumb/toggle */
92 float step; /* increment for scrollbar */
93
94 EExitType exitType; /* */
95 boolean shadow; /* */
96 boolean numbers; /* */
97 chtype titlehighlight; /* */
98 chtype highlight; /* */
99 };
100 typedef struct SScroll CDKSCROLL;
101
102 /*
103 * This creates a new CDK scrolling list pointer.
104 */
105 CDKSCROLL *newCDKScroll (
106 CDKSCREEN * /* cdkscreen */,
107 int /* xpos */,
108 int /* ypos */,
109 int /* spos */,
110 int /* height */,
111 int /* width */,
112 char * /* title */,
113 char ** /* itemList */,
114 int /* items */,
115 boolean /* numbers */,
116 chtype /* highlight */,
117 boolean /* Box */,
118 boolean /* shadow */);
119
120 /*
121 * This activates the scrolling list.
122 */
123 int activateCDKScroll (
124 CDKSCROLL * /* scroll */,
125 chtype * /* actions */);
126
127 /*
128 * This injects a single character into the scrolling list.
129 */
130 #define injectCDKScroll(obj,input) injectCDKObject(obj,input,Int)
131
132 /*
133 * This sets various attributes of the scrolling list.
134 */
135 void setCDKScroll (
136 CDKSCROLL * /* scroll */,
137 char ** /* itemList */,
138 int /* items */,
139 boolean /* numbers */,
140 chtype /* highlight */,
141 boolean /* Box */);
142
143 void setCDKScrollPosition (
144 CDKSCROLL * /* scroll */,
145 int /* item */);
146
147 int getCDKScrollCurrent(
148 CDKSCROLL * /* scroll */);
149
150 void setCDKScrollCurrent(
151 CDKSCROLL * /* scroll */,
152 int /* i */);
153
154 int getCDKScrollCurrentTop(
155 CDKSCROLL * /* scroll */);
156
157 void setCDKScrollCurrentTop(
158 CDKSCROLL * /* scroll */,
159 int /* i */);
160
161 int getCDKScrollCurrentItem(
162 CDKSCROLL * /* scroll */);
163
164 void setCDKScrollCurrentItem(
165 CDKSCROLL * /* scroll */,
166 int /* i */);
167
168 /*
169 * This sets the contents of the scrolling list.
170 */
171 void setCDKScrollItems (
172 CDKSCROLL * /* scroll */,
173 char ** /* itemList */,
174 int /* items */,
175 boolean /* numbers */);
176
177 int getCDKScrollItems (
178 CDKSCROLL * /* scroll */,
179 char ** /* itemList */);
180
181 /*
182 * This sets the highlight bar of the scrolling list.
183 */
184 void setCDKScrollHighlight (
185 CDKSCROLL * /* scroll */,
186 chtype /* highlight */);
187
188 chtype getCDKScrollHighlight (
189 CDKSCROLL * /* scroll */,
190 chtype /* highlight */);
191
192 /*
193 * This sets the box attribute of the widget.
194 */
195 void setCDKScrollBox (
196 CDKSCROLL * /* scroll */,
197 boolean /* Box */);
198
199 boolean getCDKScrollBox (
200 CDKSCROLL * /* scroll */);
201
202 /*
203 * These set the drawing characters of the widget.
204 */
205 #define setCDKScrollULChar(w,c) setULCharOf(w,c)
206 #define setCDKScrollURChar(w,c) setURCharOf(w,c)
207 #define setCDKScrollLLChar(w,c) setLLCharOf(w,c)
208 #define setCDKScrollLRChar(w,c) setLRCharOf(w,c)
209 #define setCDKScrollVerticalChar(w,c) setVTCharOf(w,c)
210 #define setCDKScrollHorizontalChar(w,c) setHZCharOf(w,c)
211 #define setCDKScrollBoxAttribute(w,c) setBXAttrOf(w,c)
212
213 /*
214 * This sets the background color of the widget.
215 */
216 #define setCDKScrollBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
217
218 /*
219 * This sets the background attribute of the widget.
220 */
221 #define setCDKScrollBackgroundAttrib(w,c) setBKAttrOf(w,c)
222
223 /*
224 * This adds a single item to the end of scrolling list.
225 */
226 void addCDKScrollItem (
227 CDKSCROLL * /* scroll */,
228 char * /* item */);
229
230 /*
231 * This adds a single item into the scrolling list.
232 */
233 void insertCDKScrollItem (
234 CDKSCROLL * /* scroll */,
235 char * /* item */);
236
237 /*
238 * This deletes a single item from the scrolling list.
239 */
240 void deleteCDKScrollItem (
241 CDKSCROLL * /* scroll */,
242 int /* position */);
243
244 /*
245 * This draws the scrolling list on the screen.
246 */
247 #define drawCDKScroll(obj,Box) drawCDKObject(obj,Box)
248
249 /*
250 * This removes the scrolling list from the screen.
251 */
252 #define eraseCDKScroll(obj) eraseCDKObject(obj)
253
254 /*
255 * This moves the widget to the given location.
256 */
257 #define moveCDKScroll(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
258
259 /*
260 * This allows the user to interactively position the widget on the screen.
261 */
262 #define positionCDKScroll(widget) positionCDKObject(ObjOf(widget),widget->win)
263
264 /*
265 * This destroys the widget and all associated memory.
266 */
267 #define destroyCDKScroll(obj) destroyCDKObject(obj)
268
269 /*
270 * These set the scrolling list pre/post process functions.
271 */
272 #define setCDKScrollPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
273 #define setCDKScrollPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
274
275 #ifdef __cplusplus
276 }
277 #endif
278
279 #endif /* CDKSCROLL_H */
280 #endif /* CDKINCLUDES */
0 /*
1 * $Id: selection.h,v 1.26 2005/12/28 21:45:16 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKSELECTION_H
6 #define CDKSELECTION_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2003,2005 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Declare selection list definitions.
58 */
59 #define MAX_CHOICES 100 /* unused by widgets */
60
61 /*
62 * Define the CDK selection widget structure.
63 */
64 struct SSelection {
65 CDKOBJS obj;
66 WINDOW * parent;
67 WINDOW * win;
68 WINDOW * scrollbarWin;
69 WINDOW * shadowWin;
70 int titleAdj; /* unused */
71 chtype ** item;
72 int * itemLen;
73 int * itemPos;
74 chtype ** choice;
75 int * choicelen;
76 int choiceCount;
77 int maxchoicelen;
78 int * selections;
79 int * mode;
80 int maxTopItem;
81 int maxLeftChar;
82 int leftChar;
83
84 int lastItem;
85 int currentTop;
86 int currentHigh;
87 int currentItem;
88 int listSize;
89 int scrollbarPlacement;
90 boolean scrollbar;
91 int toggleSize;
92 int togglePos;
93 float step;
94
95 int boxWidth;
96 int boxHeight;
97 int viewSize;
98 EExitType exitType;
99 boolean shadow;
100 chtype highlight;
101 };
102 typedef struct SSelection CDKSELECTION;
103
104 /*
105 * This creates a new pointer to a selection widget.
106 */
107 CDKSELECTION *newCDKSelection (
108 CDKSCREEN * /* cdkscreen */,
109 int /* xpos */,
110 int /* ypos */,
111 int /* spos */,
112 int /* height */,
113 int /* width */,
114 char * /* title */,
115 char ** /* list */,
116 int /* listSize */,
117 char ** /* choices */,
118 int /* choiceSize */,
119 chtype /* highlight */,
120 boolean /* Box */,
121 boolean /* shadow */);
122
123 /*
124 * This activates the selection widget.
125 */
126 int activateCDKSelection (
127 CDKSELECTION * /* selection */,
128 chtype * /* actions */);
129
130 /*
131 * This injects a single character into the widget.
132 */
133 #define injectCDKSelection(obj,input) injectCDKObject(obj,input,Int)
134
135 /*
136 * This draws the selection widget.
137 */
138 #define drawCDKSelection(obj,Box) drawCDKObject(obj,Box)
139
140 /*
141 * This erases the selection widget from the screen.
142 */
143 #define eraseCDKSelection(obj) eraseCDKObject(obj)
144
145 /*
146 * This moves the widget to the given location.
147 */
148 #define moveCDKSelection(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
149
150 /*
151 * This interactively moves the widget on the screen.
152 */
153 #define positionCDKSelection(widget) positionCDKObject(ObjOf(widget),widget->win)
154
155 /*
156 * This destroys the widget and all associated memory.
157 */
158 #define destroyCDKSelection(obj) destroyCDKObject(obj)
159
160 /*
161 * This sets various attributes of the selection widget.
162 */
163 void setCDKSelection (
164 CDKSELECTION * /* selection */,
165 chtype /* highlight */,
166 int * /* defChoices */,
167 boolean /* Box */);
168
169 /*
170 * This sets the contents of the selection list.
171 */
172 void setCDKSelectionItems (
173 CDKSELECTION * /* selection */,
174 char ** /* list */,
175 int /* listSize */);
176
177 int getCDKSelectionItems (
178 CDKSELECTION * /* selection */,
179 char ** /* list */);
180
181 /*
182 *
183 */
184 void setCDKSelectionTitle (
185 CDKSELECTION * /* selection */,
186 char * /* title */);
187
188 char *getCDKSelectionTitle (
189 CDKSELECTION * /* selection */);
190
191 /*
192 * This sets the selection list highlight bar.
193 */
194 void setCDKSelectionHighlight (
195 CDKSELECTION * /* selection */,
196 chtype /* highlight */);
197
198 chtype getCDKSelectionHighlight (
199 CDKSELECTION * /* selection */);
200
201 /*
202 * set/get the current item index
203 */
204 void setCDKSelectionCurrent (
205 CDKSELECTION * /* selection */,
206 int /* index */);
207
208 int getCDKSelectionCurrent (
209 CDKSELECTION * /* selection */);
210
211 /*
212 * This sets the choices of the selection list.
213 */
214 void setCDKSelectionChoices (
215 CDKSELECTION * /* selection */,
216 int * /* choices */);
217
218 int *getCDKSelectionChoices (
219 CDKSELECTION * /* selection */);
220
221 void setCDKSelectionChoice (
222 CDKSELECTION * /* selection */,
223 int /* index */,
224 int /* choice */);
225
226 int getCDKSelectionChoice (
227 CDKSELECTION * /* selection */,
228 int /* index */);
229
230 /*
231 * This sets the modes of the items in the selection list. Currently
232 * there are only two: editable=0 and read-only=1
233 */
234 void setCDKSelectionModes (
235 CDKSELECTION * /* selection */,
236 int * /* modes */);
237
238 int *getCDKSelectionModes (
239 CDKSELECTION * /* selection */);
240
241 void setCDKSelectionMode (
242 CDKSELECTION * /* selection */,
243 int /* index */,
244 int /* mode */);
245
246 int getCDKSelectionMode (
247 CDKSELECTION * /* selection */,
248 int /* index */);
249
250 /*
251 * This sets the box attribute of the widget.
252 */
253 void setCDKSelectionBox (
254 CDKSELECTION * /* selection */,
255 boolean /* Box */);
256
257 boolean getCDKSelectionBox (
258 CDKSELECTION * /* selection */);
259
260 /*
261 * These set the drawing characters of the widget.
262 */
263 #define setCDKSelectionULChar(w,c) setULCharOf(w,c)
264 #define setCDKSelectionURChar(w,c) setURCharOf(w,c)
265 #define setCDKSelectionLLChar(w,c) setLLCharOf(w,c)
266 #define setCDKSelectionLRChar(w,c) setLRCharOf(w,c)
267 #define setCDKSelectionVerticalChar(w,c) setVTCharOf(w,c)
268 #define setCDKSelectionHorizontalChar(w,c) setHZCharOf(w,c)
269 #define setCDKSelectionBoxAttribute(w,c) setBXAttrOf(w,c)
270
271 /*
272 * This sets the background color of the widget.
273 */
274 #define setCDKSelectionBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
275
276 /*
277 * This sets the background attribute of the widget.
278 */
279 #define setCDKSelectionBackgroundAttrib(w,c) setBKAttrOf(w,c)
280
281 /*
282 * These set the pre/post process callback functions.
283 */
284 #define setCDKSelectionPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
285 #define setCDKSelectionPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
286
287 #ifdef __cplusplus
288 }
289 #endif
290
291 #endif /* CDKSELECTION_H */
292 #endif /* CDKINCLUDES */
0 /*
1 * $Id: swindow.h,v 1.23 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKSWINDOW_H
6 #define CDKSWINDOW_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2003 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Define the CDK scrolling window widget structure.
58 */
59 struct SSwindow {
60 CDKOBJS obj;
61 WINDOW * parent;
62 WINDOW * win;
63 WINDOW * fieldWin;
64 WINDOW * shadowWin;
65 chtype ** list;
66 int * listPos;
67 int * listLen;
68 int titleAdj;
69 int listSize;
70 int boxHeight;
71 int boxWidth;
72 int viewSize;
73 int maxTopLine;
74 int currentTop;
75 int leftChar;
76 int maxLeftChar;
77 int widestLine;
78 int saveLines;
79 EExitType exitType;
80 boolean shadow;
81 };
82 typedef struct SSwindow CDKSWINDOW;
83 typedef void (*SWINDOWCB) (CDKSWINDOW *swindow, chtype input);
84
85 /*
86 * This creates a new pointer to a scrolling window widget.
87 */
88 CDKSWINDOW *newCDKSwindow (
89 CDKSCREEN * /* cdkscreen */,
90 int /* xpos */,
91 int /* ypos */,
92 int /* height */,
93 int /* width */,
94 char * /* title */,
95 int /* saveLines */,
96 boolean /* Box */,
97 boolean /* shadow */);
98
99 /*
100 * This activates the scrolling window.
101 */
102 void activateCDKSwindow (
103 CDKSWINDOW * /* swindow */,
104 chtype * /* actions */);
105
106 /*
107 * This injects a single character into the scrolling window.
108 */
109 #define injectCDKSwindow(obj,input) injectCDKObject(obj,input,Int)
110
111 /*
112 * This executes the given command and puts the output of the
113 * command into the scrolling window.
114 */
115 int execCDKSwindow (
116 CDKSWINDOW * /* swindow */,
117 char * /* command */,
118 int /* insertPos */);
119
120 /*
121 * This dumps the contents of the scrolling window to the given filename.
122 */
123 int dumpCDKSwindow (
124 CDKSWINDOW * /* swindow */,
125 char * /* filename */);
126
127 /*
128 * This jumps to the given line in the window.
129 */
130 void jumpToLineCDKSwindow (
131 CDKSWINDOW * /* swindow */,
132 int /* line */);
133
134 /*
135 * This saves the contents of the scrolling window via an
136 * interactive window.
137 */
138 void saveCDKSwindowInformation (
139 CDKSWINDOW * /* swindow */);
140
141 /*
142 * This loads the window up with information from a filename
143 * interactively provided.
144 */
145 void loadCDKSwindowInformation (
146 CDKSWINDOW * /* swindow */);
147
148 /*
149 * These functions set the attributes of the scrolling window.
150 */
151 void setCDKSwindow (
152 CDKSWINDOW * /* swindow */,
153 char ** /* info */,
154 int /* lines */,
155 boolean /* Box */);
156
157 /*
158 * This sets the contents of the scrolling window.
159 */
160 void setCDKSwindowContents (
161 CDKSWINDOW * /* swindow */,
162 char ** /* info */,
163 int /* lines */);
164
165 chtype **getCDKSwindowContents (
166 CDKSWINDOW * /* swindow */,
167 int * /* size */);
168
169 /*
170 * This sets the box attribute of the scrolling window.
171 */
172 void setCDKSwindowBox (
173 CDKSWINDOW * /* swindow */,
174 boolean /* Box */);
175
176 boolean getCDKSwindowBox (
177 CDKSWINDOW * /* swindow */);
178
179 /*
180 * These set the drawing characters of the widget.
181 */
182 #define setCDKSwindowULChar(w,c) setULCharOf(w,c)
183 #define setCDKSwindowURChar(w,c) setURCharOf(w,c)
184 #define setCDKSwindowLLChar(w,c) setLLCharOf(w,c)
185 #define setCDKSwindowLRChar(w,c) setLRCharOf(w,c)
186 #define setCDKSwindowVerticalChar(w,c) setVTCharOf(w,c)
187 #define setCDKSwindowHorizontalChar(w,c) setHZCharOf(w,c)
188 #define setCDKSwindowBoxAttribute(w,c) setBXAttrOf(w,c)
189
190 /*
191 * This sets the background color of the widget.
192 */
193 #define setCDKSwindowBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
194
195 /*
196 * This sets the background attribute of the widget.
197 */
198 #define setCDKSwindowBackgroundAttrib(w,c) setBKAttrOf(w,c)
199
200 /*
201 * This draws the scrolling window on the screen.
202 */
203 #define drawCDKSwindow(obj,Box) drawCDKObject(obj,Box)
204
205 /*
206 * This removes the widget from the screen.
207 */
208 #define eraseCDKSwindow(obj) eraseCDKObject(obj)
209
210 /*
211 * This cleans out all of the information from the window.
212 */
213 void cleanCDKSwindow (
214 CDKSWINDOW * /* swindow */);
215
216 /*
217 * This adds a line to the window.
218 */
219 void addCDKSwindow (
220 CDKSWINDOW * /* swindow */,
221 char * /* info */,
222 int /* insertPos */);
223
224 /*
225 * This trims lines from the window.
226 */
227 void trimCDKSwindow (
228 CDKSWINDOW * /* swindow */,
229 int /* start */,
230 int /* finish */);
231
232 /*
233 * This moves the window to the given location.
234 */
235 #define moveCDKSwindow(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
236
237 /*
238 * This interactively positions the widget on the screen.
239 */
240 #define positionCDKSwindow(widget) positionCDKObject(ObjOf(widget),widget->win)
241
242 /*
243 * This destroys the widget and all associated memory.
244 */
245 #define destroyCDKSwindow(obj) destroyCDKObject(obj)
246
247 /*
248 * These set the pre/post process callback functions.
249 */
250 #define setCDKSwindowPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
251 #define setCDKSwindowPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
252
253 #ifdef __cplusplus
254 }
255 #endif
256
257 #endif /* CDKSWINDOW_H */
258 #endif /* CDKINCLUDES */
0 /*
1 * $Id: template.h,v 1.23 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKTEMPLATE_H
6 #define CDKTEMPLATE_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2002,2003 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Define the CDK cdktemplate widget structure.
58 */
59 typedef struct STemplate CDKTEMPLATE;
60 typedef void (*TEMPLATECB) (CDKTEMPLATE *cdktemplate, chtype input);
61
62 struct STemplate {
63 CDKOBJS obj;
64 WINDOW * parent;
65 WINDOW * win;
66 WINDOW * shadowWin;
67 WINDOW * labelWin;
68 WINDOW * fieldWin;
69 int titleAdj;
70 chtype * label;
71 chtype * overlay;
72 chtype overlayAttr;
73 char * plate;
74 char * info;
75 int labelLen;
76 int overlayLen;
77 int labelPos;
78 int fieldWidth;
79 int boxWidth;
80 int boxHeight;
81 int platePos;
82 int plateLen;
83 int screenPos;
84 int infoPos;
85 int min;
86 chtype labelAttr;
87 chtype fieldAttr;
88 EExitType exitType;
89 boolean shadow;
90 TEMPLATECB callbackfn;
91 };
92
93 /*
94 * This creates a pointer to a new CDK cdktemplate widget.
95 */
96 CDKTEMPLATE *newCDKTemplate (
97 CDKSCREEN * /* cdkscreen */,
98 int /* xpos */,
99 int /* ypos */,
100 char * /* title */,
101 char * /* label */,
102 char * /* plate */,
103 char * /* overlay */,
104 boolean /* Box */,
105 boolean /* shadow */);
106
107 /*
108 * This activates the cdktemplate widget.
109 */
110 char *activateCDKTemplate (
111 CDKTEMPLATE * /* cdktemplate */,
112 chtype * /* actions */);
113
114 /*
115 * This injects a single character into the widget.
116 */
117 #define injectCDKTemplate(obj,input) injectCDKObject(obj,input,String)
118
119 /*
120 * This sets various attributes of the widget.
121 */
122 void setCDKTemplate (
123 CDKTEMPLATE * /* cdktemplate */,
124 char * /* value */,
125 boolean /* Box */);
126
127 /*
128 * This sets the value in the cdktemplate widget.
129 */
130 void setCDKTemplateValue (
131 CDKTEMPLATE * /* cdktemplate */,
132 char * /* value */);
133
134 char *getCDKTemplateValue (
135 CDKTEMPLATE * /* cdktemplate */);
136
137 /*
138 * This sets the minimum number of characters to enter.
139 */
140 void setCDKTemplateMin (
141 CDKTEMPLATE * /* cdktemplate */,
142 int /* min */);
143
144 int getCDKTemplateMin (
145 CDKTEMPLATE * /* cdktemplate */);
146
147 /*
148 * This sets the box attribute of the widget.
149 */
150 void setCDKTemplateBox (
151 CDKTEMPLATE * /* cdktemplate */,
152 boolean /* Box */);
153
154 boolean getCDKTemplateBox (
155 CDKTEMPLATE * /* cdktemplate */);
156
157 /*
158 * These set the drawing characters of the widget.
159 */
160 #define setCDKTemplateULChar(w,c) setULCharOf(w,c)
161 #define setCDKTemplateURChar(w,c) setURCharOf(w,c)
162 #define setCDKTemplateLLChar(w,c) setLLCharOf(w,c)
163 #define setCDKTemplateLRChar(w,c) setLRCharOf(w,c)
164 #define setCDKTemplateVerticalChar(w,c) setVTCharOf(w,c)
165 #define setCDKTemplateHorizontalChar(w,c) setHZCharOf(w,c)
166 #define setCDKTemplateBoxAttribute(w,c) setBXAttrOf(w,c)
167
168 /*
169 * This sets the background color of the widget.
170 */
171 #define setCDKTemplateBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
172
173 /*
174 * This sets the background attribute of the widget.
175 */
176 #define setCDKTemplateBackgroundAttrib(w,c) setBKAttrOf(w,c)
177
178 /*
179 * This draws the cdktemplate on the screen.
180 */
181 #define drawCDKTemplate(obj,Box) drawCDKObject(obj,Box)
182
183 /*
184 * This erases the widget from the screen.
185 */
186 #define eraseCDKTemplate(obj) eraseCDKObject(obj)
187
188 /*
189 * This erases the cdktemplates contents.
190 */
191 void cleanCDKTemplate (
192 CDKTEMPLATE * /* cdktemplate */);
193
194 /*
195 * This moves the widget to the given location on the screen.
196 */
197 #define moveCDKTemplate(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
198
199 /*
200 * This interactively positions the widget on the screen.
201 */
202 #define positionCDKTemplate(widget) positionCDKObject(ObjOf(widget),widget->win)
203
204 /*
205 * This destroys the widget and all associated memory.
206 */
207 #define destroyCDKTemplate(obj) destroyCDKObject(obj)
208
209 /*
210 * This sets the main callback function.
211 */
212 void setCDKTemplateCB (
213 CDKTEMPLATE * /* cdktemplate */,
214 TEMPLATECB /* callback */);
215
216 /*
217 * This returns a character pointer to the contents of the cdktemplate
218 * mixed with the plate.
219 */
220 char *mixCDKTemplate (
221 CDKTEMPLATE * /* cdktemplate */);
222
223 /*
224 * This returns a character pointer to the cdktemplate with the plate
225 * stripped out.
226 */
227 char *unmixCDKTemplate (
228 CDKTEMPLATE * /* cdktemplate */,
229 char * /* string */);
230
231 /*
232 * These set the pre/post callback functions.
233 */
234 #define setCDKTemplatePreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d)
235 #define setCDKTemplatePostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
236
237 #ifdef __cplusplus
238 }
239 #endif
240
241 #endif /* CDKTEMPLATE_H */
242 #endif /* CDKINCLUDES */
0 /*
1 * $Id: traverse.h,v 1.9 2005/12/30 01:09:09 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKTRAVERSE_H
6 #define CDKTRAVERSE_H 1
7
8 #include "cdk.h"
9
10 #ifndef CDK_H
11 #define CDKINCLUDES
12 #include <cdk.h>
13 #undef CDKINCLUDES
14 #include <binding.h>
15 #include <cdkscreen.h>
16 #include <cdk_objs.h>
17 #endif
18
19 /*
20 * Copyright 1999-2004,2005 Thomas E. Dickey
21 * All rights reserved.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the above copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgment:
33 * This product includes software developed by Thomas Dickey
34 * and contributors.
35 * 4. Neither the name of Thomas Dickey, nor the names of contributors
36 * may be used to endorse or promote products derived from this software
37 * without specific prior written permission.
38 *
39 * THIS SOFTWARE IS PROVIDED BY THOMAS DICKEY AND CONTRIBUTORS ``AS IS'' AND
40 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
42 * ARE DISCLAIMED. IN NO EVENT SHALL THOMAS DICKEY OR CONTRIBUTORS BE LIABLE
43 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
44 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
45 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
48 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49 * SUCH DAMAGE.
50 */
51
52 typedef boolean (*CHECK_KEYCODE)(int /* keyCode */, int /* functionKey */);
53
54 extern CDKOBJS *getCDKFocusCurrent (CDKSCREEN * /* screen */);
55 extern CDKOBJS *setCDKFocusCurrent (CDKSCREEN * /*screen */, CDKOBJS * /* obj */);
56 extern CDKOBJS *setCDKFocusNext (CDKSCREEN * /* screen */);
57 extern CDKOBJS *setCDKFocusPrevious (CDKSCREEN * /* screen */);
58 extern CDKOBJS *setCDKFocusFirst (CDKSCREEN * /* screen */);
59 extern CDKOBJS *setCDKFocusLast (CDKSCREEN * /* screen */);
60
61 extern int traverseCDKScreen (CDKSCREEN * /* screen */);
62
63 extern void exitCancelCDKScreen (CDKSCREEN * /* screen */);
64 extern void exitCancelCDKScreenOf (CDKOBJS * /* obj */);
65 extern void exitOKCDKScreen (CDKSCREEN * /* screen */);
66 extern void exitOKCDKScreenOf (CDKOBJS * /* obj */);
67 extern void resetCDKScreen (CDKSCREEN * /* screen */);
68 extern void resetCDKScreenOf (CDKOBJS * /* obj */);
69 extern void traverseCDKOnce (CDKSCREEN * /*screen */, CDKOBJS * /*curobj */, int /* keyCode */, boolean /* functionKey */, CHECK_KEYCODE /*funcMenuKey */);
70
71 #endif /* CDKTRAVERSE_H */
72 #endif /* CDKINCLUDES */
0 /*
1 * $Id: viewer.h,v 1.21 2004/08/30 00:00:57 tom Exp $
2 */
3
4 #ifndef CDKINCLUDES
5 #ifndef CDKVIEWER_H
6 #define CDKVIEWER_H 1
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef CDK_H
13 #define CDKINCLUDES
14 #include <cdk.h>
15 #undef CDKINCLUDES
16 #include <binding.h>
17 #include <cdkscreen.h>
18 #include <cdk_objs.h>
19 #endif
20
21 /*
22 * Changes 1999-2003 copyright Thomas E. Dickey
23 *
24 * Copyright 1999, Mike Glover
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgment:
37 * This product includes software developed by Mike Glover
38 * and contributors.
39 * 4. Neither the name of Mike Glover, nor the names of contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 */
55
56 /*
57 * Define the CDK viewer widget structure.
58 */
59 struct SViewer {
60 CDKOBJS obj;
61 WINDOW * parent;
62 WINDOW * win;
63 WINDOW * shadowWin;
64 chtype ** button;
65 int * buttonLen;
66 int * buttonPos;
67 int buttonCount;
68 chtype buttonHighlight;
69 chtype ** list;
70 int * listLen;
71 int * listPos;
72 int titleAdj;
73 int listSize;
74 int boxHeight;
75 int boxWidth;
76 int viewSize;
77 int currentTop;
78 int currentButton;
79 int leftChar;
80 int length;
81 int maxLeftChar;
82 int maxTopLine;
83 int widestLine;
84 long characters;
85 boolean inProgress;
86 boolean showLineInfo;
87 boolean interpret;
88 EExitType exitType;
89 boolean shadow;
90 };
91 typedef struct SViewer CDKVIEWER;
92
93 /*
94 * This creates a pointer to a new CDK viewer widget.
95 */
96 CDKVIEWER *newCDKViewer (
97 CDKSCREEN * /* cdkscreen */,
98 int /* xpos */,
99 int /* ypos */,
100 int /* height */,
101 int /* width */,
102 char ** /* buttons */,
103 int /* buttonCount */,
104 chtype /* buttonHighlight */,
105 boolean /* Box */,
106 boolean /* shadow */);
107
108 /*
109 * This activates the viewer widget.
110 */
111 int activateCDKViewer (
112 CDKVIEWER * /* viewer */,
113 chtype * /* actions */);
114
115 /*
116 * This sets various attributes of the viewer widget.
117 */
118 int setCDKViewer (
119 CDKVIEWER * /* viewer */,
120 char * /* title */,
121 char ** /* info */,
122 int /* infoSize */,
123 chtype /* buttonHighlight */,
124 boolean /* interpret */,
125 boolean /* showLineInfo */,
126 boolean /* Box */);
127
128 /*
129 * This sets the contents of the viewer widget.
130 */
131 int setCDKViewerInfo (
132 CDKVIEWER * /* viewer */,
133 char ** /* info */,
134 int /* infoSize */,
135 boolean /* interpret */);
136
137 chtype **getCDKViewerInfo (
138 CDKVIEWER * /* viewer */,
139 int * /* size */);
140
141 /*
142 * This sets the title of the viewer widget.
143 */
144 void setCDKViewerTitle (
145 CDKVIEWER * /* viewer */,
146 char * /* title */);
147
148 chtype **getCDKViewerTitle (
149 CDKVIEWER * /* viewer */);
150
151 /*
152 * This sets the highlight bar attribute.
153 */
154 void setCDKViewerHighlight (
155 CDKVIEWER * /* viewer */,
156 chtype /* buttonHighlight */);
157
158 chtype getCDKViewerHighlight (
159 CDKVIEWER * /* viewer */);
160
161 /*
162 * This sets the boolean flag dictating whether a information line
163 * will be displayed in the top left corner of the viewer.
164 */
165 void setCDKViewerInfoLine (
166 CDKVIEWER * /* viewer */,
167 boolean /* showLineInfo */);
168
169 boolean getCDKViewerInfoLine (
170 CDKVIEWER * /* viewer */);
171
172 /*
173 * This sets the box attribute of the widget.
174 */
175 void setCDKViewerBox (
176 CDKVIEWER * /* viewer */,
177 boolean /* Box */);
178
179 boolean getCDKViewerBox (
180 CDKVIEWER * /* viewer */);
181
182 /*
183 * These set the drawing characters of the widget.
184 */
185 #define setCDKViewerULChar(w,c) setULCharOf(w,c)
186 #define setCDKViewerURChar(w,c) setURCharOf(w,c)
187 #define setCDKViewerLLChar(w,c) setLLCharOf(w,c)
188 #define setCDKViewerLRChar(w,c) setLRCharOf(w,c)
189 #define setCDKViewerVerticalChar(w,c) setVTCharOf(w,c)
190 #define setCDKViewerHorizontalChar(w,c) setHZCharOf(w,c)
191 #define setCDKViewerBoxAttribute(w,c) setBXAttrOf(w,c)
192
193 /*
194 * This sets the background color of the widget.
195 */
196 #define setCDKViewerBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
197
198 /*
199 * This sets the background attribute of the widget.
200 */
201 #define setCDKViewerBackgroundAttrib(w,c) setBKAttrOf(w,c)
202
203 /*
204 * This draws the viewer field on the screen.
205 */
206 #define drawCDKViewer(obj,box) drawCDKObject(obj,box)
207
208 /*
209 * This erases the widget from the screen.
210 */
211 #define eraseCDKViewer(obj) eraseCDKObject(obj)
212
213 /*
214 * This cleans out all of the information from the viewer.
215 */
216 void cleanCDKViewer (
217 CDKVIEWER * /* viewer */);
218
219 /*
220 * This moves the widget to the given location.
221 */
222 #define moveCDKViewer(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
223
224 /*
225 * This is an interactive method of moving the widget.
226 */
227 #define positionCDKViewer(widget) positionCDKObject(ObjOf(widget),widget->win)
228
229 /*
230 * This destroys the widget and all the memory associated with the widget.
231 */
232 #define destroyCDKViewer(obj) destroyCDKObject(obj)
233
234 #ifdef __cplusplus
235 }
236 #endif
237
238 #endif /* CDKVIEWER_H */
239 #endif /* CDKINCLUDES */
0 #! /bin/sh
1 #
2 # install - install a program, script, or datafile
3 # This comes from X11R5 (mit/util/scripts/install.sh).
4 #
5 # Copyright 1991 by the Massachusetts Institute of Technology
6 #
7 # Permission to use, copy, modify, distribute, and sell this software and its
8 # documentation for any purpose is hereby granted without fee, provided that
9 # the above copyright notice appear in all copies and that both that
10 # copyright notice and this permission notice appear in supporting
11 # documentation, and that the name of M.I.T. not be used in advertising or
12 # publicity pertaining to distribution of the software without specific,
13 # written prior permission. M.I.T. makes no representations about the
14 # suitability of this software for any purpose. It is provided "as is"
15 # without express or implied warranty.
16 #
17 # Calling this script install-sh is preferred over install.sh, to prevent
18 # `make' implicit rules from creating a file called install from it
19 # when there is no Makefile.
20 #
21 # This script is compatible with the BSD install script, but was written
22 # from scratch. It can only install one file at a time, a restriction
23 # shared with many OS's install programs.
24
25
26 # set DOITPROG to echo to test this script
27
28 # Don't use :- since 4.3BSD and earlier shells don't like it.
29 doit="${DOITPROG-}"
30
31
32 # put in absolute paths if you don't have them in your path; or use env. vars.
33
34 mvprog="${MVPROG-mv}"
35 cpprog="${CPPROG-cp}"
36 chmodprog="${CHMODPROG-chmod}"
37 chownprog="${CHOWNPROG-chown}"
38 chgrpprog="${CHGRPPROG-chgrp}"
39 stripprog="${STRIPPROG-strip}"
40 rmprog="${RMPROG-rm}"
41 mkdirprog="${MKDIRPROG-mkdir}"
42
43 transformbasename=""
44 transform_arg=""
45 instcmd="$mvprog"
46 chmodcmd="$chmodprog 0755"
47 chowncmd=""
48 chgrpcmd=""
49 stripcmd=""
50 rmcmd="$rmprog -f"
51 mvcmd="$mvprog"
52 src=""
53 dst=""
54 dir_arg=""
55
56 while [ x"$1" != x ]; do
57 case $1 in
58 -c) instcmd="$cpprog"
59 shift
60 continue;;
61
62 -d) dir_arg=true
63 shift
64 continue;;
65
66 -m) chmodcmd="$chmodprog $2"
67 shift
68 shift
69 continue;;
70
71 -o) chowncmd="$chownprog $2"
72 shift
73 shift
74 continue;;
75
76 -g) chgrpcmd="$chgrpprog $2"
77 shift
78 shift
79 continue;;
80
81 -s) stripcmd="$stripprog"
82 shift
83 continue;;
84
85 -t=*) transformarg=`echo $1 | sed 's/-t=//'`
86 shift
87 continue;;
88
89 -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
90 shift
91 continue;;
92
93 *) if [ x"$src" = x ]
94 then
95 src=$1
96 else
97 # this colon is to work around a 386BSD /bin/sh bug
98 :
99 dst=$1
100 fi
101 shift
102 continue;;
103 esac
104 done
105
106 if [ x"$src" = x ]
107 then
108 echo "install: no input file specified"
109 exit 1
110 else
111 :
112 fi
113
114 if [ x"$dir_arg" != x ]; then
115 dst=$src
116 src=""
117
118 if [ -d $dst ]; then
119 instcmd=:
120 chmodcmd=""
121 else
122 instcmd=$mkdirprog
123 fi
124 else
125
126 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
127 # might cause directories to be created, which would be especially bad
128 # if $src (and thus $dsttmp) contains '*'.
129
130 if [ -f $src -o -d $src ]
131 then
132 :
133 else
134 echo "install: $src does not exist"
135 exit 1
136 fi
137
138 if [ x"$dst" = x ]
139 then
140 echo "install: no destination specified"
141 exit 1
142 else
143 :
144 fi
145
146 # If destination is a directory, append the input filename; if your system
147 # does not like double slashes in filenames, you may need to add some logic
148
149 if [ -d $dst ]
150 then
151 dst="$dst"/`basename $src`
152 else
153 :
154 fi
155 fi
156
157 ## this sed command emulates the dirname command
158 dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
159
160 # Make sure that the destination directory exists.
161 # this part is taken from Noah Friedman's mkinstalldirs script
162
163 # Skip lots of stat calls in the usual case.
164 if [ ! -d "$dstdir" ]; then
165 defaultIFS='
166 '
167 IFS="${IFS-${defaultIFS}}"
168
169 oIFS="${IFS}"
170 # Some sh's can't handle IFS=/ for some reason.
171 IFS='%'
172 set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
173 IFS="${oIFS}"
174
175 pathcomp=''
176
177 while [ $# -ne 0 ] ; do
178 pathcomp="${pathcomp}${1}"
179 shift
180
181 if [ ! -d "${pathcomp}" ] ;
182 then
183 $mkdirprog "${pathcomp}"
184 else
185 :
186 fi
187
188 pathcomp="${pathcomp}/"
189 done
190 fi
191
192 if [ x"$dir_arg" != x ]
193 then
194 $doit $instcmd $dst &&
195
196 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
197 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
198 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
199 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
200 else
201
202 # If we're going to rename the final executable, determine the name now.
203
204 if [ x"$transformarg" = x ]
205 then
206 dstfile=`basename $dst`
207 else
208 dstfile=`basename $dst $transformbasename |
209 sed $transformarg`$transformbasename
210 fi
211
212 # don't allow the sed command to completely eliminate the filename
213
214 if [ x"$dstfile" = x ]
215 then
216 dstfile=`basename $dst`
217 else
218 :
219 fi
220
221 # Make a temp file name in the proper directory.
222
223 dsttmp=$dstdir/#inst.$$#
224
225 # Move or copy the file name to the temp name
226
227 $doit $instcmd $src $dsttmp &&
228
229 trap "rm -f ${dsttmp}" 0 &&
230
231 # and set any options; do chmod last to preserve setuid bits
232
233 # If any of these fail, we abort the whole thing. If we want to
234 # ignore errors from any of these, just make sure not to ignore
235 # errors from the above "$doit $instcmd $src $dsttmp" command.
236
237 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
238 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
239 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
240 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
241
242 # Now rename the file to the real destination.
243
244 $doit $rmcmd -f $dstdir/$dstfile &&
245 $doit $mvcmd $dsttmp $dstdir/$dstfile
246
247 fi &&
248
249
250 exit 0
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:44 $
5 * $Revision: 1.79 $
6 */
7
8 static int createList (CDKITEMLIST *itemlist, char **item, int count);
9 static int createFieldWin (CDKITEMLIST *itemlist, int ypos, int xpos);
10 static int maximumFieldWidth (CDKITEMLIST *itemlist);
11 static void updateFieldWidth (CDKITEMLIST *itemlist);
12
13 DeclareCDKObjects(ITEMLIST, Itemlist, setCdk, Int);
14
15 /*
16 * This creates a pointer to an itemlist widget.
17 */
18 CDKITEMLIST *newCDKItemlist (CDKSCREEN *cdkscreen, int xplace, int yplace, char *title, char *label, char **item, int count, int defaultItem, boolean Box, boolean shadow)
19 {
20 /* Set up some variables. */
21 CDKITEMLIST *itemlist = 0;
22 int parentWidth = getmaxx(cdkscreen->window);
23 int parentHeight = getmaxy(cdkscreen->window);
24 int boxWidth = 0;
25 int boxHeight;
26 int fieldWidth = 0;
27 int xpos = xplace;
28 int ypos = yplace;
29 int junk;
30
31 if ((itemlist = newCDKObject(CDKITEMLIST, &my_funcs)) == 0
32 || !createList(itemlist, item, count))
33 {
34 destroyCDKObject (itemlist);
35 return (0);
36 }
37
38 setCDKItemlistBox (itemlist, Box);
39 boxHeight = (BorderOf(itemlist) * 2) + 1;
40
41 /* Set some basic values of the itemlist. */
42 itemlist->label = 0;
43 itemlist->labelLen = 0;
44 itemlist->labelWin = 0;
45
46 /* Translate the label char *pointer to a chtype pointer. */
47 if (label != 0)
48 {
49 itemlist->label = char2Chtype (label, &itemlist->labelLen, &junk);
50 }
51
52 /*
53 * Set the box width. Allow an extra char in field width for cursor
54 */
55 fieldWidth = maximumFieldWidth (itemlist) + 1;
56 boxWidth = fieldWidth + itemlist->labelLen + 2 * BorderOf(itemlist);
57
58 boxWidth = setCdkTitle(ObjOf(itemlist), title, boxWidth);
59
60 boxHeight += TitleLinesOf(itemlist);
61
62 /*
63 * Make sure we didn't extend beyond the dimensions of the window.
64 */
65 itemlist->boxWidth = MINIMUM(boxWidth, parentWidth);
66 itemlist->boxHeight = MINIMUM(boxHeight, parentHeight);
67 updateFieldWidth (itemlist);
68
69 /* Rejustify the x and y positions if we need to. */
70 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
71
72 /* Make the window. */
73 itemlist->win = newwin(boxHeight, boxWidth, ypos, xpos);
74 if (itemlist->win == 0)
75 {
76 destroyCDKObject (itemlist);
77 return (0);
78 }
79
80 /* Make the label window if there was a label. */
81 if (itemlist->label != 0)
82 {
83 itemlist->labelWin = subwin (itemlist->win,
84 1,
85 itemlist->labelLen,
86 ypos + BorderOf(itemlist) + TitleLinesOf(itemlist),
87 xpos + BorderOf(itemlist));
88 if (itemlist->labelWin == 0)
89 {
90 destroyCDKObject (itemlist);
91 return (0);
92 }
93 }
94
95 keypad (itemlist->win, TRUE);
96
97 /* Make the field window */
98 if (!createFieldWin (itemlist,
99 ypos + BorderOf(itemlist) + TitleLinesOf(itemlist),
100 xpos + itemlist->labelLen + BorderOf(itemlist)))
101 {
102 destroyCDKObject (itemlist);
103 return (0);
104 }
105
106 /* Set up the rest of the structure. */
107 ScreenOf(itemlist) = cdkscreen;
108 itemlist->parent = cdkscreen->window;
109 itemlist->shadowWin = 0;
110 initExitType(itemlist);
111 ObjOf(itemlist)->acceptsFocus = TRUE;
112 itemlist->shadow = shadow;
113
114 setCDKItemlistBox (itemlist, Box);
115
116 /* Set then default item. */
117 if (defaultItem >= 0 && defaultItem < itemlist->listSize)
118 {
119 itemlist->currentItem = defaultItem;
120 itemlist->defaultItem = defaultItem;
121 }
122 else
123 {
124 itemlist->currentItem = 0;
125 itemlist->defaultItem = 0;
126 }
127
128 /* Do we want a shadow??? */
129 if (shadow)
130 {
131 itemlist->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
132 if (itemlist->shadowWin == 0)
133 {
134 destroyCDKObject (itemlist);
135 return (0);
136 }
137 }
138
139 /* Register this baby. */
140 registerCDKObject (cdkscreen, vITEMLIST, itemlist);
141
142 /* Return the pointer to the structure */
143 return (itemlist);
144 }
145
146 /*
147 * This allows the user to play with the widget.
148 */
149 int activateCDKItemlist (CDKITEMLIST *itemlist, chtype *actions)
150 {
151 /* Declare local variables. */
152 int ret = -1;
153
154 /* Draw the widget. */
155 drawCDKItemlist (itemlist, ObjOf(itemlist)->box);
156 drawCDKItemlistField(itemlist, TRUE);
157
158 if (actions == 0)
159 {
160 chtype input = 0;
161 boolean functionKey;
162
163 for (;;)
164 {
165 input = getchCDKObject (ObjOf(itemlist), &functionKey);
166
167 /* Inject the character into the widget. */
168 ret = injectCDKItemlist (itemlist, input);
169 if (itemlist->exitType != vEARLY_EXIT)
170 {
171 return ret;
172 }
173 }
174 }
175 else
176 {
177 int length = chlen (actions);
178 int x = 0;
179
180 /* Inject each character one at a time. */
181 for (x=0; x < length; x++)
182 {
183 ret = injectCDKItemlist (itemlist, actions[x]);
184 if (itemlist->exitType != vEARLY_EXIT)
185 {
186 return ret;
187 }
188 }
189 }
190
191 /* Set the exit type and exit. */
192 setExitType(itemlist, 0);
193 return ret;
194 }
195
196 /*
197 * This injects a single character into the widget.
198 */
199 static int _injectCDKItemlist (CDKOBJS *object, chtype input)
200 {
201 CDKITEMLIST *itemlist = (CDKITEMLIST *)object;
202 /* Declare local variables. */
203 int ppReturn = 1;
204 int ret = unknownInt;
205 bool complete = FALSE;
206
207 /* Set the exit type. */
208 setExitType(itemlist, 0);
209
210 /* Draw the itemlist field. */
211 drawCDKItemlistField (itemlist,TRUE);
212
213 /* Check if there is a pre-process function to be called. */
214 if (PreProcessFuncOf(itemlist) != 0)
215 {
216 /* Call the pre-process function. */
217 ppReturn = PreProcessFuncOf(itemlist) (vITEMLIST, itemlist, PreProcessDataOf(itemlist), input);
218 }
219
220 /* Should we continue? */
221 if (ppReturn != 0)
222 {
223 /* Check a predefined binding. */
224 if (checkCDKObjectBind (vITEMLIST, itemlist, input) != 0)
225 {
226 checkEarlyExit(itemlist);
227 complete = TRUE;
228 }
229 else
230 {
231 switch (input)
232 {
233 case KEY_UP : case KEY_RIGHT : case SPACE : case '+' : case 'n' :
234 if (itemlist->currentItem < itemlist->listSize - 1)
235 {
236 itemlist->currentItem++;
237 }
238 else
239 {
240 itemlist->currentItem = 0;
241 }
242 break;
243
244 case KEY_DOWN : case KEY_LEFT : case '-' : case 'p' :
245 if (itemlist->currentItem > 0)
246 {
247 itemlist->currentItem--;
248 }
249 else
250 {
251 itemlist->currentItem = itemlist->listSize - 1;
252 }
253 break;
254
255 case 'd' : case 'D' :
256 itemlist->currentItem = itemlist->defaultItem;
257 break;
258
259 case '0' :
260 itemlist->currentItem = 0;
261 break;
262
263 case '$' :
264 itemlist->currentItem = itemlist->listSize - 1;
265 break;
266
267 case KEY_ESC :
268 setExitType(itemlist, input);
269 complete = TRUE;
270 break;
271
272 case KEY_TAB : case KEY_ENTER :
273 setExitType(itemlist, input);
274 ret = itemlist->currentItem;
275 complete = TRUE;
276 break;
277
278 case CDK_REFRESH :
279 eraseCDKScreen (ScreenOf(itemlist));
280 refreshCDKScreen (ScreenOf(itemlist));
281 break;
282
283 default :
284 Beep();
285 break;
286 }
287 }
288
289 /* Should we call a post-process? */
290 if (!complete && (PostProcessFuncOf(itemlist) != 0))
291 {
292 PostProcessFuncOf(itemlist) (vITEMLIST, itemlist, PostProcessDataOf(itemlist), input);
293 }
294 }
295
296 if (!complete)
297 {
298 drawCDKItemlistField (itemlist,TRUE);
299 setExitType(itemlist, 0);
300 }
301
302 ResultOf(itemlist).valueInt = ret;
303 return (ret != unknownInt);
304 }
305
306 /*
307 * This moves the itemlist field to the given location.
308 */
309 static void _moveCDKItemlist (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag)
310 {
311 CDKITEMLIST *itemlist = (CDKITEMLIST *)object;
312 /* Declare local variables. */
313 int currentX = getbegx(itemlist->win);
314 int currentY = getbegy(itemlist->win);
315 int xpos = xplace;
316 int ypos = yplace;
317 int xdiff = 0;
318 int ydiff = 0;
319
320 /*
321 * If this is a relative move, then we will adjust where we want
322 * to move to.
323 */
324 if (relative)
325 {
326 xpos = getbegx(itemlist->win) + xplace;
327 ypos = getbegy(itemlist->win) + yplace;
328 }
329
330 /* Adjust the window if we need to. */
331 alignxy (WindowOf(itemlist), &xpos, &ypos, itemlist->boxWidth, itemlist->boxHeight);
332
333 /* Get the difference. */
334 xdiff = currentX - xpos;
335 ydiff = currentY - ypos;
336
337 /* Move the window to the new location. */
338 moveCursesWindow(itemlist->win, -xdiff, -ydiff);
339 moveCursesWindow(itemlist->fieldWin, -xdiff, -ydiff);
340 moveCursesWindow(itemlist->labelWin, -xdiff, -ydiff);
341 moveCursesWindow(itemlist->shadowWin, -xdiff, -ydiff);
342
343 /* Touch the windows so they 'move'. */
344 refreshCDKWindow (WindowOf(itemlist));
345
346 /* Redraw the window, if they asked for it. */
347 if (refresh_flag)
348 {
349 drawCDKItemlist (itemlist, ObjOf(itemlist)->box);
350 }
351 }
352
353 /*
354 * This draws the widget on the screen.
355 */
356 static void _drawCDKItemlist (CDKOBJS *object, int Box)
357 {
358 CDKITEMLIST *itemlist = (CDKITEMLIST *)object;
359
360 /* Did we ask for a shadow? */
361 if (itemlist->shadowWin != 0)
362 {
363 drawShadow (itemlist->shadowWin);
364 }
365
366 /* Box the widget if asked. */
367 if (Box)
368 {
369 drawObjBox (itemlist->win, ObjOf(itemlist));
370 }
371
372 drawCdkTitle (itemlist->win, object);
373
374 /* Draw in the label to the widget. */
375 if (itemlist->labelWin != 0)
376 {
377 writeChtype (itemlist->labelWin,
378 0,
379 0,
380 itemlist->label,
381 HORIZONTAL,
382 0,
383 chlen(itemlist->label));
384 }
385
386 wrefresh (itemlist->win);
387
388 /* Draw in the field. */
389 drawCDKItemlistField(itemlist, FALSE);
390 }
391
392 /*
393 * This sets the background attribute of the widget.
394 */
395 static void _setBKattrItemlist (CDKOBJS *object, chtype attrib)
396 {
397 if (object != 0)
398 {
399 CDKITEMLIST *widget = (CDKITEMLIST *) object;
400
401 wbkgd (widget->win, attrib);
402 wbkgd (widget->fieldWin, attrib);
403 if (widget->labelWin != 0)
404 {
405 wbkgd (widget->labelWin, attrib);
406 }
407 }
408 }
409
410 /*
411 * This function draws the contents of the field.
412 */
413 void drawCDKItemlistField (CDKITEMLIST *itemlist, boolean highlight)
414 {
415 /* Declare local vars. */
416 int currentItem = itemlist->currentItem;
417 int len;
418 int x;
419
420 /* Determine how much we have to draw. */
421 len = MINIMUM (itemlist->itemLen[currentItem], itemlist->fieldWidth);
422
423 /* Erase the field window. */
424 werase (itemlist->fieldWin);
425
426 /* Draw in the current item in the field. */
427 for (x=0; x < len; x++)
428 {
429 chtype c = itemlist->item[currentItem][x];
430
431 if (highlight)
432 {
433 c = CharOf(c) | A_REVERSE;
434 }
435
436 mvwaddch (itemlist->fieldWin, 0,
437 x + itemlist->itemPos[currentItem],
438 c);
439 }
440
441 /* Redraw the field window. */
442 wrefresh (itemlist->fieldWin);
443 }
444
445 /*
446 * This function removes the widget from the screen.
447 */
448 static void _eraseCDKItemlist (CDKOBJS *object)
449 {
450 if (validCDKObject (object))
451 {
452 CDKITEMLIST *itemlist = (CDKITEMLIST *)object;
453
454 eraseCursesWindow (itemlist->fieldWin);
455 eraseCursesWindow (itemlist->labelWin);
456 eraseCursesWindow (itemlist->win);
457 eraseCursesWindow (itemlist->shadowWin);
458 }
459 }
460
461 static void destroyInfo (CDKITEMLIST *widget)
462 {
463 widget->listSize = 0;
464
465 CDKfreeChtypes (widget->item);
466 widget->item = 0;
467
468 freeAndNull (widget->itemPos);
469 freeAndNull (widget->itemLen);
470 }
471
472 /*
473 * This function destroys the widget and all the memory it used.
474 */
475 static void _destroyCDKItemlist (CDKOBJS *object)
476 {
477 if (object != 0)
478 {
479 CDKITEMLIST *itemlist = (CDKITEMLIST *)object;
480
481 cleanCdkTitle (object);
482 freeChtype (itemlist->label);
483 destroyInfo (itemlist);
484
485 /* Delete the windows. */
486 deleteCursesWindow (itemlist->fieldWin);
487 deleteCursesWindow (itemlist->labelWin);
488 deleteCursesWindow (itemlist->shadowWin);
489 deleteCursesWindow (itemlist->win);
490
491 /* Clean the key bindings. */
492 cleanCDKObjectBindings (vITEMLIST, itemlist);
493
494 /* Unregister this object. */
495 unregisterCDKObject (vITEMLIST, itemlist);
496 }
497 }
498
499 /*
500 * This sets multiple attributes of the widget.
501 */
502 void setCDKItemlist (CDKITEMLIST *itemlist, char **list, int count, int current, boolean Box)
503 {
504 setCDKItemlistValues (itemlist, list, count, current);
505 setCDKItemlistBox (itemlist, Box);
506 }
507
508 /*
509 * This function sets the contents of the list.
510 */
511 void setCDKItemlistValues (CDKITEMLIST *itemlist, char **item, int count, int defaultItem)
512 {
513 if (createList(itemlist, item, count))
514 {
515 int oldWidth = itemlist->fieldWidth;
516
517 /* Set the default item. */
518 if ((defaultItem >= 0) && (defaultItem < itemlist->listSize))
519 {
520 itemlist->currentItem = defaultItem;
521 itemlist->defaultItem = defaultItem;
522 }
523
524 /*
525 * This will not resize the outer windows but can still make a usable
526 * field width if the title made the outer window wide enough.
527 */
528 updateFieldWidth (itemlist);
529 if (itemlist->fieldWidth > oldWidth)
530 {
531 createFieldWin (itemlist,
532 getbegy(itemlist->fieldWin),
533 getbegx(itemlist->fieldWin));
534 }
535
536 /* Draw the field. */
537 eraseCDKItemlist (itemlist);
538 drawCDKItemlist (itemlist, ObjOf(itemlist)->box);
539 }
540 }
541 chtype **getCDKItemlistValues (CDKITEMLIST *itemlist, int *size)
542 {
543 (*size) = itemlist->listSize;
544 return itemlist->item;
545 }
546
547 /*
548 * This sets the default/current item of the itemlist.
549 */
550 void setCDKItemlistCurrentItem (CDKITEMLIST *itemlist, int currentItem)
551 {
552 /* Set the default item. */
553 if ((currentItem >= 0) && (currentItem < itemlist->listSize))
554 {
555 itemlist->currentItem = currentItem;
556 }
557 }
558 int getCDKItemlistCurrentItem (CDKITEMLIST *itemlist)
559 {
560 return itemlist->currentItem;
561 }
562
563 /*
564 * This sets the default item in the list.
565 */
566 void setCDKItemlistDefaultItem (CDKITEMLIST *itemlist, int defaultItem)
567 {
568 /* Make sure the item is in the correct range. */
569 if (defaultItem < 0)
570 {
571 itemlist->defaultItem = 0;
572 }
573 else if (defaultItem >= itemlist->listSize)
574 {
575 itemlist->defaultItem = itemlist->listSize - 1;
576 }
577 else
578 {
579 itemlist->defaultItem = defaultItem;
580 }
581 }
582 int getCDKItemlistDefaultItem (CDKITEMLIST *itemlist)
583 {
584 return itemlist->defaultItem;
585 }
586
587 /*
588 * This sets the box attribute of the itemlist widget.
589 */
590 void setCDKItemlistBox (CDKITEMLIST *itemlist, boolean Box)
591 {
592 ObjOf(itemlist)->box = Box;
593 ObjOf(itemlist)->borderSize = Box ? 1 : 0;
594 }
595 boolean getCDKItemlistBox (CDKITEMLIST *itemlist)
596 {
597 return ObjOf(itemlist)->box;
598 }
599
600 static void _focusCDKItemlist(CDKOBJS *object)
601 {
602 CDKITEMLIST *itemlist = (CDKITEMLIST *)object;
603
604 drawCDKItemlistField (itemlist,TRUE);
605 }
606
607 static void _unfocusCDKItemlist(CDKOBJS *object)
608 {
609 CDKITEMLIST *itemlist = (CDKITEMLIST *)object;
610
611 drawCDKItemlistField (itemlist,FALSE);
612 }
613
614 #if 0
615 static void _refreshDataCDKItemlist(CDKOBJS *object)
616 {
617 CDKITEMLIST *itemlist = (CDKITEMLIST *)object;
618
619 if (ReturnOf(itemlist))
620 {
621 switch (DataTypeOf(itemlist))
622 {
623 default:
624 case DataTypeInt:
625 itemlist->currentItem = *((int*)ReturnOf(itemlist));
626 break;
627 case DataTypeDouble:
628 itemlist->currentItem = *((double*)ReturnOf(itemlist));
629 break;
630 case DataTypeFloat:
631 itemlist->currentItem = *((float*)ReturnOf(itemlist));
632 break;
633 case DataTypeString:
634 {
635 int i;
636
637 for (i=0; i < itemlist->listSize; ++i)
638 if (!cmpStrChstr((char*)ReturnOf(itemlist),itemlist->item[i]))
639 {
640 itemlist->currentItem = i;
641 break;
642 }
643 itemlist->currentItem = itemlist->defaultItem;
644 break;
645 }
646 }
647 drawCDKItemlistField(itemlist, FALSE);
648 }
649 }
650
651 static void _saveDataCDKItemlist(CDKOBJS *object)
652 {
653 CDKITEMLIST *itemlist = (CDKITEMLIST *)object;
654
655 if (ReturnOf(itemlist))
656 {
657 switch (DataTypeOf(itemlist))
658 {
659 default:
660 case DataTypeInt:
661 *((int*)ReturnOf(itemlist)) = itemlist->currentItem;
662 break;
663 case DataTypeFloat:
664 *((float*)ReturnOf(itemlist)) = itemlist->currentItem;
665 break;
666 case DataTypeDouble:
667 *((double*)ReturnOf(itemlist)) = itemlist->currentItem;
668 break;
669 case DataTypeString:
670 chstrncpy((char*)ReturnOf(itemlist), itemlist->item[itemlist->currentItem], 9999);
671 break;
672 }
673 }
674 }
675 #else
676 dummyRefreshData(Itemlist)
677 dummySaveData(Itemlist)
678 #endif
679
680 static int createList (CDKITEMLIST *itemlist, char **item, int count)
681 {
682 int status = 0;
683
684 if (count > 0)
685 {
686 chtype **newItems = typeCallocN(chtype*, count + 1);
687 int *newPos = typeCallocN(int, count + 1);
688 int *newLen = typeCallocN(int, count + 1);
689 int x;
690 int fieldWidth = 0;
691
692 if (newItems != 0
693 && newPos != 0
694 && newLen != 0)
695 {
696 /* Go through the list and determine the widest item. */
697 status = 1;
698 for (x=0; x < count; x++)
699 {
700 /* Copy the item to the list. */
701 newItems[x] = char2Chtype (item[x], &newLen[x], &newPos[x]);
702 if (newItems[x] == 0)
703 {
704 status = 0;
705 break;
706 }
707 fieldWidth = MAXIMUM (fieldWidth, newLen[x]);
708 }
709
710 /* Now we need to justify the strings. */
711 for (x=0; x < count; x++)
712 {
713 newPos[x] = justifyString (fieldWidth + 1, newLen[x], newPos[x]);
714 }
715 }
716
717 if (status)
718 {
719 destroyInfo (itemlist);
720
721 /* Copy in the new information. */
722 itemlist->listSize = count;
723 itemlist->item = newItems;
724 itemlist->itemPos = newPos;
725 itemlist->itemLen = newLen;
726 }
727 else
728 {
729 CDKfreeChtypes (newItems);
730 freeChecked (newPos);
731 freeChecked (newLen);
732 }
733 }
734 else
735 {
736 destroyInfo (itemlist);
737 status = TRUE;
738 }
739
740 return status;
741 }
742
743 /* Go through the list and determine the widest item. */
744 static int maximumFieldWidth (CDKITEMLIST *itemlist)
745 {
746 int x;
747 int maxWidth = INT_MIN;
748
749 for (x=0; x < itemlist->listSize; x++)
750 {
751 maxWidth = MAXIMUM (maxWidth, itemlist->itemLen[x]);
752 }
753 maxWidth = MAXIMUM (maxWidth, 0);
754
755 return maxWidth;
756 }
757
758 static void updateFieldWidth (CDKITEMLIST *itemlist)
759 {
760 int want = maximumFieldWidth (itemlist) + 1;
761 int have = itemlist->boxWidth - itemlist->labelLen - 2 * BorderOf(itemlist);
762 itemlist->fieldWidth = MINIMUM(want, have);
763 }
764
765 /* Make the field window */
766 static int createFieldWin (CDKITEMLIST *itemlist, int ypos, int xpos)
767 {
768 itemlist->fieldWin = subwin (itemlist->win,
769 1,
770 itemlist->fieldWidth,
771 ypos,
772 xpos);
773 if (itemlist->fieldWin != 0)
774 {
775 keypad (itemlist->fieldWin, TRUE);
776 ObjOf(itemlist)->inputWindow = itemlist->fieldWin;
777 return 1;
778 }
779 return 0;
780 }
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:44 $
5 * $Revision: 1.84 $
6 */
7
8 DeclareCDKObjects(LABEL, Label, setCdk, Unknown);
9
10 /*
11 * This creates a label widget.
12 */
13 CDKLABEL *newCDKLabel(CDKSCREEN *cdkscreen, int xplace, int yplace, char **mesg, int rows, boolean Box, boolean shadow)
14 {
15 /* Maintain the label information. */
16 CDKLABEL *label = 0;
17 int parentWidth = getmaxx(cdkscreen->window);
18 int parentHeight = getmaxy(cdkscreen->window);
19 int boxWidth = INT_MIN;
20 int boxHeight;
21 int xpos = xplace;
22 int ypos = yplace;
23 int x = 0;
24
25 if (rows <= 0
26 || (label = newCDKObject(CDKLABEL, &my_funcs)) == 0
27 || (label->info = typeCallocN(chtype *, rows + 1)) == 0
28 || (label->infoLen = typeCallocN(int, rows + 1)) == 0
29 || (label->infoPos = typeCallocN(int, rows + 1)) == 0)
30 {
31 destroyCDKObject(label);
32 return (0);
33 }
34
35 setCDKLabelBox (label, Box);
36 boxHeight = rows + 2 * BorderOf(label);
37
38 /* Determine the box width. */
39 for (x=0; x < rows; x++)
40 {
41 /* Translate the char * to a chtype. */
42 label->info[x] = char2Chtype (mesg[x], &label->infoLen[x], &label->infoPos[x]);
43 boxWidth = MAXIMUM (boxWidth, label->infoLen[x]);
44 }
45 boxWidth += 2 * BorderOf(label);
46
47 /* Create the string alignments. */
48 for (x=0; x < rows; x++)
49 {
50 label->infoPos[x] = justifyString (boxWidth - 2 * BorderOf(label), label->infoLen[x], label->infoPos[x]);
51 }
52
53 /*
54 * Make sure we didn't extend beyond the dimensions of the window.
55 */
56 boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth);
57 boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight);
58
59 /* Rejustify the x and y positions if we need to. */
60 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
61
62 /* Create the label. */
63 ScreenOf(label) = cdkscreen;
64 label->parent = cdkscreen->window;
65 label->win = newwin (boxHeight, boxWidth, ypos, xpos);
66 label->shadowWin = 0;
67 label->xpos = xpos;
68 label->ypos = ypos;
69 label->rows = rows;
70 label->boxWidth = boxWidth;
71 label->boxHeight = boxHeight;
72 ObjOf(label)->inputWindow = label->win;
73 label->shadow = shadow;
74
75 /* Is the window null? */
76 if (label->win == 0)
77 {
78 destroyCDKObject(label);
79 return (0);
80 }
81 keypad (label->win, TRUE);
82
83 /* If a shadow was requested, then create the shadow window. */
84 if (shadow)
85 {
86 label->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
87 }
88
89 /* Register this baby. */
90 registerCDKObject (cdkscreen, vLABEL, label);
91
92 /* Return the label pointer. */
93 return (label);
94 }
95
96 /*
97 * This was added for the builder.
98 */
99 void activateCDKLabel (CDKLABEL *label, chtype *actions GCC_UNUSED)
100 {
101 drawCDKLabel (label, ObjOf(label)->box);
102 }
103
104 /*
105 * This sets multiple attributes of the widget.
106 */
107 void setCDKLabel (CDKLABEL *label, char **mesg, int lines, boolean Box)
108 {
109 setCDKLabelMessage (label, mesg, lines);
110 setCDKLabelBox (label, Box);
111 }
112
113 /*
114 * This sets the information within the label.
115 */
116 void setCDKLabelMessage (CDKLABEL *label, char **info, int infoSize)
117 {
118 int x;
119
120 /* Clean out the old message. */
121 for (x=0; x < label->rows; x++)
122 {
123 freeChtype (label->info[x]);
124 label->infoPos[x] = 0;
125 label->infoLen[x] = 0;
126 }
127 label->rows = (infoSize < label->rows ? infoSize : label->rows);
128
129 /* Copy in the new message. */
130 for (x=0; x < label->rows; x++)
131 {
132 label->info[x] = char2Chtype (info[x], &label->infoLen[x], &label->infoPos[x]);
133 label->infoPos[x] = justifyString (label->boxWidth - 2 * BorderOf(label), label->infoLen[x], label->infoPos[x]);
134 }
135
136 /* Redraw the label widget. */
137 eraseCDKLabel (label);
138 drawCDKLabel (label, ObjOf(label)->box);
139 }
140 chtype **getCDKLabelMessage (CDKLABEL *label, int *size)
141 {
142 (*size) = label->rows;
143 return label->info;
144 }
145
146 /*
147 * This sets the box flag for the label widget.
148 */
149 void setCDKLabelBox (CDKLABEL *label, boolean Box)
150 {
151 ObjOf(label)->box = Box;
152 ObjOf(label)->borderSize = Box ? 1 : 0;
153 }
154 boolean getCDKLabelBox (CDKLABEL *label)
155 {
156 return ObjOf(label)->box;
157 }
158
159 /*
160 * This sets the background attribute of the widget.
161 */
162 static void _setBKattrLabel (CDKOBJS *object, chtype attrib)
163 {
164 if (object != 0)
165 {
166 CDKLABEL *widget = (CDKLABEL *) object;
167
168 wbkgd (widget->win, attrib);
169 }
170 }
171
172 /*
173 * This draws the label widget.
174 */
175 static void _drawCDKLabel (CDKOBJS *object, boolean Box GCC_UNUSED)
176 {
177 CDKLABEL *label = (CDKLABEL *)object;
178 int x = 0;
179
180 /* Is there a shadow? */
181 if (label->shadowWin != 0)
182 {
183 drawShadow (label->shadowWin);
184 }
185
186 /* Box the widget if asked. */
187 if (ObjOf(label)->box)
188 {
189 drawObjBox (label->win, ObjOf(label));
190 }
191
192 /* Draw in the message. */
193 for (x=0; x < label->rows; x++)
194 {
195 writeChtype (label->win, label->infoPos[x] + BorderOf(label), x + BorderOf(label), label->info[x], HORIZONTAL, 0, label->infoLen[x]);
196 }
197
198 /* Refresh the window. */
199 wrefresh (label->win);
200 }
201
202 /*
203 * This erases the label widget.
204 */
205 static void _eraseCDKLabel (CDKOBJS *object)
206 {
207 if (validCDKObject (object))
208 {
209 CDKLABEL *label = (CDKLABEL *)object;
210
211 eraseCursesWindow (label->win);
212 eraseCursesWindow (label->shadowWin);
213 }
214 }
215
216 /*
217 * This moves the label field to the given location.
218 */
219 static void _moveCDKLabel (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag)
220 {
221 CDKLABEL *label = (CDKLABEL *)object;
222 int currentX = getbegx(label->win);
223 int currentY = getbegy(label->win);
224 int xpos = xplace;
225 int ypos = yplace;
226 int xdiff = 0;
227 int ydiff = 0;
228
229 /*
230 * If this is a relative move, then we will adjust where we want
231 * to move to.
232 */
233 if (relative)
234 {
235 xpos = getbegx(label->win) + xplace;
236 ypos = getbegy(label->win) + yplace;
237 }
238
239 /* Adjust the window if we need to. */
240 alignxy (WindowOf(label), &xpos, &ypos, label->boxWidth, label->boxHeight);
241
242 /* Get the difference. */
243 xdiff = currentX - xpos;
244 ydiff = currentY - ypos;
245
246 /* Move the window to the new location. */
247 moveCursesWindow(label->win, -xdiff, -ydiff);
248 moveCursesWindow(label->shadowWin, -xdiff, -ydiff);
249
250 /* Touch the windows so they 'move'. */
251 refreshCDKWindow (WindowOf(label));
252
253 /* Redraw the window, if they asked for it. */
254 if (refresh_flag)
255 {
256 drawCDKLabel (label, ObjOf(label)->box);
257 }
258 }
259
260 /*
261 * This destroys the label object pointer.
262 */
263 static void _destroyCDKLabel (CDKOBJS *object)
264 {
265 if (object != 0)
266 {
267 CDKLABEL *label = (CDKLABEL *)object;
268
269 CDKfreeChtypes (label->info);
270 freeChecked (label->infoLen);
271 freeChecked (label->infoPos);
272
273 /* Free up the window pointers. */
274 deleteCursesWindow (label->shadowWin);
275 deleteCursesWindow (label->win);
276
277 /* Clean the key bindings. */
278 cleanCDKObjectBindings (vLABEL, label);
279
280 /* Unregister the object. */
281 unregisterCDKObject (vLABEL, label);
282 }
283 }
284
285 /*
286 * This pauses until a user hits a key...
287 */
288 char waitCDKLabel (CDKLABEL *label, char key)
289 {
290 boolean functionKey;
291
292 /* If the key is null, we'll accept anything. */
293 if ( key == 0 )
294 {
295 return (getchCDKObject (ObjOf(label), &functionKey));
296 }
297 else
298 {
299 /* Only exit when a specific key is hit. */
300 int code;
301 for (;;)
302 {
303 code = getchCDKObject(ObjOf(label), &functionKey);
304 if (code == key)
305 {
306 return ( code );
307 }
308 }
309 }
310 }
311
312 dummyInject(Label)
313
314 dummyFocus(Label)
315
316 dummyUnfocus(Label)
317
318 dummyRefreshData(Label)
319
320 dummySaveData(Label)
0 '\" t
1 .\" $Id: cdk.3,v 1.12 2005/12/30 21:57:49 tom Exp $
2 .de It
3 .br
4 .ie \\n(.$>=3 .ne \\$3
5 .el .ne 3
6 .IP "\\$1" \\$2
7 ..
8 .TH Cdk 3
9 .SH NAME
10 cdk - \fBCurses Development Kit\fR
11 .SH SYNOPSIS
12 .LP
13 .B cc
14 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
15 .B \-lcdk
16 .RI "[ " "library" " \|.\|.\|. ]"
17 .LP
18 #include <cdk.h>
19 .LP
20 Cdk provides functions to use a large number of predefined curses widgets.
21 To use the Cdk widgets the header file \fIcdk.h\fR must be included in the source.
22 .LP
23 The widgets available from Cdk are listed below.
24 .LP
25 .TS
26 center tab(/);
27 l l
28 l l .
29 \fBWidget Type/Manual Page Name\fR
30 =
31 Alphalist/cdk_alphalist (3)
32 Button/cdk_button (3)
33 Buttonbox/cdk_buttonbox (3)
34 Calendar/cdk_calendar (3)
35 Dialog/cdk_dialog (3)
36 DoubleFloat Scale/cdk_dscale (3)
37 Entry Field/cdk_entry (3)
38 File Selector/cdk_fselect (3)
39 File Viewer/cdk_viewer (3)
40 Floating Scale/cdk_fscale (3)
41 Floating Slider/cdk_fslider (3)
42 Graph/cdk_graph (3)
43 Histogram/cdk_histogram (3)
44 Integer Scale/cdk_scale (3)
45 Integer Slider/cdk_slider (3)
46 Item List/cdk_itemlist (3)
47 Label/cdk_label (3)
48 Marquee/cdk_marquee (3)
49 Matrix/cdk_matrix (3)
50 Multiple Line Entry Field/cdk_mentry (3)
51 Pulldown Menu/cdk_menu (3)
52 Radio List/cdk_radio (3)
53 Scrolling List/cdk_scroll (3)
54 Scrolling Selection List/cdk_selection (3)
55 Scrolling Window/cdk_swindow (3)
56 Template/cdk_template (3)
57 Unsigned Scale/cdk_uscale (3)
58 Unsigned Slider/cdk_uslider (3)
59 .TE
60 .LP
61 The rest of the manual pages describe supporting functions:
62 .LP
63 .TS
64 center tab(/);
65 l l
66 l l
67 lw18 lw35 .
68 \fBManual Page Name/Description\fR
69 =
70 cdk_binding (3)/T{
71 Outlines how to create user definable key bindings.
72 T}
73 cdk_display (3)/T{
74 Shows how to add special display attributes,
75 colors, and justification into a widget.
76 T}
77 cdk_draw (3)/T{
78 Outlines functions used for drawing text and lines.
79 T}
80 cdk_screen (3)/T{
81 Demonstrates the use of screens within Cdk.
82 T}
83 cdk_misc (3)/T{
84 Outlines miscellaneous functions provided with the Cdk library.
85 T}
86 cdk_process (3)/T{
87 Demonstrates the use of the pre- and post-process function class.
88 T}
89 .TE
90 .SH DESCRIPTION
91 Cdk is a library of functions which allow a programmer to quickly create a
92 full screen interactive program with ease.
93 The Cdk widgets support the
94 following features:
95 .It "\(bu Ncurses library." 5
96 Instead of using the standard curses library, Cdk can take advantage of the
97 colors that Ncurses provides.
98 To learn how to take advantage of Cdk's color
99 capabilities, see \fIcdk_display (3)\fR.
100 .PP
101 .It "\(bu Key Bindings." 5
102 Individual keys can be overridden with a callback.
103 The callback is set up using
104 the \fBbindCDKObject\fR function.
105 To learn more about this see \fIcdk_binding (3)\fR.
106 .PP
107 .It "\(bu Pre and Post Processing." 5
108 Certain widgets allow the user to trap a character before and after the
109 character has been applied to the widget.
110 This allows programmers to `filter' character input.
111 To learn more about this see \fIcdk_process (3)\fR.
112 .PP
113 .It "\(bu Self Test Widgets." 5
114 With the use of the inject function class and the activate function,
115 programmers can have the widgets test themselves.
116 This allows the programmer
117 to perform automated tests on a final program.
118 .PP
119 .It "\(bu Special Display Formats" 5
120 There are special character format commands that can be inserted into any
121 string in Cdk and the contents will get mapped to a \fIchtype\fR (see the
122 curses manual page) with character attributes.
123 This allows the programmer to
124 insert format types on each character if they wish.
125 .PP
126 .It "\(bu The Ability To Build Predefined Screens" 5
127 Widgets can be associated to any given screen.
128 If there is more than one
129 screen defined, then Cdk has the ability to "flip" from one screen to another
130 with ease.
131 See the \fIcdk_screen\fR manual page for more details.
132 .PP
133 .SH STANDARD WIDGET BEHAVIOR
134 All of the widgets have a member of the structure called \fIexitType\fR.
135 This member states how the widget exited.
136 There are three values in which to check
137 for, they are as follows:
138 .LP
139 .TS
140 center tab(/) allbox;
141 l l
142 l l
143 lw15 lw35 .
144 \fBValue/Meaning\fR
145 =
146 vNORMAL/T{
147 This means the widget exited normally.
148 This value is set when the widget is given the characters TAB or RETURN.
149 T}
150 vEARLY_EXIT/T{
151 This means the widget exited early.
152 This value is set when characters such as
153 TAB or RETURN are injected into the
154 widget via the injectCDKXXX function and the
155 character injected does not exit the widget.
156 T}
157 vESCAPE_HIT/T{
158 This value states the user hit ESCAPE to leave the widget.
159 T}
160 vNEVER_ACTIVATED/T{
161 This is the initial state of the value.
162 This means that the widget has not been activated.
163 T}
164 .TE
165 .SH SEE ALSO
166 .BR cdk (3),
167 .BR cdk_binding (3),
168 .BR cdk_display (3),
169 .BR cdk_draw (3),
170 .BR cdk_misc (3),
171 .BR cdk_process (3),
172 .BR cdk_screen (3)
173 .
174 .SH NOTES
175 .PP
176 The header file \fI<cdk.h>\fR automatically includes the header files
177 \fI<curses.h>\fR,
178 \fI<stdlib.h>\fR,
179 \fI<string.h>\fR,
180 \fI<ctype.h>\fR,
181 \fI<unistd.h>\fR,
182 \fI<dirent.h>\fR,
183 \fI<time.h>\fR,
184 \fI<errno.h>\fR,
185 \fI<pwd.h>\fR,
186 \fI<grp.h>\fR,
187 \fI<sys/stat.h>\fR, and
188 \fI<sys/types.h>\fR.
189 The \fI<curses.h>\fR header file includes \fI<stdio.h>\fR and \fI<unctrl.h>\fR.
0 '\" t
1 .\" $Id: cdk_alphalist.3,v 1.23 2006/05/07 01:04:30 tom Exp $"
2 .de XX
3 ..
4 .TH cdk_alphalist 3
5 .SH NAME
6 .XX activateCDKAlphalist
7 .XX destroyCDKAlphalist
8 .XX drawCDKAlphalist
9 .XX eraseCDKAlphalist
10 .XX getCDKAlphalistBox
11 .XX getCDKAlphalistContents
12 .XX getCDKAlphalistCurrentItem
13 .XX getCDKAlphalistFillerChar
14 .XX getCDKAlphalistHighlight
15 .XX injectCDKAlphalist
16 .XX moveCDKAlphalist
17 .XX newCDKAlphalist
18 .XX positionCDKAlphalist
19 .XX setCDKAlphalist
20 .XX setCDKAlphalistBackgroundAttrib
21 .XX setCDKAlphalistBackgroundColor
22 .XX setCDKAlphalistBox
23 .XX setCDKAlphalistBoxAttribute
24 .XX setCDKAlphalistContents
25 .XX setCDKAlphalistCurrentItem
26 .XX setCDKAlphalistFillerChar
27 .XX setCDKAlphalistHighlight
28 .XX setCDKAlphalistHorizontalChar
29 .XX setCDKAlphalistLLChar
30 .XX setCDKAlphalistLRChar
31 .XX setCDKAlphalistPostProcess
32 .XX setCDKAlphalistPreProcess
33 .XX setCDKAlphalistULChar
34 .XX setCDKAlphalistURChar
35 .XX setCDKAlphalistVerticalChar
36 cdk_alphalist \- curses sorted list widget.
37 .SH SYNOPSIS
38 .LP
39 .B cc
40 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
41 .B \-lcdk
42 .RI "[ " "library" " \|.\|.\|. ]"
43 .LP
44 #include <cdk.h>
45 .nf
46 .TP 15
47 .B "char *activateCDKAlphalist ("
48 .BI "CDKALPHALIST *" "alphalist",
49 .BI "chtype *" "actions");
50 .TP 15
51 .B "void destroyCDKAlphalist ("
52 .BI "CDKALPHALIST *" "alphalist");
53 .TP 15
54 .B "void drawCDKAlphalist ("
55 .BI "CDKALPHALIST *" "alphalist",
56 .BI "boolean " "box");
57 .TP 15
58 .B "void eraseCDKAlphalist ("
59 .BI "CDKALPHALIST *" "alphalist");
60 .TP 15
61 .B "boolean getCDKAlphalistBox ("
62 .BI "CDKALPHALIST *" "alphalist");
63 .TP 15
64 .B "char **getCDKAlphalistContents ("
65 .BI "CDKALPHALIST *" "alphalist",
66 .BI "int *" "size");
67 .TP 15
68 .B "int getCDKAlphalistCurrentItem ("
69 .BI "CDKALPHALIST *" "widget");
70 .TP 15
71 .B "chtype getCDKAlphalistFillerChar ("
72 .BI "CDKALPHALIST *" "alphalist");
73 .TP 15
74 .B "chtype getCDKAlphalistHighlight ("
75 .BI "CDKALPHALIST *" "alphalist");
76 .TP 15
77 .B "char *injectCDKAlphalist ("
78 .BI "CDKALPHALIST *" "alphalist",
79 .BI "chtype " "input");
80 .TP 15
81 .B "void moveCDKAlphalist ("
82 .BI "CDKALPHALIST *" "alphalist",
83 .BI "int " "xpos",
84 .BI "int " "ypos",
85 .BI "boolean " "relative",
86 .BI "boolean " "refresh");
87 .TP 15
88 .B "CDKALPHALIST *newCDKAlphalist ("
89 .BI "CDKSCREEN *" "cdkscreen",
90 .BI "int " "xpos",
91 .BI "int " "ypos",
92 .BI "int " "height",
93 .BI "int " "width",
94 .BI "char * " "title",
95 .BI "char * " "label",
96 .BI "char ** " "list",
97 .BI "int " "listSize",
98 .BI "chtype " "fillerCharacter",
99 .BI "chtype " "highlight",
100 .BI "boolean " "box",
101 .BI "boolean " "shadow");
102 .TP 15
103 .B "void positionCDKAlphalist ("
104 .BI "CDKALPHALIST *" "alphalist");
105 .TP 15
106 .B "void setCDKAlphalist ("
107 .BI "CDKALPHALIST *" "alphalist",
108 .BI "char ** " "list",
109 .BI "int " "listSize",
110 .BI "chtype " "fillerCharacter",
111 .BI "chtype " "highlight",
112 .BI "boolean " "box");
113 .TP 15
114 .B "void setCDKAlphalistBackgroundAttrib ("
115 .BI "CDKALPHALIST *" "alphalist",
116 .BI "chtype " "attribute");
117 .TP 15
118 .B "void setCDKAlphalistBackgroundColor ("
119 .BI "CDKALPHALIST *" "alphalist",
120 .BI "char * " "color");
121 .TP 15
122 .B "void setCDKAlphalistBox ("
123 .BI "CDKALPHALIST *" "alphalist",
124 .BI "boolean " "box");
125 .TP 15
126 .B "void setCDKAlphalistBoxAttribute ("
127 .BI "CDKALPHALIST *" "alphalist",
128 .BI "chtype " "character");
129 .TP 15
130 .B "void setCDKAlphalistContents ("
131 .BI "CDKALPHALIST *" "alphalist",
132 .BI "char ** " "list",
133 .BI "int " "listSize");
134 .TP 15
135 .B "void setCDKAlphalistCurrentItem ("
136 .BI "CDKALPHALIST *" "widget",
137 .BI "int " "item");
138 .TP 15
139 .B "void setCDKAlphalistFillerChar ("
140 .BI "CDKALPHALIST *" "alphalist",
141 .BI "chtype " "fillerCharacter");
142 .TP 15
143 .B "void setCDKAlphalistHighlight ("
144 .BI "CDKALPHALIST *" "alphalist",
145 .BI "chtype " "highlight");
146 .TP 15
147 .B "void setCDKAlphalistHorizontalChar ("
148 .BI "CDKALPHALIST *" "alphalist",
149 .BI "chtype " "character");
150 .TP 15
151 .B "void setCDKAlphalistLLChar ("
152 .BI "CDKALPHALIST *" "alphalist",
153 .BI "chtype " "character");
154 .TP 15
155 .B "void setCDKAlphalistLRChar ("
156 .BI "CDKALPHALIST *" "alphalist",
157 .BI "chtype " "character");
158 .TP 15
159 .B "void setCDKAlphalistPostProcess ("
160 .BI "CDKALPHALIST *" "alphalist",
161 .BI "PROCESSFN " "callback",
162 .BI "void * " "data");
163 .TP 15
164 .B "void setCDKAlphalistPreProcess ("
165 .BI "CDKALPHALIST *" "alphalist",
166 .BI "PROCESSFN " "callback",
167 .BI "void * " "data");
168 .TP 15
169 .B "void setCDKAlphalistULChar ("
170 .BI "CDKALPHALIST *" "alphalist",
171 .BI "chtype " "character");
172 .TP 15
173 .B "void setCDKAlphalistURChar ("
174 .BI "CDKALPHALIST *" "alphalist",
175 .BI "chtype " "character");
176 .TP 15
177 .B "void setCDKAlphalistVerticalChar ("
178 .BI "CDKALPHALIST *" "alphalist",
179 .BI "chtype " "character");
180 .SH DESCRIPTION
181 The Cdk alphalist allows a user to select from a list of alphabetically
182 sorted words.
183 The user can use the arrow keys to traverse through the
184 list or type in the beginning of the word and the list will automatically
185 adjust itself in the correct place in the scrolling list.
186 This widget,
187 like the file selector widget, is a compound widget of both the entry
188 field widget and the scrolling list widget.
189 .SH AVAILABLE FUNCTIONS
190 .TP 5
191 .B activateCDKAlphalist
192 activates the alphalist widget and lets the user interact with the widget.
193 The parameter \fBalphalist\fR is a pointer to a non-NULL alphalist widget.
194 If the \fBactions\fR parameter is passed with a non-NULL value, the
195 characters in the array will be injected into the widget.
196 To activate the widget
197 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
198 If the character entered
199 into this widget is \fIRETURN\fR then this function will return a \fIchar *\fR
200 of the information which was typed in the field.
201 If the \fITAB\fR character is hit
202 then the widget will try to complete the word in the entry field.
203 If the widget
204 is exited with the \fIRETURN\fR character then the widget data \fIexitType\fR
205 will be set to \fIvNORMAL\fR.
206 If the widget was exited with the \fIESCAPE\fR key
207 then the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR and
208 the widget returns \fINULL\fR.
209 .TP 5
210 .B destroyCDKAlphalist
211 removes the widget from the screen and frees memory the object used.
212 .TP 5
213 .B drawCDKAlphalist
214 draws the alphalist widget on the screen.
215 If the \fBbox\fR parameter is true, the widget is drawn with a box.
216 .TP 5
217 .B eraseCDKAlphalist
218 removes the widget from the screen.
219 This does \fINOT\fR destroy
220 the widget.
221 .TP 5
222 .B getCDKAlphalistBox
223 returns true if the widget will be drawn with a box around it.
224 .TP 5
225 .B getCDKAlphalistContents
226 returns the contents of the alphalist.
227 .TP 5
228 .B getCDKAlphalistCurrentItem
229 returns the current position in the scroll-widget.
230 .TP 5
231 .B getCDKAlphalistFillerChar
232 returns the character being used as the filler character in the
233 entry field portion of the widget.
234 .TP 5
235 .B getCDKAlphalistHighlight
236 returns the attribute of the highlight bar of the scrolling
237 list portion of the widget.
238 .TP 5
239 .B injectCDKAlphalist
240 injects a single character into the widget (actually the entry widget).
241 The parameter \fBalphalist\fR is a pointer to a non-NULL alphalist widget.
242 The parameter \fBcharacter\fR is the character to inject into the widget.
243 The return value and side-effect (setting the widget data \fIexitType\fP)
244 depend upon the injected character:
245 .RS
246 .TP
247 \fIRETURN\fP or \fITAB\fR
248 the function returns
249 the information in the entry field.
250 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
251 .TP
252 \fIESCAPE\fP
253 the function returns
254 a \fINULL\fR pointer.
255 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
256 .TP
257 Otherwise
258 unless modified by preprocessing, postprocessing or key bindings,
259 the function returns
260 a \fINULL\fR pointer.
261 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
262 .RE
263 .TP 5
264 .B moveCDKAlphalist
265 moves the given widget to the given position.
266 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
267 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
268 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
269 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
270 \fIRIGHT\fR, and \fICENTER\fR.
271 The parameter \fBrelative\fR states whether
272 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
273 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
274 then the widget would move one row down and two columns right.
275 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
276 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
277 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
278 (weird things may happen).
279 The final parameter \fBrefresh\fR is a boolean value
280 which states whether the widget will get refreshed after the move.
281 .TP 5
282 .B newCDKAlphalist
283 creates a pointer to an alphalist widget.
284 Parameters:
285 .RS
286 .TP 5
287 \fBscreen\fR
288 is the screen you wish this widget to be placed in.
289 .TP 5
290 \fBxpos\fR
291 controls the placement of the object along the horizontal axis.
292 This parameter
293 can take an integer or one of the pre-defined values \fILEFT\fR,
294 \fIRIGHT\fR, and \fICENTER\fR.
295 .TP 5
296 \fBypos\fR
297 controls the placement
298 of the object along the vertical axis.
299 This parameter may be an integer
300 value or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
301 .TP 5
302 \fBheight\fR and
303 .TP 5
304 \fBwidth\fR
305 control the height and width of the widget.
306 If you provide a value of zero for either of the height
307 or the width, the widget will be created with the full width and height of the screen.
308 If you provide a negative value, the widget will be created the full height
309 or width minus the value provided.
310 .TP 5
311 \fBtitle\fR
312 is the string which will be displayed at the top of the scrolling list.
313 The title can be more than one
314 line; just provide a carriage return character at the line break.
315 .TP 5
316 \fBlabel\fR
317 is the string which will be displayed in the label of the entry field.
318 .TP 5
319 \fBlist\fR
320 is the list of words which will be displayed in the
321 scrolling list.
322 This list does not have to be sorted, this widget automatically
323 sorts the list
324 (note that it modifies the caller's copy of the list to do this).
325 .TP 5
326 \fBlistSize\fR
327 tells the widget how large the word list is.
328 .TP 5
329 \fBfillerCharacter\fR
330 is the character which is to be displayed in an empty space in the entry field.
331 .TP 5
332 \fBhighlight\fR
333 is the attribute of the highlight bar in the scrolling list.
334 .TP 5
335 \fBbox\fR
336 is true if the widget should be drawn with a box around it.
337 .TP 5
338 \fBshadow\fR
339 is true to turn the shadow on around this widget.
340 .RE
341 .IP
342 If the
343 widget could not be created then a \fINULL\fR pointer is returned.
344 .TP 5
345 .B positionCDKAlphalist
346 allows the user to move the widget around the screen via the cursor/keypad keys.
347 See \fBcdk_position (3)\fR for key bindings.
348 .TP 5
349 .B setCDKAlphalist
350 lets the programmer modify certain elements of an existing alphalist widget.
351 The parameter names correspond to the same parameter
352 names listed in the \fBnewCDKAlphalist\fR function.
353 .TP 5
354 .B setCDKAlphalistBackgroundAttrib
355 sets the background attribute of the widget.
356 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
357 .TP 5
358 .B setCDKAlphalistBackgroundColor
359 sets the background color of the widget.
360 The parameter \fBcolor\fR
361 is in the format of the Cdk format strings.
362 See \fBcdk_display (3)\fR.
363 .TP 5
364 .B setCDKAlphalistBox
365 sets whether the widget will be drawn with a box around it.
366 .TP 5
367 .B setCDKAlphalistBoxAttribute
368 sets the attribute of the box.
369 .TP 5
370 .B setCDKAlphalistContents
371 sets the contents of the alphalist widget
372 (note that it sorts the caller's copy of the list).
373 .TP 5
374 .B setCDKAlphalistCurrentItem
375 set the current position in the scroll-widget.
376 .TP 5
377 .B setCDKAlphalistFillerChar
378 sets the character to use when drawing the entry field portion of the widget.
379 .TP 5
380 .B setCDKAlphalistHighlight
381 sets the attribute of the highlight bar of the scrolling
382 list portion of the widget.
383 .TP 5
384 .B setCDKAlphalistHorizontalChar
385 sets the horizontal drawing character for the box to
386 the given character.
387 .TP 5
388 .B setCDKAlphalistLLChar
389 sets the lower left hand corner of the widget's box to
390 the given character.
391 .TP 5
392 .B setCDKAlphalistLRChar
393 sets the lower right hand corner of the widget's box to
394 the given character.
395 .TP 5
396 .B setCDKAlphalistPostProcess
397 allows the user to have the widget call a function after the
398 key has been applied to the widget.
399 The parameter \fBfunction\fR is the callback function.
400 The parameter \fBdata\fR points to data passed to the callback function.
401 To learn more about post-processing see \fIcdk_process (3)\fR.
402 .TP 5
403 .B setCDKAlphalistPreProcess
404 allows the user to have the widget call a function after a key
405 is hit and before the key is applied to the widget.
406 The parameter \fBfunction\fR is the callback function.
407 The parameter \fBdata\fR points to data passed to the callback function.
408 To learn more about pre-processing see \fIcdk_process (3)\fR.
409 .TP 5
410 .B setCDKAlphalistULChar
411 sets the upper left hand corner of the widget's box to
412 the given character.
413 .TP 5
414 .B setCDKAlphalistURChar
415 sets the upper right hand corner of the widget's box to
416 the given character.
417 .TP 5
418 .B setCDKAlphalistVerticalChar
419 sets the vertical drawing character for the box to
420 the given character.
421 .SH KEY BINDINGS
422 When the widget is activated there are several default key bindings which will
423 help the user enter or manipulate the information quickly.
424 Since this widget is
425 built from both the scrolling list widget and the entry field widget, the key
426 bindings are the same for the respective fields.
427 The extra key bindings are
428 listed below.
429 .LP
430 .TS
431 center tab(/) allbox;
432 l l
433 l l
434 lw15 lw35 .
435 \fBKey/Action\fR
436 =
437 Up Arrow/T{
438 Scrolls the scrolling list up one line.
439 T}
440 Down Arrow/T{
441 Scrolls the scrolling list down one line.
442 T}
443 Page Up/T{
444 Scrolls the scrolling list up one page.
445 T}
446 CTRL-B/T{
447 Scrolls the scrolling list up one page.
448 Page Down/Scrolls the scrolling list down one page.
449 T}
450 CTRL-F/T{
451 Scrolls the scrolling list down one page.
452 T}
453 Tab/T{
454 Tries to complete the word in the entry field.
455 If the word segment is not unique then the
456 widget will beep and present a list of close matches.
457 T}
458 Return/T{
459 Returns the word in the entry field.
460 It also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
461 T}
462 Escape/T{
463 Exits the widget and returns a \fINULL\fR pointer.
464 It also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
465 T}
466 .TE
467 .SH SEE ALSO
468 .BR cdk (3),
469 .BR cdk_binding (3),
470 .BR cdk_display (3),
471 .BR cdk_position (3),
472 .BR cdk_screen (3)
473 .SH NOTES
474 .PP
475 This widget is created from the scrolling list widget and the entry field widget.
476 This is a good example on how to build your own widgets using the
477 base widgets provided in this distribution.
0 '\" t
1 .\" $Id: cdk_binding.3,v 1.22 2005/12/30 00:01:59 tom Exp $
2 .de XX
3 ..
4 .TH cdk_binding 3
5 .SH NAME
6 .XX bindCDKObject
7 .XX checkCDKObjectBind
8 .XX cleanCDKObjectBindings
9 .XX unbindCDKObject
10 .XX getcCDKObject
11 .XX getchCDKObject
12 cdk_binding - \fBCurses Development Kit\fR Character Binding Capabilities.
13 .LP
14 .SH SYNOPSIS
15 .LP
16 .B cc
17 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
18 .B \-lcdk
19 .RI "[ " "library" " \|.\|.\|. ]"
20 .LP
21 .nf
22 #include <cdk.h>
23 .TP 15
24 .B "void bindCDKObject ("
25 .BI "EObjectType " "cdkType",
26 .BI "void *" "object",
27 .BI "chtype " "key",
28 .BI "BINDFN " "function",
29 .BI "void *" "data");
30 .TP 15
31 .B "int checkCDKObjectBind ("
32 .BI "EObjectType " "cdkType",
33 .BI "void *" "object",
34 .BI "chtype " "key");
35 .TP 15
36 .B "void cleanCDKObjectBindings ("
37 .BI "EObjectType " "cdkType",
38 .BI "void *" "object");
39 .TP 15
40 .B "bool isCDKObjectBind ("
41 .BI "EObjectType " "cdkType",
42 .BI "void *" "object",
43 .BI "chtype " "key");
44 .TP 15
45 .B "void unbindCDKObject ("
46 .BI "EObjectType " "cdkType",
47 .BI "void *" "object",
48 .BI "chtype " "key");
49 .TP 15
50 .B "int getcCDKObject ("
51 .BI "CDKOBJS *" "object");
52 .TP 15
53 .B "int getchCDKObject ("
54 .BI "CDKOBJS *" "object",
55 .BI "boolean *" "functionKey");
56 .fi
57 .SH DESCRIPTION
58 Cdk has the ability to create user definable key bindings.
59 This ability makes
60 Cdk more dynamic and usable for a wide variety of tasks.
61 The following section
62 outlines the binding functions, their use, and their purpose.
63 .TP 5
64 .B bindCDKObject
65 creates a key binding between a specific Cdk widget (\fBobject\fR)
66 given key (\fBkey\fR).
67 The parameter \fBcdkType\fR is of type \fIEObjectType\fR
68 which is one of the following values.
69 .LP
70 .TS
71 center tab(/);
72 l
73 l l
74 lw13 lw30 lw 30 .
75 \fBEObjectType_Value/Corresponding_Widget/Widget_Manual_Page\fR
76 =
77 vALPHALIST/Alphalist Widget/cdk_alphalist (3)
78 vBUTTON/Button Widget/cdk_button (3)
79 vBUTTONBOX/Buttonbox Widget/cdk_buttonbox (3)
80 vCALENDAR/Calendar Widget/cdk_calendar (3)
81 vDIALOG/Dialog Widget/cdk_dialog (3)
82 vDSCALE/DoubleFloat Widget/cdk_dscale (3)
83 vENTRY/Entry Widget/cdk_entry (3)
84 vFSCALE/Floating Scale Widget/cdk_fscale (3)
85 vFSELECT/File Selector Widget/cdk_fselect (3)
86 vFSLIDER/Floating Slider Widget/cdk_fslider (3)
87 vGRAPH/Graph Widget/cdk_graph (3)
88 vHISTOGRAM/Histogram Widget/cdk_histogram (3)
89 vITEMLIST/Item List Widget/cdk_itemlist (3)
90 vLABEL/Label Widget/cdk_label (3)
91 vMARQUEE/Marquee Widget/cdk_marquee (3)
92 vMATRIX/Matrix Widget/cdk_matrix (3)
93 vMENTRY/Multiple Line Entry Widget/cdk_mentry (3)
94 vMENU/Menu Widget/cdk_menu (3)
95 vRADIO/Radio List Widget/cdk_radio (3)
96 vSCALE/Integer Scale Widget/cdk_scale (3)
97 vSCROLL/Scrolling List Widget/cdk_scroll (3)
98 vSELECTION/Selection List Widget/cdk_selection (3)
99 vSLIDER/Slider Widget/cdk_slider (3)
100 vSWINDOW/Scrolling Window Widget/cdk_swindow (3)
101 vTEMPLATE/Template Entry Widget/cdk_template (3)
102 vUSCALE/Unsigned Scale Widget/cdk_uscale (3)
103 vUSLIDER/Unsigned Slider Widget/cdk_uslider (3)
104 vVIEWER/Viewer Widget/cdk_viewer (3)
105 =
106 .TE
107 .RS 3
108 The parameter \fBfunction\fR is the callback function.
109 The parameter \fBdata\fR points to data passed to the callback function.
110 The parameter \fBkey\fR is the key hit which triggered this callback.
111 .RE
112 .TP 5
113 .B checkCDKObjectBind
114 check to see if a binding for the given \fBkey\fP exists.
115 If it does,
116 Cdk runs the associated command and returns its value,
117 normally TRUE.
118 If no binding exists, return FALSE.
119 .IP
120 The widgets which accept input, e.g., via "inject" methods,
121 use this to check if the injected character is bound to a function.
122 If that returns TRUE, the widget may update its \fIexitType\fP value:
123 if \fIearlyExit\fP value is set
124 (not equal to vNEVER_ACTIVATED),
125 the widget sets \fIexitType\fP to that value.
126 .TP 5
127 .B cleanCDKObjectBindings
128 removes all user defined key bindings from the given widget.
129 .TP 5
130 .B isCDKObjectBind
131 check to see if a binding for the given \fBkey\fP exists.
132 If it does return TRUE.
133 If no binding exists, return FALSE.
134 .TP 5
135 .B unbindCDKObject
136 removes a specific binding to an object.
137 The parameter are
138 the same as for \fBbindCDKObject\fR.
139 .TP 5
140 .B getcCDKObject
141 reads a keycode from the given widget.
142 This is depcrecated: use \fBgetchCDKObject\fP.
143 .TP 5
144 .B getchCDKObject
145 reads a keycode from the given widget.
146 It sets a flag to indicate if the result is a function key.
147 If the keycode has been bound to the special function \fBgetcCDKBind\fP,
148 then it will be translated to the value which was given for the binding data.
149 Otherwise, a few special cases are performed:
150 .TS
151 center tab(/) allbox;
152 l l
153 l l
154 lw35 lw35 .
155 \fBKey/Result\fR
156 =
157 CTRL-A/KEY_HOME
158 CTRL-B/KEY_LEFT
159 CTRL-E/KEY_END
160 CTRL-F/KEY_RIGHT
161 CTRL-N/tab
162 CTRL-P/KEY_BTAB
163 DEL/KEY_DC
164 backspace/KEY_BACKSPACE
165 carriage return/KEY_ENTER
166 newline/KEY_ENTER
167 .TE
168 .PP
169 All of the widgets use \fBgetchCDKObject\fP internally for consistency.
170 .SH EXAMPLE
171 To help demonstrate how to use the key bindings I will demonstrate a simple
172 dialog box widget with help for each button.
173 The following code segment creates
174 a dialog box and a callback function named \fIdialogHelpCB\fR.
175 .LP
176 .nf
177 .ce
178 \fI________________________________________\fR
179 .LP
180 .ta 9 17 25 33 41
181 #include <cdk.h>
182
183 #ifdef HAVE_XCURSES
184 char *XCursesProgramName="bind_ex";
185 #endif
186
187 static int dialogHelpCB (EObjectType cdktype GCC_UNUSED, void *object, void *clientData GCC_UNUSED, chtype key GCC_UNUSED)
188 {
189 CDKDIALOG *dialog = (CDKDIALOG *)object;
190 char *mesg[5];
191
192 /* Check which button we are on. */
193 if (dialog->currentButton == 0)
194 {
195 mesg[0] = "<C></U>Help for </U>Who<!U>.";
196 mesg[1] = "<C>When this button is picked the name of the current";
197 mesg[2] = "<C>user is displayed on the screen in a popup window.";
198 popupLabel (ScreenOf(dialog), mesg, 3);
199 }
200 else if (dialog->currentButton == 1)
201 {
202 mesg[0] = "<C></U>Help for </U>Time<!U>.";
203 mesg[1] = "<C>When this button is picked the current time is";
204 mesg[2] = "<C>displayed on the screen in a popup window.";
205 popupLabel (ScreenOf(dialog), mesg, 3);
206 }
207 else if (dialog->currentButton == 2)
208 {
209 mesg[0] = "<C></U>Help for </U>Date<!U>.";
210 mesg[1] = "<C>When this button is picked the current date is";
211 mesg[2] = "<C>displayed on the screen in a popup window.";
212 popupLabel (ScreenOf(dialog), mesg, 3);
213 }
214 else if (dialog->currentButton == 3)
215 {
216 mesg[0] = "<C></U>Help for </U>Quit<!U>.";
217 mesg[1] = "<C>When this button is picked the dialog box is exited.";
218 popupLabel (ScreenOf(dialog), mesg, 2);
219 }
220 return (FALSE);
221 }
222
223 int main (void)
224 {
225 /* Declare variables. */
226 CDKSCREEN *cdkscreen;
227 CDKDIALOG *question;
228 WINDOW *cursesWin;
229 char *buttons[40];
230 char *message[40], *info[5], *loginName;
231 char temp[256];
232 int selection;
233 time_t clck;
234 struct tm *currentTime;
235
236 /* Set up CDK. */
237 cursesWin = initscr();
238 cdkscreen = initCDKScreen (cursesWin);
239
240 /* Start color. */
241 initCDKColor();
242
243 /* Set up the dialog box. */
244 message[0] = "<C></U>Simple Command Interface";
245 message[1] = "Pick the command you wish to run.";
246 message[2] = "<C>Press </R>?<!R> for help.";
247 buttons[0] = "Who";
248 buttons[1] = "Time";
249 buttons[2] = "Date";
250 buttons[3] = "Quit";
251
252 /* Create the dialog box. */
253 question = newCDKDialog (cdkscreen, CENTER, CENTER,
254 message, 3, buttons, 4, A_REVERSE,
255 TRUE, TRUE, FALSE);
256
257 /* Check if we got a null value back. */
258 if (question == (CDKDIALOG *)0)
259 {
260 destroyCDKScreen (cdkscreen);
261
262 /* End curses... */
263 endCDK();
264
265 /* Spit out a message. */
266 printf ("Oops. Can't seem to create the dialog box. Is the window too small?\\n");
267 exit (1);
268 }
269
270 /* Create the key binding. */
271 bindCDKObject (vDIALOG, question, '?', dialogHelpCB, 0);
272
273 /* Activate the dialog box. */
274 selection = 0;
275 while (selection != 3)
276 {
277 /* Get the users button selection. */
278 selection = activateCDKDialog (question, (chtype *)0);
279
280 /* Check the results. */
281 if (selection == 0)
282 {
283 /* Get the users login name. */
284 info[0] = "<C> </U>Login Name<!U> ";
285 loginName = getlogin();
286 if (loginName == (char *)0)
287 {
288 strcpy (temp, "<C></R>Unknown");
289 }
290 else
291 {
292 sprintf (temp, "<C><%s>", loginName);
293 }
294 info[1] = copyChar (temp);
295 popupLabel (ScreenOf(question), info, 2);
296 freeChar (info[1]);
297 }
298 else if (selection == 1)
299 {
300 /* Print out the time. */
301 time(&clck);
302 currentTime = localtime(&clck);
303 sprintf (temp, "<C>%d:%d:%d", currentTime->tm_hour,
304 currentTime->tm_min,
305 currentTime->tm_sec);
306 info[0] = "<C> </U>Current Time<!U> ";
307 info[1] = copyChar (temp);
308 popupLabel (ScreenOf(question), info, 2);
309 freeChar (info[1]);
310 }
311 else if (selection == 2)
312 {
313 /* Print out the date. */
314 time(&clck);
315 currentTime = localtime(&clck);
316 sprintf (temp, "<C>%d/%d/%02d", currentTime->tm_mday,
317 currentTime->tm_mon,
318 currentTime->tm_year % 100);
319 info[0] = "<C> </U>Current Date<!U> ";
320 info[1] = copyChar (temp);
321 popupLabel (ScreenOf(question), info, 2);
322 freeChar (info[1]);
323 }
324 }
325
326 /* Clean up. */
327 destroyCDKDialog (question);
328 destroyCDKScreen (cdkscreen);
329 delwin (cursesWin);
330 endCDK();
331 exit (0);
332 }
333 .fi
334 .ce
335 \fI________________________________________\fR
336
337 .SH SEE ALSO
338 .BR cdk (3),
339 .BR cdk_display (3),
340 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_button.3,v 1.8 2005/12/28 18:35:31 tom Exp $
2 .de XX
3 ..
4 .TH cdk_button 3
5 .SH NAME
6 .XX activateCDKButton
7 .XX destroyCDKButton
8 .XX drawCDKButton
9 .XX eraseCDKButton
10 .XX getCDKButtonBox
11 .XX getCDKButtonMessage
12 .XX injectCDKButton
13 .XX moveCDKButton
14 .XX newCDKButton
15 .XX positionCDKButton
16 .XX setCDKButton
17 .XX setCDKButtonBackgroundAttrib
18 .XX setCDKButtonBackgroundColor
19 .XX setCDKButtonBox
20 .XX setCDKButtonBoxAttribute
21 .XX setCDKButtonHorizontalChar
22 .XX setCDKButtonLLChar
23 .XX setCDKButtonLRChar
24 .XX setCDKButtonMessage
25 .XX setCDKButtonULChar
26 .XX setCDKButtonURChar
27 .XX setCDKButtonVerticalChar
28 cdk_button \- create and manage a curses button widget.
29 .SH SYNOPSIS
30 .LP
31 .B cc
32 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
33 .B \-lcdk
34 .RI "[ " "library" " \|.\|.\|. ]"
35 .LP
36 #include <cdk.h>
37
38 typedef void (*tButtonCallback)(struct SButton *button);
39 .nf
40 .TP 15
41 .B "int activateCDKButton ("
42 .BI "CDKBUTTON *" "button",
43 .BI "chtype * " "actions");
44 .TP 15
45 .BI "void destroyCDKButton ("
46 .BI "CDKBUTTON *" "button");
47 .TP 15
48 .BI "void drawCDKButton ("
49 .BI "CDKBUTTON *" "b",
50 .BI "boolean " "box");
51 .TP 15
52 .BI "void eraseCDKButton ("
53 .BI "CDKBUTTON *" "button");
54 .TP 15
55 .BI "boolean getCDKButtonBox ("
56 .BI "CDKBUTTON *" "b");
57 .TP 15
58 .BI "chtype *getCDKButtonMessage ("
59 .BI "CDKBUTTON *" "b");
60 .TP 15
61 .B "int injectCDKButtonbox ("
62 .BI "CDKBUTTON *" "buttonbox",
63 .BI "chtype " "input");
64 .TP 15
65 .BI "CDKBUTTON *newCDKButton("
66 .BI "CDKSCREEN *" "cdkscreen",
67 .BI "int " "xpos",
68 .BI "int " "ypos",
69 .BI "char *" "message",
70 .BI "tButtonCallback " "callback",
71 .BI "boolean " "box",
72 .BI "boolean " "shadow");
73 .TP 15
74 .BI "void setCDKButton("
75 .BI "CDKBUTTON *" "b",
76 .BI "char *" "message",
77 .BI "boolean " "box");
78 .TP 15
79 .BI "void setCDKButtonBackgroundAttrib ("
80 .BI "CDKBUTTON *" "b",
81 .BI "chtype " "attribute");
82 .TP 15
83 .BI "void setCDKButtonBackgroundColor ("
84 .BI "CDKBUTTON *" "b",
85 .BI "char * " "color");
86 .TP 15
87 .BI "void setCDKButtonBox ("
88 .BI "CDKBUTTON *" "button",
89 .BI "boolean " "box");
90 .TP 15
91 .BI "void setCDKButtonBoxAttribute ("
92 .BI "CDKBUTTON *" "b",
93 .BI "chtype " "c");
94 .TP 15
95 .BI "void setCDKButtonHorizontalChar ("
96 .BI "CDKBUTTON *" "b",
97 .BI "chtype " "c");
98 .TP 15
99 .BI "void setCDKButtonLLChar ("
100 .BI "CDKBUTTON *" "b",
101 .BI "chtype " "c");
102 .TP 15
103 .BI "void setCDKButtonLRChar ("
104 .BI "CDKBUTTON *" "b",
105 .BI "chtype " "c");
106 .TP 15
107 .BI "void setCDKButtonMessage ("
108 .BI "CDKBUTTON *" "b",
109 .BI "char *" "message");
110 .TP 15
111 .BI "void setCDKButtonULChar ("
112 .BI "CDKBUTTON *" "b",
113 .BI "chtype " "c");
114 .TP 15
115 .BI "void setCDKButtonURChar ("
116 .BI "CDKBUTTON *" "b",
117 .BI "chtype " "c");
118 .TP 15
119 .BI "void setCDKButtonVerticalChar ("
120 .BI "CDKBUTTON *" "b",
121 .BI "chtype " "c");
122 .TP 15
123 .BI "void moveCDKButton("
124 .BI "CDKBUTTON *" "b",
125 .BI "int " "xpos",
126 .BI "int " "ypos",
127 .BI "boolean " "relative",
128 .BI "boolean " "refresh");
129 .TP 15
130 .BI "void positionCDKButton ("
131 .BI "CDKBUTTON *" "b");
132 .TP 15
133 .BI "void waitCDKButton ("
134 .BI "CDKBUTTON *" "button",
135 .BI "char " "key");
136 .fi
137 .SH DESCRIPTION
138 The Cdk button widget displays a message string and executes a callback when
139 the user presses enter or space.
140 As such, it is only useful on a screen
141 that is being managed by some external screen traversal engine such as
142 \fBtraverseCDKScreen()\fR.
143 The button will be highlighted when the widget has the focus.
144 The following functions create or manipulate the Cdk button widget.
145 .SH AVAILABLE FUNCTIONS
146 .TP 5
147 .B activateCDKButton
148 activates the button widget and lets the user interact with the widget.
149 The parameter \fBbutton\fR is a pointer to a non-NULL button widget.
150 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
151 in the array will be injected into the widget.
152 To activate the widget
153 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
154 If the character entered
155 into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a
156 value from 0 to the number of buttons -1, representing the button selected.
157 It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
158 If the
159 character entered into this widget was \fIESCAPE\fR then the widget will return
160 a value of -1 and the widget data \fIexitType\fR will be set to
161 \fIvESCAPE_HIT\fR.
162 .TP 5
163 .B destroyCDKButton
164 removes the widget from the screen and frees up any memory the
165 object used.
166 .TP 5
167 .B drawCDKButton
168 draws the button widget on the screen.
169 If the \fBbox\fR parameter is true, the widget is drawn with a box.
170 .TP 5
171 .B eraseCDKButton
172 removes the widget from the screen.
173 This does \fINOT\fR destroy the widget.
174 .TP 5
175 .B getCDKButtonBox
176 returns true if the widget will be drawn with a box around it.
177 .TP 5
178 .B getCDKButtonMessage
179 returns the contents of the button widget.
180 .TP 5
181 .B injectCDKButton
182 injects a single character into the widget.
183 The parameter \fBbutton\fR is a pointer to a non-NULL button widget.
184 The parameter \fBcharacter\fR is the character to inject into the widget.
185 The return value and side-effect (setting the widget data \fIexitType\fP)
186 depend upon the injected character:
187 .RS
188 .TP
189 \fIRETURN\fP or \fITAB\fR
190 this function returns 0, representing the button selected.
191 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
192 .TP
193 \fIESCAPE\fP
194 the function returns
195 -1.
196 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
197 .TP
198 Otherwise
199 unless modified by preprocessing, postprocessing or key bindings,
200 the function returns
201 -1.
202 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
203 .RE
204 .TP 5
205 .B moveCDKButton
206 moves the given widget to the given position.
207 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
208 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
209 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
210 The parameter \fBypos\fR may be an integer or one of the pre-defined values
211 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
212 The parameter \fBrelative\fR states whether
213 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
214 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
215 then the widget would move one row down and two columns right.
216 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
217 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
218 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
219 (weird things may happen).
220 The final parameter \fBrefresh\fR is a boolean value which states
221 whether the widget will get refreshed after the move.
222 .TP 5
223 .B newCDKButton
224 creates a pointer to a buttonbox widget.
225 Parameters:
226 .RS
227 .TP 5
228 The \fBscreen\fR parameter
229 is the screen you wish this widget to be placed in.
230 .TP 5
231 \fBxpos\fR
232 controls the placement of the object along the horizontal axis.
233 It may be an integer or one of the pre-defined values
234 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
235 .TP 5
236 \fBypos\fR
237 controls the placement of the object along the vertical axis.
238 It be an integer or one of the pre-defined values
239 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
240 .TP 5
241 \fBmessage\fR
242 is the message to display in the button window,
243 formatted as described in \fIcdk_display\fR.
244 .TP 5
245 \fBcallback\fR
246 is an optional pointer to a callback function
247 that will be executed when the user activates the button by pressing space
248 or enter.
249 .TP 5
250 \fBbox\fR
251 is true if the widget should be drawn with a box around it.
252 .TP 5
253 \fBshadow\fR
254 turns the shadow on or off around this widget.
255 .RE
256 .IP
257 If the widget could not be created then a \fINULL\fR
258 pointer is returned.
259 .TP 5
260 .B positionCDKButton
261 allows the user to move the widget around the screen via the cursor/keypad keys.
262 See \fBcdk_position (3)\fR for key bindings.
263 .TP 5
264 .B setCDKButton
265 lets the programmer modify certain elements of an existing
266 buttonbox widget.
267 The parameter names correspond to the same parameter names listed
268 in the \fBnewCDKButton\fR function.
269 .TP 5
270 .B setCDKButtonBackgroundAttrib
271 sets the background attribute of the widget.
272 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
273 .TP 5
274 .B setCDKButtonBackgroundColor
275 sets the background color of the widget.
276 The parameter \fBcolor\fR
277 is in the format of the Cdk format strings.
278 (See \fIcdk_display\fR).
279 .TP 5
280 .B setCDKButtonBox
281 sets true if the widget will be drawn with a box around it.
282 .TP 5
283 .B setCDKButtonBoxAttribute
284 sets the attribute of the box.
285 .TP 5
286 .B setCDKButtonHorizontalChar
287 sets the horizontal drawing character for the box to the given character.
288 .TP 5
289 .B setCDKButtonLLChar
290 sets the lower left hand corner of the widget's box to the given character.
291 .TP 5
292 .B setCDKButtonLRChar
293 sets the lower right hand corner of the widget's box to the given character.
294 .TP 5
295 .B setCDKButtonMessage
296 This sets the contents of the label widget.
297 .TP 5
298 .B setCDKButtonULChar
299 sets the upper left hand corner of the widget's box to the given character.
300 .TP 5
301 .B setCDKButtonURChar
302 sets the upper right hand corner of the widget's box to the given character.
303 .TP 5
304 .B setCDKButtonVerticalChar
305 sets the vertical drawing character for the box to the given character.
306 .SH BUGS
307 Changing the Box attribute after the widget has been created probably
308 does not work right.
309 None of the positioning/movement code has been tested.
310 .SH AUTHOR
311 Grant Edwards, Aspen Research Corporation
312 .SH SEE ALSO
313 .BR cdk (3),
314 .BR cdk_binding (3),
315 .BR cdk_display (3),
316 .BR cdk_position (3),
317 .BR cdk_process (3),
318 .BR cdk_screen (3),
319 .BR cdk_traverse (3)
0 '\" t
1 .\" $Id: cdk_buttonbox.3,v 1.20 2005/12/28 18:35:31 tom Exp $
2 .de XX
3 ..
4 .TH cdk_buttonbox 3
5 .SH NAME
6 .XX activateCDKButtonbox
7 .XX destroyCDKButtonbox
8 .XX drawCDKButtonbox
9 .XX drawCDKButtonboxButtons
10 .XX eraseCDKButtonbox
11 .XX getCDKButtonboxBox
12 .XX getCDKButtonboxButtonCount
13 .XX getCDKButtonboxCurrentButton
14 .XX getCDKButtonboxHighlight
15 .XX injectCDKButtonbox
16 .XX moveCDKButtonbox
17 .XX newCDKButtonbox
18 .XX positionCDKButtonbox
19 .XX setCDKButtonbox
20 .XX setCDKButtonboxBackgroundAttrib
21 .XX setCDKButtonboxBackgroundColor
22 .XX setCDKButtonboxBox
23 .XX setCDKButtonboxBoxAttribute
24 .XX setCDKButtonboxCurrentButton
25 .XX setCDKButtonboxHighlight
26 .XX setCDKButtonboxHorizontalChar
27 .XX setCDKButtonboxLLChar
28 .XX setCDKButtonboxLRChar
29 .XX setCDKButtonboxPostProcess
30 .XX setCDKButtonboxPreProcess
31 .XX setCDKButtonboxULChar
32 .XX setCDKButtonboxURChar
33 .XX setCDKButtonboxVerticalChar
34 cdk_buttonbox \- Creates a managed curses buttonbox widget.
35 .SH SYNOPSIS
36 .LP
37 .B cc
38 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
39 .B \-lcdk
40 .RI "[ " "library" " \|.\|.\|. ]"
41 .LP
42 #include <cdk.h>
43 .nf
44 .TP 15
45 .B "int activateCDKButtonbox ("
46 .BI "CDKBUTTONBOX *" "buttonbox",
47 .BI "chtype * " "actions");
48 .TP 15
49 .B "void destroyCDKButtonbox ("
50 .BI "CDKBUTTONBOX *" "buttonbox");
51 .TP 15
52 .B "void drawCDKButtonbox ("
53 .BI "CDKBUTTONBOX *" "buttonbox",
54 .BI "boolean " "box");
55 .TP 15
56 .B "void drawCDKButtonboxButtons ("
57 .BI "CDKBUTTONBOX *" "buttonbox");
58 .TP 15
59 .B "void eraseCDKButtonbox ("
60 .BI "CDKBUTTONBOX *" "buttonbox");
61 .TP 15
62 .B "boolean getCDKButtonboxBox ("
63 .BI "CDKBUTTONBOX *" "buttonbox");
64 .TP 15
65 .B "int getCDKButtonboxButtonCount ("
66 .BI "CDKBUTTONBOX *" "buttonbox");
67 .TP 15
68 .B "int getCDKButtonboxCurrentButton ("
69 .BI "CDKBUTTONBOX *" "buttonbox");
70 .TP 15
71 .B "chtype getCDKButtonboxHighlight ("
72 .BI "CDKBUTTONBOX *" "buttonbox");
73 .TP 15
74 .B "int injectCDKButtonbox ("
75 .BI "CDKBUTTONBOX *" "buttonbox",
76 .BI "chtype " "input");
77 .TP 15
78 .B "void moveCDKButtonbox ("
79 .BI "CDKBUTTONBOX *" "buttonbox",
80 .BI "int " "xpos",
81 .BI "int " "ypos",
82 .BI "boolean " "relative",
83 .BI "boolean " "refresh");
84 .TP 15
85 .B "CDKBUTTONBOX *newCDKButtonbox ("
86 .BI "CDKSCREEN *" "cdkscreen",
87 .BI "int " "xpos",
88 .BI "int " "ypos",
89 .BI "int " "height",
90 .BI "int " "width",
91 .BI "char * " "title" ,
92 .BI "int " "rows",
93 .BI "int " "cols",
94 .BI "char ** " "buttons" ,
95 .BI "int " "buttonCount",
96 .BI "chtype " "highlight" ,
97 .BI "boolean " "box",
98 .BI "boolean " "shadow");
99 .TP 15
100 .B "void positionCDKButtonbox ("
101 .BI "CDKBUTTONBOX *" "buttonbox");
102 .TP 15
103 .B "void setCDKButtonbox ("
104 .BI "CDKBUTTONBOX *" "buttonbox",
105 .BI "chtype " "highlight",
106 .BI "boolean " "box");
107 .TP 15
108 .B "void setCDKButtonboxBackgroundAttrib ("
109 .BI "CDKBUTTONBOX *" "buttonbox",
110 .BI "chtype " "attribute");
111 .TP 15
112 .B "void setCDKButtonboxBackgroundColor ("
113 .BI "CDKBUTTONBOX *" "buttonbox",
114 .BI "char * " "color");
115 .TP 15
116 .B "void setCDKButtonboxBox ("
117 .BI "CDKBUTTONBOX *" "buttonbox",
118 .BI "boolean " "box");
119 .TP 15
120 .B "void setCDKButtonboxBoxAttribute ("
121 .BI "CDKBUTTONBOX *" "buttonbox",
122 .BI "chtype " "character");
123 .TP 15
124 .B "void setCDKButtonboxCurrentButton ("
125 .BI "CDKBUTTONBOX *" "buttonbox",
126 .BI "int " "button");
127 .TP 15
128 .B "void setCDKButtonboxHighlight ("
129 .BI "CDKBUTTONBOX *" "buttonbox",
130 .BI "chtype " "highlight");
131 .TP 15
132 .B "void setCDKButtonboxHorizontalChar ("
133 .BI "CDKBUTTONBOX *" "buttonbox",
134 .BI "chtype " "character");
135 .TP 15
136 .B "void setCDKButtonboxLLChar ("
137 .BI "CDKBUTTONBOX *" "buttonbox",
138 .BI "chtype " "character");
139 .TP 15
140 .B "void setCDKButtonboxLRChar ("
141 .BI "CDKBUTTONBOX *" "buttonbox",
142 .BI "chtype " "character");
143 .TP 15
144 .B "void setCDKButtonboxPostProcess ("
145 .BI "CDKBUTTONBOX *" "buttonbox",
146 .BI "PROCESSFN " "callback",
147 .BI "void * " "data");
148 .TP 15
149 .B "void setCDKButtonboxPreProcess ("
150 .BI "CDKBUTTONBOX *" "buttonbox",
151 .BI "PROCESSFN " "callback",
152 .BI "void * " "data");
153 .TP 15
154 .B "void setCDKButtonboxULChar ("
155 .BI "CDKBUTTONBOX *" "buttonbox",
156 .BI "chtype " "character");
157 .TP 15
158 .B "void setCDKButtonboxURChar ("
159 .BI "CDKBUTTONBOX *" "buttonbox",
160 .BI "chtype " "character");
161 .TP 15
162 .B "void setCDKButtonboxVerticalChar ("
163 .BI "CDKBUTTONBOX *" "buttonbox",
164 .BI "chtype " "character");
165 .fi
166 .SH DESCRIPTION
167 The Cdk buttonbox widget creates a buttonbox box with a message and a varied number of
168 buttons to choose from.
169 The following functions create or manipulate the Cdk buttonbox box widget.
170 .SH AVAILABLE FUNCTIONS
171 .TP 5
172 .B activateCDKButtonbox
173 activates the buttonbox widget and lets the user interact with the widget.
174 The parameter \fBbuttonbox\fR is a pointer to a non-NULL buttonbox widget.
175 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
176 in the array will be injected into the widget.
177 To activate the widget
178 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
179 If the character entered
180 into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a
181 value from 0 to the number of buttons -1, representing the button selected.
182 It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
183 If the
184 character entered into this widget was \fIESCAPE\fR then the widget will return
185 a value of -1 and the widget data \fIexitType\fR will be set to
186 \fIvESCAPE_HIT\fR.
187 .TP 5
188 .B destroyCDKButtonbox
189 removes the widget from the screen and releases any memory the
190 object used.
191 .TP 5
192 .B drawCDKButtonbox
193 draws the buttonbox widget on the screen.
194 If the \fBbox\fR parameter is true, the widget is drawn with a box.
195 .TP 5
196 .B drawCDKButtonboxButtons
197 draws the buttons.
198 .TP 5
199 .B eraseCDKButtonbox
200 removes the widget from the screen.
201 This does \fINOT\fR destroy the widget.
202 .TP 5
203 .B getCDKButtonboxBox
204 returns true if the widget will be drawn with a box around it.
205 .TP 5
206 .B getCDKButtonboxButtonCount
207 returns the number of buttons in the button box.
208 .TP 5
209 .B getCDKButtonboxCurrentButton
210 returns the current button-number.
211 .TP 5
212 .B getCDKButtonboxHighlight
213 returns the highlight attribute of the widget.
214 .TP 5
215 .B injectCDKButtonbox
216 injects a single character into the widget.
217 The parameter \fBbuttonbox\fR is a pointer to a non-NULL buttonbox widget.
218 The parameter \fBcharacter\fR is the character to inject into the widget.
219 The return value and side-effect (setting the widget data \fIexitType\fP)
220 depend upon the injected character:
221 .RS
222 .TP
223 \fIRETURN\fP or \fITAB\fR
224 the function returns
225 a value ranging from zero to one less than the number of buttons,
226 representing the button selected.
227 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
228 .TP
229 \fIESCAPE\fP
230 the function returns
231 -1.
232 \fIvESCAPE_HIT\fR.
233 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
234 .TP
235 Otherwise
236 unless modified by preprocessing, postprocessing or key bindings,
237 the function returns
238 -1.
239 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
240 .RE
241 .TP 5
242 .B moveCDKButtonbox
243 moves the given widget to the given position.
244 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
245 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
246 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
247 The parameter \fBypos\fR may be an integer or one of the pre-defined values
248 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
249 The parameter \fBrelative\fR states whether
250 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
251 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
252 then the widget would move one row down and two columns right.
253 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
254 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
255 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
256 (weird things may happen).
257 The final parameter \fBrefresh\fR is a boolean value which states
258 whether the widget will get refreshed after the move.
259 .TP 5
260 .B newCDKButtonbox
261 creates a pointer to a buttonbox widget.
262 Parameters:
263 .RS
264 .TP 5
265 \fBscreen\fR
266 is the screen you wish this widget to be placed in.
267 .TP 5
268 \fBxpos\fR
269 controls the placement of the object along the horizontal axis.
270 It may be an integer or one of the pre-defined values
271 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
272 .TP 5
273 \fBypos\fR
274 controls the placement of the object along the vertical axis.
275 It be an integer value or one of the pre-defined values
276 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
277 .TP 5
278 \fBheight\fR and
279 .TP 5
280 \fBwidth\fR
281 control the height and width of the widget.
282 .TP 5
283 \fBtitle\fR
284 is the title of the widget.
285 .TP 5
286 \fBrows\fR
287 is the number of rows of buttons.
288 .TP 5
289 \fBcols\fR
290 sets the number of columns.
291 .TP 5
292 \fBbuttons\fR
293 is an array containing the button labels.
294 .TP 5
295 \fBbuttonCount\fR
296 is the number of elements in the \fBbuttons\fR array.
297 .TP 5
298 \fBhighlight\fR
299 is the attribute of the currently highlighted button.
300 .TP 5
301 \fBbox\fR
302 is true if the widget should be drawn with a box around it.
303 .TP 5
304 \fBshadow\fR
305 turns the shadow on or off around this widget.
306 .RE
307 .IP
308 If the widget could not be created then a \fINULL\fR
309 pointer is returned.
310 .TP 5
311 .B positionCDKButtonbox
312 allows the user to move the widget around the screen via the cursor/keypad keys.
313 See \fBcdk_position (3)\fR for key bindings.
314 .TP 5
315 .B setCDKButtonbox
316 lets the programmer modify certain elements of an existing
317 buttonbox widget.
318 The parameter names correspond to the same parameter names listed
319 in the \fBnewCDKButtonbox\fR function.
320 .TP 5
321 .B setCDKButtonboxBackgroundAttrib
322 sets the background attribute of the widget.
323 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
324 .TP 5
325 .B setCDKButtonboxBackgroundColor
326 sets the background color of the widget.
327 The parameter \fBcolor\fR
328 is in the format of the Cdk format strings.
329 (See \fIcdk_display\fR).
330 .TP 5
331 .B setCDKButtonboxBox
332 sets true if the widget will be drawn with a box around it.
333 .TP 5
334 .B setCDKButtonboxBoxAttribute
335 sets the attribute of the box.
336 .TP 5
337 .B setCDKButtonboxCurrentButton
338 sets the current button-number for the box.
339 .TP 5
340 .B setCDKButtonboxHighlight
341 sets the highlight attribute of the selected button.
342 .TP 5
343 .B setCDKButtonboxHorizontalChar
344 sets the horizontal drawing character for the box to the given character.
345 .TP 5
346 .B setCDKButtonboxLLChar
347 sets the lower left hand corner of the widget's box to the given character.
348 .TP 5
349 .B setCDKButtonboxLRChar
350 sets the lower right hand corner of the widget's box to the given character.
351 .TP 5
352 .B setCDKButtonboxPostProcess
353 allows the user to have the widget call a function after the
354 key has been applied to the widget.
355 The parameter \fBfunction\fR is the callback function.
356 (See \fIcdk_process\fR).
357 .TP 5
358 .B setCDKButtonboxPreProcess
359 allows the user to have the widget call a function after a key
360 is hit and before the key is applied to the widget.
361 The parameter \fBfunction\fR is the callback function.
362 (See \fIcdk_process\fR).
363 .TP 5
364 .B setCDKButtonboxULChar
365 sets the upper left hand corner of the widget's box to the given character.
366 .TP 5
367 .B setCDKButtonboxURChar
368 sets the upper right hand corner of the widget's box to the given character.
369 .TP 5
370 .B setCDKButtonboxVerticalChar
371 sets the vertical drawing character for the box to the given character.
372 .SH KEY BINDINGS
373 When the widget is activated there are several default key bindings which will
374 help the user enter or manipulate the information quickly.
375 The following table
376 outlines the keys and their actions for this widget.
377 .LP
378 .TS
379 center tab(/) allbox;
380 l l
381 l l
382 lw15 lw35 .
383 \fBKey Action\fR
384 =
385 Left Arrow/T{
386 Selects the button to the left of the current button.
387 T}
388 Right Arrow/T{
389 Selects the button to the right of the current button.
390 T}
391 Tab/T{
392 Selects the button to the right of the current button.
393 T}
394 Space/T{
395 Selects the button to the right of the current button.
396 T}
397 Return/T{
398 Exits the widget and returns the index of the selected button.
399 This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
400 T}
401 Tab/T{
402 Exits the widget and returns the index of the selected button.
403 This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
404 T}
405 Escape/T{
406 Exits the widget and returns -1.
407 This also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
408 T}
409 Ctrl-L/T{
410 Refreshes the screen.
411 T}
412 .TE
413 .SH SEE ALSO
414 .BR cdk (3),
415 .BR cdk_binding (3),
416 .BR cdk_display (3),
417 .BR cdk_position (3),
418 .BR cdk_process (3),
419 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_calendar.3,v 1.22 2005/12/28 18:35:31 tom Exp $"
2 .de XX
3 ..
4 .TH cdk_calendar 3
5 .SH NAME
6 .XX activateCDKCalendar
7 .XX destroyCDKCalendar
8 .XX drawCDKCalendar
9 .XX eraseCDKCalendar
10 .XX getCDKCalendarBox
11 .XX getCDKCalendarDate
12 .XX getCDKCalendarDayAttribute
13 .XX getCDKCalendarHighlight
14 .XX getCDKCalendarMarker
15 .XX getCDKCalendarMonthAttribute
16 .XX getCDKCalendarYearAttribute
17 .XX injectCDKCalendar
18 .XX moveCDKCalendar
19 .XX newCDKCalendar
20 .XX positionCDKCalendar
21 .XX removeCDKCalendarMarker
22 .XX setCDKCalendar
23 .XX setCDKCalendarBackgroundAttrib
24 .XX setCDKCalendarBackgroundColor
25 .XX setCDKCalendarBox
26 .XX setCDKCalendarBoxAttribute
27 .XX setCDKCalendarDate
28 .XX setCDKCalendarDayAttribute
29 .XX setCDKCalendarDaysNames
30 .XX setCDKCalendarHighlight
31 .XX setCDKCalendarHorizontalChar
32 .XX setCDKCalendarLLChar
33 .XX setCDKCalendarLRChar
34 .XX setCDKCalendarMarker
35 .XX setCDKCalendarMonthAttribute
36 .XX setCDKCalendarMonthsNames
37 .XX setCDKCalendarPostProcess
38 .XX setCDKCalendarPreProcess
39 .XX setCDKCalendarULChar
40 .XX setCDKCalendarURChar
41 .XX setCDKCalendarVerticalChar
42 .XX setCDKCalendarYearAttribute
43 cdk_calendar \- curses calendar widget.
44 .SH SYNOPSIS
45 .LP
46 .B cc
47 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
48 .B \-lcdk
49 .RI "[ " "library" " \|.\|.\|. ]"
50 .LP
51 #include <cdk.h>
52 .nf
53 .TP 15
54 .B "time_t activateCDKCalendar (CDKCALENDAR *" "calendar",
55 .BI "chtype " "*actions");
56 .TP 15
57 .B "void destroyCDKCalendar ("
58 .BI "CDKCALENDAR *" "calendar");
59 .TP 15
60 .B "void drawCDKCalendar (CDKCALENDAR *" "calendar",
61 .BI "boolean " "box");
62 .TP 15
63 .B "void eraseCDKCalendar ("
64 .BI "CDKCALENDAR *" "calendar");
65 .TP 15
66 .B "boolean getCDKCalendarBox ("
67 .BI "CDKCALENDAR *" "calendar");
68 .TP 15
69 .B "void getCDKCalendarDate (CDKCALENDAR *" "calendar",
70 .BI "int *" "day",
71 .BI "int *" "month",
72 .BI "int *" "year");
73 .TP 15
74 .B "chtype getCDKCalendarDayAttribute ("
75 .BI "CDKCALENDAR *" "calendar");
76 .TP 15
77 .B "chtype getCDKCalendarHighlight ("
78 .BI "CDKCALENDAR *" "calendar");
79 .TP 15
80 .B "chtype getCDKCalendarMarker ("
81 .BI "CDKCALENDAR *" "calendar",
82 .BI "int " "day",
83 .BI "int " "month",
84 .BI "int " "year");
85 .TP 15
86 .B "chtype getCDKCalendarMonthAttribute ("
87 .BI "CDKCALENDAR *" "calendar");
88 .TP 15
89 .B "chtype getCDKCalendarYearAttribute ("
90 .BI "CDKCALENDAR *" "calendar");
91 .TP 15
92 .B "time_t injectCDKCalendar ("
93 .BI "CDKCALENDAR *" "calendar",
94 .BI "chtype " "input");
95 .TP 15
96 .B "void moveCDKCalendar ("
97 .BI "CDKCALENDAR *" "calendar",
98 .BI "int " "xpos",
99 .BI "int " "ypos",
100 .BI "boolean " "relative",
101 .BI "boolean " "refresh");
102 .TP 15
103 .B "CDKCALENDAR *newCDKCalendar (CDKSCREEN *" "cdkscreen",
104 .BI "int " "xpos",
105 .BI "int " "ypos",
106 .BI "char *" "title",
107 .BI "int " "day",
108 .BI "int " "month",
109 .BI "int " "year",
110 .BI "chtype " "dayAttrib",
111 .BI "chtype " "monthAttrib",
112 .BI "chtype " "yearAttrib",
113 .BI "chtype " "highlight",
114 .BI "boolean " "box",
115 .BI "boolean " "shadow");
116 .TP 15
117 .B "void positionCDKCalendar ("
118 .BI "CDKCALENDAR *" "calendar");
119 .TP 15
120 .B "void removeCDKCalendarMarker ("
121 .BI "CDKCALENDAR *" "calendar",
122 .BI "int " "day",
123 .BI "int " "month",
124 .BI "int " "year");
125 .TP 15
126 .B "void setCDKCalendar ("
127 .BI "CDKCALENDAR *" "calendar",
128 .BI "int " "day",
129 .BI "int " "month",
130 .BI "int " "year",
131 .BI "chtype " "dayAttrib",
132 .BI "chtype " "monthAttrib",
133 .BI "chtype " "yearAttrib",
134 .BI "chtype " "highlight",
135 .BI "boolean " "box");
136 .TP 15
137 .B "void setCDKCalendarBackgroundAttrib ("
138 .BI "CDKCALENDAR *" "calendar",
139 .BI "chtype " "attribute");
140 .TP 15
141 .B "void setCDKCalendarBackgroundColor ("
142 .BI "CDKCALENDAR *" "calendar",
143 .BI "char * " "color");
144 .TP 15
145 .B "void setCDKCalendarBox ("
146 .BI "CDKCALENDAR *" "calendar",
147 .BI "boolean " "box");
148 .TP 15
149 .B setCDKCalendarBoxAttribute ("
150 .BI "CDKCALENDAR *" "calendar",
151 .BI "chtype " "ch");
152 .TP 15
153 .B "void setCDKCalendarDate ("
154 .BI "CDKCALENDAR *" "calendar",
155 .BI "int " "day",
156 .BI "int " "month",
157 .BI "int " "year");
158 .TP 15
159 .B "void setCDKCalendarDayAttribute ("
160 .BI "CDKCALENDAR *" "calendar",
161 .BI "chtype " "attribute");
162 .TP
163 .B "void setCDKCalendarDaysNames ("
164 .BI "CDKCALENDAR *" "calendar",
165 .BI "char *" "days");
166 .TP 15
167 .B "void setCDKCalendarHighlight ("
168 .BI "CDKCALENDAR *" "calendar",
169 .BI "chtype " "attribute");
170 .TP 15
171 .B "void setCDKCalendarHorizontalChar ("
172 .BI "CDKCALENDAR *" "calendar",
173 .BI "chtype " "ch");
174 .TP 15
175 .B "void setCDKCalendarLLChar ("
176 .BI "CDKCALENDAR *" "calendar",
177 .BI "chtype " "ch");
178 .TP 15
179 .B "void setCDKCalendarLRChar ("
180 .BI "CDKCALENDAR *" "calendar",
181 .BI "chtype " "ch");
182 .TP 15
183 .B "void setCDKCalendarMarker ("
184 .BI "CDKCALENDAR *" "calendar",
185 .BI "int " "day",
186 .BI "int " "month",
187 .BI "int " "year",
188 .BI "chtype " "marker");
189 .TP 15
190 .B "void setCDKCalendarMonthAttribute ("
191 .BI "CDKCALENDAR *" "calendar",
192 .BI "chtype " "attribute");
193 .TP
194 .B "void setCDKCalendarMonthsNames ("
195 .BI "CDKCALENDAR *" "calendar",
196 .BI "char **" "months");
197 .TP 15
198 .B "void setCDKCalendarPostProcess ("
199 .BI "CDKCALENDAR *" "calendar",
200 .BI "PROCESSFN " "callback",
201 .BI "void * " "data");
202 .TP 15
203 .B "void setCDKCalendarPreProcess ("
204 .BI "CDKCALENDAR *" "calendar",
205 .BI "PROCESSFN " "callback",
206 .BI "void * " "data");
207 .TP 15
208 .B setCDKCalendarULChar ("
209 .BI "CDKCALENDAR *" "calendar",
210 .BI "chtype " "ch");
211 .TP 15
212 .B setCDKCalendarURChar ("
213 .BI "CDKCALENDAR *" "calendar",
214 .BI "chtype " "ch");
215 .TP 15
216 .B setCDKCalendarVerticalChar ("
217 .BI "CDKCALENDAR *" "calendar",
218 .BI "chtype " "ch");
219 .TP 15
220 .B "void setCDKCalendarYearAttribute ("
221 .BI "CDKCALENDAR *" "calendar",
222 .BI "chtype " "attribute");
223 .fi
224 .SH DESCRIPTION
225 The Cdk calendar widget creates a pop-up calendar.
226 The calendar widget allows the user to traverse through
227 months/years using the cursor keys.
228 .SH AVAILABLE FUNCTIONS
229 .TP 5
230 .B activateCDKCalendar
231 activates the calendar widget and lets the user interact with the widget.
232 The \fBcalendar\fR widget is a pointer to a non-NULL calendar widget.
233 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
234 in the array will be injected into the widget.
235 To activate the widget
236 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
237 If the character
238 entered into this widget is \fIRETURN\fR then this function will return a type
239 of \fItime_t\fR.
240 The \fItime_t\fR type is used in the functions defined in the
241 time.h header file.
242 (see \fIlocaltime\fR or \fIctime\fR for more information).
243 If the character entered into this widget was \fIESCAPE\fR or
244 \fITAB\fR then this function will return a value of (time_t)-1
245 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR.
246 .TP 5
247 .B destroyCDKCalendar
248 removes the widget from the screen and frees memory the object used.
249 .TP 5
250 .B drawCDKCalendar
251 draws the label widget on the screen.
252 If the \fBbox\fR parameter is true, the widget is drawn with a box.
253 .TP 5
254 .B eraseCDKCalendar
255 removes the widget from the screen.
256 This does \fINOT\fR destroy the widget.
257 .TP 5
258 .B getCDKCalendarBox
259 returns whether the widget will be drawn with a box around it.
260 .TP 5
261 .B getCDKCalendarDate
262 returns the current date the calendar is displaying.
263 .TP 5
264 .B getCDKCalendarDayAttribute
265 returns the attribute of the day attribute of the calendar.
266 .TP 5
267 .B getCDKCalendarHighlight
268 returns the attribute of the highlight bar of the scrolling
269 list portion of the widget.
270 .TP
271 .B getCDKCalendarMarker
272 returns the marker set on the calendar by \fBsetCDKCalendarMarker\fP.
273 .TP 5
274 .B getCDKCalendarMonthAttribute
275 returns the attribute of the month attribute of the calendar.
276 .TP 5
277 .B getCDKCalendarYearAttribute
278 returns the attribute of the year attribute of the calendar.
279 .TP 5
280 .B injectCDKCalendar
281 injects a single character into the widget.
282 The parameter \fBcalendar\fR is a pointer to a non-NULL calendar widget.
283 The parameter \fBcharacter\fR is the character to inject into the widget.
284 The return value and side-effect (setting the widget data \fIexitType\fP)
285 depend upon the injected character:
286 .RS
287 .TP
288 \fIRETURN\fP or \fITAB\fR
289 the function returns
290 a value of type \fItime_t\fR
291 (see \fIlocaltime\fR or \fIctime\fR for more information).
292 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
293 .TP
294 \fIESCAPE\fP
295 the function returns
296 (time_t)-1.
297 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
298 .TP
299 Otherwise
300 unless modified by preprocessing, postprocessing or key bindings,
301 the function returns
302 (time_t)-1.
303 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
304 .RE
305 .TP 5
306 .B moveCDKCalendar
307 moves the given widget to the given position.
308 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
309 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
310 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
311 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
312 \fIRIGHT\fR, and \fICENTER\fR.
313 The parameter \fBrelative\fR states whether
314 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
315 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
316 then the widget would move one row down and two columns right.
317 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
318 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
319 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
320 (weird things may happen).
321 The final parameter \fBrefresh\fR is a boolean value which
322 states whether the widget will get refreshed after the move.
323 .TP 5
324 .B newCDKCalendar
325 creates a calendar widget and returns a pointer to it.
326 Parameters:
327 .RS
328 .TP 5
329 \fBscreen\fR
330 is the screen you wish this widget to be placed in.
331 .TP 5
332 \fBxpos\fR
333 controls the placement of the object along the horizontal axis.
334 It may be an integer or one of the pre-defined values
335 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
336 .TP 5
337 \fBypos\fR
338 controls the placement of the object along the vertical axis.
339 It may be an integer or one of the pre-defined values
340 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
341 .TP 5
342 \fBtitle\fR
343 is the string which will be displayed at the top of the widget.
344 The title can be more than one line; just
345 provide a carriage return character at the line break.
346 .TP 5
347 \fByear\fR,
348 .TP 5
349 \fBmonth\fR and
350 .TP 5
351 \fBday\fR
352 .br
353 set the initial date of the calendar.
354 .TP 5
355 \fByearAttrib\fR,
356 .TP 5
357 \fBmonthAttrib\fR and
358 .TP 5
359 \fBdayAttrib\fR
360 represent the attributes of the year, month, and day respectively.
361 .TP 5
362 \fBhighlight\fR
363 sets the highlight of the currently selected day.
364 .TP 5
365 \fBbox\fR
366 is true if the widget should be drawn with a box around it.
367 .TP 5
368 \fBshadow\fR
369 turns the shadow on or off around this widget.
370 .RE
371 .IP
372 If the widget could not be created
373 then a \fINULL\fR pointer is returned.
374 .TP 5
375 .B positionCDKCalendar
376 allows the user to move the widget around the screen via the cursor/keypad keys.
377 See \fBcdk_position (3)\fR for key bindings.
378 .TP 5
379 .B removeCDKCalendarMarker
380 removes a marker from the calendar.
381 .TP 5
382 .B setCDKCalendar
383 lets the programmer modify certain elements of an existing
384 calendar widget.
385 The \fBcalendar\fR parameter represents an existing calendar pointer.
386 The other parameter names correspond to the same parameter names listed
387 in the \fBnewCDKCalendar\fR function.
388 .TP 5
389 .B setCDKCalendarBackgroundAttrib
390 sets the background attribute of the widget.
391 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
392 .TP 5
393 .B setCDKCalendarBackgroundColor
394 sets the background color of the widget.
395 The parameter \fBcolor\fR
396 is in the format of the Cdk format strings.
397 See \fBcdk_display (3)\fR.
398 .TP 5
399 .B setCDKCalendarBox
400 sets whether the widget will be drawn with a box around it.
401 .TP 5
402 .B setCDKCalendarBoxAttribute
403 sets the attribute of the box.
404 .TP 5
405 .B setCDKCalendarDate
406 sets the calendar to the given date.
407 If the value of the \fBday\fR,
408 \fBmonth\fR, or \fByear\fR parameters is -1 then the current day, month, or year
409 is used to set the date.
410 .TP 5
411 .B setCDKCalendarDayAttribute
412 sets the attribute of the day in the calendar.
413 .TP
414 .B setCDKCalendarDaysNames
415 sets the names of the days of the week.
416 The parameter is a string listing the 2-character abbreviations for the
417 days.
418 The default value is
419 .RS
420 "Su Mo Tu We Th Fr Sa"
421 .RE
422 .TP 5
423 .B setCDKCalendarHighlight
424 sets the attribute of the highlight bar of the scrolling
425 list portion of the widget.
426 .TP 5
427 .B setCDKCalendarHorizontalChar
428 sets the horizontal drawing character for the box to
429 the given character.
430 .TP 5
431 .B setCDKCalendarLLChar
432 sets the lower left hand corner of the widget's box to
433 the given character.
434 .TP 5
435 .B setCDKCalendarLRChar
436 sets the lower right hand corner of the widget's box to
437 the given character.
438 .TP 5
439 .B setCDKCalendarMarker
440 allows the user to set a marker which will be displayed when the month is drawn.
441 The \fBmarker\fR parameter is the attribute to use when drawing the marker.
442 If more than one marker is set on a single day, then the day will blink
443 with the original marker attribute.
444 .TP 5
445 .B setCDKCalendarMonthAttribute
446 sets the attribute of the month in the calendar.
447 .TP
448 .B setCDKCalendarMonthsNames
449 sets the names of the months of the year.
450 The parameter is a 13-element array (since indexing starts with 1).
451 The default values are the English month names, e.g., "January".
452 .TP 5
453 .B setCDKCalendarPostProcess
454 allows the user to have the widget call a function after the
455 key has been applied to the widget.
456 The parameter \fBfunction\fR is the callback function.
457 The parameter \fBdata\fR points to data passed to the callback function.
458 To learn more about post-processing see \fIcdk_process (3)\fR.
459 .TP 5
460 .B setCDKCalendarPreProcess
461 allows the user to have the widget call a function after a key
462 is hit and before the key is applied to the widget.
463 The parameter \fBfunction\fR is the callback function.
464 The parameter \fBdata\fR points to data passed to the callback function.
465 To learn more about pre-processing see \fIcdk_process (3)\fR.
466 .TP 5
467 .B setCDKCalendarULChar
468 sets the upper left hand corner of the widget's box to
469 the given character.
470 .TP 5
471 .B setCDKCalendarURChar
472 sets the upper right hand corner of the widget's box to
473 the given character.
474 .TP 5
475 .B setCDKCalendarVerticalChar
476 sets the vertical drawing character for the box to
477 the given character.
478 .TP 5
479 .B setCDKCalendarYearAttribute
480 sets the attribute of the year in the calendar.
481 .SH KEY BINDINGS
482 When the widget is activated there are several default key bindings which will
483 help the user enter or manipulate the information quickly.
484 The following table
485 outlines the keys and their actions for this widget.
486 .LP
487 .TS
488 center tab(/) allbox;
489 l l
490 l l
491 lw15 lw35 .
492 \fBKey/Action\fR
493 =
494 Left Arrow/Moves the cursor to the previous day.
495 Right Arrow/Moves the cursor to the next day.
496 Up Arrow/Moves the cursor to the next week.
497 Down Arrow/Moves the cursor to the previous week.
498 t/Sets the calendar to the current date.
499 T/Sets the calendar to the current date.
500 n/Advances the calendar one month ahead.
501 N/Advances the calendar six months ahead.
502 p/Advances the calendar one month back.
503 P/Advances the calendar six months back.
504 -/Advances the calendar one year ahead.
505 +/Advances the calendar one year back.
506 Return/T{
507 Exits the widget and returns a value of \fItime_t\fR which represents the day selected at 1 second after midnight.
508 This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
509 T}
510 Tab/T{
511 Exits the widget and returns a value of \fItime_t\fR which represents the day selected at 1 second after midnight.
512 This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
513 T}
514 Escape/T{
515 Exits the widget and returns (time_)-1.
516 This also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
517 T}
518 Ctrl-L/Refreshes the screen.
519 .TE
520 .SH SEE ALSO
521 .BR cdk (3),
522 .BR cdk_binding (3),
523 .BR cdk_display (3),
524 .BR cdk_position (3),
525 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_compat.3,v 1.4 2005/12/28 21:52:07 tom Exp $
2 .de XX
3 ..
4 .TH cdk_compat 3
5 .SH NAME
6 .XX getDirectoryContents
7 .XX readFile
8 .XX splitString
9 cdk_compat \- Cdk4 compatibility functions
10 .SH SYNOPSIS
11 .SH SYNOPSIS
12 .LP
13 .B cc
14 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
15 .B \-lcdk
16 .RI "[ " "library" " \|.\|.\|. ]"
17 .LP
18 #include <cdk_compat.h>
19 .nf
20 .TP 15
21 .B "int getDirectoryContents ("
22 .BI "char *directory",
23 .BI "char **list",
24 .BI "int " "maxListSize");
25 .TP 15
26 .B "int readFile ("
27 .BI "char *" "filename",
28 .BI "char **" "info",
29 .BI "int " "maxlines");
30 .TP 15
31 .B "int splitString ("
32 .BI "char *" "string",
33 .BI "char **" "items",
34 .BI "char " "splitChar");
35 .fi
36 .SH DESCRIPTION
37 These functions and macros make it simpler to port applications from
38 the older Cdk4 library to Cdk5.
39 .PP
40 A few functions are deprecated in Cdk5,
41 because they rely upon the caller to know in advance the size of
42 data which will be returned by the function.
43 .PP
44 Additionally, some macros are deprecated because they serve no
45 realistic purpose: they have direct (standard) equivalents in all modern
46 curses implementations.
47 .PP
48 Finally, a few macro definitions are added to iron out naming inconsistencies
49 across the Cdk4 header files.
50 .
51 .SH AVAILABLE FUNCTIONS
52 .TP 5
53 .B getDirectoryContents
54 This opens the current directory and reads the contents.
55 Use \fBCDKgetDirectoryContents()\fP in new code.
56 .TP 5
57 .B readFile
58 This reads a file and sticks it into the \fBchar\ **\fP provided.
59 Use \fBCDKreadFile()\fP for new code.
60 .TP 5
61 .B splitString
62 This splits a string into one or more parts given the split character.
63 Use \fBCDKsplitString()\fP for new code.
64 .
65 .SH EXAMPLE
66 Start the porting process by changing the \fB#include\fP's to use
67 .RS
68 #include <cdk_compat.h>
69 .RE
70 .PP
71 rather than
72 .RS
73 #include <cdk.h>
74 .RE
75 Some adjustments of course are needed to make your compiler see the
76 compatibility header file.
77 A separate name was chosen so that it in turn can (by adjusting the
78 include path) include either the old Cdk4 \fBcdk.h\fP or the new.
79 If the old is included, you should link your program against the old library.
80 Likewise, including the new requires that you link against the new library.
81 .PP
82 That is the first step: making your program compile using the compatibility
83 header file using the old headers and library.
84 .PP
85 The next step is to get it to compile against the new headers and library.
86 Most of the changes will require modifying bare references to certain
87 pointers to wrap them with the \fBObjOf()\fP and \fBScreenOf()\fP macros.
88 New Cdk uses these to provide functions which are easily shared among
89 the different widget types.
90 Your compiler should be able to tell you where the changes should be made.
91 See the example programs which are included with Cdk as a guide.
92 .PP
93 That is the hard part of porting. But even for a large program, the
94 changes can be made simply: there are not that many types of change to make.
95 At the end of this step, you should still be able to build and run your
96 program against the old headers and library.
97 It is reasonably likely that you can do the same with the new headers and
98 library.
99 By using the same source for old/new versions of Cdk, you can test and
100 verify that your program still works properly after these modifications.
101 .PP
102 Finally, unless this is a purely academic exercise, you will want to
103 remove references to the deprecated functions and macros.
104 .
105 .SH SEE ALSO
106 cdk_objs (3),
107 cdk_util (3)
0 '\" t
1 .\" $Id: cdk_dialog.3,v 1.18 2005/12/28 18:35:31 tom Exp $
2 .de XX
3 ..
4 .TH cdk_dialog 3
5 .SH NAME
6 .XX activateCDKDialog
7 .XX destroyCDKDialog
8 .XX drawCDKDialog
9 .XX drawCDKDialogButtons
10 .XX eraseCDKDialog
11 .XX getCDKDialog
12 .XX getCDKDialogBox
13 .XX getCDKDialogHighlight
14 .XX getCDKDialogSeparator
15 .XX injectCDKDialog
16 .XX moveCDKDialog
17 .XX newCDKDialog
18 .XX positionCDKDialog
19 .XX setCDKDialog
20 .XX setCDKDialogBackgroundAttrib
21 .XX setCDKDialogBackgroundColor
22 .XX setCDKDialogBox
23 .XX setCDKDialogBox
24 .XX setCDKDialogBoxAttribute
25 .XX setCDKDialogHighlight
26 .XX setCDKDialogHorizontalChar
27 .XX setCDKDialogLLChar
28 .XX setCDKDialogLRChar
29 .XX setCDKDialogPostProcess
30 .XX setCDKDialogPreProcess
31 .XX setCDKDialogSeparator
32 .XX setCDKDialogULChar
33 .XX setCDKDialogURChar
34 .XX setCDKDialogVerticalChar
35 cdk_dialog \- curses dialog widget
36 .SH SYNOPSIS
37 .LP
38 .B cc
39 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
40 .B \-lcdk
41 .RI "[ " "library" " \|.\|.\|. ]"
42 .LP
43 #include <cdk.h>
44 .nf
45 .TP 15
46 .B "int activateCDKDialog ("
47 .BI "CDKDIALOG *" "dialog",
48 .BI "chtype * " "actions");
49 .TP 15
50 .B "void destroyCDKDialog ("
51 .BI "CDKDIALOG *" "dialog");
52 .TP 15
53 .B "void drawCDKDialog ("
54 .BI "CDKDIALOG *" "dialog",
55 .BI "boolean " "box");
56 .TP 15
57 .B "void drawCDKDialogButtons ("
58 .BI "CDKDIALOG *" "dialog");
59 .TP 15
60 .B "void eraseCDKDialog ("
61 .BI "CDKDIALOG *" "dialog");
62 .TP 15
63 .B "boolean getCDKDialog ("
64 .BI "CDKDIALOG *" "dialog");
65 .TP 15
66 .B "boolean getCDKDialogBox ("
67 .BI "CDKDIALOG *" "dialog");
68 .TP 15
69 .B "chtype getCDKDialogHighlight ("
70 .BI "CDKDIALOG *" "dialog");
71 .TP 15
72 .B "boolean getCDKDialogSeparator ("
73 .BI "CDKDIALOG *" "dialog");
74 .TP 15
75 .B "int injectCDKDialog ("
76 .BI "CDKDIALOG *" "dialog",
77 .BI "chtype " "input");
78 .TP 15
79 .B "void moveCDKDialog ("
80 .BI "CDKDIALOG *" "dialog",
81 .BI "int " "xpos",
82 .BI "int " "ypos",
83 .BI "boolean " "relative",
84 .BI "boolean " "refresh");
85 .TP 15
86 .B "CDKDIALOG *newCDKDialog ("
87 .BI "CDKSCREEN *" "cdkscreen",
88 .BI "int " "xpos",
89 .BI "int " "ypos",
90 .BI "char ** " "message" ,
91 .BI "int " "rows",
92 .BI "char ** " "buttons" ,
93 .BI "int " "buttonCount",
94 .BI "chtype " "highlight" ,
95 .BI "boolean " "separator",
96 .BI "boolean " "box",
97 .BI "boolean " "shadow");
98 .TP 15
99 .B "void positionCDKDialog ("
100 .BI "CDKDIALOG *" "dialog");
101 .TP 15
102 .B "void setCDKDialogBox ("
103 .BI "CDKDIALOG *" "dialog",
104 .BI "boolean " "boxWidget");
105 .TP 15
106 .B "void setCDKDialog ("
107 .BI "CDKDIALOG *" "dialog",
108 .BI "chtype " "highlight",
109 .BI "boolean " "separator",
110 .BI "boolean " "box");
111 .TP 15
112 .B "void setCDKDialogBackgroundAttrib ("
113 .BI "CDKDIALOG *" "dialog",
114 .BI "chtype " "attribute");
115 .TP 15
116 .B "void setCDKDialogBackgroundColor ("
117 .BI "CDKDIALOG *" "dialog",
118 .BI "char * " "color");
119 .TP 15
120 .B "void setCDKDialogBox ("
121 .BI "CDKDIALOG *" "dialog",
122 .BI "boolean " "box");
123 .TP 15
124 .B "void setCDKDialogBoxAttribute ("
125 .BI "CDKDIALOG *" "dialog",
126 .BI "chtype " "character");
127 .TP 15
128 .B "void setCDKDialogHighlight ("
129 .BI "CDKDIALOG *" "dialog",
130 .BI "chtype " "highlight");
131 .TP 15
132 .B "void setCDKDialogHorizontalChar ("
133 .BI "CDKDIALOG *" "dialog",
134 .BI "chtype " "character");
135 .TP 15
136 .B "void setCDKDialogLLChar ("
137 .BI "CDKDIALOG *" "dialog",
138 .BI "chtype " "character");
139 .TP 15
140 .B "void setCDKDialogLRChar ("
141 .BI "CDKDIALOG *" "dialog",
142 .BI "chtype " "character");
143 .TP 15
144 .B "void setCDKDialogPostProcess ("
145 .BI "CDKDIALOG *" "dialog",
146 .BI "PROCESSFN " "callback",
147 .BI "void * " "data");
148 .TP 15
149 .B "void setCDKDialogPreProcess ("
150 .BI "CDKDIALOG *" "dialog",
151 .BI "PROCESSFN " "callback",
152 .BI "void * " "data");
153 .TP 15
154 .B "void setCDKDialogSeparator ("
155 .BI "CDKDIALOG *" "dialog",
156 .BI "boolean " "separator");
157 .TP 15
158 .B "void setCDKDialogULChar ("
159 .BI "CDKDIALOG *" "dialog",
160 .BI "chtype " "character");
161 .TP 15
162 .B "void setCDKDialogURChar ("
163 .BI "CDKDIALOG *" "dialog",
164 .BI "chtype " "character");
165 .TP 15
166 .B "void setCDKDialogVerticalChar ("
167 .BI "CDKDIALOG *" "dialog",
168 .BI "chtype " "character");
169 .fi
170 .SH DESCRIPTION
171 The Cdk dialog widget creates a dialog box with a message and a varied number of
172 buttons to choose from.
173 The following functions create or manipulate the Cdk dialog box widget.
174 .PP
175 .SH AVAILABLE FUNCTIONS
176 .TP 5
177 .B activateCDKDialog
178 activates the dialog widget and lets the user interact with the widget.
179 The parameter \fBdialog\fR is a pointer to a non-NULL dialog widget.
180 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
181 in the array will be injected into the widget.
182 To activate the widget
183 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
184 If the character entered
185 into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a
186 value from 0 to the number of buttons -1, representing the button selected.
187 It also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
188 If the character entered into this widget was \fIESCAPE\fR then the widget returns
189 a value of -1 and the widget data \fIexitType\fR will be set to
190 \fIvESCAPE_HIT\fR.
191 .TP 5
192 .B destroyCDKDialog
193 removes the widget from the screen and frees memory the object used.
194 .TP 5
195 .B drawCDKDialog
196 draws the dialog widget on the screen.
197 If the \fBbox\fR parameter is true, the widget is drawn with a box.
198 .TP 5
199 .B drawCDKDialogButtons
200 draws the dialog buttons and the separation line.
201 .TP 5
202 .B eraseCDKDialog
203 removes the widget from the screen.
204 This does \fINOT\fR destroy the widget.
205 .TP 5
206 .B getCDKDialog
207 returns true if the list will be drawn with a box around it.
208 .TP 5
209 .B getCDKDialogBox
210 returns true if the dialog will be drawn with a box around it.
211 .TP 5
212 .B getCDKDialogHighlight
213 returns the highlight attribute of the widget.
214 .TP 5
215 .B getCDKDialogSeparator
216 returns the state of the separator flag.
217 .TP 5
218 .B injectCDKDialog
219 injects a single character into the widget.
220 The parameter \fBdialog\fR is a pointer to a non-NULL dialog widget.
221 The parameter \fBcharacter\fR is the character to inject into the widget.
222 The return value and side-effect (setting the widget data \fIexitType\fP)
223 depend upon the injected character:
224 .RS
225 .TP
226 \fIRETURN\fP or \fITAB\fR
227 the function returns
228 a value from zero to one less than the number of buttons,
229 representing the button selected.
230 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
231 .TP
232 \fIESCAPE\fP
233 the function returns
234 -1.
235 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
236 .TP
237 Otherwise
238 unless modified by preprocessing, postprocessing or key bindings,
239 the function returns
240 -1.
241 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
242 .RE
243 .TP 5
244 .B moveCDKDialog
245 moves the given widget to the given position.
246 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
247 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
248 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
249 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
250 \fIRIGHT\fR, and \fICENTER\fR.
251 The parameter \fBrelative\fR states whether
252 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
253 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
254 then the widget would move one row down and two columns right.
255 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
256 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
257 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
258 (weird things may happen).
259 The final parameter \fBrefresh\fR is a boolean value which states
260 whether the widget will get refreshed after the move.
261 .TP 5
262 .B newCDKDialog
263 creates a dialog widget and returns a pointer to it.
264 Parameters:
265 .RS
266 .TP 5
267 \fBscreen\fR
268 is the screen you wish this widget to be placed in.
269 .TP 5
270 \fBxpos\fR
271 controls the placement of the object along the horizontal axis.
272 It may be integer or one of the pre-defined values
273 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
274 .TP 5
275 \fBypos\fR
276 controls the placement of the object along the vertical axis.
277 It may be an integer or one of the pre-defined values
278 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
279 .TP 5
280 \fBmessage\fR
281 is the text to be displayed in the message region of the dialog box.
282 .TP 5
283 \fBrows\fR
284 is the number of elements in the \fBmessage\fR list.
285 .TP 5
286 \fBbuttons\fR
287 is an array containing the button labels
288 to be displayed on the bottom of the dialog box.
289 .TP 5
290 \fBbuttonCount\fR
291 is the number of elements in the \fBbuttons\fR array.
292 .TP 5
293 \fBhighlight\fR
294 is the attribute of the currently highlighted button.
295 .TP 5
296 \fBbox\fR
297 is true if the widget should be drawn with a box around it.
298 .TP 5
299 \fBseparator\fR
300 is true if a separator line should be drawn between the message region and the buttons.
301 .TP 5
302 \fBshadow\fR
303 turns the shadow on or off around this widget.
304 .RE
305 .IP
306 If the widget could not be created then a \fINULL\fR
307 pointer is returned.
308 .TP 5
309 .B positionCDKDialog
310 allows the user to move the widget around the screen via the
311 cursor/keypad keys.
312 See \fBcdk_position (3)\fR for key bindings.
313 .TP 5
314 .B setCDKDialogBox
315 sets whether the widget will be drawn with a box around it.
316 .TP 5
317 .B setCDKDialog
318 lets the programmer modify certain elements of an existing
319 dialog widget.
320 The parameter names correspond to the same parameter names listed
321 in the \fBnewCDKDialog\fR function.
322 .TP 5
323 .B setCDKDialogBackgroundAttrib
324 sets the background attribute of the widget.
325 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
326 .TP 5
327 .B setCDKDialogBackgroundColor
328 sets the background color of the widget.
329 The parameter \fBcolor\fR
330 is in the format of the Cdk format strings.
331 See \fBcdk_display (3)\fR.
332 .B setCDKDialogBox
333 sets the box attribute of the dialog widget.
334 .TP 5
335 .B setCDKDialogBoxAttribute
336 function sets the attribute of the box.
337 .TP 5
338 .B setCDKDialogHighlight
339 sets the highlight attribute of the selected button.
340 .TP 5
341 .B setCDKDialogHorizontalChar
342 sets the horizontal drawing character for the box to
343 the given character.
344 .TP 5
345 .B setCDKDialogLLChar
346 sets the lower left hand corner of the widget's box to
347 the given character.
348 .TP 5
349 .B setCDKDialogLRChar
350 sets the lower right hand corner of the widget's box to
351 the given character.
352 .TP 5
353 .B setCDKDialogPreProcess
354 allows the user to have the widget call a function after a key
355 is hit and before the key is applied to the widget.
356 The parameter \fBfunction\fR is the callback function.
357 The parameter \fBdata\fR is a pointer to
358 \fIvoid\fR.
359 To learn more about pre-processing see \fIcdk_process (3)\fR.
360 .TP 5
361 .B setCDKDialogPostProcess
362 allows the user to have the widget call a function after the
363 key has been applied to the widget.
364 The parameter \fBfunction\fR is the callback function.
365 The parameter \fBdata\fR points to data passed to the callback function.
366 To learn more about post-processing see \fIcdk_process (3)\fR.
367 .TP 5
368 .B setCDKDialogSeparator
369 sets the boolean flag whether the widget will be drawn with the
370 separator bar between the buttons and the message area.
371 .TP 5
372 .B setCDKDialogULChar
373 function sets the upper left hand corner of the widget's box to
374 the given character.
375 .TP 5
376 .B setCDKDialogURChar
377 sets the upper right hand corner of the widget's box to
378 the given character.
379 .TP 5
380 .B setCDKDialogVerticalChar
381 sets the vertical drawing character for the box to
382 the given character.
383 .SH KEY BINDINGS
384 When the widget is activated there are several default key bindings which will
385 help the user enter or manipulate the information quickly.
386 The following table
387 outlines the keys and their actions for this widget.
388 .LP
389 .TS
390 center tab(/) allbox;
391 l l
392 l l
393 lw15 lw35 .
394 \fBKey/Action\fR
395 =
396 Left Arrow/T{
397 Selects the button to the left of the current button.
398 T}
399 Right Arrow/T{
400 Selects the button to the right of the current button.
401 T}
402 Tab/T{
403 Selects the button to the right of the current button.
404 T}
405 Space/T{
406 Selects the button to the right of the current button.
407 T}
408 Return/T{
409 Exits the widget and returns the index of the selected button.
410 This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
411 T}
412 Tab/T{
413 Exits the widget and returns the index of the selected button.
414 This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
415 T}
416 Escape/T{
417 Exits the widget and returns -1.
418 This also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
419 T}
420 Ctrl-L/Refreshes the screen.
421 .TE
422 .SH SEE ALSO
423 .BR cdk (3),
424 .BR cdk_binding (3),
425 .BR cdk_display (3),
426 .BR cdk_position (3),
427 .BR cdk_process (3),
428 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_display.3,v 1.11 2006/04/17 10:45:02 tom Exp $
2 .de It
3 .br
4 .ie \\n(.$>=3 .ne \\$3
5 .el .ne 3
6 .IP "\\$1" \\$2
7 ..
8 .TH cdk_display 3
9 .SH NAME
10 cdk_display - \fBCurses Development Kit\fR Display Capabilities.
11 .SH SYNOPSIS
12 Cdk has a number of pre-defined display types.
13 The following are outlined in this manual page:
14 .It "\(bu How To Use Colors" 5
15 .It "\(bu How To Use Different Character Attributes" 5
16 .It "\(bu How To Justify Strings" 5
17 .It "\(bu How To Use Special Drawing Characters" 5
18 .It "\(bu Edit/Display Type Codes (EDisplayType)" 5
19 .SH DESCRIPTION
20 Cdk has special formatting commands which can be included in any string which
21 add highlights, justification, or even colors to a basic string.
22 These attributes, once set, remain in effect until changed explicitly,
23 or until the end of the string.
24 .LP
25 This manual
26 page outlines and demonstrates how they work.
27 .
28 .SS How To Use Colors
29 Cdk has the capability to display colors in almost every string type displayed
30 in a Cdk widget.
31 To turn on colors, the function \fBinitCDKColor\fR has to be called.
32 When this function is called 64 color pairs are created.
33 Normally the
34 color pairs are accessed via the COLOR_PAIR macro.
35 You can still do this, but
36 creating a string with multiple colors gets terribly difficult.
37 That is why
38 the color commands were created.
39 .LP
40 The color settings are stored directly in the string.
41 When the widget is created or activated, the string is converted
42 to take advantage of any color commands in the string.
43 To turn on a color pair
44 insert </XX> into the string; where \fIXX\fR is a numeric value from 0 to 64.
45 Color pair 0 is the standard default color pair for the screen.
46 To turn off a
47 color pair use the format command <!XX> where \fIXX\fR is a numeric value from
48 0 to 64.
49 .LP
50 The following example demonstrates the use of the color commands.
51 .ne 10
52 .sp 1
53 .nf
54 .ce
55 \fI----------------------------------------\fR
56 #include <cdk.h>
57
58 void main()
59 {
60 CDKSCREEN *cdkscreen;
61 CDKLABEL *demo;
62 WINDOW *screen;
63 char *mesg[4];
64
65 /* Initialize the Cdk screen. */
66 screen = initscr();
67 cdkscreen = initCDKScreen (screen);
68
69 /* Set the labels up. */
70 mesg[0] = "</1>This line should have a yellow foreground and a blue background.<!1>";
71 mesg[1] = "</2>This line should have a white foreground and a blue background.<!2>";
72 mesg[2] = "</3>This line should have a yellow foreground and a red background.<!3>";
73 mesg[3] = "<C>This line should be set to whatever the screen default is.";
74
75 /* Declare the labels. */
76 demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 4, TRUE, TRUE);
77
78 /* Draw the label */
79 drawCDKLabel (demo, TRUE);
80 waitCDKLabel (demo, ' ');
81
82 /* Clean up */
83 destroyCDKLabel (demo);
84 destroyCDKScreen (cdkscreen);
85 endCDK();
86 exit (0);
87 }
88 .fi
89 .ce
90 \fI----------------------------------------\fR
91 .PP
92 .
93 .SS How To Use Different Character Attributes
94 Cdk also provides attribute commands which allow different character attributes
95 to be displayed in a Cdk widget.
96 To use a character attribute the format command
97 is \fI</X>\fR where \fIX\fR is one of several command characters.
98 To turn a attribute off use the command \fI<!X>\fR.
99 The following table outlines the command characters:
100 .LP
101 .TS
102 center tab(/) box;
103 l l
104 l l
105 lw15 lw35 .
106 \fBCommand Character/Character Attribute\fR
107 =
108 B/Bold
109 U/Underline
110 K/Blink
111 R/Reverse
112 S/Standout
113 D/Dim
114 N/Normal
115 .TE
116 .LP
117 The following example demonstrates the use of character display attributes.
118 .ne 10
119 .sp 2
120 .nf
121 .ce
122 \fI----------------------------------------\fR
123 #include <cdk.h>
124
125 void main()
126 {
127 CDKSCREEN *cdkscreen;
128 CDKLABEL *demo;
129 WINDOW *screen;
130 char *mesg[4];
131
132 /* Initialize the Cdk screen. */
133 screen = initscr();
134 cdkscreen = initCDKScreen (screen);
135
136 /* Set the labels up. */
137 mesg[0] = "</B/1>Bold text yellow foreground / blue background.<!1>";
138 mesg[1] = "</U/2>Underlined text white foreground / blue background.<!2>";
139 mesg[2] = "</K/3>Blinking text yellow foreground / red background.<!3>";
140 mesg[3] = "<C>This line uses the screen default colors.";
141
142 /* Declare the labels. */
143 demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 4, TRUE, TRUE);
144
145 /* Draw the label */
146 drawCDKLabel (demo, TRUE);
147 waitCDKLabel (demo, ' ');
148
149 /* Clean up */
150 destroyCDKLabel (demo);
151 destroyCDKScreen (cdkscreen);
152 endCDK();
153 exit (0);
154 }
155 .ce
156 \fI----------------------------------------\fR
157 .fi
158 .LP
159 Note that color commands and format commands can be mixed inside the same
160 format marker.
161 The above example underlines the label marker, which also sets
162 color pair number 2.
163 .
164 .SS How To Justify Strings
165 Justification commands can left justify, right justify, or center a string of text.
166 To use a justification format in a string the command <X> is used.
167 The following table lists the format commands:
168 .LP
169 .TS
170 center tab(/) box;
171 l l
172 l l
173 lw15 lw35 .
174 \fBCommand/Action.\fR
175 =
176 <L>/Left Justified. Default if not stated.
177 <C>/Centered text.
178 <R>/Right justified.
179 <I=X>/Indent the line X characters.
180 <B=X>/Bullet. X is the bullet string to use.
181 <F=X>/T{
182 Links in a file where X is the filename.
183 This works only with the viewer widget.
184 T}
185 .TE
186
187 The following example demonstrates how to use the justification commands
188 in a Cdk widget.
189 .ce
190 \fI----------------------------------------\fR
191 .nf
192 #include <cdk.h>
193
194 void main()
195 {
196 CDKSCREEN *cdkscreen;
197 CDKLABEL *demo;
198 WINDOW *screen;
199 char *mesg[4];
200
201 /* Initialize the Cdk screen. */
202 screen = initscr();
203 cdkscreen = initCDKScreen (screen);
204
205 /* Set the labels up. */
206 mesg[0] = "<R></B/1>This line should have a yellow foreground and a blue background.<!1>";
207 mesg[1] = "</U/2>This line should have a white foreground and a blue background.<!2>";
208 mesg[2] = "<B=+>This is a bullet.";
209 mesg[3] = "<I=10>This is indented 10 characters.";
210 mesg[4] = "<C>This line should be set to whatever the screen default is.";
211
212 /* Declare the labels. */
213 demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 5, TRUE, TRUE);
214
215 /* Draw the label */
216 drawCDKLabel (demo, TRUE);
217 waitCDKLabel (demo, ' ');
218
219 /* Clean up */
220 destroyCDKLabel (demo);
221 destroyCDKScreen (cdkscreen);
222 endCDK();
223 exit (0);
224 }
225 .fi
226 .ce
227 \fI----------------------------------------\fR
228 .PP
229 The bullet format command can take either a single character or a string.
230 The bullet in the above example would look like
231 .RS 3
232 \fI+\fR This is a bullet.
233 .RE
234 but if we were to use the following command instead
235 .RS 3
236 <B=***>This is a bullet.
237 .RE
238 it would look like
239 .RS 3
240 \fI***\fR This is a bullet.
241 .RE
242 .PP
243 A format command must be at the beginning of the string.
244 .
245 .SS How To Use Special Drawing Characters
246 Cdk has a set of special drawing characters which can be inserted into any
247 ASCII file.
248 In order to use a special character the format command <#XXX>
249 is used.
250 The following table lists all of the special character commands available.
251 .TS
252 center tab(/) box;
253 l l
254 l l
255 lw15 lw35 .
256 \fBSpecial_Character/Character\fR
257 =
258 <#UL>/Upper Left Corner
259 <#UR>/Upper Right Corner
260 <#LL>/Lower Left Corner
261 <#LR>/Lower Right Corner
262 =
263 <#LT>/Left Tee
264 <#RT>/Right Tee
265 <#TT>/Top Tee
266 <#BT>/Bottom Tee
267 =
268 <#HL>/Horizontal Line
269 <#VL>/Vertical Line
270 =
271 <#PL>/Plus Sign
272 <#PM>/Plus or Minus Sign
273 <#DG>/Degree Sign
274 <#CB>/Checker Board
275 <#DI>/Diamond
276 <#BU>/Bullet
277 <#S1>/Scan line 1
278 <#S9>/Scan line 9
279 =
280 <#LA>/Left Arrow
281 <#RA>/Right Arrow
282 <#TA>/Top Arrow
283 <#BA>/Bottom Arrow
284 .TE
285 .LP
286 The character formats can be repeated using an optional numeric repeat value.
287 To repeat a character add the repeat count within parentheses
288 to the end of the character format.
289 The following example draws 10 horizontal-line characters:
290 .LP
291 <#HL(10)>
292 .LP
293 The following example draws a box within a label window:
294 .ce
295 \fI----------------------------------------\fR
296 .nf
297 #include "cdk.h"
298
299 void main()
300 {
301 /* Declare variables. */
302 CDKSCREEN *cdkscreen;
303 CDKLABEL *demo;
304 WINDOW *cursesWin;
305 char *mesg[4];
306
307 /* Set up CDK */
308 cursesWin = initscr();
309 cdkscreen = initCDKScreen (cursesWin);
310
311 /* Start CDK Colors */
312 initCDKColor();
313
314 /* Set the labels up. */
315 mesg[0] = "<C><#UL><#HL(25)><#UR>";
316 mesg[1] = "<C><#VL></R>This text should be boxed.<!R><#VL>";
317 mesg[2] = "<C><#LL><#HL(25)><#LR>";
318 mesg[3] = "<C>While this is not.";
319
320 /* Declare the labels. */
321 demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 4, TRUE, TRUE);
322
323 /* Is the label NULL??? */
324 if (demo == (CDKLABEL *)NULL)
325 {
326 /* Clean up the memory. */
327 destroyCDKScreen (cdkscreen);
328
329 /* End curses... */
330 endCDK();
331
332 /* Spit out a message. */
333 printf ("Oops. Can't seem to create the label. Is the window too small?\\n");
334 exit (1);
335 }
336
337 /* Draw the CDK screen. */
338 refreshCDKScreen (cdkscreen);
339 waitCDKLabel (demo, ' ');
340
341 /* Clean up */
342 destroyCDKLabel (demo);
343 destroyCDKScreen (cdkscreen);
344 delwin (cursesWin);
345 endCDK();
346 exit (0);
347 }
348 .fi
349 .ce
350 \fI----------------------------------------\fR
351 .LP
352 Notice that drawn text can also be justified.
353 .LP
354 .
355 .SS Edit/Display Type Codes (EDisplayType)
356 .TS
357 center tab(/) box;
358 l l
359 l l
360 lw15 lw45 .
361 \fBDisplay_Type/Result\fR
362 =
363 vCHAR/Only accepts alphabetic characters.
364 vLCHAR/T{
365 Only accepts alphabetic characters.
366 Maps the character to lower case
367 when a character has been accepted.
368 T}
369 vUCHAR/T{
370 Only accepts alphabetic characters.
371 Maps the character to upper case
372 when a character has been accepted.
373 T}
374 vHCHAR/T{
375 Only accepts alphabetic characters.
376 Displays a period (\fI.\fR) when a character
377 has been accepted.
378 T}
379 vUHCHAR/T{
380 Only accepts alphabetic characters.
381 Displays a period (\fI.\fR) and maps the
382 character to upper case when a
383 character has been accepted.
384 T}
385 vLHCHAR/T{
386 Only accepts alphabetic characters.
387 Displays a period (\fI.\fR) and maps the
388 character to lower case when a
389 character has been accepted.
390 T}
391 vINT/T{
392 Only accepts numeric characters.
393 T}
394 vHINT/T{
395 Only accepts numeric characters.
396 Displays a period (\fI.\fR) when a character
397 has been accepted.
398 T}
399 vMIXED/Accepts any character types.
400 vLMIXED/T{
401 Accepts any character types.
402 Maps the character to lower case
403 when an alphabetic character has
404 been accepted.
405 T}
406 vUMIXED/T{
407 Accepts any character types.
408 Maps the character to upper case
409 when an alphabetic character has
410 been accepted.
411 T}
412 vHMIXED/T{
413 Accepts any character types.
414 Displays a period (\fI.\fR) when a character
415 has been accepted.
416 T}
417 vLHMIXED/T{
418 Accepts any character types.
419 Displays a period (\fI.\fR) and maps the
420 character to lower case when a
421 character has been accepted.
422 T}
423 vUHMIXED/T{
424 Accepts any character types.
425 Displays a period (\fI.\fR) and maps the
426 character to upper case when a
427 character has been accepted.
428 T}
429 vVIEWONLY/Uneditable field.
430 .TE
431 .SH SEE ALSO
432 .BR cdk (3),
433 .BR cdk_binding (3),
434 .BR cdk_screen (3)
0 .\" $Id: cdk_draw.3,v 1.3 2005/12/30 22:45:48 tom Exp $
1 .de XX
2 ..
3 .TH cdk_draw 3
4 .XX boxWindow
5 .XX attrbox
6 .XX drawObjBox
7 .XX drawLine
8 .XX drawShadow
9 .XX writeBlanks
10 .XX writeChar
11 .XX writeCharAttrib
12 .XX writeChtype
13 .XX writeChtypeAttrib
14 .SH NAME
15 cdk_draw \- Cdk Drawing Functions
16 .SH SYNOPSIS
17 .LP
18 .B cc
19 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
20 .B \-lcdk
21 .RI "[ " "library" " \|.\|.\|. ]"
22 .LP
23 #include <cdk.h>
24 .nf
25 .TP 15
26 .B "void boxWindow ("
27 .BI "WINDOW *" "window",
28 .BI "chtype " "attr");
29 .TP 15
30 .B "void attrbox ("
31 .BI "WINDOW *" "win",
32 .BI "chtype " "tlc",
33 .BI "chtype " "trc",
34 .BI "chtype " "blc",
35 .BI "chtype " "brc",
36 .BI "chtype " "horz",
37 .BI "chtype " "vert",
38 .BI "chtype " "attr");
39 .TP 15
40 .B "void drawObjBox ("
41 .BI "WINDOW *" "win",
42 .BI "CDKOBJS *" "object");
43 .TP 15
44 .B "void drawLine ("
45 .BI "WINDOW *" "window",
46 .BI "int " "startx",
47 .BI "int " "starty",
48 .BI "int " "endx",
49 .BI "int " "endy",
50 .BI "chtype " "line");
51 .TP 15
52 .B "void drawShadow ("
53 .BI "WINDOW *" "shadowWin");
54 .TP 15
55 .B "void writeBlanks ("
56 .BI "WINDOW *" "window",
57 .BI "int " "xpos",
58 .BI "int " "ypos",
59 .BI "int " "align",
60 .BI "int " "start",
61 .BI "int " "end");
62 .TP 15
63 .B "void writeChar ("
64 .BI "WINDOW *" "window",
65 .BI "int " "xpos",
66 .BI "int " "ypos",
67 .BI "char *" "string",
68 .BI "int " "align",
69 .BI "int " "start",
70 .BI "int " "end");
71 .TP 15
72 .B "void writeCharAttrib ("
73 .BI "WINDOW *" "window",
74 .BI "int " "xpos",
75 .BI "int " "ypos",
76 .BI "char *" "string",
77 .BI "chtype " "attr",
78 .BI "int " "align",
79 .BI "int " "start",
80 .BI "int " "end");
81 .TP 15
82 .B "void writeChtype ("
83 .BI "WINDOW *" "window",
84 .BI "int " "xpos",
85 .BI "int " "ypos",
86 .BI "chtype *" "string",
87 .BI "int " "align",
88 .BI "int " "start",
89 .BI "int " "end");
90 .TP 15
91 .B "void writeChtypeAttrib ("
92 .BI "WINDOW *" "window",
93 .BI "int " "xpos",
94 .BI "int " "ypos",
95 .BI "chtype *" "string",
96 .BI "chtype " "attr",
97 .BI "int " "align",
98 .BI "int " "start",
99 .BI "int " "end");
100 .fi
101 .SH DESCRIPTION
102 These functions perform useful drawing and attribute operations.
103 .SH AVAILABLE FUNCTIONS
104 .TP 5
105 .B boxWindow
106 draw a box with on the window \fIwin\fP.
107 Like \fBattrbox\fP,
108 this function ORs \fIattr\fP with each character as it draws the box.
109 .TP 5
110 .B attrbox
111 draw a box with on the window \fIwin\fP
112 letting the caller define each element of the box.
113 .IP
114 The parameters \fItlc\fP, \fItrc\fP, \fIblc\fP, \fIbrc\fP
115 are used for the
116 top-left,
117 top-right,
118 bottom-left and
119 bottom-right corners respectively.
120 The parameters
121 \fIhorz\fP and
122 \fIvert\fP
123 are used for the horizontal and vertical sides of the box.
124 Any of these parameters may be zero.
125 In that case, the function skips the corresponding element of the box.
126 .IP
127 The function ORs \fIattr\fP with each character as it draws the box.
128 .TP 5
129 .B drawObjBox
130 Draw a box around the given window \fIwin\fP
131 using the \fIobject\fP's defined line-drawing characters.
132 .TP 5
133 .B drawLine
134 draw a line on the given window.
135 .IP
136 The parameters \fIstarty\fP, \fIstartx\fP are the starting coordinates.
137 The parameters \fIendy\fP, \fIendx\fP are the ending coordinates.
138 The function writes the data in \fIline\fP to each coordinate in that
139 range including the start/end coordinates.
140 .IP
141 The function handles lines other than vertical or horizontal,
142 but normally it is used for that, e.g., with \fIline\fP set to
143 \fBACS_HLINE\fP or \fBACS_VLINE\fP.
144 .TP 5
145 .B drawShadow
146 draw a shadow on the right and bottom edges of a window.
147 .TP 5
148 .B writeBlanks
149 write a string of blanks, using \fBwriteChar\fP.
150 The parameters are passed to \fBwriteChar\fP as is.
151 There is no corresponding \fBwriteBlanksAttrib\fP function.
152 .TP 5
153 .B writeChar
154 writes out a \fBchar\ *\fP string without adding attributes.
155 The parameters are passed to \fBwriteCharAttrib\fP as is.
156 .TP 5
157 .B writeCharAttrib
158 writes out a \fBchar\ *\fP string with the given attributes added.
159 The string is written to the given \fIwindow\fP,
160 using its relative screen coordinates \fIypos\fP and \fIxpos\fP.
161 Compare with \fBwriteChtypeAttrib\fP, which writes a \fBchtype\ *\fP string.
162 .IP
163 The function ORs the attribute \fIattr\fP with each item from the string.
164 For instance, it may be \fBA_BOLD\fP.
165 The \fIalign\fP parameter controls whether it is written horizontally
166 (\fBHORIZONTAL\fP) or vertically (\fBVERTICAL\fP).
167 .IP
168 Finally, only a subset of the string is written,
169 i.e., from indices \fIstart\fP to \fIend\fP.
170 .TP 5
171 .B writeChtype
172 writes out a \fBchtype\ *\fP string without adding attributes.
173 The parameters are passed to \fBwriteChtypeAttrib\fP as is.
174 .TP 5
175 .B writeChtypeAttrib
176 writes out a \fIchtype\ *\fP string with the given attributes added.
177 The string is written to the given \fIwindow\fP,
178 using its relative screen coordinates \fIypos\fP and \fIxpos\fP.
179 You would normally construct the string from a \fIchar\ *\fP string
180 using \fBchar2Chtype\fP (3).
181 .IP
182 The function ORs the attribute \fIattr\fP with each item from the string.
183 For instance, it may be \fBA_BOLD\fP.
184 The \fIalign\fP parameter controls whether it is written horizontally
185 (\fBHORIZONTAL\fP) or vertically (\fBVERTICAL\fP).
186 .IP
187 Finally, only a subset of the string is written,
188 i.e., from indices \fIstart\fP to \fIend\fP.
189 .
190 .SH SEE ALSO
191 .BR cdk (3),
192 .BR cdk_util (3)
0 '\" t
1 .\" $Id: cdk_entry.3,v 1.23 2006/04/15 14:07:13 tom Exp $
2 .de XX
3 ..
4 .TH cdk_entry 3
5 .SH NAME
6 .XX activateCDKEntry
7 .XX cleanCDKEntry
8 .XX destroyCDKEntry
9 .XX drawCDKEntry
10 .XX eraseCDKEntry
11 .XX getCDKEntryBox
12 .XX getCDKEntryFillerChar
13 .XX getCDKEntryHiddenChar
14 .XX getCDKEntryMax
15 .XX getCDKEntryMin
16 .XX getCDKEntryValue
17 .XX injectCDKEntry
18 .XX moveCDKEntry
19 .XX newCDKEntry
20 .XX positionCDKEntry
21 .XX setCDKEntry
22 .XX setCDKEntryBackgroundAttrib
23 .XX setCDKEntryBackgroundColor
24 .XX setCDKEntryBox
25 .XX setCDKEntryBoxAttribute
26 .XX setCDKEntryCB
27 .XX setCDKEntryFillerChar
28 .XX setCDKEntryHiddenChar
29 .XX setCDKEntryHighlight
30 .XX setCDKEntryHorizontalChar
31 .XX setCDKEntryLLChar
32 .XX setCDKEntryLRChar
33 .XX setCDKEntryMax
34 .XX setCDKEntryMin
35 .XX setCDKEntryPostProcess
36 .XX setCDKEntryPreProcess
37 .XX setCDKEntryULChar
38 .XX setCDKEntryURChar
39 .XX setCDKEntryValue
40 .XX setCDKEntryVerticalChar
41 cdk_entry \- curses text-entry widget.
42 .SH SYNOPSIS
43 .LP
44 .B cc
45 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
46 .B \-lcdk
47 .RI "[ " "library" " \|.\|.\|. ]"
48 .LP
49 #include <cdk.h>
50 .nf
51 .TP 15
52 .B "char *activateCDKEntry ("
53 .BI "CDKENTRY *" "entry",
54 .BI "chtype *" "actions");
55 .TP 15
56 .B "void cleanCDKEntry ("
57 .BI "CDKENTRY *" "entry");
58 .TP 15
59 .B "void destroyCDKEntry ("
60 .BI "CDKENTRY *" "entry");
61 .TP 15
62 .B "void drawCDKEntry ("
63 .BI "CDKENTRY *" "entry",
64 .BI "boolean " "box");
65 .TP 15
66 .B "void eraseCDKEntry ("
67 .BI "CDKENTRY *" "entry");
68 .TP 15
69 .B "boolean getCDKEntryBox ("
70 .BI "CDKENTRY *" "entry");
71 .TP 15
72 .B "chtype getCDKEntryFillerChar ("
73 .BI "CDKENTRY *" "entry");
74 .TP 15
75 .B "chtype getCDKEntryHiddenChar ("
76 .BI "CDKENTRY *" "entry");
77 .TP 15
78 .B "int getCDKEntryMax ("
79 .BI "CDKENTRY *" "entry");
80 .TP 15
81 .B "int getCDKEntryMin ("
82 .BI "CDKENTRY *" "entry");
83 .TP 15
84 .B "char *getCDKEntryValue ("
85 .BI "CDKENTRY *" "entry");
86 .TP 15
87 .B "int injectCDKEntry ("
88 .BI "CDKENTRY *" "entry",
89 .BI "chtype " "input");
90 .TP 15
91 .B "void moveCDKEntry ("
92 .BI "CDKENTRY *" "entry",
93 .BI "int " "xpos",
94 .BI "int " "ypos",
95 .BI "boolean " "relative",
96 .BI "boolean " "refresh");
97 .TP 15
98 .B "CDKENTRY *newCDKEntry ("
99 .BI "CDKSCREEN *" "cdkscreen",
100 .BI "int " "xpos",
101 .BI "int " "ypos",
102 .BI "char *" "title",
103 .BI "char *" "label",
104 .BI "chtype " "fieldAttribute",
105 .BI "chtype " "fillerCharacter",
106 .BI "EDisplayType " "displayType",
107 .BI "int " "fieldWidth",
108 .BI "int " "minimumLength",
109 .BI "int " "maximumLength",
110 .BI "boolean " "box",
111 .BI "boolean " "shadow");
112 .TP 15
113 .B "void positionCDKEntry ("
114 .BI "CDKENTRY *" "entry");
115 .TP 15
116 .B "void setCDKEntry ("
117 .BI "CDKENTRY *" "entry",
118 .BI "char *" "value",
119 .BI "int " "minimumLength",
120 .BI "int " "maximumLength",
121 .BI "boolean " "box");
122 .TP 15
123 .B "void setCDKEntryBackgroundAttrib ("
124 .BI "CDKENTRY *" "entry",
125 .BI "chtype " "attribute");
126 .TP 15
127 .B "void setCDKEntryBackgroundColor ("
128 .BI "CDKENTRY *" "entry",
129 .BI "char * " "color");
130 .TP 15
131 .B "void setCDKEntryBox ("
132 .BI "CDKENTRY *" "entry",
133 .BI "boolean " "box");
134 .TP 15
135 .B "void setCDKEntryBoxAttribute ("
136 .BI "CDKENTRY *" "entry",
137 .BI "chtype " "character");
138 .TP 15
139 .B "void setCDKEntryCB ("
140 .BI "CDKENTRY *" "entry",
141 .BI "ENTRYCB " "callBackFunction");
142 .TP 15
143 .B "void setCDKEntryFillerChar ("
144 .BI "CDKENTRY *" "entry",
145 .BI "chtype " "character");
146 .TP 15
147 .B "void setCDKEntryHiddenChar ("
148 .BI "CDKENTRY *" "entry",
149 .BI "chtype " "character");
150 .TP 15
151 .B "void setCDKEntryHighlight ("
152 .BI "CDKENTRY *" "entry",
153 .BI "chtype " "highlight",
154 .BI "boolean " "cursor");
155 .TP 15
156 .B "void setCDKEntryHorizontalChar ("
157 .BI "CDKENTRY *" "entry",
158 .BI "chtype " "character");
159 .TP 15
160 .B "void setCDKEntryLLChar ("
161 .BI "CDKENTRY *" "entry",
162 .BI "chtype " "character");
163 .TP 15
164 .B "void setCDKEntryLRChar ("
165 .BI "CDKENTRY *" "entry",
166 .BI "chtype " "character");
167 .TP 15
168 .B "void setCDKEntryMax ("
169 .BI "CDKENTRY *" "entry",
170 .BI "int " "maximum");
171 .TP 15
172 .B "void setCDKEntryMin ("
173 .BI "CDKENTRY *" "entry",
174 .BI "int " "minimum");
175 .TP 15
176 .B "void setCDKEntryPostProcess ("
177 .BI "CDKENTRY *" "entry",
178 .BI "PROCESSFN " "callback",
179 .BI "void * " "data");
180 .TP 15
181 .B "void setCDKEntryPreProcess ("
182 .BI "CDKENTRY *" "entry",
183 .BI "PROCESSFN " "callback",
184 .BI "void * " "data");
185 .TP 15
186 .B "void setCDKEntryULChar ("
187 .BI "CDKENTRY *" "entry",
188 .BI "chtype " "character");
189 .TP 15
190 .B "void setCDKEntryURChar ("
191 .BI "CDKENTRY *" "entry",
192 .BI "chtype " "character");
193 .TP 15
194 .B "void setCDKEntryValue ("
195 .BI "CDKENTRY *" "entry",
196 .BI "char *" "value");
197 .TP 15
198 .B "void setCDKEntryVerticalChar ("
199 .BI "CDKENTRY *" "entry",
200 .BI "chtype " "character");
201 .fi
202 .SH DESCRIPTION
203 The Cdk entry widget creates a text-entry box with a label and an entry field.
204 The following functions create or manipulate the Cdk entry box widget.
205 .SH AVAILABLE FUNCTIONS
206 .TP 5
207 .B activateCDKEntry
208 activates the entry widget and lets the user interact with the widget.
209 The parameter \fBentry\fR is a pointer to a non-NULL entry widget.
210 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
211 in the array will be injected into the widget.
212 To activate the widget
213 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
214 If the character entered
215 into this widget is \fIRETURN\fR or \fITAB\fR then this function will return
216 a \fIchar *\fR representing the information typed into the widget and the
217 widget data \fIexitType\fR will be set to \fIvNORMAL\fR.
218 If the character
219 entered was \fIESCAPE\fR then the function will return \fINULL\fR pointer and
220 the widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
221 .TP 5
222 .B cleanCDKEntry
223 clears the information from the field.
224 .TP 5
225 .B destroyCDKEntry
226 removes the widget from the screen and frees memory the object used.
227 .TP 5
228 .B drawCDKEntry
229 draws the entry widget on the screen.
230 If the \fBbox\fR parameter is true, the widget is drawn with a box.
231 .TP 5
232 .B eraseCDKEntry
233 removes the widget from the screen.
234 This does \fINOT\fR destroy the widget.
235 .TP 5
236 .B getCDKEntryBox
237 returns true if the widget will be drawn with a box around it.
238 .TP 5
239 .B getCDKEntryFillerChar
240 returns the character being used to draw unused space in the widget.
241 .TP 5
242 .B getCDKEntryHiddenChar
243 returns the character being used to draw the hidden character type.
244 .TP 5
245 .B getCDKEntryMax
246 returns the maximum length of a string the widget will allow.
247 .TP 5
248 .B getCDKEntryMin
249 returns the minimum length of a string the widget will allow.
250 .TP 5
251 .B getCDKEntryValue
252 returns the current value of the widget.
253 .TP 5
254 .B injectCDKEntry
255 injects a single character into the widget.
256 The parameter \fBentry\fR is a pointer to a non-NULL entry widget.
257 The parameter \fBcharacter\fR is the character to inject into the widget.
258 The return value and side-effect (setting the widget data \fIexitType\fP)
259 depend upon the injected character:
260 .RS
261 .TP
262 \fIRETURN\fP or \fITAB\fR
263 the function returns
264 a \fIchar *\fR representing the information typed into the widget.
265 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
266 .TP
267 \fIESCAPE\fP
268 the function returns
269 a \fINULL\fR pointer.
270 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
271 .TP
272 Otherwise
273 unless modified by preprocessing, postprocessing or key bindings,
274 the function returns
275 a \fINULL\fR pointer.
276 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
277 .RE
278 .TP 5
279 .B moveCDKEntry
280 moves the given widget to the given position.
281 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
282 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
283 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
284 The parameter \fBypos\fR may be an integer or one of the pre-defined values
285 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
286 The parameter \fBrelative\fR states whether
287 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
288 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
289 then the widget would move one row down and two columns right.
290 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
291 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
292 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
293 (weird things may happen).
294 The final parameter \fBrefresh\fR is a boolean value which states
295 whether the widget will get refreshed after the move.
296 .TP 5
297 .B newCDKEntry
298 creates a pointer to an entry widget.
299 Parameters:
300 .RS
301 .TP 5
302 The \fBscreen\fR parameter
303 is the screen you wish this widget to be placed in.
304 .TP 5
305 \fBxpos\fR
306 controls the placement of the object along the horizontal axis.
307 It may be an integer or one of the pre-defined values
308 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
309 .TP 5
310 \fBypos\fR
311 controls the placement of the object along the vertical axis.
312 It may be an integer or one of the pre-defined values
313 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
314 .TP 5
315 \fBtitle\fR
316 is the string which will be displayed at the top of the widget.
317 The title can be more than one line; just provide a carriage
318 return character at the line break.
319 .TP 5
320 \fBlabel\fR
321 is the string which will be displayed in the label of the entry field.
322 .TP 5
323 \fBfieldAttribute\fR
324 is the attribute of the characters which are typed in.
325 .TP 5
326 \fBfiller\fR
327 is the character which is to be displayed in an empty space in the entry field.
328 .TP 5
329 \fBdisplayType\fR
330 tells how the entry field will behave when a character is entered into the field.
331 See \fBcdk_display (3)\fR for valid values for this field.
332 .TP 5
333 \fBfieldWidth\fR
334 denotes the width of the field.
335 If a value
336 of zero is provided, the field will be made as wide as possible on the screen.
337 If a negative value is given, then the field width will be the
338 maximum width minus the value provided.
339 .TP 5
340 \fBminimumLength\fR
341 controls the number of characters
342 which must be entered before the user can exit the entry field.
343 .TP 5
344 \fBmaximumLength\fR
345 sets the maximum number of characters that can be entered.
346 .TP 5
347 \fBbox\fR
348 is true if the widget should be drawn with a box around it.
349 .TP 5
350 \fBshadow\fR
351 turns the shadow on around this widget.
352 .RE
353 .IP
354 If the widget could not be created then a \fINULL\fR pointer is returned.
355 .TP 5
356 .B positionCDKEntry
357 allows the user to move the widget around the screen via the
358 cursor/keypad keys.
359 The following key bindings can be used to move the
360 widget around the screen.
361 See \fBcdk_position (3)\fR for key bindings.
362 .TP 5
363 .B setCDKEntry
364 lets the programmer modify certain elements of an existing
365 entry widget.
366 The \fBvalue\fR parameter sets the value of the contents of the
367 entry field.
368 The other parameter names correspond to the same parameter names
369 listed in the \fBnewCDKEntry\fR function.
370 .TP 5
371 .B setCDKEntryBackgroundAttrib
372 sets the background attribute of the widget.
373 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
374 .TP 5
375 .B setCDKEntryBackgroundColor
376 sets the background color of the widget.
377 The parameter \fBcolor\fR
378 is in the format of the Cdk format strings.
379 See \fBcdk_display (3)\fR.
380 .TP 5
381 .B setCDKEntryBox
382 sets whether the widget will be drawn with a box around it.
383 .TP 5
384 .B setCDKEntryBoxAttribute
385 function sets the attribute of the box.
386 .TP 5
387 .B setCDKEntryCB
388 allows the programmer to set a different widget input handler.
389 The parameter \fBcallbackFunction\fR is of type \fIENTRYCB\fR.
390 The default function is \fICDKEntryCallBack\fR.
391 .TP 5
392 .B setCDKEntryFillerChar
393 sets the character to use when drawing unused space in the field.
394 .TP 5
395 .B setCDKEntryHiddenChar
396 sets the character to use when using a hidden character type.
397 .TP 5
398 .B setCDKEntryHighlight
399 sets the attribute of the entry field.
400 .TP 5
401 .B setCDKEntryHorizontalChar
402 sets the horizontal drawing character for the box to
403 the given character.
404 .TP 5
405 .B setCDKEntryLLChar
406 sets the lower left hand corner of the widget's box to
407 the given character.
408 .TP 5
409 .B setCDKEntryLRChar
410 sets the lower right hand corner of the widget's box to the given character.
411 .TP 5
412 .B setCDKEntryMax
413 sets the maximum length of the string that the widget will allow.
414 .TP 5
415 .B setCDKEntryMin
416 sets the minimum length of the string that the widget will allow.
417 .TP 5
418 .B setCDKEntryPostProcess
419 allows the user to have the widget call a function after the
420 key has been applied to the widget.
421 The parameter \fBfunction\fR is the callback function.
422 The parameter \fBdata\fR points to data passed to the callback function.
423 To learn more about post-processing see \fIcdk_process (3)\fR.
424 .TP 5
425 .B setCDKEntryPreProcess
426 allows the user to have the widget call a function after a key
427 is hit and before the key is applied to the widget.
428 The parameter \fBfunction\fR is the callback function.
429 The parameter \fBdata\fR points to data passed to the callback function.
430 To learn more about pre-processing see \fIcdk_process (3)\fR.
431 .TP 5
432 .B setCDKEntryULChar
433 sets the upper left hand corner of the widget's box to the given character.
434 .TP 5
435 .B setCDKEntryURChar
436 sets the upper right hand corner of the widget's box to the given character.
437 .TP 5
438 .B setCDKEntryValue
439 sets the current value of the widget.
440 .TP 5
441 .B setCDKEntryVerticalChar
442 sets the vertical drawing character for the box to
443 the given character.
444 .SH KEY BINDINGS
445 When the widget is activated there are several default key bindings which will
446 help the user enter or manipulate the information quickly.
447 The following table
448 outlines the keys and their actions for this widget.
449 .LP
450 .TS
451 center tab(/);
452 l l
453 lw15 lw35 .
454 \fBKey/Action\fR
455 =
456 Left Arrow/Moves the cursor to the left.
457 CTRL-B/Moves the cursor to the left.
458 Right Arrow/Moves the cursor to the right.
459 CTRL-F/Moves the cursor to the right.
460 Delete/Deletes the character at the cursor.
461 Backspace/Deletes the character before cursor, moves cursor left.
462 CTRL-V/T{
463 Pastes whatever is in the paste buffer, into the widget.
464 T}
465 CTRL-X/T{
466 Cuts the contents from the widget and saves a copy in the paste buffer.
467 T}
468 CTRL-Y/T{
469 Copies the contents of the widget into the paste buffer.
470 T}
471 CTRL-U/Erases the contents of the widget.
472 CTRL-A/T{
473 Moves the cursor to the beginning of the entry field.
474 T}
475 CTRL-E/T{
476 Moves the cursor to the end of the entry field.
477 T}
478 CTRL-T/T{
479 Transposes the character under the cursor with the character to the right.
480 T}
481 Return/T{
482 Exits the widget and returns a \fIchar *\fR representing the information which was typed into the field.
483 It also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
484 T}
485 Tab/T{
486 Exits the widget and returns a \fIchar *\fR representing the information which was typed into the field.
487 It also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
488 T}
489 Escape/T{
490 Exits the widget and returns a \fINULL\fR pointer.
491 It also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
492 T}
493 Ctrl-L/Refreshes the screen.
494 =
495 .TE
496 .SH SEE ALSO
497 .BR cdk (3),
498 .BR cdk_binding (3),
499 .BR cdk_display (3),
500 .BR cdk_position (3),
501 .BR cdk_process (3),
502 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_fselect.3,v 1.24 2006/05/07 01:00:01 tom Exp $
2 .de XX
3 ..
4 .TH cdk_fselect 3
5 .SH NAME
6 .XX activateCDKFselect
7 .XX deleteFileCB
8 .XX destroyCDKFselect
9 .XX drawCDKFselect
10 .XX eraseCDKFselect
11 .XX getCDKFselectBox
12 .XX getCDKFselectContents
13 .XX getCDKFselectCurrentItem
14 .XX getCDKFselectDirAttribute
15 .XX getCDKFselectDirContents
16 .XX getCDKFselectDirectory
17 .XX getCDKFselectFileAttribute
18 .XX getCDKFselectFillerChar
19 .XX getCDKFselectHighlight
20 .XX getCDKFselectLinkAttribute
21 .XX getCDKFselectSocketAttribute
22 .XX injectCDKFselect
23 .XX moveCDKFselect
24 .XX newCDKFselect
25 .XX positionCDKFselect
26 .XX setCDKFselect
27 .XX setCDKFselectBackgroundAttrib
28 .XX setCDKFselectBackgroundColor
29 .XX setCDKFselectBox
30 .XX setCDKFselectBoxAttribute
31 .XX setCDKFselectContents
32 .XX setCDKFselectCurrentItem
33 .XX setCDKFselectDirAttribute
34 .XX setCDKFselectDirContents
35 .XX setCDKFselectDirectory
36 .XX setCDKFselectFileAttribute
37 .XX setCDKFselectFillerChar
38 .XX setCDKFselectHighlight
39 .XX setCDKFselectHorizontalChar
40 .XX setCDKFselectLLChar
41 .XX setCDKFselectLRChar
42 .XX setCDKFselectLinkAttribute
43 .XX setCDKFselectSocketAttribute
44 .XX setCDKFselectULChar
45 .XX setCDKFselectURChar
46 .XX setCDKFselectVerticalChar
47 cdk_fselect \- curses file selector widget.
48 .SH SYNOPSIS
49 .LP
50 .B cc
51 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
52 .B \-lcdk
53 .RI "[ " "library" " \|.\|.\|. ]"
54 .LP
55 #include <cdk.h>
56 .nf
57 .TP 15
58 .B "char *activateCDKFselect ("
59 .BI "CDKFSELECT *" "fselect",
60 .BI "chtype *" "actions");
61 .TP 15
62 .B "void deleteFileCB ("
63 .BI "EObjectType " "objectType",
64 .BI "void *" "object",
65 .BI "void *" "clientData");
66 .TP 15
67 .B "void destroyCDKFselect ("
68 .BI "CDKFSELECT *" "fselect");
69 .TP 15
70 .B "void drawCDKFselect ("
71 .BI "CDKFSELECT *" "fselect",
72 .BI "boolean " "box");
73 .TP 15
74 .B "void eraseCDKFselect ("
75 .BI "CDKFSELECT *" "fselect");
76 .TP 15
77 .B "boolean getCDKFselectBox ("
78 .BI "CDKFSELECT *" "fselect");
79 .TP 15
80 .B "char **getCDKFselectContents ("
81 .BI "CDKFSELECT *" "widget",
82 .BI "int *" "size");
83 .TP 15
84 .B "int getCDKFselectCurrentItem ("
85 .BI "CDKFSELECT *" "widget");
86 .TP 15
87 .B "char *getCDKFselectDirAttribute ("
88 .BI "CDKFSELECT *" "fselect");
89 .TP 15
90 .B "char **getCDKFselectDirContents ("
91 .BI "CDKFSELECT *" "fselect",
92 .BI "int *" "count");
93 .TP 15
94 .B "char *getCDKFselectDirectory ("
95 .BI "CDKFSELECT *" "fselect");
96 .TP 15
97 .B "char *getCDKFselectFileAttribute ("
98 .BI "CDKFSELECT *" "fselect");
99 .TP 15
100 .B "chtype getCDKFselectFillerChar ("
101 .BI "CDKFSELECT *" "fselect");
102 .TP 15
103 .B "chtype getCDKFselectHighlight ("
104 .BI "CDKFSELECT *" "fselect");
105 .TP 15
106 .B "char *getCDKFselectLinkAttribute ("
107 .BI "CDKFSELECT *" "fselect");
108 .TP 15
109 .B "char *getCDKFselectSocketAttribute ("
110 .BI "CDKFSELECT *" "fselect");
111 .TP 15
112 .B "char *injectCDKFselect ("
113 .BI "CDKFSELECT *" "fselect",
114 .BI "chtype " "input");
115 .TP 15
116 .B "void moveCDKFselect ("
117 .BI "CDKFSELECT *" "fselect",
118 .BI "int " "xpos",
119 .BI "int " "ypos",
120 .BI "boolean " "relative",
121 .BI "boolean " "refresh");
122 .TP 15
123 .B "CDKFSELECT *newCDKFselect ("
124 .BI "CDKSCREEN *" "cdkscreen",
125 .BI "int " "xpos",
126 .BI "int " "ypos",
127 .BI "int " "height",
128 .BI "int " "width",
129 .BI "char *" "title",
130 .BI "char *" "label",
131 .BI "chtype " "fieldAttribute",
132 .BI "chtype " "fillerCharacter",
133 .BI "chtype " "highlight",
134 .BI "char *" "dirAttribute",
135 .BI "char *" "fileAttribute",
136 .BI "char *" "linkAttribute",
137 .BI "char *" "sockAttribute",
138 .BI "boolean " "box",
139 .BI "boolean " "shadow");
140 .TP 15
141 .B "void positionCDKFselect ("
142 .BI "CDKFSELECT *" "fselect");
143 .TP 15
144 .B "void setCDKFselect ("
145 .BI "CDKFSELECT *" "fselect",
146 .BI "char *" "directory",
147 .BI "chtype " "fieldAttribute",
148 .BI "chtype " "fillerCharacter",
149 .BI "chtype " "highlight",
150 .BI "char *" "dirAttribute",
151 .BI "char *" "fileAttribute",
152 .BI "char *" "linkAttribute",
153 .BI "char *" "sockAttribute",
154 .BI "boolean " "box");
155 .TP 15
156 .B "void setCDKFselectBackgroundAttrib ("
157 .BI "CDKFSELECT *" "fselect",
158 .BI "chtype " "attribute");
159 .TP 15
160 .B "void setCDKFselectBackgroundColor ("
161 .BI "CDKFSELECT *" "fselect",
162 .BI "char * " "color");
163 .TP 15
164 .B "void setCDKFselectBox ("
165 .BI "CDKFSELECT *" "fselect",
166 .BI "boolean " "box");
167 .TP 15
168 .B "void setCDKFselectBoxAttribute ("
169 .BI "CDKFSELECT *" "fselect",
170 .BI "chtype " "character");
171 .TP 15
172 .B "void setCDKFselectContents ("
173 .BI "CDKFSELECT *" "widget",
174 .BI "char **" "list",
175 .BI "int " "listSize");
176 .TP 15
177 .B "void setCDKFselectCurrentItem ("
178 .BI "CDKFSELECT *" "widget",
179 .BI "int " "item");
180 .TP 15
181 .B "void setCDKFselectDirAttribute ("
182 .BI "CDKFSELECT *" "fselect",
183 .BI "char *" "attribute");
184 .TP 15
185 .B "int setCDKFselectDirContents ("
186 .BI "CDKFSELECT *" "fselect");
187 .TP 15
188 .B "int setCDKFselectDirectory ("
189 .BI "CDKFSELECT *" "fselect",
190 .BI "char *" "directory");
191 .TP 15
192 .B "void setCDKFselectFileAttribute ("
193 .BI "CDKFSELECT *" "fselect",
194 .BI "char *" "attribute");
195 .TP 15
196 .B "void setCDKFselectFillerChar ("
197 .BI "CDKFSELECT *" "fselect",
198 .BI "chtype " "filler");
199 .TP 15
200 .B "void setCDKFselectHighlight ("
201 .BI "CDKFSELECT *" "fselect",
202 .BI "chtype " "highlight");
203 .TP 15
204 .B "void setCDKFselectHorizontalChar ("
205 .BI "CDKFSELECT *" "fselect",
206 .BI "chtype " "character");
207 .TP 15
208 .B "void setCDKFselectLLChar ("
209 .BI "CDKFSELECT *" "fselect",
210 .BI "chtype " "character");
211 .TP 15
212 .B "void setCDKFselectLRChar ("
213 .BI "CDKFSELECT *" "fselect",
214 .BI "chtype " "character");
215 .TP 15
216 .B "void setCDKFselectLinkAttribute ("
217 .BI "CDKFSELECT *" "fselect",
218 .BI "char *" "attribute");
219 .TP 15
220 .B "void setCDKFselectSocketAttribute ("
221 .BI "CDKFSELECT *" "fselect",
222 .BI "char *" "attribute");
223 .TP 15
224 .B "void setCDKFselectULChar ("
225 .BI "CDKFSELECT *" "fselect",
226 .BI "chtype " "character");
227 .TP 15
228 .B "void setCDKFselectURChar ("
229 .BI "CDKFSELECT *" "fselect",
230 .BI "chtype " "character");
231 .TP 15
232 .B "void setCDKFselectVerticalChar ("
233 .BI "CDKFSELECT *" "fselect",
234 .BI "chtype " "character");
235 .fi
236 .SH DESCRIPTION
237 The Cdk file selector widget creates a widget which allows a user to interact
238 with the Unix file system.
239 This widget allows the user to traverse the file
240 system and even delete files.
241 (See \fINOTES\fR below for more information)
242 .SH AVAILABLE FUNCTIONS
243 .TP 5
244 .B activateCDKFselect
245 activates the file selector widget and lets the user interact with the widget.
246 The parameter \fBfselect\fR is a pointer to a non-NULL file selector widget.
247 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
248 in the array will be injected into the widget.
249 To activate the widget
250 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
251 If the character entered
252 into this widget is \fIRETURN\fR or \fITAB\fR then this function will return
253 a \fIchar *\fR representing the information typed into the widget and the
254 widget data \fIexitType\fR will be set to \fIvNORMAL\fR.
255 If the character
256 entered was \fIESCAPE\fR then the function will return \fINULL\fR pointer and
257 the widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
258 void deleteFileCB (EObjectType objectType GCC_UNUSED, void *object, void *clientData)
259 .TP 5
260 .B deleteFileCB
261 Prompts the user to confirm,
262 and deletes the current item in the file-list.
263 .TP 5
264 .B destroyCDKFselect
265 removes the widget from the screen and frees memory the object used.
266 .TP 5
267 .B drawCDKFselect
268 draws the fselect widget on the screen.
269 If the \fBbox\fR option is true, the widget is drawn with a box.
270 .TP 5
271 .B eraseCDKFselect
272 removes the widget from the screen.
273 This does \fINOT\fR destroy the widget.
274 .TP 5
275 .B getCDKFselectBox
276 returns true if the widget will be drawn with a box around it.
277 .TP 5
278 .B getCDKFselectContents
279 returns the directory-contents (which are formatted),
280 and sets the number of entries via the \fIsize\fP parameter.
281 .TP 5
282 .B getCDKFselectCurrentItem
283 returns the current position in the scroll-widget.
284 .TP 5
285 .B getCDKFselectDirAttribute
286 returns the attribute that directories are drawn with in the
287 scrolling region of the widget.
288 .TP
289 .B getCDKFselectDirContents
290 returns the list of files and the corresponding count as a side-effect.
291 If no files are found, this function returns zero, otherwise one.
292 .TP 5
293 .B getCDKFselectDirectory
294 returns the current directory of the widget.
295 .TP 5
296 .B getCDKFselectFileAttribute
297 returns the attribute that plain files are drawn with in the
298 scrolling region of the widget.
299 .TP 5
300 .B getCDKFselectFillerChar
301 returns the character being used as the filler character in the
302 entry field portion of the widget.
303 .TP 5
304 .B getCDKFselectHighlight
305 returns the attribute of the highlight bar of the scrolling
306 list portion of the widget.
307 .TP 5
308 .B getCDKFselectLinkAttribute
309 returns the attribute that symbolic links are drawn with in the
310 scrolling region of the widget.
311 .TP 5
312 .B getCDKFselectSocketAttribute
313 returns the attribute that sockets are drawn with in the
314 scrolling region of the widget.
315 .TP 5
316 .B injectCDKFselect
317 injects a single character into the widget.
318 The parameter \fBfselect\fR is a pointer to a non-NULL file selector widget.
319 The parameter \fBcharacter\fR is the character to inject into the widget.
320 The return value and side-effect (setting the widget data \fIexitType\fP)
321 depend upon the injected character:
322 .RS
323 .TP
324 \fIRETURN\fP or \fITAB\fR
325 the function returns
326 a \fIchar *\fR representing the information typed into the widget.
327 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
328 .TP
329 \fIESCAPE\fP
330 the function returns
331 a \fINULL\fR pointer.
332 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
333 .TP
334 Otherwise
335 unless modified by preprocessing, postprocessing or key bindings,
336 the function returns
337 a \fINULL\fR pointer.
338 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
339 .RE
340 .TP 5
341 .B moveCDKFselect
342 moves the given widget to the given position.
343 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
344 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
345 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
346 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
347 \fIRIGHT\fR, and \fICENTER\fR.
348 The parameter \fBrelative\fR states whether
349 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
350 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
351 then the widget would move one row down and two columns right.
352 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
353 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
354 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
355 (weird things may happen).
356 The final parameter \fBrefresh\fR is a boolean value which states
357 whether the widget will get refreshed after the move.
358 .TP 5
359 .B newCDKFselect
360 creates an fselect widget and returns a pointer to it.
361 Parameters:
362 .RS
363 .TP 5
364 The \fBscreen\fR parameter
365 is the screen you wish this widget to be placed in.
366 .TP 5
367 The parameter \fBxpos\fR
368 controls the placement of the object along the horizontal axis.
369 This parameter
370 may be an integer or one of the pre-defined values \fILEFT\fR,
371 \fIRIGHT\fR, and \fICENTER\fR.
372 .TP 5
373 \fBypos\fR
374 controls the placement of the object along the vertical axis.
375 It may be an integer value or one of the pre-defined values
376 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
377 .TP 5
378 \fBheight\fR and
379 .TP 5
380 \fBwidth\fR
381 control the height and width of the widget.
382 If you provide a value of zero for either of the height or the width,
383 the widget will be created with the full width and height of the screen.
384 If you provide a negative value, the widget will be created the full height or
385 width minus the value provided.
386 .TP 5
387 \fBtitle\fR
388 is the string which will be displayed at the top of the widget.
389 The title can be more than one
390 line; just provide a carriage return character at the line break.
391 .TP 5
392 \fBlabel\fR
393 is the text to use as the label of the file selector.
394 .TP 5
395 \fBfieldAttribute\fR
396 is the attribute of the entry field at the top of the widget;
397 .TP 5
398 \fBfillerCharacter\fR
399 is the filler character for the entry field.
400 .TP 5
401 \fBhighlight\fR
402 is the highlight attribute on the scrolling list.
403 .TP 5
404 \fBdirAttribute\fR,
405 .TP 5
406 \fBfileAttribute\fR,
407 .TP 5
408 \fBlinkAttribute\fR and
409 .TP 5
410 \fBsockAttribute\fR
411 are the attributes of directories, files, links, and
412 sockets found in the directory list.
413 .TP 5
414 \fBbox\fR
415 is true if the widget should be drawn with a box around it.
416 .TP 5
417 \fBshadow\fR
418 turns the shadow on or off around this widget.
419 .RE
420 .IP
421 If the widget could not be created then a \fINULL\fR pointer is returned.
422 .TP 5
423 .B positionCDKFselect
424 allows the user to move the widget around the screen via the cursor/keypad keys.
425 See \fBcdk_position (3)\fR for key bindings.
426 .TP 5
427 .B setCDKFselect
428 lets the programmer modify certain elements of an existing fselect widget.
429 The parameter names correspond to the same parameter
430 names listed in the \fBnewCDKFselect\fR function.
431 .TP 5
432 .B setCDKFselectBackgroundAttrib
433 sets the background attribute of the widget.
434 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
435 .TP 5
436 .B setCDKFselectBackgroundColor
437 sets the background color of the widget.
438 The parameter \fBcolor\fR
439 is in the format of the Cdk format strings.
440 See \fBcdk_display (3)\fR.
441 .TP 5
442 .B setCDKFselectBox
443 sets whether the widget will be drawn with a box around it.
444 .TP 5
445 .B setCDKFselectBoxAttribute
446 sets the attribute of the box.
447 .TP 5
448 .B setCDKFselectContents
449 sets the contents of the widget.
450 .TP 5
451 .B setCDKFselectCurrentItem
452 set the current position in the scroll-widget.
453 .TP 5
454 .B setCDKFselectDirAttribute
455 sets the attribute that directories will be drawn with in the scrolling
456 region of the widget.
457 .B
458 .B setCDKFselectDirContents
459 This creates a list of the files in the current directory.
460 See \fBgetCDKFselectDirContents\FP.
461 .TP 5
462 .B setCDKFselectDirectory
463 sets the current directory of the widget.
464 .TP 5
465 .B setCDKFselectFileAttribute
466 sets the attribute that plain files will be drawn with in the scrolling
467 region of the widget.
468 .TP 5
469 .B setCDKFselectFillerChar
470 sets the character to use when drawing the entry field portion of the widget.
471 .TP 5
472 .B setCDKFselectHighlight
473 sets the attribute of the highlight bar of the scrolling
474 list portion of the widget.
475 .TP 5
476 .B setCDKFselectHorizontalChar
477 sets the horizontal drawing character for the box to
478 the given character.
479 .TP 5
480 .B setCDKFselectLLChar
481 sets the lower left hand corner of the widget's box to
482 the given character.
483 .TP 5
484 .B setCDKFselectLRChar
485 sets the lower right hand corner of the widget's box to
486 the given character.
487 .TP 5
488 .B setCDKFselectLinkAttribute
489 sets the attribute that symbolic links will be drawn with in the scrolling
490 region of the widget.
491 .TP 5
492 .B setCDKFselectSocketAttribute
493 sets the attribute that sockets will be drawn with in the scrolling
494 region of the widget.
495 .TP 5
496 .B setCDKFselectULChar
497 sets the upper left hand corner of the widget's box to
498 the given character.
499 .TP 5
500 .B setCDKFselectURChar
501 sets the upper right hand corner of the widget's box to
502 the given character.
503 .TP 5
504 .B setCDKFselectVerticalChar
505 sets the vertical drawing character for the box to
506 the given character.
507 .SH KEY BINDINGS
508 When the widget is activated there are several default key bindings which will
509 help the user enter or manipulate the information quickly.
510 Since this widget is
511 built from both the scrolling list widget and the entry field widget, the key
512 bindings are the same for the respective fields.
513 The extra key bindings are
514 listed below.
515 .LP
516 .TS
517 center tab(/) allbox;
518 l l
519 l l
520 lw15 lw35 .
521 \fBKey/Action\fR
522 =
523 CTRL-^/Displays statistics about the current filename.
524 Tab/Tries to complete the current filename.
525 Up Arrow/Scrolls the scrolling list up one line.
526 Down Arrow/Scrolls the scrolling list down one line.
527 Page Up/Scrolls the scrolling list up one page.
528 CTRL-B/Scrolls the scrolling list up one page.
529 Page Down/T{
530 Scrolls the scrolling list down one page.
531 T}
532 CTRL-F/T{
533 Scrolls the scrolling list down one page.
534 T}
535 Return/T{
536 Returns the filename in the entry field of the file selector.
537 It also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
538 T}
539 Escape/T{
540 Exits the widget and returns a \fINULL\fR pointer.
541 It also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
542 T}
543 .TE
544 .SH SEE ALSO
545 .BR cdk (3),
546 .BR cdk_binding (3),
547 .BR cdk_display (3),
548 .BR cdk_position (3),
549 .BR cdk_screen (3)
550 .SH NOTES
551 .PP
552 This widget is created from the scrolling list widget and the entry field widget.
553 This is a good example on how to build your own widgets using the
554 base widgets provided in this distribution.
555 In order for you to delete
556 files using the file selector, you must add the following call
557 into your program.
558 (the character X is the character you wish to use to
559 tell the file selector you want to delete a file.)
560 .RS 5
561 \fBbindCDKObject (vSCROLL, fselect->filelist, X, deleteFile, fselect);\fR
562 .RE
563 where \fBfselect\fR is a pointer to the object.
564 This was originally turned on,
565 but I thought it better to put the control of file deletion on an 'as-need' basis.
0 .\" $Id: cdk_graph.3,v 1.14 2005/12/28 18:35:31 tom Exp $
1 .de XX
2 ..
3 .TH cdk_graph 3
4 .SH NAME
5 .XX activateCDKGraph
6 .XX destroyCDKGraph
7 .XX drawCDKGraph
8 .XX eraseCDKGraph
9 .XX getCDKGraphBox
10 .XX getCDKGraphCharacter
11 .XX getCDKGraphCharacters
12 .XX getCDKGraphDisplayType
13 .XX getCDKGraphValue
14 .XX getCDKGraphValues
15 .XX moveCDKGraph
16 .XX newCDKGraph
17 .XX positionCDKGraph
18 .XX setCDKGraph
19 .XX setCDKGraphBackgroundAttrib
20 .XX setCDKGraphBackgroundColor
21 .XX setCDKGraphBox
22 .XX setCDKGraphBoxAttribute
23 .XX setCDKGraphCharacter
24 .XX setCDKGraphCharacters
25 .XX setCDKGraphDisplayType
26 .XX setCDKGraphHorizontalChar
27 .XX setCDKGraphLLChar
28 .XX setCDKGraphLRChar
29 .XX setCDKGraphULChar
30 .XX setCDKGraphURChar
31 .XX setCDKGraphValue
32 .XX setCDKGraphValues
33 .XX setCDKGraphVerticalChar
34 cdk_graph \- curses graph widget
35 .SH SYNOPSIS
36 .LP
37 .B cc
38 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
39 .B \-lcdk
40 .RI "[ " "library" " \|.\|.\|. ]"
41 .LP
42 #include <cdk.h>
43 .nf
44 .TP 15
45 .B "void activateCDKGraph ("
46 .BI "CDKGRAPH *" "graph",
47 .BI "chtype *" "unused");
48 .TP 15
49 .B "void destroyCDKGraph ("
50 .BI "CDKGRAPH *" "graph");
51 .TP 15
52 .B "void drawCDKGraph ("
53 .BI "CDKGRAPH *" "graph",
54 .BI "boolean " "box");
55 .TP 15
56 .B "void eraseCDKGraph ("
57 .BI "CDKGRAPH *" "graph");
58 .TP 15
59 .B "boolean getCDKGraphBox ("
60 .BI "CDKGRAPH *" "graph");
61 .TP 15
62 .B "chtype getCDKGraphCharacter ("
63 .BI "CDKGRAPH *" "graph",
64 .BI "int " "index");
65 .TP 15
66 .B "chtype *getCDKGraphCharacters ("
67 .BI "CDKGRAPH *" "graph");
68 .TP 15
69 .B "EGraphDisplayType getCDKGraphDisplayType ("
70 .BI "CDKGRAPH *" "graph");
71 .TP 15
72 .B "int getCDKGraphValue ("
73 .BI "CDKGRAPH *" "graph",
74 .BI "int " "index");
75 .TP 15
76 .B "int *getCDKGraphValues ("
77 .BI "CDKGRAPH *" "graph",
78 .BI "int *" "size");
79 .TP 15
80 .B "void moveCDKGraph ("
81 .BI "CDKGRAPH *" "graph",
82 .BI "int " "xpos",
83 .BI "int " "ypos",
84 .BI "boolean " "relative",
85 .BI "boolean " "refresh");
86 .TP 15
87 .B "CDKGRAPH *newCDKGraph ("
88 .BI "CDKSCREEN *" "cdkscreen",
89 .BI "int " "xpos",
90 .BI "int " "ypos",
91 .BI "int " "height",
92 .BI "int " "width",
93 .BI "char *" "title",
94 .BI "char *" "xtitle",
95 .BI "char *" "ytitle");
96 .TP 15
97 .B "void positionCDKGraph ("
98 .BI "CDKGRAPH *" "graph");
99 .TP 15
100 .B "int setCDKGraph ("
101 .BI "CDKGRAPH *" "graph",
102 .BI "int *" "values",
103 .BI "int " "valueCount",
104 .BI "char *" "graphCharacters",
105 .BI "boolean " "startAtZero",
106 .BI "EGraphDisplayType " "displayType");
107 .TP 15
108 .B "void setCDKGraphBackgroundAttrib ("
109 .BI "CDKGRAPH *" "graph",
110 .BI "chtype " "attribute");
111 .TP 15
112 .B "void setCDKGraphBackgroundColor ("
113 .BI "CDKGRAPH *" "graph",
114 .BI "char * " "color");
115 .TP 15
116 .B "void setCDKGraphBox ("
117 .BI "CDKGRAPH *" "graph",
118 .BI "boolean " "box");
119 .TP 15
120 .B "void setCDKGraphBoxAttribute ("
121 .BI "CDKGRAPH *" "graph",
122 .BI "chtype " "character");
123 .TP 15
124 .B "int setCDKGraphCharacter ("
125 .BI "CDKGRAPH *" "graph",
126 .BI "int " "index",
127 .BI "char *" "graphCharacter");
128 .TP 15
129 .B "int setCDKGraphCharacters ("
130 .BI "CDKGRAPH *" "graph",
131 .BI "char *" "graphCharacters");
132 .TP 15
133 .B "void setCDKGraphDisplayType ("
134 .BI "CDKGRAPH *" "graph",
135 .BI "EGraphDisplayType " "type");
136 .TP 15
137 .B "void setCDKGraphHorizontalChar ("
138 .BI "CDKGRAPH *" "graph",
139 .BI "chtype " "character");
140 .TP 15
141 .B "void setCDKGraphLLChar ("
142 .BI "CDKGRAPH *" "graph",
143 .BI "chtype " "character");
144 .TP 15
145 .B "void setCDKGraphLRChar ("
146 .BI "CDKGRAPH *" "graph",
147 .BI "chtype " "character");
148 .TP 15
149 .B "void setCDKGraphULChar ("
150 .BI "CDKGRAPH *" "graph",
151 .BI "chtype " "character");
152 .TP 15
153 .B "void setCDKGraphURChar ("
154 .BI "CDKGRAPH *" "graph",
155 .BI "chtype " "character");
156 .TP 15
157 .B "int setCDKGraphValue ("
158 .BI "CDKGRAPH *" "graph",
159 .BI "int " "index",
160 .BI "int " "value",
161 .BI "boolean " "startAtZero");
162 .TP 15
163 .B "int setCDKGraphValues ("
164 .BI "CDKGRAPH *" "graph",
165 .BI "int *" "values",
166 .BI "int " "valueCount",
167 .BI "boolean " "startAtZero");
168 .TP 15
169 .B "void setCDKGraphVerticalChar ("
170 .BI "CDKGRAPH *" "graph",
171 .BI "chtype " "character");
172 .fi
173 .SH DESCRIPTION
174 The Cdk graph widget creates a graph in either X/Y plot or line mode.
175 The following functions create or manipulate the Cdk graph box widget.
176 .SH AVAILABLE FUNCTIONS
177 .TP 5
178 .B activateCDKGraph
179 this is an obsolete function that calls \fBdrawCDKGraph\fP.
180 .TP 5
181 .B destroyCDKGraph
182 removes the widget from the screen and frees memory the object used.
183 .TP 5
184 .B drawCDKGraph
185 draws the graph widget on the screen.
186 The \fBbox\fR option tells whether to draw the widget with a box.
187 .TP 5
188 .B eraseCDKGraph
189 removes the widget from the screen.
190 This does \fINOT\fR destroy the widget.
191 .TP 5
192 .B getCDKGraphBox
193 returns true if the widget will be drawn with a box around it.
194 .TP 5
195 .B getCDKGraphCharacter
196 returns the character in the graph at the given index.
197 .TP 5
198 .B getCDKGraphCharacters
199 returns all the characters currently in the graph widget.
200 .TP 5
201 .B getCDKGraphDisplayType
202 returns the current display type of the widget.
203 .TP 5
204 .B getCDKGraphValue
205 returns the value in the graph at the given index.
206 .TP 5
207 .B getCDKGraphValues
208 returns all the values currently in the graph widget.
209 .TP 5
210 .B moveCDKGraph
211 moves the given widget to the given position.
212 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
213 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
214 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
215 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
216 \fIRIGHT\fR, and \fICENTER\fR.
217 The parameter \fBrelative\fR states whether
218 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
219 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
220 then the widget would move one row down and two columns right.
221 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
222 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
223 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
224 (weird things may happen).
225 The final parameter \fBrefresh\fR is a boolean value which states
226 whether the widget will get refreshed after the move.
227 .TP 5
228 .B newCDKGraph
229 creates a pointer to a graph widget.
230 Parameters:
231 .RS
232 .TP 5
233 \fBscreen\fR
234 is the screen you wish this widget to be placed in.
235 .TP 5
236 \fBxpos\fR
237 controls the placement of the object along the horizontal axis.
238 It may be an integer or one of the pre-defined values
239 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
240 .TP 5
241 \fBypos\fR
242 controls the placement of the object along the vertical axis.
243 It may be an integer or one of the pre-defined values
244 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
245 .TP 5
246 \fBheight\fR and
247 .TP 5
248 \fBwidth\fR
249 control the height and width of the widget.
250 If you provide a zero for either of the height or the width,
251 the widget will be created with the full width and height of the screen.
252 If you provide a negative value, the widget will be created the full height or
253 width minus the value provided.
254 .TP 5
255 \fBtitle\fR,
256 .TP 5
257 \fBxtitle\fR and
258 .TP 5
259 \fBytitle\fR
260 are the graph title, the X axis title, and the Y axis title respectively.
261 The graph title may be more than one line by providing a
262 carriage return character at the line break.
263 .RE
264 .IP
265 If the widget could not be created then a \fINULL\fR pointer is returned.
266 .TP 5
267 .B positionCDKGraph
268 allows the user to move the widget around the screen via the
269 cursor/keypad keys.
270 See \fBcdk_position (3)\fR for key bindings.
271 .TP 5
272 .B setCDKGraph
273 lets the programmer set the specific values of the graph widget.
274 The parameter \fBvalues\fR is an integer array of the values to display in the
275 widget; \fBvalueCount\fR is the number of values in the array.
276 The parameter \fBgraphCharacters\fR is an array of the characters to use for each graph point.
277 The parameter \fBstartAtZero\fR states whether you want the graph to start at
278 zero or the lowest values of the X and Y axis'.
279 The parameter \fBdisplayType\fR
280 may be \fIvPLOT\fR, to make the graph draw the values as a plot graph,
281 or \fIvLINE\fR to draw the values as a line graph.
282 .TP 5
283 .B setCDKGraphBackgroundAttrib
284 sets the background attribute of the widget.
285 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
286 .TP 5
287 .B setCDKGraphBackgroundColor
288 sets the background color of the widget.
289 The parameter \fBcolor\fR
290 is in the format of the Cdk format strings.
291 See \fBcdk_display (3)\fR.
292 .TP 5
293 .B setCDKGraphBox
294 sets whether the widget will be drawn with a box around it.
295 .TP 5
296 .B setCDKGraphBoxAttribute
297 function sets the attribute of the box.
298 .TP 5
299 .B setCDKGraphCharacter
300 lets the programmer set a specific character of the graph widget.
301 The parameter \fBcharacter\fR is the new character, while \fBindex\fR is the
302 index where the new character will be stored.
303 .TP 5
304 .B setCDKGraphCharacters
305 lets the programmer set the specific characters of the graph widget.
306 The parameter \fBcharacters\fR is a char pointer array of the characters to display
307 in the widget.
308 .TP 5
309 .B setCDKGraphDisplayType
310 allows the programmer tochange the way the graph draws itself.
311 The parameter \fBdisplayType\fR may be \fIvPLOT\fR, to make the graph
312 draw the values as a plot graph, or \fIvLINE\fR to draw the values as a line graph.
313 .TP 5
314 .B setCDKGraphHorizontalChar
315 sets the horizontal drawing character for the box to
316 the given character.
317 .TP 5
318 .B setCDKGraphLLChar
319 sets the lower left hand corner of the widget's box to
320 the given character.
321 .TP 5
322 .B setCDKGraphLRChar
323 sets the lower right hand corner of the widget's box to
324 the given character.
325 .TP 5
326 .B setCDKGraphULChar
327 sets the upper left hand corner of the widget's box to
328 the given character.
329 .TP 5
330 .B setCDKGraphURChar
331 sets the upper right hand corner of the widget's box to
332 the given character.
333 .TP 5
334 .B setCDKGraphValue
335 lets the programmer set a specific value of the graph widget.
336 The parameter \fBvalue\fR is the new value, while \fBindex\fR is the
337 index where the new value will be stored.
338 The parameter \fBstartAtZero\fR
339 states whether you want the graph to start at zero or the lowest values of
340 the X and Y axis.
341 .TP 5
342 .B setCDKGraphValues
343 lets the programmer set the specific values of the graph widget.
344 The parameter \fBvalues\fR is an integer array of the values to display in the
345 widget; where \fBvalueCount\fR is the number of values in the array.
346 The parameter \fBstartAtZero\fR states whether you want the graph to start at
347 zero or the lowest values of the X and Y axis'.
348 .TP 5
349 .B setCDKGraphVerticalChar
350 sets the vertical drawing character for the box to the given character.
351 .SH SEE ALSO
352 .BR cdk (3),
353 .BR cdk_binding (3),
354 .BR cdk_display (3),
355 .BR cdk_position (3),
356 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_histogram.3,v 1.14 2005/12/28 18:35:31 tom Exp $
2 .de XX
3 ..
4 .TH cdk_histogram 3
5 .SH NAME
6 .XX activateCDKHistogram
7 .XX destroyCDKHistogram
8 .XX drawCDKHistogram
9 .XX eraseCDKHistogram
10 .XX getCDKHistogramBox
11 .XX getCDKHistogramFillerChar
12 .XX getCDKHistogramHighValue
13 .XX getCDKHistogramLowValue
14 .XX getCDKHistogramStatsAttr
15 .XX getCDKHistogramStatsPos
16 .XX getCDKHistogramValue
17 .XX getCDKHistogramViewType
18 .XX moveCDKHistogram
19 .XX newCDKHistogram
20 .XX positionCDKHistogram
21 .XX setCDKHistogram
22 .XX setCDKHistogramBackgroundAttrib
23 .XX setCDKHistogramBackgroundColor
24 .XX setCDKHistogramBox
25 .XX setCDKHistogramBoxAttribute
26 .XX setCDKHistogramDisplayType
27 .XX setCDKHistogramFillerChar
28 .XX setCDKHistogramHorizontalChar
29 .XX setCDKHistogramLLChar
30 .XX setCDKHistogramLRChar
31 .XX setCDKHistogramStatsAttr
32 .XX setCDKHistogramStatsPos
33 .XX setCDKHistogramULChar
34 .XX setCDKHistogramURChar
35 .XX setCDKHistogramValue
36 .XX setCDKHistogramVerticalChar
37 .XX setCDKHistogramViewType
38 cdk_histogram \- curses histogram widget
39 .SH SYNOPSIS
40 .LP
41 .B cc
42 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
43 .B \-lcdk
44 .RI "[ " "library" " \|.\|.\|. ]"
45 .LP
46 #include <cdk.h>
47 .nf
48 .TP 15
49 .B "void activateCDKHistogram ("
50 .BI "CDKHISTOGRAM *" "histogram",
51 .BI "chtype " "unused");
52 .TP 15
53 .B "void destroyCDKHistogram ("
54 .BI "CDKHISTOGRAM *" "histogram");
55 .TP 15
56 .B "void drawCDKHistogram ("
57 .BI "CDKHISTOGRAM *" "histogram",
58 .BI "boolean " "box");
59 .TP 15
60 .B "void eraseCDKHistogram ("
61 .BI "CDKHISTOGRAM *" "histogram");
62 .TP 15
63 .B "boolean getCDKHistogramBox ("
64 .BI "CDKHISTOGRAM *" "histogram");
65 .TP 15
66 .B "chtype getCDKHistogramFillerChar ("
67 .BI "CDKHISTOGRAM *" "histogram");
68 .TP 15
69 .B "int getCDKHistogramHighValue ("
70 .BI "CDKHISTOGRAM *" "histogram");
71 .TP 15
72 .B "int getCDKHistogramLowValue ("
73 .BI "CDKHISTOGRAM *" "histogram");
74 .TP 15
75 .B "chtype getCDKHistogramStatsAttr ("
76 .BI "CDKHISTOGRAM *" "histogram");
77 .TP 15
78 .B "int getCDKHistogramStatsPos ("
79 .BI "CDKHISTOGRAM *" "histogram");
80 .TP 15
81 .B "int getCDKHistogramValue ("
82 .BI "CDKHISTOGRAM *" "histogram");
83 .TP 15
84 .B "EHistogramDisplayType getCDKHistogramViewType ("
85 .BI "CDKHISTOGRAM *" "histogram");
86 .TP 15
87 .B "void moveCDKHistogram ("
88 .BI "CDKHISTOGRAM *" "histogram",
89 .BI "int " "xpos",
90 .BI "int " "ypos",
91 .BI "boolean " "relative",
92 .BI "boolean " "refresh");
93 .TP 15
94 .B "CDKHISTOGRAM *newCDKHistogram ("
95 .BI "CDKSCREEN *" "cdkscreen",
96 .BI "int " "xpos",
97 .BI "int " "ypos",
98 .BI "int " "height",
99 .BI "int " "width",
100 .BI "int " "orient",
101 .BI "char *" "title",
102 .BI "boolean " "box",
103 .BI "boolean " "shadow");
104 .TP 15
105 .B "void positionCDKHistogram ("
106 .BI "CDKHISTOGRAM *" "histogram");
107 .TP 15
108 .B "void setCDKHistogram ("
109 .BI "CDKHISTOGRAM *" "histogram",
110 .BI "EHistogramDisplayType " "viewType",
111 .BI "int " "statsPos",
112 .BI "chtype " "statsAttribute",
113 .BI "int " "lowValue",
114 .BI "int " "highValue",
115 .BI "int " "currentValue",
116 .BI "chtype " "fillerCharacter",
117 .BI "boolean " "box");
118 .TP 15
119 .B "void setCDKHistogramBackgroundAttrib ("
120 .BI "CDKHISTOGRAM *" "histogram",
121 .BI "chtype " "attribute");
122 .TP 15
123 .B "void setCDKHistogramBackgroundColor ("
124 .BI "CDKHISTOGRAM *" "histogram",
125 .BI "char * " "color");
126 .TP 15
127 .B "void setCDKHistogramBox ("
128 .BI "CDKHISTOGRAM *" "histogram",
129 .BI "boolean " "box");
130 .TP 15
131 .B "void setCDKHistogramBoxAttribute ("
132 .BI "CDKHISTOGRAM *" "histogram",
133 .BI "chtype " "character");
134 .TP 15
135 .B "void setCDKHistogramDisplayType ("
136 .BI "CDKHISTOGRAM *" "histogram",
137 .BI "EHistogramDisplayType " "viewtype");
138 .TP 15
139 .B "void setCDKHistogramFillerChar ("
140 .BI "CDKHISTOGRAM *" "histogram",
141 .BI "chtype " "fillerCharacter");
142 .TP 15
143 .B "void setCDKHistogramHorizontalChar ("
144 .BI "CDKHISTOGRAM *" "histogram",
145 .BI "chtype " "character");
146 .TP 15
147 .B "void setCDKHistogramLLChar ("
148 .BI "CDKHISTOGRAM *" "histogram",
149 .BI "chtype " "character");
150 .TP 15
151 .B "void setCDKHistogramLRChar ("
152 .BI "CDKHISTOGRAM *" "histogram",
153 .BI "chtype " "character");
154 .TP 15
155 .B "void setCDKHistogramStatsAttr ("
156 .BI "CDKHISTOGRAM *" "histogram",
157 .BI "chtype " "statsAttribute");
158 .TP 15
159 .B "void setCDKHistogramStatsPos ("
160 .BI "CDKHISTOGRAM *" "histogram",
161 .BI "int " "statsPosition");
162 .TP 15
163 .B "void setCDKHistogramULChar ("
164 .BI "CDKHISTOGRAM *" "histogram",
165 .BI "chtype " "character");
166 .TP 15
167 .B "void setCDKHistogramURChar ("
168 .BI "CDKHISTOGRAM *" "histogram",
169 .BI "chtype " "character");
170 .TP 15
171 .B "void setCDKHistogramValue ("
172 .BI "CDKHISTOGRAM *" "histogram",
173 .BI "int " "lowValue",
174 .BI "int " "highValue",
175 .BI "int " "currentValue");
176 .TP 15
177 .B "void setCDKHistogramVerticalChar ("
178 .BI "CDKHISTOGRAM *" "histogram",
179 .BI "chtype " "character");
180 .TP 15
181 .B "void setCDKHistogramViewType ("
182 .BI "CDKHISTOGRAM *" "histogram",
183 .BI "EHistogramDisplayType " "viewType");
184 .fi
185 .SH DESCRIPTION
186 The Cdk histogram widget creates a histogram widget.
187 This widget can draw a vertical or horizontal histogram.
188 The functions create or manipulate the Cdk histogram box widget.
189 .SH AVAILABLE FUNCTIONS
190 .TP 5
191 .B activateCDKHistogram
192 obsolete entrypoint which calls \fBdrawCDKHistogram\fP.
193 .TP 5
194 .B destroyCDKHistogram
195 removes the widget from the screen and frees memory the object used.
196 .TP 5
197 .B drawCDKHistogram
198 draws the histogram widget on the screen.
199 If the \fBbox\fR parameter is true, the widget is drawn with a box.
200 .TP 5
201 .B eraseCDKHistogram
202 removes the widget from the screen.
203 This does \fINOT\fR destroy the widget.
204 .TP 5
205 .B getCDKHistogramBox
206 returns true if the widget will be drawn with a box around it.
207 .TP 5
208 .B getCDKHistogramFillerChar
209 returns the character being used to draw the histogram bar.
210 .TP 5
211 .B getCDKHistogramHighValue
212 returns the high value of the histogram.
213 .TP 5
214 .B getCDKHistogramLowValue
215 returns the low value of the histogram.
216 .TP 5
217 .B getCDKHistogramStatsAttr
218 returns the attribute of the statistics of the histogram.
219 .TP 5
220 .B getCDKHistogramStatsPos
221 returns where the histogram will draw the statistics.
222 .TP 5
223 .B getCDKHistogramValue
224 returns the current value of the histogram.
225 .TP 5
226 .B getCDKHistogramViewType
227 returns the view type of the histogram widget.
228 .TP 5
229 .B moveCDKHistogram
230 moves the given widget to the given position.
231 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
232 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
233 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
234 The parameter \fBypos\fR can be an integer or one of the pre-defined values
235 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
236 The parameter \fBrelative\fR states whether
237 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
238 For example
239 if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
240 then the widget would move one row down and two columns right.
241 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
242 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
243 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
244 (weird things may happen).
245 The final parameter \fBrefresh\fR is a boolean value which states
246 whether the widget will get refreshed after the move.
247 .TP 5
248 .B newCDKHistogram
249 creates a histogram widget and returns a pointer to it.
250 Parameters:
251 .RS
252 .TP 5
253 \fBscreen\fR
254 is the screen you wish this widget to be placed in.
255 .TP 5
256 \fBxpos\fR
257 controls the placement of the object along the horizontal axis.
258 It may be an integer or one of the pre-defined values
259 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
260 .TP 5
261 \fBypos\fR
262 controls the placement of the object along the vertical axis.
263 It may be an integer or one of the pre-defined values
264 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
265 .TP 5
266 \fBtitle\fR
267 is the string which will be displayed at the top of the widget.
268 The title can be more than one line; just provide a carriage return
269 character at the line break.
270 .TP 5
271 \fBheight\fR and
272 .TP 5
273 \fBwidth\fR
274 control the height and width of the widget.
275 If you provide a value of zero for either
276 of the height or the width, the widget will be created with the full width and
277 height of the screen.
278 If you provide a negative value, the widget will be created
279 the full height or width minus the value provided.
280 .TP 5
281 \fBorient\fR
282 specifies the orientation of the histogram.
283 It is one of these pre-defined values: \fIVERTICAL\fR and \fIHORIZONTAL\fR.
284 .TP 5
285 \fBlabel\fR
286 is the string to use as the label of the histogram.
287 .TP 5
288 \fBbox\fR
289 is true if the widget should be drawn with a box around it.
290 .TP 5
291 \fBshadow\fR
292 turns the shadow on or off around this widget.
293 .RE
294 .IP
295 If the widget could not be created then a \fINULL\fR pointer is returned.
296 .TP 5
297 .B positionCDKHistogram
298 allows the user to move the widget around the screen via the
299 cursor/keypad keys.
300 See \fBcdk_position (3)\fR for key bindings.
301 .TP 5
302 .B setCDKHistogram
303 lets the programmer set the specific values of the histogram widget.
304 The parameter \fBviewType\fR specifies the type of histogram to draw.
305 The following table lists the valid values and the results.
306 .LP
307 .TS
308 center tab(/) allbox;
309 l l
310 lw15 lw30 .
311 \fBDisplay_Type/Result\fR
312 vNONE/T{
313 Displays no information about the current values.
314 T}
315 vPERCENT/T{
316 Displays the current value as a percentage.
317 T}
318 vFRACTION/T{
319 Displays the current value as a fraction.
320 T}
321 vREAL/Displays the current value.
322 .TE
323 .sp
324 .TP 5
325 \&
326 The \fBstatsPosition\fR parameter states where the statistics will be displayed.
327 It accepts \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
328 .IP
329 The parameter \fBstatsAttribute\fR sets the attributes of the statistics.
330 .IP
331 The parameters \fBlowValue\fR, \fBhighValue\fR, and \fBcurrentValue\fR are the low, high,
332 and current values respectively.
333 .IP
334 The \fBfiller\fR character is the character
335 to use in the unused space in the histogram.
336 .IP
337 If the \fBbox\fR parameter is true, the widget is drawn with a box.
338 .TP 5
339 .B setCDKHistogramBackgroundAttrib
340 the background color attribute the widget.
341 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
342 .TP 5
343 .B setCDKHistogramBackgroundColor
344 the background color of the widget.
345 The parameter \fBcolor\fR
346 is in the format of the Cdk format strings.
347 See \fBcdk_display (3)\fR.
348 .TP 5
349 .B setCDKHistogramBox
350 sets whether the widget will be drawn with a box around it.
351 .TP 5
352 .B setCDKHistogramBoxAttribute
353 sets the attribute of the box.
354 .TP 5
355 .B setCDKHistogramDisplayType
356 sets the display type (see \fBgetCDKHistogramViewType\fP).
357 .TP 5
358 .B setCDKHistogramFillerChar
359 sets the character to use when drawing the histogram bar.
360 .TP 5
361 .B setCDKHistogramHorizontalChar
362 sets the horizontal drawing character for the box to
363 the given character.
364 .TP 5
365 .B setCDKHistogramLLChar
366 sets the lower left hand corner of the widget's box to
367 the given character.
368 .TP 5
369 .B setCDKHistogramLRChar
370 sets the lower right hand corner of the widget's box to
371 the given character.
372 .TP 5
373 .B setCDKHistogramStatsAttr
374 sets the attribute to use when drawing the histogram statistics.
375 .TP 5
376 .B setCDKHistogramStatsPos
377 sets where the statistics will be drawn on the widget.
378 See the \fBsetCDKHistogram\fR description for more details.
379 .TP 5
380 .B setCDKHistogramULChar
381 sets the upper left hand corner of the widget's box to the given character.
382 .TP 5
383 .B setCDKHistogramURChar
384 sets the upper right hand corner of the widget's box to
385 the given character.
386 .TP 5
387 .B setCDKHistogramValue
388 sets the low, high, and current value of the histogram.
389 .TP 5
390 .B setCDKHistogramVerticalChar
391 sets the vertical drawing character for the box to
392 the given character.
393 .TP 5
394 .B setCDKHistogramViewType
395 sets the view type of the histogram.
396 Look at the \fBsetCDKHistogram\fR description for more details.
397 .SH SEE ALSO
398 .BR cdk (3),
399 .BR cdk_binding (3),
400 .BR cdk_display (3),
401 .BR cdk_position (3),
402 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_itemlist.3,v 1.18 2005/12/28 18:35:31 tom Exp $
2 .de XX
3 ..
4 .TH cdk_itemlist 3
5 .SH NAME
6 .XX activateCDKItemlist
7 .XX destroyCDKItemlist
8 .XX drawCDKItemlist
9 .XX drawCDKItemlistField
10 .XX eraseCDKItemlist
11 .XX getCDKItemlistBox
12 .XX getCDKItemlistCurrentItem
13 .XX getCDKItemlistDefaultItem
14 .XX getCDKItemlistValues
15 .XX injectCDKItemlist
16 .XX moveCDKItemlist
17 .XX newCDKItemlist
18 .XX positionCDKItemlist
19 .XX setCDKItemlist
20 .XX setCDKItemlistBackgroundAttrib
21 .XX setCDKItemlistBackgroundColor
22 .XX setCDKItemlistBox
23 .XX setCDKItemlistBoxAttribute
24 .XX setCDKItemlistCurrentItem
25 .XX setCDKItemlistDefaultItem
26 .XX setCDKItemlistHorizontalChar
27 .XX setCDKItemlistLLChar
28 .XX setCDKItemlistLRChar
29 .XX setCDKItemlistPostProcess
30 .XX setCDKItemlistPreProcess
31 .XX setCDKItemlistULChar
32 .XX setCDKItemlistURChar
33 .XX setCDKItemlistValues
34 .XX setCDKItemlistVerticalChar
35 cdk_itemlist \- curses itemlist widget.
36 .SH SYNOPSIS
37 .LP
38 .B cc
39 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
40 .B \-lcdk
41 .RI "[ " "library" " \|.\|.\|. ]"
42 .LP
43 #include <cdk.h>
44 .nf
45 .TP 15
46 .B "int activateCDKItemlist ("
47 .BI "CDKITEMLIST *" "itemlist",
48 .BI "chtype *" "actions");
49 .TP 15
50 .B "void destroyCDKItemlist ("
51 .BI "CDKITEMLIST *" "itemlist");
52 .TP 15
53 .B "void drawCDKItemlist ("
54 .BI "CDKITEMLIST *" "itemlist",
55 .BI "boolean " "box");
56 .TP 15
57 .B "void drawCDKItemlistField ("
58 .BI "CDKITEMLIST *" "itemlist",
59 .BI "boolean " "highlight");
60 .TP 15
61 .B "void eraseCDKItemlist ("
62 .BI "CDKITEMLIST *" "itemlist");
63 .TP 15
64 .B "boolean getCDKItemlistBox ("
65 .BI "CDKITEMLIST *" "itemlist");
66 .TP 15
67 .B "int getCDKItemlistCurrentItem ("
68 .BI "CDKITEMLIST *" "itemlist");
69 .TP 15
70 .B "int getCDKItemlistDefaultItem ("
71 .BI "CDKITEMLIST *" "itemlist");
72 .TP 15
73 .B "chtype **getCDKItemlistValues ("
74 .BI "CDKITEMLIST *" "itemlist",
75 .BI "int *" "listSize");
76 .TP 15
77 .B "int injectCDKItemlist ("
78 .BI "CDKITEMLIST *" "itemlist",
79 .BI "chtype " "input");
80 .TP 15
81 .B "void moveCDKItemlist ("
82 .BI "CDKITEMLIST *" "itemlist",
83 .BI "int " "xpos",
84 .BI "int " "ypos",
85 .BI "boolean " "relative",
86 .BI "boolean " "refresh");
87 .TP 15
88 .B "CDKITEMLIST *newCDKItemlist ("
89 .BI "CDKSCREEN *" "cdkscreen",
90 .BI "int " "xpos",
91 .BI "int " "ypos",
92 .BI "char *" "title",
93 .BI "char *" "label",
94 .BI "char **" "itemList",
95 .BI "int " "itemCount",
96 .BI "int " "defaultItem",
97 .BI "boolean " "box",
98 .BI "boolean " "shadow");
99 .TP 15
100 .B "void positionCDKItemlist ("
101 .BI "CDKITEMLIST *" "itemlist");
102 .TP 15
103 .B "void setCDKItemlist ("
104 .BI "CDKITEMLIST *" "itemlist",
105 .BI "char **" "itemList",
106 .BI "int " "itemCount",
107 .BI "int " "currentSelection",
108 .BI "boolean " "box");
109 .TP 15
110 .B "void setCDKItemlistBackgroundAttrib ("
111 .BI "CDKITEMLIST *" "itemlist",
112 .BI "chtype" "attribute");
113 .TP 15
114 .B "void setCDKItemlistBackgroundColor ("
115 .BI "CDKITEMLIST *" "itemlist",
116 .BI "char *" "color");
117 .TP 15
118 .B "void setCDKItemlistBox ("
119 .BI "CDKITEMLIST *" "itemlist",
120 .BI "boolean " "box");
121 .TP 15
122 .B "void setCDKItemlistBoxAttribute ("
123 .BI "CDKITEMLIST *" "itemlist",
124 .BI "chtype " "character");
125 .TP 15
126 .B "void setCDKItemlistCurrentItem ("
127 .BI "CDKITEMLIST *" "itemlist",
128 .BI "int " "currentItem");
129 .TP 15
130 .B "void setCDKItemlistDefaultItem ("
131 .BI "CDKITEMLIST *" "itemlist",
132 .BI "int " "defaultItem");
133 .TP 15
134 .B "void setCDKItemlistHorizontalChar ("
135 .BI "CDKITEMLIST *" "itemlist",
136 .BI "chtype " "character");
137 .TP 15
138 .B "void setCDKItemlistLLChar ("
139 .BI "CDKITEMLIST *" "itemlist",
140 .BI "chtype " "character");
141 .TP 15
142 .B "void setCDKItemlistLRChar ("
143 .BI "CDKITEMLIST *" "itemlist",
144 .BI "chtype " "character");
145 .TP 15
146 .B "void setCDKItemlistPostProcess ("
147 .BI "CDKITEMLIST *" "itemlist",
148 .BI "PROCESSFN " "callback",
149 .BI "void *" "data");
150 .TP 15
151 .B "void setCDKItemlistPreProcess ("
152 .BI "CDKITEMLIST *" "itemlist",
153 .BI "PROCESSFN " "callback",
154 .BI "void *" "data");
155 .TP 15
156 .B "void setCDKItemlistULChar ("
157 .BI "CDKITEMLIST *" "itemlist",
158 .BI "chtype " "character");
159 .TP 15
160 .B "void setCDKItemlistURChar ("
161 .BI "CDKITEMLIST *" "itemlist",
162 .BI "chtype " "character");
163 .TP 15
164 .B "void setCDKItemlistValues ("
165 .BI "CDKITEMLIST *" "itemlist",
166 .BI "char **" "itemList",
167 .BI "int " "itemCount");
168 .TP 15
169 .B "void setCDKItemlistVerticalChar ("
170 .BI "CDKITEMLIST *" "itemlist",
171 .BI "chtype " "character");
172 .fi
173 .SH DESCRIPTION
174 The Cdk itemlist widget creates a widget which allows a user to select from a
175 list of preset character strings such as
176 the days of the week or the months of the year.
177 The following functions create or manipulate the Cdk itemlist widget.
178 .SH AVAILABLE FUNCTIONS
179 .TP 5
180 .B activateCDKItemlist
181 activates the itemlist widget and lets the user interact with the widget.
182 The parameter \fBitemlist\fR is a pointer to a non-NULL itemlist widget.
183 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
184 in the array will be injected into the widget.
185 To activate the widget
186 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
187 If the character entered
188 into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a
189 value from 0 to the number of buttons -1, representing the button selected.
190 It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
191 If the character entered into this widget was \fIESCAPE\fR
192 then the widget will return a -1
193 and the widget data \fIexitType\fR will be set to
194 \fIvESCAPE_HIT\fR.
195 .TP 5
196 .B destroyCDKItemlist
197 removes the widget from the screen and frees memory the object used.
198 .TP 5
199 .B drawCDKItemlist
200 draws the itemlist widget on the screen.
201 The \fBbox\fR option is true if the widget is drawn with a box.
202 .TP 5
203 .B drawCDKItemlistField
204 draws the contents of the field.
205 .TP 5
206 .B eraseCDKItemlist
207 removes the widget from the screen.
208 This does \fINOT\fR destroy the widget.
209 .TP 5
210 .B getCDKItemlistBox
211 returns true if the widget will be drawn with a box around it.
212 .TP 5
213 .B getCDKItemlistCurrentItem
214 returns the index of the currently displayed item in the widget.
215 .TP 5
216 .B getCDKItemlistDefaultItem
217 returns the index of the default item in the widget.
218 .TP 5
219 .B getCDKItemlistValues
220 returns the list of pointers to the items.
221 The parameter \fBsize\fR points to a location which receives the item count.
222 .TP 5
223 .B injectCDKItemlist
224 injects a single character into the widget.
225 The parameter \fBitemlist\fR is a pointer to a non-NULL itemlist widget.
226 The parameter \fBcharacter\fR is the character to inject into the widget.
227 The return value and side-effect (setting the widget data \fIexitType\fP)
228 depend upon the injected character:
229 .RS
230 .TP
231 \fIRETURN\fP or \fITAB\fR
232 the function returns
233 a value ranging from zero to one less than the number of buttons,
234 representing the button selected.
235 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
236 .TP
237 \fIESCAPE\fP
238 the function returns
239 -1.
240 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
241 .TP
242 Otherwise
243 unless modified by preprocessing, postprocessing or key bindings,
244 the function returns
245 -1.
246 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
247 .RE
248 .TP 5
249 .B moveCDKItemlist
250 moves the given widget to the given position.
251 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
252 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
253 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
254 The parameter \fBypos\fR may
255 be an integer or one of the pre-defined values \fILEFT\fR,
256 \fIRIGHT\fR, and \fICENTER\fR.
257 The parameter \fBrelative\fR states whether
258 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
259 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
260 then the widget would move one row down and two columns right.
261 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
262 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
263 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
264 (weird things may happen).
265 The final parameter \fBrefresh\fR is a boolean value which
266 states whether the widget will get refreshed after the move.
267 .TP 5
268 .B newCDKItemlist
269 creates a pointer to an itemlist widget.
270 Parameters:
271 .RS
272 .TP 5
273 \fBscreen\fR
274 is the screen you wish this widget to be placed in.
275 .TP 5
276 \fBxpos\fR
277 controls the placement of the object along the horizontal axis.
278 It may be an integer or one of the pre-defined values
279 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
280 .TP 5
281 \fBypos\fR
282 controls the placement of the object along the vertical axis.
283 It may be an integer or one of the pre-defined values
284 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
285 .TP 5
286 \fBtitle\fR
287 is the string which will be displayed at the top of the widget.
288 The title can be more than one line; just provide a carriage return
289 character at the line break.
290 .TP 5
291 \fBlabel\fR
292 is the string to use as the label of the itemlist field.
293 .TP 5
294 \fBitemList\fR
295 is the list of the strings which will be displayed in the widget.
296 .TP 5
297 \fBitemCount\fR
298 is the number of elements in the list.
299 .TP 5
300 \fBdefaultItem\fR
301 is the index of the default item for the list.
302 .TP 5
303 \fBbox\fR
304 is true if widget should be drawn with a box around it.
305 .TP 5
306 \fBshadow\fR
307 turns the shadow on or off around this widget.
308 .RE
309 .IP
310 If the widget could not be created then a \fINULL\fR pointer is returned.
311 .TP 5
312 .B positionCDKItemlist
313 allows the user to move the widget around the screen via the cursor/keypad keys.
314 See \fBcdk_position (3)\fR for key bindings.
315 .TP 5
316 .B setCDKItemlist
317 lets the programmer modify certain elements of an existing itemlist widget.
318 The parameter names correspond to the same parameter names
319 listed in the \fBnewCDKItemlist\fR function.
320 .TP 5
321 .B setCDKItemlistBackgroundAttrib
322 the background color attribute the widget.
323 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
324 .TP 5
325 .B setCDKItemlistBackgroundColor
326 sets the background color of the widget.
327 The parameter \fBcolor\fR is in the format of the Cdk format strings.
328 See \fBcdk_display (3)\fR.
329 .TP 5
330 .B setCDKItemlistBox
331 sets whether the widget will be drawn with a box around it.
332 .TP 5
333 .B setCDKItemlistBoxAttribute
334 sets the attribute of the box.
335 .TP 5
336 .B setCDKItemlistCurrentItem
337 sets the currently displayed item in the widget.
338 .TP 5
339 .B setCDKItemlistDefaultItem
340 sets the default item in the widget.
341 .TP 5
342 .B setCDKItemlistHorizontalChar
343 sets the horizontal drawing character for the box to the given character.
344 .TP 5
345 .B setCDKItemlistLLChar
346 sets the lower left hand corner of the widget's box to the given character.
347 .TP 5
348 .B setCDKItemlistLRChar
349 sets the lower right hand corner of the widget's box to the given character.
350 .TP 5
351 .B setCDKItemlistPostProcess
352 allows the user to have the widget call a function after the
353 key has been applied to the widget.
354 The parameter \fBfunction\fR is the callback function.
355 The parameter \fBdata\fR points to data passed to the callback function.
356 To learn more about post-processing see \fIcdk_process (3)\fR.
357 .TP 5
358 .B setCDKItemlistPreProcess
359 allows the user to have the widget call a function after a key
360 is hit and before the key is applied to the widget.
361 The parameter \fBfunction\fR is the callback function.
362 The parameter \fBdata\fR points to data passed to the callback function.
363 To learn more about pre-processing see \fIcdk_process (3)\fR.
364 .TP 5
365 .B setCDKItemlistULChar
366 sets the upper left hand corner of the widget's box to the given character.
367 .TP 5
368 .B setCDKItemlistURChar
369 sets the upper right hand corner of the widget's box to the given character.
370 .TP 5
371 .B setCDKItemlistValues
372 sets the contents of the list from an array of string pointers \fBitem\fR
373 whose final index is given by \fBcount\fR.
374 If \fBdefaultItem\fR is in the range 0..\fBcount\fR, that sets the
375 default item value for the list.
376 .TP 5
377 .B setCDKItemlistVerticalChar
378 sets the vertical drawing character for the box to the given character.
379 .SH KEY BINDINGS
380 When the widget is activated there are several default key bindings which will
381 help the user enter or manipulate the information quickly.
382 The following table
383 outlines the keys and their actions for this widget.
384 .LP
385 .TS
386 center tab(/) box;
387 l l
388 l l
389 lw15 lw35 .
390 \fBKey/Action\fR
391 =
392 Left Arrow
393 Down Arrow
394 -
395 p/Shift the list one column to the left.
396 _
397 Right Arrow
398 Up Arrow
399 Space
400 +
401 n/Shift the list one column to the right.
402 _
403 d
404 D/Display the default item.
405 _
406 0/Display the first item in the list.
407 $/Display the last item in the list.
408 _
409 Return/T{
410 Exit the widget and return an integer representing the current selection.
411 Also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
412 T}
413 Tab/T{
414 Exit the widget and return an integer representing the current selection.
415 Also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
416 T}
417 Escape/T{
418 Exit the widget and return -1.
419 Also set the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
420 T}
421 Ctrl-L/Refreshes the screen.
422 .TE
423 .SH SEE ALSO
424 .BR cdk (3),
425 .BR cdk_binding (3),
426 .BR cdk_display (3),
427 .BR cdk_position (3),
428 .BR cdk_process (3),
429 .BR cdk_screen (3)
0 .\" $Id: cdk_label.3,v 1.14 2005/12/28 18:35:31 tom Exp $
1 .de XX
2 ..
3 .TH cdk_label 3
4 .SH NAME
5 .XX activateCDKLabel
6 .XX destroyCDKLabel
7 .XX drawCDKLabel
8 .XX eraseCDKLabel
9 .XX getCDKLabelBox
10 .XX getCDKLabelMessage
11 .XX moveCDKLabel
12 .XX newCDKLabel
13 .XX positionCDKLabel
14 .XX setCDKLabel
15 .XX setCDKLabelBackgroundAttrib
16 .XX setCDKLabelBackgroundColor
17 .XX setCDKLabelBox
18 .XX setCDKLabelBoxAttribute
19 .XX setCDKLabelHorizontalChar
20 .XX setCDKLabelLLChar
21 .XX setCDKLabelLRChar
22 .XX setCDKLabelMessage
23 .XX setCDKLabelULChar
24 .XX setCDKLabelURChar
25 .XX setCDKLabelVerticalChar
26 .XX waitCDKLabel
27 cdk_label \- Creates a managed curses label widget.
28 .SH SYNOPSIS
29 .LP
30 .B cc
31 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
32 .B \-lcdk
33 .RI "[ " "library" " \|.\|.\|. ]"
34 .LP
35 #include <cdk.h>
36 .nf
37 .TP 15
38 .B "void activateCDKLabel ("
39 .BI "CDKLABEL *" "label",
40 .BI "chtype " "unused");
41 .TP 15
42 .B "void destroyCDKLabel ("
43 .BI "CDKLABEL *" "label");
44 .TP 15
45 .B "void drawCDKLabel ("
46 .BI "CDKLABEL *" "label",
47 .BI "boolean " "box");
48 .TP 15
49 .B "void eraseCDKLabel ("
50 .BI "CDKLABEL *" "label");
51 .TP 15
52 .B "boolean getCDKLabelBox ("
53 .BI "CDKLABEL *" "label");
54 .TP 15
55 .B "chtype **getCDKLabelMessage ("
56 .BI "CDKLABEL *" "label"
57 .BI "int *" "messageLines");
58 .TP 15
59 .B "void moveCDKLabel ("
60 .BI "CDKLABEL *" "label",
61 .BI "int " "xpos",
62 .BI "int " "ypos",
63 .BI "boolean " "relative",
64 .BI "boolean " "refresh");
65 .TP 15
66 .B "CDKLABEL *newCDKLabel ("
67 .BI "CDKSCREEN *" "cdkscreen",
68 .BI "int " "xpos",
69 .BI "int " "ypos",
70 .BI "char **" "message",
71 .BI "int " "messageLines",
72 .BI "boolean " "box",
73 .BI "boolean " "shadow");
74 .TP 15
75 .B "void positionCDKLabel ("
76 .BI "CDKLABEL *" "label");
77 .TP 15
78 .B "void setCDKLabel ("
79 .BI "CDKLABEL *" "label",
80 .BI "char **" "message",
81 .BI "int " "messageLines",
82 .BI "boolean " "box");
83 .TP 15
84 .B "void setCDKLabelBackgroundAttrib ("
85 .BI "CDKLABEL *" "label",
86 .BI "chtype " "attribute");
87 .TP 15
88 .B "void setCDKLabelBackgroundColor ("
89 .BI "CDKLABEL *" "label",
90 .BI "char * " "color");
91 .TP 15
92 .B "void setCDKLabelBox ("
93 .BI "CDKLABEL *" "label",
94 .BI "boolean " "box");
95 .TP 15
96 .B "void setCDKLabelBoxAttribute ("
97 .BI "CDKLABEL *" "label",
98 .BI "chtype " "character");
99 .TP 15
100 .B "void setCDKLabelHorizontalChar ("
101 .BI "CDKLABEL *" "label",
102 .BI "chtype " "character");
103 .TP 15
104 .B "void setCDKLabelLLChar ("
105 .BI "CDKLABEL *" "label",
106 .BI "chtype " "character");
107 .TP 15
108 .B "void setCDKLabelLRChar ("
109 .BI "CDKLABEL *" "label",
110 .BI "chtype " "character");
111 .TP 15
112 .B "void setCDKLabelMessage ("
113 .BI "CDKLABEL *" "label",
114 .BI "char **" "message",
115 .BI "int " "messageLines");
116 .TP 15
117 .B "void setCDKLabelULChar ("
118 .BI "CDKLABEL *" "label",
119 .BI "chtype " "character");
120 .TP 15
121 .B "void setCDKLabelURChar ("
122 .BI "CDKLABEL *" "label",
123 .BI "chtype " "character");
124 .TP 15
125 .B "void setCDKLabelVerticalChar ("
126 .BI "CDKLABEL *" "label",
127 .BI "chtype " "character");
128 .TP 15
129 .B "char waitCDKLabel ("
130 .BI "CDKLABEL *" "label",
131 .BI "char " "key");
132 .fi
133 .SH DESCRIPTION
134 The Cdk label widget creates a pop-up label window.
135 The following functions create or manipulate the Cdk label widget.
136 .SH AVAILABLE FUNCTIONS
137 .TP 5
138 .B activateCDKLabel
139 obsolete entrypoint which calls \fBdrawCDKLabel\fP.
140 .TP 5
141 .B destroyCDKLabel
142 removes the widget from the screen and frees memory the object used.
143 .TP 5
144 .B drawCDKLabel
145 draws the label widget on the screen.
146 If the \fBbox\fR parameter is true, the widget is drawn with a box.
147 .TP 5
148 .B eraseCDKLabel
149 removes the widget from the screen.
150 This does \fINOT\fR destroy the widget.
151 .TP 5
152 .B getCDKLabelBox
153 returns true if the widget will be drawn with a box around it.
154 .TP 5
155 .B getCDKLabelMessage
156 returns the contents of the label widget.
157 The parameter \fBmessageLines\fR points to the location
158 which will be given the number of message-lines.
159 .TP 5
160 .B moveCDKLabel
161 moves the given widget to the given position.
162 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
163 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
164 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
165 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
166 \fIRIGHT\fR, and \fICENTER\fR.
167 The parameter \fBrelative\fR states whether
168 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
169 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
170 then the widget would move one row down and two columns right.
171 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
172 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
173 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
174 (weird things may happen).
175 The final parameter \fBrefresh\fR is a boolean value which
176 states whether the widget will get refreshed after the move.
177 .TP 5
178 .B newCDKLabel
179 creates a label widget and returns a pointer to it.
180 Parameters:
181 .RS
182 .TP 5
183 \fBscreen\fR
184 is the screen you wish this widget to be placed in.
185 .TP 5
186 \fBxpos\fR
187 controls the placement of the object along the horizontal axis.
188 It may be an integer or one of the pre-defined values
189 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
190 .TP 5
191 \fBypos\fR
192 controls the placement of the object along the vertical axis.
193 It may be an integer or one of the pre-defined values
194 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
195 .TP 5
196 \fBmessage\fR
197 is the message to be displayed in the window.
198 It may contain any of the standard Cdk display format commands.
199 To learn more about this see \fIcdk_display (3)\fR.
200 .TP 5
201 \fBrows\fR
202 is the number of message rows that were passed in the \fBmessage\fR parameter.
203 .TP 5
204 \fBbox\fR
205 is true if widget should be drawn with a box around it.
206 .TP 5
207 \fBshadow\fR
208 turns the shadow on or off around this widget.
209 .RE
210 .IP
211 If the widget could not be created then a \fINULL\fR pointer is returned.
212 .TP 5
213 .B positionCDKLabel
214 allows the user to move the widget around the screen via the
215 cursor/keypad keys.
216 See \fBcdk_position (3)\fR for key bindings.
217 .TP 5
218 .B setCDKLabel
219 allows the user to change the contents of the label widget.
220 The parameters are the same as the \fBnewCDKLabel\fR.
221 .TP 5
222 .B setCDKLabelBackgroundAttrib
223 sets the background attribute of the widget.
224 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
225 .TP 5
226 .B setCDKLabelBackgroundColor
227 sets the background color of the widget.
228 The parameter \fBcolor\fR is in the format of the Cdk format strings.
229 For more information see \fIcdk_display (3)\fR.
230 .TP 5
231 .B setCDKLabelBox
232 sets whether the widget will be drawn with a box around it.
233 .TP 5
234 .B setCDKLabelBoxAttribute
235 sets the attribute of the box.
236 .TP 5
237 .B setCDKLabelHorizontalChar
238 sets the horizontal drawing character for the box to the given character.
239 .TP 5
240 .B setCDKLabelLLChar
241 sets the lower left hand corner of the widget's box to the given character.
242 .TP 5
243 .B setCDKLabelLRChar
244 sets the lower right hand corner of the widget's box to the given character.
245 .TP 5
246 .B setCDKLabelMessage
247 This sets the contents of the label widget.
248 .TP 5
249 .B setCDKLabelULChar
250 sets the upper left hand corner of the widget's box to the given character.
251 .TP 5
252 .B setCDKLabelURChar
253 sets the upper right hand corner of the widget's box to the given character.
254 .TP 5
255 .B setCDKLabelVerticalChar
256 sets the vertical drawing character for the box to the given character.
257 .TP 5
258 .B waitCDKLabel
259 waits for a user to press a key.
260 The \fBlabel\fR parameter is the pointer to a label widget,
261 and \fBkey\fR is the key to wait for.
262 If no specific key is desired, use \fI(char)0\fR.
263 .SH SEE ALSO
264 .BR cdk (3),
265 .BR cdk_binding (3),
266 .BR cdk_display (3),
267 .BR cdk_position (3),
268 .BR cdk_screen (3)
0 .\" $Id: cdk_marquee.3,v 1.15 2005/12/28 18:35:31 tom Exp $
1 .de XX
2 ..
3 .TH cdk_marquee 3
4 .SH NAME
5 .XX activateCDKMarquee
6 .XX deactivateCDKMarquee
7 .XX destroyCDKMarquee
8 .XX drawCDKMarquee
9 .XX eraseCDKMarquee
10 .XX getCDKMarqueeBox
11 .XX moveCDKMarquee
12 .XX newCDKMarquee
13 .XX positionCDKMarquee
14 .XX setCDKMarqueeBackgroundAttrib
15 .XX setCDKMarqueeBackgroundColor
16 .XX setCDKMarqueeBox
17 .XX setCDKMarqueeBoxAttribute
18 .XX setCDKMarqueeHorizontalChar
19 .XX setCDKMarqueeLLChar
20 .XX setCDKMarqueeLRChar
21 .XX setCDKMarqueeULChar
22 .XX setCDKMarqueeURChar
23 .XX setCDKMarqueeVerticalChar
24 cdk_marquee \- curses marquee widget
25 .SH SYNOPSIS
26 .LP
27 .B cc
28 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
29 .B \-lcdk
30 .RI "[ " "library" " \|.\|.\|. ]"
31 .LP
32 #include <cdk.h>
33 .nf
34 .TP 15
35 .B "int activateCDKMarquee ("
36 .BI "CDKMARQUEE *" "marquee",
37 .BI "char *" "message",
38 .BI "int " "delay",
39 .BI "int " "repeat",
40 .BI "boolean " "box");
41 .TP 15
42 .B "void deactivateCDKMarquee ("
43 .BI "CDKMARQUEE *" "marquee");
44 .TP 15
45 .B "void destroyCDKMarquee ("
46 .BI "CDKMARQUEE *" "marquee");
47 .TP 15
48 .B "void drawCDKMarquee ("
49 .BI "CDKMARQUEE *" "marquee",
50 .BI "boolean " "box");
51 .TP 15
52 .B "void eraseCDKMarquee ("
53 .BI "CDKMARQUEE *" "marquee");
54 .TP 15
55 .B "boolean getCDKMarqueeBox ("
56 .BI "CDKMENTRY *" "mentry");
57 .TP 15
58 .B "void moveCDKMarquee ("
59 .BI "CDKMARQUEE *" "marquee",
60 .BI "int " "xpos",
61 .BI "int " "ypos",
62 .BI "boolean " "relative",
63 .BI "boolean " "refresh");
64 .TP 15
65 .B "CDKMARQUEE *newCDKMarquee ("
66 .BI "CDKSCREEN *" "cdkscreen",
67 .BI "int " "xpos",
68 .BI "int " "ypos",
69 .BI "int " "fieldWidth",
70 .BI "boolean " "box",
71 .BI "boolean " "shadow");
72 .TP 15
73 .B "void positionCDKMarquee ("
74 .BI "CDKMARQUEE *" "marquee");
75 .TP 15
76 .B "void setCDKMarqueeBackgroundAttrib ("
77 .BI "CDKMARQUEE *" "marquee",
78 .BI "chtype " "attribute");
79 .TP 15
80 .B "void setCDKMarqueeBackgroundColor ("
81 .BI "CDKMARQUEE *" "marquee",
82 .BI "char * " "color");
83 .TP 15
84 .B "void setCDKMarqueeBox ("
85 .BI "CDKMENTRY *" "mentry",
86 .BI "boolean " "boxWidget");
87 .TP 15
88 .B "void setCDKMarqueeBoxAttribute ("
89 .BI "CDKMARQUEE *" "marquee",
90 .BI "chtype " "character");
91 .TP 15
92 .B "void setCDKMarqueeHorizontalChar ("
93 .BI "CDKMARQUEE *" "marquee",
94 .BI "chtype " "character");
95 .TP 15
96 .B "void setCDKMarqueeLLChar ("
97 .BI "CDKMARQUEE *" "marquee",
98 .BI "chtype " "character");
99 .TP 15
100 .B "void setCDKMarqueeLRChar ("
101 .BI "CDKMARQUEE *" "marquee",
102 .BI "chtype " "character");
103 .TP 15
104 .B "void setCDKMarqueeULChar ("
105 .BI "CDKMARQUEE *" "marquee",
106 .BI "chtype " "character");
107 .TP 15
108 .B "void setCDKMarqueeURChar ("
109 .BI "CDKMARQUEE *" "marquee",
110 .BI "chtype " "character");
111 .TP 15
112 .B "void setCDKMarqueeVerticalChar ("
113 .BI "CDKMARQUEE *" "marquee",
114 .BI "chtype " "character");
115 .fi
116 .LP
117 .SH DESCRIPTION
118 The Cdk marquee widget creates a pop-up marquee window.
119 The following functions create or manipulate the Cdk marquee widget.
120 .SH AVAILABLE FUNCTIONS
121 .TP 5
122 .B activateCDKMarquee
123 activates the marquee widget.
124 The \fBmarquee\fR parameter is a
125 pointer to a defined marquee widget.
126 The \fBdelay\fR parameter states how long
127 to wait between movements.
128 This value is highly dependent on each machine the
129 program runs on.
130 The \fBrepeat\fR value tells the marquee widget how many times
131 to display the given message.
132 The \fBbox\fR option draws the widget with or
133 without a box.
134 This function returns -1 if the message passed is \fINULL\fR,
135 0 otherwise.
136 .TP 5
137 .B deactivateCDKMarquee
138 deactivates the marquee widget.
139 .TP 5
140 .B destroyCDKMarquee
141 removes the widget from the screen and frees memory the object used.
142 .TP 5
143 .B drawCDKMarquee
144 draws the marquee widget on the screen.
145 If the \fBbox\fR parameter is true, the widget is drawn with a box.
146 .TP 5
147 .B eraseCDKMarquee
148 removes the widget from the screen.
149 This does \fINOT\fR destroy the widget.
150 .TP 5
151 .B getCDKMarqueeBox
152 returns true if the widget will be drawn with a box around it.
153 .TP 5
154 .B moveCDKMarquee
155 moves the given widget to the given position.
156 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
157 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
158 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
159 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
160 \fIRIGHT\fR, and \fICENTER\fR.
161 The parameter \fBrelative\fR states whether
162 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
163 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
164 then the widget would move one row down and two columns right.
165 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
166 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
167 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
168 (weird things may happen).
169 The final parameter \fBrefresh\fR is a boolean value which
170 states whether the widget will get refreshed after the move.
171 .TP 5
172 .B newCDKMarquee
173 creates a marquee widget and returns a pointer to it.
174 Parameters:
175 .RS
176 .TP 5
177 \fBscreen\fR
178 is the screen you wish this widget to be placed in.
179 .TP 5
180 \fBxpos\fR
181 controls the placement of the object along the horizontal axis.
182 It may be an integer or one of the pre-defined values
183 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
184 .TP 5
185 \fBypos\fR
186 controls the placement of the object along the vertical axis.
187 It may be an integer or one of the pre-defined values
188 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
189 .TP 5
190 \fBwidth\fR
191 controls the width of the field.
192 If you provide a value of zero for the width,
193 the widget uses the width of the screen.
194 If a negative value is provided,
195 then the widget uses the width of the screen less the value provided.
196 .TP 5
197 \fBshadow\fR
198 turns the shadow on or off around this widget.
199 .RE
200 .IP
201 If the widget could not be created then a \fINULL\fR pointer is returned.
202 .TP 5
203 .B positionCDKMarquee
204 allows the user to move the widget around the screen via the cursor/keypad keys.
205 See \fBcdk_position (3)\fR for key bindings.
206 .TP 5
207 .B setCDKMarqueeBackgroundAttrib
208 sets the background attribute of the widget.
209 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
210 .TP 5
211 .B setCDKMarqueeBackgroundColor
212 sets the background color of the widget.
213 The parameter \fBcolor\fR is in the format of the Cdk format strings.
214 For more information see \fIcdk_display (3)\fR.
215 .TP 5
216 .B setCDKMarqueeBox
217 sets whether the widget will be drawn with a box around it.
218 .TP 5
219 .B setCDKMarqueeBoxAttribute
220 sets the attribute of the box.
221 .TP 5
222 .B setCDKMarqueeHorizontalChar
223 sets the horizontal drawing character for the box to the given character.
224 .TP 5
225 .B setCDKMarqueeLLChar
226 sets the lower left hand corner of the widget's box to the given character.
227 .TP 5
228 .B setCDKMarqueeLRChar
229 sets the lower right hand corner of the widget's box to the given character.
230 .TP 5
231 .B setCDKMarqueeULChar
232 sets the upper left hand corner of the widget's box to the given character.
233 .TP 5
234 .B setCDKMarqueeURChar
235 sets the upper right hand corner of the widget's box to the given character.
236 .TP 5
237 .B setCDKMarqueeVerticalChar
238 sets the vertical drawing character for the box to the given character.
239 .SH SEE ALSO
240 .BR cdk (3),
241 .BR cdk_binding (3),
242 .BR cdk_display (3),
243 .BR cdk_position (3),
244 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_matrix.3,v 1.24 2006/04/15 14:10:32 tom Exp $
2 .de XX
3 ..
4 .TH cdk_matrix 3
5 .SH NAME
6 .XX activateCDKMatrix
7 .XX cleanCDKMatrix
8 .XX cleanCDKMatrixCell
9 .XX destroyCDKMatrix
10 .XX drawCDKMatrix
11 .XX eraseCDKMatrix
12 .XX getCDKMatrixBox
13 .XX getCDKMatrixCell
14 .XX getCDKMatrixCol
15 .XX getCDKMatrixRow
16 .XX injectCDKMatrix
17 .XX jumpToCell
18 .XX moveToCDKMatrixCell
19 .XX newCDKMatrix
20 .XX setCDKMatrix
21 .XX setCDKMatrixBackgroundAttrib
22 .XX setCDKMatrixBackgroundColor
23 .XX setCDKMatrixBox
24 .XX setCDKMatrixBoxAttribute
25 .XX setCDKMatrixCB
26 .XX setCDKMatrixCell
27 .XX setCDKMatrixCells
28 .XX setCDKMatrixHorizontalChar
29 .XX setCDKMatrixLLChar
30 .XX setCDKMatrixLRChar
31 .XX setCDKMatrixPostProcess
32 .XX setCDKMatrixPreProcess
33 .XX setCDKMatrixULChar
34 .XX setCDKMatrixURChar
35 .XX setCDKMatrixVerticalChar
36 cdk_matrix \- curses matrix widget.
37 .SH SYNOPSIS
38 .LP
39 .B cc
40 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
41 .B \-lcdk
42 .RI "[ " "library" " \|.\|.\|. ]"
43 .LP
44 #include <cdk.h>
45 .nf
46 .TP 15
47 .B "int activateCDKMatrix ("
48 .BI "CDKMATRIX *" "matrix",
49 .BI "chtype * " "actions");
50 .TP 15
51 .B "void cleanCDKMatrix ("
52 .BI "CDKMATRIX *" "matrix");
53 .TP
54 .B "void cleanCDKMatrixCell ("
55 .BI "CDKMATRIX *" "matrix",
56 .BI "int " "row",
57 .BI "int " "col");
58 .TP 15
59 .B "void destroyCDKMatrix ("
60 .BI "CDKMATRIX *" "matrix");
61 .TP 15
62 .B "void drawCDKMatrix ("
63 .BI "CDKMATRIX *" "matrix",
64 .BI "boolean " "box");
65 .TP 15
66 .B "void eraseCDKMatrix ("
67 .BI "CDKMATRIX *" "matrix");
68 .TP 15
69 .B "boolean getCDKMatrixBox ("
70 .BI "CDKMENTRY *" "matrix");
71 .TP 15
72 .B "char * getCDKMatrixCell ("
73 .BI "CDKMATRIX *" "matrix",
74 .BI "int " "row",
75 .BI "int " "col");
76 .TP 15
77 .B "int getCDKMatrixCol ("
78 .BI "CDKMENTRY *" "matrix");
79 .TP 15
80 .B "int getCDKMatrixRow ("
81 .BI "CDKMENTRY *" "matrix");
82 .TP 15
83 .B "int injectCDKMatrix ("
84 .BI "CDKMATRIX *" "matrix",
85 .BI "chtype " "input");
86 .TP 15
87 .B "int jumpToCell ("
88 .BI "CDKMATRIX *" "matrix",
89 .BI "int " "row",
90 .BI "int " "col");
91 .TP 15
92 .B "void moveCDKMatrix ("
93 .BI "CDKMATRIX *" "matrix",
94 .BI "int " "xpos",
95 .BI "int " "ypos",
96 .BI "boolean " "relative",
97 .BI "boolean " "refresh");
98 .TP 15
99 .B "int moveToCDKMatrixCell ("
100 .BI "CDKMATRIX *" "matrix",
101 .BI "int " "row",
102 .BI "int " "col");
103 .TP 15
104 .B "CDKMATRIX *newCDKMatrix ("
105 .BI "CDKSCREEN *" "cdkscreen",
106 .BI "int " "xpos",
107 .BI "int " "ypos",
108 .BI "int " "screenRows",
109 .BI "int " "screenCols",
110 .BI "int " "actualRows",
111 .BI "int " "actualCols",
112 .BI "char *" "title",
113 .BI "char **" "rowTitles",
114 .BI "char **" "colTitles",
115 .BI "int *" "columnWidths",
116 .BI "int *" "columnTypes",
117 .BI "int " "rowSpace",
118 .BI "int " "colSpace",
119 .BI "chtype " "filler",
120 .BI "int " "dominantAttribute",
121 .BI "boolean " "boxMatrix",
122 .BI "boolean " "boxCell",
123 .BI "boolean " "shadow");
124 .TP 15
125 .B "void positionCDKMatrix ("
126 .BI "CDKMATRIX *" "matrix");
127 .TP 15
128 .B "void setCDKMatrix ("
129 .BI "CDKMATRIX *" "matrix",
130 .BI "char *" "info"[MAX_MATRIX_ROWS][MAX_MATRIX_COLS],
131 .BI "int " "rows",
132 .BI "int *" "columnLengths");
133 .TP 15
134 .B "void setCDKMatrixBackgroundAttrib ("
135 .BI "CDKMATRIX *" "matrix",
136 .BI "chtype " "attribute");
137 .TP 15
138 .B "void setCDKMatrixBackgroundColor ("
139 .BI "CDKMATRIX *" "matrix",
140 .BI "char * " "color");
141 .TP 15
142 .B "void setCDKMatrixBox ("
143 .BI "CDKMENTRY *" "matrix",
144 .BI "boolean " "boxWidget");
145 .TP 15
146 .B "void setCDKMatrixBoxAttribute ("
147 .BI "CDKMATRIX *" "matrix",
148 .BI "chtype " "character");
149 .TP 15
150 .B "void setCDKMatrixCB ("
151 .BI "CDKMATRIX *" "matrix",
152 .BI "MATRIXCB " "callbackFunction");
153 .TP 15
154 .B "int setCDKMatrixCell ("
155 .BI "CDKMATRIX *" "matrix",
156 .BI "int " "row",
157 .BI "int " "col",
158 .BI "char *" "value");
159 .B "void setCDKMatrixCells ("
160 .BI "CDKMATRIX *" "matrix",
161 .BI "char **" "info",
162 .BI "int " "rows",
163 .BI "int " "cols",
164 .BI "int *" "columnLengths");
165 .TP 15
166 .B "void setCDKMatrixHorizontalChar ("
167 .BI "CDKMATRIX *" "matrix",
168 .BI "chtype " "character");
169 .TP 15
170 .B "void setCDKMatrixLLChar ("
171 .BI "CDKMATRIX *" "matrix",
172 .BI "chtype " "character");
173 .TP 15
174 .B "void setCDKMatrixLRChar ("
175 .BI "CDKMATRIX *" "matrix",
176 .BI "chtype " "character");
177 .TP 15
178 .B "void setCDKMatrixPostProcess ("
179 .BI "CDKMATRIX *" "matrix",
180 .BI "PROCESSFN " "callback",
181 .BI "void * " "data");
182 .TP 15
183 .B "void setCDKMatrixPreProcess ("
184 .BI "CDKMATRIX *" "matrix",
185 .BI "PROCESSFN " "callback",
186 .BI "void * " "data");
187 .TP 15
188 .B "void setCDKMatrixULChar ("
189 .BI "CDKMATRIX *" "matrix",
190 .BI "chtype " "character");
191 .TP 15
192 .B "void setCDKMatrixURChar ("
193 .BI "CDKMATRIX *" "matrix",
194 .BI "chtype " "character");
195 .TP 15
196 .B "void setCDKMatrixVerticalChar ("
197 .BI "CDKMATRIX *" "matrix",
198 .BI "chtype " "character");
199 .fi
200 .SH DESCRIPTION
201 The Cdk matrix widget creates a matrix widget.
202 The following are functions which
203 create or manipulate the Cdk matrix box widget.
204 .SH AVAILABLE FUNCTIONS
205 .TP 5
206 .B activateCDKMatrix
207 activates the matrix widget and lets the user interact with the widget.
208 The parameter \fBmatrix\fR is a pointer to a non-NULL matrix widget.
209 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
210 in the array will be injected into the widget.
211 To activate the widget
212 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
213 If the character
214 entered into this widget is \fIRETURN\fR then this function will return 1.
215 It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
216 If the character entered into this widget was \fIESCAPE\fR then the widget
217 will return a value of -1 and the widget data \fIexitType\fR will be
218 set to \fIvESCAPE_HIT\fR.
219 The matrix cell contents can be retrieved by using
220 the \fBinfo\fR array of the matrix widget.
221 .TP 5
222 .B cleanCDKMatrix
223 clears the information from all cells of the matrix.
224 .TP
225 .B cleanCDKMatrixCell
226 clears the information from the specified cell of the matrix.
227 .TP 5
228 .B destroyCDKMatrix
229 removes the widget from the screen and frees memory the object used.
230 .TP 5
231 .B drawCDKMatrix
232 draws the matrix widget on the screen.
233 If the \fBbox\fR parameter is true, the widget is drawn with a box.
234 .TP 5
235 .B eraseCDKMatrix
236 removes the widget from the screen.
237 This does \fINOT\fR destroy the widget.
238 .TP 5
239 .B getCDKMatrixBox
240 returns true if the widget will be drawn with a box around it.
241 .TP 5
242 .B getCDKMatrixCell
243 returns the contents of the cell located by the \fBrow\fR and \fBcol\fR pair.
244 .TP 5
245 .B getCDKMatrixCol
246 returns the current column index.
247 .TP 5
248 .B getCDKMatrixRow
249 returns the current row index.
250 .TP 5
251 .B injectCDKMatrix
252 injects a single character into the widget.
253 The parameter \fBmatrix\fR is a pointer to a non-NULL matrix widget.
254 The parameter \fBcharacter\fR is the character to inject into the widget.
255 The return value and side-effect (setting the widget data \fIexitType\fP)
256 depend upon the injected character:
257 .RS
258 .TP
259 \fIRETURN\fP or \fITAB\fR
260 the function returns
261 1.
262 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
263 .TP
264 \fIESCAPE\fP
265 the function returns
266 -1.
267 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
268 .TP
269 Otherwise
270 unless modified by preprocessing, postprocessing or key bindings,
271 the function returns
272 -1.
273 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
274 .RE
275 .IP
276 The matrix cell contents can be retrieved by
277 using the \fBinfo\fR array of the matrix widget.
278 .TP 5
279 .B jumpToCell
280 provides an interactive method of moving to a cell.
281 It pops up a
282 scale widget and asks which cell the user wants to go to.
283 Then it performs the jump.
284 .TP 5
285 .B moveCDKMatrix
286 moves the given widget to the given position.
287 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
288 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
289 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
290 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
291 \fIRIGHT\fR, and \fICENTER\fR.
292 The parameter \fBrelative\fR states whether
293 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
294 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
295 then the widget would move one row down and two columns right.
296 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
297 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
298 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
299 (weird things may happen).
300 The final parameter \fBrefresh\fR is a boolean value which
301 states whether the widget will get refreshed after the move.
302 .TP 5
303 .B moveToCDKMatrixCell
304 jumps to the given cells dictated by the parameters \fBrow\fR and \fBcol\fR.
305 It returns a value of \fITRUE\fR or \fIFALSE\fR depending if
306 the move was successful.
307 .TP 5
308 .B newCDKMatrix
309 creates a matrix widget and returns a pointer to it.
310 Parameters:
311 .RS
312 .TP 5
313 \fBscreen\fR
314 is the screen you wish this widget to be placed in.
315 .TP 5
316 \fBxpos\fR
317 controls the placement of the object along the horizontal axis.
318 It may be an integer or one of the pre-defined values
319 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
320 .TP 5
321 \fBypos\fR
322 controls the placement of the object along the vertical axis.
323 It may be an integer or one of the pre-defined values
324 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
325 .TP 5
326 \fBscreenRows\fR and
327 .TP 5
328 \fBscreenCols\fR
329 are the number of rows and
330 columns to be displayed on the screen respectively.
331 .TP 5
332 \fBactualRows\fR and
333 .TP 5
334 \fBactualCols\fR
335 are the number of actual rows and columns the matrix has.
336 .TP 5
337 \fBtitle\fR
338 is the string which will be displayed at the top of the widget.
339 The title can be more than one line; just provide a carriage return
340 character at the line break.
341 .TP 5
342 \fBrowTitles\fR and
343 .TP 5
344 \fBcolTitles\fR
345 are the titles along the row and columns respectively.
346 .TP 5
347 \fBcolumnWidths\fR
348 is an array of integers stating how wide the individual columns are to be.
349 .TP 5
350 \fBcolumnTypes\fR
351 is an array of integers
352 which correspond to the individual column display types.
353 The values of the array should be assigned a value of type \fIEDisplayType\fR.
354 See \fBcdk_display (3)\fR for legal values of \fIEDisplayType\fR.
355 .TP 5
356 \fBrowSpace\fR and
357 .TP 5
358 \fBcolSpace\fR
359 dictate how much white space is to be between rows and columns respectively.
360 .TP 5
361 \fBfiller\fR
362 is the character to use in empty space within a cell.
363 .TP 5
364 \fBdominantAttribute\fR
365 states which (the rows or the columns)
366 will have the dominant character attributes.
367 This is stated when a cell has
368 both a row attribute and a column attribute.
369 If the value of the parameter
370 \fBdominantAttribute\fR is set to \fBROW\fR then the attribute of the row
371 will be displayed.
372 If it is set to \fBCOL\fR then the column's attributes
373 will be displayed instead.
374 .TP 5
375 \fBboxMatrix\fR
376 is true if the widget should be drawn with a box around it.
377 .TP 5
378 \fBboxCell\fR
379 is true if the individual cells should have boxes drawn around them.
380 .TP 5
381 \fBshadow\fR
382 turns the shadow on or off around this widget.
383 .RE
384 .IP
385 If the widget could not be created then a \fINULL\fR pointer is returned.
386 .TP 5
387 .B positionCDKMatrix
388 allows the user to move the widget around the screen via the
389 cursor/keypad keys.
390 See \fBcdk_position (3)\fR for key bindings.
391 .TP 5
392 .B setCDKMatrix
393 lets the programmer modify certain elements of an existing matrix widget.
394 The parameter \fBinfo\fR is an array of \fIchar *\fR which
395 contains the cell information.
396 The parameter \fBrows\fR has the number of rows
397 the parameter \fBinfo\fR contains, while \fBcolumnLengths\fR has the lengths of
398 the individual columns in \fBinfo\fR.
399 .IP
400 Do not use this function.
401 It is obsolete, provided only for compatibility with older versions of CDK.
402 Use \fBsetCDKMatrixCells\fP.
403 .TP 5
404 .B setCDKMatrixBackgroundAttrib
405 sets the background attribute of the widget.
406 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
407 .TP 5
408 .B setCDKMatrixBackgroundColor
409 sets the background color of the widget.
410 The parameter \fBcolor\fR
411 is in the format of the Cdk format strings.
412 See \fBcdk_display (3)\fR.
413 .TP 5
414 .B setCDKMatrixBox
415 sets whether the widget will be drawn with a box around it.
416 .TP 5
417 .B setCDKMatrixBoxAttribute
418 sets the attribute of the box.
419 .TP 5
420 .B setCDKMatrixCB
421 allows the programmer to set a different widget input handler.
422 The parameter \fBcallbackFunction\fR is of type \fIMATRIXCB\fR.
423 The default function is \fICDKMatrixCallBack\fR.
424 .TP 5
425 .B setCDKMatrixCell
426 sets the contents of the cell located by the \fBrow\fR and \fBcol\fR pair.
427 The value of the cell will be set to \fBvalue\fR.
428 .TP
429 .B setCDKMatrixCells,
430 lets the programmer initialize elements of an existing matrix widget.
431 The parameter \fBinfo\fR is an array of \fIchar *\fR which
432 contains the cell information.
433 The parameter \fBrows\fR has the number of rows
434 The parameter \fBcols\fR has the number of columns
435 the parameter \fBinfo\fR contains, while \fBcolumnLengths\fR has the lengths of
436 the individual columns in \fBinfo\fR.
437 .TP 5
438 .B setCDKMatrixHorizontalChar
439 sets the horizontal drawing character for the box to
440 the given character.
441 .TP 5
442 .B setCDKMatrixLLChar
443 sets the lower left hand corner of the widget's box to
444 the given character.
445 .TP 5
446 .B setCDKMatrixLRChar
447 sets the lower right hand corner of the widget's box to
448 the given character.
449 .TP 5
450 .B setCDKMatrixPostProcess
451 allows the user to have the widget call a function after the
452 key has been applied to the widget.
453 The parameter \fBfunction\fR is the callback function.
454 The parameter \fBdata\fR points to data passed to the callback function.
455 To learn more about post-processing see \fIcdk_process (3)\fR.
456 .TP 5
457 .B setCDKMatrixPreProcess
458 allows the user to have the widget call a function after a key
459 is hit and before the key is applied to the widget.
460 The parameter \fBfunction\fR is the callback function.
461 The parameter \fBdata\fR points to data passed to the callback function.
462 To learn more about pre-processing see \fIcdk_process (3)\fR.
463 .TP 5
464 .B setCDKMatrixULChar
465 sets the upper left hand corner of the widget's box to
466 the given character.
467 .TP 5
468 .B setCDKMatrixURChar
469 sets the upper right hand corner of the widget's box to
470 the given character.
471 .TP 5
472 .B setCDKMatrixVerticalChar
473 sets the vertical drawing character for the box to
474 the given character.
475 .SH KEY BINDINGS
476 When the widget is activated there are several default key bindings which will
477 help the user enter or manipulate the information quickly.
478 The following table
479 outlines the keys and their actions for this widget.
480 .TS
481 center tab(/) box;
482 l l
483 l l
484 lw15 lw35 .
485 \fBKey/Action\fR
486 =
487 Left Arrow/Moves one cell to the left.
488 Right Arrow/Moves the cell to the right.
489 Tab/Moves the cell to the right.
490 Up Arrow/Moves one cell up.
491 Down Arrow/Moves one cell down.
492 Next Page/Moves one page forward.
493 Ctrl-F/Moves one page forward.
494 Prev Page/Moves one page backward.
495 Ctrl-B/Moves one page backward.
496 Ctrl-G/T{
497 Calls the function \fBjumpToCell\fR and requests which cell the user wishes to jump to.
498 T}
499 Ctrl-P/T{
500 Pastes whatever is in the paste buffer, into the current cell.
501 T}
502 Ctrl-K/T{
503 Cuts the contents from the current cell and saves a copy in the paste buffer.
504 T}
505 Ctrl-T/T{
506 Copies the contents of the current cell into the paste buffer.
507 T}
508 Ctrl-E/Erases the contents of the current cell.
509 Delete/T{
510 Deletes the character before the cursor, moves cursor left.
511 There is no function to delete the character at the cursor since there
512 are no functions for moving the cursor within the edited text.
513 T}
514 Backspace/T{
515 Deletes the character before cursor, moves cursor left.
516 T}
517 Ctrl-H/Deletes the character before the cursor.
518 Return/T{
519 Exits the widget and returns 1.
520 This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
521 T}
522 Escape/T{
523 Exits the widget and returns -1.
524 This also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
525 T}
526 Ctrl-L/Refreshes the screen.
527 .TE
528 .SH SEE ALSO
529 .BR cdk (3),
530 .BR cdk_binding (3),
531 .BR cdk_display (3),
532 .BR cdk_position (3),
533 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_mentry.3,v 1.24 2006/04/15 14:08:31 tom Exp $
2 .de XX
3 ..
4 .TH cdk_mentry 3
5 .SH NAME
6 .XX activateCDKMentry
7 .XX cleanCDKMentry
8 .XX destroyCDKMentry
9 .XX drawCDKMentry
10 .XX drawCDKMentryField
11 .XX eraseCDKMentry
12 .XX getCDKMentryBox
13 .XX getCDKMentryFillerChar
14 .XX getCDKMentryHiddenChar
15 .XX getCDKMentryMin
16 .XX getCDKMentryValue
17 .XX injectCDKMentry
18 .XX moveCDKMentry
19 .XX newCDKMentry
20 .XX positionCDKMentry
21 .XX setCDKMentry
22 .XX setCDKMentryBackgroundAttrib
23 .XX setCDKMentryBackgroundColor
24 .XX setCDKMentryBox
25 .XX setCDKMentryBoxAttribute
26 .XX setCDKMentryCB
27 .XX setCDKMentryFillerChar
28 .XX setCDKMentryHiddenChar
29 .XX setCDKMentryHorizontalChar
30 .XX setCDKMentryLLChar
31 .XX setCDKMentryLRChar
32 .XX setCDKMentryMin
33 .XX setCDKMentryPostProcess
34 .XX setCDKMentryPreProcess
35 .XX setCDKMentryULChar
36 .XX setCDKMentryURChar
37 .XX setCDKMentryValue
38 .XX setCDKMentryVerticalChar
39 cdk_mentry \- curses multiple line entry widget.
40 .SH SYNOPSIS
41 .LP
42 .B cc
43 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
44 .B \-lcdk
45 .RI "[ " "library" " \|.\|.\|. ]"
46 .LP
47 #include <cdk.h>
48 .nf
49 .TP 15
50 .B "char *activateCDKMentry ("
51 .BI "CDKMENTRY *" "mentry",
52 .BI "chtype *" "actions");
53 .TP 15
54 .B "void cleanCDKMentry ("
55 .BI "CDKMENTRY *" "mentry");
56 .TP 15
57 .B "void destroyCDKMentry ("
58 .BI "CDKMENTRY *" "mentry");
59 .TP 15
60 .B "void drawCDKMentry ("
61 .BI "CDKMENTRY *" "mentry",
62 .BI "boolean " "box");
63 .TP 15
64 .B "void drawCDKMentryField ("
65 .BI "CDKMENTRY *" "mentry");
66 .TP 15
67 .B "void eraseCDKMentry ("
68 .BI "CDKMENTRY *" "mentry");
69 .TP 15
70 .B "boolean getCDKMentryBox ("
71 .BI "CDKMENTRY *" "mentry");
72 .TP 15
73 .B "chtype getCDKMentryFillerChar ("
74 .BI "CDKMENTRY *" "mentry");
75 .TP 15
76 .B "chtype getCDKMentryHiddenChar ("
77 .BI "CDKMENTRY *" "mentry");
78 .TP 15
79 .B "int getCDKMentryMin ("
80 .BI "CDKMENTRY *" "mentry");
81 .TP 15
82 .B "char *getCDKMentryValue ("
83 .BI "CDKMENTRY *" "mentry");
84 .TP 15
85 .B "char *injectCDKMentry ("
86 .BI "CDKMENTRY *" "mentry",
87 .BI "chtype " "input");
88 .TP 15
89 .B "void moveCDKMentry ("
90 .BI "CDKMENTRY *" "mentry",
91 .BI "int " "xpos",
92 .BI "int " "ypos",
93 .BI "boolean " "relative",
94 .BI "boolean " "refresh");
95 .TP 15
96 .B "CDKMENTRY *newCDKMentry ("
97 .BI "CDKSCREEN *" "cdkscreen",
98 .BI "int " "xpos",
99 .BI "int " "ypos",
100 .BI "char *" "title",
101 .BI "char *" "label",
102 .BI "chtype " "fieldAttribute",
103 .BI "chtype " "fillerCharacter",
104 .BI "EDisplayType " "displayType",
105 .BI "int " "fieldWidth",
106 .BI "int " "fieldRows",
107 .BI "int " "logicalRows",
108 .BI "int " "minimumLength",
109 .BI "boolean " "box",
110 .BI "boolean " "shadow");
111 .TP 15
112 .B "void positionCDKMentry ("
113 .BI "CDKMENTRY *" "mentry");
114 .TP 15
115 .B "void setCDKMentry ("
116 .BI "CDKMENTRY *" "mentry",
117 .BI "char *" "value",
118 .BI "int " "minimumLength",
119 .BI "boolean " "box");
120 .TP 15
121 .B "void setCDKMentryBackgroundAttrib ("
122 .BI "CDKMENTRY *" "mentry",
123 .BI "chtype " "attribute");
124 .TP 15
125 .B "void setCDKMentryBackgroundColor ("
126 .BI "CDKMENTRY *" "mentry",
127 .BI "char * " "color");
128 .TP 15
129 .B "void setCDKMentryBox ("
130 .BI "CDKMENTRY *" "mentry",
131 .BI "boolean " "boxWidget");
132 .TP 15
133 .B "void setCDKMentryBoxAttribute ("
134 .BI "CDKMENTRY *" "mentry",
135 .BI "chtype " "character");
136 .TP 15
137 .B "void setCDKMentryCB ("
138 .BI "CDKMENTRY *" "mentry",
139 .BI "MENTRYCB " "callBackFunction");
140 .TP 15
141 .B "void setCDKMentryFillerChar ("
142 .BI "CDKMENTRY *" "mentry",
143 .BI "chtype " "filler");
144 .TP 15
145 .B "void setCDKMentryHiddenChar ("
146 .BI "CDKMENTRY *" "mentry",
147 .BI "chtype " "character");
148 .TP 15
149 .B "void setCDKMentryHorizontalChar ("
150 .BI "CDKMENTRY *" "mentry",
151 .BI "chtype " "character");
152 .TP 15
153 .B "void setCDKMentryLLChar ("
154 .BI "CDKMENTRY *" "mentry",
155 .BI "chtype " "character");
156 .TP 15
157 .B "void setCDKMentryLRChar ("
158 .BI "CDKMENTRY *" "mentry",
159 .BI "chtype " "character");
160 .TP 15
161 .B "void setCDKMentryMin ("
162 .BI "CDKMENTRY *" "mentry",
163 .BI "int " "maximum");
164 .TP 15
165 .B "void setCDKMentryPostProcess ("
166 .BI "CDKMENTRY *" "mentry",
167 .BI "PROCESSFN " "callback",
168 .BI "void * " "data");
169 .TP 15
170 .B "void setCDKMentryPreProcess ("
171 .BI "CDKMENTRY *" "mentry",
172 .BI "PROCESSFN " "callback",
173 .BI "void * " "data");
174 .TP 15
175 .B "void setCDKMentryULChar ("
176 .BI "CDKMENTRY *" "mentry",
177 .BI "chtype " "character");
178 .TP 15
179 .B "void setCDKMentryURChar ("
180 .BI "CDKMENTRY *" "mentry",
181 .BI "chtype " "character");
182 .TP 15
183 .B "void setCDKMentryValue ("
184 .BI "CDKMENTRY *" "mentry",
185 .BI "char *" "value");
186 .TP 15
187 .B "void setCDKMentryVerticalChar ("
188 .BI "CDKMENTRY *" "mentry",
189 .BI "chtype " "character");
190 .fi
191 .SH DESCRIPTION
192 The Cdk mentry widget creates a multiple line entry box with a label and an
193 entry field.
194 The following are functions which create or manipulate the Cdk
195 mentry box widget.
196 .SH AVAILABLE FUNCTIONS
197 .TP 5
198 .B activateCDKMentry
199 activates the mentry widget and lets the user interact with the widget.
200 The parameter \fBmentry\fR is a pointer to a non-NULL mentry widget.
201 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
202 in the array will be injected into the widget.
203 To activate the widget
204 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
205 If the character entered
206 into this widget is \fIRETURN\fR or \fITAB\fR then this function will return
207 a \fIchar *\fR representing the information typed into the widget and the
208 widget data \fIexitType\fR will be set to \fIvNORMAL\fR.
209 If the character
210 entered was \fIESCAPE\fR then the function will return \fINULL\fR pointer and
211 the widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
212 .TP 5
213 .B cleanCDKMentry
214 clears the information from the field.
215 .TP 5
216 .B destroyCDKMentry
217 removes the widget from the screen and frees memory the object used.
218 .TP 5
219 .B drawCDKMentry
220 draws the widget on the screen.
221 If the \fBbox\fR parameter is true, the widget is drawn with a box.
222 .TP 5
223 .B drawCDKMentryField
224 redraws the multiple line entry field.
225 .TP 5
226 .B eraseCDKMentry
227 removes the widget from the screen.
228 This does \fINOT\fR destroy the widget.
229 .TP 5
230 .B getCDKMentryBox
231 returns true if the widget will be drawn with a box around it.
232 .TP 5
233 .B getCDKMentryFillerChar
234 returns the character being used to draw unused space in the widget.
235 .TP 5
236 .B getCDKMentryHiddenChar
237 returns the character being used to draw hidden characters in the widget (obsolete).
238 .TP 5
239 .B getCDKMentryMin
240 returns the minimum length of a string the widget will allow.
241 .TP 5
242 .B getCDKMentryValue
243 returns the current value of the widget.
244 .TP 5
245 .B injectCDKMentry
246 injects a single character into the widget.
247 The parameter \fBmentry\fR is a pointer to a non-NULL mentry.
248 The parameter \fBcharacter\fR is the character to inject into the widget.
249 The return value and side-effect (setting the widget data \fIexitType\fP)
250 depend upon the injected character:
251 .RS
252 .TP
253 \fIRETURN\fP or \fITAB\fR
254 the function returns
255 a \fIchar *\fR representing the information typed into the widget.
256 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
257 .TP
258 \fIESCAPE\fP
259 the function returns
260 a \fINULL\fR pointer.
261 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
262 .TP
263 Otherwise
264 unless modified by preprocessing, postprocessing or key bindings,
265 the function returns
266 a \fINULL\fR pointer.
267 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
268 .RE
269 .TP 5
270 .B moveCDKMentry
271 moves the given widget to the given position.
272 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
273 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
274 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
275 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
276 \fIRIGHT\fR, and \fICENTER\fR.
277 The parameter \fBrelative\fR states whether
278 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
279 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
280 then the widget would move one row down and two columns right.
281 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
282 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
283 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
284 (weird things may happen).
285 The final parameter \fBrefresh\fR is a boolean value which
286 states whether the widget will get refreshed after the move.
287 .TP 5
288 .B newCDKMentry
289 creates a mentry widget and returns a pointer to it.
290 Parameters:
291 .RS
292 .TP 5
293 \fBscreen\fR
294 is the screen you wish this widget to be placed in.
295 .TP 5
296 \fBxpos\fR
297 controls the placement of the object along the horizontal axis.
298 It may be an integer or one of the pre-defined values
299 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
300 .TP 5
301 \fBypos\fR
302 controls the placement of the object along the vertical axis.
303 It may be an integer or one of the pre-defined values
304 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
305 .TP 5
306 \fBtitle\fR
307 is the string which will be displayed at the top of the widget.
308 The title can be more than one line; just provide a carriage return
309 character at the line break.
310 .TP 5
311 \fBlabel\fR
312 is the string which will be displayed in the label of the mentry field.
313 .TP 5
314 \fBfieldAttribute\fR
315 is the attribute of the characters to be displayed when they are typed in.
316 .TP 5
317 \fBfiller\fR
318 is the character which is to display in an empty space in the mentry field.
319 .TP 5
320 \fBdisplayType\fR
321 tells how the mentry field will behave when a character is entered into the field.
322 The following table
323 outlines valid values for this field and what they mean:
324 .LP
325 .TS
326 center tab(/);
327 l l
328 l l
329 lw15 lw35 .
330 \fBDisplay_Type/Meaning\fR
331 =
332 vCHAR/Only accepts alphabetic characters.
333 vLCHAR/T{
334 Only accepts alphabetic characters.
335 Maps the character to lower case
336 when a character has been accepted.
337 T}
338 vUCHAR/T{
339 Only accepts alphabetic characters.
340 Maps the character to upper case
341 when a character has been accepted.
342 T}
343 vHCHAR/T{
344 Only accepts alphabetic characters.
345 Displays a \fI.\fR when a character
346 has been accepted.
347 T}
348 vUHCHAR/T{
349 Only accepts alphabetic characters.
350 Displays a \fI.\fR and maps the
351 character to upper case when a
352 character has been accepted.
353 T}
354 vLHCHAR/T{
355 Only accepts alphabetic characters.
356 Displays a \fI.\fR and maps the
357 character to lower case when a
358 character has been accepted.
359 T}
360 vINT/Only accepts numeric characters.
361 vHINT/T{
362 Only accepts numeric characters.
363 Displays a \fI.\fR when a character
364 has been accepted.
365 T}
366 vMIXED/Accepts any character types.
367 vLMIXED/T{
368 Accepts any character types.
369 Maps the character to lower case
370 when an alphabetic character has
371 been accepted.
372 T}
373 vUMIXED/T{
374 Accepts any character types.
375 Maps the character to upper case
376 when an alphabetic character has
377 been accepted.
378 T}
379 vHMIXED/T{
380 Accepts any character types.
381 Displays a \fI.\fR when a character
382 has been accepted.
383 T}
384 vLHMIXED/T{
385 Accepts any character types.
386 Displays a \fI.\fR and maps the
387 character to lower case when a
388 character has been accepted.
389 T}
390 vUHMIXED/T{
391 Accepts any character types.
392 Displays a \fI.\fR and maps the
393 character to upper case when a
394 character has been accepted.
395 T}
396 vVIEWONLY/Uneditable field.
397 =
398 .TE
399 .TP 5
400 \fBfieldRows\fR and
401 .TP 5
402 \fBfieldWidth\fR
403 control the height and width of the field of the widget.
404 If you provide a value of zero for either of the values,
405 the field in the widget will be made as large as it can both in width and in height.
406 If you provide a negative value, the field will be created the full height or width
407 minus the value provided.
408 .TP 5
409 \fBlogicalRows\fR
410 is the number of rows for the mentry field.
411 .TP 5
412 \fBminimumLength\fR
413 is the number of characters which must
414 be entered before the use can exit the mentry field.
415 .TP 5
416 \fBcallBackFunction\fR
417 allows the user to override the key processing element of the widget.
418 .TP 5
419 \fBbox\fR
420 is true if widget should be drawn with a box around it.
421 .TP 5
422 \fBshadow\fR
423 turns the shadow on or off around this widget.
424 .RE
425 .IP
426 If the widget could not be created then a \fINULL\fR pointer is returned.
427 .RE
428 .TP 5
429 .B positionCDKMentry
430 allows the user to move the widget around the screen via the
431 cursor/keypad keys.
432 See \fBcdk_position (3)\fR for key bindings.
433 .TP 5
434 .B setCDKMentry
435 lets the programmer modify certain elements of an existing
436 entry widget.
437 The parameter names correspond to the same parameter names listed
438 in the \fBnewCDKMentry\fR function.
439 .TP 5
440 .B setCDKMentryBackgroundAttrib
441 sets the background attribute of the widget.
442 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
443 .TP 5
444 .B setCDKMentryBackgroundColor
445 sets the background color of the widget.
446 The parameter \fBcolor\fR
447 is in the format of the Cdk format strings.
448 See \fBcdk_display (3)\fR.
449 .TP 5
450 .B setCDKMentryBox
451 sets whether the widget will be drawn with a box around it.
452 .TP 5
453 .B setCDKMentryBoxAttribute
454 function sets the attribute of the box.
455 .TP 5
456 .B setCDKMentryCB
457 function allows the programmer to set a different widget input handler.
458 The parameter \fBcallbackFunction\fR is of type \fIMENTRYCB\fR.
459 The default function is \fICDKMentryCallBack\fR.
460 .TP 5
461 .B setCDKMentryFillerChar
462 sets the character to use when drawing unused space in the field.
463 .TP 5
464 .B setCDKMentryHiddenChar
465 sets the character to use when a hidden character type is used (obsolete).
466 .TP 5
467 .B setCDKMentryHorizontalChar
468 function sets the horizontal drawing character for the box to
469 the given character.
470 .TP 5
471 .B setCDKMentryLLChar
472 function sets the lower left hand corner of the widget's box to
473 the given character.
474 .TP 5
475 .B setCDKMentryLRChar
476 function sets the lower right hand corner of the widget's box to
477 the given character.
478 .TP 5
479 .B setCDKMentryMin
480 sets the minimum length of the string that the widget will allow.
481 .TP 5
482 .B setCDKMentryPostProcess
483 allows the user to have the widget call a function after the
484 key has been applied to the widget.
485 The parameter \fBfunction\fR is the callback function.
486 The parameter \fBdata\fR points to data passed to the callback function.
487 To learn more about post-processing see \fIcdk_process (3)\fR.
488 .TP 5
489 .B setCDKMentryPreProcess
490 allows the user to have the widget call a function after a key
491 is hit and before the key is applied to the widget.
492 The parameter \fBfunction\fR is the callback function.
493 The parameter \fBdata\fR points to data passed to the callback function.
494 To learn more about pre-processing see \fIcdk_process (3)\fR.
495 .TP 5
496 .B setCDKMentryULChar
497 sets the upper left hand corner of the widget's box to
498 the given character.
499 .TP 5
500 .B setCDKMentryURChar
501 sets the upper right hand corner of the widget's box to
502 the given character.
503 .TP 5
504 .B setCDKMentryValue
505 sets the current value of the widget.
506 .TP 5
507 .B setCDKMentryVerticalChar
508 sets the vertical drawing character for the box to
509 the given character.
510 .SH KEY BINDINGS
511 When the widget is activated there are several default key bindings which will
512 help the user enter or manipulate the information quickly.
513 The following table
514 outlines the keys and their actions for this widget.
515 .LP
516 .TS
517 center tab(/) box;
518 l l
519 lw(15) lw(35) .
520 \fBKey/Action\fR
521 =
522 Left Arrow/Moves the cursor to the left.
523 CTRL-B/Moves the cursor to the left.
524 Right Arrow/Moves the cursor to the right.
525 CTRL-F/Moves the cursor to the right.
526 Up Arrow/Moves the cursor one row down.
527 Down Arrow/Moves the cursor one row up.
528 Delete/Deletes the character at the cursor.
529 Backspace/Deletes the character before cursor, moves cursor left.
530 CTRL-V/T{
531 Pastes whatever is in the paste buffer, into the widget.
532 T}
533 CTRL-X/T{
534 Cuts the contents from the widget and saves a copy in the paste buffer.
535 T}
536 CTRL-Y/T{
537 Copies the contents of the widget into the paste buffer.
538 T}
539 CTRL-U/T{
540 Erases the contents of the widget.
541 T}
542 CTRL-A/T{
543 Moves the cursor to the beginning of the entry field.
544 T}
545 CTRL-E/T{
546 Moves the cursor to the end of the entry field.
547 T}
548 CTRL-T/T{
549 Transposes the character under the cursor with the character to the right.
550 T}
551 Return/T{
552 Exits the widget and returns a \fIchar *\fR representing
553 the information which was typed into the field.
554 It also sets the widget data \fIexitType\fR in the widget
555 pointer to \fIvNORMAL\fR.
556 T}
557 Tab/T{
558 Exits the widget and returns a \fIchar *\fR representing
559 the information which was typed into the field.
560 It also sets the widget data \fIexitType\fR in the widget
561 pointer to \fIvNORMAL\fR.
562 T}
563 Escape/T{
564 Exits the widget and returns a \fINULL\fR pointer.
565 It also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
566 T}
567 Ctrl-L/Refreshes the screen.
568 .TE
569 .fi
570 .SH SEE ALSO
571 .BR cdk (3),
572 .BR cdk_binding (3),
573 .BR cdk_display (3),
574 .BR cdk_position (3),
575 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_menu.3,v 1.18 2005/12/28 18:35:31 tom Exp $
2 .de XX
3 ..
4 .TH cdk_menu 3
5 .SH NAME
6 .XX activateCDKMenu
7 .XX destroyCDKMenu
8 .XX drawCDKMenu
9 .XX drawCDKMenuSubwin
10 .XX eraseCDKMenu
11 .XX eraseCDKMenuSubwin
12 .XX getCDKMenuCurrentItem
13 .XX getCDKMenuSubTitleHighlight
14 .XX getCDKMenuTitleHighlight
15 .XX injectCDKMenu
16 .XX newCDKMenu
17 .XX setCDKMenu
18 .XX setCDKMenuBackgroundAttrib
19 .XX setCDKMenuBackgroundColor
20 .XX setCDKMenuCurrentItem
21 .XX setCDKMenuPostProcess
22 .XX setCDKMenuPreProcess
23 .XX setCDKMenuSubTitleHighlight
24 .XX setCDKMenuTitleHighlight
25 cdk_menu \- curses menu widget
26 .SH SYNOPSIS
27 .LP
28 .B cc
29 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
30 .B \-lcdk
31 .RI "[ " "library" " \|.\|.\|. ]"
32 .LP
33 #include <cdk.h>
34 .nf
35 .TP 15
36 .B "int activateCDKMenu ("
37 .BI "CDKMENU *" "menu",
38 .BI "chtype * " "actions");
39 .TP 15
40 .B "void destroyCDKMenu ("
41 .BI "CDKMENU *" "menu");
42 .TP 15
43 .B "void drawCDKMenu ("
44 .BI "CDKMENU *" "menu",
45 .BI "boolean " "box");
46 .TP 15
47 .BI "void drawCDKMenuSubwin ("
48 .BI "CDKMENU *" "menu");
49 .TP 15
50 .B "void eraseCDKMenu ("
51 .BI "CDKMENU *" "menu");
52 .TP 15
53 .BI "void eraseCDKMenuSubwin ("
54 .BI "CDKMENU *" "menu");
55 .TP 15
56 .B "void getCDKMenuCurrentItem ("
57 .BI "CDKMENU *" "menu",
58 .BI "int *" "menuItem",
59 .BI "int *" "submenuItem");
60 .TP 15
61 .B "chtype getCDKMenuSubTitleHighlight ("
62 .BI "CDKMENU *" "menu");
63 .TP 15
64 .B "chtype getCDKMenuTitleHighlight ("
65 .BI "CDKMENU *" "menu");
66 .TP 15
67 .B "int injectCDKMenu ("
68 .BI "CDKMENU *" "menu",
69 .BI "chtype " "input");
70 .TP 15
71 .B "CDKMENU *newCDKMenu ("
72 .BI "CDKSCREEN *" "cdkscreen",
73 .BI "char *" "menulist"[MAX_MENU_ITEMS][MAX_SUB_ITEMS],
74 .BI "int " "menuListLength",
75 .BI "int *" "submenuListLength",
76 .BI "int *" "menuLocation",
77 .BI "int " "menuPos",
78 .BI "chtype " "titleAttribute",
79 .BI "chtype " "subtitleAttribute");
80 .TP 15
81 .B "void setCDKMenu ("
82 .BI "CDKMENU *" "menu",
83 .BI "int " "menuItem",
84 .BI "int " "submenuItem",
85 .BI "chtype " "titleAttribute",
86 .BI "chtype " "subtitleAttribute");
87 .TP 15
88 .B "void setCDKMenuBackgroundAttrib ("
89 .BI "CDKMENU *" "menu",
90 .BI "chtype " "attribute");
91 .TP 15
92 .B "void setCDKMenuBackgroundColor ("
93 .BI "CDKMENU *" "menu",
94 .BI "char * " "color");
95 .TP 15
96 .B "void setCDKMenuCurrentItem ("
97 .BI "CDKMENU *" "menu",
98 .BI "int " "menuItem",
99 .BI "int " "submenuItem");
100 .TP 15
101 .B "void setCDKMenuPostProcess ("
102 .BI "CDKMENU *" "menu",
103 .BI "PROCESSFN " "callback",
104 .BI "void * " "data");
105 .TP 15
106 .B "void setCDKMenuPreProcess ("
107 .BI "CDKMENU *" "menu",
108 .BI "PROCESSFN " "callback",
109 .BI "void * " "data");
110 .TP 15
111 .B "void setCDKMenuSubTitleHighlight ("
112 .BI "CDKMENU *" "menu",
113 .BI "chtype " "highlight");
114 .TP 15
115 .B "void setCDKMenuTitleHighlight ("
116 .BI "CDKMENU *" "menu",
117 .BI "chtype " "highlight");
118 .fi
119 .SH DESCRIPTION
120 The Cdk menu widget creates a pull-down menu list.
121 The following are functions
122 which create or manipulate the Cdk menu widget.
123 .SH AVAILABLE FUNCTIONS
124 .TP 5
125 .B activateCDKMenu
126 activates the menu widget and lets the user interact with the widget.
127 The parameter \fBmenu\fR is a pointer to a non-NULL menu widget.
128 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
129 in the array will be injected into the widget.
130 To activate the widget
131 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
132 If the character entered
133 into this widget is \fIRETURN\fR then this then this function returns an
134 integer which is a value of the current menu list * 100 + the sub-menu number.
135 It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
136 If the character entered into this widget was \fIESCAPE\fR then the widget
137 will return a value of -1 and the widget data \fIexitType\fR will be
138 set to \fIvESCAPE_HIT\fR.
139 .TP 5
140 .B destroyCDKMenu
141 removes the widget from the screen and frees memory the object used.
142 .TP 5
143 .B drawCDKMenu
144 draws the menu widget on the screen.
145 If the \fBbox\fR parameter is true, the widget is drawn with a box.
146 .TP 5
147 .B drawCDKMenuSubwin
148 draws the menu item subwindow.
149 .TP 5
150 .B eraseCDKMenu
151 removes the widget from the screen.
152 This does \fINOT\fR destroy the widget.
153 .TP 5
154 .B eraseCDKMenuSubwin
155 erases the menu item subwindow.
156 .TP 5
157 .B getCDKMenuCurrentItem
158 returns the values \fBmenuItem\fR and \fBsubmenuItem\fR to the current
159 menu selection.
160 .TP 5
161 .B getCDKMenuSubTitleHighlight
162 returns the highlight attribute of the sub-menu selection bar.
163 .TP 5
164 .B getCDKMenuTitleHighlight
165 returns the highlight attributes of the menu title.
166 .TP 5
167 .B injectCDKMenu
168 injects a single character into the widget.
169 The parameter \fBmenu\fR is a pointer to a non-NULL menu widget.
170 The parameter \fBcharacter\fR is the character to inject into the widget.
171 The return value and side-effect (setting the widget data \fIexitType\fP)
172 depend upon the injected character:
173 .RS
174 .TP
175 \fIRETURN\fP or \fITAB\fR
176 the function returns
177 the current menu list * 100 + the sub-menu number.
178 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
179 .TP
180 \fIESCAPE\fP
181 the function returns
182 -1.
183 to \fIvESCAPE_HIT\fR.
184 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
185 .TP
186 Otherwise
187 unless modified by preprocessing, postprocessing or key bindings,
188 the function returns
189 -1.
190 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
191 .RE
192 .TP 5
193 .B newCDKMenu
194 creates a menu widget and returns a pointer to it.
195 Parameters:
196 .RS
197 .TP 5
198 \fBscreen\fR
199 is the screen you wish this widget to be placed in.
200 .TP 5
201 \fBmenuList\fR
202 is a list of the menu list titles.
203 .TP 5
204 \fBmenuListLength\fR
205 is the number of pull down menus.
206 .TP 5
207 \fBsubmenuListLength\fR
208 is the number of menu items under each menu list.
209 .TP 5
210 \fBmenuLocation\fR
211 tells where each menu is to be located.
212 Valid values are \fILEFT\fR and \fIRIGHT\fR.
213 .TP 5
214 \fBmenuPos\fR
215 tells whether the menu is to be on the top of the screen or the bottom.
216 Valid values are \fITOP\fR and \fIBOTTOM\fR.
217 .TP 5
218 \fBtitleAttribute\fR and
219 .TP 5
220 \fBsubtitleAttribute\fR
221 are the character attributes of the title and sub-titles respectively.
222 .RE
223 .IP
224 If the widget could not be created then a \fINULL\fR pointer is returned.
225 .TP 5
226 .B setCDKMenu
227 lets the programmer modify certain elements of an existing menu widget.
228 The parameters \fBmenuItem\fR and \fBsubmenuItem\fR set which
229 menu list and sub-menu item are going to be highlighted when the widget is activated.
230 The other parameter names correspond to the same parameter names
231 listed in the \fBnewCDKMenu\fR function.
232 .TP 5
233 .B setCDKMenuBackgroundAttrib
234 sets the background attribute of the widget.
235 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
236 .TP 5
237 .B setCDKMenuBackgroundColor
238 sets the background color of the widget.
239 The parameter \fBcolor\fR
240 is in the format of the Cdk format strings.
241 See \fBcdk_display (3)\fR.
242 .TP 5
243 .B setCDKMenuCurrentItem
244 sets the current item in the menu widget.
245 .TP 5
246 .B setCDKMenuPostProcess
247 allows the user to have the widget call a function after the
248 key has been applied to the widget.
249 The parameter \fBfunction\fR is the callback function.
250 The parameter \fBdata\fR points to data passed to the callback function.
251 To learn more about post-processing see \fIcdk_process (3)\fR.
252 .TP 5
253 .B setCDKMenuPreProcess
254 allows the user to have the widget call a function after a key
255 is hit and before the key is applied to the widget.
256 The parameter \fBfunction\fR is the callback function.
257 The parameter \fBdata\fR points to data passed to the callback function.
258 To learn more about pre-processing see \fIcdk_process (3)\fR.
259 .TP 5
260 .B setCDKMenuSubTitleHighlight
261 sets the highlight attribute of the sub-menu selection bar.
262 .TP 5
263 .B setCDKMenuTitleHighlight
264 sets the highlight attributes of the menu title.
265 .SH KEY BINDINGS
266 When the widget is activated there are several default key bindings which will
267 help the user enter or manipulate the information quickly.
268 The following table
269 outlines the keys and their actions for this widget.
270 .LP
271 .TS
272 center tab(/) allbox;
273 l l
274 l l
275 lw15 lw35 .
276 \fBKey/Action\fR
277 Left Arrow/T{
278 Highlights the menu list to the left of the current menu.
279 T}
280 Right Arrow/T{
281 Highlights the menu list to the right of the current menu.
282 T}
283 Up Arrow/T{
284 Moves the current menu selection up one.
285 T}
286 Down Arrow/T{
287 Moves the current menu selection down one.
288 T}
289 Space/T{
290 Moves the current menu selection down one.
291 T}
292 Tab/T{
293 Highlights the menu list to the right of the current menu.
294 T}
295 Return/T{
296 Exits the widget and returns the index of the selected item.
297 This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
298 T}
299 Escape/T{
300 Exits the widget and returns -1.
301 This also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
302 T}
303 Ctrl-L/Refreshes the screen.
304 .TE
305 .SH SEE ALSO
306 .BR cdk (3),
307 .BR cdk_binding (3),
308 .BR cdk_display (3),
309 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_misc.3,v 1.16 2006/05/07 01:09:57 tom Exp $
2 .de XX
3 ..
4 .TH cdk_misc 3
5 .SH NAME
6 .XX Beep
7 .XX CDKallocStrings
8 .XX CDKcountStrings
9 .XX CDKfreeChtypes
10 .XX CDKfreeStrings
11 .XX CDKsplitString
12 .XX baseName
13 .XX ceilCDK
14 .XX chlen
15 .XX chstrncpy
16 .XX chtype2Char
17 .XX cleanChar
18 .XX cleanChtype
19 .XX cmpStrChstr
20 .XX copyChar
21 .XX copyCharList
22 .XX copyChtype
23 .XX copyChtypeList
24 .XX dirName
25 .XX floorCDK
26 .XX freeChar
27 .XX freeCharList
28 .XX freeChtype
29 .XX freeChtypeList
30 .XX intlen
31 .XX lenCharList
32 .XX lenChtypeList
33 .XX mode2Char
34 .XX searchList
35 .XX sortList
36 cdk_misc - \fBCurses Development Kit\fR Miscellaneous Routines
37 .LP
38 .SH SYNOPSIS
39 .LP
40 .B cc
41 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
42 .B \-lcdk
43 .RI "[ " "library" " \|.\|.\|. ]"
44 .LP
45 #include <cdk.h>
46 .nf
47 .TP 15
48 .B "void Beep(void);
49 .TP 15
50 .B "unsigned CDKallocStrings("
51 .BI "char ***" "list"/,
52 .BI "char *" "item"/,
53 .BI "unsigned " "length"/,
54 .BI "unsigned " "used"/);
55 .TP 15
56 .B "unsigned CDKcountStrings ("
57 .BI "char **\fIlist");
58 .TP 15
59 .B "void CDKfreeChtypes("
60 .BI "chtype **" "list");
61 .TP 15
62 .B "void CDKfreeStrings ("
63 .BI "char **" "list");
64 .TP 15
65 .B "char ** CDKsplitString ("
66 .BI "char *" "string",
67 .BI "int " "splitChar);
68 .TP 15
69 .B "char * baseName ("
70 .BI "char *" "string");
71 .TP 15
72 .B "int ceilCDK("
73 .BI "double" "value");
74 .TP 15
75 .B "int chlen ("
76 .BI "chtype *" "string");
77 .TP 15
78 .B "void chstrncpy(
79 .BI "char *" "dest",
80 .BI "chtype *" "src",
81 .BI "int " "maxcount");
82 .TP 15
83 .BI "char *chtype2Char ("
84 .BI "chtype *" "string");
85 .TP 15
86 .B "void cleanChar ("
87 .BI "char *" "string",
88 .BI "int " "length",
89 .BI "char " "character");
90 .TP 15
91 .B "void cleanChtype ("
92 .BI "chtype *" "string",
93 .BI "int " "length",
94 .BI "chtype " "character");
95 .TP 15
96 .B "int cmpStrChstr("
97 .BI "char *" "str",
98 .BI "chtype *" "chstr");
99 .TP 15
100 .B "char *copyChar ("
101 .BI "char *" "string");
102 .TP 15
103 .B "char **copyCharList ("
104 .BI "char **" "list");
105 .TP 15
106 .B "chtype *copyChtype ("
107 .BI "chtype *" "string");
108 .TP 15
109 .B "chtype **copyChtypeList ("
110 .BI "chtype **" "list");
111 .TP 15
112 .B "char *dirName ("
113 .BI "char *" "filename");
114 .TP 15
115 .B "int floorCDK("
116 .BI "double " "value");
117 .TP 15
118 .B "void freeChar ("
119 .BI "char *" "string");
120 .TP 15
121 .B "void freeCharList ("
122 .BI "char **" "list",
123 .BI "unsigned " "size");
124 .TP 15
125 .B "void freeChtype ("
126 .BI "chtype *" "string");
127 .TP 15
128 .B void freeChtypeList ("
129 .BI "chtype **" "list",
130 .BI "unsigned " "size");
131 .TP 15
132 .B "int intlen ("
133 .BI "int " "value");
134 .TP 15
135 .B "int lenCharList ("
136 .BI "char **" "list");
137 .TP 15
138 .B "int lenChtypeList ("
139 .BI "chtype **" "list");
140 .TP 15
141 .B "int mode2Char ("
142 .BI "char *" "string",
143 .BI "mode_t " "fileMode");
144 .TP 15
145 .B "int searchList ("
146 .BI "char **" "list",
147 .BI "int " "listSize",
148 .BI "char *" "pattern");
149 .TP 15
150 .B "void sortList ("
151 .BI "char **" "list",
152 .BI "int " "length");
153 .fi
154 .SH DESCRIPTION
155 These are miscellaneous functions
156 which may be useful with the Cdk widget set.
157 .SH AVAILABLE FUNCTIONS
158 .TP 5
159 .B Beep
160 makes an audible beep.
161 The standard curses beep() does not
162 flush the stream, so it will only beep until a force is made.
163 This forces a flush after issuing the beep command.
164 .TP 5
165 .B CDKallocStrings
166 Add a new string \fIitem\fP to a \fIlist\fP.
167 Keep a null pointer on the end so one may use
168 \fBCDKfreeStrings()\fP to deallocate the whole list.
169 The caller is responsible for updating the \fIlength\fP of the list.
170 The return value is the updated number of chars \fIused\fP.
171 .TP 5
172 .B CDKcountStrings
173 Count the number of items in a null-terminated \fIlist\fP of character strings.
174 Return the count.
175 .TP 5
176 .B CDKfreeChtypes
177 Free a \fIlist\fP of chtype-strings which is terminated by a null pointer.
178 .TP 5
179 .B CDKfreeStrings
180 Free a \fIlist\fP of character strings which is terminated by a null pointer.
181 Also free \fIlist\fR itself.
182 .TP 5
183 .B CDKsplitString
184 split the \fIstring\fP at each occurrence of \fIseparator\fP,
185 returning a pointer to a dynamically allocated array of the pieces.
186 The original \fIstring\fP is unmodified.
187 The caller is responsible for freeing the result.
188 .TP 5
189 .B baseName
190 returns a pointer to the first character of the filename in
191 the given pathname.
192 The result should be freed by the caller.
193 .TP 5
194 .B ceilCDK
195 Return an integer like the math library \fBceil()\fP, which returns a double.
196 .TP 5
197 .B chlen
198 returns the length of the (null-terminated) \fIstring\fP of chtype's.
199 .TP 5
200 .B chstrncpy
201 Extract the characters from a null-terminated array of chtype's \fIsrc\fP.
202 The size of the destination \fIdest\fP is given in \fImaxcount\fP.
203 .TP 5
204 .B chtype2Char
205 Extract the characters from a null-terminated array of chtype's \fIstring\fP.
206 A dynamically allocated string is returned.
207 The caller is responsible for freeing the result.
208 .TP 5
209 .B cleanChar
210 is analogous to \fImemset\fR.
211 Set the characters in \fIstring\fP to the given \fIcharacter\fP.
212 The length of \fIstring\fP is given by \fIlength\fP.
213 character which will be written.
214 .TP 5
215 .B cleanChtype
216 is analogous to \fImemset\fR.
217 Set the chtype's in \fIstring\fP to the given \fIcharacter\fP.
218 The length of \fIstring\fP is given by \fIlength\fP.
219 .TP 5
220 .B cmpStrChstr
221 Compare a char string \fIstr\fP to a chtype string \fIchstr\fP.
222 Return -1, 0 or 1 according to whether \fIstr\fP is less than, equal to
223 to greater than \fIchstr\fP.
224 .TP 5
225 .B copyChar
226 copies the string passed in.
227 Unlike \fIstrdup\fR this checks to see if the string is NULL before copying.
228 .TP 5
229 .B copyCharList
230 copies the given list.
231 .TP 5
232 .B copyChtype
233 function copies the string passed in, analogous to \fBcopyChar\fR, but
234 for chtype strings.
235 .TP 5
236 .B copyChtypeList
237 copies the given list.
238 .TP 5
239 .B dirName
240 Returns the directory for the given \fIfilename\fP,
241 i.e., the part before the * last slash.
242 The return value should be freed by the caller.
243 .TP 5
244 .B floorCDK
245 Return an integer like the math function floor(), which returns a double.
246 .TP 5
247 .B freeChar
248 is a wrapper for \fIfree\fR.
249 It checks to see if the string
250 is NULL before trying to free the string.
251 .TP 5
252 .B freeCharList
253 Free the memory used by the given \fIlist\fP of strings.
254 The number of strings to free is given by \fIsize\fP.
255 .TP 5
256 .B freeChtype
257 is a wrapper for \fIfree\fR, like \fIfreeChar\fR.
258 .TP 5
259 .B freeChtypeList
260 Free the memory used by the given \fIlist\fP of chtype strings.
261 The number of strings to free is given by \fIsize\fP.
262 .TP 5
263 .B intlen
264 returns the length of an integer, i.e., the number of characters
265 needed to represent it.
266 .TP 5
267 .B lenCharList
268 returns the length of the given list.
269 .TP 5
270 .B lenChtypeList
271 returns the length of the given list.
272 .TP 5
273 .B mode2Char
274 Given a file protection mode \fIfileMode\fP,
275 store a printable version of the permissions in \fIstring\fP,
276 formatted as if by "ls -l").
277 Return the corresponding permissions data,
278 i.e., ignoring the file-type bits.
279 .TP 5
280 .B searchList
281 Search the given \fIlist\fP of \fIlistSize\fP strings
282 for a subset of a word \fIpattern\fP in the given list.
283 Return the index in the list if it is found, or -1 if not found.
284 .TP 5
285 .B sortList
286 performs a quick sort of the given list.
287 This is a wrapper for qsort,
288 used to sort the \fIlist\fP of strings.
289 The number of strings in \fIlist\fP is given by \fIlength\fP.
290 The list is sorted alphabetically in increasing order.
291 .SH SEE ALSO
292 .BR cdk (3),
293 .BR cdk_screen (3),
294 .BR cdk_display (3),
295 .BR cdk_binding (3),
296 .BR cdk_util (3)
0 .\" $Id: cdk_objs.3,v 1.2 2005/12/28 20:54:41 tom Exp $
1 .de XX
2 ..
3 .TH cdk_objs 3
4 .SH NAME
5 .XX cleanCdkTitle
6 .XX drawCdkTitle
7 .XX positionCDKObject
8 .XX setCDKObjectBackgroundColor
9 .XX setCDKObjectPostProcess
10 .XX setCDKObjectPreProcess
11 .XX setCdkExitType
12 .XX setCdkTitle
13 .XX validCDKObject
14 cdk_objs \- Cdk object-support functions
15 .SH SYNOPSIS
16 .LP
17 .B cc
18 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
19 .B \-lcdk
20 .RI "[ " "library" " \|.\|.\|. ]"
21 .LP
22 .nf
23 .TP 15
24 .B "void cleanCdkTitle ("
25 .BI "CDKOBJS *" "obj");
26 .TP 15
27 .B "void drawCdkTitle ("
28 .BI "WINDOW *" "window",
29 .BI "CDKOBJS *" "object");
30 .TP 15
31 .B "void positionCDKObject ("
32 .BI "CDKOBJS *" "object",
33 .BI "WINDOW *" "win");
34 .TP 15
35 .B "void setCDKObjectBackgroundColor ("
36 .BI "CDKOBJS *" "object",
37 .BI "char *" "color");
38 .TP 15
39 .B "void setCDKObjectPostProcess ("
40 .BI "CDKOBJS *" "object",
41 .BI "PROCESSFN " "func",
42 .BI "void *" "data");
43 .TP 15
44 .B "void setCDKObjectPreProcess ("
45 .BI "CDKOBJS *" "object",
46 .BI "PROCESSFN " "func",
47 .BI "void *" "data");
48 .TP 15
49 .B "void setCdkExitType("
50 .BI "CDKOBJS *" "obj",
51 .BI "EExitType *" "type",
52 .BI "chtyp " "ch");
53 .TP 15
54 .B "int setCdkTitle ("
55 .BI "CDKOBJS *" "obj",
56 .BI "char *" "title",
57 .BI "int " "boxWidth");
58 .TP 15
59 .B "bool validCDKObject ("
60 .BI "CDKOBJS *" "obj");
61 .fi
62 .SH DESCRIPTION
63 Cdk is written in ANSI C, which has "no" object support.
64 Most of the object support in Cdk is done using macros and a small number
65 of types which hold object information:
66 .RS 5
67 .TP 5
68 CDKFUNCS
69 contains the function pointers for common methods of the widgets.
70 It is separate from CDKOBJS because it is compiled into each widget's C code
71 (see the DeclareCDKObjects() and DeclareSetXXchar() macros.
72 The widget instances point to a single copy of CDKFUNCS for each widget.
73 .TP 5
74 CDKOBJS
75 Holds data common to all objects (widget instances).
76 It appears first in each widget's struct to allow Cdk
77 to use generic functions in binding.c, cdkscreen.c, position.c, etc.
78 .RE
79
80 .SH AVAILABLE FUNCTIONS
81 The functions declared in <cdk_objs.h> are used in situations where the
82 expressions are too complex for a macro.
83 .TP 5
84 .B cleanCdkTitle
85 Remove storage for the widget's title.
86 .TP 5
87 .B drawCdkTitle,
88 Draw the widget's title.
89 .TP 5
90 .B positionCDKObject
91 This allows the user to use the cursor keys to adjust the
92 position of the widget.
93 .TP 5
94 .B setCDKObjectBackgroundColor
95 Set the background color of the widget.
96 .TP 5
97 .B setCDKObjectPostProcess
98 Set data for postprocessing.
99 .TP 5
100 .B setCDKObjectPreProcess
101 Set data for preprocessing.
102 .TP 5
103 .B setCdkExitType
104 Set the object's exit-type based on the input.
105 The \fB.exitType\fP field should have been part of the CDKOBJS struct, but it
106 is used too pervasively in Cdk4 applications to move.
107 .TP 5
108 .B setCdkTitle
109 Set the widget's title.
110 .TP 5
111 .B validCDKObject
112 Returns true if a "new" was done on the object but no "destroy".
113 .
114 .SH SEE ALSO
115 cdk_binding (3)
116 cdk_process (3)
0 '\" t
1 .\" $Id: cdk_params.3,v 1.3 2005/12/28 18:35:31 tom Exp $
2 .de XX
3 ..
4 .TH cdk_params 3
5 .SH NAME
6 .XX CDKparamNumber
7 .XX CDKparamNumber2
8 .XX CDKparamString
9 .XX CDKparamString2
10 .XX CDKparseParams
11 .XX CDKparsePosition
12 .XX CDKparamValue
13 cdk_params \- Cdk command-line parsing
14 .SH SYNOPSIS
15 .LP
16 .B cc
17 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
18 .B \-lcdk
19 .RI "[ " "library" " \|.\|.\|. ]"
20 .LP
21 #include <cdk.h>
22 .nf
23 .TP 15
24 .B "int CDKparamNumber ("
25 .BI "CDK_PARAMS *" "params",
26 .BI "int " "option");
27 .TP 15
28 .B "int CDKparamNumber2 ("
29 .BI "CDK_PARAMS *" "params",
30 .BI "int " "option",
31 .BI "int " "missing");
32 .TP 15
33 .B "char * CDKparamString ("
34 .BI "CDK_PARAMS *" "params",
35 .BI "int " "option");
36 .TP 15
37 .B "char * CDKparamString2 ("
38 .BI "CDK_PARAMS *" "params",
39 .BI "int " "option",
40 .BI "char *" "missing");
41 .TP 15
42 .B "void CDKparseParams ("
43 .BI "int " "argc",
44 .BI "char **" "argv",
45 .BI "CDK_PARAMS *" "params",
46 .BI "char *" "options");
47 .TP 15
48 .B "int CDKparsePosition ("
49 .BI "char *" "string");
50 .TP 15
51 .B "int CDKparamValue ("
52 .BI "CDK_PARAMS * " "params",
53 .BI "int " "option",
54 .BI "int " "missing");
55 .fi
56 .SH DESCRIPTION
57 These are a set of functions used to implement the command-line utilities and
58 demonstration programs for Cdk.
59 Rather than set the programs' options at initialization,
60 they construct a simple database which holds the common parameters
61 using \fBCDKparseParams()\fP.
62 .
63 .SH AVAILABLE FUNCTIONS
64 .TP 5
65 .B CDKparamNumber
66 Retrieves an integer (or boolean) option value from the parsed command-line.
67 .TP 5
68 .B CDKparamNumber2
69 Retrieves an optional integer (or boolean) value from the parsed command-line.
70 If the command line option is not present, the \fImissing\fP value is used.
71 .TP 5
72 .B CDKparamString
73 Retrieves a string option value from the parsed command-line.
74 .TP 5
75 .B CDKparamString2
76 Retrieve an optional string option value from the parsed command-line.
77 .TP 5
78 .B CDKparamValue
79 Retrieve an integer (or boolean) option value from the parsed command-line.
80 .TP 5
81 .B CDKparseParams
82 Parse the given argc/argv command-line, with the options passed to
83 getopt()'s 3rd parameter.
84 .TP 5
85 .B CDKparsePosition
86 Parse the string as one of CDK's positioning keywords, or an actual position.
87 .
88 .SH SEE ALSO
89 cdk_position (3),
90 getopt (3)
0 '\" t
1 .\" $Id: cdk_position.3,v 1.4 2002/08/09 22:15:50 tom Exp $
2 .TH cdk_position 3
3 .SH NAME
4 cdk_position \- curses widget positioning key-bindings
5 .SH SYNOPSIS
6 Position methods for the Cdk widgets
7 allow the user to move the widget around the screen via the
8 cursor/keypad keys.
9 .SH DESCRIPTION
10 The following key bindings can be used to move the
11 widget around the screen.
12 .LP
13 .TS
14 center tab(/) box;
15 l l
16 lw15 lw35 .
17 \fBKey/Action\fR
18 =
19 Up Arrow/T{
20 Moves the widget up one row.
21 T}
22 Down Arrow/T{
23 Moves the widget down one row.
24 T}
25 Left Arrow/T{
26 Moves the widget left one column
27 T}
28 Right Arrow/T{
29 Moves the widget right one column
30 T}
31 1/T{
32 Moves the widget down one row and left one column.
33 T}
34 2/T{
35 Moves the widget down one row.
36 T}
37 3/T{
38 Moves the widget down one row and right one column.
39 T}
40 4/T{
41 Moves the widget left one column
42 T}
43 5/T{
44 Centers the widget both vertically and horizontally.
45 T}
46 6/Moves the widget right one column
47 7/T{
48 Moves the widget up one row and left one column.
49 T}
50 8/T{
51 Moves the widget up one row.
52 T}
53 9/T{
54 Moves the widget up one row and right one column.
55 T}
56 t/T{
57 Moves the widget to the top of the screen.
58 T}
59 b/T{
60 Moves the widget to the bottom of the screen.
61 T}
62 l/T{
63 Moves the widget to the left of the screen.
64 T}
65 r/T{
66 Moves the widget to the right of the screen.
67 T}
68 c/T{
69 Centers the widget between the left and right of the window.
70 T}
71 C/T{
72 Centers the widget between the top and bottom of the window.
73 T}
74 Escape/Returns the widget to its original position.
75 Return/T{
76 Exits the function and leaves the widgetwhere it was.
77 T}
78 =
79 .TE
80 .LP
81 The numbers 0-9 are chosen to correspond to the numeric keypad on your terminal.
82 Cdk does not handle the application mode keypad control sequences,
83 since those are not defined via terminfo.
84 To use the numeric keypad you should ensure that it is in normal (or NumLock)
85 mode.
86 .SH SEE ALSO
87 .BR cdk (3),
88 .BR cdk_binding (3),
89 .BR cdk_display (3),
90 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_process.3,v 1.3 2005/12/28 18:19:17 tom Exp $
2 .de XX
3 ..
4 .TH cdk_process 3
5 .SH NAME
6 cdk_process \- curses widget pre/post-processing
7 .SH SYNOPSIS
8 Perform pre- and post-processing of data which is injected into a widget.
9 .SH DESCRIPTION
10 Character input is handled by each widget by its injection function.
11 That is typically a large case-statement consisting of the actions to
12 be taken for editing and scrolling keys.
13 The calling application can modify the behavior of the injection function
14 by defining either or both preprocess and postprocess functions.
15 .PP
16 Preprocessing is performed before doing anything with the injected keystroke.
17 If the preprocess function returns zero, no further action is taken in
18 the injection function.
19 Note that the preprocess function may do more than filter out characters;
20 it can fill in logic to coordinate different widgets.
21 .PP
22 Postprocessing is performed after all other actions have been done in
23 the injection function.
24 Like the other actions, it is performed only if the preprocess function
25 returns a nonzero value.
26 Unlike the preprocess function, its return value is ignored.
27 .SH SEE ALSO
28 .BR cdk (3),
29 .BR cdk_binding (3).
0 '\" t
1 .\" $Id: cdk_radio.3,v 1.28 2005/12/28 21:52:07 tom Exp $
2 .de XX
3 ..
4 .TH cdk_radio 3
5 .SH NAME
6 .XX activateCDKRadio
7 .XX destroyCDKRadio
8 .XX drawCDKRadio
9 .XX eraseCDKRadio
10 .XX getCDKRadioBox
11 .XX getCDKRadioChoiceCharacter
12 .XX getCDKRadioCurrentItem
13 .XX getCDKRadioHighlight
14 .XX getCDKRadioItems
15 .XX getCDKRadioLeftBrace
16 .XX getCDKRadioRightBrace
17 .XX getCDKRadioSelectedItem
18 .XX injectCDKRadio
19 .XX moveCDKRadio
20 .XX newCDKRadio
21 .XX positionCDKRadio
22 .XX setCDKRadio
23 .XX setCDKRadioBackgroundAttrib
24 .XX setCDKRadioBackgroundColor
25 .XX setCDKRadioBox
26 .XX setCDKRadioBoxAttribute
27 .XX setCDKRadioChoiceCharacter
28 .XX setCDKRadioCurrentItem
29 .XX setCDKRadioHighlight
30 .XX setCDKRadioHorizontalChar
31 .XX setCDKRadioItems
32 .XX setCDKRadioLLChar
33 .XX setCDKRadioLRChar
34 .XX setCDKRadioLeftBrace
35 .XX setCDKRadioPostProcess
36 .XX setCDKRadioPreProcess
37 .XX setCDKRadioRightBrace
38 .XX setCDKRadioSelectedItem
39 .XX setCDKRadioULChar
40 .XX setCDKRadioURChar
41 .XX setCDKRadioVerticalChar
42 cdk_radio \- curses radio list widget.
43 .SH SYNOPSIS
44 .LP
45 .B cc
46 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
47 .B \-lcdk
48 .RI "[ " "library" " \|.\|.\|. ]"
49 .LP
50 #include <cdk.h>
51 .nf
52 .TP 15
53 .B "int activateCDKRadio ("
54 .BI "CDKRADIO *" "radio",
55 .BI "chtype *" "actions");
56 .TP 15
57 .B "void destroyCDKRadio ("
58 .BI "CDKRADIO *" "radio");
59 .TP 15
60 .B "void drawCDKRadio ("
61 .BI "CDKRADIO *" "radio",
62 .BI "boolean " "box");
63 .TP 15
64 .B "void eraseCDKRadio ("
65 .BI "CDKRADIO *" "radio");
66 .TP 15
67 .B "boolean getCDKRadioBox ("
68 .BI "CDKRADIO *" "radio");
69 .TP 15
70 .B "chtype getCDKRadioChoiceCharacter ("
71 .BI "CDKRADIO *" "radio");
72 .TP 15
73 .B "int getCDKRadioCurrentItem ("
74 .BI "CDKRADIO *" "radio");
75 .TP 15
76 .B "chtype getCDKRadioHighlight ("
77 .BI "CDKRADIO *" "radio");
78 .TP 15
79 .B "int getCDKRadioItems ("
80 .BI "CDKRADIO *" "radio",
81 .BI "char **" "list");
82 .TP 15
83 .B "chtype getCDKRadioLeftBrace ("
84 .BI "CDKRADIO *" "radio");
85 .TP 15
86 .B "chtype getCDKRadioRightBrace ("
87 .BI "CDKRADIO *" "radio");
88 .TP 15
89 .B "int getCDKRadioSelectedItem ("
90 .BI "CDKRADIO *" "radio");
91 .TP 15
92 .B "int injectCDKRadio ("
93 .BI "CDKRADIO *" "radio",
94 .BI "chtype " "input");
95 .TP 15
96 .B "void moveCDKRadio ("
97 .BI "CDKRADIO *" "radio",
98 .BI "int " "xpos",
99 .BI "int " "ypos",
100 .BI "boolean " "relative",
101 .BI "boolean " "refresh");
102 .TP 15
103 .B "CDKRADIO *newCDKRadio ("
104 .BI "CDKSCREEN *" "cdkscreen",
105 .BI "int " "xpos",
106 .BI "int " "ypos",
107 .BI "int " "spos",
108 .BI "int " "height",
109 .BI "int " "width",
110 .BI "char *" "title",
111 .BI "char **" "radioList",
112 .BI "int " "radioListLength",
113 .BI "chtype " "choiceCharacter",
114 .BI "int " "defaultItem",
115 .BI "chtype " "highlight",
116 .BI "boolean " "box",
117 .BI "boolean " "shadow");
118 .TP 15
119 .B "void positionCDKRadio ("
120 .BI "CDKRADIO *" "radio");
121 .TP 15
122 .B "void setCDKRadio ("
123 .BI "CDKRADIO *" "radio",
124 .BI "chtype " "highlight",
125 .BI "chtype " "choiceCharacter",
126 .BI "boolean " "box");
127 .TP 15
128 .B "void setCDKRadioBackgroundAttrib ("
129 .BI "CDKRADIO *" "radio",
130 .BI "chtype " "attribute");
131 .TP 15
132 .B "void setCDKRadioBackgroundColor ("
133 .BI "CDKRADIO *" "radio",
134 .BI "char * " "color");
135 .TP 15
136 .B "void setCDKRadioBox ("
137 .BI "CDKRADIO *" "radio",
138 .BI "boolean " "box");
139 .TP 15
140 .B "void setCDKRadioBoxAttribute ("
141 .BI "CDKRADIO *" "radio",
142 .BI "chtype " "character");
143 .TP 15
144 .B "void setCDKRadioChoiceCharacter ("
145 .BI "CDKRADIO *" "radio",
146 .BI "chtype " "character");
147 .TP 15
148 .B "void setCDKRadioCurrentItem ("
149 .BI "CDKRADIO *" "radio",
150 .BI "int" "index");
151 .TP 15
152 .B "void setCDKRadioHighlight ("
153 .BI "CDKRADIO *" "radio",
154 .BI "chtype " "highlight");
155 .TP 15
156 .B "void setCDKRadioHorizontalChar ("
157 .BI "CDKRADIO *" "radio",
158 .BI "chtype " "character");
159 .TP 15
160 .B "void setCDKRadioItems ("
161 .BI "CDKRADIO *" "radio",
162 .BI "char **" "list",
163 .BI "int " "listSize");
164 .TP 15
165 .B "void setCDKRadioLLChar ("
166 .BI "CDKRADIO *" "radio",
167 .BI "chtype " "character");
168 .TP 15
169 .B "void setCDKRadioLRChar ("
170 .BI "CDKRADIO *" "radio",
171 .BI "chtype " "character");
172 .TP 15
173 .B "void setCDKRadioLeftBrace ("
174 .BI "CDKRADIO *" "radio",
175 .BI "chtype " "character");
176 .TP 15
177 .B "void setCDKRadioPostProcess ("
178 .BI "CDKRADIO *" "radio",
179 .BI "PROCESSFN " "callback",
180 .BI "void * " "data");
181 .TP 15
182 .B "void setCDKRadioPreProcess ("
183 .BI "CDKRADIO *" "radio",
184 .BI "PROCESSFN " "callback",
185 .BI "void * " "data");
186 .TP 15
187 .B "void setCDKRadioRightBrace ("
188 .BI "CDKRADIO *" "radio",
189 .BI "chtype " "character");
190 .TP 15
191 .B "void setCDKRadioSelectedItem ("
192 .BI "CDKRADIO *" "radio",
193 .BI "int " "item");
194 .TP 15
195 .B "void setCDKRadioULChar ("
196 .BI "CDKRADIO *" "radio",
197 .BI "chtype " "character");
198 .TP 15
199 .B "void setCDKRadioURChar ("
200 .BI "CDKRADIO *" "radio",
201 .BI "chtype " "character");
202 .TP 15
203 .B "void setCDKRadioVerticalChar ("
204 .BI "CDKRADIO *" "radio",
205 .BI "chtype " "character");
206 .fi
207 .SH DESCRIPTION
208 The Cdk radio widget creates a radio list.
209 The following are functions which
210 create or manipulate the Cdk radio box widget.
211 .SH AVAILABLE FUNCTIONS
212 .TP 5
213 .B activateCDKRadio
214 activates the radio widget and lets the user interact with the widget.
215 The parameter \fBradio\fR is a pointer to a non-NULL radio widget.
216 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
217 in the array will be injected into the widget.
218 To activate the widget
219 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
220 If the character entered
221 into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a
222 value from 0 to the number of items -1, representing the item selected.
223 It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
224 If the
225 character entered into this widget was \fIESCAPE\fR then the widget will return
226 a value of -1 and the widget data \fIexitType\fR will be set to
227 \fIvESCAPE_HIT\fR.
228 .TP 5
229 .B destroyCDKRadio
230 removes the widget from the screen and frees memory the object used.
231 .TP 5
232 .B drawCDKRadio
233 draws the radio widget on the screen.
234 If the \fBbox\fR parameter is true, the widget is drawn with a box.
235 .TP 5
236 .B eraseCDKRadio
237 removes the widget from the screen.
238 This does \fINOT\fR destroy the widget.
239 .TP 5
240 .B getCDKRadioBox
241 returns true if the widget will be drawn with a box around it.
242 .TP 5
243 .B getCDKRadioChoiceCharacter
244 returns the character being used to draw the selected element in the list.
245 .TP 5
246 .B getCDKRadioCurrentItem
247 returns the index of the current item.
248 .TP 5
249 .B getCDKRadioHighlight
250 returns the attribute of the highlight bar.
251 .TP 5
252 .B getCDKRadioItems
253 copies the radio box items into the caller's list,
254 which must be large enough since this function does not allocate it.
255 It returns the list size.
256 .TP 5
257 .B getCDKRadioLeftBrace
258 returns the character being used to draw the left brace of the selection box.
259 .TP 5
260 .B getCDKRadioRightBrace
261 returns the character being used to draw the right brace of the selection box.
262 .TP 5
263 .B getCDKRadioSelectedItem,
264 returns the selected item of the widget.
265 .TP 5
266 .B injectCDKRadio
267 function injects a single character into the widget.
268 The parameter \fBradio\fR is a pointer to a non-NULL radio widget.
269 The parameter \fBcharacter\fR is the character to inject into the widget.
270 The return value and side-effect (setting the widget data \fIexitType\fP)
271 depend upon the injected character:
272 .RS
273 .TP
274 \fIRETURN\fP or \fITAB\fR
275 the function returns
276 a value ranging from zero to one less than the number of items,
277 representing the items selected.
278 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
279 .TP
280 \fIESCAPE\fP
281 the function returns
282 -1.
283 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
284 .TP
285 Otherwise
286 unless modified by preprocessing, postprocessing or key bindings,
287 the function returns
288 -1.
289 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
290 .RE
291 .TP 5
292 .B moveCDKRadio
293 moves the given widget to the given position.
294 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
295 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
296 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
297 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
298 \fIRIGHT\fR, and \fICENTER\fR.
299 The parameter \fBrelative\fR states whether
300 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
301 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
302 then the widget would move one row down and two columns right.
303 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
304 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
305 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
306 (weird things may happen).
307 The final parameter \fBrefresh\fR is a boolean value which
308 states whether the widget will get refreshed after the move.
309 .TP 5
310 .B newCDKRadio
311 creates a radio widget and returns a pointer to it.
312 Parameters:
313 .RS
314 .TP 5
315 \fBscreen\fR
316 is the screen you wish this widget to be placed in.
317 .TP 5
318 \fBxpos\fR
319 controls the placement of the object along the horizontal axis.
320 It may be an integer or one of the pre-defined values
321 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
322 .TP 5
323 \fBypos\fR
324 controls the placement of the object along the vertical axis.
325 It may be an integer or one of the pre-defined values
326 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
327 .TP 5
328 \fBspos\fR
329 tells where the scroll bar is to be placed.
330 This may be one of three values:
331 .RS
332 .TP 5
333 \fILEFT\fR
334 puts the scroll bar on the left of the scrolling list.
335 .TP 5
336 \fIRIGHT\fR
337 puts the scroll bar on the right side of the list, and
338 .TP 5
339 \fINONE\fR
340 does not add a scroll bar.
341 .RE
342 .TP 5
343 \fBheight\fR and
344 \fBwidth\fR
345 control the height and width of the widget.
346 If you
347 provide a value of zero for either of the height or the width, the widget will
348 be created with the full width and height of the screen.
349 If you provide a negative
350 value, the widget will be created the full height or width minus the value provided.
351 .TP 5
352 \fBtitle\fR
353 is the string which will be displayed at the top of the widget.
354 The title can be more than one line; just provide a carriage return
355 character at the line break.
356 .TP 5
357 \fBradioList\fR
358 is the list of items to display in the radio list.
359 .TP 5
360 \fBradioListLength\fR
361 is the number of elements in the given list.
362 .TP 5
363 \fBchoiceCharacter\fR
364 is the character to use to highlight the current selection.
365 .TP 5
366 \fBhighlight\fR
367 specifies the display attribute of the currently selected item.
368 .TP 5
369 \fBdefaultItem\fR
370 is the index in the list of the default selection.
371 .TP 5
372 \fBbox\fR
373 is true if widget should be drawn with a box around it.
374 .TP 5
375 \fBshadow\fR
376 turns the shadow on or off around this widget.
377 .RE
378 .IP
379 If the widget could not be created then a \fINULL\fR pointer is returned.
380 .TP 5
381 .B positionCDKRadio
382 allows the user to move the widget around the screen via the
383 cursor/keypad keys.
384 See \fRcdk_position (3)\fR for key bindings.
385 .TP 5
386 .B setCDKRadio
387 lets the programmer modify certain elements of an existing radio widget.
388 The parameter names correspond to the same parameter names listed
389 in the \fBnewCDKRadio\fR function.
390 .TP 5
391 .B setCDKRadioBackgroundAttrib
392 sets the background attribute of the widget.
393 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
394 .TP 5
395 .B setCDKRadioBackgroundColor
396 sets the background color of the widget.
397 The parameter \fBcolor\fR
398 is in the format of the Cdk format strings.
399 See \fBcdk_display (3)\fR.
400 .TP 5
401 .B setCDKRadioBox
402 sets whether the widget will be drawn with a box around it.
403 .TP 5
404 .B setCDKRadioBoxAttribute
405 function sets the attribute of the box.
406 .TP 5
407 .B setCDKRadioChoiceCharacter
408 sets the character to use to draw the selected element in the list.
409 .TP 5
410 .B setCDKRadioCurrentItem
411 sets the current item by its index in the list.
412 .TP 5
413 .B setCDKRadioHighlight
414 sets the attribute of the highlight bar.
415 .TP 5
416 .B setCDKRadioHorizontalChar
417 sets the horizontal drawing character for the box to the given character.
418 .TP 5
419 .B setCDKRadioItems
420 set the radio list items and display the result.
421 The current item is set to the beginning of the list.
422 .TP 5
423 .B setCDKRadioLLChar
424 sets the lower left hand corner of the widget's box to the given character.
425 .TP 5
426 .B setCDKRadioLRChar
427 sets the lower right hand corner of the widget's box to the given character.
428 .TP 5
429 .B setCDKRadioLeftBrace
430 sets the character to use to draw the left brace of the selection box.
431 .TP 5
432 .B setCDKRadioPostProcess
433 allows the user to have the widget call a function after the
434 key has been applied to the widget.
435 The parameter \fBfunction\fR is the callback function.
436 The parameter \fBdata\fR points to data passed to the callback function.
437 To learn more about post-processing see \fIcdk_process (3)\fR.
438 .TP 5
439 .B setCDKRadioPreProcess
440 allows the user to have the widget call a function after a key
441 is hit and before the key is applied to the widget.
442 The parameter \fBfunction\fR is the callback function.
443 The parameter \fBdata\fR points to data passed to the callback function.
444 To learn more about pre-processing see \fIcdk_process (3)\fR.
445 .TP 5
446 .B setCDKRadioRightBrace
447 sets the character to use to draw the right brace of the selection box.
448 .TP 5
449 .B setCDKRadioSelectedItem
450 sets the selected item.
451 .TP 5
452 .B setCDKRadioULChar
453 function sets the upper left hand corner of the widget's box to
454 the given character.
455 .TP 5
456 .B setCDKRadioURChar
457 function sets the upper right hand corner of the widget's box to
458 the given character.
459 .TP 5
460 .B setCDKRadioVerticalChar
461 function sets the vertical drawing character for the box to
462 the given character.
463 .SH KEY BINDINGS
464 When the widget is activated there are several default key bindings which will
465 help the user enter or manipulate the information quickly.
466 The following table
467 outlines the keys and their actions for this widget.
468 .LP
469 .TS
470 center tab(/) box;
471 l l
472 lw15 lw35 .
473 \fBKey/Action\fR
474 =
475 Left Arrow/Shifts the whole list left one character.
476 Right Arrow/Shifts the whole list right one character.
477 Up Arrow/Selects the next item up in the list.
478 Down Arrow/Selects the next item down in the list.
479 _
480 Prev Page
481 Ctrl-B/Scroll one page backward.
482 _
483 Next Page
484 Ctrl-F/Scroll one page forward.
485 _
486 1
487 <
488 g
489 Home/Move to the first element in the list.
490 _
491 >
492 G
493 End/Move to the last element in the list.
494 _
495 $/Shifts the whole list to the far right.
496 |/Shifts the whole list to the far left.
497 _
498 Space/Selects or deselects the current choice.
499 Return/T{
500 Exits the widget and returns the index of the selected item.
501 This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
502 T}
503 Tab/T{
504 Exit the widget and return the index of the selected item.
505 Set the widget data \fIexitType\fR to \fIvNORMAL\fR.
506 T}
507 Escape/T{
508 Exit the widget and return -1.
509 Set the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
510 T}
511 Ctrl-L/Refreshes the screen.
512 _
513 .TE
514 .SH SEE ALSO
515 .BR cdk (3),
516 .BR cdk_binding (3),
517 .BR cdk_display (3),
518 .BR cdk_position (3),
519 .BR cdk_screen (3)
0 .\" $Id: cdk_screen.3,v 1.8 2005/12/29 01:31:04 tom Exp $
1 .de XX
2 ..
3 .TH cdk_screen 3
4 .SH NAME
5 .XX destroyCDKScreen
6 .XX endCDK
7 .XX eraseCDKScreen
8 .XX initCDKColor
9 .XX initCDKScreen
10 .XX lowerCDKObject
11 .XX raiseCDKObject
12 .XX refreshCDKScreen
13 .XX registerCDKObject
14 .XX unregisterCDKObject
15 cdk_screen \- Cdk Screen and Widget Manipulation Functions
16 .SH SYNOPSIS
17 .LP
18 .B cc
19 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
20 .B \-lcdk
21 .RI "[ " "library" " \|.\|.\|. ]"
22 .LP
23 #include <cdk.h>
24 .nf
25 .TP 15
26 .B "void destroyCDKScreen("
27 .BI "CDKSCREEN *" "screen");
28 .TP 15
29 .B "void endCDK(void)";
30 .TP 15
31 .B "void eraseCDKScreen("
32 .BI "CDKSCREEN *" "screen");
33 .TP 15
34 .B "void initCDKColor (void)";
35 .TP 15
36 .B "CDKSCREEN *initCDKScreen ("
37 .BI "WINDOW *" "cursesWindow");
38 .TP 15
39 .B "void lowerCDKObject("
40 .BI "EObjectType " "widgetType",
41 .BI "void *" "object");
42 .TP 15
43 .B "void raiseCDKObject("
44 .BI "EObjectType " "widgetType",
45 .BI "void *" "object");
46 .TP 15
47 .B "void refreshCDKScreen("
48 .BI "CDKSCREEN *" "screen");
49 .TP 15
50 .B "void registerCDKObject ("
51 .BI "CDKSCREEN *" "screen",
52 .BI "EObjectType " "widgetType",
53 .BI "void *" "object");
54 .TP 15
55 .B "void unregisterCDKObject("
56 .BI "EObjectType " "widgetType",
57 .BI "void *" "object");
58 .fi
59 .SH DESCRIPTION
60 Cdk manages all of the widgets for you.
61 These functions perform some of the management of the widgets in a screen.
62 .SH AVAILABLE FUNCTIONS
63 .TP 5
64 .B destroyCDKScreen
65 frees any memory allocated by the Cdk screen pointer.
66 .TP 5
67 .B endCDK
68 cleans up any memory created by starting Cdk and shuts down curses.
69 .TP 5
70 .B eraseCDKScreen
71 erases all of the widgets which are currently associated to the
72 given screen.
73 This does \fBNOT\fR destroy the widgets.
74 .TP 5
75 .B initCDKColor
76 starts the Cdk color capabilities.
77 It defines 64 color pairs each
78 of which is accessible using the COLOR_PAIR macro.
79 If you do not have color
80 support, this function call makes no difference.
81 .TP 5
82 .B initCDKScreen
83 takes a \fIWINDOW *\fR (\fIcursesWindow\fR) and returns a
84 pointer to a \fICDKSCREEN *\fR.
85 Since all of the widgets take a
86 \fICDKSCREEN\fR pointer as a first argument, this is also one of the first
87 calls made.
88 This also starts curses, so no curses initialization calls have
89 to be made when using Cdk.
90 .TP 5
91 .B lowerCDKObject
92 has the opposite effect of the \fBraiseCDKObject\fR function call.
93 .TP 5
94 .B raiseCDKObject
95 raises the widget to the top of the screen.
96 If there are any
97 widgets which overlap the given object when a refresh is done, calling this
98 function has the effect of raiding the object so no other widgets obstruct it.
99 The \fIwidgetType\fR parameter states what Cdk widget type this object is.
100 The \fIobject\fR parameter is a void pointer to the object.
101 .TP 5
102 .B refreshCDKScreen
103 redraws all of the widgets which are currently associated to the
104 given screen.
105 .TP 5
106 .B registerCDKObject
107 is called automatically when a widget is created.
108 If for some
109 reason an object does get unregistered, by calling \fBunregisterCDKObject\fR,
110 the widget can be registered again by calling this function.
111 The \fIwidgetType\fR parameter states what Cdk widget type this object is.
112 The \fIobject\fR parameter is a void pointer to the object.
113 .TP 5
114 .B unregisterCDKObject
115 removes the widget from the screen.
116 This does \fBNOT\fR destroy
117 the object, it removes the widget from any further refreshes by the function
118 \fBrefreshCDKScreen\fR.
119 The \fIwidgetType\fR parameter states what Cdk widget
120 type this object is.
121 The \fIobject\fR parameter is a void pointer to the object.
122 .SH SEE ALSO
123 .BR cdk (3),
124 .BR cdk_binding (3),
125 .BR cdk_display (3)
0 '\" t
1 .\" $Id: cdk_scroll.3,v 1.26 2006/05/07 00:49:10 tom Exp $"
2 .de XX
3 ..
4 .TH cdk_scroll 3
5 .SH NAME
6 .XX activateCDKScroll
7 .XX addCDKScrollItem
8 .XX deleteCDKScrollItem
9 .XX destroyCDKScroll
10 .XX drawCDKScroll
11 .XX eraseCDKScroll
12 .XX getCDKScrollBox
13 .XX getCDKScrollCurrent
14 .XX getCDKScrollCurrentItem
15 .XX getCDKScrollCurrentTop
16 .XX getCDKScrollHighlight
17 .XX getCDKScrollItems
18 .XX injectCDKScroll
19 .XX insertCDKScrollItem
20 .XX moveCDKScroll
21 .XX newCDKScroll
22 .XX positionCDKScroll
23 .XX setCDKScroll
24 .XX setCDKScrollBackgroundAttrib
25 .XX setCDKScrollBackgroundColor
26 .XX setCDKScrollBox
27 .XX setCDKScrollBoxAttribute
28 .XX setCDKScrollCurrent
29 .XX setCDKScrollCurrentItem
30 .XX setCDKScrollCurrentTop
31 .XX setCDKScrollHighlight
32 .XX setCDKScrollHorizontalChar
33 .XX setCDKScrollItems
34 .XX setCDKScrollLLChar
35 .XX setCDKScrollLRChar
36 .XX setCDKScrollPosition
37 .XX setCDKScrollPostProcess
38 .XX setCDKScrollPreProcess
39 .XX setCDKScrollULChar
40 .XX setCDKScrollURChar
41 .XX setCDKScrollVerticalChar
42 cdk_scroll \- curses scrolling list widget.
43 .SH SYNOPSIS
44 .LP
45 .B cc
46 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
47 .B \-lcdk
48 .RI "[ " "library" " \|.\|.\|. ]"
49 .LP
50 #include <cdk.h>
51 .nf
52 .TP 15
53 .B "int activateCDKScroll ("
54 .BI "CDKSCROLL *" "scroll",
55 .BI "chtype * " "actions");
56 .TP 15
57 .B "void addCDKScrollItem ("
58 .BI "CDKSCROLL *" "scroll",
59 .BI "char *" "item");
60 .TP 15
61 .B "void deleteCDKScrollItem ("
62 .BI "CDKSCROLL *" "scroll",
63 .BI "int " "position");
64 .TP 15
65 .B "void destroyCDKScroll ("
66 .BI "CDKSCROLL *" "scroll");
67 .TP 15
68 .B "void drawCDKScroll ("
69 .BI "CDKSCROLL *" "scroll",
70 .BI "boolean " "box");
71 .TP 15
72 .B "void eraseCDKScroll ("
73 .BI "CDKSCROLL *" "scroll");
74 .TP 15
75 .B "boolean getCDKScrollBox ("
76 .BI "CDKSCROLL *" "scroll");
77 .TP 15
78 .B "int getCDKScrollCurrent("
79 .BI "CDKSCROLL *" "scroll");
80 .TP 15
81 .B "int getCDKScrollCurrentItem ("
82 .BI "CDKSCROLL *" "widget");
83 .TP 15
84 .B "chtype getCDKScrollHighlight ("
85 .BI "CDKSCROLL *" "scroll",
86 .BI "chtype " "highlight");
87 .TP 15
88 .B "int getCDKScrollCurrentTop ("
89 .BI "CDKSCROLL *" "widget");
90 .TP 15
91 .B "int getCDKScrollItems ("
92 .BI "CDKSCROLL *" "scroll",
93 .BI "char **" "itemList");
94 .TP 15
95 .B "int injectCDKScroll ("
96 .BI "CDKSCROLL *" "scroll",
97 .BI "chtype " "input");
98 .TP 15
99 .B void insertCDKScrollItem (
100 .BI "CDKSCROLL *" "scroll",
101 .BI "char *" "item");
102 .TP 15
103 .B "void moveCDKScroll ("
104 .BI "CDKSCROLL *" "scroll",
105 .BI "int " "xpos",
106 .BI "int " "ypos",
107 .BI "boolean " "relative",
108 .BI "boolean " "refresh");
109 .TP 15
110 .B "CDKSCROLL *newCDKScroll ("
111 .BI "CDKSCREEN *" "cdkscreen",
112 .BI "int " "xpos",
113 .BI "int " "ypos",
114 .BI "int " "spos",
115 .BI "int " "height",
116 .BI "int " "width",
117 .BI "char *" "title",
118 .BI "char **" "itemList",
119 .BI "int " "items",
120 .BI "boolean " "numbers",
121 .BI "chtype " "highlight",
122 .BI "boolean " "box",
123 .BI "boolean " "shadow");
124 .TP 15
125 .B "void positionCDKScroll ("
126 .BI "CDKSCROLL *" "scroll");
127 .TP 15
128 .B "void setCDKScroll ("
129 .BI "CDKSCROLL *" "scroll",
130 .BI "char **" "itemList",
131 .BI "int " "items",
132 .BI "boolean " "numbers",
133 .BI "chtype " "highlight",
134 .BI "boolean " "box");
135 .TP 15
136 .B "void setCDKScrollBackgroundAttrib ("
137 .BI "CDKSCROLL *" "scroll",
138 .BI "chtype " "attribute");
139 .TP 15
140 .B "void setCDKScrollBackgroundColor ("
141 .BI "CDKSCROLL *" "scroll",
142 .BI "char * " "color");
143 .TP 15
144 .B "void setCDKScrollBox ("
145 .BI "CDKSCROLL *" "scroll",
146 .BI "boolean " "box");
147 .TP 15
148 .B "void setCDKScrollBoxAttribute ("
149 .BI "CDKSCROLL *" "scroll",
150 .BI "chtype " "character");
151 .TP 15
152 .B "void setCDKScrollCurrent(
153 .BI "CDKSCROLL *" "scroll",
154 .BI "int" "item");
155 .TP 15
156 .B "void setCDKScrollCurrentItem ("
157 .BI "CDKSCROLL *" "widget",
158 .BI "int" "item");
159 .TP 15
160 .B "int getCDKScrollCurrentTop ("
161 .BI "CDKSCROLL *" "widget");
162 .TP 15
163 .B "void setCDKScrollHighlight ("
164 .BI "CDKSCROLL *" "scroll",
165 .BI "chtype " "highlight");
166 .TP 15
167 .B "void setCDKScrollHorizontalChar ("
168 .BI "CDKSCROLL *" "scroll",
169 .BI "chtype " "character");
170 .TP 15
171 .B "void setCDKScrollItems ("
172 .BI "CDKSCROLL *" "scroll",
173 .BI "char **" "itemList",
174 .BI "int " "listSize",
175 .BI "boolean " "numbers");
176 .TP 15
177 .B "void setCDKScrollLLChar ("
178 .BI "CDKSCROLL *" "scroll",
179 .BI "chtype " "character");
180 .TP 15
181 .B "void setCDKScrollLRChar ("
182 .BI "CDKSCROLL *" "scroll",
183 .BI "chtype " "character");
184 .TP 15
185 .B "void setCDKScrollPosition ("
186 .BI "CDKSCROLL *" "scroll",
187 .BI "int" "item");
188 .TP 15
189 .B "void setCDKScrollPostProcess ("
190 .BI "CDKSCROLL *" "scroll",
191 .BI "PROCESSFN " "callback",
192 .BI "void * " "data");
193 .TP 15
194 .B "void setCDKScrollPreProcess ("
195 .BI "CDKSCROLL *" "scroll",
196 .BI "PROCESSFN " "callback",
197 .BI "void * " "data");
198 .TP 15
199 .B "void setCDKScrollULChar ("
200 .BI "CDKSCROLL *" "scroll",
201 .BI "chtype " "character");
202 .TP 15
203 .B "void setCDKScrollURChar ("
204 .BI "CDKSCROLL *" "scroll",
205 .BI "chtype " "character");
206 .TP 15
207 .B "void setCDKScrollVerticalChar ("
208 .BI "CDKSCROLL *" "scroll",
209 .BI "chtype " "character");
210 .fi
211 .SH DESCRIPTION
212 The Cdk scroll widget creates a scrolling list.
213 The following are functions
214 which create or manipulate the Cdk scrolling list widget.
215 .SH AVAILABLE FUNCTIONS
216 .TP 5
217 .B activateCDKScroll
218 activates the scroll widget and lets the user interact with the widget.
219 The parameter \fBscroll\fR points to a non-NULL scroll widget.
220 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
221 in the array will be injected into the widget.
222 To activate the widget
223 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
224 If the character entered
225 into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a
226 value from 0 to the number of items-1, representing the item selected.
227 It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
228 If the
229 character entered into this widget was \fIESCAPE\fR then the widget will return
230 a value of -1 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR.
231 .TP 5
232 .B addCDKScrollItem
233 allows the user to add an item into an existing scrolling list.
234 The \fBscroll\fR parameter points to the scrolling list to add the
235 item to.
236 The parameter \fBitem\fR is a \fIchar *\fR representing the new item
237 to add.
238 The item is always added to the end of the list.
239 .TP 5
240 .B deleteCDKScrollItem
241 allows the user to add an item into an existing scrolling list.
242 The \fBscroll\fR parameter points to the scrolling list to add the
243 item to.
244 The parameter \fBf2position\fR is an \fIint\fR which specifies which
245 element to remove.
246 .TP 5
247 .B destroyCDKScroll
248 removes the widget from the screen and frees memory the object used.
249 .TP 5
250 .B drawCDKScroll
251 draws the scroll widget on the screen.
252 If the \fBbox\fR option is true, the widget is drawn with a box.
253 .TP 5
254 .B eraseCDKScroll
255 removes the widget from the screen.
256 This does \fINOT\fR destroy the widget.
257 .TP 5
258 .B getCDKScrollBox
259 returns true if the widget will be drawn with a box around it.
260 .TP 5
261 .B getCDKScrollCurrent
262 returns the current item's index.
263 .TP 5
264 .B getCDKScrollCurrentItem
265 returns the current item number in the scroller.
266 .TP 5
267 .B getCDKScrollHighlight
268 returns the attribute of the highlight bar.
269 .TP 5
270 .B getCDKScrollCurrentTop
271 returns the top line of the scroller, counting from zero.
272 .TP 5
273 .B getCDKScrollItems
274 fills the parameter \fBitemList\fR with the contents of the scrolling list.
275 It returns the number of elements in the scrolling list.
276 .TP 5
277 .B injectCDKScroll
278 injects a single character into the widget.
279 The parameter \fBscroll\fR points to a non-NULL scroll widget.
280 The parameter \fBcharacter\fR is the character to inject into the widget.
281 The return value and side-effect (setting the widget data \fIexitType\fP)
282 depend upon the injected character:
283 .RS
284 .TP
285 \fIRETURN\fP or \fITAB\fR
286 the function returns
287 a value ranging from zero to one less than the number of items,
288 representing the item selected.
289 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
290 .TP
291 \fIESCAPE\fP
292 the function returns
293 -1.
294 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
295 .TP
296 Otherwise
297 unless modified by preprocessing, postprocessing or key bindings,
298 the function returns
299 -1.
300 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
301 .RE
302 .TP 5
303 .B insertCDKScrollItem
304 allows the user to add an item into an existing scrolling list.
305 The \fBscroll\fR parameter points to the scrolling list to add the item to.
306 The parameter \fBitem\fR is a \fIchar *\fR representing the new item to add.
307 The item is always added before the current item in the list.
308 .TP 5
309 .B moveCDKScroll
310 moves the given widget to the given position.
311 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
312 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
313 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
314 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
315 \fIRIGHT\fR, and \fICENTER\fR.
316 The parameter \fBrelative\fR states whether
317 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
318 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
319 then the widget would move one row down and two columns right.
320 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
321 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
322 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
323 (weird things may happen).
324 The final parameter \fBrefresh\fR is a boolean value which states
325 whether the widget will get refreshed after the move.
326 .TP 5
327 .B newCDKScroll
328 creates a scroll widget and returns a pointer to it.
329 Parameters:
330 .RS
331 .TP 5
332 \fBscreen\fR
333 parameter
334 is the screen you wish this widget to be placed in.
335 The parameter \fBxpos\fR
336 controls the placement of the object along the horizontal axis.
337 This parameter
338 may be an integer or one of the pre-defined values \fILEFT\fR,
339 \fIRIGHT\fR, and \fICENTER\fR.
340 .TP 5
341 \fBypos\fR
342 controls the placement
343 of the object along the vertical axis.
344 This parameter may be an integer
345 value or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
346 .TP 5
347 \fBspos\fR
348 is where the scroll bar is to be placed.
349 This may be one of three values:
350 .RS
351 .TP 5
352 \fILEFT\fR,
353 which puts the scroll bar on the left
354 of the scrolling list.
355 .TP 5
356 \fIRIGHT\fR
357 which puts the scroll bar on the right side
358 of the list, and
359 .TP 5
360 \fINONE\fR which does not add a scroll bar.
361 .RE
362 .TP 5
363 \fBheight\fR and
364 .TP 5
365 \fBwidth\fR
366 control the height and width of the widget.
367 If you provide a value of zero for either of the height or the width, the widget will
368 be created with the full width and height of the screen.
369 If you provide a negative
370 value, the widget will be created the full height or width minus the value provided.
371 .TP 5
372 \fBtitle\fR
373 is the string which will be displayed
374 at the top of the widget.
375 The title can be more than one line; just provide a
376 carriage return character at the line break.
377 .TP 5
378 \fBitemList\fR
379 is the list of items to be displayed in the scrolling list.
380 .TP 5
381 \fBitems\fR
382 is the number of elements in the given list.
383 .TP 5
384 \fBnumbers\fR
385 is true if you want the items in the list to have a number
386 attached to the front of the list items.
387 .TP 5
388 \fBhighlight\fR
389 specifies
390 the display attribute of the currently selected item.
391 .TP 5
392 \fBbox\fR
393 is true if the widget should be drawn with a box around it.
394 .TP 5
395 \fBshadow\fR
396 is true to turn the shadow on around this widget.
397 .RE
398 .IP
399 If the widget could not be created then a \fINULL\fR pointer is returned.
400 .TP 5
401 .B positionCDKScroll
402 allows the user to move the widget around the screen via the cursor/keypad keys.
403 See \fBcdk_position (3)\fR for key bindings.
404 .TP 5
405 .B setCDKScroll
406 lets the programmer modify certain elements of an existing
407 scroll widget.
408 The parameter names correspond to the same parameter names listed
409 in the \fBnewCDKScroll\fR function.
410 .TP 5
411 .B setCDKScrollBackgroundAttrib
412 sets the background attribute of the widget.
413 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
414 .TP 5
415 .B setCDKScrollBackgroundColor
416 sets the background color of the widget.
417 The parameter \fBcolor\fR
418 is in the format of the Cdk format strings.
419 See \fBcdk_display (3)\fR.
420 .TP 5
421 .B setCDKScrollBox
422 sets whether the widget will be drawn with a box around it.
423 .TP 5
424 .B setCDKScrollBoxAttribute
425 sets the attribute of the box.
426 .TP 5
427 .B setCDKScrollCurrent
428 sets the index for the current item.
429 .TP 5
430 .B setCDKScrollCurrentItem
431 set the current item number in the scroller.
432 .TP 5
433 .B setCDKScrollCurrentTop
434 set the top line number of the scroller.
435 .TP 5
436 .B setCDKScrollHighlight
437 sets the attribute of the highlight bar.
438 .TP 5
439 .B setCDKScrollHorizontalChar
440 sets the horizontal drawing character for the box to
441 the given character.
442 .TP 5
443 .B setCDKScrollItems
444 sets the contents of the scrolling list.
445 .TP 5
446 .B setCDKScrollLLChar
447 sets the lower left hand corner of the widget's box to
448 the given character.
449 .TP 5
450 .B setCDKScrollLRChar
451 sets the lower right hand corner of the widget's box to
452 the given character.
453 .TP 5
454 .B setCDKScrollPosition
455 sets the current item in the widget to the given position.
456 .TP 5
457 .B setCDKScrollPostProcess
458 allows the user to have the widget call a function after the
459 key has been applied to the widget.
460 The parameter \fBfunction\fR is the callback function.
461 The parameter \fBdata\fR points to data passed to the callback function.
462 To learn more about post-processing see \fIcdk_process (3)\fR.
463 .TP 5
464 .B setCDKScrollPreProcess
465 allows the user to have the widget call a function after a key
466 is hit and before the key is applied to the widget.
467 The parameter \fBfunction\fR is the callback function.
468 The parameter \fBdata\fR points to data passed to the callback function.
469 To learn more about pre-processing see \fIcdk_process (3)\fR.
470 .TP 5
471 .B setCDKScrollULChar
472 sets the upper left hand corner of the widget's box to
473 the given character.
474 .TP 5
475 .B setCDKScrollURChar
476 sets the upper right hand corner of the widget's box to
477 the given character.
478 .TP 5
479 .B setCDKScrollVerticalChar
480 sets the vertical drawing character for the box to
481 the given character.
482 .SH KEY BINDINGS
483 When the widget is activated there are several default key bindings which will
484 help the user enter or manipulate the information quickly.
485 The following table
486 outlines the keys and their actions for this widget.
487 .LP
488 .TS
489 center tab(/) box;
490 l l
491 l l
492 lw15 lw35 .
493 \fBKey/Action\fR
494 =
495 Left Arrow/Shift the list left one column.
496 Right Arrow/Shift the list right one column.
497 Up Arrow/Select the previous item in the list.
498 Down Arrow/Select the next item in the list.
499 _
500 Prev Page
501 Ctrl-B/Scroll one page backward.
502 Next Page
503 Ctrl-F/Scroll one page forward.
504 _
505 1
506 <
507 g
508 Home/Move to the first element in the list.
509 _
510 >
511 G
512 End/Move to the last element in the list.
513 _
514 $/Shift the list to the far right.
515 |/Shift the list to the far left.
516 _
517 Return/T{
518 Exit the widget and return the index of the selected item.
519 Also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
520 T}
521 Tab/T{
522 Exit the widget and return the index of the selected item.
523 Also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
524 T}
525 Escape/T{
526 Exit the widget and return -1.
527 Also set the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
528 T}
529 Ctrl-L/Refreshes the screen.
530 .TE
531 .SH SEE ALSO
532 .BR cdk (3),
533 .BR cdk_binding (3),
534 .BR cdk_display (3),
535 .BR cdk_position (3),
536 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_selection.3,v 1.22 2005/12/28 21:52:07 tom Exp $"
2 .de XX
3 ..
4 .TH cdk_selection 3
5 .SH NAME
6 .XX activateCDKSelection
7 .XX destroyCDKSelection
8 .XX drawCDKSelection
9 .XX eraseCDKSelection
10 .XX getCDKSelectionBox
11 .XX getCDKSelectionChoice
12 .XX getCDKSelectionChoices
13 .XX getCDKSelectionCurrent
14 .XX getCDKSelectionHighlight
15 .XX getCDKSelectionItems
16 .XX getCDKSelectionMode
17 .XX getCDKSelectionModes
18 .XX getCDKSelectionTitle
19 .XX injectCDKSelection
20 .XX moveCDKSelection
21 .XX newCDKSelection
22 .XX positionCDKSelection
23 .XX setCDKSelection
24 .XX setCDKSelectionBackgroundAttrib
25 .XX setCDKSelectionBackgroundColor
26 .XX setCDKSelectionBox
27 .XX setCDKSelectionBoxAttribute
28 .XX setCDKSelectionChoice
29 .XX setCDKSelectionChoices
30 .XX setCDKSelectionCurrent
31 .XX setCDKSelectionHighlight
32 .XX setCDKSelectionHorizontalChar
33 .XX setCDKSelectionItems
34 .XX setCDKSelectionLLChar
35 .XX setCDKSelectionLRChar
36 .XX setCDKSelectionMode
37 .XX setCDKSelectionModes
38 .XX setCDKSelectionPostProcess
39 .XX setCDKSelectionPreProcess
40 .XX setCDKSelectionTitle
41 .XX setCDKSelectionULChar
42 .XX setCDKSelectionURChar
43 .XX setCDKSelectionVerticalChar
44 cdk_selection \- curses selection list widget.
45 .SH SYNOPSIS
46 .LP
47 .B cc
48 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
49 .B \-lcdk
50 .RI "[ " "library" " \|.\|.\|. ]"
51 .LP
52 #include <cdk.h>
53 .nf
54 .TP 15
55 .B "int activateCDKSelection ("
56 .BI "CDKSELECTION *" "selection",
57 .BI "chtype * " "actions");
58 .TP 15
59 .B "void destroyCDKSelection ("
60 .BI "CDKSELECTION *" "selection");
61 .TP 15
62 .B "void drawCDKSelection ("
63 .BI "CDKSELECTION *" "selection",
64 .BI "boolean " "box");
65 .TP 15
66 .B "void eraseCDKSelection ("
67 .BI "CDKSELECTION *" "selection");
68 .TP 15
69 .B "boolean getCDKSelectionBox ("
70 .BI "CDKSELECTION *" "selection");
71 .TP 15
72 .B "int getCDKSelectionChoice ("
73 .BI "CDKSELECTION *" "selection",
74 .BI "int " "index");
75 .TP 15
76 .B "int *getCDKSelectionChoices ("
77 .BI "CDKSELECTION *" "selection");
78 .TP 15
79 .B "int getCDKSelectionCurrent ("
80 .BI "CDKSELECTION *" "selection");
81 .TP 15
82 .B "chtype getCDKSelectionHighlight ("
83 .BI "CDKSELECTION *" "selection");
84 .TP 15
85 .B "int getCDKSelectionItems ("
86 .BI "CDKSELECTION *" "selection",
87 .BI "char **" "list");
88 .TP 15
89 .B "int getCDKSelectionMode ("
90 .BI "CDKSELECTION *" "selection",
91 .BI "int " "index");
92 .TP 15
93 .B "int *getCDKSelectionModes ("
94 .BI "CDKSELECTION *" "selection");
95 .TP 15
96 .B "char *getCDKSelectionTitle ("
97 .BI "CDKSELECTION *" "selection");
98 .TP 15
99 .B "int injectCDKSelection ("
100 .BI "CDKSELECTION *" "selection",
101 .BI "chtype " "input");
102 .TP 15
103 .B "void moveCDKSelection ("
104 .BI "CDKSELECTION *" "selection",
105 .BI "int " "xpos",
106 .BI "int " "ypos",
107 .BI "boolean " "relative",
108 .BI "boolean " "refresh");
109 .TP 15
110 .B "CDKSELECTION *newCDKSelection ("
111 .BI "CDKSCREEN *" "cdkscreen",
112 .BI "int " "xpos",
113 .BI "int " "ypos",
114 .BI "int " "spos",
115 .BI "int " "height",
116 .BI "int " "width",
117 .BI "char *" "title",
118 .BI "char **" "selectionList",
119 .BI "int " "selectionListLength",
120 .BI "char **" "choiceList",
121 .BI "int " "choiceListLength",
122 .BI "chtype " "highlight",
123 .BI "boolean " "box",
124 .BI "boolean " "shadow");
125 .TP 15
126 .B "void positionCDKSelection ("
127 .BI "CDKSELECTION *" "selection");
128 .TP 15
129 .B "void setCDKSelection ("
130 .BI "CDKSELECTION *" "selection",
131 .BI "chtype " "highlight",
132 .BI "int *" "defChoices",
133 .BI "boolean " "box");
134 .TP 15
135 .B "void setCDKSelectionBackgroundAttrib ("
136 .BI "CDKSELECTION *" "selection",
137 .BI "chtype " "attribute");
138 .TP 15
139 .B "void setCDKSelectionBackgroundColor ("
140 .BI "CDKSELECTION *" "selection",
141 .BI "char * " "color");
142 .TP 15
143 .B "void setCDKSelectionBox ("
144 .BI "CDKSELECTION *" "selection",
145 .BI "boolean " "boxWidget");
146 .TP 15
147 .B "void setCDKSelectionBoxAttribute ("
148 .BI "CDKSELECTION *" "selection",
149 .BI "chtype " "character");
150 .TP 15
151 .B "void setCDKSelectionChoice ("
152 .BI "CDKSELECTION *" "selection",
153 .BI "int " "index",
154 .BI "int " "choice");
155 .TP 15
156 .B "void setCDKSelectionChoices ("
157 .BI "CDKSELECTION *" "selection",
158 .BI "int *" "choices");
159 .TP 15
160 .B "void setCDKSelectionCurrent ("
161 .BI "CDKSELECTION *" "selection",
162 .BI "int" "index");
163 .TP 15
164 .B "void setCDKSelectionHighlight ("
165 .BI "CDKSELECTION *" "selection",
166 .BI "chtype " "highlight");
167 .TP 15
168 .B "void setCDKSelectionHorizontalChar ("
169 .BI "CDKSELECTION *" "selection",
170 .BI "chtype " "character");
171 .TP 15
172 .B "void setCDKSelectionItems ("
173 .BI "CDKSELECTION *" "selection",
174 .BI "char **" "list",
175 .BI "int " "listSize");
176 .TP 15
177 .B "void setCDKSelectionLLChar ("
178 .BI "CDKSELECTION *" "selection",
179 .BI "chtype " "character");
180 .TP 15
181 .B "void setCDKSelectionLRChar ("
182 .BI "CDKSELECTION *" "selection",
183 .BI "chtype " "character");
184 .TP 15
185 .B "void setCDKSelectionMode ("
186 .BI "CDKSELECTION *" "selection",
187 .BI "int " "index",
188 .BI "int " "mode");
189 .TP 15
190 .B "void setCDKSelectionModes ("
191 .BI "CDKSELECTION *" "selection",
192 .BI "int *" "modes");
193 .TP 15
194 .B "void setCDKSelectionPostProcess ("
195 .BI "CDKSELECTION *" "selection",
196 .BI "PROCESSFN " "callback",
197 .BI "void * " "data");
198 .TP 15
199 .B "void setCDKSelectionPreProcess ("
200 .BI "CDKSELECTION *" "selection",
201 .BI "PROCESSFN " "callback",
202 .BI "void * " "data");
203 .TP 15
204 .B "void setCDKSelectionTitle ("
205 .BI "CDKSELECTION *" "selection",
206 .BI "char *" "title");
207 .TP 15
208 .B "void setCDKSelectionULChar ("
209 .BI "CDKSELECTION *" "selection",
210 .BI "chtype " "character");
211 .TP 15
212 .B "void setCDKSelectionURChar ("
213 .BI "CDKSELECTION *" "selection",
214 .BI "chtype " "character");
215 .TP 15
216 .B "void setCDKSelectionVerticalChar ("
217 .BI "CDKSELECTION *" "selection",
218 .BI "chtype " "character");
219 .fi
220 .SH DESCRIPTION
221 The Cdk selection widget creates a selection list.
222 The following functions create or manipulate the Cdk selection list widget.
223 .SH AVAILABLE FUNCTIONS
224 .TP 5
225 .B activateCDKSelection
226 activates the selection widget and lets the user interact with the widget.
227 The parameter \fBselection\fR is a pointer to a non-NULL selection widget.
228 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
229 in the array will be injected into the widget.
230 To activate the widget
231 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
232 If the character entered
233 into this widget is \fIRETURN\fR or \fITAB\fR then this function will return 1.
234 Itm will also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
235 If the
236 character entered into this widget was \fIESCAPE\fR then the widget will return
237 a value of -1 and the widget data \fIexitType\fR will be set to
238 \fIvESCAPE_HIT\fR.
239 .TP 5
240 .B destroyCDKSelection
241 removes the widget from the screen and frees memory the object used.
242 .TP 5
243 .B drawCDKSelection
244 draws the selection widget on the screen.
245 If the \fBbox\fR parameter is true, the widget is drawn with a box.
246 .TP 5
247 .B eraseCDKSelection
248 removes the widget from the screen.
249 This does \fINOT\fR destroy the widget.
250 .TP 5
251 .B getCDKSelectionBox
252 returns true if the widget will be drawn with a box around it.
253 .TP 5
254 .B getCDKSelectionChoice
255 returns the selection choice at the given index.
256 .TP 5
257 .B getCDKSelectionChoices
258 returns an array of the current selection choices for the widget.
259 .TP 5
260 .B getCDKSelectionCurrent
261 returns the current selection index.
262 .TP 5
263 .B getCDKSelectionHighlight
264 returns the attribute of the highlight bar.
265 .TP 5
266 .B getCDKSelectionItems
267 copies the selection-list items into the caller's array
268 and returns the number of items in the list.
269 .TP 5
270 .B getCDKSelectionMode
271 returns the selection mode at the given index.
272 .TP 5
273 .B getCDKSelectionModes
274 returns an array of the current modes for the widget.
275 .TP 5
276 .B getCDKSelectionTitle
277 returns the first line of the title of the selection widget.
278 The caller must free the returned value.
279 .TP 5
280 .B injectCDKSelection
281 injects a single character into the widget.
282 The parameter \fBselection\fR is a pointer to a non-NULL selection widget.
283 The parameter \fBcharacter\fR is the character to inject into the widget.
284 The return value and side-effect (setting the widget data \fIexitType\fP)
285 depend upon the injected character:
286 .RS
287 .TP
288 \fIRETURN\fP or \fITAB\fR
289 the function returns
290 1.
291 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
292 .TP
293 \fIESCAPE\fP
294 the function returns
295 -1.
296 \fIvESCAPE_HIT\fR.
297 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
298 .TP
299 Otherwise
300 unless modified by preprocessing, postprocessing or key bindings,
301 the function returns
302 -1.
303 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
304 .RE
305 .TP 5
306 .B moveCDKSelection
307 moves the given widget to the given position.
308 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
309 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
310 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
311 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
312 \fIRIGHT\fR, and \fICENTER\fR.
313 The parameter \fBrelative\fR states whether
314 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
315 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
316 then the widget would move one row down and two columns right.
317 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
318 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
319 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
320 (weird things may happen).
321 The final parameter \fBrefresh\fR is a boolean value which
322 states whether the widget will get refreshed after the move.
323 .TP 5
324 .B newCDKSelection
325 creates a selection widget and returns a pointer to it.
326 Parameters:
327 .RS
328 .TP 5
329 \fBscreen\fR
330 is the screen you wish this widget to be placed in.
331 .TP 5
332 \fBxpos\fR
333 controls the placement of the object along the horizontal axis.
334 It may be an integer or one of the pre-defined values
335 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
336 .TP 5
337 \fBypos\fR
338 controls the placement of the object along the vertical axis.
339 It may be an integer or one of the pre-defined values
340 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
341 .TP 5
342 \fBspos\fR
343 is where the scroll bar is to be placed.
344 It may be one of three values:
345 .RS
346 .TP 5
347 \fILEFT\fR
348 puts the scroll bar on the left
349 of the scrolling list.
350 \fIRIGHT\fR
351 puts the scroll bar on the right side of the list, and
352 .TP 5
353 \fINONE\fR
354 does not add a scroll bar.
355 .RE
356 .TP 5
357 \fBheight\fR and
358 .TP 5
359 \fBwidth\fR
360 control the height and width of the widget.
361 If you provide a value of zero for either of the height or the width, the widget
362 will be created with the full width and height of the screen.
363 If you provide a
364 negative value, the widget will be created the full height or width minus the
365 value provided.
366 .TP 5
367 \fBtitle\fR
368 is the string which to display at the top of the widget.
369 The title can be more than one line; just
370 provide a carriage return character at the line break.
371 .TP 5
372 \fBselectionList\fR
373 is the list of items to display in the selection list
374 .TP 5
375 \fBselectionListLength\fR
376 is the number of elements in the given list.
377 .TP 5
378 \fBchoiceList\fR
379 is the list of choices that will
380 be selected when the user presses the space bar.
381 .TP 5
382 \fBchoiceListLength\fR
383 is the length of this list.
384 .TP 5
385 \fBhighlight\fR
386 specifies the display attribute of the currently selected item.
387 .TP 5
388 \fBbox\fR
389 is true if the widget should be drawn with a box around it.
390 .TP 5
391 \fBshadow\fR
392 turns the shadow on or off around this widget.
393 .RE
394 .IP
395 If the widget could not be created then a \fINULL\fR pointer is returned.
396 .TP 5
397 .B positionCDKSelection
398 allows the user to move the widget around the screen via the cursor/keypad keys.
399 See \fBcdk_position (3)\fR for key bindings.
400 .TP 5
401 .B setCDKSelection
402 lets the programmer modify certain elements of an existing selection widget.
403 The parameter names correspond to the same
404 parameter names listed in the \fBnewCDKSelection\fR function.
405 .TP 5
406 .B setCDKSelectionBackgroundAttrib
407 sets the background attribute of the widget.
408 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
409 .TP 5
410 .B setCDKSelectionBackgroundColor
411 sets the background color of the widget.
412 The parameter \fBcolor\fR
413 is in the format of the Cdk format strings.
414 See \fBcdk_display (3)\fR.
415 .TP 5
416 .B setCDKSelectionBox
417 sets whether the widget will be drawn with a box around it.
418 .TP 5
419 .B setCDKSelectionBoxAttribute
420 sets the attribute of the box.
421 .TP 5
422 .B setCDKSelectionChoice
423 sets the selection choice value at the given index.
424 .TP 5
425 .B setCDKSelectionChoices
426 sets the selection choice values of the widget.
427 .TP 5
428 .B setCDKSelectionCurrent
429 sets the current selection index.
430 .TP 5
431 .B setCDKSelectionHighlight
432 sets the attribute of the highlight bar.
433 .TP 5
434 .B setCDKSelectionHorizontalChar
435 sets the horizontal drawing character for the box to the given character.
436 .TP 5
437 .B setCDKSelectionItems
438 sets the selection list items.
439 .TP 5
440 .B setCDKSelectionLLChar
441 sets the lower left hand corner of the widget's box to the given character.
442 .TP 5
443 .B setCDKSelectionLRChar
444 sets the lower right hand corner of the widget's box to the given character.
445 .TP 5
446 .B setCDKSelectionMode
447 sets the selection mode at the given index.
448 .TP 5
449 .B setCDKSelectionModes
450 sets the selection mode of the elements of the widget.
451 There are two acceptable values for the modes: 0 which allows the user to change the
452 selection value at the given index; and 1 which sets the element to a read-only state.
453 .TP 5
454 .B setCDKSelectionPostProcess
455 allows the user to have the widget call a function after the
456 key has been applied to the widget.
457 The parameter \fBfunction\fR is the callback function.
458 The parameter \fBdata\fR points to data passed to the callback function.
459 To learn more about post-processing see \fIcdk_process (3)\fR.
460 .TP 5
461 .B setCDKSelectionPreProcess
462 allows the user to have the widget call a function after a key
463 is hit and before the key is applied to the widget.
464 The parameter \fBfunction\fR is the callback function.
465 The parameter \fBdata\fR is a pointer to
466 \fIvoid\fR.
467 To learn more about pre-processing see \fIcdk_process (3)\fR.
468 .TP 5
469 .B setCDKSelectionTitle
470 set the selection list's title.
471 .TP 5
472 .B setCDKSelectionULChar
473 sets the upper left hand corner of the widget's box to the given character.
474 .TP 5
475 .B setCDKSelectionURChar
476 sets the upper right hand corner of the widget's box to the given character.
477 .TP 5
478 .B setCDKSelectionVerticalChar
479 sets the vertical drawing character for the box to the given character.
480 .SH KEY BINDINGS
481 When the widget is activated there are several default key bindings which
482 help the user enter or manipulate the information quickly:
483 .LP
484 .TS
485 center tab(/) box;
486 l l
487 l l
488 lw15 lw35 .
489 \fBKey/Action\fR
490 =
491 Left Arrow/T{
492 Shift the whole list left one column.
493 T}
494 Right Arrow/T{
495 Shift the whole list right one column.
496 T}
497 Up Arrow/T{
498 Select the previous item in the list.
499 T}
500 Down Arrow/T{
501 Select the next item in the list.
502 T}
503 _
504 Prev Page
505 Ctrl-B/Scroll one page backward.
506 _
507 Next Page
508 Ctrl-F/Scroll one page forward.
509 _
510 1
511 <
512 g
513 Home/Move to the first element in the list.
514 _
515 >
516 G
517 End/Move to the last element in the list.
518 _
519 $/Shift the whole list to the far right.
520 |/Shift the whole list to the far left.
521 _
522 Space/T{
523 Cycles to the next choice on the current item.
524 T}
525 Return/T{
526 Exit the widget and return 1.
527 Also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
528 T}
529 Tab/T{
530 Exit the widget and return 1.
531 Also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
532 T}
533 Escape/T{
534 Exit the widget and return -1.
535 Also set the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
536 T}
537 Ctrl-L/Refreshes the screen.
538 .TE
539 .SH SEE ALSO
540 .BR cdk (3),
541 .BR cdk_binding (3),
542 .BR cdk_display (3),
543 .BR cdk_position (3),
544 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_swindow.3,v 1.22 2005/12/28 18:35:31 tom Exp $
2 .de XX
3 ..
4 .TH cdk_swindow 3
5 .SH NAME
6 .XX activateCDKSwindow
7 .XX addCDKSwindow
8 .XX cleanCDKSwindow
9 .XX destroyCDKSwindow
10 .XX drawCDKSwindow
11 .XX dumpCDKSwindow
12 .XX eraseCDKSwindow
13 .XX execCDKSwindow
14 .XX getCDKSwindowBox
15 .XX getCDKSwindowContents
16 .XX injectCDKSwindow
17 .XX jumpToLineCDKSwindow
18 .XX loadCDKSwindowInformation
19 .XX moveCDKSwindow
20 .XX newCDKSwindow
21 .XX positionCDKSwindow
22 .XX saveCDKSwindowInformation
23 .XX setCDKSwindow
24 .XX setCDKSwindowBackgroundAttrib
25 .XX setCDKSwindowBackgroundColor
26 .XX setCDKSwindowBox
27 .XX setCDKSwindowBoxAttribute
28 .XX setCDKSwindowContents
29 .XX setCDKSwindowHorizontalChar
30 .XX setCDKSwindowLLChar
31 .XX setCDKSwindowLRChar
32 .XX setCDKSwindowPostProcess
33 .XX setCDKSwindowPreProcess
34 .XX setCDKSwindowULChar
35 .XX setCDKSwindowURChar
36 .XX setCDKSwindowVerticalChar
37 .XX trimCDKSwindow
38 cdk_swindow \- a curses scrolling window widget.
39 .SH SYNOPSIS
40 .LP
41 .B cc
42 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
43 .B \-lcdk
44 .RI "[ " "library" " \|.\|.\|. ]"
45 .LP
46 #include <cdk.h>
47 .nf
48 .TP 15
49 .B "void activateCDKSwindow ("
50 .BI "CDKSWINDOW *" "swindow",
51 .BI "chtype * " "actions");
52 .TP 15
53 .B "void addCDKSwindow ("
54 .BI "CDKSWINDOW *" "swindow",
55 .BI "char *" "info",
56 .BI "int " "insertPosition");
57 .TP 15
58 .B "void cleanCDKSwindow ("
59 .BI "CDKSWINDOW *" "swindow");
60 .TP 15
61 .B "int execCDKSwindow ("
62 .BI "CDKSWINDOW *" "swindow",
63 .BI "char * " "command",
64 .BI "int " "insertPosition");
65 .TP 15
66 .B "void destroyCDKSwindow ("
67 .BI "CDKSWINDOW *" "swindow");
68 .TP 15
69 .B "void drawCDKSwindow ("
70 .BI "CDKSWINDOW *" "swindow",
71 .BI "boolean " "box");
72 .TP 15
73 .B "void dumpCDKSwindow ("
74 .BI "CDKSWINDOW *" "swindow",
75 .BI "char *" "filename");
76 .TP 15
77 .B "void eraseCDKSwindow ("
78 .BI "CDKSWINDOW *" "swindow");
79 .B "void execCDKSwindow ("
80 .BI "CDKSWINDOW *" "swindow,"
81 .BI "char *" "command,"
82 .BI "int " "insertPosition);"
83 .B "boolean getCDKSwindowBox ("
84 .BI "CDKSWINDOW *" "swindow);"
85 .TP 15
86 .B "chtype **getCDKSwindowContents ("
87 .BI "CDKSWINDOW *" "swindow");
88 .TP 15
89 .B "int injectCDKSwindow ("
90 .BI "CDKSWINDOW *" "swindow",
91 .BI "chtype " "input");
92 .TP 15
93 .B "void jumpToLineCDKSwindow ("
94 .BI "CDKSWINDOW *" "swindow",
95 .BI "int " "line");
96 .TP 15
97 .B "void loadCDKSwindowInformation ("
98 .BI "CDKSWINDOW *" "swindow");
99 .TP 15
100 .B "void moveCDKSwindow ("
101 .BI "CDKSWINDOW *" "swindow",
102 .BI "int " "xpos",
103 .BI "int " "ypos",
104 .BI "boolean " "relative",
105 .BI "boolean " "refresh");
106 .TP 15
107 .B "CDKSWINDOW *newCDKSwindow ("
108 .BI "CDKSCREEN *" "cdkscreen",
109 .BI "int " "xpos",
110 .BI "int " "ypos",
111 .BI "int " "height",
112 .BI "int " "width",
113 .BI "char *" "title",
114 .BI "int " "saveLines",
115 .BI "boolean " "box",
116 .BI "boolean " "shadow");
117 .TP 15
118 .B "void positionCDKSwindow ("
119 .BI "CDKSWINDOW *" "swindow");
120 .TP 15
121 .B "void saveCDKSwindowInformation ("
122 .BI "CDKSWINDOW *" "swindow");
123 .TP 15
124 .B "void setCDKSwindow ("
125 .BI "CDKSWINDOW *" "swindow",
126 .BI "char **" "info",
127 .BI "int " "lines",
128 .BI "boolean " "box");
129 .TP 15
130 .B "void setCDKSwindowBackgroundAttrib ("
131 .BI "CDKSWINDOW *" "swindow",
132 .BI "chtype " "attribute");
133 .TP 15
134 .B "void setCDKSwindowBackgroundColor ("
135 .BI "CDKSWINDOW *" "swindow",
136 .BI "char * " "color");
137 .B "void setCDKSwindowBox ("
138 .BI "CDKSWINDOW *" "swindow,"
139 .BI "boolean " "boxWidget);"
140 .TP 15
141 .B "void setCDKSwindowBoxAttribute ("
142 .BI "CDKSWINDOW *" "swindow",
143 .BI "chtype " "character");
144 .TP 15
145 .B "void setCDKSwindowContents ("
146 .BI "CDKSWINDOW *" "swindow",
147 .BI "char **" "info",
148 .BI "int " "lines");
149 .TP 15
150 .B "void setCDKSwindowHorizontalChar ("
151 .BI "CDKSWINDOW *" "swindow",
152 .BI "chtype " "character");
153 .TP 15
154 .B "void setCDKSwindowLLChar ("
155 .BI "CDKSWINDOW *" "swindow",
156 .BI "chtype " "character");
157 .TP 15
158 .B "void setCDKSwindowLRChar ("
159 .BI "CDKSWINDOW *" "swindow",
160 .BI "chtype " "character");
161 .TP 15
162 .B "void setCDKSwindowPostProcess ("
163 .BI "CDKSWINDOW *" "swindow",
164 .BI "PROCESSFN " "callback",
165 .BI "void * " "data");
166 .TP 15
167 .B "void setCDKSwindowPreProcess ("
168 .BI "CDKSWINDOW *" "swindow",
169 .BI "PROCESSFN " "callback",
170 .BI "void * " "data");
171 .TP 15
172 .B "void setCDKSwindowULChar ("
173 .BI "CDKSWINDOW *" "swindow",
174 .BI "chtype " "character");
175 .TP 15
176 .B "void setCDKSwindowURChar ("
177 .BI "CDKSWINDOW *" "swindow",
178 .BI "chtype " "character");
179 .TP 15
180 .B "void setCDKSwindowVerticalChar ("
181 .BI "CDKSWINDOW *" "swindow",
182 .BI "chtype " "character");
183 .TP 15
184 .B "void trimCDKSwindow ("
185 .BI "CDKSWINDOW *" "swindow",
186 .BI "int " "start",
187 .BI "int " "finish");
188 .fi
189 .SH DESCRIPTION
190 The Cdk scrolling window (swindow) widget can be used to display messages.
191 The following functions create or manipulate the Cdk swindow box widget.
192 .SH AVAILABLE FUNCTIONS
193 .TP 5
194 .B activateCDKSwindow
195 function activates the swindow widget and lets the user interact with the widget.
196 The parameter \fBswindow\fR is a pointer to a non-NULL swindow widget.
197 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
198 in the array will be injected into the widget.
199 To activate the widget
200 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
201 If the character
202 entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will
203 return 1.
204 It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
205 If the character entered into this widget was \fIESCAPE\fR then the widget will
206 return a value of -1 and the widget data \fIexitType\fR will be set to
207 \fIvESCAPE_HIT\fR.
208 .TP 5
209 .B addCDKSwindow
210 adds information to a scrolling window.
211 The information
212 is supplied by the \fBinfo\fR parameter.
213 The information is immediately added
214 to the scrolling window.
215 The position of the new information is governed by
216 the value of the parameter \fBinsertPosition\fR.
217 This parameter may be
218 two values: \fITOP\fR or \fIBOTTOM\fR.
219 .TP 5
220 .B cleanCDKSwindow
221 clears the information from the window.
222 .TP 5
223 .B destroyCDKSwindow
224 removes the widget from the screen and frees memory the object used.
225 .TP 5
226 .B drawCDKSwindow
227 draws the swindow widget on the screen.
228 If the \fBbox\fR parameter is true, the widget is drawn with a box.
229 .TP 5
230 .B dumpCDKSwindow
231 saves the contents of the scrolling window into the file
232 specified by the \fBfilename\fR parameter.
233 It returns -1 on failure,
234 and the number of lines saved if the dump was successful.
235 .TP 5
236 .B eraseCDKSwindow
237 removes the widget from the screen.
238 This does \fINOT\fR destroy the widget.
239 .TP 5
240 .B execCDKSwindow
241 allows the user to execute a shell command and have the output
242 of the shell command direct itself to the scrolling window.
243 The \fBcommand\fR parameter is the command to execute.
244 The \fBinsertPosition\fR parameter tells where the
245 output will be inserted within the scrolling window.
246 .TP 5
247 .B getCDKSwindowBox
248 returns true if the widget will be drawn with a box around it.
249 .TP 5
250 .B getCDKSwindowContents
251 returns the contents of the scrolling window.
252 The parameter \fBlines\fR will be
253 set to the number of lines returned.
254 .TP 5
255 .B injectCDKSwindow
256 injects a single character into the widget.
257 The parameter \fBswindow\fR is a pointer to a non-NULL swindow widget.
258 The parameter \fBcharacter\fR is the character to inject into the widget.
259 The return value and side-effect (setting the widget data \fIexitType\fP)
260 depend upon the injected character:
261 .RS
262 .TP
263 \fIRETURN\fP or \fITAB\fR
264 the function returns
265 1.
266 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
267 .TP
268 \fIESCAPE\fP
269 the function returns
270 -1.
271 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
272 .TP
273 Otherwise
274 unless modified by preprocessing, postprocessing or key bindings,
275 the function returns
276 -1.
277 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
278 .RE
279 .TP 5
280 .B jumpToLineCDKSwindow
281 moves the scrolling window to the given line.
282 The parameter \fBline\fR may be an integer or one of the two predefined values
283 \fITOP\fR and \fIBOTTOM\fR.
284 .TP 5
285 .B loadCDKSwindowInformation
286 allows the user to load the contents of a file into the scrolling window.
287 This function is interactive, and will ask for a filename.
288 .TP 5
289 .B moveCDKSwindow
290 moves the given widget to the given position.
291 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
292 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
293 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
294 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
295 \fIRIGHT\fR, and \fICENTER\fR.
296 The parameter \fBrelative\fR states whether
297 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
298 For example,
299 if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
300 then the widget would move one row down and two columns right.
301 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
302 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
303 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR
304 (weird things may happen).
305 The final parameter \fBrefresh\fR is a boolean value which
306 states whether the widget will get refreshed after the move.
307 .TP 5
308 .B newCDKSwindow
309 creates a swindow widget and returns a pointer to it.
310 Parameters:
311 .RS
312 .TP 5
313 \fBscreen\fR
314 is the screen you wish this widget to be placed in.
315 .TP 5
316 \fBxpos\fR
317 controls the placement of the object along the horizontal axis.
318 It may be an integer or one of the pre-defined values
319 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
320 .TP 5
321 \fBypos\fR
322 controls the placement of the object along the vertical axis.
323 It may be an integer or one of the pre-defined values
324 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
325 .TP 5
326 \fBheight\fR and
327 .TP 5
328 \fBwidth\fR
329 control the height and width of the widget.
330 If you provide a value of zero for either of the height or the width, the
331 widget will be created with the full width and height of the screen.
332 If you provide
333 a negative value, the widget will be created the full height or width minus the
334 value provided.
335 .TP 5
336 \fBtitle\fR
337 is the string to display at the top of the widget.
338 The title can be more than one line; just provide a carriage
339 return character at the line break.
340 .TP 5
341 \fBsaveLines\fR
342 is the number of lines to save before throwing information away.
343 .TP 5
344 \fBbox\fR
345 is true if the widget should be drawn with a box around it.
346 .TP 5
347 The \fBshadow\fR
348 turns the shadow on or off around this widget.
349 .RE
350 .IP
351 If the widget could not be created then a \fINULL\fR pointer is returned.
352 .TP 5
353 .B positionCDKSwindow
354 allows the user to move the widget around the screen via the
355 cursor/keypad keys.
356 See \fBcdk_position (3)\fR for key bindings.
357 .TP 5
358 .B saveCDKSwindowInformation
359 allows the user to save the contents of the scrolling window into a file.
360 This function is interactive, and will ask for a filename.
361 .TP 5
362 .B setCDKSwindow
363 lets the programmer modify certain elements of an existing
364 swindow widget.
365 The parameter \fBinfo\fR is a \fIchar **\fR of the information
366 to set in the scrolling window; \fBlines\fR is the number of lines being added.
367 The other parameter names correspond to the same parameter names listed in the
368 \fBnewCDKSwindow\fR function.
369 .TP 5
370 .B setCDKSwindowBackgroundAttrib
371 sets the background attribute of the widget.
372 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
373 .TP 5
374 .B setCDKSwindowBackgroundColor
375 sets the background color of the widget.
376 The parameter \fBcolor\fR
377 is in the format of the Cdk format strings.
378 See \fBcdk_display (3)\fR.
379 .TP 5
380 .B setCDKSwindowBox
381 sets whether the widget will be drawn with a box around it.
382 .TP 5
383 .B setCDKSwindowBoxAttribute
384 sets the attribute of the box.
385 .TP 5
386 .B setCDKSwindowContents
387 lets the programmer modify certain elements of an existing swindow widget.
388 The parameter \fBinfo\fR is a \fIchar **\fR of the information
389 to set in the scrolling window; \fBlines\fR is the number of lines being added.
390 .TP 5
391 .B setCDKSwindowHorizontalChar
392 sets the horizontal drawing character for the box to the given character.
393 .TP 5
394 .B setCDKSwindowLLChar
395 sets the lower left hand corner of the widget's box to the given character.
396 .TP 5
397 .B setCDKSwindowLRChar
398 sets the lower right hand corner of the widget's box to the given character.
399 .TP 5
400 .B setCDKSwindowPostProcess
401 allows the user to have the widget call a function after the
402 key has been applied to the widget.
403 The parameter \fBfunction\fR is the callback function.
404 The parameter \fBdata\fR points to data passed to the callback function.
405 To learn more about post-processing see \fIcdk_process (3)\fR.
406 .TP 5
407 .B setCDKSwindowPreProcess
408 allows the user to have the widget call a function after a key
409 is hit and before the key is applied to the widget.
410 The parameter \fBfunction\fR is the callback function.
411 The parameter \fBdata\fR points to data passed to the callback function.
412 To learn more about pre-processing see \fIcdk_process (3)\fR.
413 .TP 5
414 .B setCDKSwindowULChar
415 sets the upper left hand corner of the widget's box to the given character.
416 .TP 5
417 .B setCDKSwindowURChar
418 sets the upper right hand corner of the widget's box to the given character.
419 .TP 5
420 .B setCDKSwindowVerticalChar
421 sets the vertical drawing character for the box to the given character.
422 .TP 5
423 .B trimCDKSwindow
424 removes information from a scrolling window.
425 The parameters \fBstart\fR and \fBend\fR state where to start cutting from and where to stop.
426 The first element in the scrolling window starts at index 0.
427 .SH KEY BINDINGS
428 When the widget is activated there are several default key bindings which will
429 help the user enter or manipulate the information quickly.
430 The following table
431 outlines the keys and their actions for this widget.
432 .LP
433 .TS
434 center tab(/) box;
435 l l
436 lw(15) lw(45) .
437 \fBKey/Action\fR
438 =
439 Left Arrow/Scrolls the window left one column.
440 Right Arrow/Scrolls the window right one column.
441 Up Arrow/Scrolls the window up one row.
442 Down Arrow/Scrolls the window down one row.
443 _
444 Prev Page
445 Ctrl-B
446 b
447 B/Scroll the window backward one page.
448 _
449 Next Page
450 Ctrl-F
451 Space
452 f
453 F/Scroll the window forward one page.
454 _
455 Home
456 |/Scroll the list to the left margin.
457 _
458 End
459 $/Scroll the list to the right margin.
460 _
461 1
462 <
463 g/Move to the top of the scrolling window.
464 >
465 G/Move to the bottom of the scrolling window.
466 _
467 l
468 L/Load a file into the scrolling window.
469 _
470 s
471 S/T{
472 Save the contents of the scrolling window into a file.
473 T}
474 _
475 Return/T{
476 Set the widget's \fIexitType\fR to \fIvNORMAL\fR, exit the widget and return 1.
477 T}
478 Tab/T{
479 Set the widget's \fIexitType\fR to \fIvNORMAL\fR, exit the widget and return 1.
480 T}
481 Escape/T{
482 Set the widget's \fIexitType\fR to \fIvESCAPE_HIT\fR, exit the widget and return -1.
483 T}
484 Ctrl-L/Refreshes the screen.
485 =
486 .TE
487 .SH SEE ALSO
488 .BR cdk (3),
489 .BR cdk_binding (3),
490 .BR cdk_display (3),
491 .BR cdk_position (3),
492 .BR cdk_screen (3)
0 .\" $Id: cdk_template.3,v 1.25 2006/04/15 14:08:31 tom Exp $
1 .de XX
2 ..
3 .TH cdk_template 3
4 .SH NAME
5 .XX activateCDKTemplate
6 .XX cleanCDKTemplate
7 .XX destroyCDKTemplate
8 .XX drawCDKTemplate
9 .XX eraseCDKTemplate
10 .XX getCDKTemplateBox
11 .XX getCDKTemplateMin
12 .XX getCDKTemplateValue
13 .XX injectCDKTemplate
14 .XX mixCDKTemplate
15 .XX newCDKTemplate
16 .XX setCDKTemplate
17 .XX setCDKTemplateBackgroundAttrib
18 .XX setCDKTemplateBackgroundColor
19 .XX setCDKTemplateBox
20 .XX setCDKTemplateBoxAttribute
21 .XX setCDKTemplateCB
22 .XX setCDKTemplateHorizontalChar
23 .XX setCDKTemplateLLChar
24 .XX setCDKTemplateLRChar
25 .XX setCDKTemplateMin
26 .XX setCDKTemplatePostProcess
27 .XX setCDKTemplatePreProcess
28 .XX setCDKTemplateULChar
29 .XX setCDKTemplateURChar
30 .XX setCDKTemplateValue
31 .XX setCDKTemplateVerticalChar
32 .XX unmixCDKTemplate
33 cdk_template \- a curses template widget.
34 .SH SYNOPSIS
35 .LP
36 .B cc
37 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
38 .B \-lcdk
39 .RI "[ " "library" " \|.\|.\|. ]"
40 .LP
41 #include <cdk.h>
42 .nf
43 .TP 15
44 .B "char *activateCDKTemplate ("
45 .BI "CDKTEMPLATE *" "template",
46 .BI "chtype * " "actions");
47 .TP 15
48 .B "void cleanCDKTemplate ("
49 .BI "CDKTEMPLATE *" "template");
50 .TP 15
51 .B "void destroyCDKTemplate ("
52 .BI "CDKTEMPLATE *" "template");
53 .TP 15
54 .B "void drawCDKTemplate ("
55 .BI "CDKTEMPLATE *" "template",
56 .BI "boolean " "box");
57 .TP 15
58 .B "void eraseCDKTemplate ("
59 .BI "CDKTEMPLATE *" "template");
60 .TP 15
61 .B "boolean getCDKTemplateBox ("
62 .BI "CDKTEMPLATE *" "template");
63 .TP 15
64 .B "int getCDKTemplateMin ("
65 .BI "CDKTEMPLATE *" "template");
66 .TP 15
67 .B "char *getCDKTemplateValue ("
68 .BI "CDKTEMPLATE *" "template");
69 .TP 15
70 .B "char *injectCDKTemplate ("
71 .BI "CDKTEMPLATE *" "template",
72 .BI "chtype " "input");
73 .TP 15
74 .B "char *mixCDKTemplate ("
75 .BI "CDKTEMPLATE *" "template");
76 .TP 15
77 .B "void moveCDKTemplate ("
78 .BI "CDKTEMPLATE *" "template",
79 .BI "int " "xpos",
80 .BI "int " "ypos",
81 .BI "boolean " "relative",
82 .BI "boolean " "refresh");
83 .TP 15
84 .B "CDKTEMPLATE *newCDKTemplate ("
85 .BI "CDKSCREEN *" "cdkscreen",
86 .BI "int " "xpos",
87 .BI "int " "ypos",
88 .BI "char *" "title",
89 .BI "char *" "label",
90 .BI "char *" "plate",
91 .BI "char *" "overlay",
92 .BI "boolean " "box",
93 .BI "boolean " "shadow");
94 .TP 15
95 .B "void positionCDKTemplate ("
96 .BI "CDKTEMPLATE *" "template");
97 .TP 15
98 .B "void setCDKTemplate ("
99 .BI "CDKTEMPLATE *" "template",
100 .BI "char *" "value",
101 .BI "boolean " "box");
102 .TP 15
103 .B "void setCDKTemplateBackgroundAttrib ("
104 .BI "CDKTEMPLATE *" "template",
105 .BI "chtype " "attribute");
106 .TP 15
107 .B "void setCDKTemplateBackgroundColor ("
108 .BI "CDKTEMPLATE *" "template",
109 .BI "char * " "color");
110 .TP 15
111 .B "void setCDKTemplateBox ("
112 .BI "CDKTEMPLATE *" "template",
113 .BI "boolean " "box");
114 .TP 15
115 .B "void setCDKTemplateBoxAttribute ("
116 .BI "CDKTEMPLATE *" "template",
117 .BI "chtype " "character");
118 .TP 15
119 .B "void setCDKTemplateCB ("
120 .BI "CDKTEMPLATE *" "template",
121 .BI "TEMPLATECB " "callbackFunction");
122 .TP 15
123 .B "void setCDKTemplateHorizontalChar ("
124 .BI "CDKTEMPLATE *" "template",
125 .BI "chtype " "character");
126 .TP 15
127 .B "void setCDKTemplateLLChar ("
128 .BI "CDKTEMPLATE *" "template",
129 .BI "chtype " "character");
130 .TP 15
131 .B "void setCDKTemplateLRChar ("
132 .BI "CDKTEMPLATE *" "template",
133 .BI "chtype " "character");
134 .TP 15
135 .B "void setCDKTemplateMin ("
136 .BI "CDKTEMPLATE *" "template",
137 .BI "int " "minimum");
138 .TP 15
139 .B "void setCDKTemplatePostProcess ("
140 .BI "CDKTEMPLATE *" "template",
141 .BI "PROCESSFN " "callback",
142 .BI "void * " "data");
143 .TP 15
144 .B "void setCDKTemplatePreProcess ("
145 .BI "CDKTEMPLATE *" "template",
146 .BI "PROCESSFN " "callback",
147 .BI "void * " "data");
148 .TP 15
149 .B "void setCDKTemplateULChar ("
150 .BI "CDKTEMPLATE *" "template",
151 .BI "chtype " "character");
152 .TP 15
153 .B "void setCDKTemplateURChar ("
154 .BI "CDKTEMPLATE *" "template",
155 .BI "chtype " "character");
156 .TP 15
157 .B "void setCDKTemplateValue ("
158 .BI "CDKTEMPLATE *" "template",
159 .BI "char *" "value");
160 .TP 15
161 .B "void setCDKTemplateVerticalChar ("
162 .BI "CDKTEMPLATE *" "template",
163 .BI "chtype " "character");
164 .TP 15
165 .B "char *unmixCDKTemplate ("
166 .BI "CDKTEMPLATE *" "template",
167 .BI "char *" "string");
168 .fi
169 .SH DESCRIPTION
170 The Cdk template widget creates a template widget which allows a user to type
171 information into an entry field with a pre-set field format.
172 Typical uses for
173 this widget would be a date field or a time field.
174 The following are functions
175 which create or manipulate the Cdk template box widget.
176 .SH AVAILABLE FUNCTIONS
177 .TP 5
178 .B activateCDKTemplate
179 activates the template widget and lets the user interact with the widget.
180 The parameter \fBtemplate\fR is a pointer to a non-NULL template widget.
181 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
182 in the array will be injected into the widget.
183 To activate the widget
184 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
185 If the character entered
186 into this widget is \fIRETURN\fR or \fITAB\fR then this function will return
187 a \fIchar\ *\fR representing the information typed into the widget and the
188 widget data \fIexitType\fR will be set to \fIvNORMAL\fR.
189 If the character
190 entered was \fIESCAPE\fR then the function will return \fINULL\fR pointer and
191 the widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
192 .TP 5
193 .B cleanCDKTemplate
194 clears the information from the field.
195 .TP 5
196 .B destroyCDKTemplate
197 removes the widget from the screen and frees any memory the object used.
198 .TP 5
199 .B drawCDKTemplate
200 draws the template widget on the screen.
201 If \fBbox\fR is true,
202 the widget is drawn with a box.
203 .TP 5
204 .B eraseCDKTemplate
205 removes the widget from the screen.
206 This does \fBNOT\fR destroy the widget.
207 .TP 5
208 .B getCDKTemplateBox
209 returns true if the widget will be drawn with a box around it.
210 .TP 5
211 .B getCDKTemplateMin
212 returns the minimum characters that must be entered before the
213 widget will exit.
214 .TP 5
215 .B getCDKTemplateValue
216 returns the current value of the widget.
217 .TP 5
218 .B injectCDKTemplate
219 injects a single character into the widget.
220 The parameter \fBtemplate\fR is a pointer to a non-NULL template widget.
221 The parameter \fBcharacter\fR is the character to inject into the widget.
222 The return value and side-effect (setting the widget data \fIexitType\fP)
223 depend upon the injected character:
224 .RS
225 .TP
226 \fIRETURN\fP or \fITAB\fR
227 the function returns
228 a \fIchar\ *\fR representing the information typed into the widget.
229 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
230 .TP
231 \fIESCAPE\fP
232 the function returns
233 a \fINULL\fR pointer.
234 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
235 .TP
236 Otherwise
237 unless modified by preprocessing, postprocessing or key bindings,
238 the function returns
239 a \fINULL\fR pointer.
240 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
241 .RE
242 .TP 5
243 .B mixCDKTemplate
244 returns a \fIchar*\fR pointer to the field value and the plate.
245 .TP 5
246 .B moveCDKTemplate
247 moves the given widget to the given position.
248 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
249 The parameter \fBxpos\fR is an integer or one of the predefined values
250 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
251 The parameter \fBypos\fR
252 may be an integer or one of the pre-defined values \fILEFT\fR,
253 \fIRIGHT\fR, and \fICENTER\fR.
254 The parameter \fBrelative\fR states whether
255 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
256 For example,
257 if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
258 then the widget would move one row down and two columns right.
259 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
260 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
261 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR
262 (weird things may happen).
263 The final parameter \fBrefresh\fR is a boolean value which
264 states whether the widget will be repainted after the move.
265 .TP 5
266 .B newCDKTemplate
267 creates a template widget, returning a pointer to it.
268 Parameters:
269 .RS
270 .TP 5
271 \fBscreen\fR
272 is the screen you wish this widget to be placed in.
273 .TP 5
274 \fBxpos\fR
275 controls the placement of the object along the horizontal axis.
276 It may be an integer or one of the pre-defined values
277 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
278 .TP 5
279 \fBypos\fR
280 controls the placement of the object along the vertical axis.
281 It may be an integer or one of the pre-defined values
282 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
283 .TP 5
284 \fBtitle\fR
285 is the string to display at the top of the widget.
286 The title can be more than one line; just provide a carriage return
287 character at the line break.
288 .TP 5
289 \fBlabel\fR
290 is the string to display in the label of the template field.
291 .TP 5
292 \fBplate\fR
293 defines the character to allow at each position in the template field.
294 This is done by creating a character plate by using
295 special format character to tell the template widget what type of character
296 is allowed where in the template widget.
297 The following table lists the format types.
298 .LP
299 .TS
300 center tab(/);
301 l
302 l l
303 lw15 lw35 .
304 \fBPlate_Character/Effect\fR
305 =
306 #/Accepts an integer.
307 A/Accepts an alphabetic value.
308 C/T{
309 Accepts an alphabetic value.
310 Automatically converts the character to upper case.
311 T}
312 c/T{
313 Accepts an alphabetic value.
314 Automatically converts the character to lower case.
315 T}
316 M/T{
317 Accepts alphanumeric characters.
318 T}
319 X/T{
320 Accepts alphanumeric characters.
321 Automatically converts the character to upper case.
322 T}
323 x/T{
324 Accepts alphanumeric characters.
325 Automatically converts the character to upper case.
326 T}
327 Anything else/T{
328 Ignored and assumed a non-editable position.
329 T}
330 =
331 .TE
332 .TP 5
333 \fBoverlay\fR
334 is the overlay of the template field.
335 If the field
336 needs some sort of overlay, this parameter supplies this.
337 A date field could
338 have YY/MM/DD, the overlay parameter would display YY/MM/DD on an empty template field.
339 .TP 5
340 \fBbox\fR
341 is true if the widget should be drawn with a box around it.
342 .TP 5
343 \fBshadow\fR
344 turns the shadow on or off around this widget.
345 .RE
346 .IP
347 If the widget could not be created then a \fINULL\fR pointer is returned.
348 .TP 5
349 .B positionCDKTemplate
350 allows the user to move the widget around the screen via the
351 single keystroke commands.
352 See \fBcdk_position (3)\fR for key bindings.
353 .TP 5
354 .B setCDKTemplate
355 lets the programmer modify certain elements of an existing
356 template widget.
357 The parameter names correspond to the same parameter names
358 listed in the \fBnewCDKTemplate\fR function.
359 .TP 5
360 .B setCDKTemplateBackgroundAttrib
361 sets the background attribute of the widget.
362 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
363 .TP 5
364 .B setCDKTemplateBackgroundColor
365 sets the background color of the widget.
366 The parameter \fBcolor\fR
367 is in the format of the Cdk format strings.
368 For more information, see the \fIcdk_display (3)\fR.
369 .TP 5
370 .B setCDKTemplateBox
371 sets a flag, true if the widget will be drawn with a box around it.
372 .TP 5
373 .B setCDKTemplateBoxAttribute
374 sets the attribute of the box.
375 .TP 5
376 .B setCDKTemplateCB
377 allows the programmer to set a different widget input handler.
378 The parameter \fBcallbackFunction\fR is of type \fITEMPLATECB\fR.
379 The default input handler is \fICDKTemplateCallBack\fR.
380 .TP 5
381 .B setCDKTemplateHorizontalChar
382 sets the horizontal drawing character for the box to
383 the given character.
384 .TP 5
385 .B setCDKTemplateLLChar
386 sets the lower left hand corner of the widget's box to
387 the given character.
388 .TP 5
389 .B setCDKTemplateLRChar
390 sets the lower right hand corner of the widget's box to
391 the given character.
392 .TP 5
393 .B setCDKTemplateMin
394 sets the minimum number of characters that must be entered
395 before the widget will exit.
396 .TP 5
397 .B setCDKTemplatePostProcess
398 allows the user to have the widget call a function after the
399 key has been applied to the widget.
400 To learn more about post-processing see \fIcdk_process\fR (3).
401 .TP 5
402 .B setCDKTemplatePreProcess
403 allows the user to have the widget call a function after a key
404 is hit and before the key is applied to the widget.
405 To learn more about preprocessing see \fIcdk_process\fR (3).
406 .TP 5
407 .B setCDKTemplateULChar
408 sets the upper left hand corner of the widget's box to
409 the given character.
410 .TP 5
411 .B setCDKTemplateURChar
412 sets the upper right hand corner of the widget's box to
413 the given character.
414 .TP 5
415 .B setCDKTemplateValue
416 sets a value in the widget.
417 .TP 5
418 .B setCDKTemplateVerticalChar
419 sets the vertical drawing character for the box to
420 the given character.
421 .TP 5
422 .B unmixCDKTemplate
423 returns a \fIchar*\fR pointer to the field value without any
424 plate characters.
425 .SH KEY BINDINGS
426 When the widget is activated there are several default key bindings which will
427 help the user enter or manipulate the information quickly.
428 The following table
429 outlines the keys and their actions for this widget.
430 .TS
431 center tab(/) allbox;
432 l l
433 l l
434 lw15 lw35 .
435 \fBKey/Action\fR
436 =
437 Delete/T{
438 Deletes the character at the cursor.
439 T}
440 Backspace/T{
441 Deletes the character before cursor, moves cursor left.
442 T}
443 Ctrl-P/T{
444 Pastes whatever is in the paste buffer, into the widget.
445 T}
446 Ctrl-K/T{
447 Cuts the contents from the widget and saves a copy in the paste buffer.
448 T}
449 Ctrl-T/T{
450 Copies the contents of the widget into the paste buffer.
451 T}
452 Ctrl-E/T{
453 Erases the contents of the widget.
454 T}
455 Return/T{
456 Exits the widget and returns a \fIchar*\fR representing the information which was typed into the field.
457 It also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
458 T}
459 Tab/T{
460 Exits the widget and returns a \fIchar*\fR representing the information which was typed into the field.
461 It also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
462 T}
463 Escape/T{
464 Exits the widget and returns a \fINULL\fR pointer.
465 It also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
466 T}
467 Ctrl-L/Refreshes the screen.
468 .TE
469 .SH SEE ALSO
470 .BR cdk (3),
471 .BR cdk_binding (3),
472 .BR cdk_display (3),
473 .BR cdk_screen (3)
0 .\" $Id: cdk_traverse.3,v 1.7 2005/12/30 01:47:25 tom Exp $
1 .de XX
2 ..
3 .TH cdk_traverse 3
4 .SH NAME
5 .XX exitCancelCDKScreen
6 .XX exitCancelCDKScreenOf
7 .XX exitOKCDKScreen
8 .XX exitOKCDKScreenOf
9 .XX getCDKFocusCurrent
10 .XX resetCDKScreen
11 .XX resetCDKScreenOf
12 .XX setCDKFocusCurrent
13 .XX setCDKFocusFirst
14 .XX setCDKFocusLast
15 .XX setCDKFocusNext
16 .XX setCDKFocusPrevious
17 .XX traverseCDKOnce
18 .XX traverseCDKScreen
19 cdk_traverse - functions to support keyboard traversal
20 .SH SYNOPSIS
21 .LP
22 .B cc
23 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
24 .B \-lcdk
25 .RI "[ " "library" " \|.\|.\|. ]"
26 .LP
27 .nf
28 #include <cdk.h>
29 .LP
30 .BI "CDKOBJS *getCDKFocusCurrent (CDKSCREEN *" "screen");
31 .LP
32 .BI "CDKOBJS *setCDKFocusCurrent (CDKSCREEN *" "screen\fB, CDKOBJS *\fPobj");
33 .LP
34 .BI "CDKOBJS *setCDKFocusFirst (CDKSCREEN *" "screen");
35 .LP
36 .BI "CDKOBJS *setCDKFocusLast (CDKSCREEN *" "screen");
37 .LP
38 .BI "CDKOBJS *setCDKFocusNext (CDKSCREEN *" "screen");
39 .LP
40 .BI "CDKOBJS *setCDKFocusPrevious (CDKSCREEN *" "screen");
41 .LP
42 .BI "int traverseCDKScreen (CDKSCREEN *" "screen");
43 .LP
44 .BI "void exitOKCDKScreen (CDKSCREEN *" "screen");
45 .LP
46 .BI "void exitCancelCDKScreen (CDKSCREEN *" "screen");
47 .LP
48 .BI "void resetCDKScreen (CDKSCREEN *" "screen");
49 .LP
50 .BI "void exitOKCDKScreenOf(CDKOBJS *" "obj");
51 .LP
52 .BI "void exitCancelCDKScreenOf (CDKOBJS *" "obj");
53 .LP
54 .BI "void resetCDKScreenOf (CDKOBJS *" "obj");
55 .TP 15
56 .BI "void traverseCDKOnce ("
57 .BI "CDKSCREEN *\fIscreen\fP,"
58 .BI "CDKOBJS *\fIcurobj\fP,"
59 .BI "int \fIkeyCode\fP,"
60 .BI "boolean \fIfunctionKey\fP,"
61 .BI "CHECK_KEYCODE \fIfuncMenuKey\fP);
62 .fi
63 .
64 .SH DESCRIPTION
65 The functions above handle the traversal of a screen populated with various
66 widgets.
67 Once the screen has been created and populated with widgets, a
68 single call to \fBtraverseCDKScreen()\fP will allow the user to move between
69 widgets and enter data (or otherwise manipulate widgets).
70 Other functions are provided for use as callbacks by the widgets on
71 the screen.
72 Finally, there are several functions which allow the caller to manipulate
73 the state of the traversal, i.e., the object which has focus.
74 .LP
75 In order for widgets to be used on a screen which is to be handled by
76 \fBtraverseCDKScreen()\fP, it must have the following methods available:
77 .nf
78 .ft C
79 injectCharObj
80 inputWindowObj
81 focusObj
82 unfocusObj
83 saveDataObj
84 refreshDataObj
85 .ft R
86 .fi
87 .LP
88 In addition, the following object properties must be properly handled:
89 .nf
90 .ft C
91 acceptsFocus
92 hasFocus
93 inputWindow
94 dataPtr
95 dataType
96 .ft R
97 .fi
98 .LP
99 At the time of this writing, not all widgets have been modified to work with
100 the screen-traversal facility.
101 .SH AVAILABLE FUNCTIONS
102 .B int traverseCDKScreen (CDKSCREEN *\fIscreen\fP);
103 .RS 3
104 This function contains the main screen traversal engine.
105 It does the following:
106 .TP 4
107 1.
108 Calls the refreshData method on each of the widgets to tell them to
109 update their appearance to match the data which are referenced by their
110 respective data pointers.
111 .TP 4
112 2.
113 Calls the focusObject method on the first widget.
114 .TP 4
115 3.
116 Repeats the following until one of the exit functions listed above has been
117 called:
118 .RS 4
119 .TP 3
120 *
121 Read a keystroke from the keyboard.
122 .TP 3
123 *
124 If the keystroke is ESCAPE and a menu widget is present, activate the
125 menu and traverse it until the user selects an entry or hits TAB.
126 .TP 3
127 *
128 If the keystroke is TAB/BACKTAB then call the unfocusObject method on the
129 current widget, and move focus to the next/previous widget (not counting
130 menu widgets).
131 Call the focusObject method on the newly current widget.
132 .TP 3
133 *
134 If the keystroke is the EXIT-SAVE keystroke, then call the saveData method
135 on each widget and return 1.
136 .TP 3
137 *
138 If the keystroke is the EXIT-CANCEL keystroke, return 0 without saving
139 changes made by the user.
140 .TP 3
141 *
142 If the keystroke is the RESET-DATA keystroke, then call the refreshData
143 method on each of the widgets to reset their appearance to match the data
144 values that were present upon entry.
145 .TP 3
146 *
147 Otherwise, pass the keystroke to the current widget.
148 .RE
149 .RE
150 .TP 5
151 .B CDKOBJS *getCDKFocusCurrent (CDKSCREEN *\fIscreen\fP);
152 Return a pointer to the object which currently has focus in the given screen.
153 .TP 5
154 .B CDKOBJS *setCDKFocusCurrent (CDKSCREEN *\fIscreen\fP, CDKOBJS *\fIobj\fP);
155 Set the focus to the given object, if the screen contains that object.
156 If the screen does not contain the object, return null.
157 Otherwise, return the object.
158 .TP 5
159 .B CDKOBJS *setCDKFocusFirst (CDKSCREEN *\fIscreen\fP);
160 Set focus on the first object in the given screen.
161 .TP 5
162 .B CDKOBJS *setCDKFocusLast (CDKSCREEN *\fIscreen\fP);
163 Set focus on the last object in the given screen.
164 .TP 5
165 .B CDKOBJS *setCDKFocusNext (CDKSCREEN *\fIscreen\fP);
166 Set focus on the next object in the given screen.
167 .TP 5
168 .B CDKOBJS *setCDKFocusPrevious (CDKSCREEN *\fIscreen\fP);
169 Set focus on the previous object in the given screen.
170 .TP 5
171 .B exitOKCDKScreen
172 .RS 3
173 Causes the traversal engine to exit after calling the saveData
174 method for each of the widgets.
175 .RE
176 .TP 5
177 .B exitOKCDKScreenOf
178 .RS 3
179 Calls \fBexitOKCDKScreen()\fP on the screen associated with widget
180 \fIobj\fP.
181 This function was designed to be used as a callback routine
182 for a button widget used as an OK button on a data-entry screen.
183 .RE
184 .TP 5
185 .B exitCancelCDKScreen
186 .RS 3
187 Causes the traversal engine to exit without saving
188 user modified data.
189 .RE
190 .TP 5
191 .B exitCancelCDKScreenOf
192 .RS 3
193 Calls \fBexitCancelCDKScreen()\fP on the screen associated with widget
194 \fIobj\fP.
195 This function was designed to be used as a callback routine
196 for a button widget used as a Cancel button on a data-entry screen.
197 .RE
198 .TP 5
199 .B resetCDKScreen
200 .RS 3
201 Causes the traversal engine to call the refreshData method for each widget.
202 This will cause any unsaved changes to be discarded
203 and the widget states will be restored to their initial values.
204 .RE
205 .TP 5
206 .B resetCDKScreenOf
207 .RS 3
208 Calls \fBresetCDKScreen()\fP on the screen associated with widget \fIobj\fP.
209 This function was designed to be used as a callback routine
210 for a button widget used as a Reset button on a data-entry screen.
211 .RE
212 .TP 5
213 .B traverseCDKOnce
214 .RS 3
215 This is a utility function, one of the pieces from which you can
216 construct a customized version of \fBtraverseCDKScreen\fP.
217 .RE
218 .SH BUGS
219 Not all widgets have had the extra methods added so that they work with
220 the screen traversal engine.
221 .SH AUTHOR
222 Grant Edwards, Aspen Research Corporation
223 .br
224 Thomas Dickey and contributors.
225 .SH SEE ALSO
226 .BR cdk (3),
227 .BR cdk_binding (3),
228 .BR cdk_display (3),
229 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: cdk_util.3,v 1.6 2005/12/28 18:35:31 tom Exp $
2 .de XX
3 ..
4 .TH cdk_util 3
5 .SH NAME
6 .XX CDKgetDirectoryContents
7 .XX CDKreadFile
8 .XX alignxy
9 .XX char2Chtype
10 .XX char2DisplayType
11 .XX checkForLink
12 .XX chtype2String
13 .XX deleteCursesWindow
14 .XX eraseCursesWindow
15 .XX getListIndex
16 .XX getString
17 .XX justifyString
18 .XX mode2Filetype
19 .XX moveCursesWindow
20 .XX popupDialog
21 .XX popupLabel
22 .XX popupLabelAttrib
23 .XX selectFile
24 .XX setWidgetDimension
25 .XX stripWhiteSpace
26 .XX viewFile
27 .XX viewInfo
28 cdk_util \- Cdk utility functions
29 .SH SYNOPSIS
30 .LP
31 .B cc
32 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
33 .B \-lcdk
34 .RI "[ " "library" " \|.\|.\|. ]"
35 .LP
36 #include <cdk.h>
37 .nf
38 .TP 15
39 .B "int CDKgetDirectoryContents ("
40 .BI "char *" "directory",
41 .BI "char ***" "list");
42 .TP 15
43 .B "int CDKreadFile ("
44 .BI "char *" "filename",
45 .BI "char ***" "info");
46 .TP 15
47 .B "void alignxy ("
48 .BI "WINDOW *" "window",
49 .BI "int *" "xpos",
50 .BI "int *" "ypos",
51 .BI "int " "boxWidth",
52 .BI "int " "boxHeight");
53 .TP 15
54 .B "chtype *char2Chtype ("
55 .BI "char *" "string",
56 .BI "int *" "length",
57 .BI "int *" "align");
58 .TP 15
59 .B "EDisplayType char2DisplayType ("
60 .BI "char *" "string");
61 .TP 15
62 .B "int checkForLink ("
63 .BI "char *" "line",
64 .BI "char *" "filename");
65 .TP 15
66 .B "char *chtype2String (
67 .BI "chtype *" "string");
68 .TP 15
69 .B "void deleteCursesWindow ("
70 .BI "WINDOW *" "window");
71 .TP 15
72 .B "void eraseCursesWindow ("
73 .BI "WINDOW *" "window");
74 .TP 15
75 .B "int getListIndex ("
76 .BI "CDKSCREEN *" "screen",
77 .BI "char *" "title",
78 .BI "char **" "list",
79 .BI "int " "listSize",
80 .BI "boolean " "numbers");
81 .TP 15
82 .B char *getString ("
83 .BI "CDKSCREEN *" "screen",
84 .BI "char *" "title",
85 .BI "char *" "label",
86 .BI "char *" "init");
87 .TP 15
88 .B "int justifyString ("
89 .BI "int " "fieldWidth",
90 .BI "int " "mesglen",
91 .BI "int " "justify");
92 .TP 15
93 .B "int mode2Filetype ("
94 .BI "mode_t " "fileMode");
95 .TP 15
96 .B "void moveCursesWindow ("
97 .BI "WINDOW *" "window",
98 .BI "int " "xdiff",
99 .BI "int " "ydiff");
100 .TP 15
101 .B "int popupDialog ("
102 .BI "CDKSCREEN *" "screen",
103 .BI "char **" "mesg",
104 .BI "int " "mesgCount",
105 .BI "char **" "buttons",
106 .BI "int " "buttonCount");
107 .TP 15
108 .B "void popupLabel ("
109 .BI "CDKSCREEN *" "win",
110 .BI "char **" "mesg",
111 .BI "int " "count");
112 .TP 15
113 .B "void popupLabelAttrib ("
114 .BI "CDKSCREEN *" "win",
115 .BI "char **" "mesg",
116 .BI "int " "count",
117 .BI "chtype " "attribute");
118 .TP 15
119 .B "char *selectFile ("
120 .BI "CDKSCREEN *" "screen",
121 .BI "char *" "title");
122 .TP 15
123 .B "int setWidgetDimension ("
124 .BI "int " "parentDim",
125 .BI "int " "proposedDim",
126 .BI "int " "adjustment");
127 .TP 15
128 .B "void stripWhiteSpace ("
129 .BI "EStripType " "stripType",
130 .BI "char *" "string");
131 .TP 15
132 .B "int viewFile ("
133 .BI "CDKSCREEN *" "screen",
134 .BI "char *" "title",
135 .BI "char *" "filename",
136 .BI "char **" "buttons",
137 .BI "int " "buttonCount");
138 .TP 15
139 .B "int viewInfo ("
140 .BI "CDKSCREEN *" "screen",
141 .BI "char *" "title",
142 .BI "char **" "info",
143 .BI "int " "size",
144 .BI "char **" "buttons",
145 .BI "int " "buttonCount",
146 .BI "boolean " "interpret");
147 .fi
148 .SH DESCRIPTION
149 These are utility functions that one may use to initialize,
150 build or customize widgets.
151 .
152 .SH AVAILABLE FUNCTIONS
153 .TP 5
154 .B CDKgetDirectoryContents
155 opens and reads the contents of the given directory, filling
156 the array \fBlist\fR with the sorted contents of the directory.
157 If the directory cannot be opened then it returns a value of -1.
158 .TP 5
159 .B CDKreadFile
160 Read the file \fIfilename\fP,
161 load the contents into a dynamically allocated array,
162 storing its address via \fIinfo\fP.
163 It returns the number of lines
164 read if the file could be opened, -1 otherwise.
165 .TP 5
166 .B alignxy
167 Aligns a box on the given \fIwindow\fP with the height and width given.
168 See cdk_position (3) for the interpretation of the
169 \fIxpos\fP,
170 \fIypos\fP,
171 \fIboxWidth\fP and
172 \fIboxHeight\fP,
173 parameters.
174 .TP 5
175 .B char2Chtype
176 Translate a character \fIstring\fP with embedded format markers
177 (e.g., "</X/Y>Blah Blah")
178 to a null-terminated array of chtype's.
179 The length of the array is stored via the \fIlength\fP parameter.
180 The \fBalign\fR parameter contains justification information
181 (LEFT, CENTER, RIGHT).
182 The caller is responsible for freeing the result.
183 .TP 5
184 .B char2DisplayType
185 Lookup the given name in \fIstring\fP and return the equivalent display type.
186 See also cdk_display (3).
187 .TP 5
188 .B checkForLink
189 Check if the given \fIline\fP is of the form
190 .RS
191 <F=\fIfilename\fP>
192 .RE
193 .IP
194 If so, extract the filename from the line, storing it in the \fIfilename\fP
195 buffer (which must hold at least CDK_PATHMAX characters).
196 Return nonzero if a filename is extracted.
197 .TP 5
198 .B chtype2String
199 Extract the characters and formatting information
200 from a null-terminated array of chtype's \fIstring\fP.
201 A dynamically allocated string is returned.
202 .TP 5
203 .B deleteCursesWindow
204 Safely delete a given window,
205 i.e., first check if the \fIwindow\fP parameter is nonnull.
206 .TP 5
207 .B eraseCursesWindow
208 Safely erase a given window,
209 i.e., first check if the \fIwindow\fP parameter is nonnull.
210 .TP 5
211 .B getListIndex
212 Display a scrollable list of strings in a dialog,
213 allow the user to select one.
214 Return the index in the list of the value selected.
215 The \fIlist\fP parameter contains the strings to display;
216 there are \fIlistSize\fP strings in the list.
217 If \fInumbers\fP is true, the displayed list items will be numbered.
218 .TP 5
219 .B getString
220 pops up an entry widget with a title supplied by the value
221 of the \fBtitle\fR parameter, a label supplied by the \fBlabel\fR parameter,
222 and an initial value supplied by the \fBinitialValue\fR parameter.
223 It returns
224 a pointer to the value typed in or NULL if the widget was exited early.
225 .TP 5
226 .B justifyString
227 Given a string length \fImesglen\fP,
228 the available field width \fIfieldWidth\fP
229 and a justification type \fIjustify\fP,
230 return the number of characters by which to shift the string.
231 .TP 5
232 .B mode2Filetype
233 Given a file protection mode \fIfileMode\fP,
234 return ignoring the file-type bits,
235 i.e., ignoring the corresponding permissions data.
236 .TP 5
237 .B moveCursesWindow
238 Move a given \fIwindow\fP by the amounts in \fIxdiff\fP and \fIydiff\fP.
239 .TP 5
240 .B popupDialog
241 creates a quick pop-up dialog box.
242 Pass in the message in the
243 \fBmesg\fR parameter, the size of the message in the \fBmesgCount\fR parameter,
244 the button labels in the \fBbuttons\fR parameter and the number of buttons in
245 the \fBbuttonCount\fR parameter.
246 The dialog box will be centered on the screen.
247 .TP 5
248 .B popupLabel
249 creates a quick pop-up label widget.
250 The message and the size of
251 the message are passed in via the \fBmesg\fR and \fBcount\fR parameters respectively.
252 The label widget waits until the user hits a character and is centered
253 on the screen.
254 .TP 5
255 .B popupLabelAttrib
256 Display a simple dialog with
257 a list of \fIcount\fP message strings \fImesg\fP.
258 Use the given \fIattribute\fP for the background of the dialog.
259 .TP 5
260 .B selectFile
261 Display a file-selection dialog.
262 Return the selected filename, or null if none is selected.
263 The caller should free the return-value.
264 .TP 5
265 .B setWidgetDimension
266 This is a helper function used to set the height/width of a widget:
267 .RS
268 .TP 3
269 -
270 If the proposed dimension \fIproposedDim\fP is FULL or zero,
271 the return value will be \fIparentDim\fP.
272 .TP 3
273 -
274 If the proposed dimension \fIproposedDim\fP is positive,
275 .RS
276 .TP 3
277 -
278 and it is larger than \fIparentDim\fP, return \fIproposedDim\fP,
279 .TP 3
280 -
281 otherwise return \fIproposedDim\fP plus \fIadjustment\fP.
282 .RE
283 .TP 3
284 -
285 If the proposed dimension \fIproposedDim\fP is negative,
286 the return value will be \fIparentDim\fP plus \fIproposedDim\fP.
287 .TP 3
288 -
289 Otherwise, the return value will be \fIproposedDim\fP.
290 .RE
291 .TP 5
292 .B stripWhiteSpace
293 Strip whitespace from the front and/or back of the given \fIstring\fP.
294 The \fIstripType\fP parameter controls the type of stripping done:
295 vFRONT, vBACK or vBOTH.
296 .TP 5
297 .B viewFile
298 Read the file specified by \fIfilename\fP and display it in a CDKVIEWER window.
299 The \fItitle\fP, \fIbuttons\fP and \fIbuttonCount\fP are applied to the
300 CDKVIEWER window.
301 The viewer shows
302 the contents of the file supplied by the \fBfilename\fR value.
303 The buttons on
304 the file viewer are supplied by the \fBbuttons\fR parameter.
305 It returns the index of the button selected,
306 or -1 if the file does not exist or if the widget was exited early.
307 .LP
308 .TS
309 center tab(/) allbox;
310 l l
311 l l
312 lw15 lw35 .
313 \fBStrip_Type/Result\fR
314 =
315 vFRONT/T{
316 This tells the function to remove
317 all of the white space from the
318 front of the given string.
319 T}
320 vBACK/T{
321 This tells the function to remove
322 all of the white space from the
323 back of the given string.
324 T}
325 vBOTH/T{
326 This tells the function to remove
327 all of the white space from both
328 the front and the back of the given string.
329 T}
330 .TE
331 .TP 5
332 .B viewInfo
333 Display the list of strings in \fIinfo\fP in a CDKVIEWER window.
334 The number of strings is given by \fIsize\fP.
335 The \fItitle\fP, \fIbuttons\fP and \fIbuttonCount\fP are applied to the
336 CDKVIEWER window.
337 .
338 .SH SEE ALSO
339 cdk_dialog (3),
340 cdk_display (3),
341 cdk_position (3),
342 cdk_misc (3).
0 '\" t
1 .\" $Id: cdk_viewer.3,v 1.25 2005/12/29 01:31:04 tom Exp $
2 .de XX
3 ..
4 .TH cdk_viewer 3
5 .SH NAME
6 .XX activateCDKViewer
7 .XX cleanCDKViewer
8 .XX destroyCDKViewer
9 .XX drawCDKViewer
10 .XX eraseCDKViewer
11 .XX getCDKViewerBox
12 .XX getCDKViewerHighlight
13 .XX getCDKViewerInfo
14 .XX getCDKViewerInfoLine
15 .XX getCDKViewerTitle
16 .XX moveCDKViewer
17 .XX newCDKViewer
18 .XX positionCDKViewer
19 .XX setCDKViewer
20 .XX setCDKViewerBackgroundAttrib
21 .XX setCDKViewerBackgroundColor
22 .XX setCDKViewerBox
23 .XX setCDKViewerBoxAttribute
24 .XX setCDKViewerHighlight
25 .XX setCDKViewerHorizontalChar
26 .XX setCDKViewerInfo
27 .XX setCDKViewerInfoLine
28 .XX setCDKViewerLLChar
29 .XX setCDKViewerLRChar
30 .XX setCDKViewerTitle
31 .XX setCDKViewerULChar
32 .XX setCDKViewerURChar
33 .XX setCDKViewerVerticalChar
34 cdk_viewer \- curses viewer list widget.
35 .SH SYNOPSIS
36 .LP
37 .B cc
38 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
39 .B \-lcdk
40 .RI "[ " "library" " \|.\|.\|. ]"
41 .LP
42 #include <cdk.h>
43 .nf
44 .TP 15
45 .B "int activateCDKViewer ("
46 .BI "CDKVIEWER *" "viewer");
47 .TP 15
48 .B "void cleanCDKViewer ("
49 .BI "CDKVIEWER *" "viewer");
50 .TP 15
51 .B "void destroyCDKViewer ("
52 .BI "CDKVIEWER *" "viewer");
53 .TP 15
54 .B "void drawCDKViewer ("
55 .BI "CDKVIEWER *" "viewer",
56 .BI "boolean " "box");
57 .TP 15
58 .B "void eraseCDKViewer ("
59 .BI "CDKVIEWER *" "viewer");
60 .TP 15
61 .B "boolean getCDKViewerBox ("
62 .BI "CDKVIEWER *" "viewer");
63 .TP 15
64 .B "chtype getCDKViewerHighlight ("
65 .BI "CDKVIEWER *" "viewer");
66 .TP 15
67 .B "chtype **getCDKViewerInfo ("
68 .BI "CDKVIEWER *" "viewer",
69 .BI "char **" "itemList");
70 .TP 15
71 .B "boolean getCDKViewerInfoLine ("
72 .BI "CDKVIEWER *" "viewer");
73 .TP 15
74 .B "chtype **getCDKViewerTitle ("
75 .BI "CDKVIEWER *" "viewer");
76 .TP 15
77 .B "void moveCDKViewer ("
78 .BI "CDKVIEWEE *" "viewer",
79 .BI "int " "box",
80 .BI "int " "box",
81 .BI "boolean " "relative",
82 .BI "boolean " "refresh");
83 .TP 15
84 .B "CDKVIEWER *newCDKViewer ("
85 .BI "CDKSCREEN *" "cdkscreen",
86 .BI "int " "xpos",
87 .BI "int " "ypos",
88 .BI "int " "height",
89 .BI "int " "width",
90 .BI "char **" "buttonList",
91 .BI "int " "buttonCount",
92 .BI "chtype " "buttonHighlight",
93 .BI "boolean " "box",
94 .BI "boolean " "shadow");
95 .TP 15
96 .B "void positionCDKViewer ("
97 .BI "CDKVIEWER *" "viewer");
98 .TP 15
99 .B "void setCDKViewer ("
100 .BI "CDKVIEWER *" "viewer",
101 .BI "char *" "title",
102 .BI "char **" "list",
103 .BI "int " "listSize",
104 .BI "chtype " "buttonAttribute",
105 .BI "boolean " "interpret",
106 .BI "boolean " "showLineInfo",
107 .BI "boolean " "box");
108 .TP 15
109 .B "void setCDKViewerBackgroundAttrib ("
110 .BI "CDKVIEWER *" "viewer",
111 .BI "chtype " "attribute");
112 .TP 15
113 .B "void setCDKViewerBackgroundColor ("
114 .BI "CDKVIEWER *" "viewer",
115 .BI "char * " "color");
116 .TP 15
117 .B "void setCDKViewerBox ("
118 .BI "CDKVIEWER *" "viewer",
119 .BI "boolean " "Box");
120 .TP 15
121 .B "void setCDKViewerBoxAttribute ("
122 .BI "CDKVIEWER *" "viewer",
123 .BI "chtype " "character");
124 .TP 15
125 .B "void setCDKViewerHighlight ("
126 .BI "CDKVIEWER *" "viewer",
127 .BI "chtype " "highlight");
128 .TP 15
129 .B "void setCDKViewerHorizontalChar ("
130 .BI "CDKVIEWER *" "viewer",
131 .BI "chtype " "character");
132 .TP 15
133 .B "void setCDKViewerInfo ("
134 .BI "CDKVIEWER *" "viewer",
135 .BI "char **" "list",
136 .BI "int " "listSize",
137 .BI "boolean " "interpret");
138 .TP 15
139 .B "void setCDKViewerTitle ("
140 .BI "CDKVIEWER *" "viewer",
141 .BI "char *" "title");
142 .TP 15
143 .B "void setCDKViewerInfoLine ("
144 .BI "CDKVIEWER *" "viewer",
145 .BI "boolean " "showInfoLine");
146 .TP 15
147 .B "void setCDKViewerLLChar ("
148 .BI "CDKVIEWER *" "viewer",
149 .BI "chtype " "character");
150 .TP 15
151 .B "void setCDKViewerLRChar ("
152 .BI "CDKVIEWER *" "viewer",
153 .BI "chtype " "character");
154 .TP 15
155 .B "void setCDKViewerTitle ("
156 .BI "CDKVIEWER *" "viewer",
157 .BI "char *" "title");
158 .TP 15
159 .B "void setCDKViewerULChar ("
160 .BI "CDKVIEWER *" "viewer",
161 .BI "chtype " "character");
162 .TP 15
163 .B "void setCDKViewerURChar ("
164 .BI "CDKVIEWER *" "viewer",
165 .BI "chtype " "character");
166 .TP 15
167 .B "void setCDKViewerVerticalChar ("
168 .BI "CDKVIEWER *" "viewer",
169 .BI "chtype " "character");
170 .fi
171 .SH DESCRIPTION
172 The Cdk viewer widget creates a file viewer widget.
173 This widget allows a user
174 to interact with a file.
175 It does \fINOT\fR allow editing, this is view only.
176 The following are functions which create or manipulate the Cdk viewer list widget.
177 .SH AVAILABLE FUNCTIONS
178 .TP 5
179 .B activateCDKViewer
180 activates the viewer widget and lets the user interact with the widget.
181 The parameter \fBviewer\fR is a pointer to a non-NULL viewer widget.
182 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
183 in the array will be injected into the widget.
184 To activate the widget
185 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
186 If the character entered
187 into this widget is \fIRETURN\fR then this function will return a value from
188 0 to the number of buttons -1, representing the button selected.
189 It will also
190 set the widget data \fIexitType\fR to \fIvNORMAL\fR.
191 If the character
192 entered into this widget was \fIESCAPE\fR then the widget will return
193 a value of -1 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR.
194 .TP 5
195 .B cleanCDKViewer
196 clears the information from the window.
197 .TP 5
198 .B destroyCDKViewer
199 removes the widget from the screen and frees memory the object used.
200 .TP 5
201 .B drawCDKViewer
202 draws the viewer widget on the screen.
203 If the \fBbox\fR option is true, the widget is drawn with a box.
204 .TP 5
205 .B eraseCDKViewer
206 removes the widget from the screen.
207 This does \fINOT\fR destroy the widget.
208 .TP 5
209 .B getCDKViewerBox
210 returns true if the widget will be drawn with a box around it.
211 .TP 5
212 .B getCDKViewerHighlight
213 returns the attribute of the buttons.
214 .TP 5
215 .B getCDKViewerInfo
216 returns the contents of the viewer widget.
217 .TP 5
218 .B getCDKViewerInfoLine
219 returns true if the information line is on.
220 .TP 5
221 .B getCDKViewerTitle
222 returns the title of the widget.
223 .TP 5
224 .B moveCDKViewer
225 function moves the given widget to the given position.
226 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
227 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
228 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
229 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
230 \fIRIGHT\fR, and \fICENTER\fR.
231 The parameter \fBrelative\fR states whether
232 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
233 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
234 then the widget would move one row down and two columns right.
235 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
236 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
237 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
238 (weird things may happen).
239 The final parameter \fBrefresh\fR is a boolean value which
240 states whether the widget will get refreshed after the move.
241 .TP 5
242 .B *newCDKViewer
243 function creates a viewer widget and returns a pointer to it.
244 Parameters:
245 .RS
246 .TP 5
247 \fBscreen\fR
248 is the screen you wish this widget to be placed in.
249 .TP 5
250 \fBxpos\fR
251 controls the placement of the object along the horizontal axis.
252 It may be an integer or one of the pre-defined values
253 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
254 .TP 5
255 \fBypos\fR
256 controls the placement of the object along the vertical axis.
257 It may be an integer or one of the pre-defined values
258 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
259 .TP 5
260 \fBheight\fR and
261 .TP 5
262 \fBwidth\fR
263 are the height and width of the viewer window.
264 .TP 5
265 \fBbuttons\fR
266 is an array of the button labels which are
267 to be attached to the viewer on the bottom.
268 .TP 5
269 \fBbuttonCount\fR
270 is the number of buttons in \fBbuttons\fP.
271 .TP 5
272 \fBbuttonHighlight\fR
273 is the highlight attribute of the currently selected button.
274 .TP 5
275 \fBbox\fR
276 is true if the widget should be drawn with a box around it.
277 .TP 5
278 \fBshadow\fR
279 turns the shadow on or off around this widget.
280 .RE
281 .IP
282 If the widget could not be created then a \fINULL\fR pointer is returned.
283 .TP 5
284 .B positionCDKViewer
285 allows the user to move the widget around the screen via the cursor/keypad keys.
286 See \fBcdk_position (3)\fR for key bindings.
287 .TP 5
288 .B setCDKViewer
289 lets the programmer modify several elements of an existing
290 viewer widget.
291 The parameter \fBtitle\fR is the title to be displayed on
292 the top of the viewer.
293 .IP
294 The parameter \fBlist\fR is the information to display,
295 while \fBlistSize\fR states how many rows there are in the \fBlist\fR array.
296 If \fBlistSize\fR is negative, \fBlist\fR is scanned to find its
297 length, including files which will be included via embedded links.
298 .IP
299 The parameter \fBbuttonAttribute\fR states the attribute of the current
300 highlighted button.
301 The boolean parameter \fBinterpret\fR tells the viewer to
302 interpret the contents of \fBlist\fR for Cdk display command.
303 The \fBshowLineInfo\fR boolean flag tells the viewer to show to show the
304 line number and percentage in the top left corner of the viewer window.
305 The parameters \fBbox\fR and \fBshadow\fR are the same as in the function
306 description of \fBnewCDKViewer\fR.
307 .TP 5
308 .B setCDKViewerBackgroundAttrib
309 sets the background attribute of the widget.
310 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
311 .TP 5
312 .B setCDKViewerBackgroundColor
313 sets the background color of the widget.
314 The parameter \fBcolor\fR
315 is in the format of the Cdk format strings.
316 See \fBcdk_display (3)\fR.
317 .TP 5
318 .B setCDKViewerBox
319 sets whether the widget will be drawn with a box around it.
320 .TP 5
321 .B setCDKViewerBoxAttribute
322 sets the attribute of the box.
323 .TP 5
324 .B setCDKViewerHighlight
325 sets the highlight attribute of the buttons on the widget.
326 .TP 5
327 .B setCDKViewerHorizontalChar
328 sets the horizontal drawing character for the box to
329 the given character.
330 .TP 5
331 .B setCDKViewerInfo
332 sets the contents of the viewer widget.
333 See \fBsetCDKViewer\fP for parameter descriptions.
334 .TP 5
335 .B setCDKViewerInfoLine
336 turns on/off the information line in the top left hand corner of
337 the widget.
338 If the value of \fBshowInfoLine\fR is \fITRUE\fR, the information
339 line will be displayed.
340 If it is \fIFALSE\fR it won't.
341 .TP 5
342 .B setCDKViewerLLChar
343 sets the lower left hand corner of the widget's box to the given character.
344 .TP 5
345 .B setCDKViewerLRChar
346 sets the lower right hand corner of the widget's box to the given character.
347 .TP 5
348 .B setCDKViewerTitle
349 sets the title of the widget.
350 .TP 5
351 .B setCDKViewerULChar
352 sets the upper left hand corner of the widget's box to the given character.
353 .TP 5
354 .B setCDKViewerURChar
355 sets the upper right hand corner of the widget's box to the given character.
356 .TP 5
357 .B setCDKViewerVerticalChar
358 sets the vertical drawing character for the box to the given character.
359 .SH KEY BINDINGS
360 When the widget is activated there are several default key bindings which will
361 help the user enter or manipulate the information quickly.
362 The following table
363 outlines the keys and their actions for this widget.
364 .LP
365 .TS
366 center box;
367 l l
368 l l
369 lw15 lw35 .
370 \fBKey Action\fR
371 =
372 Left Arrow Shifts the viewport one column left.
373 Right Arrow Shifts the viewport one column left
374 Up Arrow Scrolls the viewport one line up.
375 Down Arrow Scrolls the viewport one line down.
376 _
377 Prev Page
378 Ctrl-B
379 B
380 b Scroll one page backward.
381 _
382 Next Page
383 Ctrl-F
384 Space
385 F
386 f Scroll one page forward.
387 _
388 Home
389 | Shift the whole list to the far left.
390 _
391 End
392 $ Shift the whole list to the far right.
393 _
394 1
395 <
396 g Moves to the first line in the viewer.
397 _
398 >
399 G Moves to the last line in the viewer.
400 _
401 L T{
402 Moves half the distance to the end of the viewer.
403 T}
404 l T{
405 Moves half the distance to the top of the viewer.
406 T}
407 _
408 ? Searches up for a pattern.
409 / Searches down for a pattern.
410 n Repeats last search.
411 N Repeats last search, reversed direction.
412 : Jumps to a given line.
413 _
414 i Displays file statistics.
415 s Displays file statistics.
416 _
417 Tab Switches buttons.
418 Return T{
419 Exit the widget and return the index of the selected button.
420 Set the widget data \fIexitType\fR to \fIvNORMAL\fR.
421 T}
422 Escape T{
423 Exit the widget and return -1.
424 Set the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
425 T}
426 Ctrl-L Refreshes the screen.
427 .TE
428 .SH SEE ALSO
429 .BR cdk (3),
430 .BR cdk_binding (3),
431 .BR cdk_display (3),
432 .BR cdk_position (3),
433 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: gen-scale.3,v 1.6 2005/12/28 20:52:05 tom Exp $"
2 .de XX
3 ..
4 .TH cdk_<MODEL>scale 3
5 .SH NAME
6 .XX activateCDK<MIXED>
7 .XX destroyCDK<MIXED>
8 .XX drawCDK<MIXED>
9 .XX eraseCDK<MIXED>
10 .XX getCDK<MIXED>Box
11 #if <FLOAT>
12 .XX getCDK<MIXED>Digits
13 #endif <FLOAT>
14 .XX getCDK<MIXED>HighValue
15 .XX getCDK<MIXED>LowValue
16 .XX getCDK<MIXED>Value
17 .XX injectCDK<MIXED>
18 .XX moveCDK<MIXED>
19 .XX newCDK<MIXED>
20 .XX positionCDK<MIXED>
21 .XX setCDK<MIXED>
22 .XX setCDK<MIXED>BackgroundAttrib
23 .XX setCDK<MIXED>BackgroundColor
24 .XX setCDK<MIXED>Box
25 .XX setCDK<MIXED>BoxAttribute
26 #if <FLOAT>
27 .XX setCDK<MIXED>Digits
28 #endif <FLOAT>
29 .XX setCDK<MIXED>HorizontalChar
30 .XX setCDK<MIXED>LLChar
31 .XX setCDK<MIXED>LRChar
32 .XX setCDK<MIXED>LowHigh
33 .XX setCDK<MIXED>PostProcess
34 .XX setCDK<MIXED>PreProcess
35 .XX setCDK<MIXED>ULChar
36 .XX setCDK<MIXED>URChar
37 .XX setCDK<MIXED>Value
38 .XX setCDK<MIXED>VerticalChar
39 cdk_<MODEL>scale \- curses scale widget (type <CTYPE>).
40 .SH SYNOPSIS
41 .LP
42 .B cc
43 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
44 .B \-lcdk
45 .RI "[ " "library" " \|.\|.\|. ]"
46 .LP
47 #include <cdk.h>
48 .nf
49 .TP 15
50 .B "<CTYPE> activateCDK<MIXED> ("
51 .BI "CDK<UPPER> *" "scale",
52 .BI "chtype *" "actions");
53 .TP 15
54 .B "void destroyCDK<MIXED> ("
55 .BI "CDK<UPPER> *" "scale");
56 .TP 15
57 .B "void drawCDK<MIXED> ("
58 .BI "CDK<UPPER> *" "scale",
59 .BI "boolean " "box");
60 .TP 15
61 .B "void eraseCDK<MIXED> ("
62 .BI "CDK<UPPER> *" "scale");
63 .TP 15
64 .B "boolean getCDK<MIXED>Box ("
65 .BI "CDK<UPPER> *" "scale");
66 #if <FLOAT>
67 .TP 15
68 .B "int getCDK<MIXED>Digits ("
69 .BI "CDK<UPPER> *" "scale");
70 #endif <FLOAT>
71 .TP 15
72 .B "<CTYPE> getCDK<MIXED>HighValue ("
73 .BI "CDK<UPPER> *" "scale");
74 .TP 15
75 .B "<CTYPE> getCDK<MIXED>LowValue ("
76 .BI "CDK<UPPER> *" "scale");
77 .TP 15
78 .B "<CTYPE> getCDK<MIXED>Value ("
79 .BI "CDK<UPPER> *" "scale");
80 .TP 15
81 .B "int injectCDK<MIXED> ("
82 .BI "CDK<UPPER> *" "scale",
83 .BI "chtype " "input");
84 .TP 15
85 .B "void moveCDK<MIXED> ("
86 .BI "CDK<UPPER> *" "scale",
87 .BI "int " "xpos",
88 .BI "int " "ypos",
89 .BI "boolean " "relative",
90 .BI "boolean " "refresh");
91 .TP 15
92 .B "CDK<UPPER> *newCDK<MIXED> ("
93 .BI "CDKSCREEN *" "cdkscreen",
94 .BI "int " "xpos",
95 .BI "int " "ypos",
96 .BI "char *" "title",
97 .BI "char *" "label",
98 .BI "chtype " "fieldAttribute",
99 .BI "int " "fieldWidth",
100 .BI "<CTYPE> " "currentValue",
101 .BI "<CTYPE> " "lowValue",
102 .BI "<CTYPE> " "highValue",
103 .BI "<CTYPE> " "increment",
104 .BI "<CTYPE> " "fastIncrement",
105 #if <FLOAT>
106 .BI "int " "digits",
107 #endif <FLOAT>
108 .BI "boolean " "box",
109 .BI "boolean " "shadow");
110 .TP 15
111 .B "void positionCDK<MIXED> ("
112 .BI "CDK<UPPER> *" "scale");
113 .TP 15
114 .B "void setCDK<MIXED> ("
115 .BI "CDK<UPPER> *" "scale",
116 .BI "<CTYPE> " "lowValue",
117 .BI "<CTYPE> " "highValue",
118 .BI "<CTYPE> " "currentValue",
119 .BI "boolean " "box");
120 .TP 15
121 .B "void setCDK<MIXED>BackgroundAttrib ("
122 .BI "CDK<UPPER> *" "scale",
123 .BI "chtype " "attribute");
124 .TP 15
125 .B "void setCDK<MIXED>BackgroundColor ("
126 .BI "CDK<UPPER> *" "scale",
127 .BI "char * " "color");
128 .TP 15
129 .B "void setCDK<MIXED>Box ("
130 .BI "CDK<UPPER> *" "scale",
131 .BI "boolean " "box");
132 .TP 15
133 .B "void setCDK<MIXED>BoxAttribute ("
134 .BI "CDK<UPPER> *" "scale",
135 .BI "chtype " "character");
136 #if <FLOAT>
137 .TP 15
138 .B "void setCDK<MIXED>Digits ("
139 .BI "CDK<UPPER> *" "scale",
140 .BI "int " "digits");
141 #endif <FLOAT>
142 .TP 15
143 .B "void setCDK<MIXED>HorizontalChar ("
144 .BI "CDK<UPPER> *" "scale",
145 .BI "chtype " "character");
146 .TP 15
147 .B "void setCDK<MIXED>LLChar ("
148 .BI "CDK<UPPER> *" "scale",
149 .BI "chtype " "character");
150 .TP 15
151 .B "void setCDK<MIXED>LRChar ("
152 .BI "CDK<UPPER> *" "scale",
153 .BI "chtype " "character");
154 .TP 15
155 .B "void setCDK<MIXED>LowHigh ("
156 .BI "CDK<UPPER> *" "scale",
157 .BI "<CTYPE> " "low",
158 .BI "<CTYPE> " "high");
159 .TP 15
160 .B "void setCDK<MIXED>PostProcess ("
161 .BI "CDK<UPPER> *" "scale",
162 .BI "PROCESSFN " "callback",
163 .BI "void * " "data");
164 .TP 15
165 .B "void setCDK<MIXED>PreProcess ("
166 .BI "CDK<UPPER> *" "scale",
167 .BI "PROCESSFN " "callback",
168 .BI "void * " "data");
169 .TP 15
170 .B "void setCDK<MIXED>ULChar ("
171 .BI "CDK<UPPER> *" "scale",
172 .BI "chtype " "character");
173 .TP 15
174 .B "void setCDK<MIXED>URChar ("
175 .BI "CDK<UPPER> *" "scale",
176 .BI "chtype " "character");
177 .TP 15
178 .B "void setCDK<MIXED>Value ("
179 .BI "CDK<UPPER> *" "scale",
180 .BI "<CTYPE> " "value");
181 .TP 15
182 .B "void setCDK<MIXED>VerticalChar ("
183 .BI "CDK<UPPER> *" "scale",
184 .BI "chtype " "character");
185 .fi
186 .SH DESCRIPTION
187 The Cdk scale widget creates a scale box with a label and a scale field.
188 The following functions create or manipulate the Cdk scale box widget.
189 .SH AVAILABLE FUNCTIONS
190 .TP 5
191 .B activateCDK<MIXED>
192 activates the scale widget and lets the user interact with the widget.
193 The parameter \fBscale\fR is a pointer to a non-NULL scale widget.
194 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
195 in the array will be injected into the widget.
196 To activate the widget
197 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
198 If the character entered
199 into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a
200 value from the low value to the high value.
201 It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
202 If the character entered into this
203 widget was \fIESCAPE\fR then the widget will return
204 the unknown<DTYPE> value (see the cdk_objs.h header file).
205 The widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR.
206 .TP 5
207 .B destroyCDK<MIXED>
208 removes the widget from the screen and frees memory the object used.
209 .TP 5
210 .B drawCDK<MIXED>
211 draws the scale widget on the screen.
212 If the \fBbox\fR parameter is true, the widget is drawn with a box.
213 .TP 5
214 .B eraseCDK<MIXED>
215 removes the widget from the screen.
216 This does \fINOT\fR destroy the widget.
217 .TP 5
218 .B getCDK<MIXED>Box
219 returns whether the widget will be drawn with a box around it.
220 #if <FLOAT>
221 .TP 5
222 .B getCDK<MIXED>Digits
223 returns the number of digits shown after the decimal point for the box value.
224 #endif <FLOAT>
225 .TP 5
226 .B getCDK<MIXED>HighValue
227 returns the high value of the scale widget.
228 .TP 5
229 .B getCDK<MIXED>LowValue
230 returns the low value of the scale widget.
231 .TP 5
232 .B getCDK<MIXED>Value
233 returns the current value of the widget.
234 .TP 5
235 .B injectCDK<MIXED>
236 injects a single character into the widget.
237 The parameter \fBscale\fR is a pointer to a non-NULL scale widget.
238 The parameter \fBcharacter\fR is the character to inject into the widget.
239 The return value and side-effect (setting the widget data \fIexitType\fP)
240 depend upon the injected character:
241 .RS
242 .TP
243 \fIRETURN\fP or \fITAB\fR
244 the function returns
245 a value ranging from the scale's low value to the scale's high value.
246 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
247 .TP
248 \fIESCAPE\fP
249 the function returns
250 the unknown<DTYPE> value (see the cdk_objs.h header file).
251 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
252 .TP
253 Otherwise
254 unless modified by preprocessing, postprocessing or key bindings,
255 the function returns
256 the unknown<DTYPE> value (see the cdk_objs.h header file).
257 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
258 .RE
259 .TP 5
260 .B moveCDK<MIXED>
261 moves the given widget to the given position.
262 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
263 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
264 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
265 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
266 \fIRIGHT\fR, and \fICENTER\fR.
267 The parameter \fBrelative\fR states whether
268 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
269 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
270 then the widget would move one row down and two columns right.
271 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
272 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
273 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
274 (weird things may happen).
275 The final parameter \fBrefresh\fR is a boolean value which
276 states whether the widget will get refreshed after the move.
277 .TP 5
278 .B newCDK<MIXED>
279 creates a pointer to a scale widget.
280 Parameters:
281 .RS
282 .TP 5
283 \fBscreen\fR
284 is the screen you wish this widget to be placed in.
285 .TP 5
286 \fBxpos\fR
287 controls the placement of the object along the horizontal axis.
288 It may be an integer or one of the pre-defined values
289 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
290 .TP 5
291 \fBypos\fR
292 controls the placement of the object along the vertical axis.
293 It may be an integer or one of the pre-defined values
294 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
295 .TP 5
296 \fBtitle\fR
297 is the string to display at the top of the widget.
298 The title can be more than one line; just provide a carriage return
299 character at the line break.
300 .TP 5
301 \fBlabel\fR
302 is the string to display in the label of the scale field.
303 .TP 5
304 \fBfieldAttribute\fR
305 is the attribute of the characters displayed in the field.
306 .TP 5
307 \fBfieldWidth\fR
308 controls the width of the widget.
309 If you
310 provide a value of zero the widget will be created with the full width of
311 the screen.
312 If you provide a negative value, the widget will be created
313 the full width minus the value provided.
314 .TP 5
315 \fBcurrentValue\fR
316 is the value of the scale field when the widget is activated.
317 .TP 5
318 \fBlowValue\fR and
319 .TP 5
320 \fBhighValue\fR
321 are the low and high values of the widget respectively.
322 .TP 5
323 \fBincrement\fR
324 is the regular increment value
325 .TP 5
326 \fBfastIncrement\fR
327 is the accelerated increment value.
328 .TP 5
329 \fBbox\fR
330 is true if the widget should be drawn with a box around it.
331 .TP 5
332 \fBshadow\fR
333 turns the shadow on or off around this widget.
334 .RE
335 .IP
336 If the widget could not be created then a \fINULL\fR
337 pointer is returned.
338 .TP 5
339 .B positionCDK<MIXED>
340 allows the user to move the widget around the screen via the cursor/keypad keys.
341 See \fBcdk_position (3)\fR for key bindings.
342 .TP 5
343 .B setCDK<MIXED>
344 lets the programmer modify certain elements of an existing scale widget.
345 The parameter names correspond to the same parameter
346 names listed in the \fInewCDK<MIXED>\fR function.
347 .TP 5
348 .B setCDK<MIXED>BackgroundAttrib
349 sets the background attribute of the widget.
350 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
351 .TP 5
352 .B setCDK<MIXED>BackgroundColor
353 sets the background color of the widget.
354 The parameter \fBcolor\fR
355 is in the format of the Cdk format strings.
356 See \fBcdk_display (3)\fR.
357 .TP 5
358 .B setCDK<MIXED>Box
359 sets whether the widget will be drawn with a box around it.
360 .TP 5
361 .B setCDK<MIXED>BoxAttribute
362 sets the attribute of the box.
363 #if <FLOAT>
364 .TP 5
365 .B setCDK<MIXED>Digits
366 sets the number of digits shown after the decimal point for the box value.
367 #endif <FLOAT>
368 .TP 5
369 .B setCDK<MIXED>HorizontalChar
370 sets the horizontal drawing character for the box to
371 the given character.
372 .TP 5
373 .B setCDK<MIXED>LLChar
374 sets the lower left hand corner of the widget's box to
375 the given character.
376 .TP 5
377 .B setCDK<MIXED>LRChar
378 sets the lower right hand corner of the widget's box to
379 the given character.
380 .TP 5
381 .B setCDK<MIXED>LowHigh
382 sets the low and high values of the widget.
383 .TP 5
384 .B setCDK<MIXED>PostProcess
385 allows the user to have the widget call a function after the
386 key has been applied to the widget.
387 The parameter \fBfunction\fR is the callback function.
388 The parameter \fBdata\fR points to data passed to the callback function.
389 To learn more about post-processing see \fIcdk_process (3)\fR.
390 .TP 5
391 .B setCDK<MIXED>PreProcess
392 allows the user to have the widget call a function after a key
393 is hit and before the key is applied to the widget.
394 The parameter \fBfunction\fR is the callback function.
395 The parameter \fBdata\fR points to data passed to the callback function.
396 To learn more about pre-processing see \fIcdk_process (3)\fR.
397 .TP 5
398 .B setCDK<MIXED>ULChar
399 sets the upper left hand corner of the widget's box to
400 the given character.
401 .TP 5
402 .B setCDK<MIXED>URChar
403 sets the upper right hand corner of the widget's box to
404 the given character.
405 .TP 5
406 .B setCDK<MIXED>Value
407 sets the current value of the widget.
408 .TP 5
409 .B setCDK<MIXED>VerticalChar
410 sets the vertical drawing character for the box to
411 the given character.
412 .SH KEY BINDINGS
413 When the widget is activated there are several default key bindings which will
414 help the user enter or manipulate the information quickly.
415 The following table
416 outlines the keys and their actions for this widget.
417 .LP
418 .TS
419 center tab(/) box;
420 l l
421 l l
422 lw15 lw50 .
423 \fBKey/Action\fR
424 =
425 Down Arrow/T{
426 Decrements the scale by the normal value.
427 T}
428 Up Arrow/Increments the scale by the normal value.
429 u/Increments the scale by the normal value.
430 Prev Page/Decrements the scale by the accelerated value.
431 U/Decrements the scale by the accelerated value.
432 Ctrl-B/Decrements the scale by the accelerated value.
433 Next Page/Increments the scale by the accelerated value.
434 Ctrl-F/Increments the scale by the accelerated value.
435 Home/Sets the scale to the low value.
436 g/Sets the scale to the low value.
437 ^/Sets the scale to the low value.
438 End/Sets the scale to the high value.
439 G/Sets the scale to the high value.
440 $/Sets the scale to the high value.
441 Return/T{
442 Exits the widget and returns the index of the selected value.
443 This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
444 T}
445 Tab/T{
446 Exits the widget and returns the index of the selected value.
447 This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
448 T}
449 Escape/T{
450 Exits the widget and returns
451 the unknown<DTYPE> value (see the cdk_objs.h header file).
452 This also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
453 T}
454 Ctrl-R/Refreshes the screen.
455 .TE
456 .LP
457 If the cursor is not pointing to the field's value, the following
458 key bindings apply. You may use the left/right arrows to move the
459 cursor onto the field's value and modify it by typing characters to
460 replace the digits and sign.
461 .TS
462 center tab(/) box;
463 l l
464 l l
465 lw15 lw50 .
466 \fBKey/Action\fR
467 =
468 Left Arrow/T{
469 Decrements the scale by the normal value.
470 T}
471 Right Arrow/Increments the scale by the normal value.
472 =
473 d/Decrements the scale by the normal value.
474 D/Increments the scale by the accelerated value.
475 -/Decrements the scale by the normal value.
476 +/Increments the scale by the normal value.
477 0/Sets the scale to the low value.
478 .TE
479 .SH SEE ALSO
480 .BR cdk (3),
481 .BR cdk_binding (3),
482 .BR cdk_display (3),
483 .BR cdk_position (3),
484 .BR cdk_screen (3)
0 '\" t
1 .\" $Id: gen-slider.3,v 1.4 2005/12/28 20:51:59 tom Exp $"
2 .de XX
3 ..
4 .TH cdk_<MODEL>slider 3
5 .SH NAME
6 .XX activateCDK<MIXED>
7 .XX destroyCDK<MIXED>
8 .XX drawCDK<MIXED>
9 .XX eraseCDK<MIXED>
10 .XX getCDK<MIXED>Box
11 #if <FLOAT>
12 .XX getCDK<MIXED>Digits
13 #endif <FLOAT>
14 .XX getCDK<MIXED>HighValue
15 .XX getCDK<MIXED>LowValue
16 .XX getCDK<MIXED>Value
17 .XX injectCDK<MIXED>
18 .XX moveCDK<MIXED>
19 .XX newCDK<MIXED>
20 .XX positionCDK<MIXED>
21 .XX setCDK<MIXED>
22 .XX setCDK<MIXED>BackgroundAttrib
23 .XX setCDK<MIXED>BackgroundColor
24 .XX setCDK<MIXED>Box
25 .XX setCDK<MIXED>BoxAttribute
26 #if <FLOAT>
27 .XX setCDK<MIXED>Digits
28 #endif <FLOAT>
29 .XX setCDK<MIXED>HorizontalChar
30 .XX setCDK<MIXED>LLChar
31 .XX setCDK<MIXED>LRChar
32 .XX setCDK<MIXED>LowHigh
33 .XX setCDK<MIXED>PostProcess
34 .XX setCDK<MIXED>PreProcess
35 .XX setCDK<MIXED>ULChar
36 .XX setCDK<MIXED>URChar
37 .XX setCDK<MIXED>Value
38 .XX setCDK<MIXED>VerticalChar
39 cdk_<MODEL>slider \- curses slider widget (type <CTYPE>)
40 .SH SYNOPSIS
41 .LP
42 .B cc
43 .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
44 .B \-lcdk
45 .RI "[ " "library" " \|.\|.\|. ]"
46 .LP
47 #include <cdk.h>
48 .nf
49 .TP 15
50 .B "int activateCDK<MIXED> ("
51 .BI "CDK<UPPER> *" "slider",
52 .BI "chtype *" "actions");
53 .TP 15
54 .B "void destroyCDK<MIXED> ("
55 .BI "CDK<UPPER> *" "slider");
56 .TP 15
57 .B "void drawCDK<MIXED> ("
58 .BI "CDK<UPPER> *" "slider",
59 .BI "boolean " "box");
60 .TP 15
61 .B "void eraseCDK<MIXED> ("
62 .BI "CDK<UPPER> *" "slider");
63 .TP 15
64 .B "boolean getCDK<MIXED>Box ("
65 .BI "CDK<UPPER> *" "slider");
66 #if <FLOAT>
67 .TP 15
68 .B "int getCDK<MIXED>Digits ("
69 .BI "CDK<UPPER> *" "scale");
70 #endif <FLOAT>
71 .TP 15
72 .B "<CTYPE> getCDK<MIXED>HighValue ("
73 .BI "CDK<UPPER> *" "slider");
74 .TP 15
75 .B "<CTYPE> getCDK<MIXED>LowValue ("
76 .BI "CDK<UPPER> *" "slider");
77 .TP 15
78 .B "<CTYPE> getCDK<MIXED>Value ("
79 .BI "CDK<UPPER> *" "slider");
80 .TP 15
81 .B "<CTYPE> injectCDK<MIXED> ("
82 .BI "CDK<UPPER> *" "slider",
83 .BI "chtype " "input");
84 .TP 15
85 .B "void moveCDK<MIXED> ("
86 .BI "CDK<UPPER> *" "slider",
87 .BI "int " "xpos",
88 .BI "int " "ypos",
89 .BI "boolean " "relative",
90 .BI "boolean " "refresh");
91 .TP 15
92 .B "CDK<UPPER> *newCDK<MIXED> ("
93 .BI "CDKSCREEN *" "cdkscreen",
94 .BI "int " "xpos",
95 .BI "int " "ypos",
96 .BI "char *" "title",
97 .BI "char *" "label",
98 .BI "chtype " "fillerCharacter",
99 .BI "int " "fieldWidth",
100 .BI "int " "currentValue",
101 .BI "<CTYPE> " "lowValue",
102 .BI "<CTYPE> " "highValue",
103 .BI "<CTYPE> " "increment",
104 .BI "<CTYPE> " "fastIncrement",
105 #if <FLOAT>
106 .BI "int " "digits",
107 #endif <FLOAT>
108 .BI "boolean " "box",
109 .BI "boolean " "shadow");
110 .TP 15
111 .B "void positionCDK<MIXED> ("
112 .BI "CDK<UPPER> *" "slider");
113 .TP 15
114 .B "void setCDK<MIXED> ("
115 .BI "CDK<UPPER> *" "slider",
116 .BI "<CTYPE> " "lowValue",
117 .BI "<CTYPE> " "highValue",
118 .BI "<CTYPE> " "currentValue",
119 .BI "boolean " "box");
120 .TP 15
121 .B "void setCDK<MIXED>BackgroundAttrib ("
122 .BI "CDK<UPPER> *" "slider",
123 .BI "chtype " "attribute");
124 .TP 15
125 .B "void setCDK<MIXED>BackgroundColor ("
126 .BI "CDK<UPPER> *" "slider",
127 .BI "char * " "color");
128 .TP 15
129 .B "void setCDK<MIXED>Box ("
130 .BI "CDK<UPPER> *" "slider",
131 .BI "boolean " "boxWidget");
132 .TP 15
133 .B "void setCDK<MIXED>BoxAttribute ("
134 .BI "CDK<UPPER> *" "slider",
135 .BI "chtype " "character");
136 #if <FLOAT>
137 .TP 15
138 .B "void setCDK<MIXED>Digits ("
139 .BI "CDK<UPPER> *" "scale",
140 .BI "int " "digits");
141 #endif <FLOAT>
142 .TP 15
143 .B "void setCDK<MIXED>HorizontalChar ("
144 .BI "CDK<UPPER> *" "slider",
145 .BI "chtype " "character");
146 .TP 15
147 .B "void setCDK<MIXED>LLChar ("
148 .BI "CDK<UPPER> *" "slider",
149 .BI "chtype " "character");
150 .TP 15
151 .B "void setCDK<MIXED>LRChar ("
152 .BI "CDK<UPPER> *" "slider",
153 .BI "chtype " "character");
154 .TP 15
155 .B "void setCDK<MIXED>LowHigh ("
156 .BI "CDK<UPPER> *" "slider",
157 .BI "<CTYPE> " "lowValue",
158 .BI "<CTYPE> " "highValue");
159 .TP 15
160 .B "void setCDK<MIXED>PostProcess ("
161 .BI "CDK<UPPER> *" "slider",
162 .BI "PROCESSFN " "callback",
163 .BI "void * " "data");
164 .TP 15
165 .B "void setCDK<MIXED>PreProcess ("
166 .BI "CDK<UPPER> *" "slider",
167 .BI "PROCESSFN " "callback",
168 .BI "void * " "data");
169 .TP 15
170 .B "void setCDK<MIXED>ULChar ("
171 .BI "CDK<UPPER> *" "slider",
172 .BI "chtype " "character");
173 .TP 15
174 .B "void setCDK<MIXED>URChar ("
175 .BI "CDK<UPPER> *" "slider",
176 .BI "chtype " "character");
177 .TP 15
178 .B "void setCDK<MIXED>Value ("
179 .BI "CDK<UPPER> *" "slider",
180 .BI "<CTYPE> " "value");
181 .TP 15
182 .B "void setCDK<MIXED>VerticalChar ("
183 .BI "CDK<UPPER> *" "slider",
184 .BI "chtype " "character");
185 .fi
186 .SH DESCRIPTION
187 The Cdk slider widget creates a visual slider box with a label and a slider field.
188 The following are functions which create or manipulate the Cdk slider
189 box widget.
190 .SH AVAILABLE FUNCTIONS
191 .TP 5
192 .B activateCDK<MIXED>
193 activates the slider widget and lets the user interact with the widget.
194 The parameter \fBslider\fR is a pointer to a non-NULL slider widget.
195 If the \fBactions\fR parameter is passed with a non-NULL value, the characters
196 in the array will be injected into the widget.
197 To activate the widget
198 interactively pass in a \fINULL\fR pointer for \fBactions\fR.
199 If the character entered
200 into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a
201 value from the low value to the high value.
202 It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR.
203 If the character entered into this
204 widget was \fIESCAPE\fR then the widget returns
205 the unknown<DTYPE> value (see the cdk_objs.h header file).
206 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
207 .TP 5
208 .B destroyCDK<MIXED>
209 removes the widget from the screen and frees memory the object used.
210 .TP 5
211 .B drawCDK<MIXED>
212 draws the slider widget on the screen.
213 If the \fBbox\fR option is true, the widget is drawn with a box.
214 .TP 5
215 .B eraseCDK<MIXED>
216 removes the widget from the screen.
217 This does \fINOT\fR destroy the widget.
218 .TP 5
219 .B getCDK<MIXED>Box
220 returns true if the widget will be drawn with a box around it.
221 #if <FLOAT>
222 .TP 5
223 .B getCDK<MIXED>Digits
224 returns the number of digits shown after the decimal point for the box value.
225 #endif <FLOAT>
226 .TP 5
227 .B getCDK<MIXED>HighValue
228 returns the high value of the slider widget.
229 .TP 5
230 .B getCDK<MIXED>LowValue
231 returns the low value of the slider widget.
232 .TP 5
233 .B getCDK<MIXED>Value
234 returns the current value of the widget.
235 .TP 5
236 .B injectCDK<MIXED>
237 injects a single character into the widget.
238 The parameter \fBslider\fR is a pointer to a non-NULL slider widget.
239 The parameter \fBcharacter\fR is the character to inject into the widget.
240 The return value and side-effect (setting the widget data \fIexitType\fP)
241 depend upon the injected character:
242 .RS
243 .TP
244 \fIRETURN\fP or \fITAB\fR
245 the function returns
246 a value ranging from the slider's low value to the slider's high value.
247 The widget data \fIexitType\fR is set to \fIvNORMAL\fR.
248 .TP
249 \fIESCAPE\fP
250 the function returns
251 the unknown<DTYPE> value (see the cdk_objs.h header file).
252 The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR.
253 .TP
254 Otherwise
255 unless modified by preprocessing, postprocessing or key bindings,
256 the function returns
257 the unknown<DTYPE> value (see the cdk_objs.h header file).
258 The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR.
259 .RE
260 .TP 5
261 .B moveCDK<MIXED>
262 moves the given widget to the given position.
263 The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget.
264 The parameter \fBxpos\fR may be an integer or one of the pre-defined values
265 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
266 The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR,
267 \fIRIGHT\fR, and \fICENTER\fR.
268 The parameter \fBrelative\fR states whether
269 the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move.
270 For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR,
271 then the widget would move one row down and two columns right.
272 If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2).
273 Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR,
274 \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR.
275 (weird things may happen).
276 The final parameter \fBrefresh\fR is a boolean value which
277 states whether the widget will get refreshed after the move.
278 .TP 5
279 .B newCDK<MIXED>
280 function creates a slider widget and returns a pointer to it..
281 Parameters:
282 .RS
283 .TP 5
284 \fBscreen\fR
285 is the screen you wish this widget to be placed in.
286 .TP 5
287 \fBxpos\fR
288 controls the placement of the object along the horizontal axis.
289 It may be an integer or one of the pre-defined values
290 \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR.
291 .TP 5
292 \fBypos\fR
293 controls the placement of the object along the vertical axis.
294 It may be an integer or one of the pre-defined values
295 \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR.
296 .TP 5
297 \fBtitle\fR
298 is the string to display at the top of the widget.
299 The title can be more than one line; just provide a carriage return
300 character at the line break.
301 .TP 5
302 \fBlabel\fR
303 is the string to display in the label of the slider field.
304 .TP 5
305 \fBfillerCharacter\fR
306 is the character to be used to draw the slider bar in the field.
307 .TP 5
308 \fBfieldWidth\fR
309 controls the width of the widget.
310 If you provide a value
311 of zero the widget will be created with the full width of the screen.
312 If you provide a negative value, the widget will be created the full width
313 minus the value provided.
314 .TP 5
315 \fBcurrentValue\fR
316 is the value of the slider field when the widget is activated.
317 .TP 5
318 \fBlowValue\fR and
319 .TP 5
320 \fBhighValue\fR
321 are the low and high values of the widget respectively.
322 .TP 5
323 \fBincrement\fR
324 is the regular increment value
325 .TP 5
326 \fBfastIncrement\fR
327 is the accelerated increment value.
328 .TP 5
329 \fBbox\fR
330 is true if the widget should be drawn with a box around it.
331 .TP 5
332 \fBshadow\fR
333 turns the shadow on or off around this widget.
334 .RE
335 .IP
336 If the widget could not be created then a \fINULL\fR pointer is returned.
337 .TP 5
338 .B positionCDK<MIXED>
339 allows the user to move the widget around the screen via the cursor/keypad keys.
340 See \fBcdk_position (3)\fR for key bindings.
341 .TP 5
342 .B setCDK<MIXED>
343 lets the programmer modify certain elements of an existing slider widget.
344 The parameter names correspond to the same parameter
345 names listed in the \fInewCDK<MIXED>\fR function.
346 .TP 5
347 .B setCDK<MIXED>BackgroundAttrib
348 sets the background attribute of the widget.
349 The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD.
350 .TP 5
351 .B setCDK<MIXED>BackgroundColor
352 sets the background color of the widget.
353 The parameter \fBcolor\fR is in the format of the Cdk format strings.
354 See \fBcdk_display (3)\fR.
355 .TP 5
356 .B setCDK<MIXED>Box
357 sets whether the widget will be drawn with a box around it.
358 .TP 5
359 .B setCDK<MIXED>BoxAttribute
360 function sets the attribute of the box.
361 #if <FLOAT>
362 .TP 5
363 .B setCDK<MIXED>Digits
364 sets the number of digits shown after the decimal point for the box value.
365 #endif <FLOAT>
366 .TP 5
367 .B setCDK<MIXED>HorizontalChar
368 sets the horizontal drawing character for the box to the given character.
369 .TP 5
370 .B setCDK<MIXED>LLChar
371 sets the lower left hand corner of the widget's box to the given character.
372 .TP 5
373 .B setCDK<MIXED>LRChar
374 sets the lower right hand corner of the widget's box to the given character.
375 .TP 5
376 .B setCDK<MIXED>LowHigh
377 sets the low and high values of the widget.
378 .TP 5
379 .B setCDK<MIXED>PostProcess
380 allows the user to have the widget call a function after the
381 key has been applied to the widget.
382 The parameter \fBfunction\fR is the callback function.
383 The parameter \fBdata\fR points to data passed to the callback function.
384 To learn more about post-processing see \fIcdk_process (3)\fR.
385 .TP 5
386 .B setCDK<MIXED>PreProcess
387 allows the user to have the widget call a function after a key
388 is hit and before the key is applied to the widget.
389 The parameter \fBfunction\fR is the callback function.
390 The parameter \fBdata\fR points to data passed to the callback function.
391 To learn more about pre-processing see \fIcdk_process (3)\fR.
392 .TP 5
393 .B setCDK<MIXED>ULChar
394 sets the upper left hand corner of the widget's box to the given character.
395 .TP 5
396 .B setCDK<MIXED>URChar
397 sets the upper right hand corner of the widget's box to the given character.
398 .TP 5
399 .B setCDK<MIXED>Value
400 sets the current value of the widget.
401 .TP 5
402 .B setCDK<MIXED>VerticalChar
403 sets the vertical drawing character for the box to the given character.
404 .SH KEY BINDINGS
405 When the widget is activated there are several default key bindings which will
406 help the user enter or manipulate the information quickly.
407 The following table
408 outlines the keys and their actions for this widget.
409 .LP
410 .TS
411 center tab(/) box;
412 l l
413 l l
414 lw15 lw50 .
415 \fBKey/Action\fR
416 =
417 Down Arrow/T{
418 Decrements the field by the normal decrement value.
419 T}
420 Up Arrow/T{
421 Increments the field by the normal increment value.
422 T}
423 u/T{
424 Increments the field by the normal increment value.
425 T}
426 Prev Page/T{
427 Decrements the field by the accelerated decrement value.
428 T}
429 U/T{
430 Decrements the field by the accelerated decrement value.
431 T}
432 Ctrl-B/T{
433 Decrements the field by the accelerated decrement value.
434 T}
435 Next Page/T{
436 Increments the field by the accelerated increment value.
437 T}
438 D/T{
439 Increments the field by the accelerated increment value.
440 T}
441 Ctrl-F/T{
442 Increments the field by the accelerated increment value.
443 T}
444 Home/Sets the value to the low value.
445 g/Sets the value to the low value.
446 End/Sets the value to the high value.
447 G/Sets the value to the high value.
448 $/Sets the value to the high value.
449 Return/T{
450 Exits the widget and returns the
451 current value.
452 This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
453 T}
454 Tab/T{
455 Exits the widget and returns the current value.
456 This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR.
457 T}
458 Escape/T{
459 Exits the widget and returns
460 the unknown<DTYPE> value (see the cdk_objs.h header file).
461 This also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR.
462 T}
463 Ctrl-R/Refreshes the screen.
464 .TE
465 .LP
466 If the cursor is not pointing to the field's value, the following
467 key bindings apply. You may use the left/right arrows to move the
468 cursor onto the field's value and modify it by typing characters to
469 replace the digits and sign.
470 .TS
471 center tab(/) box;
472 l l
473 l l
474 lw15 lw50 .
475 \fBKey/Action\fR
476 =
477 Left Arrow/T{
478 Decrements the scale by the normal value.
479 T}
480 Right Arrow/Increments the scale by the normal value.
481 =
482 d/Decrements the scale by the normal value.
483 D/Increments the scale by the accelerated value.
484 -/Decrements the scale by the normal value.
485 +/Increments the scale by the normal value.
486 0/Sets the scale to the low value.
487 .TE
488 .SH SEE ALSO
489 .BR cdk (3),
490 .BR cdk_binding (3),
491 .BR cdk_display (3),
492 .BR cdk_position (3),
493 .BR cdk_screen (3)
0 # $Id: manlinks.sed,v 1.6 2005/12/31 01:34:26 tom Exp $
1 ##############################################################################
2 # Copyright 2000-2002,2005 Thomas E. Dickey #
3 # #
4 # Permission is hereby granted, free of charge, to any person obtaining a #
5 # copy of this software and associated documentation files (the "Software"), #
6 # to deal in the Software without restriction, including without limitation #
7 # the rights to use, copy, modify, merge, publish, distribute, distribute #
8 # with modifications, sublicense, and/or sell copies of the Software, and to #
9 # permit persons to whom the Software is furnished to do so, subject to the #
10 # following conditions: #
11 # #
12 # The above copyright notice and this permission notice shall be included in #
13 # all copies or substantial portions of the Software. #
14 # #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
18 # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
20 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
21 # DEALINGS IN THE SOFTWARE. #
22 # #
23 # Except as contained in this notice, the name(s) of the above copyright #
24 # holders shall not be used in advertising or otherwise to promote the sale, #
25 # use or other dealings in this Software without prior written #
26 # authorization. #
27 ##############################################################################
28 # Given a manpage (nroff) as input, writes a list of the names that are
29 # listed in the "NAME" section, i.e., the names that we would like to use
30 # as aliases for the manpage -T.Dickey
31 /^'\\"/d
32 /\.\\"/d
33 /^\.br/d
34 /^\.sp/d
35 /^\.It/d
36 s/^\.XX[ ]\+\([^ ]\+\).*$/\1,/
37 s/\\f.//g
38 s/[:,]/ /g
39 s/^[ ][ ]*//
40 s/[ ][ ]*$//
41 s/[ ][ ]*/ /g
42 s/\.SH[ ][ ]*/.SH_(/
43 #
44 /^\.SH_(NAME/,/^\.SH_(SYNOPSIS/{
45 s/\\-.*/ -/
46 / -/{
47 s/ -.*//
48 s/ /\
49 /g
50 }
51 /^-/{
52 d
53 }
54 s/ /\
55 /g
56 s/^\.XX//
57 }
58 /^\.SH_(SYNOPSIS/,/^\.SH_(DESCRIPTION/{
59 /^\.TS/,/^\.TE/{
60 d
61 }
62 /^#/d
63 /^[^(]*$/d
64 s/^\([^ (]* [^ (]* [*]*\)//g
65 s/^\([^ (]* [*]*\)//g
66 s/\.SH_(/.SH_/
67 s/(.*//
68 s/\.SH_/.SH_(/
69 }
70 /^\.SH_(DESCRIPTION/,${
71 d
72 }
73 /^\./d
74 /^$/d
0 #! /bin/sh
1 # $Id: manlinks.sh,v 1.5 2005/12/29 00:22:00 tom Exp $
2 # install/uninstall aliases for one or more manpages,
3 #
4 # Copyright 2002,2005 Thomas Dickey
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # 3. All advertising materials mentioning features or use of this software
16 # must display the following acknowledgment:
17 # This product includes software developed by Thomas Dickey
18 # and contributors.
19 # 4. Neither the name of Thomas Dickey, nor the names of contributors
20 # may be used to endorse or promote products derived from this software
21 # without specific prior written permission.
22 #
23 # THIS SOFTWARE IS PROVIDED BY THOMAS DICKEY AND CONTRIBUTORS ``AS IS'' AND
24 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 # ARE DISCLAIMED. IN NO EVENT SHALL THOMAS DICKEY OR CONTRIBUTORS BE LIABLE
27 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 # SUCH DAMAGE.
34
35 CDPATH=
36
37 verb=$1
38 shift
39
40 srcdir=$1
41 shift
42
43 mandir=$1
44 shift
45
46 mansect=$1
47 shift
48
49 parent=`pwd`
50 script=$srcdir/manlinks.sed
51
52 for source in $* ; do
53 case $source in #(vi
54 *.orig|*.rej) ;; #(vi
55 *.[0-9]*)
56 cd $parent
57 section=`expr "$source" : '.*\.\([0-9]\)[xm]*'`;
58 aliases=
59 inalias=$source
60 test ! -f $inalias && inalias="$srcdir/$inalias"
61 if test ! -f $inalias ; then
62 echo " .. skipped $source"
63 continue
64 fi
65 aliases=`sed -f $script $inalias | sort -u`
66
67 suffix=`basename $source | sed -e 's/^[^.]*//'`
68 cd $mandir || exit 1
69 if test $verb = installing ; then
70 test -n "$aliases" && (
71 if test "$suffix" = ".$mansect" ; then
72 target=`basename $source`
73 else
74 target=`basename $source $suffix`.$mansect
75 suffix=".$mansect"
76 fi
77 for cf_alias in $aliases
78 do
79 cf_doit=no
80 if test -f $cf_alias${suffix} ; then
81 if ( cmp -s $target $cf_alias${suffix} )
82 then
83 :
84 else
85 cf_doit=yes
86 fi
87 else
88 cf_doit=yes
89 fi
90 if test $cf_doit = yes ; then
91 echo " ... alias $cf_alias${suffix}"
92 rm -f $cf_alias${suffix}
93 if (ln -s $target $cf_alias${suffix}) ; then
94 :
95 else
96 echo ".so $target" > $cf_alias${suffix}
97 fi
98 fi
99 done
100 )
101 elif test $verb = removing ; then
102 suffix=".$mansect"
103 test -n "$aliases" && (
104 for cf_alias in $aliases
105 do
106 echo " ... alias $cf_alias${suffix}"
107 rm -f $cf_alias${suffix}
108 done
109 )
110 fi
111 ;;
112 esac
113 done
114 exit 0
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:44 $
5 * $Revision: 1.77 $
6 */
7
8 DeclareCDKObjects (MARQUEE, Marquee, setCdk, Unknown);
9
10 /*
11 * This creates a marquee widget.
12 */
13 CDKMARQUEE *newCDKMarquee (CDKSCREEN *cdkscreen,
14 int xplace,
15 int yplace,
16 int width,
17 boolean Box,
18 boolean shadow)
19 {
20 CDKMARQUEE *widget = 0;
21 int parentWidth = getmaxx (cdkscreen->window);
22 int xpos = xplace;
23 int ypos = yplace;
24 int boxHeight;
25 int boxWidth;
26
27 if ((widget = newCDKObject (CDKMARQUEE, &my_funcs)) == 0)
28 return (0);
29
30 setCDKMarqueeBox (widget, Box);
31
32 boxWidth = setWidgetDimension (parentWidth, width, 0);
33 boxHeight = (BorderOf (widget) * 2) + 1;
34
35 /* Rejustify the x and y positions if we need to. */
36 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
37
38 /* Create the widget pointer. */
39 ScreenOf (widget) = cdkscreen;
40 widget->parent = cdkscreen->window;
41 widget->win = newwin (boxHeight, boxWidth, ypos, xpos);
42 widget->boxHeight = boxHeight;
43 widget->boxWidth = boxWidth;
44 widget->shadowWin = 0;
45 widget->active = TRUE;
46 widget->width = width;
47 widget->shadow = shadow;
48
49 /* Is the window null??? */
50 if (widget->win == 0)
51 {
52 destroyCDKObject (widget);
53 return (0);
54 }
55
56 /* Do we want a shadow? */
57 if (shadow)
58 {
59 widget->shadowWin = subwin (cdkscreen->window,
60 boxHeight, boxWidth,
61 ypos + 1, xpos + 1);
62 }
63
64 keypad (widget->win, TRUE);
65
66 registerCDKObject (cdkscreen, vMARQUEE, widget);
67
68 return (widget);
69 }
70
71 /*
72 * This activates the widget.
73 */
74 int activateCDKMarquee (CDKMARQUEE *widget,
75 char *mesg,
76 int delay,
77 int repeat,
78 boolean Box)
79 {
80 chtype *message;
81 int mesgLength = 0;
82 int startPos = 0;
83 int firstChar = 0;
84 int lastChar = 1;
85 int repeatCount = 0;
86 int viewSize = 0;
87 int viewLimit;
88 int padding;
89 int x, y, junk, oldcurs;
90 bool firstTime = TRUE;
91
92 /* Make sure the message has some content. */
93 if (mesg == 0 || *mesg == '\0')
94 {
95 return (-1);
96 }
97
98 /* Keep the box info, setting BorderOf () */
99 setCDKMarqueeBox (widget, Box);
100
101 padding = (mesg[strlen (mesg) - 1] == ' ') ? 0 : 1;
102
103 /* Translate the char * to a chtype * */
104 message = char2Chtype (mesg, &mesgLength, &junk);
105
106 /* Draw in the widget. */
107 drawCDKMarquee (widget, ObjOf (widget)->box);
108 viewLimit = widget->width - (2 * BorderOf (widget));
109
110 /* Start doing the marquee thing... */
111 oldcurs = curs_set (0);
112 while (widget->active)
113 {
114 if (firstTime)
115 {
116 firstChar = 0;
117 lastChar = 1;
118 viewSize = lastChar - firstChar;
119 startPos = widget->width - viewSize - BorderOf (widget);
120
121 firstTime = FALSE;
122 }
123
124 /* Draw in the characters. */
125 y = firstChar;
126 for (x = startPos; x < (startPos + viewSize); x++)
127 {
128 chtype ch = (y < mesgLength) ? message[y] : ' ';
129 mvwaddch (widget->win, BorderOf (widget), x, ch);
130 y++;
131 }
132 wrefresh (widget->win);
133
134 /* Set my variables. */
135 if (mesgLength < viewLimit)
136 {
137 if (lastChar < (mesgLength + padding))
138 {
139 lastChar++;
140 viewSize++;
141 startPos = widget->width - viewSize - BorderOf (widget);
142 }
143 else if (startPos > BorderOf (widget))
144 {
145 /* This means the whole string is visible. */
146 startPos--;
147 viewSize = mesgLength + padding;
148 }
149 else
150 {
151 /* We have to start chopping the viewSize */
152 startPos = BorderOf (widget);
153 firstChar++;
154 viewSize--;
155 }
156 }
157 else
158 {
159 if (startPos > BorderOf (widget))
160 {
161 lastChar++;
162 viewSize++;
163 startPos--;
164 }
165 else if (lastChar < (mesgLength + padding))
166 {
167 firstChar++;
168 lastChar++;
169 startPos = BorderOf (widget);
170 viewSize = viewLimit;
171 }
172 else
173 {
174 startPos = BorderOf (widget);
175 firstChar++;
176 viewSize--;
177 }
178 }
179
180 /* OK, lets check if we have to start over. */
181 if (viewSize <= 0 && firstChar == mesgLength + padding)
182 {
183 /* Check if we repeat a specified number, or loop indefinitely. */
184 if ((repeat > 0) && (++repeatCount >= repeat))
185 {
186 break;
187 }
188
189 /* Time to start over. */
190 mvwaddch (widget->win, BorderOf (widget), BorderOf (widget), ' ');
191 wrefresh (widget->win);
192 firstTime = TRUE;
193 }
194
195 /* Now sleep */
196 napms (delay * 10);
197 }
198 if (oldcurs < 0)
199 oldcurs = 1;
200 curs_set (oldcurs);
201 freeChtype (message);
202 return (0);
203 }
204
205 /*
206 * This de-activates a marquee widget.
207 */
208 void deactivateCDKMarquee (CDKMARQUEE *widget)
209 {
210 widget->active = FALSE;
211 }
212
213 /*
214 * This moves the marquee field to the given location.
215 */
216 static void _moveCDKMarquee (CDKOBJS *object,
217 int xplace,
218 int yplace,
219 boolean relative,
220 boolean refresh_flag)
221 {
222 CDKMARQUEE *widget = (CDKMARQUEE *)object;
223 int currentX = getbegx (widget->win);
224 int currentY = getbegy (widget->win);
225 int xpos = xplace;
226 int ypos = yplace;
227 int xdiff = 0;
228 int ydiff = 0;
229
230 /*
231 * If this is a relative move, then we will adjust where we want
232 * to move to.
233 */
234 if (relative)
235 {
236 xpos = getbegx (widget->win) + xplace;
237 ypos = getbegy (widget->win) + yplace;
238 }
239
240 /* Adjust the window if we need to. */
241 alignxy (WindowOf (widget), &xpos, &ypos, widget->boxWidth, widget->boxHeight);
242
243 /* Get the difference. */
244 xdiff = currentX - xpos;
245 ydiff = currentY - ypos;
246
247 /* Move the window to the new location. */
248 moveCursesWindow (widget->win, -xdiff, -ydiff);
249 moveCursesWindow (widget->shadowWin, -xdiff, -ydiff);
250
251 /* Touch the windows so they 'move'. */
252 refreshCDKWindow (WindowOf (widget));
253
254 /* Redraw the window, if they asked for it. */
255 if (refresh_flag)
256 {
257 drawCDKMarquee (widget, ObjOf (widget)->box);
258 }
259 }
260
261 /*
262 * This draws the marquee widget on the screen.
263 */
264 static void _drawCDKMarquee (CDKOBJS *object, boolean Box)
265 {
266 CDKMARQUEE *widget = (CDKMARQUEE *)object;
267
268 /* Keep the box information. */
269 ObjOf (widget)->box = Box;
270
271 /* Do we need to draw a shadow??? */
272 if (widget->shadowWin != 0)
273 {
274 drawShadow (widget->shadowWin);
275 }
276
277 /* Box it if needed. */
278 if (Box)
279 {
280 drawObjBox (widget->win, ObjOf (widget));
281 }
282
283 /* Refresh the window. */
284 wrefresh (widget->win);
285 }
286
287 /*
288 * This destroys the widget.
289 */
290 static void _destroyCDKMarquee (CDKOBJS *object)
291 {
292 if (object != 0)
293 {
294 CDKMARQUEE *widget = (CDKMARQUEE *)object;
295
296 /* Clean up the windows. */
297 deleteCursesWindow (widget->shadowWin);
298 deleteCursesWindow (widget->win);
299
300 /* Clean the key bindings. */
301 cleanCDKObjectBindings (vMARQUEE, widget);
302
303 /* Unregister this object. */
304 unregisterCDKObject (vMARQUEE, widget);
305 }
306 }
307
308 /*
309 * This erases the widget.
310 */
311 static void _eraseCDKMarquee (CDKOBJS *object)
312 {
313 if (validCDKObject (object))
314 {
315 CDKMARQUEE *widget = (CDKMARQUEE *)object;
316
317 eraseCursesWindow (widget->win);
318 eraseCursesWindow (widget->shadowWin);
319 }
320 }
321
322 /*
323 * This sets the widgets box attribute.
324 */
325 void setCDKMarqueeBox (CDKMARQUEE *widget, boolean Box)
326 {
327 ObjOf (widget)->box = Box;
328 ObjOf (widget)->borderSize = Box ? 1 : 0;
329 }
330 boolean getCDKMarqueeBox (CDKMARQUEE *widget)
331 {
332 return ObjOf (widget)->box;
333 }
334
335 /*
336 * This sets the background attribute of the widget.
337 */
338 static void _setBKattrMarquee (CDKOBJS *object, chtype attrib)
339 {
340 if (object != 0)
341 {
342 CDKMARQUEE *widget = (CDKMARQUEE *)object;
343
344 wbkgd (widget->win, attrib);
345 }
346 }
347
348 dummyInject (Marquee)
349
350 dummyFocus (Marquee)
351
352 dummyUnfocus (Marquee)
353
354 dummyRefreshData (Marquee)
355
356 dummySaveData (Marquee)
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:44 $
5 * $Revision: 1.179 $
6 */
7
8 /*
9 * Declare file local prototypes.
10 */
11 static void highlightCDKMatrixCell (CDKMATRIX *matrix);
12 static void CDKMatrixCallBack (CDKMATRIX *matrix, chtype input);
13 static void drawCDKMatrixCell (CDKMATRIX *matrix,
14 int srow, int scol,
15 int vrow, int vcol,
16 chtype attr, boolean Box);
17 static void redrawTitles (CDKMATRIX *matrix, int row, int col);
18
19 DeclareCDKObjects (MATRIX, Matrix, setCdk, Int);
20
21 /*
22 * This function creates the matrix widget.
23 */
24 CDKMATRIX *newCDKMatrix (CDKSCREEN *cdkscreen,
25 int xplace,
26 int yplace,
27 int rows,
28 int cols,
29 int vrows,
30 int vcols,
31 char *title,
32 char **rowtitles,
33 char **coltitles,
34 int *colwidths,
35 int *colvalues,
36 int rspace,
37 int cspace,
38 chtype filler,
39 int dominant,
40 boolean Box,
41 boolean boxCell,
42 boolean shadow)
43 {
44 CDKMATRIX *matrix = 0;
45 int parentWidth = getmaxx (cdkscreen->window);
46 int parentHeight = getmaxy (cdkscreen->window);
47 int boxHeight = 0;
48 int boxWidth = 0;
49 int xpos = xplace;
50 int ypos = yplace;
51 int maxWidth;
52 int maxRowTitleWidth = 0;
53 int rowSpace = MAXIMUM (0, rspace);
54 int colSpace = MAXIMUM (0, cspace);
55 int begx = 0;
56 int begy = 0;
57 int cellWidth = 0;
58 char **temp = 0;
59 int x, y;
60
61 static const struct { int from; int to; } bindings[] = {
62 { CDK_FORCHAR, KEY_NPAGE },
63 { CDK_BACKCHAR, KEY_PPAGE },
64 };
65
66 if ((matrix = newCDKObject (CDKMATRIX, &my_funcs)) == 0)
67 {
68 return (0);
69 }
70
71 setCDKMatrixBox (matrix, Box);
72
73 /* Make sure that the number of rows/cols/vrows/vcols is not zero. */
74 if (rows <= 0 || cols <= 0 || vrows <= 0 || vcols <= 0)
75 {
76 destroyCDKObject (matrix);
77 return (0);
78 }
79 #if NEW_CDKMATRIX
80 matrix->cell = typeCallocN (WINDOW *, (rows + 1) * (cols + 1));
81 matrix->info = typeCallocN (char *, (rows + 1) * (cols + 1));
82 #endif
83
84 /*
85 * Make sure the number of virtual cells is not larger than
86 * the physical size.
87 */
88 vrows = (vrows > rows ? rows : vrows);
89 vcols = (vcols > cols ? cols : vcols);
90
91 /*
92 * Set these early, since they are used in matrix index computations.
93 */
94 matrix->rows = rows;
95 matrix->cols = cols;
96
97 matrix->colwidths = typeCallocN (int, cols + 1);
98 matrix->colvalues = typeCallocN (int, cols + 1);
99
100 matrix->coltitle = typeCallocN (chtype *, cols + 1);
101 matrix->coltitleLen = typeCallocN (int, cols + 1);
102 matrix->coltitlePos = typeCallocN (int, cols + 1);
103
104 matrix->rowtitle = typeCallocN (chtype *, rows + 1);
105 matrix->rowtitleLen = typeCallocN (int, rows + 1);
106 matrix->rowtitlePos = typeCallocN (int, rows + 1);
107
108 /*
109 * Count the number of lines in the title (see setCdkTitle).
110 */
111 temp = CDKsplitString (title, '\n');
112 TitleLinesOf (matrix) = CDKcountStrings (temp);
113 CDKfreeStrings (temp);
114
115 /* Determine the height of the box. */
116 if (vrows == 1)
117 {
118 boxHeight = 6 + TitleLinesOf (matrix);
119 }
120 else
121 {
122 if (rowSpace == 0)
123 {
124 boxHeight = (6 + TitleLinesOf (matrix) +
125 ((vrows - 1) * 2));
126 }
127 else
128 {
129 boxHeight = (3 + TitleLinesOf (matrix) +
130 (vrows * 3) + ((vrows - 1) * (rowSpace - 1)));
131 }
132 }
133
134 /* Determine the maximum row title width */
135 for (x = 1; x <= rows; x++)
136 {
137 matrix->rowtitle[x] = char2Chtype (rowtitles[x],
138 &matrix->rowtitleLen[x],
139 &matrix->rowtitlePos[x]);
140 maxRowTitleWidth = MAXIMUM (maxRowTitleWidth, matrix->rowtitleLen[x]);
141 }
142 matrix->maxrt = maxRowTitleWidth + 2;
143
144 /* We need to rejustify the row title cell info. */
145 for (x = 1; x <= rows; x++)
146 {
147 matrix->rowtitlePos[x] = justifyString (matrix->maxrt,
148 matrix->rowtitleLen[x],
149 matrix->rowtitlePos[x]);
150 }
151
152 /* Determine the width of the matrix. */
153 maxWidth = 2 + matrix->maxrt;
154 for (x = 1; x <= vcols; x++)
155 {
156 maxWidth += colwidths[x] + 2 + colSpace;
157 }
158 maxWidth -= (colSpace - 1);
159 boxWidth = MAXIMUM (maxWidth, boxWidth);
160
161 boxWidth = setCdkTitle (ObjOf (matrix), title, boxWidth);
162
163 /*
164 * Make sure the dimensions of the window didn't
165 * extend beyond the dimensions of the parent window.
166 */
167 boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth);
168 boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight);
169
170 /* Rejustify the x and y positions if we need to. */
171 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
172
173 /* Make the pop-up window. */
174 matrix->win = newwin (boxHeight, boxWidth, ypos, xpos);
175
176 if (matrix->win == 0)
177 {
178 destroyCDKObject (matrix);
179 return (0);
180 }
181
182 /* Make the subwindows in the pop-up. */
183 begx = xpos;
184 begy = ypos + 1 + TitleLinesOf (matrix);
185
186 /* Make the 'empty' 0x0 cell. */
187 MATRIX_CELL (matrix, 0, 0) = subwin (matrix->win, 3, matrix->maxrt, begy, begx);
188 begx += matrix->maxrt + 1;
189
190 /* Make the column titles. */
191 for (x = 1; x <= vcols; x++)
192 {
193 cellWidth = colwidths[x] + 3;
194 MATRIX_CELL (matrix, 0, x) = subwin (matrix->win, 1, cellWidth, begy, begx);
195
196 if (MATRIX_CELL (matrix, 0, x) == 0)
197 {
198 destroyCDKObject (matrix);
199 return (0);
200 }
201 begx += cellWidth + colSpace - 1;
202 }
203 begy++;
204
205 /* Make the main cell body */
206 for (x = 1; x <= vrows; x++)
207 {
208 /* Make the row titles */
209 MATRIX_CELL (matrix, x, 0) = subwin (matrix->win,
210 3, matrix->maxrt,
211 begy, xpos + 1);
212
213 if (MATRIX_CELL (matrix, x, 0) == 0)
214 {
215 destroyCDKObject (matrix);
216 return (0);
217 }
218
219 /* Set the start of the x position. */
220 begx = xpos + matrix->maxrt + 1;
221
222 /* Make the cells */
223 for (y = 1; y <= vcols; y++)
224 {
225 cellWidth = colwidths[y] + 3;
226 MATRIX_CELL (matrix, x, y) = subwin (matrix->win,
227 3, cellWidth,
228 begy, begx);
229
230 if (MATRIX_CELL (matrix, x, y) == 0)
231 {
232 destroyCDKObject (matrix);
233 return (0);
234 }
235 begx += cellWidth + colSpace - 1;
236 keypad (MATRIX_CELL (matrix, x, y), TRUE);
237 }
238 begy += rowSpace + 2;
239 }
240 keypad (matrix->win, TRUE);
241
242 /* Copy the titles into the structure. */
243 for (x = 1; x <= cols; x++)
244 {
245 matrix->coltitle[x] = char2Chtype (coltitles[x],
246 &matrix->coltitleLen[x],
247 &matrix->coltitlePos[x]);
248 matrix->coltitlePos[x] = (BorderOf (matrix) +
249 justifyString (colwidths[x],
250 matrix->coltitleLen[x],
251 matrix->coltitlePos[x]));
252 matrix->colwidths[x] = colwidths[x];
253 }
254
255 /* Keep the rest of the info. */
256 ScreenOf (matrix) = cdkscreen;
257 ObjOf (matrix)->acceptsFocus = TRUE;
258 ObjOf (matrix)->inputWindow = matrix->win;
259 matrix->parent = cdkscreen->window;
260 matrix->vrows = vrows;
261 matrix->vcols = vcols;
262 matrix->boxWidth = boxWidth;
263 matrix->boxHeight = boxHeight;
264 matrix->rowSpace = rowSpace;
265 matrix->colSpace = colSpace;
266 matrix->filler = filler;
267 matrix->dominant = dominant;
268 matrix->row = 1;
269 matrix->col = 1;
270 matrix->crow = 1;
271 matrix->ccol = 1;
272 matrix->trow = 1;
273 matrix->lcol = 1;
274 matrix->oldcrow = 1;
275 matrix->oldccol = 1;
276 matrix->oldvrow = 1;
277 matrix->oldvcol = 1;
278 initExitType (matrix);
279 matrix->boxCell = boxCell;
280 matrix->shadow = shadow;
281 matrix->highlight = A_REVERSE;
282 matrix->callbackfn = CDKMatrixCallBack;
283
284 /* Make room for the cell information. */
285 for (x = 1; x <= rows; x++)
286 {
287 for (y = 1; y <= cols; y++)
288 {
289 MATRIX_INFO (matrix, x, y) = typeCallocN (char, (colwidths[y] + 1));
290 matrix->colvalues[y] = colvalues[y];
291 matrix->colwidths[y] = colwidths[y];
292 }
293 }
294
295 /* Do we want a shadow??? */
296 if (shadow)
297 {
298 matrix->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
299 }
300
301 /* Setup the key bindings. */
302 for (x = 0; x < (int)SIZEOF (bindings); ++x)
303 bindCDKObject (vMATRIX, matrix,
304 bindings[x].from, getcCDKBind,
305 (void *)(long)bindings[x].to);
306
307 /* Register this baby. */
308 registerCDKObject (cdkscreen, vMATRIX, matrix);
309
310 /* Return the matrix pointer */
311 return (matrix);
312 }
313
314 /*
315 * This activates the matrix.
316 */
317 int activateCDKMatrix (CDKMATRIX *matrix, chtype *actions)
318 {
319 int ret;
320
321 /* Draw the matrix */
322 drawCDKMatrix (matrix, ObjOf (matrix)->box);
323
324 if (actions == 0)
325 {
326 chtype input = 0;
327 boolean functionKey;
328
329 for (;;)
330 {
331 ObjOf (matrix)->inputWindow = MATRIX_CELL (matrix, matrix->crow, matrix->ccol);
332 keypad (ObjOf (matrix)->inputWindow, TRUE);
333 input = getchCDKObject (ObjOf (matrix), &functionKey);
334
335 /* Inject the character into the widget. */
336 ret = injectCDKMatrix (matrix, input);
337 if (matrix->exitType != vEARLY_EXIT)
338 {
339 return ret;
340 }
341 }
342 }
343 else
344 {
345 int length = chlen (actions);
346 int x = 0;
347
348 /* Inject each character one at a time. */
349 for (x = 0; x < length; x++)
350 {
351 ret = injectCDKMatrix (matrix, actions[x]);
352 if (matrix->exitType != vEARLY_EXIT)
353 {
354 return ret;
355 }
356 }
357 }
358
359 /* Set the exit type and exit. */
360 setExitType (matrix, 0);
361 return -1;
362 }
363
364 /*
365 * This injects a single character into the matrix widget.
366 */
367 static int _injectCDKMatrix (CDKOBJS *object, chtype input)
368 {
369 CDKMATRIX *matrix = (CDKMATRIX *)object;
370 int refreshCells = FALSE;
371 int movedCell = FALSE;
372 int charcount = (int)strlen (MATRIX_INFO (matrix, matrix->row, matrix->col));
373 int ppReturn = 1;
374 int x, y, infolen;
375 int ret = unknownInt;
376 bool complete = FALSE;
377
378 /* Set the exit type. */
379 setExitType (matrix, 0);
380
381 /* Move the cursor to the correct position within the cell. */
382 if (matrix->colwidths[matrix->ccol] == 1)
383 {
384 wmove (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), 1, 1);
385 }
386 else
387 {
388 wmove (MATRIX_CELL (matrix, matrix->crow, matrix->ccol),
389 1,
390 (int)strlen (MATRIX_INFO (matrix, matrix->row, matrix->col)) + 1);
391 }
392
393 /* Put the focus on the current cell */
394 attrbox (MATRIX_CELL (matrix, matrix->crow, matrix->ccol),
395 ACS_ULCORNER, ACS_URCORNER,
396 ACS_LLCORNER, ACS_LRCORNER,
397 ACS_HLINE, ACS_VLINE,
398 A_BOLD);
399 wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol));
400 highlightCDKMatrixCell (matrix);
401
402 /* Check if there is a pre-process function to be called. */
403 if (PreProcessFuncOf (matrix) != 0)
404 {
405 /* Call the pre-process function. */
406 ppReturn = PreProcessFuncOf (matrix) (vMATRIX,
407 matrix,
408 PreProcessDataOf (matrix),
409 input);
410 }
411
412 /* Should we continue? */
413 if (ppReturn != 0)
414 {
415 /* Check the key bindings. */
416 if (checkCDKObjectBind (vMATRIX, matrix, input) != 0)
417 {
418 checkEarlyExit (matrix);
419 complete = TRUE;
420 }
421 else
422 {
423 switch (input)
424 {
425 case CDK_TRANSPOSE:
426 break;
427
428 case KEY_HOME:
429 break;
430
431 case KEY_END:
432 break;
433
434 case KEY_BACKSPACE:
435 case KEY_DC:
436 if (matrix->colvalues[matrix->col] == vVIEWONLY || charcount <= 0)
437 {
438 Beep ();
439 }
440 else
441 {
442 charcount--;
443 mvwdelch (MATRIX_CELL (matrix, matrix->crow, matrix->ccol),
444 1, charcount + 1);
445 mvwinsch (MATRIX_CELL (matrix, matrix->crow, matrix->ccol),
446 1, charcount + 1,
447 matrix->filler);
448 wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol));
449 MATRIX_INFO (matrix, matrix->row, matrix->col)[charcount] = '\0';
450 }
451 break;
452
453 case KEY_RIGHT:
454 case KEY_TAB:
455 if (matrix->ccol != matrix->vcols)
456 {
457 /* We are moving to the right... */
458 matrix->col++;
459 matrix->ccol++;
460 movedCell = TRUE;
461 }
462 else
463 {
464 /* We have to shift the columns to the right. */
465 if (matrix->col != matrix->cols)
466 {
467 matrix->lcol++;
468 matrix->col++;
469
470 /* Redraw the column titles. */
471 if (matrix->rows > matrix->vrows)
472 {
473 redrawTitles (matrix, FALSE, TRUE);
474 }
475 refreshCells = TRUE;
476 movedCell = TRUE;
477 }
478 else
479 {
480 /* We are at the far right column, we need */
481 /* shift down one row, if we can. */
482 if (matrix->row == matrix->rows)
483 {
484 Beep ();
485 }
486 else
487 {
488 /* Set up the columns info. */
489 matrix->col = 1;
490 matrix->lcol = 1;
491 matrix->ccol = 1;
492
493 /* Shift the rows... */
494 if (matrix->crow != matrix->vrows)
495 {
496 matrix->row++;
497 matrix->crow++;
498 }
499 else
500 {
501 matrix->row++;
502 matrix->trow++;
503 }
504 redrawTitles (matrix, TRUE, TRUE);
505 refreshCells = TRUE;
506 movedCell = TRUE;
507 }
508 }
509 }
510 break;
511
512 case KEY_LEFT:
513 case KEY_BTAB:
514 if (matrix->ccol != 1)
515 {
516 /* We are moving to the left... */
517 matrix->col--;
518 matrix->ccol--;
519 movedCell = TRUE;
520 }
521 else
522 {
523 /* Are we at the far left??? */
524 if (matrix->lcol != 1)
525 {
526 matrix->lcol--;
527 matrix->col--;
528
529 /* Redraw the column titles. */
530 if (matrix->cols > matrix->vcols)
531 {
532 redrawTitles (matrix, FALSE, TRUE);
533 }
534 refreshCells = TRUE;
535 movedCell = TRUE;
536 }
537 else
538 {
539 /* Shift up one line if we can... */
540 if (matrix->row == 1)
541 {
542 Beep ();
543 }
544 else
545 {
546 /* Set up the columns info. */
547 matrix->col = matrix->cols;
548 matrix->lcol = matrix->cols - matrix->vcols + 1;
549 matrix->ccol = matrix->vcols;
550
551 /* Shift the rows... */
552 if (matrix->crow != 1)
553 {
554 matrix->row--;
555 matrix->crow--;
556 }
557 else
558 {
559 matrix->row--;
560 matrix->trow--;
561 }
562 redrawTitles (matrix, TRUE, TRUE);
563 refreshCells = TRUE;
564 movedCell = TRUE;
565 }
566 }
567 }
568 break;
569
570 case KEY_UP:
571 if (matrix->crow != 1)
572 {
573 matrix->row--;
574 matrix->crow--;
575 movedCell = TRUE;
576 }
577 else
578 {
579 if (matrix->trow != 1)
580 {
581 matrix->trow--;
582 matrix->row--;
583
584 /* Redraw the row titles. */
585 if (matrix->rows > matrix->vrows)
586 {
587 redrawTitles (matrix, TRUE, FALSE);
588 }
589 refreshCells = TRUE;
590 movedCell = TRUE;
591 }
592 else
593 {
594 Beep ();
595 }
596 }
597 break;
598
599 case KEY_DOWN:
600 if (matrix->crow != matrix->vrows)
601 {
602 matrix->row++;
603 matrix->crow++;
604 movedCell = TRUE;
605 }
606 else
607 {
608 if ((matrix->trow + matrix->vrows - 1) != matrix->rows)
609 {
610 matrix->trow++;
611 matrix->row++;
612
613 /* Redraw the titles. */
614 if (matrix->rows > matrix->vrows)
615 {
616 redrawTitles (matrix, TRUE, FALSE);
617 }
618 refreshCells = TRUE;
619 movedCell = TRUE;
620 }
621 else
622 {
623 Beep ();
624 }
625 }
626 break;
627
628 case KEY_NPAGE:
629 if (matrix->rows > matrix->vrows)
630 {
631 if ((matrix->trow + ((matrix->vrows - 1) * 2)) <= matrix->rows)
632 {
633 matrix->trow += matrix->vrows - 1;
634 matrix->row += matrix->vrows - 1;
635 redrawTitles (matrix, TRUE, FALSE);
636 refreshCells = TRUE;
637 movedCell = TRUE;
638 }
639 else
640 {
641 Beep ();
642 }
643 }
644 else
645 {
646 Beep ();
647 }
648 break;
649
650 case KEY_PPAGE:
651 if (matrix->rows > matrix->vrows)
652 {
653 if ((matrix->trow - ((matrix->vrows - 1) * 2)) >= 1)
654 {
655 matrix->trow -= matrix->vrows - 1;
656 matrix->row -= matrix->vrows - 1;
657 redrawTitles (matrix, TRUE, FALSE);
658 refreshCells = TRUE;
659 movedCell = TRUE;
660 }
661 else
662 {
663 Beep ();
664 }
665 }
666 else
667 {
668 Beep ();
669 }
670 break;
671
672 case CTRL ('G'):
673 jumpToCell (matrix, -1, -1);
674 drawCDKMatrix (matrix, ObjOf (matrix)->box);
675 break;
676
677 case CDK_PASTE:
678 if (GPasteBuffer == 0 ||
679 (int)strlen (GPasteBuffer) > matrix->colwidths[matrix->ccol])
680 {
681 Beep ();
682 }
683 else
684 {
685 strcpy (MATRIX_INFO (matrix,
686 matrix->trow + matrix->crow - 1,
687 matrix->lcol + matrix->ccol - 1),
688 GPasteBuffer);
689 drawCDKMatrixCell (matrix,
690 matrix->crow,
691 matrix->ccol,
692 matrix->row,
693 matrix->col,
694 A_NORMAL,
695 matrix->boxCell);
696 }
697 break;
698
699 case CDK_COPY:
700 freeChar (GPasteBuffer);
701 GPasteBuffer = copyChar (MATRIX_INFO (matrix,
702 matrix->trow +
703 matrix->crow - 1,
704 matrix->lcol +
705 matrix->ccol - 1));
706 break;
707
708 case CDK_CUT:
709 freeChar (GPasteBuffer);
710 GPasteBuffer = copyChar (MATRIX_INFO (matrix,
711 matrix->trow +
712 matrix->crow - 1,
713 matrix->lcol +
714 matrix->ccol - 1));
715 cleanCDKMatrixCell (matrix,
716 matrix->trow + matrix->crow - 1,
717 matrix->lcol + matrix->ccol - 1);
718 drawCDKMatrixCell (matrix,
719 matrix->crow,
720 matrix->ccol,
721 matrix->row,
722 matrix->col,
723 A_NORMAL,
724 matrix->boxCell);
725 break;
726
727 case CDK_ERASE:
728 cleanCDKMatrixCell (matrix,
729 matrix->trow + matrix->crow - 1,
730 matrix->lcol + matrix->ccol - 1);
731 drawCDKMatrixCell (matrix,
732 matrix->crow,
733 matrix->ccol,
734 matrix->row,
735 matrix->col,
736 A_NORMAL,
737 matrix->boxCell);
738 break;
739
740 case KEY_ENTER:
741 if (!matrix->boxCell)
742 {
743 attrbox (MATRIX_CELL (matrix, matrix->oldcrow, matrix->oldccol),
744 ' ', ' ',
745 ' ', ' ',
746 ' ', ' ',
747 A_NORMAL);
748 }
749 else
750 {
751 drawCDKMatrixCell (matrix,
752 matrix->oldcrow,
753 matrix->oldccol,
754 matrix->oldvrow,
755 matrix->oldvcol,
756 A_NORMAL,
757 matrix->boxCell);
758 }
759 wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol));
760 setExitType (matrix, input);
761 ret = 1;
762 complete = TRUE;
763 break;
764
765 case KEY_ESC:
766 if (!matrix->boxCell)
767 {
768 attrbox (MATRIX_CELL (matrix, matrix->oldcrow, matrix->oldccol),
769 ' ', ' ',
770 ' ', ' ',
771 ' ', ' ',
772 A_NORMAL);
773 }
774 else
775 {
776 drawCDKMatrixCell (matrix,
777 matrix->oldcrow,
778 matrix->oldccol,
779 matrix->oldvrow,
780 matrix->oldvcol,
781 A_NORMAL,
782 matrix->boxCell);
783 }
784 wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol));
785 setExitType (matrix, input);
786 complete = TRUE;
787 break;
788
789 case CDK_REFRESH:
790 eraseCDKScreen (ScreenOf (matrix));
791 refreshCDKScreen (ScreenOf (matrix));
792 break;
793
794 default:
795 (matrix->callbackfn) (matrix, input);
796 break;
797 }
798 }
799
800 if (!complete)
801 {
802 /* Did we change cells? */
803 if (movedCell)
804 {
805 /* un-highlight the old box */
806 if (!matrix->boxCell)
807 {
808 attrbox (MATRIX_CELL (matrix, matrix->oldcrow, matrix->oldccol),
809 ' ', ' ',
810 ' ', ' ',
811 ' ', ' ',
812 A_NORMAL);
813 }
814 else
815 {
816 drawCDKMatrixCell (matrix,
817 matrix->oldcrow,
818 matrix->oldccol,
819 matrix->oldvrow,
820 matrix->oldvcol,
821 0,
822 matrix->boxCell);
823 }
824 wrefresh (MATRIX_CELL (matrix, matrix->oldcrow, matrix->oldccol));
825
826 /* Highlight the new cell. */
827 attrbox (MATRIX_CELL (matrix, matrix->crow, matrix->ccol),
828 ACS_ULCORNER, ACS_URCORNER,
829 ACS_LLCORNER, ACS_LRCORNER,
830 ACS_HLINE, ACS_VLINE,
831 A_BOLD);
832 wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol));
833 highlightCDKMatrixCell (matrix);
834 }
835
836 /* Redraw each cell. */
837 if (refreshCells)
838 {
839 /* Fill in the cells. */
840 for (x = 1; x <= matrix->vrows; x++)
841 {
842 for (y = 1; y <= matrix->vcols; y++)
843 {
844 drawCDKMatrixCell (matrix, x, y,
845 matrix->trow + x - 1,
846 matrix->lcol + y - 1,
847 0,
848 matrix->boxCell);
849 }
850 }
851
852 /* Highlight the current cell. */
853 attrbox (MATRIX_CELL (matrix, matrix->crow, matrix->ccol),
854 ACS_ULCORNER, ACS_URCORNER,
855 ACS_LLCORNER, ACS_LRCORNER,
856 ACS_HLINE, ACS_VLINE,
857 A_BOLD);
858 wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol));
859 highlightCDKMatrixCell (matrix);
860 }
861
862 /* Move to the correct position in the cell. */
863 if (refreshCells || movedCell)
864 {
865 if (matrix->colwidths[matrix->ccol] == 1)
866 {
867 wmove (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), 1, 1);
868 }
869 else
870 {
871 infolen = (int)strlen (MATRIX_INFO (matrix,
872 matrix->trow +
873 matrix->crow - 1,
874 matrix->lcol +
875 matrix->ccol - 1));
876 wmove (MATRIX_CELL (matrix, matrix->crow, matrix->ccol),
877 1,
878 infolen + 1);
879 }
880 wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol));
881 }
882
883 /* Should we call a post-process? */
884 if (PostProcessFuncOf (matrix) != 0)
885 {
886 PostProcessFuncOf (matrix) (vMATRIX,
887 matrix,
888 PostProcessDataOf (matrix),
889 input);
890 }
891 }
892 }
893
894 if (!complete)
895 {
896 /* Set the variables we need. */
897 matrix->oldcrow = matrix->crow;
898 matrix->oldccol = matrix->ccol;
899 matrix->oldvrow = matrix->row;
900 matrix->oldvcol = matrix->col;
901
902 /* Set the exit type and exit. */
903 setExitType (matrix, 0);
904 }
905
906 ResultOf (matrix).valueInt = ret;
907 return (ret != unknownInt);
908 }
909
910 /*
911 * This allows the programmer to define their own key mappings.
912 */
913 static void CDKMatrixCallBack (CDKMATRIX *matrix, chtype input)
914 {
915 EDisplayType disptype = (EDisplayType) matrix->colvalues[matrix->col];
916 int plainchar = filterByDisplayType (disptype, input);
917 int charcount = (int)strlen (MATRIX_INFO (matrix, matrix->row, matrix->col));
918
919 if (plainchar == ERR)
920 {
921 Beep ();
922 }
923 else if (charcount == matrix->colwidths[matrix->col])
924 {
925 Beep ();
926 }
927 else
928 {
929 /* Update the screen. */
930 wmove (MATRIX_CELL (matrix, matrix->crow, matrix->ccol),
931 1,
932 (int)strlen (MATRIX_INFO (matrix, matrix->row, matrix->col)) + 1);
933 waddch (MATRIX_CELL (matrix, matrix->crow, matrix->ccol),
934 ((isHiddenDisplayType (disptype))
935 ? (int)matrix->filler
936 : plainchar));
937 wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol));
938
939 /* Update the character pointer. */
940 MATRIX_INFO (matrix, matrix->row, matrix->col)[charcount++] = plainchar;
941 MATRIX_INFO (matrix, matrix->row, matrix->col)[charcount] = '\0';
942 }
943 }
944
945 /*
946 * Highlight the new field.
947 */
948 static void highlightCDKMatrixCell (CDKMATRIX *matrix)
949 {
950 EDisplayType disptype = (EDisplayType) matrix->colvalues[matrix->col];
951 chtype highlight = matrix->highlight;
952 int x = 0;
953 int infolen = (int)strlen (MATRIX_INFO (matrix, matrix->row, matrix->col));
954
955 /*
956 * Given the dominance of the colors/attributes, we need to set the
957 * current cell attribute.
958 */
959 if (matrix->dominant == ROW)
960 {
961 highlight = matrix->rowtitle[matrix->crow][0] & A_ATTRIBUTES;
962 }
963 else if (matrix->dominant == COL)
964 {
965 highlight = matrix->coltitle[matrix->ccol][0] & A_ATTRIBUTES;
966 }
967
968 /* If the column is only one char. */
969 for (x = 1; x <= matrix->colwidths[matrix->ccol]; x++)
970 {
971 chtype ch = (((x <= infolen) && !isHiddenDisplayType (disptype))
972 ? CharOf (MATRIX_INFO (matrix,
973 matrix->row,
974 matrix->col)[x - 1])
975 : matrix->filler);
976
977 mvwaddch (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), 1, x, ch | highlight);
978 }
979 wmove (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), 1, infolen + 1);
980 wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol));
981 }
982
983 /*
984 * This moves the matrix field to the given location.
985 */
986 static void _moveCDKMatrix (CDKOBJS *object,
987 int xplace,
988 int yplace,
989 boolean relative,
990 boolean refresh_flag)
991 {
992 CDKMATRIX *matrix = (CDKMATRIX *)object;
993 int currentX = getbegx (matrix->win);
994 int currentY = getbegy (matrix->win);
995 int xpos = xplace;
996 int ypos = yplace;
997 int xdiff = 0;
998 int ydiff = 0;
999 int x, y;
1000
1001 /*
1002 * If this is a relative move, then we will adjust where we want
1003 * to move to.
1004 */
1005 if (relative)
1006 {
1007 xpos = getbegx (matrix->win) + xplace;
1008 ypos = getbegy (matrix->win) + yplace;
1009 }
1010
1011 /* Adjust the window if we need to. */
1012 alignxy (WindowOf (matrix), &xpos, &ypos, matrix->boxWidth, matrix->boxHeight);
1013
1014 /* Get the difference. */
1015 xdiff = currentX - xpos;
1016 ydiff = currentY - ypos;
1017
1018 /* Move the window to the new location. */
1019 moveCursesWindow (matrix->win, -xdiff, -ydiff);
1020
1021 for (x = 0; x <= matrix->vrows; x++)
1022 {
1023 for (y = 0; y <= matrix->vcols; y++)
1024 {
1025 moveCursesWindow (MATRIX_CELL (matrix, x, y), -xdiff, -ydiff);
1026 }
1027 }
1028
1029 moveCursesWindow (matrix->shadowWin, -xdiff, -ydiff);
1030
1031 /* Touch the windows so they 'move'. */
1032 refreshCDKWindow (WindowOf (matrix));
1033
1034 /* Redraw the window, if they asked for it. */
1035 if (refresh_flag)
1036 {
1037 drawCDKMatrix (matrix, ObjOf (matrix)->box);
1038 }
1039 }
1040
1041 /*
1042 * This draws a cell within a matrix.
1043 */
1044 static void drawCDKMatrixCell (CDKMATRIX *matrix,
1045 int row,
1046 int col,
1047 int vrow,
1048 int vcol,
1049 chtype attr,
1050 boolean Box)
1051 {
1052 WINDOW *cell = MATRIX_CELL (matrix, row, col);
1053 EDisplayType disptype = (EDisplayType) matrix->colvalues[matrix->col];
1054 chtype highlight = matrix->filler & A_ATTRIBUTES;
1055 int rows = matrix->vrows;
1056 int cols = matrix->vcols;
1057 int infolen = (int)strlen (MATRIX_INFO (matrix, vrow, vcol));
1058 int x;
1059
1060 /*
1061 * Given the dominance of the colors/attributes, we need to set the
1062 * current cell attribute.
1063 */
1064 if (matrix->dominant == ROW)
1065 {
1066 highlight = matrix->rowtitle[row][0] & A_ATTRIBUTES;
1067 }
1068 else if (matrix->dominant == COL)
1069 {
1070 highlight = matrix->coltitle[col][0] & A_ATTRIBUTES;
1071 }
1072
1073 /* Draw in the cell info. */
1074 for (x = 1; x <= matrix->colwidths[col]; x++)
1075 {
1076 chtype ch = (((x <= infolen) && !isHiddenDisplayType (disptype))
1077 ? (CharOf (MATRIX_INFO (matrix, vrow, vcol)[x - 1]) | highlight)
1078 : matrix->filler);
1079
1080 mvwaddch (cell, 1, x, ch | highlight);
1081 }
1082 wmove (cell, 1, infolen + 1);
1083 wrefresh (cell);
1084
1085 /* Only draw the box iff the user asked for a box. */
1086 if (!Box)
1087 {
1088 return;
1089 }
1090
1091 /*
1092 * If the value of the column spacing is greater than 0 then these
1093 * are independent boxes.
1094 */
1095 if (matrix->colSpace != 0 && matrix->rowSpace != 0)
1096 {
1097 attrbox (cell,
1098 ACS_ULCORNER, ACS_URCORNER,
1099 ACS_LLCORNER, ACS_LRCORNER,
1100 ACS_HLINE, ACS_VLINE,
1101 attr);
1102 return;
1103 }
1104 if (matrix->colSpace != 0 && matrix->rowSpace == 0)
1105 {
1106 if (row == 1)
1107 {
1108 attrbox (cell,
1109 ACS_ULCORNER, ACS_URCORNER,
1110 ACS_LTEE, ACS_RTEE,
1111 ACS_HLINE, ACS_VLINE,
1112 attr);
1113 return;
1114 }
1115 else if (row > 1 && row < rows)
1116 {
1117 attrbox (cell,
1118 ACS_LTEE, ACS_RTEE,
1119 ACS_LTEE, ACS_RTEE,
1120 ACS_HLINE, ACS_VLINE,
1121 attr);
1122 return;
1123 }
1124 else if (row == rows)
1125 {
1126 attrbox (cell,
1127 ACS_LTEE, ACS_RTEE,
1128 ACS_LLCORNER, ACS_LRCORNER,
1129 ACS_HLINE, ACS_VLINE,
1130 attr);
1131 return;
1132 }
1133 }
1134 if (matrix->colSpace == 0 && matrix->rowSpace != 0)
1135 {
1136 if (col == 1)
1137 {
1138 attrbox (cell,
1139 ACS_ULCORNER, ACS_TTEE,
1140 ACS_LLCORNER, ACS_BTEE,
1141 ACS_HLINE, ACS_VLINE,
1142 attr);
1143 return;
1144 }
1145 else if (col > 1 && col < cols)
1146 {
1147 attrbox (cell,
1148 ACS_TTEE, ACS_TTEE,
1149 ACS_BTEE, ACS_BTEE,
1150 ACS_HLINE, ACS_VLINE,
1151 attr);
1152 return;
1153 }
1154 else if (col == cols)
1155 {
1156 attrbox (cell,
1157 ACS_TTEE, ACS_URCORNER,
1158 ACS_BTEE, ACS_LRCORNER,
1159 ACS_HLINE, ACS_VLINE,
1160 attr);
1161 return;
1162 }
1163 }
1164
1165 /* Start drawing the matrix. */
1166 if (row == 1)
1167 {
1168 if (col == 1)
1169 {
1170 /* Draw the top left corner */
1171 attrbox (cell,
1172 ACS_ULCORNER, ACS_TTEE,
1173 ACS_LTEE, ACS_PLUS,
1174 ACS_HLINE, ACS_VLINE,
1175 attr);
1176 }
1177 else if (col > 1 && col < cols)
1178 {
1179 /* Draw the top middle box */
1180 attrbox (cell,
1181 ACS_TTEE, ACS_TTEE,
1182 ACS_PLUS, ACS_PLUS,
1183 ACS_HLINE, ACS_VLINE,
1184 attr);
1185 }
1186 else if (col == cols)
1187 {
1188 /* Draw the top right corner */
1189 attrbox (cell,
1190 ACS_TTEE, ACS_URCORNER,
1191 ACS_PLUS, ACS_RTEE,
1192 ACS_HLINE, ACS_VLINE,
1193 attr);
1194 }
1195 }
1196 else if (row > 1 && row < rows)
1197 {
1198 if (col == 1)
1199 {
1200 /* Draw the middle left box */
1201 attrbox (cell,
1202 ACS_LTEE, ACS_PLUS,
1203 ACS_LTEE, ACS_PLUS,
1204 ACS_HLINE, ACS_VLINE,
1205 attr);
1206 }
1207 else if (col > 1 && col < cols)
1208 {
1209 /* Draw the middle box */
1210 attrbox (cell,
1211 ACS_PLUS, ACS_PLUS,
1212 ACS_PLUS, ACS_PLUS,
1213 ACS_HLINE, ACS_VLINE,
1214 attr);
1215 }
1216 else if (col == cols)
1217 {
1218 /* Draw the middle right box */
1219 attrbox (cell,
1220 ACS_PLUS, ACS_RTEE,
1221 ACS_PLUS, ACS_RTEE,
1222 ACS_HLINE, ACS_VLINE,
1223 attr);
1224 }
1225 }
1226 else if (row == rows)
1227 {
1228 if (col == 1)
1229 {
1230 /* Draw the bottom left corner */
1231 attrbox (cell,
1232 ACS_LTEE, ACS_PLUS,
1233 ACS_LLCORNER, ACS_BTEE,
1234 ACS_HLINE, ACS_VLINE,
1235 attr);
1236 }
1237 else if (col > 1 && col < cols)
1238 {
1239 /* Draw the bottom middle box */
1240 attrbox (cell,
1241 ACS_PLUS, ACS_PLUS,
1242 ACS_BTEE, ACS_BTEE,
1243 ACS_HLINE, ACS_VLINE,
1244 attr);
1245 }
1246 else if (col == cols)
1247 {
1248 /* Draw the bottom right corner */
1249 attrbox (cell,
1250 ACS_PLUS, ACS_RTEE,
1251 ACS_BTEE, ACS_LRCORNER,
1252 ACS_HLINE, ACS_VLINE,
1253 attr);
1254 }
1255 }
1256
1257 /* Highlight the current cell. */
1258 attrbox (MATRIX_CELL (matrix, matrix->crow, matrix->ccol),
1259 ACS_ULCORNER, ACS_URCORNER,
1260 ACS_LLCORNER, ACS_LRCORNER,
1261 ACS_HLINE, ACS_VLINE,
1262 A_BOLD);
1263 wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol));
1264 highlightCDKMatrixCell (matrix);
1265 }
1266
1267 /*
1268 * This function draws the matrix widget.
1269 */
1270 static void _drawCDKMatrix (CDKOBJS *object, boolean Box)
1271 {
1272 CDKMATRIX *matrix = (CDKMATRIX *)object;
1273 int x, y;
1274
1275 /* Did we ask for a shadow??? */
1276 if (matrix->shadowWin != 0)
1277 {
1278 drawShadow (matrix->shadowWin);
1279 }
1280
1281 /* Should we box the matrix??? */
1282 if (Box)
1283 {
1284 drawObjBox (matrix->win, ObjOf (matrix));
1285 }
1286
1287 drawCdkTitle (matrix->win, object);
1288
1289 wrefresh (matrix->win);
1290
1291 /* Draw in the column titles. */
1292 for (x = 1; x <= matrix->vcols; x++)
1293 {
1294 writeChtype (MATRIX_CELL (matrix, 0, x),
1295 matrix->coltitlePos[matrix->lcol + x - 1], 0,
1296 matrix->coltitle[matrix->lcol + x - 1],
1297 HORIZONTAL,
1298 0, matrix->coltitleLen[matrix->lcol + x - 1]);
1299 wrefresh (MATRIX_CELL (matrix, 0, x));
1300 }
1301
1302 /* Fill in the rest of the matrix. */
1303 for (x = 1; x <= matrix->vrows; x++)
1304 {
1305 /* Draw in the row titles */
1306 writeChtype (MATRIX_CELL (matrix, x, 0),
1307 matrix->rowtitlePos[matrix->trow + x - 1], 1,
1308 matrix->rowtitle[matrix->trow + x - 1],
1309 HORIZONTAL,
1310 0, matrix->rowtitleLen[matrix->trow + x - 1]);
1311 wrefresh (MATRIX_CELL (matrix, x, 0));
1312
1313 /* Draw in the cells.. */
1314 for (y = 1; y <= matrix->vcols; y++)
1315 {
1316 drawCDKMatrixCell (matrix, x, y,
1317 matrix->trow + x - 1,
1318 matrix->lcol + y - 1,
1319 A_NORMAL,
1320 matrix->boxCell);
1321 }
1322 }
1323
1324 /* Highlight the current cell. */
1325 attrbox (MATRIX_CELL (matrix, matrix->crow, matrix->ccol),
1326 ACS_ULCORNER, ACS_URCORNER,
1327 ACS_LLCORNER, ACS_LRCORNER,
1328 ACS_HLINE, ACS_VLINE,
1329 A_BOLD);
1330 wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol));
1331 highlightCDKMatrixCell (matrix);
1332 }
1333
1334 /*
1335 * This function destroys the matrix widget.
1336 */
1337 static void _destroyCDKMatrix (CDKOBJS *object)
1338 {
1339 if (object != 0)
1340 {
1341 CDKMATRIX *matrix = (CDKMATRIX *)object;
1342 int x = 0;
1343 int y = 0;
1344
1345 cleanCdkTitle (object);
1346
1347 /* Clear out the col titles. */
1348 for (x = 1; x <= matrix->cols; x++)
1349 {
1350 freeChtype (matrix->coltitle[x]);
1351 }
1352
1353 /* Clear out the row titles. */
1354 for (x = 1; x <= matrix->rows; x++)
1355 {
1356 freeChtype (matrix->rowtitle[x]);
1357 }
1358
1359 /* Clear out the matrix cells. */
1360 for (x = 1; x <= matrix->rows; x++)
1361 {
1362 for (y = 1; y <= matrix->cols; y++)
1363 {
1364 freeChar (MATRIX_INFO (matrix, x, y));
1365 }
1366 }
1367
1368 /* Clear the matrix windows. */
1369 deleteCursesWindow (MATRIX_CELL (matrix, 0, 0));
1370 for (x = 1; x <= matrix->vrows; x++)
1371 {
1372 deleteCursesWindow (MATRIX_CELL (matrix, x, 0));
1373 }
1374 for (x = 1; x <= matrix->vcols; x++)
1375 {
1376 deleteCursesWindow (MATRIX_CELL (matrix, 0, x));
1377 }
1378 for (x = 1; x <= matrix->vrows; x++)
1379 {
1380 for (y = 1; y <= matrix->vcols; y++)
1381 {
1382 deleteCursesWindow (MATRIX_CELL (matrix, x, y));
1383 }
1384 }
1385
1386 #if NEW_CDKMATRIX
1387 freeChecked (matrix->cell);
1388 freeChecked (matrix->info);
1389 #endif
1390
1391 freeChecked (matrix->colwidths);
1392 freeChecked (matrix->colvalues);
1393
1394 freeChecked (matrix->coltitle);
1395 freeChecked (matrix->coltitleLen);
1396 freeChecked (matrix->coltitlePos);
1397
1398 freeChecked (matrix->rowtitle);
1399 freeChecked (matrix->rowtitleLen);
1400 freeChecked (matrix->rowtitlePos);
1401
1402 deleteCursesWindow (matrix->shadowWin);
1403 deleteCursesWindow (matrix->win);
1404
1405 /* Clean the key bindings. */
1406 cleanCDKObjectBindings (vMATRIX, matrix);
1407
1408 /* Unregister this object. */
1409 unregisterCDKObject (vMATRIX, matrix);
1410 }
1411 }
1412
1413 /*
1414 * This function erases the matrix widget from the screen.
1415 */
1416 static void _eraseCDKMatrix (CDKOBJS *object)
1417 {
1418 if (validCDKObject (object))
1419 {
1420 CDKMATRIX *matrix = (CDKMATRIX *)object;
1421 int x = 0;
1422 int y = 0;
1423
1424 /* Clear the matrix cells. */
1425 eraseCursesWindow (MATRIX_CELL (matrix, 0, 0));
1426 for (x = 1; x <= matrix->vrows; x++)
1427 {
1428 eraseCursesWindow (MATRIX_CELL (matrix, x, 0));
1429 }
1430 for (x = 1; x <= matrix->vcols; x++)
1431 {
1432 eraseCursesWindow (MATRIX_CELL (matrix, 0, x));
1433 }
1434 for (x = 1; x <= matrix->vrows; x++)
1435 {
1436 for (y = 1; y <= matrix->vcols; y++)
1437 {
1438 eraseCursesWindow (MATRIX_CELL (matrix, x, y));
1439 }
1440 }
1441 eraseCursesWindow (matrix->shadowWin);
1442 eraseCursesWindow (matrix->win);
1443 }
1444 }
1445
1446 /*
1447 * Set the callback-function.
1448 */
1449 void setCDKMatrixCB (CDKMATRIX *widget, MATRIXCB callback)
1450 {
1451 widget->callbackfn = callback;
1452 }
1453
1454 /*
1455 * This function sets the values of the matrix widget.
1456 */
1457 void setCDKMatrixCells (CDKMATRIX *matrix,
1458 char **info,
1459 int rows,
1460 int maxcols,
1461 int *subSize)
1462 {
1463 int x = 0;
1464 int y = 0;
1465
1466 if (rows > matrix->rows)
1467 rows = matrix->rows;
1468
1469 /* Copy in the new info. */
1470 for (x = 1; x <= rows; x++)
1471 {
1472 for (y = 1; y <= matrix->cols; y++)
1473 {
1474 if (x <= rows && y <= subSize[x])
1475 {
1476 char *source = info[(x * maxcols) + y];
1477
1478 /* Copy in the new information. */
1479 if (source != 0)
1480 {
1481 char *target = MATRIX_INFO (matrix, x, y);
1482
1483 if (target == 0) /* this should not happen... */
1484 {
1485 target = typeCallocN (char, matrix->colwidths[y] + 1);
1486 MATRIX_INFO (matrix, x, y) = target;
1487 }
1488 strncpy (MATRIX_INFO (matrix, x, y),
1489 source,
1490 matrix->colwidths[y]);
1491 }
1492 }
1493 else
1494 cleanCDKMatrixCell (matrix, x, y);
1495 }
1496 }
1497 }
1498
1499 /*
1500 * This sets the widget's box attribute.
1501 */
1502 void setCDKMatrixBox (CDKMATRIX *matrix, boolean Box)
1503 {
1504 ObjOf (matrix)->box = Box;
1505 ObjOf (matrix)->borderSize = Box ? 1 : 0;
1506 }
1507 boolean getCDKMatrixBox (CDKMATRIX *matrix)
1508 {
1509 return ObjOf (matrix)->box;
1510 }
1511
1512 /*
1513 * This cleans out the information cells in the matrix widget.
1514 */
1515 void cleanCDKMatrix (CDKMATRIX *matrix)
1516 {
1517 int x = 0;
1518 int y = 0;
1519
1520 for (x = 1; x <= matrix->rows; x++)
1521 {
1522 for (y = 1; y <= matrix->cols; y++)
1523 {
1524 cleanCDKMatrixCell (matrix, x, y);
1525 }
1526 }
1527 }
1528
1529 /*
1530 * This cleans one cell in the matrix widget.
1531 */
1532 void cleanCDKMatrixCell (CDKMATRIX *matrix, int row, int col)
1533 {
1534 if (row > 0 && row <= matrix->rows &&
1535 col > 0 && col <= matrix->cols)
1536 cleanChar (MATRIX_INFO (matrix, row, col), matrix->colwidths[col], '\0');
1537 }
1538
1539 /*
1540 * This allows us to hyper-warp to a cell.
1541 */
1542 int jumpToCell (CDKMATRIX *matrix, int row, int col)
1543 {
1544 CDKSCALE *scale = 0;
1545 int newRow = row;
1546 int newCol = col;
1547
1548 /*
1549 * Only create the row scale if needed.
1550 */
1551 if ((row == -1) || (row > matrix->rows))
1552 {
1553 /* Create the row scale widget. */
1554 scale = newCDKScale (ScreenOf (matrix),
1555 CENTER, CENTER,
1556 "<C>Jump to which row.",
1557 "</5/B>Row: ", A_NORMAL, 5,
1558 1, 1, matrix->rows, 1, 1, TRUE, FALSE);
1559
1560 /* Activate the scale and get the row. */
1561 newRow = activateCDKScale (scale, 0);
1562 destroyCDKScale (scale);
1563 }
1564
1565 /*
1566 * Only create the column scale if needed.
1567 */
1568 if ((col == -1) || (col > matrix->cols))
1569 {
1570 /* Create the column scale widget. */
1571 scale = newCDKScale (ScreenOf (matrix),
1572 CENTER, CENTER,
1573 "<C>Jump to which column",
1574 "</5/B>Col: ", A_NORMAL, 5,
1575 1, 1, matrix->cols, 1, 1, TRUE, FALSE);
1576
1577 /* Activate the scale and get the column. */
1578 newCol = activateCDKScale (scale, 0);
1579 destroyCDKScale (scale);
1580 }
1581
1582 /* Hyper-warp.... */
1583 if (newRow != matrix->row || newCol != matrix->col)
1584 {
1585 return (moveToCDKMatrixCell (matrix, newRow, newCol));
1586 }
1587 else
1588 {
1589 return 1;
1590 }
1591 }
1592
1593 /*
1594 * This allows us to move to a given cell.
1595 */
1596 int moveToCDKMatrixCell (CDKMATRIX *matrix, int newrow, int newcol)
1597 {
1598 int rowShift = newrow - matrix->row;
1599 int colShift = newcol - matrix->col;
1600
1601 /* Make sure we arent asking to move out of the matrix. */
1602 if (newrow > matrix->rows ||
1603 newcol > matrix->cols ||
1604 newrow <= 0 ||
1605 newcol <= 0)
1606 {
1607 return 0;
1608 }
1609
1610 /* Did we move up/down???? */
1611 if (rowShift > 0)
1612 {
1613 /* We are moving down. */
1614 if (matrix->vrows == matrix->cols)
1615 {
1616 matrix->trow = 1;
1617 matrix->crow = newrow;
1618 matrix->row = newrow;
1619 }
1620 else
1621 {
1622 if ((rowShift + matrix->vrows) < matrix->rows)
1623 {
1624 /* Just shift down by rowShift... */
1625 matrix->trow += rowShift;
1626 matrix->crow = 1;
1627 matrix->row += rowShift;
1628 }
1629 else
1630 {
1631 /* We need to munge with the values... */
1632 matrix->trow = matrix->rows - matrix->vrows + 1;
1633 matrix->crow = ((rowShift + matrix->vrows) - matrix->rows) + 1;
1634 matrix->row = newrow;
1635 }
1636 }
1637 }
1638 else if (rowShift < 0)
1639 {
1640 /* We are moving up. */
1641 if (matrix->vrows == matrix->rows)
1642 {
1643 matrix->trow = 1;
1644 matrix->row = newrow;
1645 matrix->crow = newrow;
1646 }
1647 else
1648 {
1649 if ((rowShift + matrix->vrows) > 1)
1650 {
1651 /* Just shift up by rowShift... */
1652 matrix->trow += rowShift;
1653 matrix->row += rowShift;
1654 matrix->crow = 1;
1655 }
1656 else
1657 {
1658 /* We need to munge with the values... */
1659 matrix->trow = 1;
1660 matrix->crow = 1;
1661 matrix->row = 1;
1662 }
1663 }
1664 }
1665
1666 /* Did we move left/right ???? */
1667 if (colShift > 0)
1668 {
1669 /* We are moving right. */
1670 if (matrix->vcols == matrix->cols)
1671 {
1672 matrix->lcol = 1;
1673 matrix->ccol = newcol;
1674 matrix->col = newcol;
1675 }
1676 else
1677 {
1678 if ((colShift + matrix->vcols) < matrix->cols)
1679 {
1680 matrix->lcol += colShift;
1681 matrix->ccol = 1;
1682 matrix->col += colShift;
1683 }
1684 else
1685 {
1686 /* We need to munge with the values... */
1687 matrix->lcol = matrix->cols - matrix->vcols + 1;
1688 matrix->ccol = ((colShift + matrix->vcols) - matrix->cols) + 1;
1689 matrix->col = newcol;
1690 }
1691 }
1692 }
1693 else if (colShift < 0)
1694 {
1695 /* We are moving left. */
1696 if (matrix->vcols == matrix->cols)
1697 {
1698 matrix->lcol = 1;
1699 matrix->col = newcol;
1700 matrix->ccol = newcol;
1701 }
1702 else
1703 {
1704 if ((colShift + matrix->vcols) > 1)
1705 {
1706 /* Just shift left by colShift... */
1707 matrix->lcol += colShift;
1708 matrix->col += colShift;
1709 matrix->ccol = 1;
1710 }
1711 else
1712 {
1713 matrix->lcol = 1;
1714 matrix->col = 1;
1715 matrix->ccol = 1;
1716 }
1717 }
1718 }
1719
1720 /* Keep the 'old' values around for redrawing sake. */
1721 matrix->oldcrow = matrix->crow;
1722 matrix->oldccol = matrix->ccol;
1723 matrix->oldvrow = matrix->row;
1724 matrix->oldvcol = matrix->col;
1725
1726 /* Lets ... */
1727 return 1;
1728 }
1729
1730 /*
1731 * This redraws the titles indicated...
1732 */
1733 static void redrawTitles (CDKMATRIX *matrix, int rowTitles, int colTitles)
1734 {
1735 int x = 0;
1736
1737 /* Redraw the row titles. */
1738 if (rowTitles)
1739 {
1740 for (x = 1; x <= matrix->vrows; x++)
1741 {
1742 werase (MATRIX_CELL (matrix, x, 0));
1743 writeChtype (MATRIX_CELL (matrix, x, 0),
1744 matrix->rowtitlePos[matrix->trow + x - 1], 1,
1745 matrix->rowtitle[matrix->trow + x - 1],
1746 HORIZONTAL,
1747 0, matrix->rowtitleLen[matrix->trow + x - 1]);
1748 wrefresh (MATRIX_CELL (matrix, x, 0));
1749 }
1750 }
1751
1752 /* Redraw the column titles. */
1753 if (colTitles)
1754 {
1755 for (x = 1; x <= matrix->vcols; x++)
1756 {
1757 werase (MATRIX_CELL (matrix, 0, x));
1758 writeChtype (MATRIX_CELL (matrix, 0, x),
1759 matrix->coltitlePos[matrix->lcol + x - 1], 0,
1760 matrix->coltitle[matrix->lcol + x - 1],
1761 HORIZONTAL,
1762 0, matrix->coltitleLen[matrix->lcol + x - 1]);
1763 wrefresh (MATRIX_CELL (matrix, 0, x));
1764 }
1765 }
1766 }
1767
1768 /*
1769 * This sets the value of a matrix cell.
1770 */
1771 int setCDKMatrixCell (CDKMATRIX *matrix, int row, int col, char *value)
1772 {
1773 /* Make sure the row/col combination is within the matrix. */
1774 if (row > matrix->rows || col > matrix->cols || row <= 0 || col <= 0)
1775 {
1776 return -1;
1777 }
1778
1779 cleanCDKMatrixCell (matrix, row, col);
1780 strncpy (MATRIX_INFO (matrix, row, col), value, matrix->colwidths[col]);
1781 return 1;
1782 }
1783
1784 /*
1785 * This gets the value of a matrix cell.
1786 */
1787 char *getCDKMatrixCell (CDKMATRIX *matrix, int row, int col)
1788 {
1789 /* Make sure the row/col combination is within the matrix. */
1790 if (row > matrix->rows || col > matrix->cols || row <= 0 || col <= 0)
1791 {
1792 return 0;
1793 }
1794 return MATRIX_INFO (matrix, row, col);
1795 }
1796
1797 /*
1798 * This returns the current row/col cell.
1799 */
1800 int getCDKMatrixCol (CDKMATRIX *matrix)
1801 {
1802 return matrix->col;
1803 }
1804 int getCDKMatrixRow (CDKMATRIX *matrix)
1805 {
1806 return matrix->row;
1807 }
1808
1809 /*
1810 * This sets the background attribute of the widget.
1811 */
1812 static void _setBKattrMatrix (CDKOBJS *object, chtype attrib)
1813 {
1814 if (object != 0)
1815 {
1816 CDKMATRIX *widget = (CDKMATRIX *)object;
1817 int x, y;
1818
1819 wbkgd (widget->win, attrib);
1820 for (x = 0; x <= widget->vrows; x++)
1821 {
1822 for (y = 0; y <= widget->vcols; y++)
1823 {
1824 wbkgd (MATRIX_CELL (widget, x, y), attrib);
1825 }
1826 }
1827 }
1828 }
1829
1830 static void _focusCDKMatrix (CDKOBJS *object)
1831 {
1832 CDKMATRIX *widget = (CDKMATRIX *)object;
1833
1834 drawCDKMatrix (widget, ObjOf (widget)->box);
1835 }
1836
1837 static void _unfocusCDKMatrix (CDKOBJS *object)
1838 {
1839 CDKMATRIX *widget = (CDKMATRIX *)object;
1840
1841 drawCDKMatrix (widget, ObjOf (widget)->box);
1842 }
1843
1844 dummyRefreshData (Matrix)
1845
1846 dummySaveData (Matrix)
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:44 $
5 * $Revision: 1.160 $
6 */
7
8 /*
9 * Declare file local prototypes.
10 */
11 static void CDKMentryCallBack (CDKMENTRY *mentry, chtype character);
12
13 DeclareCDKObjects (MENTRY, Mentry, setCdk, String);
14
15 /*
16 * This creates a pointer to a multiple line entry widget.
17 */
18 CDKMENTRY *newCDKMentry (CDKSCREEN *cdkscreen,
19 int xplace,
20 int yplace,
21 char *title,
22 char *label,
23 chtype fieldAttr,
24 chtype filler,
25 EDisplayType dispType,
26 int fWidth,
27 int fRows,
28 int logicalRows,
29 int min,
30 boolean Box,
31 boolean shadow)
32 {
33 CDKMENTRY *mentry = 0;
34 int parentWidth = getmaxx (cdkscreen->window);
35 int parentHeight = getmaxy (cdkscreen->window);
36 int fieldWidth = fWidth;
37 int fieldRows = fRows;
38 int boxWidth = 0;
39 int boxHeight = 0;
40 int horizontalAdjust, oldWidth;
41 int xpos = xplace;
42 int ypos = yplace;
43 int junk;
44
45 if ((mentry = newCDKObject (CDKMENTRY, &my_funcs)) == 0)
46 return (0);
47
48 setCDKMentryBox (mentry, Box);
49
50 /*
51 * If the fieldWidth is a negative value, the fieldWidth will
52 * be COLS-fieldWidth, otherwise, the fieldWidth will be the
53 * given width.
54 */
55 fieldWidth = setWidgetDimension (parentWidth, fieldWidth, 0);
56
57 /*
58 * If the fieldRows is a negative value, the fieldRows will
59 * be ROWS-fieldRows, otherwise, the fieldRows will be the
60 * given height.
61 */
62 fieldRows = setWidgetDimension (parentWidth, fieldRows, 0);
63 boxHeight = fieldRows + 2;
64
65 /* Set some basic values of the mentry field. */
66 mentry->label = 0;
67 mentry->labelLen = 0;
68 mentry->labelWin = 0;
69
70 /* We need to translate the char * label to a chtype * */
71 if (label != 0)
72 {
73 mentry->label = char2Chtype (label, &mentry->labelLen, &junk);
74 }
75 boxWidth = mentry->labelLen + fieldWidth + 2;
76
77 oldWidth = boxWidth;
78 boxWidth = setCdkTitle (ObjOf (mentry), title, boxWidth);
79 horizontalAdjust = (boxWidth - oldWidth) / 2;
80
81 boxHeight += TitleLinesOf (mentry);
82
83 /*
84 * Make sure we didn't extend beyond the parent window.
85 */
86 boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth);
87 boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight);
88 fieldWidth = (fieldWidth > (boxWidth - mentry->labelLen - 2)
89 ? (boxWidth - mentry->labelLen - 2)
90 : fieldWidth);
91 fieldRows = (fieldRows > (boxHeight - TitleLinesOf (mentry) - 2)
92 ? (boxHeight - TitleLinesOf (mentry) - 2)
93 : fieldRows);
94
95 /* Rejustify the x and y positions if we need to. */
96 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
97
98 /* Make the label window. */
99 mentry->win = newwin (boxHeight, boxWidth, ypos, xpos);
100
101 /* Is the window null??? */
102 if (mentry->win == 0)
103 {
104 destroyCDKObject (mentry);
105 return (0);
106 }
107
108 /* Create the label window. */
109 if (mentry->label != 0)
110 {
111 mentry->labelWin = subwin (mentry->win, fieldRows,
112 mentry->labelLen + 2,
113 ypos + TitleLinesOf (mentry) + 1,
114 xpos + horizontalAdjust + 1);
115 }
116
117 /* Make the field window. */
118 mentry->fieldWin = subwin (mentry->win, fieldRows, fieldWidth,
119 ypos + TitleLinesOf (mentry) + 1,
120 xpos + mentry->labelLen + horizontalAdjust + 1);
121
122 /* Turn on the keypad. */
123 keypad (mentry->fieldWin, TRUE);
124 keypad (mentry->win, TRUE);
125
126 /* Set up the rest of the structure. */
127 mentry->parent = cdkscreen->window;
128 mentry->totalWidth = (fieldWidth*logicalRows) + 1;
129
130 /* Create the info char * pointer. */
131 mentry->info = typeMallocN (char, mentry->totalWidth + 3);
132 cleanChar (mentry->info, mentry->totalWidth + 3, '\0');
133
134 /* Set up the rest of the widget information. */
135 ScreenOf (mentry) = cdkscreen;
136 mentry->shadowWin = 0;
137 mentry->fieldAttr = fieldAttr;
138 mentry->fieldWidth = fieldWidth;
139 mentry->rows = fieldRows;
140 mentry->boxHeight = boxHeight;
141 mentry->boxWidth = boxWidth;
142 mentry->filler = filler;
143 mentry->hidden = filler;
144 ObjOf (mentry)->inputWindow = mentry->win;
145 ObjOf (mentry)->acceptsFocus = TRUE;
146 mentry->currentRow = 0;
147 mentry->currentCol = 0;
148 mentry->topRow = 0;
149 mentry->shadow = shadow;
150 mentry->dispType = dispType;
151 mentry->min = min;
152 mentry->logicalRows = logicalRows;
153 initExitType (mentry);
154 mentry->callbackfn = CDKMentryCallBack;
155
156 /* Do we need to create a shadow. */
157 if (shadow)
158 {
159 mentry->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
160 }
161
162 /* Register this baby. */
163 registerCDKObject (cdkscreen, vMENTRY, mentry);
164
165 /* Return the pointer to the structure. */
166 return (mentry);
167 }
168
169 /*
170 * This actually manages the mentry widget...
171 */
172 char *activateCDKMentry (CDKMENTRY *mentry, chtype *actions)
173 {
174 chtype input = 0;
175 boolean functionKey;
176 char *ret = 0;
177
178 /* Draw the mentry widget. */
179 drawCDKMentry (mentry, ObjOf (mentry)->box);
180
181 if (actions == 0)
182 {
183 for (;;)
184 {
185 input = getchCDKObject (ObjOf (mentry), &functionKey);
186
187 /* Inject this character into the widget. */
188 ret = injectCDKMentry (mentry, input);
189 if (mentry->exitType != vEARLY_EXIT)
190 {
191 return ret;
192 }
193 }
194 }
195 else
196 {
197 int length = chlen (actions);
198 int x;
199
200 /* Inject each character one at a time. */
201 for (x = 0; x < length; x++)
202 {
203 ret = injectCDKMentry (mentry, actions[x]);
204 if (mentry->exitType != vEARLY_EXIT)
205 {
206 return ret;
207 }
208 }
209 }
210
211 /* Set the exit type and exit. */
212 setExitType (mentry, 0);
213 return 0;
214 }
215
216 static bool setTopRow (CDKMENTRY *widget, int row)
217 {
218 if (widget->topRow != row)
219 {
220 widget->topRow = row;
221 return TRUE;
222 }
223 return FALSE;
224 }
225
226 static bool setCurPos (CDKMENTRY *widget, int row, int col)
227 {
228 if (widget->currentRow != row ||
229 widget->currentCol != col)
230 {
231 widget->currentRow = row;
232 widget->currentCol = col;
233 return TRUE;
234 }
235 return FALSE;
236 }
237
238 static bool handle_KEY_LEFT (CDKMENTRY *mentry, bool *moved, bool *redraw)
239 {
240 bool result = TRUE;
241
242 if (mentry->currentCol != 0)
243 {
244 *moved = setCurPos (mentry,
245 mentry->currentRow,
246 mentry->currentCol - 1);
247 }
248 else if (mentry->currentRow == 0)
249 {
250 if (mentry->topRow != 0)
251 {
252 *moved = setCurPos (mentry,
253 mentry->currentRow,
254 mentry->fieldWidth - 1);
255 *redraw = setTopRow (mentry, mentry->topRow - 1);
256 }
257 }
258 else
259 {
260 *moved = setCurPos (mentry,
261 mentry->currentRow - 1,
262 mentry->fieldWidth - 1);
263 }
264
265 if (!*moved && !*redraw)
266 {
267 Beep ();
268 result = FALSE;
269 }
270 return result;
271 }
272
273 static int getCursorPos (CDKMENTRY *mentry)
274 {
275 return (((mentry->currentRow + mentry->topRow) * mentry->fieldWidth) +
276 mentry->currentCol);
277 }
278
279 /*
280 * This injects a character into the widget.
281 */
282 static int _injectCDKMentry (CDKOBJS *object, chtype input)
283 {
284 CDKMENTRY *mentry = (CDKMENTRY *)object;
285 int cursorPos = getCursorPos (mentry);
286 int ppReturn = 1;
287 int x, fieldCharacters;
288 char holder;
289 char *ret = unknownString;
290 bool complete = FALSE;
291
292 /* Set the exit type. */
293 setExitType (mentry, 0);
294
295 /* Refresh the field. */
296 drawCDKMentryField (mentry);
297
298 /* Check if there is a pre-process function to be called. */
299 if (PreProcessFuncOf (mentry) != 0)
300 {
301 /* Call the pre-process function. */
302 ppReturn = PreProcessFuncOf (mentry) (vMENTRY,
303 mentry,
304 PreProcessDataOf (mentry),
305 input);
306 }
307
308 /* Should we continue? */
309 if (ppReturn != 0)
310 {
311 /* Check for a key binding... */
312 if (checkCDKObjectBind (vMENTRY, mentry, input) != 0)
313 {
314 checkEarlyExit (mentry);
315 complete = TRUE;
316 }
317 else
318 {
319 bool moved = FALSE;
320 bool redraw = FALSE;
321 int infoLength = (int)strlen (mentry->info);
322
323 switch (input)
324 {
325 case KEY_HOME:
326 moved = setCurPos (mentry, 0, 0);
327 redraw = setTopRow (mentry, 0);
328 break;
329
330 case KEY_END:
331 fieldCharacters = mentry->rows * mentry->fieldWidth;
332 if (infoLength < fieldCharacters)
333 {
334 redraw = setTopRow (mentry, 0);
335 moved = setCurPos (mentry,
336 infoLength / mentry->fieldWidth,
337 infoLength % mentry->fieldWidth);
338 }
339 else
340 {
341 redraw = setTopRow (mentry,
342 (infoLength / mentry->fieldWidth) -
343 mentry->rows + 1);
344 moved = setCurPos (mentry,
345 mentry->rows - 1,
346 infoLength % mentry->fieldWidth);
347 }
348 break;
349
350 case KEY_LEFT:
351 handle_KEY_LEFT (mentry, &moved, &redraw);
352 break;
353
354 case KEY_RIGHT:
355 if (mentry->currentCol < (mentry->fieldWidth - 1))
356 {
357 if ((getCursorPos (mentry) + 1) <= infoLength)
358 {
359 moved = setCurPos (mentry,
360 mentry->currentRow,
361 mentry->currentCol + 1);
362 }
363 }
364 else if (mentry->currentRow == mentry->rows - 1)
365 {
366 if ((mentry->topRow + mentry->currentRow + 1) <= mentry->logicalRows)
367 {
368 moved = setCurPos (mentry, mentry->currentRow, 0);
369 redraw = setTopRow (mentry, mentry->topRow + 1);
370 }
371 }
372 else
373 {
374 moved = setCurPos (mentry, mentry->currentRow + 1, 0);
375 }
376 if (!moved && !redraw)
377 Beep ();
378 break;
379
380 case KEY_DOWN:
381 if (mentry->currentRow != (mentry->rows - 1))
382 {
383 if ((getCursorPos (mentry) + mentry->fieldWidth + 1)
384 <= infoLength)
385 {
386 moved = setCurPos (mentry, mentry->currentRow + 1, mentry->currentCol);
387 }
388 }
389 else if (mentry->topRow < mentry->logicalRows - mentry->rows)
390 {
391 if (((mentry->topRow + mentry->currentRow + 1) *
392 mentry->fieldWidth) <= infoLength)
393 {
394 redraw = setTopRow (mentry, mentry->topRow + 1);
395 }
396 }
397 if (!moved && !redraw)
398 Beep ();
399 break;
400
401 case KEY_UP:
402 if (mentry->currentRow != 0)
403 {
404 moved = setCurPos (mentry, mentry->currentRow - 1, mentry->currentCol);
405 }
406 else if (mentry->topRow != 0)
407 {
408 redraw = setTopRow (mentry, mentry->topRow - 1);
409 }
410 if (!moved && !redraw)
411 Beep ();
412 break;
413
414 case KEY_BACKSPACE:
415 case KEY_DC:
416 if (mentry->dispType == vVIEWONLY)
417 {
418 Beep ();
419 }
420 else if (infoLength == 0)
421 {
422 Beep ();
423 }
424 else if (input == KEY_DC
425 || handle_KEY_LEFT (mentry, &moved, &redraw))
426 {
427 cursorPos = getCursorPos (mentry);
428 if (mentry->info[cursorPos] != '\0')
429 {
430 for (x = cursorPos; x < infoLength; x++)
431 {
432 mentry->info[x] = mentry->info[x + 1];
433 }
434 mentry->info[--infoLength] = '\0';
435
436 drawCDKMentryField (mentry);
437 }
438 else
439 {
440 Beep ();
441 }
442 }
443 break;
444
445 case CDK_TRANSPOSE:
446 if (cursorPos >= infoLength - 1)
447 {
448 Beep ();
449 }
450 else
451 {
452 holder = mentry->info[cursorPos];
453 mentry->info[cursorPos] = mentry->info[cursorPos + 1];
454 mentry->info[cursorPos + 1] = holder;
455 drawCDKMentryField (mentry);
456 }
457 break;
458
459 case CDK_ERASE:
460 if (infoLength != 0)
461 {
462 cleanCDKMentry (mentry);
463 drawCDKMentryField (mentry);
464 }
465 break;
466
467 case CDK_CUT:
468 if (infoLength == 0)
469 {
470 Beep ();
471 }
472 else
473 {
474 freeChar (GPasteBuffer);
475 GPasteBuffer = copyChar (mentry->info);
476 cleanCDKMentry (mentry);
477 drawCDKMentryField (mentry);
478 }
479 break;
480
481 case CDK_COPY:
482 if (infoLength == 0)
483 {
484 Beep ();
485 }
486 else
487 {
488 freeChar (GPasteBuffer);
489 GPasteBuffer = copyChar (mentry->info);
490 }
491 break;
492
493 case CDK_PASTE:
494 if (GPasteBuffer == 0)
495 {
496 Beep ();
497 }
498 else
499 {
500 setCDKMentryValue (mentry, GPasteBuffer);
501 drawCDKMentry (mentry, ObjOf (mentry)->box);
502 }
503 break;
504
505 case KEY_TAB:
506 case KEY_ENTER:
507 if (infoLength < mentry->min + 1)
508 {
509 Beep ();
510 }
511 else
512 {
513 setExitType (mentry, input);
514 ret = (mentry->info);
515 complete = TRUE;
516 }
517 break;
518
519 case KEY_ESC:
520 setExitType (mentry, input);
521 complete = TRUE;
522 break;
523
524 case CDK_REFRESH:
525 eraseCDKScreen (ScreenOf (mentry));
526 refreshCDKScreen (ScreenOf (mentry));
527 break;
528
529 default:
530 if (mentry->dispType == vVIEWONLY
531 || infoLength >= mentry->totalWidth)
532 {
533 Beep ();
534 }
535 else
536 {
537 (mentry->callbackfn) (mentry, input);
538 }
539 break;
540 }
541
542 if (redraw)
543 {
544 drawCDKMentryField (mentry);
545 }
546 else if (moved)
547 {
548 wmove (mentry->fieldWin, mentry->currentRow, mentry->currentCol);
549 wrefresh (mentry->fieldWin);
550 }
551 }
552
553 /* Should we do a post-process? */
554 if (!complete && (PostProcessFuncOf (mentry) != 0))
555 {
556 PostProcessFuncOf (mentry) (vMENTRY,
557 mentry,
558 PostProcessDataOf (mentry),
559 input);
560 }
561 }
562
563 if (!complete)
564 {
565 setExitType (mentry, 0);
566 }
567
568 ResultOf (mentry).valueString = ret;
569 return (ret != unknownString);
570 }
571
572 /*
573 * This moves the mentry field to the given location.
574 */
575 static void _moveCDKMentry (CDKOBJS *object,
576 int xplace,
577 int yplace,
578 boolean relative,
579 boolean refresh_flag)
580 {
581 CDKMENTRY *mentry = (CDKMENTRY *)object;
582 int currentX = getbegx (mentry->win);
583 int currentY = getbegy (mentry->win);
584 int xpos = xplace;
585 int ypos = yplace;
586 int xdiff = 0;
587 int ydiff = 0;
588
589 /*
590 * If this is a relative move, then we will adjust where we want
591 * to move to.
592 */
593 if (relative)
594 {
595 xpos = getbegx (mentry->win) + xplace;
596 ypos = getbegy (mentry->win) + yplace;
597 }
598
599 /* Adjust the window if we need to. */
600 alignxy (WindowOf (mentry), &xpos, &ypos, mentry->boxWidth, mentry->boxHeight);
601
602 /* Get the difference. */
603 xdiff = currentX - xpos;
604 ydiff = currentY - ypos;
605
606 /* Move the window to the new location. */
607 moveCursesWindow (mentry->win, -xdiff, -ydiff);
608 moveCursesWindow (mentry->fieldWin, -xdiff, -ydiff);
609 moveCursesWindow (mentry->labelWin, -xdiff, -ydiff);
610 moveCursesWindow (mentry->shadowWin, -xdiff, -ydiff);
611
612 /* Touch the windows so they 'move'. */
613 refreshCDKWindow (WindowOf (mentry));
614
615 /* Redraw the window, if they asked for it. */
616 if (refresh_flag)
617 {
618 drawCDKMentry (mentry, ObjOf (mentry)->box);
619 }
620 }
621
622 /*
623 * This function redraws the multiple line entry field.
624 */
625 void drawCDKMentryField (CDKMENTRY *mentry)
626 {
627 int currchar = (mentry->fieldWidth * mentry->topRow);
628 int length = 0;
629 int lastpos = 0;
630 int x, y;
631
632 /* Check the value of info. */
633 if (mentry->info == 0)
634 {
635 return;
636 }
637
638 drawCdkTitle (mentry->win, ObjOf (mentry));
639
640 wrefresh (mentry->win);
641
642 /* The information isn't null, redraw the field. */
643 length = (int)strlen (mentry->info);
644 lastpos = ((chtype)mentry->info[length] == (chtype)mentry->filler
645 ? length - 1
646 : length);
647
648 /* Start redrawing the fields. */
649 for (x = 0; x < mentry->rows; x++)
650 {
651 for (y = 0; y < mentry->fieldWidth; y++)
652 {
653 if (currchar < lastpos)
654 {
655 if (isHiddenDisplayType (mentry->dispType))
656 {
657 mvwaddch (mentry->fieldWin, x, y, mentry->filler);
658 }
659 else
660 {
661 mvwaddch (mentry->fieldWin, x, y,
662 CharOf (mentry->info[currchar++]) | mentry->fieldAttr);
663 }
664 }
665 else
666 {
667 mvwaddch (mentry->fieldWin, x, y, mentry->filler);
668 }
669 }
670 }
671
672 /* Refresh the screen. */
673 wmove (mentry->fieldWin, mentry->currentRow, mentry->currentCol);
674 wrefresh (mentry->fieldWin);
675 }
676
677 /*
678 * This is a generic character parser for the mentry field. It is used as a
679 * callback function, so any personal modifications can be made by creating
680 * a new function and calling that one the mentry activation.
681 */
682 static void CDKMentryCallBack (CDKMENTRY *mentry, chtype character)
683 {
684 int cursorPos = getCursorPos (mentry);
685 int infoLength = (int)strlen (mentry->info);
686 char newchar = filterByDisplayType (mentry->dispType, character);
687 int x;
688
689 if (newchar == ERR)
690 {
691 Beep ();
692 }
693 else
694 {
695 for (x = infoLength + 1; x > cursorPos; x--)
696 {
697 mentry->info[x] = mentry->info[x - 1];
698 }
699 mentry->info[cursorPos] = newchar;
700 mentry->currentCol++;
701
702 drawCDKMentryField (mentry);
703
704 /* Have we gone out of bounds. */
705 if (mentry->currentCol >= mentry->fieldWidth)
706 {
707 /* Update the row and col values. */
708 mentry->currentCol = 0;
709 mentry->currentRow++;
710
711 /*
712 * If we have gone outside of the visual boundaries, we
713 * need to scroll the window.
714 */
715 if (mentry->currentRow == mentry->rows)
716 {
717 /* We have to redraw the screen. */
718 mentry->currentRow--;
719 mentry->topRow++;
720 drawCDKMentryField (mentry);
721 }
722 wmove (mentry->fieldWin, mentry->currentRow, mentry->currentCol);
723 wrefresh (mentry->fieldWin);
724 }
725 }
726 }
727
728 /*
729 * This function draws the multiple line entry field.
730 */
731 static void _drawCDKMentry (CDKOBJS *object, boolean Box)
732 {
733 CDKMENTRY *mentry = (CDKMENTRY *)object;
734
735 /* Box the widget if asked. */
736 if (Box)
737 {
738 drawObjBox (mentry->win, ObjOf (mentry));
739 wrefresh (mentry->win);
740 }
741
742 /* Do we need to draw in the shadow??? */
743 if (mentry->shadowWin != 0)
744 {
745 drawShadow (mentry->shadowWin);
746 }
747
748 /* Draw in the label to the widget. */
749 if (mentry->labelWin != 0)
750 {
751 writeChtype (mentry->labelWin, 0, 0,
752 mentry->label,
753 HORIZONTAL, 0,
754 mentry->labelLen);
755 wrefresh (mentry->labelWin);
756 }
757
758 /* Draw the mentry field. */
759 drawCDKMentryField (mentry);
760 }
761
762 /*
763 * This sets the background attribute of the widget.
764 */
765 static void _setBKattrMentry (CDKOBJS *object, chtype attrib)
766 {
767 if (object != 0)
768 {
769 CDKMENTRY *widget = (CDKMENTRY *)object;
770
771 wbkgd (widget->win, attrib);
772 wbkgd (widget->fieldWin, attrib);
773 if (widget->labelWin != 0)
774 {
775 wbkgd (widget->labelWin, attrib);
776 }
777 }
778 }
779
780 /*
781 * This function erases the multiple line entry field from the screen.
782 */
783 static void _eraseCDKMentry (CDKOBJS *object)
784 {
785 if (validCDKObject (object))
786 {
787 CDKMENTRY *mentry = (CDKMENTRY *)object;
788
789 eraseCursesWindow (mentry->fieldWin);
790 eraseCursesWindow (mentry->labelWin);
791 eraseCursesWindow (mentry->win);
792 eraseCursesWindow (mentry->shadowWin);
793 }
794 }
795
796 /*
797 * This function destroys a multiple line entry field widget.
798 */
799 static void _destroyCDKMentry (CDKOBJS *object)
800 {
801 if (object != 0)
802 {
803 CDKMENTRY *mentry = (CDKMENTRY *)object;
804
805 cleanCdkTitle (object);
806 freeChtype (mentry->label);
807 freeChar (mentry->info);
808
809 /* Clean up the windows. */
810 deleteCursesWindow (mentry->fieldWin);
811 deleteCursesWindow (mentry->labelWin);
812 deleteCursesWindow (mentry->shadowWin);
813 deleteCursesWindow (mentry->win);
814
815 /* Clean the key bindings. */
816 cleanCDKObjectBindings (vMENTRY, mentry);
817
818 /* Unregister this object. */
819 unregisterCDKObject (vMENTRY, mentry);
820 }
821 }
822
823 /*
824 * This sets multiple attributes of the widget.
825 */
826 void setCDKMentry (CDKMENTRY *mentry, char *value, int min, boolean Box)
827 {
828 setCDKMentryValue (mentry, value);
829 setCDKMentryMin (mentry, min);
830 setCDKMentryBox (mentry, Box);
831 }
832
833 /*
834 * This removes the old information in the entry field and keeps the
835 * new information given.
836 */
837 void setCDKMentryValue (CDKMENTRY *mentry, char *newValue)
838 {
839 int fieldCharacters = mentry->rows * mentry->fieldWidth;
840 int len = 0;
841 int copychars = 0;
842 int rowsUsed;
843
844 /* Just to be sure, if lets make sure the new value isn't null. */
845 if (newValue == 0)
846 {
847 /* Then we want to just erase the old value. */
848 cleanChar (mentry->info, mentry->totalWidth, '\0');
849 return;
850 }
851
852 /* Determine how many characters we need to copy. */
853 len = (int)strlen (newValue);
854 copychars = (len < mentry->totalWidth ? len : mentry->totalWidth);
855
856 /* OK, erase the old value, and copy in the new value. */
857 cleanChar (mentry->info, mentry->totalWidth, '\0');
858 strncpy (mentry->info, newValue, copychars);
859
860 /* Set the cursor/row info. */
861 if (len < fieldCharacters)
862 {
863 mentry->topRow = 0;
864 mentry->currentRow = len / mentry->fieldWidth;
865 mentry->currentCol = len % mentry->fieldWidth;
866 }
867 else
868 {
869 rowsUsed = len / mentry->fieldWidth;
870 mentry->topRow = rowsUsed - mentry->rows + 1;
871 mentry->currentRow = mentry->rows - 1;
872 mentry->currentCol = len % mentry->fieldWidth;
873 }
874
875 /* Redraw the widget. */
876 drawCDKMentryField (mentry);
877 }
878 char *getCDKMentryValue (CDKMENTRY *mentry)
879 {
880 return mentry->info;
881 }
882
883 /*
884 * This sets the filler character to use when drawing the widget.
885 */
886 void setCDKMentryFillerChar (CDKMENTRY *mentry, chtype filler)
887 {
888 mentry->filler = filler;
889 }
890 chtype getCDKMentryFillerChar (CDKMENTRY *mentry)
891 {
892 return mentry->filler;
893 }
894
895 /*
896 * This sets the character to use when a hidden character type is used.
897 */
898 void setCDKMentryHiddenChar (CDKMENTRY *mentry, chtype character)
899 {
900 mentry->hidden = character;
901 }
902 chtype getCDKMentryHiddenChar (CDKMENTRY *mentry)
903 {
904 return mentry->hidden;
905 }
906
907 /*
908 * This sets the minimum length of the widget.
909 */
910 void setCDKMentryMin (CDKMENTRY *mentry, int min)
911 {
912 mentry->min = min;
913 }
914 int getCDKMentryMin (CDKMENTRY *mentry)
915 {
916 return mentry->min;
917 }
918
919 /*
920 * This sets the widgets box attribute.
921 */
922 void setCDKMentryBox (CDKMENTRY *mentry, boolean Box)
923 {
924 ObjOf (mentry)->box = Box;
925 ObjOf (mentry)->borderSize = Box ? 1 : 0;
926 }
927 boolean getCDKMentryBox (CDKMENTRY *mentry)
928 {
929 return ObjOf (mentry)->box;
930 }
931
932 /*
933 * This erases the information in the multiple line entry widget.
934 */
935 void cleanCDKMentry (CDKMENTRY *mentry)
936 {
937 cleanChar (mentry->info, mentry->totalWidth, '\0');
938 mentry->currentRow = 0;
939 mentry->currentCol = 0;
940 mentry->topRow = 0;
941 }
942
943 /*
944 * This sets the callback function.
945 */
946 void setCDKMentryCB (CDKMENTRY *mentry, MENTRYCB callback)
947 {
948 mentry->callbackfn = callback;
949 }
950
951 static void _focusCDKMentry (CDKOBJS *object)
952 {
953 CDKMENTRY *mentry = (CDKMENTRY *)object;
954
955 wmove (mentry->fieldWin, 0, mentry->currentCol);
956 wrefresh (mentry->fieldWin);
957 }
958
959 static void _unfocusCDKMentry (CDKOBJS *object)
960 {
961 CDKMENTRY *mentry = (CDKMENTRY *)object;
962
963 wrefresh (mentry->fieldWin);
964 }
965
966 dummyRefreshData (Mentry)
967
968 dummySaveData (Mentry)
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:44 $
5 * $Revision: 1.98 $
6 */
7
8 #define TITLELINES 1
9
10 /*
11 * Declare file local prototypes.
12 */
13 static void cleanUpMenu (CDKMENU *menu);
14
15 DeclareCDKObjects (MENU, Menu, setCdk, Int);
16
17 /*
18 * This creates a new menu widget.
19 */
20 CDKMENU *newCDKMenu (CDKSCREEN *cdkscreen,
21 char *menulist[MAX_MENU_ITEMS][MAX_SUB_ITEMS],
22 int menuItems,
23 int *subsize,
24 int *menuLocation,
25 int menuPos,
26 chtype titleAttr,
27 chtype subtitleAttr)
28 {
29 CDKMENU *menu = 0;
30 int rightcount = menuItems - 1;
31 int rightloc = getmaxx (cdkscreen->window);
32 int leftloc = 0;
33 int x, y, max, junk;
34 int xpos = getbegx (cdkscreen->window);
35 int ypos = getbegy (cdkscreen->window);
36 int ymax = getmaxy (cdkscreen->window);
37
38 if ((menu = newCDKObject (CDKMENU, &my_funcs)) == 0)
39 return (0);
40
41 /* Start making a copy of the information. */
42 ScreenOf (menu) = cdkscreen;
43 ObjOf (menu)->box = FALSE;
44 ObjOf (menu)->acceptsFocus = FALSE;
45 rightcount = menuItems-1;
46 menu->parent = cdkscreen->window;
47 menu->menuItems = menuItems;
48 menu->titleAttr = titleAttr;
49 menu->subtitleAttr = subtitleAttr;
50 menu->currentTitle = 0;
51 menu->currentSubtitle = 0;
52 menu->lastSelection = -1;
53 menu->menuPos = menuPos;
54 initExitType (menu);
55
56 /* Create the pull down menus. */
57 for (x = 0; x < menuItems; x++)
58 {
59 int x1 = (menuLocation[x] == LEFT) ? x : rightcount--;
60 int x2;
61 int y1 = (menuPos == BOTTOM) ? (ymax - 1) : 0;
62 int y2 = (menuPos == BOTTOM) ? (ymax - subsize[x] - 2) : TITLELINES;
63 int high = subsize[x] + TITLELINES;
64
65 /*
66 * Limit the menu height to fit on the screen.
67 */
68 if (high + y2 > ymax)
69 {
70 high = ymax - TITLELINES;
71 }
72
73 max = -1;
74 for (y = TITLELINES; y < subsize[x]; y++)
75 {
76 int y0 = y - TITLELINES;
77
78 menu->sublist[x1][y0] = char2Chtype (menulist[x][y],
79 &menu->sublistLen[x1][y0],
80 &junk);
81 max = MAXIMUM (max, menu->sublistLen[x1][y0]);
82 }
83
84 if (menuLocation[x] == LEFT)
85 {
86 x2 = leftloc;
87 }
88 else
89 {
90 x2 = (rightloc -= max + 2);
91 }
92 menu->title[x1] = char2Chtype (menulist[x][0], &menu->titleLen[x1], &junk);
93 menu->subsize[x1] = subsize[x] - TITLELINES;
94 menu->titleWin[x1] = subwin (cdkscreen->window, TITLELINES, menu->titleLen[x1]+2, ypos + y1, xpos + x2);
95 menu->pullWin[x1] = subwin (cdkscreen->window, high, max+2, ypos + y2, xpos + x2);
96 if (menu->titleWin[x1] == 0 || menu->pullWin[x1] == 0)
97 {
98 destroyCDKMenu (menu);
99 return (0);
100 }
101
102 leftloc += menu->titleLen[x] + 1;
103
104 keypad (menu->titleWin[x1], TRUE);
105 keypad (menu->pullWin[x1], TRUE);
106 }
107 ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle];
108
109 /* Register this baby. */
110 registerCDKObject (cdkscreen, vMENU, menu);
111
112 /* Return the menu object. */
113 return (menu);
114 }
115
116 /*
117 * This activates the CDK Menu.
118 */
119 int activateCDKMenu (CDKMENU *menu, chtype *actions)
120 {
121 chtype input;
122 boolean functionKey;
123 int ret;
124
125 /* Draw in the screen. */
126 refreshCDKScreen (ScreenOf (menu));
127
128 /* Display the menu titles. */
129 drawCDKMenu (menu, ObjOf (menu)->box);
130
131 /* Highlight the current title and window. */
132 drawCDKMenuSubwin (menu);
133
134 /* If the input string is null, this is an interactive activate. */
135 if (actions == 0)
136 {
137 ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle];
138
139 /* Start taking input from the keyboard. */
140 for (;;)
141 {
142 input = getchCDKObject (ObjOf (menu), &functionKey);
143
144 /* Inject the character into the widget. */
145 ret = injectCDKMenu (menu, input);
146 if (menu->exitType != vEARLY_EXIT)
147 {
148 return ret;
149 }
150 }
151 }
152 else
153 {
154 int count = chlen (actions);
155 int x = 0;
156
157 for (x = 0; x < count; x++)
158 {
159 ret = injectCDKMenu (menu, actions[x]);
160 if (menu->exitType != vEARLY_EXIT)
161 {
162 return ret;
163 }
164 }
165 }
166
167 /* Set the exit type and return. */
168 setExitType (menu, 0);
169 return -1;
170 }
171
172 /*
173 * The "%" operator is simpler but does not handle negative values.
174 */
175 static int wrapped (int within, int limit)
176 {
177 if (within < 0)
178 within = limit - 1;
179 else if (within >= limit)
180 within = 0;
181 return within;
182 }
183
184 static void drawTitle (CDKMENU *menu, int item)
185 {
186 writeChtype (menu->titleWin[item],
187 0, 0, menu->title[item],
188 HORIZONTAL,
189 0, menu->titleLen[item]);
190 }
191
192 static void drawItem (CDKMENU *menu, int item, int offset)
193 {
194 writeChtype (menu->pullWin[menu->currentTitle],
195 1, item + TITLELINES - offset,
196 menu->sublist[menu->currentTitle][item],
197 HORIZONTAL,
198 0, menu->sublistLen[menu->currentTitle][item]);
199 }
200
201 /* Highlight the current sub-menu item. */
202 static void selectItem (CDKMENU *menu, int item, int offset)
203 {
204 writeChtypeAttrib (menu->pullWin[menu->currentTitle],
205 1, item + TITLELINES - offset,
206 menu->sublist[menu->currentTitle][item],
207 menu->subtitleAttr,
208 HORIZONTAL,
209 0, menu->sublistLen[menu->currentTitle][item]);
210 }
211
212 static void withinSubmenu (CDKMENU *menu, int step)
213 {
214 int next = wrapped (menu->currentSubtitle + step, menu->subsize[menu->currentTitle]);
215
216 if (next != menu->currentSubtitle)
217 {
218 CDKSCREEN *screen = ScreenOf (menu);
219 int ymax = getmaxy (screen->window);
220
221 if ((1 +
222 getbegy (menu->pullWin[menu->currentTitle]) +
223 menu->subsize[menu->currentTitle]) >= ymax)
224 {
225 menu->currentSubtitle = next;
226 drawCDKMenuSubwin (menu);
227 }
228 else
229 {
230 /* Erase the old subtitle. */
231 drawItem (menu, menu->currentSubtitle, 0);
232
233 /* Set the values. */
234 menu->currentSubtitle = next;
235
236 /* Draw the new sub-title. */
237 selectItem (menu, menu->currentSubtitle, 0);
238
239 wrefresh (menu->pullWin[menu->currentTitle]);
240 }
241
242 ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle];
243 }
244 }
245
246 static void acrossSubmenus (CDKMENU *menu, int step)
247 {
248 int next = wrapped (menu->currentTitle + step, menu->menuItems);
249
250 if (next != menu->currentTitle)
251 {
252 /* Erase the menu sub-window. */
253 eraseCDKMenuSubwin (menu);
254 refreshCDKScreen (ScreenOf (menu));
255
256 /* Set the values. */
257 menu->currentTitle = next;
258 menu->currentSubtitle = 0;
259
260 /* Draw the new menu sub-window. */
261 drawCDKMenuSubwin (menu);
262 ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle];
263 }
264 }
265
266 /*
267 * Inject a character into the menu widget.
268 */
269 static int _injectCDKMenu (CDKOBJS *object, chtype input)
270 {
271 CDKMENU *menu = (CDKMENU *)object;
272 int ppReturn = 1;
273 int ret = unknownInt;
274 bool complete = FALSE;
275
276 /* Set the exit type. */
277 setExitType (menu, 0);
278
279 /* Check if there is a pre-process function to be called. */
280 if (PreProcessFuncOf (menu) != 0)
281 {
282 /* Call the pre-process function. */
283 ppReturn = PreProcessFuncOf (menu) (vMENU,
284 menu,
285 PreProcessDataOf (menu),
286 input);
287 }
288
289 /* Should we continue? */
290 if (ppReturn != 0)
291 {
292 /* Check for key bindings. */
293 if (checkCDKObjectBind (vMENU, menu, input) != 0)
294 {
295 checkEarlyExit (menu);
296 complete = TRUE;
297 }
298 else
299 {
300 switch (input)
301 {
302 case KEY_LEFT:
303 acrossSubmenus (menu, -1);
304 break;
305
306 case KEY_RIGHT:
307 case KEY_TAB:
308 acrossSubmenus (menu, 1);
309 break;
310
311 case KEY_UP:
312 withinSubmenu (menu, -1);
313 break;
314
315 case KEY_DOWN:
316 case SPACE:
317 withinSubmenu (menu, 1);
318 break;
319
320 case KEY_ENTER:
321 cleanUpMenu (menu);
322 setExitType (menu, input);
323 menu->lastSelection = ((menu->currentTitle * 100) + menu->currentSubtitle);
324 ret = menu->lastSelection;
325 complete = TRUE;
326 break;
327
328 case KEY_ESC:
329 cleanUpMenu (menu);
330 setExitType (menu, input);
331 menu->lastSelection = -1;
332 ret = menu->lastSelection;
333 complete = TRUE;
334 break;
335
336 case CDK_REFRESH:
337 eraseCDKScreen (ScreenOf (menu));
338 refreshCDKScreen (ScreenOf (menu));
339 break;
340 }
341 }
342
343 /* Should we call a post-process? */
344 if (!complete && (PostProcessFuncOf (menu) != 0))
345 {
346 PostProcessFuncOf (menu) (vMENU, menu, PostProcessDataOf (menu), input);
347 }
348 }
349
350 if (!complete)
351 {
352 setExitType (menu, 0);
353 }
354
355 ResultOf (menu).valueInt = ret;
356 return (ret != unknownInt);
357 }
358
359 /*
360 * Draw a menu item subwindow.
361 */
362 void drawCDKMenuSubwin (CDKMENU *menu)
363 {
364 int x;
365 int high = getmaxy (menu->pullWin[menu->currentTitle]) - 2;
366 int x0 = 0;
367 int x1 = menu->subsize[menu->currentTitle];
368
369 if (x1 > high)
370 x1 = high;
371
372 if (menu->currentSubtitle >= x1)
373 {
374 x0 = (menu->currentSubtitle - x1) + 1;
375 x1 += x0;
376 }
377
378 /* Box the window. */
379 werase (menu->pullWin[menu->currentTitle]);
380 box (menu->pullWin[menu->currentTitle], ACS_VLINE, ACS_HLINE);
381
382 if (menu->menuPos == BOTTOM)
383 {
384 mvwaddch (menu->pullWin[menu->currentTitle],
385 menu->subsize[menu->currentTitle] + 1, 0, ACS_LTEE);
386 }
387 else
388 {
389 mvwaddch (menu->pullWin[menu->currentTitle], 0, 0, ACS_LTEE);
390 }
391
392 /* Draw the items. */
393 for (x = x0; x < x1; x++)
394 {
395 drawItem (menu, x, x0);
396 }
397
398 selectItem (menu, menu->currentSubtitle, x0);
399 wrefresh (menu->pullWin[menu->currentTitle]);
400
401 /* Highlight the title. */
402 writeChtypeAttrib (menu->titleWin[menu->currentTitle],
403 0, 0, menu->title[menu->currentTitle],
404 menu->titleAttr, HORIZONTAL, 0,
405 menu->titleLen[menu->currentTitle]);
406 wrefresh (menu->titleWin[menu->currentTitle]);
407 }
408
409 /*
410 * Erase a menu item subwindow.
411 */
412 void eraseCDKMenuSubwin (CDKMENU *menu)
413 {
414 eraseCursesWindow (menu->pullWin[menu->currentTitle]);
415
416 /* Redraw the sub-menu title. */
417 drawTitle (menu, menu->currentTitle);
418 wrefresh (menu->titleWin[menu->currentTitle]);
419 }
420
421 /*
422 * Draw the menu.
423 */
424 static void _drawCDKMenu (CDKOBJS *object, boolean Box GCC_UNUSED)
425 {
426 CDKMENU *menu = (CDKMENU *)object;
427 int x;
428
429 /* Draw in the menu titles. */
430 for (x = 0; x < menu->menuItems; x++)
431 {
432 drawTitle (menu, x);
433 wrefresh (menu->titleWin[x]);
434 }
435 }
436
437 /*
438 * Move the menu to the given location.
439 */
440 static void _moveCDKMenu (CDKOBJS *object,
441 int xplace,
442 int yplace,
443 boolean relative,
444 boolean refresh_flag)
445 {
446 CDKMENU *menu = (CDKMENU *)object;
447 int currentX = getbegx (WindowOf (menu));
448 int currentY = getbegy (WindowOf (menu));
449 int xpos = xplace;
450 int ypos = yplace;
451 int xdiff = 0;
452 int ydiff = 0;
453 int x;
454
455 /*
456 * If this is a relative move, then we will adjust where we want
457 * to move to.
458 */
459 if (relative)
460 {
461 xpos = getbegx (WindowOf (menu)) + xplace;
462 ypos = getbegy (WindowOf (menu)) + yplace;
463 }
464
465 /* Adjust the window if we need to. */
466 alignxy (WindowOf (menu),
467 &xpos,
468 &ypos,
469 getmaxx (WindowOf (menu)),
470 getmaxy (WindowOf (menu)));
471
472 /* Get the difference. */
473 xdiff = currentX - xpos;
474 ydiff = currentY - ypos;
475
476 /* Move the windows to the new location. */
477 moveCursesWindow (WindowOf (menu), -xdiff, -ydiff);
478 for (x = 0; x < menu->menuItems; x++)
479 {
480 moveCursesWindow (menu->titleWin[x], -xdiff, -ydiff);
481 }
482
483 /* Touch the windows so they 'move'. */
484 refreshCDKWindow (WindowOf (menu));
485
486 /* Redraw the window, if they asked for it. */
487 if (refresh_flag)
488 {
489 drawCDKMenu (menu, ObjOf (menu)->box);
490 }
491 }
492
493 /*
494 * Set the background attribute of the widget.
495 */
496 static void _setBKattrMenu (CDKOBJS *object, chtype attrib)
497 {
498 if (object != 0)
499 {
500 CDKMENU *widget = (CDKMENU *)object;
501 int x;
502
503 for (x = 0; x < widget->menuItems; x++)
504 {
505 wbkgd (widget->titleWin[x], attrib);
506 wbkgd (widget->pullWin[x], attrib);
507 }
508 }
509 }
510
511 /*
512 * Destroy a menu widget.
513 */
514 static void _destroyCDKMenu (CDKOBJS *object)
515 {
516 if (object != 0)
517 {
518 CDKMENU *menu = (CDKMENU *)object;
519 int x, y;
520
521 /* Clean up both the winodws and the char pointers. */
522 for (x = 0; x < menu->menuItems; x++)
523 {
524 /* Clean the windows. */
525 deleteCursesWindow (menu->titleWin[x]);
526 deleteCursesWindow (menu->pullWin[x]);
527
528 /* Delete the character pointers. */
529 freeChtype (menu->title[x]);
530 for (y = 0; y < menu->subsize[x]; y++)
531 {
532 freeChtype (menu->sublist[x][y]);
533 }
534 }
535
536 /* Clean the key bindings. */
537 cleanCDKObjectBindings (vMENU, menu);
538
539 /* Unregister this object. */
540 unregisterCDKObject (vMENU, menu);
541 }
542 }
543
544 /*
545 * Erase the menu widget from the screen.
546 */
547 static void _eraseCDKMenu (CDKOBJS *object)
548 {
549 if (validCDKObject (object))
550 {
551 CDKMENU *menu = (CDKMENU *)object;
552 int x = 0;
553
554 for (x = 0; x < menu->menuItems; x++)
555 {
556 werase (menu->titleWin[x]);
557 wrefresh (menu->titleWin[x]);
558 werase (menu->pullWin[x]);
559 wrefresh (menu->pullWin[x]);
560 }
561 }
562 }
563
564 /*
565 * Set multiple features of the menu.
566 */
567 void setCDKMenu (CDKMENU *menu,
568 int menuItem,
569 int subMenuItem,
570 chtype titleHighlight,
571 chtype subTitleHighlight)
572 {
573 setCDKMenuCurrentItem (menu, menuItem, subMenuItem);
574 setCDKMenuTitleHighlight (menu, titleHighlight);
575 setCDKMenuSubTitleHighlight (menu, subTitleHighlight);
576 }
577
578 /*
579 * Set the current menu item to highlight.
580 */
581 void setCDKMenuCurrentItem (CDKMENU *menu, int menuitem, int submenuitem)
582 {
583 menu->currentTitle = wrapped (menuitem, menu->menuItems);
584 menu->currentSubtitle = wrapped (submenuitem, menu->subsize[menu->currentTitle]);
585 }
586 void getCDKMenuCurrentItem (CDKMENU *menu, int *menuItem, int *subMenuItem)
587 {
588 (*menuItem) = menu->currentTitle;
589 (*subMenuItem) = menu->currentSubtitle;
590 }
591
592 /*
593 * Set the attribute of the menu titles.
594 */
595 void setCDKMenuTitleHighlight (CDKMENU *menu, chtype highlight)
596 {
597 menu->titleAttr = highlight;
598 }
599 chtype getCDKMenuTitleHighlight (CDKMENU *menu)
600 {
601 return menu->titleAttr;
602 }
603
604 /*
605 * Set the attribute of the sub-title.
606 */
607 void setCDKMenuSubTitleHighlight (CDKMENU *menu, chtype highlight)
608 {
609 menu->subtitleAttr = highlight;
610 }
611 chtype getCDKMenuSubTitleHighlight (CDKMENU *menu)
612 {
613 return menu->subtitleAttr;
614 }
615
616 /*
617 * Exit the menu.
618 */
619 static void cleanUpMenu (CDKMENU *menu)
620 {
621 /* Erase the sub-menu. */
622 eraseCDKMenuSubwin (menu);
623 wrefresh (menu->pullWin[menu->currentTitle]);
624
625 /* Refresh the screen. */
626 refreshCDKScreen (ScreenOf (menu));
627 }
628
629 static void _focusCDKMenu (CDKOBJS *object)
630 {
631 CDKMENU *menu = (CDKMENU *)object;
632
633 drawCDKMenuSubwin (menu);
634 ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle];
635 }
636
637 dummyUnfocus (Menu)
638
639 dummyRefreshData (Menu)
640
641 dummySaveData (Menu)
0 #! /bin/sh
1 # mkinstalldirs --- make directory hierarchy
2 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
3 # Created: 1993-05-16
4 # Last modified: 1994-03-25
5 # Public domain
6 #
7
8 errstatus=0
9 umask 022
10
11 for file in ${1+"$@"} ; do
12 set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
13 shift
14
15 pathcomp=
16 for d in ${1+"$@"} ; do
17 pathcomp="$pathcomp$d"
18 case "$pathcomp" in
19 -* ) pathcomp=./$pathcomp ;;
20 esac
21
22 if test ! -d "$pathcomp"; then
23 echo "mkdir $pathcomp" 1>&2
24 case "$pathcomp" in
25 [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]: )
26 ;; # DOSISH systems
27 * ) mkdir "$pathcomp" || errstatus=$? ;;
28 esac
29 fi
30
31 pathcomp="$pathcomp/"
32 done
33 done
34
35 exit $errstatus
36
37 # mkinstalldirs ends here
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2003/11/27 22:16:09 $
5 * $Revision: 1.1 $
6 */
7
8 /*
9 * This pops up a dialog box.
10 */
11 int popupDialog (CDKSCREEN *screen, char **mesg, int mesgCount, char **buttons, int buttonCount)
12 {
13 /* Declare local variables. */
14 CDKDIALOG *popup = 0;
15 int choice;
16
17 /* Create the dialog box. */
18 popup = newCDKDialog (screen, CENTER, CENTER,
19 mesg, mesgCount,
20 buttons, buttonCount,
21 A_REVERSE, TRUE,
22 TRUE, FALSE);
23
24 /* Activate the dialog box */
25 drawCDKDialog (popup, TRUE);
26
27 /* Get the choice. */
28 choice = activateCDKDialog (popup, 0);
29
30 /* Destroy the dialog box. */
31 destroyCDKDialog (popup);
32
33 /* Clean the screen. */
34 eraseCDKScreen (screen);
35 refreshCDKScreen (screen);
36
37 /* Return the choice. */
38 return choice;
39 }
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2005/12/30 00:17:57 $
5 * $Revision: 1.2 $
6 */
7
8 /*
9 * This pops up a message.
10 */
11 void popupLabel (CDKSCREEN *screen, char **mesg, int count)
12 {
13 CDKLABEL *popup = 0;
14 int oldCursState;
15 boolean functionKey;
16
17 /* Create the label. */
18 popup = newCDKLabel (screen, CENTER, CENTER, mesg, count, TRUE, FALSE);
19
20 oldCursState = curs_set(0);
21 /* Draw it on the screen. */
22 drawCDKLabel (popup, TRUE);
23
24 /* Wait for some input. */
25 keypad (popup->win, TRUE);
26 getchCDKObject (ObjOf(popup), &functionKey);
27
28 /* Kill it. */
29 destroyCDKLabel (popup);
30
31 /* Clean the screen. */
32 curs_set(oldCursState);
33 eraseCDKScreen (screen);
34 refreshCDKScreen (screen);
35 }
36
37 /*
38 * This pops up a message.
39 */
40 void popupLabelAttrib (CDKSCREEN *screen, char **mesg, int count, chtype attrib)
41 {
42 CDKLABEL *popup = 0;
43 int oldCursState;
44 boolean functionKey;
45
46 /* Create the label. */
47 popup = newCDKLabel (screen, CENTER, CENTER, mesg, count, TRUE, FALSE);
48 setCDKLabelBackgroundAttrib(popup, attrib);
49
50 oldCursState = curs_set(0);
51 /* Draw it on the screen. */
52 drawCDKLabel (popup, TRUE);
53
54 /* Wait for some input. */
55 keypad (popup->win, TRUE);
56 getchCDKObject (ObjOf(popup), &functionKey);
57
58 /* Kill it. */
59 destroyCDKLabel (popup);
60
61 /* Clean the screen. */
62 curs_set(oldCursState);
63 eraseCDKScreen (screen);
64 refreshCDKScreen (screen);
65 }
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2005/12/30 00:27:48 $
5 * $Revision: 1.11 $
6 */
7
8 #undef ObjOf
9 #define ObjOf(ptr) (ptr)
10
11 /*
12 * This allows the user to use the cursor keys to adjust the
13 * position of the widget.
14 */
15 void positionCDKObject (CDKOBJS *obj, WINDOW *win)
16 {
17 CDKSCREEN *screen = ScreenOf(obj);
18 WINDOW *parent = screen->window;
19 int origX = getbegx(win);
20 int origY = getbegy(win);
21 int begX = getbegx(parent);
22 int begY = getbegy(parent);
23 int endX = begX + getmaxx(WindowOf(obj));
24 int endY = begY + getmaxy(WindowOf(obj));
25
26 chtype key;
27 boolean functionKey;
28
29 /* Let them move the widget around until they hit return. */
30 while ((key = getchCDKObject(obj, &functionKey)) != KEY_ENTER)
31 {
32 switch (key)
33 {
34 case KEY_UP:
35 case '8':
36 if (getbegy(win) > begY)
37 {
38 moveCDKObject (obj, 0, -1, TRUE, TRUE);
39 }
40 else
41 {
42 Beep();
43 }
44 break;
45 case KEY_DOWN:
46 case '2':
47 if (getendy(win) < endY)
48 {
49 moveCDKObject (obj, 0, 1, TRUE, TRUE);
50 }
51 else
52 {
53 Beep();
54 }
55 break;
56 case KEY_LEFT:
57 case '4':
58 if (getbegx(win) > begX)
59 {
60 moveCDKObject (obj, -1, 0, TRUE, TRUE);
61 }
62 else
63 {
64 Beep();
65 }
66 break;
67 case KEY_RIGHT:
68 case '6':
69 if (getendx(win) < endX)
70 {
71 moveCDKObject (obj, 1, 0, TRUE, TRUE);
72 }
73 else
74 {
75 Beep();
76 }
77 break;
78 case '7':
79 if (getbegy(win) > begY && getbegx(win) > begX)
80 {
81 moveCDKObject (obj, -1, -1, TRUE, TRUE);
82 }
83 else
84 {
85 Beep();
86 }
87 break;
88 case '9':
89 if (getendx(win) < endX && getbegy(win) > begY)
90 {
91 moveCDKObject (obj, 1, -1, TRUE, TRUE);
92 }
93 else
94 {
95 Beep();
96 }
97 break;
98 case '1':
99 if (getbegx(win) > begX && getendy(win) < endY)
100 {
101 moveCDKObject (obj, -1, 1, TRUE, TRUE);
102 }
103 else
104 {
105 Beep();
106 }
107 break;
108 case '3':
109 if (getendx(win) < endX && getendy(win) < endY)
110 {
111 moveCDKObject (obj, 1, 1, TRUE, TRUE);
112 }
113 else
114 {
115 Beep();
116 }
117 break;
118 case '5':
119 moveCDKObject (obj, CENTER, CENTER, FALSE, TRUE);
120 break;
121 case 't':
122 moveCDKObject (obj, getbegx(win), TOP, FALSE, TRUE);
123 break;
124 case 'b':
125 moveCDKObject (obj, getbegx(win), BOTTOM, FALSE, TRUE);
126 break;
127 case 'l':
128 moveCDKObject (obj, LEFT, getbegy(win), FALSE, TRUE);
129 break;
130 case 'r':
131 moveCDKObject (obj, RIGHT, getbegy(win), FALSE, TRUE);
132 break;
133 case 'c':
134 moveCDKObject (obj, CENTER, getbegy(win), FALSE, TRUE);
135 break;
136 case 'C':
137 moveCDKObject (obj, getbegx(win), CENTER, FALSE, TRUE);
138 break;
139 case CDK_REFRESH:
140 eraseCDKScreen (ScreenOf(obj));
141 refreshCDKScreen (ScreenOf(obj));
142 break;
143 case KEY_ESC:
144 moveCDKObject (obj, origX, origY, FALSE, TRUE);
145 break;
146 default:
147 Beep();
148 break;
149 }
150 }
151 }
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2005/12/30 00:29:34 $
5 * $Revision: 1.130 $
6 */
7
8 /*
9 * Declare file local prototypes.
10 */
11 static int createList (CDKRADIO *radio, char **list, int listSize, int width);
12 static void drawCDKRadioList (CDKRADIO *radio, boolean Box);
13 static void setViewSize(CDKRADIO *scrollp, int listSize);
14 static int maxViewSize(CDKRADIO *scrollp);
15
16 /* Determine how many characters we can shift to the right */
17 /* before all the items have been scrolled off the screen. */
18 #define AvailableWidth(w) ((w)->boxWidth - 2*BorderOf(w) - 3)
19 #define updateViewWidth(w, widest) \
20 (w)->maxLeftChar = (((w)->boxWidth > widest) \
21 ? 0 \
22 : (widest - AvailableWidth(w)))
23 #define WidestItem(w) ((w)->maxLeftChar + AvailableWidth(w))
24
25 #define SCREENPOS(w,n) (w)->itemPos[n] - (w)->leftChar + scrollbarAdj + BorderOf(w)
26
27 DeclareCDKObjects(RADIO, Radio, setCdk, Int);
28
29 /*
30 * This function creates the radio widget.
31 */
32 CDKRADIO *newCDKRadio (CDKSCREEN *cdkscreen, int xplace, int yplace, int splace, int height, int width, char *title, char **list, int listSize, chtype choiceChar, int defItem, chtype highlight, boolean Box, boolean shadow)
33 {
34 CDKRADIO *radio = 0;
35 int parentWidth = getmaxx(cdkscreen->window);
36 int parentHeight = getmaxy(cdkscreen->window);
37 int boxWidth = width;
38 int boxHeight = height;
39 int xpos = xplace;
40 int ypos = yplace;
41 int widestItem = 0;
42 int j;
43
44 static const struct { int from; int to; } bindings[] = {
45 { CDK_BACKCHAR, KEY_PPAGE },
46 { CDK_FORCHAR, KEY_NPAGE },
47 { 'g', KEY_HOME },
48 { '1', KEY_HOME },
49 { 'G', KEY_END },
50 { '<', KEY_HOME },
51 { '>', KEY_END },
52 };
53
54 if ((radio = newCDKObject(CDKRADIO, &my_funcs)) == 0)
55 {
56 return (0);
57 }
58
59 setCDKRadioBox (radio, Box);
60
61 /*
62 * If the height is a negative value, the height will
63 * be ROWS-height, otherwise, the height will be the
64 * given height.
65 */
66 boxHeight = setWidgetDimension (parentHeight, height, 0);
67
68 /*
69 * If the width is a negative value, the width will
70 * be COLS-width, otherwise, the width will be the
71 * given width.
72 */
73 boxWidth = setWidgetDimension (parentWidth, width, 5);
74
75 boxWidth = setCdkTitle(ObjOf(radio), title, boxWidth);
76
77 /* Set the box height. */
78 if (TitleLinesOf(radio) > boxHeight)
79 {
80 boxHeight = TitleLinesOf(radio)
81 + MINIMUM(listSize, 8)
82 + 2 * BorderOf(radio);
83 }
84
85 /* Adjust the box width if there is a scroll bar. */
86 if (splace == LEFT || splace == RIGHT)
87 {
88 boxWidth++;
89 radio->scrollbar = TRUE;
90 }
91 else
92 {
93 radio->scrollbar = FALSE;
94 }
95
96 /*
97 * Make sure we didn't extend beyond the dimensions of the window.
98 */
99 radio->boxWidth = MINIMUM(boxWidth, parentWidth);
100 radio->boxHeight = MINIMUM(boxHeight, parentHeight);
101
102 setViewSize(radio, listSize);
103
104 /* Each item in the needs to be converted to chtype * */
105 widestItem = createList(radio, list, listSize, radio->boxWidth);
106 if (widestItem > 0)
107 {
108 updateViewWidth(radio, widestItem);
109 }
110 else if (listSize)
111 {
112 destroyCDKObject(radio);
113 return (0);
114 }
115
116 /* Rejustify the x and y positions if we need to. */
117 alignxy (cdkscreen->window, &xpos, &ypos, radio->boxWidth, radio->boxHeight);
118
119 /* Make the radio window */
120 radio->win = newwin (radio->boxHeight, radio->boxWidth, ypos, xpos);
121
122 /* Is the window null??? */
123 if (radio->win == 0)
124 {
125 destroyCDKObject(radio);
126 return (0);
127 }
128
129 /* Turn on the keypad. */
130 keypad (radio->win, TRUE);
131
132 /* Create the scrollbar window. */
133 if (splace == RIGHT)
134 {
135 radio->scrollbarWin = subwin (radio->win,
136 maxViewSize(radio), 1,
137 SCREEN_YPOS(radio, ypos),
138 xpos + radio->boxWidth - BorderOf(radio) - 1);
139 }
140 else if (splace == LEFT)
141 {
142 radio->scrollbarWin = subwin (radio->win,
143 maxViewSize(radio), 1,
144 SCREEN_YPOS(radio, ypos),
145 SCREEN_XPOS(radio, xpos));
146 }
147 else
148 {
149 radio->scrollbarWin = 0;
150 }
151
152 /* Set the rest of the variables */
153 ScreenOf(radio) = cdkscreen;
154 radio->parent = cdkscreen->window;
155 radio->scrollbarPlacement = splace;
156 radio->widestItem = widestItem;
157 radio->leftChar = 0;
158 radio->selectedItem = 0;
159 radio->highlight = highlight;
160 radio->choiceChar = choiceChar;
161 radio->leftBoxChar = (chtype)'[';
162 radio->rightBoxChar = (chtype)']';
163 radio->defItem = defItem;
164 initExitType(radio);
165 ObjOf(radio)->inputWindow = radio->win;
166 ObjOf(radio)->acceptsFocus = TRUE;
167 radio->shadow = shadow;
168
169 setCDKRadioCurrentItem(radio, 0);
170
171 /* Do we need to create the shadow??? */
172 if (shadow)
173 {
174 radio->shadowWin = newwin (boxHeight, boxWidth + 1, ypos + 1, xpos + 1);
175 }
176
177 /* Setup the key bindings. */
178 for (j = 0; j < (int) SIZEOF(bindings); ++j)
179 bindCDKObject (vRADIO, radio, bindings[j].from, getcCDKBind, (void *)(long)bindings[j].to);
180
181 /* Register this baby. */
182 registerCDKObject (cdkscreen, vRADIO, radio);
183
184 /* Return the radio list */
185 return (radio);
186 }
187
188 /*
189 * Put the cursor on the currently-selected item.
190 */
191 static void fixCursorPosition (CDKRADIO *widget)
192 {
193 int scrollbarAdj = (widget->scrollbarPlacement == LEFT) ? 1 : 0;
194 int ypos = SCREEN_YPOS(widget, widget->currentItem - widget->currentTop);
195 int xpos = SCREEN_XPOS(widget, 0) + scrollbarAdj;
196
197 wmove(InputWindowOf(widget), ypos, xpos);
198 wrefresh(InputWindowOf(widget));
199 }
200
201 /*
202 * This actually manages the radio widget.
203 */
204 int activateCDKRadio (CDKRADIO *radio, chtype *actions)
205 {
206 /* Draw the radio list. */
207 drawCDKRadio (radio, ObjOf(radio)->box);
208
209 if (actions == 0)
210 {
211 chtype input;
212 boolean functionKey;
213 int ret;
214
215 for (;;)
216 {
217 fixCursorPosition (radio);
218 input = getchCDKObject (ObjOf(radio), &functionKey);
219
220 /* Inject the character into the widget. */
221 ret = injectCDKRadio (radio, input);
222 if (radio->exitType != vEARLY_EXIT)
223 {
224 return ret;
225 }
226 }
227 }
228 else
229 {
230 int length = chlen (actions);
231 int j, ret;
232
233 /* Inject each character one at a time. */
234 for (j=0; j < length; j++)
235 {
236 ret = injectCDKRadio (radio, actions[j]);
237 if (radio->exitType != vEARLY_EXIT)
238 {
239 return ret;
240 }
241 }
242 }
243
244 /* Set the exit type and return. */
245 setExitType(radio, 0);
246 return -1;
247 }
248
249 /*
250 * This injects a single character into the widget.
251 */
252 static int _injectCDKRadio (CDKOBJS *object, chtype input)
253 {
254 CDKRADIO *radio = (CDKRADIO *)object;
255 int ppReturn = 1;
256 int ret = unknownInt;
257 bool complete = FALSE;
258
259 /* Set the exit type. */
260 setExitType(radio, 0);
261
262 /* Draw the radio list */
263 drawCDKRadioList (radio, ObjOf(radio)->box);
264
265 /* Check if there is a pre-process function to be called. */
266 if (PreProcessFuncOf(radio) != 0)
267 {
268 /* Call the pre-process function. */
269 ppReturn = PreProcessFuncOf(radio) (vRADIO, radio, PreProcessDataOf(radio), input);
270 }
271
272 /* Should we continue? */
273 if (ppReturn != 0)
274 {
275 /* Check for a predefined key binding. */
276 if (checkCDKObjectBind (vRADIO, radio, input) != 0)
277 {
278 checkEarlyExit(radio);
279 complete = TRUE;
280 }
281 else
282 {
283 switch (input)
284 {
285 case KEY_UP :
286 scroller_KEY_UP(radio);
287 break;
288
289 case KEY_DOWN :
290 scroller_KEY_DOWN(radio);
291 break;
292
293 case KEY_RIGHT :
294 scroller_KEY_RIGHT(radio);
295 break;
296
297 case KEY_LEFT :
298 scroller_KEY_LEFT(radio);
299 break;
300
301 case KEY_PPAGE :
302 scroller_KEY_PPAGE(radio);
303 break;
304
305 case KEY_NPAGE :
306 scroller_KEY_NPAGE(radio);
307 break;
308
309 case KEY_HOME :
310 scroller_KEY_HOME(radio);
311 break;
312
313 case KEY_END :
314 scroller_KEY_END(radio);
315 break;
316
317 case '$' :
318 radio->leftChar = radio->maxLeftChar;
319 break;
320
321 case '|' :
322 radio->leftChar = 0;
323 break;
324
325 case SPACE :
326 radio->selectedItem = radio->currentItem;
327 break;
328
329 case KEY_ESC :
330 setExitType(radio, input);
331 ret = -1;
332 complete = TRUE;
333 break;
334
335 case KEY_TAB : case KEY_ENTER :
336 setExitType(radio, input);
337 ret = radio->selectedItem;
338 complete = TRUE;
339 break;
340
341 case CDK_REFRESH :
342 eraseCDKScreen (ScreenOf(radio));
343 refreshCDKScreen (ScreenOf(radio));
344 break;
345
346 default :
347 break;
348 }
349 }
350
351 /* Should we call a post-process? */
352 if (!complete && (PostProcessFuncOf(radio) != 0))
353 {
354 PostProcessFuncOf(radio) (vRADIO, radio, PostProcessDataOf(radio), input);
355 }
356 }
357
358 if (!complete) {
359 drawCDKRadioList (radio, ObjOf(radio)->box);
360 setExitType(radio, 0);
361 }
362
363 fixCursorPosition (radio);
364 ResultOf(radio).valueInt = ret;
365 return (ret != unknownInt);
366 }
367
368 /*
369 * This moves the radio field to the given location.
370 */
371 static void _moveCDKRadio (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag)
372 {
373 CDKRADIO *radio = (CDKRADIO *)object;
374 int currentX = getbegx(radio->win);
375 int currentY = getbegy(radio->win);
376 int xpos = xplace;
377 int ypos = yplace;
378 int xdiff = 0;
379 int ydiff = 0;
380
381 /*
382 * If this is a relative move, then we will adjust where we want
383 * to move to.
384 */
385 if (relative)
386 {
387 xpos = getbegx(radio->win) + xplace;
388 ypos = getbegy(radio->win) + yplace;
389 }
390
391 /* Adjust the window if we need to. */
392 alignxy (WindowOf(radio), &xpos, &ypos, radio->boxWidth, radio->boxHeight);
393
394 /* Get the difference. */
395 xdiff = currentX - xpos;
396 ydiff = currentY - ypos;
397
398 /* Move the window to the new location. */
399 moveCursesWindow(radio->win, -xdiff, -ydiff);
400 moveCursesWindow(radio->scrollbarWin, -xdiff, -ydiff);
401 moveCursesWindow(radio->shadowWin, -xdiff, -ydiff);
402
403 /* Touch the windows so they 'move'. */
404 refreshCDKWindow (WindowOf(radio));
405
406 /* Redraw the window, if they asked for it. */
407 if (refresh_flag)
408 {
409 drawCDKRadio (radio, ObjOf(radio)->box);
410 }
411 }
412
413 static int maxViewSize(CDKRADIO *widget)
414 {
415 return scroller_MaxViewSize(widget);
416 }
417
418 /*
419 * Set variables that depend upon the list-size.
420 */
421 static void setViewSize(CDKRADIO *widget, int listSize)
422 {
423 scroller_SetViewSize(widget, listSize);
424 }
425
426 /*
427 * This function draws the radio widget.
428 */
429 static void _drawCDKRadio (CDKOBJS *object, boolean Box GCC_UNUSED)
430 {
431 CDKRADIO *radio = (CDKRADIO *)object;
432
433 /* Do we need to draw in the shadow??? */
434 if (radio->shadowWin != 0)
435 {
436 drawShadow (radio->shadowWin);
437 }
438
439 drawCdkTitle (radio->win, object);
440
441 /* Draw in the radio list. */
442 drawCDKRadioList (radio, ObjOf(radio)->box);
443 }
444
445 /*
446 * This redraws the radio list.
447 */
448 static void drawCDKRadioList (CDKRADIO *radio, boolean Box)
449 {
450 int scrollbarAdj = (radio->scrollbarPlacement == LEFT) ? 1 : 0;
451 int screenPos = 0;
452 int j;
453 int xpos, ypos;
454
455 /* draw the list */
456 for (j=0; j < radio->viewSize; j++)
457 {
458 xpos = SCREEN_XPOS(radio, 0);
459 ypos = SCREEN_YPOS(radio, j);
460
461 screenPos = SCREENPOS(radio, j + radio->currentTop);
462
463 /* Draw the empty string. */
464 writeBlanks (radio->win, xpos, ypos,
465 HORIZONTAL, 0, radio->boxWidth - BorderOf(radio));
466
467 /* Draw the line. */
468 writeChtype (radio->win,
469 (screenPos >= 0) ? screenPos : 1,
470 ypos,
471 radio->item[j + radio->currentTop],
472 HORIZONTAL,
473 (screenPos >= 0) ? 0 : (1 - screenPos),
474 radio->itemLen[j + radio->currentTop]);
475
476 /* Draw the selected choice... */
477 xpos += scrollbarAdj;
478 mvwaddch (radio->win, ypos, xpos++, radio->leftBoxChar);
479 mvwaddch (radio->win, ypos, xpos++, ((j + radio->currentTop) == radio->selectedItem) ? radio->choiceChar : ' ');
480 mvwaddch (radio->win, ypos, xpos++, radio->rightBoxChar);
481 }
482
483 /* Highlight the current item. */
484 if (ObjPtr(radio)->hasFocus)
485 {
486 screenPos = SCREENPOS(radio, radio->currentItem);
487 ypos = SCREEN_YPOS(radio, radio->currentHigh);
488
489 writeChtypeAttrib (radio->win,
490 (screenPos >= 0) ? screenPos : (1 + scrollbarAdj),
491 ypos,
492 radio->item[radio->currentItem],
493 radio->highlight,
494 HORIZONTAL,
495 (screenPos >= 0) ? 0 : (1 - screenPos),
496 radio->itemLen[radio->currentItem]);
497 }
498
499 if (radio->scrollbar)
500 {
501 radio->togglePos = floorCDK(radio->currentItem * radio->step);
502 radio->togglePos = MINIMUM(radio->togglePos, getmaxy(radio->scrollbarWin) - 1);
503
504 mvwvline (radio->scrollbarWin, 0, 0, ACS_CKBOARD, getmaxy(radio->scrollbarWin));
505 mvwvline (radio->scrollbarWin, radio->togglePos, 0, ' ' | A_REVERSE, radio->toggleSize);
506 }
507
508 /* Box it if needed. */
509 if (Box)
510 {
511 drawObjBox (radio->win, ObjOf(radio));
512 }
513
514 fixCursorPosition (radio);
515 }
516
517 /*
518 * This sets the background attribute of the widget.
519 */
520 static void _setBKattrRadio (CDKOBJS *object, chtype attrib)
521 {
522 if (object != 0)
523 {
524 CDKRADIO *widget = (CDKRADIO *) object;
525
526 wbkgd (widget->win, attrib);
527 if (widget->scrollbarWin != 0)
528 {
529 wbkgd (widget->scrollbarWin, attrib);
530 }
531 }
532 }
533
534 static void destroyInfo(CDKRADIO *widget)
535 {
536 CDKfreeChtypes (widget->item);
537 widget->item = 0;
538
539 freeAndNull (widget->itemLen);
540 freeAndNull (widget->itemPos);
541 }
542
543 /*
544 * This function destroys the radio widget.
545 */
546 static void _destroyCDKRadio (CDKOBJS *object)
547 {
548 if (object != 0)
549 {
550 CDKRADIO *radio = (CDKRADIO *)object;
551
552 cleanCdkTitle (object);
553 destroyInfo (radio);
554
555 /* Clean up the windows. */
556 deleteCursesWindow (radio->scrollbarWin);
557 deleteCursesWindow (radio->shadowWin);
558 deleteCursesWindow (radio->win);
559
560 /* Clean the key bindings. */
561 cleanCDKObjectBindings (vRADIO, radio);
562
563 /* Unregister this object. */
564 unregisterCDKObject (vRADIO, radio);
565 }
566 }
567
568 /*
569 * This function erases the radio widget.
570 */
571 static void _eraseCDKRadio (CDKOBJS *object)
572 {
573 if (validCDKObject (object))
574 {
575 CDKRADIO *radio = (CDKRADIO *)object;
576
577 eraseCursesWindow (radio->win);
578 eraseCursesWindow (radio->shadowWin);
579 }
580 }
581
582 /*
583 * This set various attributes of the radio list.
584 */
585 void setCDKRadio (CDKRADIO *radio, chtype highlight, chtype choiceChar, int Box)
586 {
587 setCDKRadioHighlight (radio, highlight);
588 setCDKRadioChoiceCharacter (radio, choiceChar);
589 setCDKRadioBox (radio, Box);
590 }
591
592 /*
593 * This sets the radio list items.
594 */
595 void setCDKRadioItems (CDKRADIO *radio, char **list, int listSize)
596 {
597 int widestItem = -1;
598 int j = 0;
599
600 widestItem = createList(radio, list, listSize, radio->boxWidth);
601 if (widestItem <= 0)
602 return;
603
604 /* Clean up the display. */
605 for (j=0; j < radio->viewSize ; j++)
606 {
607 writeBlanks (radio->win,
608 SCREEN_XPOS(radio, 0),
609 SCREEN_YPOS(radio, j),
610 HORIZONTAL,
611 0,
612 radio->boxWidth - BorderOf(radio));
613 }
614
615 setViewSize(radio, listSize);
616
617 setCDKRadioCurrentItem(radio, 0);
618 radio->leftChar = 0;
619 radio->selectedItem = 0;
620
621 updateViewWidth(radio, widestItem);
622 }
623 int getCDKRadioItems (CDKRADIO *radio, char **list)
624 {
625 int j;
626
627 if (list != 0)
628 {
629 for (j=0; j < radio->listSize; j++)
630 {
631 list[j] = chtype2Char (radio->item[j]);
632 }
633 }
634 return radio->listSize;
635 }
636
637 /*
638 * This sets the highlight bar of the radio list.
639 */
640 void setCDKRadioHighlight (CDKRADIO *radio, chtype highlight)
641 {
642 radio->highlight = highlight;
643 }
644 chtype getCDKRadioHighlight (CDKRADIO *radio)
645 {
646 return radio->highlight;
647 }
648
649 /*
650 * This sets the character to use when selecting an item in the list.
651 */
652 void setCDKRadioChoiceCharacter (CDKRADIO *radio, chtype character)
653 {
654 radio->choiceChar = character;
655 }
656 chtype getCDKRadioChoiceCharacter (CDKRADIO *radio)
657 {
658 return radio->choiceChar;
659 }
660
661 /*
662 * This sets the character to use to draw the left side of the
663 * choice box on the list.
664 */
665 void setCDKRadioLeftBrace (CDKRADIO *radio, chtype character)
666 {
667 radio->leftBoxChar = character;
668 }
669 chtype getCDKRadioLeftBrace (CDKRADIO *radio)
670 {
671 return radio->leftBoxChar;
672 }
673
674 /*
675 * This sets the character to use to draw the right side of the
676 * choice box on the list.
677 */
678 void setCDKRadioRightBrace (CDKRADIO *radio, chtype character)
679 {
680 radio->rightBoxChar = character;
681 }
682 chtype getCDKRadioRightBrace (CDKRADIO *radio)
683 {
684 return radio->rightBoxChar;
685 }
686
687 /*
688 * This sets the box attribute of the widget.
689 */
690 void setCDKRadioBox (CDKRADIO *radio, boolean Box)
691 {
692 ObjOf(radio)->box = Box;
693 ObjOf(radio)->borderSize = Box ? 1 : 0;
694 }
695 boolean getCDKRadioBox (CDKRADIO *radio)
696 {
697 return ObjOf(radio)->box;
698 }
699
700 /*
701 * This sets the current high lighted item of the widget
702 */
703 void setCDKRadioCurrentItem (CDKRADIO *radio, int item)
704 {
705 scroller_SetPosition(radio, item);
706 radio->selectedItem = item;
707 }
708 int getCDKRadioCurrentItem (CDKRADIO *radio)
709 {
710 return radio->currentItem;
711 }
712
713 /*
714 * This sets the selected item of the widget
715 */
716 void setCDKRadioSelectedItem (CDKRADIO *radio, int item)
717 {
718 radio->selectedItem = item;
719 }
720 int getCDKRadioSelectedItem (CDKRADIO *radio)
721 {
722 return radio->selectedItem;
723 }
724
725 static void _focusCDKRadio(CDKOBJS *object)
726 {
727 CDKRADIO *radio = (CDKRADIO *)object;
728
729 drawCDKRadioList (radio, ObjOf(radio)->box);
730 }
731
732 static void _unfocusCDKRadio(CDKOBJS *object)
733 {
734 CDKRADIO *radio = (CDKRADIO *)object;
735
736 drawCDKRadioList (radio, ObjOf(radio)->box);
737 }
738
739 static int createList (CDKRADIO *radio, char **list, int listSize, int boxWidth)
740 {
741 int status = 0;
742 int widestItem = 0;
743
744 if (listSize > 0)
745 {
746 chtype **newList = typeCallocN(chtype *, listSize + 1);
747 int *newLen = typeCallocN(int, listSize + 1);
748 int *newPos = typeCallocN(int, listSize + 1);
749 int j;
750
751 if (newList != 0
752 && newLen != 0
753 && newPos != 0)
754 {
755 /* Each item in the needs to be converted to chtype * */
756 status = 1;
757 boxWidth -= (2 + BorderOf(radio));
758 for (j=0; j < listSize; j++)
759 {
760 newList[j] = char2Chtype (list[j], &newLen[j], &newPos[j]);
761 if (newList[j] == 0)
762 {
763 status = 0;
764 break;
765 }
766 newPos[j] = justifyString (boxWidth, newLen[j], newPos[j]) + 3;
767 widestItem = MAXIMUM(widestItem, newLen[j]);
768 }
769 if (status)
770 {
771 destroyInfo (radio);
772
773 radio->item = newList;
774 radio->itemLen = newLen;
775 radio->itemPos = newPos;
776 }
777 else
778 {
779 CDKfreeChtypes (newList);
780 freeChecked (newLen);
781 freeChecked (newPos);
782 }
783 }
784 }
785 else
786 {
787 destroyInfo (radio);
788 }
789
790 return status ? widestItem : 0;
791 }
792
793 dummyRefreshData(Radio)
794
795 dummySaveData(Radio)
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:24:56 $
5 * $Revision: 1.146 $
6 */
7
8 /*
9 * Declare file local prototypes.
10 */
11 static void drawCDKScrollList (CDKSCROLL *scrollp, boolean Box);
12 static int createCDKScrollItemList (CDKSCROLL *scrollp, boolean numbers,
13 char **list, int listSize);
14 static void fixCursorPosition (CDKSCROLL *widget);
15 static void setViewSize (CDKSCROLL *scrollp, int listSize);
16 static int maxViewSize (CDKSCROLL *scrollp);
17
18 #define NUMBER_FMT "%4d. %s"
19 #define NUMBER_LEN(s) (8 + strlen (s))
20
21 /* Determine how many characters we can shift to the right */
22 /* before all the items have been scrolled off the screen. */
23 #define AvailableWidth(w) ((w)->boxWidth - 2 * BorderOf (w))
24 #define updateViewWidth(w, widest) \
25 (w)->maxLeftChar = (((w)->boxWidth > widest) \
26 ? 0 \
27 : (widest - AvailableWidth (w)))
28 #define WidestItem(w) ((w)->maxLeftChar + AvailableWidth (w))
29
30 #define SCREENPOS(w,n) (w)->itemPos[n] - (w)->leftChar /* + scrollbarAdj + BorderOf(w) */
31
32 DeclareCDKObjects (SCROLL, Scroll, setCdk, Int);
33
34 /*
35 * This function creates a new scrolling list widget.
36 */
37 CDKSCROLL *newCDKScroll (CDKSCREEN *cdkscreen,
38 int xplace,
39 int yplace,
40 int splace,
41 int height,
42 int width,
43 char *title,
44 char **list,
45 int listSize,
46 boolean numbers,
47 chtype highlight,
48 boolean Box,
49 boolean shadow)
50 {
51 CDKSCROLL *scrollp = 0;
52 int parentWidth = getmaxx (cdkscreen->window);
53 int parentHeight = getmaxy (cdkscreen->window);
54 int boxWidth = width;
55 int boxHeight = height;
56 int xpos = xplace;
57 int ypos = yplace;
58 int scrollAdjust = 0;
59 int x;
60
61 /* *INDENT-OFF* */
62 static const struct { int from; int to; } bindings[] = {
63 { CDK_BACKCHAR, KEY_PPAGE },
64 { CDK_FORCHAR, KEY_NPAGE },
65 { 'g', KEY_HOME },
66 { '1', KEY_HOME },
67 { 'G', KEY_END },
68 { '<', KEY_HOME },
69 { '>', KEY_END },
70 };
71 /* *INDENT-ON* */
72
73 if ((scrollp = newCDKObject (CDKSCROLL, &my_funcs)) == 0)
74 {
75 destroyCDKObject (scrollp);
76 return (0);
77 }
78
79 setCDKScrollBox (scrollp, Box);
80
81 /*
82 * If the height is a negative value, the height will
83 * be ROWS-height, otherwise, the height will be the
84 * given height.
85 */
86 boxHeight = setWidgetDimension (parentHeight, height, 0);
87
88 /*
89 * If the width is a negative value, the width will
90 * be COLS-width, otherwise, the width will be the
91 * given width.
92 */
93 boxWidth = setWidgetDimension (parentWidth, width, 0);
94
95 boxWidth = setCdkTitle (ObjOf (scrollp), title, boxWidth);
96
97 /* Set the box height. */
98 if (TitleLinesOf (scrollp) > boxHeight)
99 {
100 boxHeight = (TitleLinesOf (scrollp)
101 + MINIMUM (listSize, 8)
102 + 2 * BorderOf (scrollp));
103 }
104
105 /* Adjust the box width if there is a scrollp bar. */
106 if ((splace == LEFT) || (splace == RIGHT))
107 {
108 scrollp->scrollbar = TRUE;
109 boxWidth += 1;
110 }
111 else
112 {
113 scrollp->scrollbar = FALSE;
114 }
115
116 /*
117 * Make sure we didn't extend beyond the dimensions of the window.
118 */
119 scrollp->boxWidth = (boxWidth > parentWidth
120 ? (parentWidth - scrollAdjust)
121 : boxWidth);
122 scrollp->boxHeight = (boxHeight > parentHeight
123 ? parentHeight
124 : boxHeight);
125
126 setViewSize (scrollp, listSize);
127
128 /* Rejustify the x and y positions if we need to. */
129 alignxy (cdkscreen->window, &xpos, &ypos, scrollp->boxWidth, scrollp->boxHeight);
130
131 /* Make the scrolling window */
132 scrollp->win = newwin (scrollp->boxHeight, scrollp->boxWidth, ypos, xpos);
133
134 /* Is the scrolling window null?? */
135 if (scrollp->win == 0)
136 {
137 destroyCDKObject (scrollp);
138 return (0);
139 }
140
141 /* Turn the keypad on for the window. */
142 keypad (scrollp->win, TRUE);
143
144 /* Create the scrollbar window. */
145 if (splace == RIGHT)
146 {
147 scrollp->scrollbarWin = subwin (scrollp->win,
148 maxViewSize (scrollp), 1,
149 SCREEN_YPOS (scrollp, ypos),
150 xpos + scrollp->boxWidth
151 - BorderOf (scrollp) - 1);
152 }
153 else if (splace == LEFT)
154 {
155 scrollp->scrollbarWin = subwin (scrollp->win,
156 maxViewSize (scrollp), 1,
157 SCREEN_YPOS (scrollp, ypos),
158 SCREEN_XPOS (scrollp, xpos));
159 }
160 else
161 {
162 scrollp->scrollbarWin = 0;
163 }
164
165 /* create the list window */
166
167 scrollp->listWin = subwin (scrollp->win,
168 maxViewSize (scrollp),
169 scrollp->boxWidth
170 - 2 * BorderOf (scrollp) - scrollAdjust,
171 SCREEN_YPOS (scrollp, ypos),
172 SCREEN_XPOS (scrollp, xpos)
173 + (splace == LEFT ? 1 : 0));
174
175 /* Set the rest of the variables */
176 ScreenOf (scrollp) = cdkscreen;
177 scrollp->parent = cdkscreen->window;
178 scrollp->shadowWin = 0;
179 scrollp->scrollbarPlacement = splace;
180 scrollp->maxLeftChar = 0;
181 scrollp->leftChar = 0;
182 scrollp->highlight = highlight;
183 initExitType (scrollp);
184 ObjOf (scrollp)->acceptsFocus = TRUE;
185 ObjOf (scrollp)->inputWindow = scrollp->win;
186 scrollp->shadow = shadow;
187
188 setCDKScrollPosition (scrollp, 0);
189
190 /* Create the scrolling list item list and needed variables. */
191 if (createCDKScrollItemList (scrollp, numbers, list, listSize) <= 0)
192 {
193 destroyCDKObject (scrollp);
194 return (0);
195 }
196
197 /* Do we need to create a shadow? */
198 if (shadow)
199 {
200 scrollp->shadowWin = newwin (scrollp->boxHeight,
201 boxWidth,
202 ypos + 1,
203 xpos + 1);
204 }
205
206 /* Setup the key bindings. */
207 for (x = 0; x < (int) SIZEOF (bindings); ++x)
208 bindCDKObject (vSCROLL, scrollp, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to);
209
210 registerCDKObject (cdkscreen, vSCROLL, scrollp);
211
212 /* Return the scrolling list */
213 return scrollp;
214 }
215
216 /*
217 * Put the cursor on the currently-selected item's row.
218 */
219 static void fixCursorPosition (CDKSCROLL *widget)
220 {
221 int scrollbarAdj = (widget->scrollbarPlacement == LEFT) ? 1 : 0;
222 int ypos = SCREEN_YPOS (widget, widget->currentItem - widget->currentTop);
223 int xpos = SCREEN_XPOS (widget, 0) + scrollbarAdj;
224
225 wmove (InputWindowOf (widget), ypos, xpos);
226 wrefresh (InputWindowOf (widget));
227 }
228
229 /*
230 * This actually does all the 'real' work of managing the scrolling list.
231 */
232 int activateCDKScroll (CDKSCROLL *scrollp, chtype *actions)
233 {
234 /* Draw the scrolling list */
235 drawCDKScroll (scrollp, ObjOf (scrollp)->box);
236
237 if (actions == 0)
238 {
239 chtype input;
240 boolean functionKey;
241 int ret;
242
243 for (;;)
244 {
245 fixCursorPosition (scrollp);
246 input = getchCDKObject (ObjOf (scrollp), &functionKey);
247
248 /* Inject the character into the widget. */
249 ret = injectCDKScroll (scrollp, input);
250 if (scrollp->exitType != vEARLY_EXIT)
251 {
252 return ret;
253 }
254 }
255 }
256 else
257 {
258 int length = chlen (actions);
259 int i = 0;
260 int ret;
261
262 /* Inject each character one at a time. */
263 for (i = 0; i < length; i++)
264 {
265 ret = injectCDKScroll (scrollp, actions[i]);
266 if (scrollp->exitType != vEARLY_EXIT)
267 return ret;
268 }
269 }
270
271 /* Set the exit type for the widget and return. */
272 setExitType (scrollp, 0);
273 return -1;
274 }
275
276 /*
277 * This injects a single character into the widget.
278 */
279 static int _injectCDKScroll (CDKOBJS *object, chtype input)
280 {
281 CDKSCROLL *scrollp = (CDKSCROLL *)object;
282 int ppReturn = 1;
283 int ret = unknownInt;
284 bool complete = FALSE;
285
286 /* Set the exit type for the widget. */
287 setExitType (scrollp, 0);
288
289 /* Draw the scrolling list */
290 drawCDKScrollList (scrollp, ObjOf (scrollp)->box);
291
292 /* Check if there is a pre-process function to be called. */
293 if (PreProcessFuncOf (scrollp) != 0)
294 {
295 /* Call the pre-process function. */
296 ppReturn = PreProcessFuncOf (scrollp) (vSCROLL,
297 scrollp,
298 PreProcessDataOf (scrollp),
299 input);
300 }
301
302 /* Should we continue? */
303 if (ppReturn != 0)
304 {
305 /* Check for a predefined key binding. */
306 if (checkCDKObjectBind (vSCROLL, scrollp, input) != 0)
307 {
308 checkEarlyExit (scrollp);
309 complete = TRUE;
310 }
311 else
312 {
313 switch (input)
314 {
315 case KEY_UP:
316 scroller_KEY_UP (scrollp);
317 break;
318
319 case KEY_DOWN:
320 scroller_KEY_DOWN (scrollp);
321 break;
322
323 case KEY_RIGHT:
324 scroller_KEY_RIGHT (scrollp);
325 break;
326
327 case KEY_LEFT:
328 scroller_KEY_LEFT (scrollp);
329 break;
330
331 case KEY_PPAGE:
332 scroller_KEY_PPAGE (scrollp);
333 break;
334
335 case KEY_NPAGE:
336 scroller_KEY_NPAGE (scrollp);
337 break;
338
339 case KEY_HOME:
340 scroller_KEY_HOME (scrollp);
341 break;
342
343 case KEY_END:
344 scroller_KEY_END (scrollp);
345 break;
346
347 case '$':
348 scrollp->leftChar = scrollp->maxLeftChar;
349 break;
350
351 case '|':
352 scrollp->leftChar = 0;
353 break;
354
355 case KEY_ESC:
356 setExitType (scrollp, input);
357 complete = TRUE;
358 break;
359
360 case CDK_REFRESH:
361 eraseCDKScreen (ScreenOf (scrollp));
362 refreshCDKScreen (ScreenOf (scrollp));
363 break;
364
365 case KEY_TAB:
366 case KEY_ENTER:
367 setExitType (scrollp, input);
368 ret = scrollp->currentItem;
369 complete = TRUE;
370 break;
371
372 default:
373 break;
374 }
375 }
376
377 /* Should we call a post-process? */
378 if (!complete && (PostProcessFuncOf (scrollp) != 0))
379 {
380 PostProcessFuncOf (scrollp) (vSCROLL,
381 scrollp,
382 PostProcessDataOf (scrollp),
383 input);
384 }
385 }
386
387 if (!complete)
388 {
389 drawCDKScrollList (scrollp, ObjOf (scrollp)->box);
390 setExitType (scrollp, 0);
391 }
392
393 fixCursorPosition (scrollp);
394 ResultOf (scrollp).valueInt = ret;
395 return (ret != unknownInt);
396 }
397
398 /*
399 * This allows the user to accelerate to a position in the scrolling list.
400 */
401 void setCDKScrollPosition (CDKSCROLL *scrollp, int item)
402 {
403 scroller_SetPosition (scrollp, item);
404 }
405
406 /* obsolete (because the name is inconsistent) */
407 int getCDKScrollCurrent (CDKSCROLL *scrollp)
408 {
409 return scrollp->currentItem;
410 }
411
412 void setCDKScrollCurrent (CDKSCROLL *scrollp, int item)
413 {
414 scroller_SetPosition (scrollp, item);
415 }
416
417 /*
418 * Get/Set the current item number of the scroller.
419 */
420 int getCDKScrollCurrentItem (CDKSCROLL *widget)
421 {
422 return widget->currentItem;
423 }
424
425 void setCDKScrollCurrentItem (CDKSCROLL *widget, int item)
426 {
427 scroller_SetPosition (widget, item);
428 }
429
430 /*
431 * Get/Set the top line of the scroller.
432 */
433 int getCDKScrollCurrentTop (CDKSCROLL *widget)
434 {
435 return widget->currentTop;
436 }
437
438 void setCDKScrollCurrentTop (CDKSCROLL *widget, int item)
439 {
440 if (item < 0)
441 item = 0;
442 else if (item > widget->maxTopItem)
443 item = widget->maxTopItem;
444 widget->currentTop = item;
445
446 scroller_SetPosition (widget, item);
447 }
448
449 /*
450 * This moves the scroll field to the given location.
451 */
452 static void _moveCDKScroll (CDKOBJS *object,
453 int xplace,
454 int yplace,
455 boolean relative,
456 boolean refresh_flag)
457 {
458 CDKSCROLL *scrollp = (CDKSCROLL *)object;
459 int currentX = getbegx (scrollp->win);
460 int currentY = getbegy (scrollp->win);
461 int xpos = xplace;
462 int ypos = yplace;
463 int xdiff = 0;
464 int ydiff = 0;
465
466 /*
467 * If this is a relative move, then we will adjust where we want
468 * to move to.
469 */
470 if (relative)
471 {
472 xpos = getbegx (scrollp->win) + xplace;
473 ypos = getbegy (scrollp->win) + yplace;
474 }
475
476 /* Adjust the window if we need to. */
477 alignxy (WindowOf (scrollp), &xpos, &ypos, scrollp->boxWidth, scrollp->boxHeight);
478
479 /* Get the difference. */
480 xdiff = currentX - xpos;
481 ydiff = currentY - ypos;
482
483 /* Move the window to the new location. */
484 moveCursesWindow (scrollp->win, -xdiff, -ydiff);
485 moveCursesWindow (scrollp->listWin, -xdiff, -ydiff);
486 moveCursesWindow (scrollp->shadowWin, -xdiff, -ydiff);
487 moveCursesWindow (scrollp->scrollbarWin, -xdiff, -ydiff);
488
489 /* Touch the windows so they 'move'. */
490 refreshCDKWindow (WindowOf (scrollp));
491
492 /* Redraw the window, if they asked for it. */
493 if (refresh_flag)
494 {
495 drawCDKScroll (scrollp, ObjOf (scrollp)->box);
496 }
497 }
498
499 /*
500 * This function draws the scrolling list widget.
501 */
502 static void _drawCDKScroll (CDKOBJS *object, boolean Box)
503 {
504 CDKSCROLL *scrollp = (CDKSCROLL *)object;
505
506 /* Draw in the shadow if we need to. */
507 if (scrollp->shadowWin != 0)
508 drawShadow (scrollp->shadowWin);
509
510 drawCdkTitle (scrollp->win, object);
511
512 /* Draw in the scolling list items. */
513 drawCDKScrollList (scrollp, Box);
514 }
515
516 static void drawCDKScrollCurrent (CDKSCROLL *s)
517 {
518 /* Rehighlight the current menu item. */
519 int screenPos = s->itemPos[s->currentItem] - s->leftChar;
520 chtype highlight = HasFocusObj (s) ? s->highlight : A_NORMAL;
521
522 writeChtypeAttrib (s->listWin,
523 (screenPos >= 0) ? screenPos : 0,
524 s->currentHigh,
525 s->item[s->currentItem],
526 highlight,
527 HORIZONTAL,
528 (screenPos >= 0) ? 0 : (1 - screenPos),
529 s->itemLen[s->currentItem]);
530 }
531
532 static int maxViewSize (CDKSCROLL *scrollp)
533 {
534 return scroller_MaxViewSize (scrollp);
535 }
536
537 /*
538 * Set variables that depend upon the list-size.
539 */
540 static void setViewSize (CDKSCROLL *scrollp, int listSize)
541 {
542 scroller_SetViewSize (scrollp, listSize);
543 }
544
545 #undef SCREEN_YPOS /* because listWin is separate */
546 #define SCREEN_YPOS(w,n) (n)
547
548 /*
549 * This redraws the scrolling list.
550 */
551 static void drawCDKScrollList (CDKSCROLL *scrollp, boolean Box)
552 {
553 int j;
554
555 /* If the list is empty, don't draw anything. */
556 if (scrollp->listSize > 0)
557 {
558 /* Redraw the list */
559 for (j = 0; j < scrollp->viewSize; j++)
560 {
561 int k = j + scrollp->currentTop;
562
563 writeBlanks (scrollp->listWin,
564 0, j,
565 HORIZONTAL, 0,
566 scrollp->boxWidth - 2 * BorderOf (scrollp));
567
568 /* Draw the elements in the scrolling list. */
569 if (k < scrollp->listSize)
570 {
571 int screenPos = SCREENPOS (scrollp, j + scrollp->currentTop);
572 int ypos = SCREEN_YPOS (scrollp, j);
573
574 /* Write in the correct line. */
575 writeChtype (scrollp->listWin,
576 (screenPos >= 0) ? screenPos : 1,
577 ypos,
578 scrollp->item[k],
579 HORIZONTAL,
580 (screenPos >= 0) ? 0 : (1 - screenPos),
581 scrollp->itemLen[k]);
582 }
583 }
584
585 drawCDKScrollCurrent (scrollp);
586
587 /* Determine where the toggle is supposed to be. */
588 if (scrollp->scrollbarWin != 0)
589 {
590 scrollp->togglePos = floorCDK (scrollp->currentItem * scrollp->step);
591
592 /* Make sure the toggle button doesn't go out of bounds. */
593
594 if (scrollp->togglePos >= getmaxy (scrollp->scrollbarWin))
595 scrollp->togglePos = getmaxy (scrollp->scrollbarWin) - 1;
596
597 /* Draw the scrollbar. */
598 mvwvline (scrollp->scrollbarWin,
599 0, 0,
600 ACS_CKBOARD,
601 getmaxy (scrollp->scrollbarWin));
602 mvwvline (scrollp->scrollbarWin,
603 scrollp->togglePos, 0,
604 ' ' | A_REVERSE,
605 scrollp->toggleSize);
606 }
607 }
608
609 /* Box it if needed. */
610 if (Box)
611 {
612 drawObjBox (scrollp->win, ObjOf (scrollp));
613 }
614
615 /* Refresh the window. */
616 wrefresh (scrollp->win);
617 }
618
619 /*
620 * This sets the background attribute of the widget.
621 */
622 static void _setBKattrScroll (CDKOBJS *object, chtype attrib)
623 {
624 if (object != 0)
625 {
626 CDKSCROLL *widget = (CDKSCROLL *)object;
627
628 wbkgd (widget->win, attrib);
629 wbkgd (widget->listWin, attrib);
630 if (widget->scrollbarWin != 0)
631 {
632 wbkgd (widget->scrollbarWin, attrib);
633 }
634 }
635 }
636
637 /*
638 * This function destroys
639 */
640 static void _destroyCDKScroll (CDKOBJS *object)
641 {
642 if (object != 0)
643 {
644 CDKSCROLL *scrollp = (CDKSCROLL *)object;
645
646 cleanCdkTitle (object);
647 CDKfreeChtypes (scrollp->item);
648 freeChecked (scrollp->itemPos);
649 freeChecked (scrollp->itemLen);
650
651 /* Clean up the windows. */
652 deleteCursesWindow (scrollp->scrollbarWin);
653 deleteCursesWindow (scrollp->shadowWin);
654 deleteCursesWindow (scrollp->listWin);
655 deleteCursesWindow (scrollp->win);
656
657 /* Clean the key bindings. */
658 cleanCDKObjectBindings (vSCROLL, scrollp);
659
660 /* Unregister this object. */
661 unregisterCDKObject (vSCROLL, scrollp);
662 }
663 }
664
665 /*
666 * This function erases the scrolling list from the screen.
667 */
668 static void _eraseCDKScroll (CDKOBJS *object)
669 {
670 if (validCDKObject (object))
671 {
672 CDKSCROLL *scrollp = (CDKSCROLL *)object;
673
674 eraseCursesWindow (scrollp->win);
675 eraseCursesWindow (scrollp->shadowWin);
676 }
677 }
678
679 static boolean allocListArrays (CDKSCROLL *scrollp,
680 int oldSize,
681 int newSize)
682 {
683 boolean result;
684 int n;
685 int nchunk = ((newSize + 1) | 31) + 1;
686 chtype ** newList = typeCallocN (chtype *, nchunk);
687 int * newLen = typeCallocN (int, nchunk);
688 int * newPos = typeCallocN (int, nchunk);
689
690 if (newList != 0 &&
691 newLen != 0 &&
692 newPos != 0)
693 {
694 for (n = 0; n < oldSize; ++n)
695 {
696 newList[n] = scrollp->item[n];
697 newLen[n] = scrollp->itemLen[n];
698 newPos[n] = scrollp->itemPos[n];
699 }
700
701 if (oldSize == 0)
702 {
703 CDKfreeChtypes (scrollp->item);
704 freeChecked (scrollp->itemPos);
705 freeChecked (scrollp->itemLen);
706 }
707
708 scrollp->item = newList;
709 scrollp->itemLen = newLen;
710 scrollp->itemPos = newPos;
711 result = TRUE;
712 }
713 else
714 {
715 freeChecked (newList);
716 freeChecked (newLen);
717 freeChecked (newPos);
718 result = FALSE;
719 }
720 return result;
721 }
722
723 static boolean allocListItem (CDKSCROLL *scrollp,
724 int which,
725 char **work,
726 unsigned *used,
727 int number,
728 char *value)
729 {
730 if (number > 0)
731 {
732 unsigned need = NUMBER_LEN (value);
733 if (need > *used)
734 {
735 *used = ((need + 2) * 2);
736 if (*work == 0)
737 {
738 if ((*work = (char *)malloc (*used)) == 0)
739 return FALSE;
740 }
741 else
742 {
743 if ((*work = (char *)realloc (*work, *used)) == 0)
744 return FALSE;
745 }
746 }
747 sprintf (*work, NUMBER_FMT, number, value);
748 value = *work;
749 }
750
751 if ((scrollp->item[which] = char2Chtype (value,
752 &(scrollp->itemLen[which]),
753 &(scrollp->itemPos[which]))) == 0)
754 return FALSE;
755
756 scrollp->itemPos[which] = justifyString (scrollp->boxWidth,
757 scrollp->itemLen[which],
758 scrollp->itemPos[which]);
759
760 return TRUE;
761 }
762
763 /*
764 * This function creates the scrolling list information and sets up the needed
765 * variables for the scrolling list to work correctly.
766 */
767 static int createCDKScrollItemList (CDKSCROLL *scrollp,
768 boolean numbers,
769 char **list,
770 int listSize)
771 {
772 int status = 0;
773
774 if (listSize > 0)
775 {
776 int widestItem = 0;
777 int x = 0;
778 unsigned have = 0;
779 char *temp = 0;
780
781 if (allocListArrays (scrollp, 0, listSize))
782 {
783 /* Create the items in the scrolling list. */
784 status = 1;
785 for (x = 0; x < listSize; x++)
786 {
787 if (!allocListItem (scrollp,
788 x,
789 &temp,
790 &have,
791 numbers ? (x + 1) : 0,
792 list[x]))
793 {
794 status = 0;
795 break;
796 }
797
798 widestItem = MAXIMUM (scrollp->itemLen[x], widestItem);
799 }
800 freeChecked (temp);
801
802 if (status)
803 {
804 updateViewWidth (scrollp, widestItem);
805
806 /* Keep the boolean flag 'numbers' */
807 scrollp->numbers = numbers;
808 }
809 }
810 }
811 else
812 {
813 status = 1; /* null list is ok - for a while */
814 }
815
816 return status;
817 }
818
819 /*
820 * This sets certain attributes of the scrolling list.
821 */
822 void setCDKScroll (CDKSCROLL *scrollp,
823 char **list,
824 int listSize,
825 boolean numbers,
826 chtype highlight,
827 boolean Box)
828 {
829 setCDKScrollItems (scrollp, list, listSize, numbers);
830 setCDKScrollHighlight (scrollp, highlight);
831 setCDKScrollBox (scrollp, Box);
832 }
833
834 /*
835 * This sets the scrolling list items.
836 */
837 void setCDKScrollItems (CDKSCROLL *scrollp, char **list, int listSize, boolean numbers)
838 {
839 int x = 0;
840
841 if (createCDKScrollItemList (scrollp, numbers, list, listSize) <= 0)
842 return;
843
844 /* Clean up the display. */
845 for (x = 0; x < scrollp->viewSize; x++)
846 {
847 writeBlanks (scrollp->win, 1, SCREEN_YPOS (scrollp, x),
848 HORIZONTAL, 0, scrollp->boxWidth - 2);
849 }
850
851 setViewSize (scrollp, listSize);
852 setCDKScrollPosition (scrollp, 0);
853 scrollp->leftChar = 0;
854 }
855 int getCDKScrollItems (CDKSCROLL *scrollp, char **list)
856 {
857 int x;
858
859 if (list != 0)
860 {
861 for (x = 0; x < scrollp->listSize; x++)
862 {
863 list[x] = chtype2Char (scrollp->item[x]);
864 }
865 }
866 return scrollp->listSize;
867 }
868
869 /*
870 * This sets the highlight of the scrolling list.
871 */
872 void setCDKScrollHighlight (CDKSCROLL *scrollp, chtype highlight)
873 {
874 scrollp->highlight = highlight;
875 }
876 chtype getCDKScrollHighlight (CDKSCROLL *scrollp, chtype highlight GCC_UNUSED)
877 {
878 return scrollp->highlight;
879 }
880
881 /*
882 * This sets the box attribute of the scrolling list.
883 */
884 void setCDKScrollBox (CDKSCROLL *scrollp, boolean Box)
885 {
886 ObjOf (scrollp)->box = Box;
887 ObjOf (scrollp)->borderSize = Box ? 1 : 0;
888 }
889 boolean getCDKScrollBox (CDKSCROLL *scrollp)
890 {
891 return ObjOf (scrollp)->box;
892 }
893
894 /*
895 * Resequence the numbers after a insertion/deletion.
896 */
897 static void resequence (CDKSCROLL *scrollp)
898 {
899 if (scrollp->numbers)
900 {
901 int j, k;
902 for (j = 0; j < scrollp->listSize; ++j)
903 {
904 char source[80];
905 chtype *target = scrollp->item[j];
906
907 sprintf (source, NUMBER_FMT, j + 1, "");
908
909 for (k = 0; source[k] != 0; ++k)
910 {
911 /* handle deletions that change the length of number */
912 if (source[k] == '.' && CharOf (target[k]) != '.')
913 {
914 int k2 = k;
915 while ((target[k2] = target[k2 + 1]) != 0)
916 ++k2;
917 scrollp->itemLen[j] -= 1;
918 }
919 target[k] &= A_ATTRIBUTES;
920 target[k] |= source[k];
921 }
922 }
923 }
924 }
925
926 static boolean insertListItem (CDKSCROLL *scrollp, int item)
927 {
928 int x;
929 for (x = scrollp->listSize; x > item; --x)
930 {
931 scrollp->item[x] = scrollp->item[x - 1];
932 scrollp->itemLen[x] = scrollp->itemLen[x - 1];
933 scrollp->itemPos[x] = scrollp->itemPos[x - 1];
934 }
935 return TRUE;
936 }
937
938 /*
939 * This adds a single item to a scrolling list, at the end of the list.
940 */
941 void addCDKScrollItem (CDKSCROLL *scrollp, char *item)
942 {
943 int itemNumber = scrollp->listSize;
944 int widestItem = WidestItem (scrollp);
945 char *temp = 0;
946 unsigned have = 0;
947
948 if (allocListArrays (scrollp, scrollp->listSize, scrollp->listSize + 1) &&
949 allocListItem (scrollp,
950 itemNumber,
951 &temp,
952 &have,
953 scrollp->numbers ? (itemNumber + 1) : 0,
954 item))
955 {
956 /* Determine the size of the widest item. */
957 widestItem = MAXIMUM (scrollp->itemLen[itemNumber], widestItem);
958
959 updateViewWidth (scrollp, widestItem);
960
961 setViewSize (scrollp, scrollp->listSize + 1);
962 }
963
964 freeChecked (temp);
965 }
966
967 /*
968 * This adds a single item to a scrolling list, before the current item.
969 */
970 void insertCDKScrollItem (CDKSCROLL *scrollp, char *item)
971 {
972 int widestItem = WidestItem (scrollp);
973 char *temp = 0;
974 unsigned have = 0;
975
976 if (allocListArrays (scrollp, scrollp->listSize, scrollp->listSize + 1) &&
977 insertListItem (scrollp, scrollp->currentItem) &&
978 allocListItem (scrollp,
979 scrollp->currentItem,
980 &temp,
981 &have,
982 scrollp->numbers ? (scrollp->currentItem + 1) : 0,
983 item))
984 {
985 /* Determine the size of the widest item. */
986 widestItem = MAXIMUM (scrollp->itemLen[scrollp->currentItem], widestItem);
987
988 updateViewWidth (scrollp, widestItem);
989
990 setViewSize (scrollp, scrollp->listSize + 1);
991
992 resequence (scrollp);
993 }
994
995 freeChecked (temp);
996 }
997
998 /*
999 * This removes a single item from a scrolling list.
1000 */
1001 void deleteCDKScrollItem (CDKSCROLL *scrollp, int position)
1002 {
1003 int x;
1004
1005 if (position >= 0 && position < scrollp->listSize)
1006 {
1007 freeChtype (scrollp->item[position]);
1008
1009 /* Adjust the list. */
1010 for (x = position; x < scrollp->listSize; x++)
1011 {
1012 scrollp->item[x] = scrollp->item[x + 1];
1013 scrollp->itemLen[x] = scrollp->itemLen[x + 1];
1014 scrollp->itemPos[x] = scrollp->itemPos[x + 1];
1015 }
1016 setViewSize (scrollp, scrollp->listSize - 1);
1017
1018 if (scrollp->listSize > 0)
1019 resequence (scrollp);
1020
1021 if (scrollp->listSize < maxViewSize (scrollp))
1022 werase (scrollp->win); /* force the next redraw to be complete */
1023
1024 /* do this to update the view size, etc. */
1025 setCDKScrollPosition (scrollp, scrollp->currentItem);
1026 }
1027 }
1028
1029 static void _focusCDKScroll (CDKOBJS *object)
1030 {
1031 CDKSCROLL *scrollp = (CDKSCROLL *)object;
1032
1033 drawCDKScrollCurrent (scrollp);
1034 wrefresh (scrollp->listWin);
1035 }
1036
1037 static void _unfocusCDKScroll (CDKOBJS *object)
1038 {
1039 CDKSCROLL *scrollp = (CDKSCROLL *)object;
1040
1041 drawCDKScrollCurrent (scrollp);
1042 wrefresh (scrollp->listWin);
1043 }
1044
1045 dummyRefreshData (Scroll)
1046
1047 dummySaveData (Scroll)
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2003/11/27 22:04:30 $
5 * $Revision: 1.1 $
6 */
7
8 /*
9 * This allows a person to select a file.
10 */
11 char *selectFile (CDKSCREEN *screen, char *title)
12 {
13 CDKFSELECT *fselect = 0;
14 char *filename = 0;
15 char *holder = 0;
16
17 /* Create the file selector. */
18 fselect = newCDKFselect (screen, CENTER, CENTER, -4, -20,
19 title, "File: ",
20 A_NORMAL, '_', A_REVERSE,
21 "</5>", "</48>", "</N>", "</N>",
22 TRUE, FALSE);
23
24 /* Let the user play. */
25 holder = activateCDKFselect (fselect, 0);
26
27 /* Check the way the user exited the selector. */
28 if (fselect->exitType != vNORMAL)
29 {
30 destroyCDKFselect (fselect);
31 refreshCDKScreen (screen);
32 return (0);
33 }
34
35 /* Otherwise... */
36 filename = copyChar (holder);
37 destroyCDKFselect (fselect);
38 refreshCDKScreen (screen);
39 return (filename);
40 }
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2005/12/30 00:29:34 $
5 * $Revision: 1.143 $
6 */
7
8 /*
9 * Declare file local prototypes.
10 */
11 static int createList(CDKSELECTION *selection, char **list, int listSize);
12 static void drawCDKSelectionList (CDKSELECTION *selection, boolean Box);
13 static void setViewSize(CDKSELECTION *scrollp, int listSize);
14 static int maxViewSize(CDKSELECTION *scrollp);
15
16 /* Determine how many characters we can shift to the right */
17 /* before all the items have been scrolled off the screen. */
18 #define AvailableWidth(w) ((w)->boxWidth - 2*BorderOf(w) - (w)->maxchoicelen)
19 #define updateViewWidth(w, widest) \
20 (w)->maxLeftChar = (((w)->boxWidth > widest) \
21 ? 0 \
22 : (widest - AvailableWidth(w)))
23 #define WidestItem(w) ((w)->maxLeftChar + AvailableWidth(w))
24
25 #define SCREENPOS(w,n) (w)->itemPos[n] - (w)->leftChar + scrollbarAdj /* + BorderOf(w) */
26
27 DeclareCDKObjects(SELECTION, Selection, setCdk, Int);
28
29 /*
30 * This function creates a selection widget.
31 */
32 CDKSELECTION *newCDKSelection (CDKSCREEN *cdkscreen, int xplace, int yplace, int splace, int height, int width, char *title, char **list, int listSize, char **choices, int choiceCount, chtype highlight, boolean Box, boolean shadow)
33 {
34 CDKSELECTION *selection = 0;
35 int widestItem = -1;
36 int parentWidth = getmaxx(cdkscreen->window);
37 int parentHeight = getmaxy(cdkscreen->window);
38 int boxWidth = width;
39 int boxHeight = height;
40 int xpos = xplace;
41 int ypos = yplace;
42 int j = 0;
43 int junk2;
44
45 static const struct { int from; int to; } bindings[] = {
46 { CDK_BACKCHAR, KEY_PPAGE },
47 { CDK_FORCHAR, KEY_NPAGE },
48 { 'g', KEY_HOME },
49 { '1', KEY_HOME },
50 { 'G', KEY_END },
51 { '<', KEY_HOME },
52 { '>', KEY_END },
53 };
54
55 if (choiceCount <= 0
56 || (selection = newCDKObject(CDKSELECTION, &my_funcs)) == 0
57 || (selection->choice = typeCallocN(chtype *, choiceCount + 1)) == 0
58 || (selection->choicelen = typeCallocN(int, choiceCount + 1)) == 0)
59 {
60 destroyCDKObject(selection);
61 return (0);
62 }
63
64 setCDKSelectionBox (selection, Box);
65
66 /*
67 * If the height is a negative value, the height will
68 * be ROWS-height, otherwise, the height will be the
69 * given height.
70 */
71 boxHeight = setWidgetDimension (parentHeight, height, 0);
72
73 /*
74 * If the width is a negative value, the width will
75 * be COLS-width, otherwise, the width will be the
76 * given width.
77 */
78 boxWidth = setWidgetDimension (parentWidth, width, 0);
79
80 boxWidth = setCdkTitle(ObjOf(selection), title, boxWidth);
81
82 /* Set the box height. */
83 if (TitleLinesOf(selection) > boxHeight)
84 {
85 boxHeight = TitleLinesOf(selection)
86 + MINIMUM(listSize, 8)
87 + 2 * BorderOf(selection);
88 }
89
90 selection->maxchoicelen = 0;
91
92 /* Adjust the box width if there is a scroll bar. */
93 if (splace == LEFT || splace == RIGHT)
94 {
95 boxWidth++;
96 selection->scrollbar = TRUE;
97 }
98 else
99 {
100 selection->scrollbar = FALSE;
101 }
102
103 /*
104 * Make sure we didn't extend beyond the dimensions of the window.
105 */
106 selection->boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth);
107 selection->boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight);
108
109 setViewSize(selection, listSize);
110
111 /* Rejustify the x and y positions if we need to. */
112 alignxy (cdkscreen->window, &xpos, &ypos, selection->boxWidth, selection->boxHeight);
113
114 /* Make the selection window */
115 selection->win = newwin (selection->boxHeight, selection->boxWidth, ypos, xpos);
116
117 /* Is the window null?? */
118 if (selection->win == 0)
119 {
120 destroyCDKObject(selection);
121 return (0);
122 }
123
124 /* Turn the keypad on for this window. */
125 keypad (selection->win, TRUE);
126
127 /* Create the scrollbar window. */
128 if (splace == RIGHT)
129 {
130 selection->scrollbarWin = subwin (selection->win,
131 maxViewSize(selection), 1,
132 SCREEN_YPOS(selection, ypos),
133 xpos + selection->boxWidth - BorderOf(selection) - 1);
134 }
135 else if (splace == LEFT)
136 {
137 selection->scrollbarWin = subwin (selection->win,
138 maxViewSize(selection), 1,
139 SCREEN_YPOS(selection, ypos),
140 SCREEN_XPOS(selection, xpos));
141 }
142 else
143 {
144 selection->scrollbarWin = 0;
145 }
146
147 /* Set the rest of the variables */
148 ScreenOf(selection) = cdkscreen;
149 selection->parent = cdkscreen->window;
150 selection->scrollbarPlacement = splace;
151 selection->maxLeftChar = 0;
152 selection->leftChar = 0;
153 selection->highlight = highlight;
154 selection->choiceCount = choiceCount;
155 initExitType(selection);
156 ObjOf(selection)->acceptsFocus = TRUE;
157 ObjOf(selection)->inputWindow = selection->win;
158 selection->shadow = shadow;
159
160 setCDKSelectionCurrent (selection, 0);
161
162 /* Each choice has to be converted from char * to chtype * */
163 for (j = 0; j < choiceCount; j++)
164 {
165 selection->choice[j] = char2Chtype (choices[j], &selection->choicelen[j], &junk2);
166 selection->maxchoicelen = MAXIMUM (selection->maxchoicelen, selection->choicelen[j]);
167 }
168
169 /* Each item in the needs to be converted to chtype * */
170 widestItem = createList(selection, list, listSize);
171 if (widestItem > 0)
172 {
173 updateViewWidth(selection, widestItem);
174 }
175 else if (listSize)
176 {
177 destroyCDKObject(selection);
178 return (0);
179 }
180
181 /* Do we need to create a shadow. */
182 if (shadow)
183 {
184 selection->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
185 }
186
187 /* Setup the key bindings. */
188 for (j = 0; j < (int) SIZEOF(bindings); ++j)
189 bindCDKObject (vSELECTION, selection, bindings[j].from, getcCDKBind, (void *)(long)bindings[j].to);
190
191 /* Register this baby. */
192 registerCDKObject (cdkscreen, vSELECTION, selection);
193
194 /* Return the selection list */
195 return (selection);
196 }
197
198 /*
199 * Put the cursor on the currently-selected item.
200 */
201 static void fixCursorPosition (CDKSELECTION *selection)
202 {
203 int scrollbarAdj = (selection->scrollbarPlacement == LEFT) ? 1 : 0;
204 int ypos = SCREEN_YPOS(selection, selection->currentItem - selection->currentTop);
205 int xpos = SCREEN_XPOS(selection, 0) + scrollbarAdj;
206
207 wmove(InputWindowOf(selection), ypos, xpos);
208 wrefresh(InputWindowOf(selection));
209 }
210
211 /*
212 * This actually manages the selection widget...
213 */
214 int activateCDKSelection (CDKSELECTION *selection, chtype *actions)
215 {
216 /* Draw the selection list */
217 drawCDKSelection (selection, ObjOf(selection)->box);
218
219 if (actions == 0)
220 {
221 chtype input;
222 boolean functionKey;
223 int ret;
224
225 for (;;)
226 {
227 fixCursorPosition (selection);
228 input = getchCDKObject (ObjOf(selection), &functionKey);
229
230 /* Inject the character into the widget. */
231 ret = injectCDKSelection (selection, input);
232 if (selection->exitType != vEARLY_EXIT)
233 {
234 return ret;
235 }
236 }
237 }
238 else
239 {
240 int length = chlen (actions);
241 int j = 0;
242 int ret;
243
244 /* Inject each character one at a time. */
245 for (j = 0; j < length; j++)
246 {
247 ret = injectCDKSelection (selection, actions[j]);
248 if (selection->exitType != vEARLY_EXIT)
249 {
250 return ret;
251 }
252 }
253 }
254
255 /* Set the exit type and return. */
256 setExitType(selection, 0);
257 return 0;
258 }
259
260 /*
261 * This injects a single character into the widget.
262 */
263 static int _injectCDKSelection (CDKOBJS *object, chtype input)
264 {
265 CDKSELECTION *selection = (CDKSELECTION *)object;
266 int ppReturn = 1;
267 int ret = unknownInt;
268 bool complete = FALSE;
269
270 /* Set the exit type. */
271 setExitType(selection, 0);
272
273 /* Draw the selection list */
274 drawCDKSelectionList (selection, ObjOf(selection)->box);
275
276 /* Check if there is a pre-process function to be called. */
277 if (PreProcessFuncOf(selection) != 0)
278 {
279 /* Call the pre-process function. */
280 ppReturn = PreProcessFuncOf(selection) (vSELECTION, selection, PreProcessDataOf(selection), input);
281 }
282
283 /* Should we continue? */
284 if (ppReturn != 0)
285 {
286 /* Check for a predefined binding. */
287 if (checkCDKObjectBind (vSELECTION, selection, input) != 0)
288 {
289 checkEarlyExit(selection);
290 complete = TRUE;
291 }
292 else
293 {
294 switch (input)
295 {
296 case KEY_UP :
297 scroller_KEY_UP(selection);
298 break;
299
300 case KEY_DOWN :
301 scroller_KEY_DOWN(selection);
302 break;
303
304 case KEY_RIGHT :
305 scroller_KEY_RIGHT(selection);
306 break;
307
308 case KEY_LEFT :
309 scroller_KEY_LEFT(selection);
310 break;
311
312 case KEY_PPAGE :
313 scroller_KEY_PPAGE(selection);
314 break;
315
316 case KEY_NPAGE :
317 scroller_KEY_NPAGE(selection);
318 break;
319
320 case KEY_HOME :
321 scroller_KEY_HOME(selection);
322 break;
323
324 case KEY_END :
325 scroller_KEY_END(selection);
326 break;
327
328 case '$' :
329 selection->leftChar = selection->maxLeftChar;
330 break;
331
332 case '|' :
333 selection->leftChar = 0;
334 break;
335
336 case SPACE :
337 if (selection->mode[selection->currentItem] == 0)
338 {
339 if (selection->selections[selection->currentItem] == selection->choiceCount - 1)
340 {
341 selection->selections[selection->currentItem] = 0;
342 }
343 else
344 {
345 selection->selections[selection->currentItem]++;
346 }
347 }
348 else
349 {
350 Beep();
351 }
352 break;
353
354 case KEY_ESC :
355 setExitType(selection, input);
356 complete = TRUE;
357 break;
358
359 case KEY_TAB : case KEY_ENTER :
360 setExitType(selection, input);
361 ret = 1;
362 complete = TRUE;
363 break;
364
365 case CDK_REFRESH :
366 eraseCDKScreen (ScreenOf(selection));
367 refreshCDKScreen (ScreenOf(selection));
368 break;
369
370 default :
371 break;
372 }
373 }
374
375 /* Should we call a post-process? */
376 if (!complete && (PostProcessFuncOf(selection) != 0))
377 {
378 PostProcessFuncOf(selection) (vSELECTION, selection, PostProcessDataOf(selection), input);
379 }
380 }
381
382 if (!complete) {
383 drawCDKSelectionList (selection, ObjOf(selection)->box);
384 setExitType(selection, 0);
385 }
386
387 ResultOf(selection).valueInt = ret;
388 fixCursorPosition (selection);
389 return (ret != unknownInt);
390 }
391
392 /*
393 * This moves the selection field to the given location.
394 */
395 static void _moveCDKSelection (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag)
396 {
397 CDKSELECTION *selection = (CDKSELECTION *)object;
398 int currentX = getbegx(selection->win);
399 int currentY = getbegy(selection->win);
400 int xpos = xplace;
401 int ypos = yplace;
402 int xdiff = 0;
403 int ydiff = 0;
404
405 /*
406 * If this is a relative move, then we will adjust where we want
407 * to move to.
408 */
409 if (relative)
410 {
411 xpos = getbegx(selection->win) + xplace;
412 ypos = getbegy(selection->win) + yplace;
413 }
414
415 /* Adjust the window if we need to. */
416 alignxy (WindowOf(selection), &xpos, &ypos, selection->boxWidth, selection->boxHeight);
417
418 /* Get the difference. */
419 xdiff = currentX - xpos;
420 ydiff = currentY - ypos;
421
422 /* Move the window to the new location. */
423 moveCursesWindow(selection->win, -xdiff, -ydiff);
424 moveCursesWindow(selection->scrollbarWin, -xdiff, -ydiff);
425 moveCursesWindow(selection->shadowWin, -xdiff, -ydiff);
426
427 /* Touch the windows so they 'move'. */
428 refreshCDKWindow (WindowOf(selection));
429
430 /* Redraw the window, if they asked for it. */
431 if (refresh_flag)
432 {
433 drawCDKSelection (selection, ObjOf(selection)->box);
434 }
435 }
436
437 /*
438 * This function draws the selection list.
439 */
440 static void _drawCDKSelection (CDKOBJS *object, boolean Box)
441 {
442 CDKSELECTION *selection = (CDKSELECTION *)object;
443
444 /* Draw in the shadow if we need to. */
445 if (selection->shadowWin != 0)
446 {
447 drawShadow (selection->shadowWin);
448 }
449
450 drawCdkTitle (selection->win, object);
451
452 /* Redraw the list */
453 drawCDKSelectionList (selection, Box);
454 }
455
456 static int maxViewSize(CDKSELECTION *widget)
457 {
458 return scroller_MaxViewSize(widget);
459 }
460
461 /*
462 * Set variables that depend upon the list-size.
463 */
464 static void setViewSize(CDKSELECTION *widget, int listSize)
465 {
466 scroller_SetViewSize(widget, listSize);
467 }
468
469 /*
470 * This function draws the selection list window.
471 */
472 static void drawCDKSelectionList (CDKSELECTION *selection, boolean Box GCC_UNUSED)
473 {
474 int scrollbarAdj = (selection->scrollbarPlacement == LEFT) ? 1 : 0;
475 int screenPos = 0;
476 int xpos, ypos;
477 int j;
478 int selItem = -1;
479
480 /* If there is to be a highlight, assign it now */
481 if (ObjOf(selection)->hasFocus)
482 selItem = selection->currentItem;
483
484 /* draw the list... */
485 for (j = 0; j < selection->viewSize; j++)
486 {
487 screenPos = SCREENPOS(selection, j + selection->currentTop);
488 ypos = SCREEN_YPOS(selection, j);
489 xpos = SCREEN_XPOS(selection, 0);
490
491 /* Draw the empty line. */
492 writeBlanks (selection->win,
493 xpos,
494 ypos,
495 HORIZONTAL, 0,
496 getmaxx(selection->win));
497
498 /* Draw the selection item. */
499 writeChtypeAttrib (selection->win,
500 (screenPos >= 0) ? screenPos : 1,
501 ypos,
502 selection->item[j + selection->currentTop],
503 ((j + selection->currentTop == selItem)
504 ? selection->highlight
505 : A_NORMAL),
506 HORIZONTAL,
507 (screenPos >= 0) ? 0 : (1 - screenPos),
508 selection->itemLen[j + selection->currentTop]);
509
510 /* Draw the choice value. */
511 writeChtype (selection->win,
512 xpos + scrollbarAdj,
513 ypos,
514 selection->choice[selection->selections[j + selection->currentTop]],
515 HORIZONTAL,
516 0,
517 selection->choicelen[selection->selections[j + selection->currentTop]]);
518 }
519
520 /* Determine where the toggle is supposed to be. */
521 if (selection->scrollbar)
522 {
523 selection->togglePos = floorCDK(selection->currentItem * selection->step);
524 selection->togglePos = MINIMUM(selection->togglePos, getmaxy(selection->scrollbarWin) - 1);
525
526 mvwvline (selection->scrollbarWin, 0, 0, ACS_CKBOARD, getmaxy(selection->scrollbarWin));
527 mvwvline (selection->scrollbarWin, selection->togglePos, 0, ' ' | A_REVERSE, selection->toggleSize);
528 }
529
530 /* Box it if needed */
531 if (ObjOf(selection)->box)
532 {
533 drawObjBox (selection->win, ObjOf(selection));
534 }
535
536 fixCursorPosition (selection);
537 }
538
539 /*
540 * This sets the background attribute of the widget.
541 */
542 static void _setBKattrSelection (CDKOBJS *object, chtype attrib)
543 {
544 if (object != 0)
545 {
546 CDKSELECTION *widget = (CDKSELECTION *) object;
547
548 wbkgd (widget->win, attrib);
549 if (widget->scrollbarWin != 0)
550 {
551 wbkgd (widget->scrollbarWin, attrib);
552 }
553 }
554 }
555
556 static void destroyInfo (CDKSELECTION *widget)
557 {
558 CDKfreeChtypes (widget->item);
559 widget->item = 0;
560
561 freeAndNull (widget->itemPos);
562 freeAndNull (widget->itemLen);
563 freeAndNull (widget->selections);
564 freeAndNull (widget->mode);
565 }
566
567 /*
568 * This function destroys the selection list.
569 */
570 static void _destroyCDKSelection (CDKOBJS *object)
571 {
572 if (object != 0)
573 {
574 CDKSELECTION *selection = (CDKSELECTION *)object;
575
576 cleanCdkTitle (object);
577 CDKfreeChtypes (selection->choice);
578 freeChecked (selection->choicelen);
579 destroyInfo (selection);
580
581 /* Clean up the windows. */
582 deleteCursesWindow (selection->scrollbarWin);
583 deleteCursesWindow (selection->shadowWin);
584 deleteCursesWindow (selection->win);
585
586 /* Clean the key bindings. */
587 cleanCDKObjectBindings (vSELECTION, selection);
588
589 /* Unregister this object. */
590 unregisterCDKObject (vSELECTION, selection);
591 }
592 }
593
594 /*
595 * This function erases the selection list from the screen.
596 */
597 static void _eraseCDKSelection (CDKOBJS *object)
598 {
599 if (validCDKObject (object))
600 {
601 CDKSELECTION *selection = (CDKSELECTION *)object;
602
603 eraseCursesWindow (selection->win);
604 eraseCursesWindow (selection->shadowWin);
605 }
606 }
607
608 /*
609 * This function sets a couple of the selection list attributes.
610 */
611 void setCDKSelection (CDKSELECTION *selection, chtype highlight, int * choices, boolean Box)
612 {
613 setCDKSelectionChoices (selection, choices);
614 setCDKSelectionHighlight(selection, highlight);
615 setCDKSelectionBox (selection, Box);
616 }
617
618 /*
619 * This sets the selection list items.
620 */
621 void setCDKSelectionItems (CDKSELECTION *selection, char **list, int listSize)
622 {
623 int widestItem = -1;
624 int j = 0;
625
626 widestItem = createList(selection, list, listSize);
627 if (widestItem <= 0)
628 return;
629
630 /* Clean up the display. */
631 for (j = 0; j < selection->viewSize ; j++)
632 {
633 writeBlanks (selection->win,
634 SCREEN_XPOS(selection, 0),
635 SCREEN_YPOS(selection, j),
636 HORIZONTAL, 0, getmaxx(selection->win));
637 }
638
639 setViewSize(selection, listSize);
640 setCDKSelectionCurrent (selection, 0);
641
642 updateViewWidth(selection, widestItem);
643 }
644 int getCDKSelectionItems (CDKSELECTION *selection, char **list)
645 {
646 int j;
647
648 if (list != 0)
649 {
650 for (j = 0; j < selection->listSize; j++)
651 {
652 list[j] = chtype2Char (selection->item[j]);
653 }
654 }
655 return selection->listSize;
656 }
657
658 /*
659 *
660 */
661 void setCDKSelectionTitle (CDKSELECTION *selection, char *title)
662 {
663 /* Make sure the title isn't null. */
664 if (title == 0)
665 {
666 return;
667 }
668
669 (void) setCdkTitle(ObjOf(selection), title, - (selection->boxWidth + 1));
670
671 setViewSize(selection, selection->listSize);
672 }
673 char *getCDKSelectionTitle (CDKSELECTION *selection GCC_UNUSED)
674 {
675 return chtype2Char(*TitleOf(selection));
676 }
677
678 /*
679 * This sets the highlight bar.
680 */
681 void setCDKSelectionHighlight (CDKSELECTION *selection, chtype highlight)
682 {
683 selection->highlight = highlight;
684 }
685 chtype getCDKSelectionHighlight (CDKSELECTION *selection)
686 {
687 return selection->highlight;
688 }
689
690 /*
691 * This sets the default choices for the selection list.
692 */
693 void setCDKSelectionChoices (CDKSELECTION *selection, int * choices)
694 {
695 int j;
696
697 /* Set the choice values in the selection list. */
698 for (j = 0; j < selection->listSize; j++)
699 {
700 if (choices[j] < 0)
701 {
702 selection->selections[j] = 0;
703 }
704 else if (choices[j] > selection->choiceCount)
705 {
706 selection->selections[j] = selection->choiceCount - 1;
707 }
708 else
709 {
710 selection->selections[j] = choices[j];
711 }
712 }
713 }
714 int *getCDKSelectionChoices (CDKSELECTION *selection)
715 {
716 return selection->selections;
717 }
718
719 /*
720 * This sets a single item's choice value.
721 */
722 void setCDKSelectionChoice (CDKSELECTION *selection, int Index, int choice)
723 {
724 int correctChoice = choice;
725 int correctIndex = Index;
726
727 /* Verify that the choice value is in range. */
728 if (choice < 0)
729 {
730 correctChoice = 0;
731 }
732 else if (choice > selection->choiceCount)
733 {
734 correctChoice = selection->choiceCount - 1;
735 }
736
737 /* Make sure the index isn't out of range. */
738 if (Index < 0)
739 {
740 Index = 0;
741 }
742 else if (Index > selection->listSize)
743 {
744 Index = selection->listSize - 1;
745 }
746
747 /* Set the choice value. */
748 selection->selections[correctIndex] = correctChoice;
749 }
750 int getCDKSelectionChoice (CDKSELECTION *selection, int Index)
751 {
752 /* Make sure the index isn't out of range. */
753 if (Index < 0)
754 {
755 return selection->selections[0];
756 }
757 else if (Index > selection->listSize)
758 {
759 return selection->selections[selection->listSize - 1];
760 }
761 else
762 {
763 return selection->selections[Index];
764 }
765 }
766
767 /*
768 * This sets the modes of the items in the selection list. Currently
769 * there are only two: editable=0 and read-only=1
770 */
771 void setCDKSelectionModes (CDKSELECTION *selection, int * modes)
772 {
773 int j;
774
775 /* Make sure the widget pointer is not null. */
776 if (selection == 0)
777 {
778 return;
779 }
780
781 /* Set the modes. */
782 for (j = 0; j < selection->listSize; j++)
783 {
784 selection->mode[j] = modes[j];
785 }
786 }
787 int *getCDKSelectionModes (CDKSELECTION *selection)
788 {
789 return selection->mode;
790 }
791
792 /*
793 * This sets a single mode of an item in the selection list.
794 */
795 void setCDKSelectionMode (CDKSELECTION *selection, int Index, int mode)
796 {
797 /* Make sure the widget pointer is not null. */
798 if (selection == 0)
799 {
800 return;
801 }
802
803 /* Make sure the index isn't out of range. */
804 if (Index < 0)
805 {
806 selection->mode[0] = mode;
807 }
808 else if (Index > selection->listSize)
809 {
810 selection->mode[selection->listSize - 1] = mode;
811 }
812 else
813 {
814 selection->mode[Index] = mode;
815 }
816 }
817 int getCDKSelectionMode (CDKSELECTION *selection, int Index)
818 {
819 /* Make sure the index isn't out of range. */
820 if (Index < 0)
821 {
822 return selection->mode[0];
823 }
824 else if (Index > selection->listSize)
825 {
826 return selection->mode[selection->listSize - 1];
827 }
828 else
829 {
830 return selection->mode[Index];
831 }
832 }
833
834 /*
835 * This sets the box attribute of the widget.
836 */
837 void setCDKSelectionBox (CDKSELECTION *selection, boolean Box)
838 {
839 ObjOf(selection)->box = Box;
840 ObjOf(selection)->borderSize = Box ? 1 : 0;
841 }
842 boolean getCDKSelectionBox (CDKSELECTION *selection)
843 {
844 return ObjOf(selection)->box;
845 }
846
847 /*
848 * set/get the current item index
849 */
850 void setCDKSelectionCurrent (CDKSELECTION *selection, int item)
851 {
852 scroller_SetPosition(selection, item);
853 }
854
855 int getCDKSelectionCurrent (CDKSELECTION *selection)
856 {
857 return selection->currentItem;
858 }
859
860 /*
861 * methods for generic type methods
862 */
863 static void _focusCDKSelection(CDKOBJS *object)
864 {
865 CDKSELECTION *selection = (CDKSELECTION *)object;
866
867 drawCDKSelectionList (selection, ObjOf(selection)->box);
868 }
869
870 static void _unfocusCDKSelection(CDKOBJS *object)
871 {
872 CDKSELECTION *selection = (CDKSELECTION *)object;
873
874 drawCDKSelectionList (selection, ObjOf(selection)->box);
875 }
876
877 static int createList(CDKSELECTION *selection, char **list, int listSize)
878 {
879 int status = 0;
880 int widestItem = 0;
881 int j;
882
883 if (listSize > 0)
884 {
885 chtype ** newList = typeCallocN(chtype *, listSize + 1);
886 int * newLen = typeCallocN(int, listSize + 1);
887 int * newPos = typeCallocN(int, listSize + 1);
888 int * newSel = typeCallocN(int, listSize + 1);
889 int * newMode = typeCallocN(int, listSize + 1);
890
891 if (newList != 0
892 && newLen != 0
893 && newPos != 0
894 && newSel != 0
895 && newMode != 0)
896 {
897 int boxWidth = AvailableWidth(selection);
898 int adjust = selection->maxchoicelen + BorderOf(selection);
899
900 status = 1;
901 for (j = 0; j < listSize; j++)
902 {
903 newList[j] = char2Chtype (list[j], &newLen[j], &newPos[j]);
904 if (newList[j] == 0)
905 {
906 status = 0;
907 break;
908 }
909 newPos[j] = justifyString (boxWidth, newLen[j], newPos[j]) + adjust;
910 widestItem = MAXIMUM (widestItem, newLen[j]);
911 }
912
913 if (status)
914 {
915 destroyInfo (selection);
916
917 selection->item = newList;
918 selection->itemPos = newPos;
919 selection->itemLen = newLen;
920 selection->selections = newSel;
921 selection->mode = newMode;
922 }
923 else
924 {
925 CDKfreeChtypes (newList);
926 freeChecked (newPos);
927 freeChecked (newLen);
928 freeChecked (newSel);
929 freeChecked (newMode);
930 }
931 }
932 }
933 else
934 {
935 destroyInfo (selection);
936 }
937
938 return status ? widestItem : 0;
939 }
940
941 dummyRefreshData(Selection)
942
943 dummySaveData(Selection)
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:33:16 $
5 * $Revision: 1.114 $
6 */
7
8 /*
9 * Declare file local prototypes.
10 */
11 static int createList(CDKSWINDOW *swindow, int listSize);
12 static void drawCDKSwindowList (CDKSWINDOW *swindow, boolean Box);
13
14 DeclareCDKObjects(SWINDOW, Swindow, setCdk, Int);
15
16 /*
17 * This function creates a scrolling window widget.
18 */
19 CDKSWINDOW *newCDKSwindow (CDKSCREEN *cdkscreen, int xplace, int yplace, int height, int width, char *title, int saveLines, boolean Box, boolean shadow)
20 {
21 CDKSWINDOW *swindow = 0;
22 int parentWidth = getmaxx(cdkscreen->window);
23 int parentHeight = getmaxy(cdkscreen->window);
24 int boxWidth = width;
25 int boxHeight = height;
26 int xpos = xplace;
27 int ypos = yplace;
28 int x;
29
30 static const struct { int from; int to; } bindings[] = {
31 { CDK_BACKCHAR, KEY_PPAGE },
32 { 'b', KEY_PPAGE },
33 { 'B', KEY_PPAGE },
34 { CDK_FORCHAR, KEY_NPAGE },
35 { SPACE, KEY_NPAGE },
36 { 'f', KEY_NPAGE },
37 { 'F', KEY_NPAGE },
38 { '|', KEY_HOME },
39 { '$', KEY_END },
40 };
41
42 if ((swindow = newCDKObject(CDKSWINDOW, &my_funcs)) == 0)
43 return (0);
44
45 setCDKSwindowBox (swindow, Box);
46
47 /*
48 * If the height is a negative value, the height will
49 * be ROWS-height, otherwise, the height will be the
50 * given height.
51 */
52 boxHeight = setWidgetDimension (parentHeight, height, 0);
53
54 /*
55 * If the width is a negative value, the width will
56 * be COLS-width, otherwise, the width will be the
57 * given width.
58 */
59 boxWidth = setWidgetDimension (parentWidth, width, 0);
60
61 boxWidth = setCdkTitle(ObjOf(swindow), title, boxWidth);
62
63 /* Set the box height. */
64 boxHeight += TitleLinesOf(swindow) + 1;
65
66 /*
67 * Make sure we didn't extend beyond the dimensions of the window.
68 */
69 boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth);
70 boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight);
71
72 /* Set the rest of the variables. */
73 swindow->titleAdj = TitleLinesOf(swindow) + 1;
74
75 /* Rejustify the x and y positions if we need to. */
76 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
77
78 /* Make the scrolling window */
79 swindow->win = newwin (boxHeight, boxWidth, ypos, xpos);
80 if (swindow->win == 0)
81 {
82 destroyCDKObject(swindow);
83 return (0);
84 }
85 keypad (swindow->win, TRUE);
86
87 /* Make the field window. */
88 swindow->fieldWin = subwin (swindow->win,
89 (boxHeight-TitleLinesOf(swindow)-2),
90 boxWidth - 2,
91 ypos + TitleLinesOf(swindow) + 1,
92 xpos + 1);
93 keypad (swindow->fieldWin, TRUE);
94
95 /* Set the rest of the variables */
96 ScreenOf(swindow) = cdkscreen;
97 swindow->parent = cdkscreen->window;
98 swindow->shadowWin = 0;
99 swindow->boxHeight = boxHeight;
100 swindow->boxWidth = boxWidth;
101 swindow->viewSize = boxHeight-TitleLinesOf(swindow)-2;
102 swindow->currentTop = 0;
103 swindow->maxTopLine = 0;
104 swindow->leftChar = 0;
105 swindow->maxLeftChar = 0;
106 swindow->listSize = 0;
107 swindow->widestLine = -1;
108 swindow->saveLines = saveLines;
109 initExitType(swindow);
110 ObjOf(swindow)->acceptsFocus = TRUE;
111 ObjOf(swindow)->inputWindow = swindow->win;
112 swindow->shadow = shadow;
113
114 if (!createList(swindow, saveLines))
115 {
116 destroyCDKObject(swindow);
117 return (0);
118 }
119
120 /* Do we need to create a shadow??? */
121 if (shadow)
122 {
123 swindow->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
124 }
125
126 /* Clean the key bindings. */
127 for (x = 0; x < (int) SIZEOF(bindings); ++x)
128 bindCDKObject (vSWINDOW, swindow, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to);
129
130 /* Register this baby. */
131 registerCDKObject (cdkscreen, vSWINDOW, swindow);
132
133 /* Return the scrolling window */
134 return (swindow);
135 }
136
137 /*
138 * This sets the lines and the box attribute of the scrolling window.
139 */
140 void setCDKSwindow (CDKSWINDOW *swindow, char **list, int lines, boolean Box)
141 {
142 setCDKSwindowContents (swindow, list, lines);
143 setCDKSwindowBox (swindow, Box);
144 }
145
146 static void setupLine (CDKSWINDOW *swindow, char *list, int x)
147 {
148 swindow->list[x] = char2Chtype (list, &swindow->listLen[x], &swindow->listPos[x]);
149 swindow->listPos[x] = justifyString (swindow->boxWidth, swindow->listLen[x], swindow->listPos[x]);
150 swindow->widestLine = MAXIMUM (swindow->widestLine, swindow->listLen[x]);
151 }
152
153 /*
154 * This sets all the lines inside the scrolling window.
155 */
156 void setCDKSwindowContents (CDKSWINDOW *swindow, char **list, int listSize)
157 {
158 int x = 0;
159
160 /* First lets clean all the lines in the window. */
161 cleanCDKSwindow(swindow);
162 createList(swindow, listSize);
163
164 /* Now lets set all the lines inside the window. */
165 for (x=0; x < listSize; x++)
166 {
167 setupLine(swindow, list[x], x);
168 }
169
170 /* Set some of the more important members of the scrolling window. */
171 swindow->listSize = listSize;
172 swindow->maxTopLine = swindow->listSize - swindow->viewSize;
173 swindow->maxTopLine = (swindow->maxTopLine < 0 ? 0 : swindow->maxTopLine);
174 swindow->maxLeftChar = swindow->widestLine - (swindow->boxWidth - 2);
175 swindow->currentTop = 0;
176 swindow->leftChar = 0;
177 }
178 chtype **getCDKSwindowContents (CDKSWINDOW *swindow, int *size)
179 {
180 (*size) = swindow->listSize;
181 return swindow->list;
182 }
183
184 /*
185 * This sets the box attribute for the widget.
186 */
187 void setCDKSwindowBox (CDKSWINDOW *swindow, boolean Box)
188 {
189 ObjOf(swindow)->box = Box;
190 ObjOf(swindow)->borderSize = Box ? 1 : 0;
191 }
192 boolean getCDKSwindowBox (CDKSWINDOW *swindow)
193 {
194 return ObjOf(swindow)->box;
195 }
196
197 static void freeLine (CDKSWINDOW *swindow, int x)
198 {
199 if (x < swindow->listSize)
200 {
201 freeChtype (swindow->list[x]);
202 swindow->list[x] = 0;
203 }
204 }
205
206 /*
207 * This adds a line to the scrolling window.
208 */
209 void addCDKSwindow (CDKSWINDOW *swindow, char *list, int insertPos)
210 {
211 int x = 0;
212
213 /*
214 * If we are at the maximum number of save lines. Erase
215 * the first position and bump everything up one spot.
216 */
217 if (swindow->listSize == swindow->saveLines)
218 {
219 /* Free up the memory. */
220 freeLine (swindow, 0);
221
222 /* Bump everything up one spot. */
223 for (x=0; x < swindow->listSize; x++)
224 {
225 swindow->list[x] = swindow->list[x + 1];
226 swindow->listPos[x] = swindow->listPos[x + 1];
227 swindow->listLen[x] = swindow->listLen[x + 1];
228 }
229
230 /* Clean out the last position. */
231 swindow->list[swindow->listSize] = 0;
232 swindow->listLen[swindow->listSize] = 0;
233 swindow->listPos[swindow->listSize] = 0;
234 swindow->listSize--;
235 }
236
237 /* Determine where the line is being added. */
238 if (insertPos == TOP)
239 {
240 /* We need to 'bump' everything down one line... */
241 for (x = swindow->listSize; x > 0; x--)
242 {
243 /* Copy in the new row. */
244 swindow->list[x] = swindow->list[x - 1];
245 swindow->listPos[x] = swindow->listPos[x - 1];
246 swindow->listLen[x] = swindow->listLen[x - 1];
247 }
248
249 /* Add it into the scrolling window. */
250 setupLine(swindow, list, 0);
251
252 /* Set some variables. */
253 swindow->currentTop = 0;
254 if (swindow->listSize < swindow->saveLines)
255 {
256 swindow->listSize++;
257 }
258
259 /* Set the maximum top line. */
260 swindow->maxTopLine = swindow->listSize - swindow->viewSize;
261 swindow->maxTopLine = (swindow->maxTopLine < 0 ? 0 : swindow->maxTopLine);
262
263 swindow->maxLeftChar = swindow->widestLine - (swindow->boxWidth - 2);
264 }
265 else
266 {
267 /* Add to the bottom. */
268 setupLine(swindow, list, swindow->listSize);
269
270 swindow->maxLeftChar = swindow->widestLine - (swindow->boxWidth - 2);
271
272 /* Increment the item count and zero out the next row. */
273 if (swindow->listSize < swindow->saveLines)
274 {
275 swindow->listSize++;
276 freeLine (swindow, swindow->listSize);
277 }
278
279 /* Set the maximum top line. */
280 if (swindow->listSize <= swindow->viewSize)
281 {
282 swindow->maxTopLine = 0;
283 swindow->currentTop = 0;
284 }
285 else
286 {
287 swindow->maxTopLine = (swindow->listSize - swindow->viewSize);
288 swindow->currentTop = swindow->maxTopLine;
289 }
290 }
291
292 /* Draw in the list. */
293 drawCDKSwindowList (swindow, ObjOf(swindow)->box);
294 }
295
296 /*
297 * This jumps to a given line.
298 */
299 void jumpToLineCDKSwindow (CDKSWINDOW *swindow, int line)
300 {
301 /*
302 * Make sure the line is in bounds.
303 */
304 if (line == BOTTOM || line >= swindow->listSize)
305 {
306 /* We are moving to the last page. */
307 swindow->currentTop = swindow->listSize - swindow->viewSize;
308 }
309 else if (line == TOP || line <= 0)
310 {
311 /* We are moving to the top of the page. */
312 swindow->currentTop = 0;
313 }
314 else
315 {
316 /* We are moving in the middle somewhere. */
317 if ((swindow->viewSize + line) < swindow->listSize)
318 {
319 swindow->currentTop = line;
320 }
321 else
322 {
323 swindow->currentTop = swindow->listSize - swindow->viewSize;
324 }
325 }
326
327 /* A little sanity check to make we don't something silly. */
328 if (swindow->currentTop < 0)
329 {
330 swindow->currentTop = 0;
331 }
332
333 /* Redraw the window. */
334 drawCDKSwindow (swindow, ObjOf(swindow)->box);
335 }
336
337 /*
338 * This removes all the lines inside the scrolling window.
339 */
340 void cleanCDKSwindow (CDKSWINDOW *swindow)
341 {
342 int x;
343
344 /* Clean up the memory used ... */
345 for (x=0; x < swindow->listSize; x++)
346 {
347 freeLine (swindow, x);
348 }
349
350 /* Reset some variables. */
351 swindow->listSize = 0;
352 swindow->maxLeftChar = 0;
353 swindow->widestLine = 0;
354 swindow->currentTop = 0;
355 swindow->maxTopLine = 0;
356
357 /* Redraw the window. */
358 drawCDKSwindow (swindow, ObjOf(swindow)->box);
359 }
360
361 /*
362 * This trims lines from the scrolling window.
363 */
364 void trimCDKSwindow (CDKSWINDOW *swindow, int begin, int end)
365 {
366 int start, finish, x;
367
368 /* Check the value of begin. */
369 if (begin < 0)
370 {
371 start = 0;
372 }
373 else if (begin >= swindow->listSize)
374 {
375 start = swindow->listSize-1;
376 }
377 else
378 {
379 start = begin;
380 }
381
382 /* Check the value of end. */
383 if (end < 0)
384 {
385 finish = 0;
386 }
387 else if (end >= swindow->listSize)
388 {
389 finish = swindow->listSize-1;
390 }
391 else
392 {
393 finish = end;
394 }
395
396 /* Make sure the start is lower than the end. */
397 if (start > finish)
398 {
399 return;
400 }
401
402 /* Start nuking elements from the window. */
403 for (x=start; x <=finish; x++)
404 {
405 freeLine (swindow, x);
406
407 if (x < swindow->listSize-1)
408 {
409 swindow->list[x] = copyChtype (swindow->list[x + 1]);
410 swindow->listPos[x] = swindow->listPos[x + 1];
411 swindow->listLen[x] = swindow->listLen[x + 1];
412 }
413 }
414
415 /* Adjust the item count correctly. */
416 swindow->listSize = swindow->listSize - (end - begin) - 1;
417
418 /* Redraw the window. */
419 drawCDKSwindow (swindow, ObjOf(swindow)->box);
420 }
421
422 /*
423 * This allows the user to play inside the scrolling window.
424 */
425 void activateCDKSwindow (CDKSWINDOW *swindow, chtype *actions)
426 {
427 /* Draw the scrolling list */
428 drawCDKSwindow (swindow, ObjOf(swindow)->box);
429
430 if (actions == 0)
431 {
432 chtype input;
433 boolean functionKey;
434 int ret;
435
436 for (;;)
437 {
438 input = getchCDKObject (ObjOf(swindow), &functionKey);
439
440 /* Inject the character into the widget. */
441 ret = injectCDKSwindow (swindow, input);
442 if (swindow->exitType != vEARLY_EXIT)
443 {
444 return;
445 }
446 }
447 }
448 else
449 {
450 int length = chlen (actions);
451 int x = 0;
452 int ret;
453
454 /* Inject each character one at a time. */
455 for (x=0; x < length; x++)
456 {
457 ret = injectCDKSwindow (swindow, actions[x]);
458 if (swindow->exitType != vEARLY_EXIT)
459 {
460 return;
461 }
462 }
463 }
464
465 /* Set the exit type and return. */
466 setExitType(swindow, 0);
467 return;
468 }
469
470 /*
471 * This injects a single character into the widget.
472 */
473 static int _injectCDKSwindow (CDKOBJS *object, chtype input)
474 {
475 CDKSWINDOW *swindow = (CDKSWINDOW *)object;
476 int ppReturn = 1;
477 int ret = unknownInt;
478 bool complete = FALSE;
479
480 /* Set the exit type. */
481 setExitType(swindow, 0);
482
483 /* Draw the window.... */
484 drawCDKSwindow (swindow, ObjOf(swindow)->box);
485
486 /* Check if there is a pre-process function to be called. */
487 if (PreProcessFuncOf(swindow) != 0)
488 {
489 /* Call the pre-process function. */
490 ppReturn = PreProcessFuncOf(swindow) (vSWINDOW, swindow, PreProcessDataOf(swindow), input);
491 }
492
493 /* Should we continue? */
494 if (ppReturn != 0)
495 {
496 /* Check for a key binding. */
497 if (checkCDKObjectBind (vSWINDOW, swindow, input) != 0)
498 {
499 checkEarlyExit(swindow);
500 complete = TRUE;
501 }
502 else
503 {
504 switch (input)
505 {
506 case KEY_UP :
507 if (swindow->currentTop > 0)
508 {
509 swindow->currentTop--;
510 }
511 else
512 {
513 Beep();
514 }
515 break;
516
517 case KEY_DOWN :
518 if (swindow->currentTop >= 0 && swindow->currentTop < swindow->maxTopLine)
519 {
520 swindow->currentTop++;
521 }
522 else
523 {
524 Beep();
525 }
526 break;
527
528 case KEY_RIGHT :
529 if (swindow->leftChar < swindow->maxLeftChar)
530 {
531 swindow->leftChar ++;
532 }
533 else
534 {
535 Beep();
536 }
537 break;
538
539 case KEY_LEFT :
540 if (swindow->leftChar > 0)
541 {
542 swindow->leftChar--;
543 }
544 else
545 {
546 Beep();
547 }
548 break;
549
550 case KEY_PPAGE :
551 if (swindow->currentTop != 0)
552 {
553 if (swindow->currentTop >= swindow->viewSize)
554 {
555 swindow->currentTop = swindow->currentTop - (swindow->viewSize - 1);
556 }
557 else
558 {
559 swindow->currentTop = 0;
560 }
561 }
562 else
563 {
564 Beep();
565 }
566 break;
567
568 case KEY_NPAGE :
569 if (swindow->currentTop != swindow->maxTopLine)
570 {
571 if ((swindow->currentTop + swindow->viewSize) < swindow->maxTopLine)
572 {
573 swindow->currentTop = swindow->currentTop + (swindow->viewSize - 1);
574 }
575 else
576 {
577 swindow->currentTop = swindow->maxTopLine;
578 }
579 }
580 else
581 {
582 Beep();
583 }
584 break;
585
586 case KEY_HOME :
587 swindow->leftChar = 0;
588 break;
589
590 case KEY_END :
591 swindow->leftChar = swindow->maxLeftChar + 1;
592 break;
593
594 case 'g' : case '1' : case '<' :
595 swindow->currentTop = 0;
596 break;
597
598 case 'G' : case '>' :
599 swindow->currentTop = swindow->maxTopLine;
600 break;
601
602 case 'l' : case 'L' :
603 loadCDKSwindowInformation (swindow);
604 break;
605
606 case 's' : case 'S' :
607 saveCDKSwindowInformation (swindow);
608 break;
609
610 case KEY_TAB : case KEY_ENTER :
611 setExitType(swindow, input);
612 ret = 1;
613 complete = TRUE;
614 break;
615
616 case KEY_ESC :
617 setExitType(swindow, input);
618 complete = TRUE;
619 break;
620
621 case CDK_REFRESH :
622 eraseCDKScreen (ScreenOf(swindow));
623 refreshCDKScreen (ScreenOf(swindow));
624 break;
625
626 default :
627 break;
628 }
629 }
630
631 /* Should we call a post-process? */
632 if (!complete && (PostProcessFuncOf(swindow) != 0))
633 {
634 PostProcessFuncOf(swindow) (vSWINDOW, swindow, PostProcessDataOf(swindow), input);
635 }
636 }
637
638 if (!complete) {
639 drawCDKSwindowList (swindow, ObjOf(swindow)->box);
640 setExitType(swindow, 0);
641 }
642
643 ResultOf(swindow).valueInt = ret;
644 return (ret != unknownInt);
645 }
646
647 /*
648 * This moves the swindow field to the given location.
649 */
650 static void _moveCDKSwindow (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag)
651 {
652 CDKSWINDOW *swindow = (CDKSWINDOW *)object;
653 int currentX = getbegx(swindow->win);
654 int currentY = getbegy(swindow->win);
655 int xpos = xplace;
656 int ypos = yplace;
657 int xdiff = 0;
658 int ydiff = 0;
659
660 /*
661 * If this is a relative move, then we will adjust where we want
662 * to move to.
663 */
664 if (relative)
665 {
666 xpos = getbegx(swindow->win) + xplace;
667 ypos = getbegy(swindow->win) + yplace;
668 }
669
670 /* Adjust the window if we need to. */
671 alignxy (WindowOf(swindow), &xpos, &ypos, swindow->boxWidth, swindow->boxHeight);
672
673 /* Get the difference. */
674 xdiff = currentX - xpos;
675 ydiff = currentY - ypos;
676
677 /* Move the window to the new location. */
678 moveCursesWindow(swindow->win, -xdiff, -ydiff);
679 moveCursesWindow(swindow->shadowWin, -xdiff, -ydiff);
680
681 /* Touch the windows so they 'move'. */
682 refreshCDKWindow (WindowOf(swindow));
683
684 /* Redraw the window, if they asked for it. */
685 if (refresh_flag)
686 {
687 drawCDKSwindow (swindow, ObjOf(swindow)->box);
688 }
689 }
690
691 /*
692 * This function draws the swindow window widget.
693 */
694 static void _drawCDKSwindow (CDKOBJS *object, boolean Box)
695 {
696 CDKSWINDOW *swindow = (CDKSWINDOW *)object;
697
698 /* Do we need to draw in the shadow. */
699 if (swindow->shadowWin != 0)
700 {
701 drawShadow (swindow->shadowWin);
702 }
703
704 /* Box the widget if needed */
705 if (Box)
706 {
707 drawObjBox (swindow->win, ObjOf(swindow));
708 }
709
710 drawCdkTitle (swindow->win, object);
711
712 wrefresh (swindow->win);
713
714 /* Draw in the list. */
715 drawCDKSwindowList (swindow, Box);
716 }
717
718 /*
719 * This draws in the contents of the scrolling window.
720 */
721 static void drawCDKSwindowList (CDKSWINDOW *swindow, boolean Box GCC_UNUSED)
722 {
723 int lastLine, screenPos, x;
724
725 /* Determine the last line to draw. */
726 if (swindow->listSize < swindow->viewSize)
727 {
728 lastLine = swindow->listSize;
729 }
730 else
731 {
732 lastLine = swindow->viewSize;
733 }
734
735 /* Erase the scrolling window. */
736 werase (swindow->fieldWin);
737
738 /* Start drawing in each line. */
739 for (x=0; x < lastLine; x++)
740 {
741 screenPos = swindow->listPos[x + swindow->currentTop]-swindow->leftChar;
742
743 /* Write in the correct line. */
744 if (screenPos >= 0)
745 {
746 writeChtype (swindow->fieldWin, screenPos, x,
747 swindow->list[x + swindow->currentTop],
748 HORIZONTAL, 0,
749 swindow->listLen[x + swindow->currentTop]);
750 }
751 else
752 {
753 writeChtype (swindow->fieldWin, 0, x,
754 swindow->list[x + swindow->currentTop],
755 HORIZONTAL,
756 swindow->leftChar - swindow->listPos[x + swindow->currentTop],
757 swindow->listLen[x + swindow->currentTop]);
758 }
759 }
760
761 wrefresh (swindow->fieldWin);
762 }
763
764 /*
765 * This sets the background attribute of the widget.
766 */
767 static void _setBKattrSwindow (CDKOBJS *object, chtype attrib)
768 {
769 if (object != 0)
770 {
771 CDKSWINDOW *widget = (CDKSWINDOW *) object;
772
773 wbkgd (widget->win, attrib);
774 wbkgd (widget->fieldWin, attrib);
775 }
776 }
777
778 /*
779 * Free any storage associated with the info-list.
780 */
781 static void destroyInfo(CDKSWINDOW *swindow)
782 {
783 CDKfreeChtypes (swindow->list);
784 freeChecked (swindow->listPos);
785 freeChecked (swindow->listLen);
786
787 swindow->list = 0;
788 swindow->listPos = 0;
789 swindow->listLen = 0;
790 }
791
792 /*
793 * This function destroys the scrolling window widget.
794 */
795 static void _destroyCDKSwindow (CDKOBJS *object)
796 {
797 if (object != 0)
798 {
799 CDKSWINDOW *swindow = (CDKSWINDOW *)object;
800
801 destroyInfo(swindow);
802
803 cleanCdkTitle (object);
804
805 /* Delete the windows. */
806 deleteCursesWindow (swindow->shadowWin);
807 deleteCursesWindow (swindow->fieldWin);
808 deleteCursesWindow (swindow->win);
809
810 /* Clean the key bindings. */
811 cleanCDKObjectBindings (vSWINDOW, swindow);
812
813 /* Unregister this object. */
814 unregisterCDKObject (vSWINDOW, swindow);
815 }
816 }
817
818 /*
819 * This function erases the scrolling window widget.
820 */
821 static void _eraseCDKSwindow (CDKOBJS *object)
822 {
823 if (validCDKObject (object))
824 {
825 CDKSWINDOW *swindow = (CDKSWINDOW *)object;
826
827 eraseCursesWindow (swindow->win);
828 eraseCursesWindow (swindow->shadowWin);
829 }
830 }
831
832 /*
833 * This exec's a command and redirects the output to the scrolling window.
834 */
835 int execCDKSwindow (CDKSWINDOW *swindow, char *command, int insertPos)
836 {
837 FILE *ps;
838 char temp[BUFSIZ];
839 int count = -1;
840
841 endwin();
842 /* Try to open the command. */
843 if ((ps = popen (command, "r")) != 0)
844 {
845 /* Start reading. */
846 while (fgets (temp, sizeof(temp), ps) != 0)
847 {
848 size_t len = strlen(temp);
849 if (len != 0 && temp[len-1] == '\n')
850 temp[--len] = '\0';
851 /* Add the line to the scrolling window. */
852 addCDKSwindow (swindow, temp, insertPos);
853 count++;
854 }
855
856 /* Close the pipe. */
857 pclose (ps);
858 }
859 return count;
860 }
861
862 static void showMessage2(CDKSWINDOW *swindow, char *msg, char *msg2, char *filename)
863 {
864 char *mesg[10];
865 char *temp = (char *)malloc(80 + strlen(filename));
866 int n = 0;
867
868 mesg[n++] = copyChar (msg);
869 mesg[n++] = copyChar (msg2);
870 sprintf (temp, "<C>(%s)", filename);
871 mesg[n++] = copyChar (temp);
872 mesg[n++] = copyChar (" ");
873 mesg[n++] = copyChar ("<C>Press any key to continue.");
874 popupLabel (ScreenOf(swindow), mesg, n);
875 freeCharList (mesg, n);
876 free (temp);
877 }
878
879 /*
880 * This function allows the user to dump the information from the
881 * scrolling window to a file.
882 */
883 void saveCDKSwindowInformation (CDKSWINDOW *swindow)
884 {
885 CDKENTRY *entry = 0;
886 char *filename = 0;
887 char temp[256], *mesg[10];
888 int linesSaved;
889
890 /* Create the entry field to get the filename. */
891 entry = newCDKEntry (ScreenOf(swindow), CENTER, CENTER,
892 "<C></B/5>Enter the filename of the save file.",
893 "Filename: ",
894 A_NORMAL, '_', vMIXED,
895 20, 1, 256,
896 TRUE, FALSE);
897
898 /* Get the filename. */
899 filename = activateCDKEntry (entry, 0);
900
901 /* Did they hit escape? */
902 if (entry->exitType == vESCAPE_HIT)
903 {
904 /* Popup a message. */
905 mesg[0] = "<C></B/5>Save Canceled.";
906 mesg[1] = "<C>Escape hit. Scrolling window information not saved.";
907 mesg[2] = " ";
908 mesg[3] = "<C>Press any key to continue.";
909 popupLabel (ScreenOf(swindow), mesg, 4);
910
911 /* Clean up and exit. */
912 destroyCDKEntry (entry);
913 return;
914 }
915
916 /* Write the contents of the scrolling window to the file. */
917 linesSaved = dumpCDKSwindow (swindow, filename);
918
919 /* Was the save successful? */
920 if (linesSaved == -1)
921 {
922 /* Nope, tell 'em. */
923 showMessage2(swindow,
924 "<C></B/16>Error",
925 "<C>Could not save to the file.",
926 filename);
927 }
928 else
929 {
930 /* Yep, let them know how many lines were saved. */
931 sprintf (temp, "<C>There were %d lines saved to the file", linesSaved);
932 showMessage2(swindow,
933 "<C></B/5>Save Successful",
934 temp,
935 filename);
936 }
937
938 /* Clean up and exit. */
939 destroyCDKEntry (entry);
940 eraseCDKScreen (ScreenOf(swindow));
941 drawCDKScreen (ScreenOf(swindow));
942 }
943
944 /*
945 * This function allows the user to load new information into the scrolling
946 * window.
947 */
948 void loadCDKSwindowInformation (CDKSWINDOW *swindow)
949 {
950 CDKFSELECT *fselect = 0;
951 CDKDIALOG *dialog = 0;
952 char *filename = 0;
953 char *mesg[15], *button[5], **fileInfo = 0;
954 int lines, answer;
955
956 /* Create the file selector to choose the file. */
957 fselect = newCDKFselect (ScreenOf(swindow), CENTER, CENTER, 20, 55,
958 "<C>Load Which File",
959 "Filename",
960 A_NORMAL, '.',
961 A_REVERSE,
962 "</5>", "</48>", "</N>", "</N>",
963 TRUE, FALSE);
964
965 /* Get the filename to load. */
966 filename = activateCDKFselect (fselect, 0);
967
968 /* Make sure they selected a file. */
969 if (fselect->exitType == vESCAPE_HIT)
970 {
971 /* Popup a message. */
972 mesg[0] = "<C></B/5>Load Canceled.";
973 mesg[1] = " ";
974 mesg[2] = "<C>Press any key to continue.";
975 popupLabel (ScreenOf(swindow), mesg, 3);
976
977 /* Clean up and exit. */
978 destroyCDKFselect (fselect);
979 return;
980 }
981
982 /* Copy the filename and destroy the file selector. */
983 filename = copyChar (fselect->pathname);
984 destroyCDKFselect (fselect);
985
986 /*
987 * Maye we should check before nuking all the information
988 * in the scrolling window...
989 */
990 if (swindow->listSize > 0)
991 {
992 /* Create the dialog message. */
993 mesg[0] = "<C></B/5>Save Information First";
994 mesg[1] = "<C>There is information in the scrolling window.";
995 mesg[2] = "<C>Do you want to save it to a file first?";
996 button[0] = "(Yes)";
997 button[1] = "(No)";
998
999 /* Create the dialog widget. */
1000 dialog = newCDKDialog (ScreenOf(swindow), CENTER, CENTER,
1001 mesg, 3, button, 2,
1002 COLOR_PAIR(2)|A_REVERSE,
1003 TRUE, TRUE, FALSE);
1004
1005 /* Activate the widget. */
1006 answer = activateCDKDialog (dialog, 0);
1007 destroyCDKDialog (dialog);
1008
1009 /* Check the answer. */
1010 if (answer == -1 || answer == 0)
1011 {
1012 /* Save the information. */
1013 saveCDKSwindowInformation (swindow);
1014 }
1015 }
1016
1017 /* Open the file and read it in. */
1018 lines = CDKreadFile (filename, &fileInfo);
1019 if (lines == -1)
1020 {
1021 /* The file read didn't work. */
1022 showMessage2(swindow,
1023 "<C></B/16>Error",
1024 "<C>Could not read the file",
1025 filename);
1026 freeChar (filename);
1027 return;
1028 }
1029
1030 /* Clean out the scrolling window. */
1031 cleanCDKSwindow (swindow);
1032
1033 /* Set the new information in the scrolling window. */
1034 setCDKSwindow (swindow, fileInfo, lines, ObjOf(swindow)->box);
1035
1036 /* Clean up. */
1037 CDKfreeStrings (fileInfo);
1038 freeChar (filename);
1039 }
1040
1041 /*
1042 * This actually dumps the information from the scrolling window to a
1043 * file.
1044 */
1045 int dumpCDKSwindow (CDKSWINDOW *swindow, char *filename)
1046 {
1047 FILE *outputFile = 0;
1048 char *rawLine = 0;
1049 int x;
1050
1051 /* Try to open the file. */
1052 if ((outputFile = fopen (filename, "w")) == 0)
1053 {
1054 return -1;
1055 }
1056
1057 /* Start writing out the file. */
1058 for (x=0; x < swindow->listSize; x++)
1059 {
1060 rawLine = chtype2Char (swindow->list[x]);
1061 fprintf (outputFile, "%s\n", rawLine);
1062 freeChar (rawLine);
1063 }
1064
1065 /* Close the file and return the number of lines written. */
1066 fclose (outputFile);
1067 return swindow->listSize;
1068 }
1069
1070 static void _focusCDKSwindow(CDKOBJS *object)
1071 {
1072 CDKSWINDOW *widget = (CDKSWINDOW *)object;
1073
1074 drawCDKSwindow (widget, ObjOf(widget)->box);
1075 }
1076
1077 static void _unfocusCDKSwindow(CDKOBJS *object)
1078 {
1079 CDKSWINDOW *widget = (CDKSWINDOW *)object;
1080
1081 drawCDKSwindow (widget, ObjOf(widget)->box);
1082 }
1083
1084 static int createList(CDKSWINDOW *swindow, int listSize)
1085 {
1086 int status = 0;
1087
1088 if (listSize <= 0)
1089 {
1090 destroyInfo(swindow);
1091 status = 1;
1092 }
1093 else
1094 {
1095 chtype **newList = typeCallocN(chtype *, listSize + 1);
1096 int *newPos = typeCallocN(int, listSize + 1);
1097 int *newLen = typeCallocN(int, listSize + 1);
1098
1099 if (newList != 0
1100 && newPos != 0
1101 && newLen != 0)
1102 {
1103 status = 1;
1104 destroyInfo(swindow);
1105
1106 swindow->list = newList;
1107 swindow->listPos = newPos;
1108 swindow->listLen = newLen;
1109 }
1110 if (!status)
1111 {
1112 CDKfreeChtypes (newList);
1113 freeChecked (newPos);
1114 freeChecked (newLen);
1115 }
1116 }
1117 return status;
1118 }
1119
1120 dummyRefreshData(Swindow)
1121
1122 dummySaveData(Swindow)
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:44 $
5 * $Revision: 1.130 $
6 */
7
8 /*
9 * Declare file local prototypes.
10 */
11 static void CDKTemplateCallBack (CDKTEMPLATE *widget, chtype input);
12 static void drawCDKTemplateField (CDKTEMPLATE *widget);
13 static void adjustCDKTemplateCursor (CDKTEMPLATE *widget, int direction);
14
15 #define isPlateChar(c) ((c) != 0 && strchr ("#ACcMXz", c) != 0)
16
17 DeclareCDKObjects (TEMPLATE, Template, setCdk, String);
18
19 /*
20 * This creates a cdktemplate widget.
21 */
22 CDKTEMPLATE *newCDKTemplate (CDKSCREEN *cdkscreen,
23 int xplace,
24 int yplace,
25 char *title,
26 char *label,
27 char *plate,
28 char *Overlay,
29 boolean Box,
30 boolean shadow)
31 {
32 CDKTEMPLATE *cdktemplate = 0;
33 int parentWidth = getmaxx (cdkscreen->window);
34 int parentHeight = getmaxy (cdkscreen->window);
35 int boxWidth = 0;
36 int boxHeight = Box ? 3 : 1;
37 int xpos = xplace;
38 int ypos = yplace;
39 int horizontalAdjust, oldWidth;
40 int fieldWidth = 0;
41 int plateLen = 0;
42 int junk = 0;
43
44 if (plate == 0
45 || (cdktemplate = newCDKObject (CDKTEMPLATE, &my_funcs)) == 0)
46 return (0);
47
48 setCDKTemplateBox (cdktemplate, Box);
49
50 fieldWidth = (int)strlen (plate) + 2 * BorderOf (cdktemplate);
51
52 /* Set some basic values of the cdktemplate field. */
53 cdktemplate->label = 0;
54 cdktemplate->labelLen = 0;
55 cdktemplate->labelWin = 0;
56
57 /* Translate the char * label to a chtype * */
58 if (label != 0)
59 {
60 cdktemplate->label = char2Chtype (label, &cdktemplate->labelLen, &junk);
61 }
62
63 /* Translate the char * Overlay to a chtype * */
64 if (Overlay != 0)
65 {
66 cdktemplate->overlay = char2Chtype (Overlay, &cdktemplate->overlayLen, &junk);
67 cdktemplate->fieldAttr = cdktemplate->overlay[0] & A_ATTRIBUTES;
68 }
69 else
70 {
71 cdktemplate->overlay = 0;
72 cdktemplate->overlayLen = 0;
73 cdktemplate->fieldAttr = A_NORMAL;
74 }
75
76 /* Set the box width. */
77 boxWidth = fieldWidth + cdktemplate->labelLen + 2 * BorderOf (cdktemplate);
78
79 oldWidth = boxWidth;
80 boxWidth = setCdkTitle (ObjOf (cdktemplate), title, boxWidth);
81 horizontalAdjust = (boxWidth - oldWidth) / 2;
82
83 boxHeight += TitleLinesOf (cdktemplate);
84
85 /*
86 * Make sure we didn't extend beyond the dimensions of the window.
87 */
88 boxWidth = MINIMUM (boxWidth, parentWidth);
89 boxHeight = MINIMUM (boxHeight, parentHeight);
90 fieldWidth = MINIMUM (fieldWidth, boxWidth - cdktemplate->labelLen - 2 * BorderOf (cdktemplate));
91
92 /* Rejustify the x and y positions if we need to. */
93 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
94
95 /* Make the cdktemplate window */
96 cdktemplate->win = newwin (boxHeight, boxWidth, ypos, xpos);
97
98 /* Is the cdktemplate window null?? */
99 if (cdktemplate->win == 0)
100 {
101 destroyCDKObject (cdktemplate);
102 return (0);
103 }
104 keypad (cdktemplate->win, TRUE);
105
106 /* Make the label window. */
107 if (cdktemplate->label != 0)
108 {
109 cdktemplate->labelWin = subwin (cdktemplate->win,
110 1, cdktemplate->labelLen,
111 (ypos +
112 TitleLinesOf (cdktemplate) +
113 BorderOf (cdktemplate)),
114 (xpos +
115 horizontalAdjust +
116 BorderOf (cdktemplate)));
117 }
118
119 /* Make the field window. */
120 cdktemplate->fieldWin = subwin (cdktemplate->win,
121 1, fieldWidth,
122 (ypos +
123 TitleLinesOf (cdktemplate) +
124 BorderOf (cdktemplate)),
125 (xpos +
126 cdktemplate->labelLen +
127 horizontalAdjust +
128 BorderOf (cdktemplate)));
129 keypad (cdktemplate->fieldWin, TRUE);
130
131 /* Set up the info field. */
132 cdktemplate->plateLen = (int)strlen (plate);
133 cdktemplate->info = typeCallocN (char, cdktemplate->plateLen + 2);
134 if (cdktemplate->info == 0)
135 {
136 destroyCDKObject (cdktemplate);
137 return (0);
138 }
139
140 /* Copy the plate to the cdktemplate. */
141 plateLen = strlen (plate);
142 cdktemplate->plate = typeMallocN (char, plateLen + 3);
143 if (cdktemplate->plate == 0)
144 {
145 destroyCDKObject (cdktemplate);
146 return (0);
147 }
148 strcpy (cdktemplate->plate, plate);
149
150 /* Set up the rest of the structure */
151 ScreenOf (cdktemplate) = cdkscreen;
152 cdktemplate->parent = cdkscreen->window;
153 cdktemplate->shadowWin = 0;
154 cdktemplate->fieldWidth = fieldWidth;
155 cdktemplate->boxHeight = boxHeight;
156 cdktemplate->boxWidth = boxWidth;
157 cdktemplate->platePos = 0;
158 cdktemplate->screenPos = 0;
159 cdktemplate->infoPos = 0;
160 initExitType (cdktemplate);
161 cdktemplate->min = 0;
162 ObjOf (cdktemplate)->inputWindow = cdktemplate->win;
163 ObjOf (cdktemplate)->acceptsFocus = TRUE;
164 cdktemplate->shadow = shadow;
165 cdktemplate->callbackfn = CDKTemplateCallBack;
166
167 /* Do we need to create a shadow??? */
168 if (shadow)
169 {
170 cdktemplate->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
171 }
172
173 registerCDKObject (cdkscreen, vTEMPLATE, cdktemplate);
174
175 return cdktemplate;
176 }
177
178 /*
179 * This actually manages the cdktemplate widget...
180 */
181 char *activateCDKTemplate (CDKTEMPLATE *cdktemplate, chtype *actions)
182 {
183 chtype input = 0;
184 boolean functionKey;
185 char *ret = 0;
186
187 /* Draw the object. */
188 drawCDKTemplate (cdktemplate, ObjOf (cdktemplate)->box);
189
190 if (actions == 0)
191 {
192 for (;;)
193 {
194 input = getchCDKObject (ObjOf (cdktemplate), &functionKey);
195
196 /* Inject the character into the widget. */
197 ret = injectCDKTemplate (cdktemplate, input);
198 if (cdktemplate->exitType != vEARLY_EXIT)
199 {
200 return ret;
201 }
202 }
203 }
204 else
205 {
206 int length = chlen (actions);
207 int x = 0;
208
209 /* Inject each character one at a time. */
210 for (x = 0; x < length; x++)
211 {
212 ret = injectCDKTemplate (cdktemplate, actions[x]);
213 if (cdktemplate->exitType != vEARLY_EXIT)
214 {
215 return ret;
216 }
217 }
218 }
219
220 /* Set the exit type and return. */
221 setExitType (cdktemplate, 0);
222 return ret;
223 }
224
225 /*
226 * This injects a character into the widget.
227 */
228 static int _injectCDKTemplate (CDKOBJS *object, chtype input)
229 {
230 CDKTEMPLATE *cdktemplate = (CDKTEMPLATE *)object;
231 int ppReturn = 1;
232 int length, x;
233 char *ret = unknownString;
234 bool complete = FALSE;
235
236 /* Set the exit type and return. */
237 setExitType (cdktemplate, 0);
238
239 /* Move the cursor. */
240 drawCDKTemplateField (cdktemplate);
241
242 /* Check if there is a pre-process function to be called. */
243 if (PreProcessFuncOf (cdktemplate) != 0)
244 {
245 ppReturn = PreProcessFuncOf (cdktemplate) (vTEMPLATE,
246 cdktemplate,
247 PreProcessDataOf (cdktemplate),
248 input);
249 }
250
251 /* Should we continue? */
252 if (ppReturn != 0)
253 {
254 /* Check a predefined binding... */
255 if (checkCDKObjectBind (vTEMPLATE, cdktemplate, input) != 0)
256 {
257 checkEarlyExit (cdktemplate);
258 complete = TRUE;
259 }
260 else
261 {
262 switch (input)
263 {
264 case CDK_ERASE:
265 if (strlen (cdktemplate->info) != 0)
266 {
267 cleanCDKTemplate (cdktemplate);
268 drawCDKTemplateField (cdktemplate);
269 }
270 break;
271
272 case CDK_CUT:
273 if ((int)strlen (cdktemplate->info) != 0)
274 {
275 freeChar (GPasteBuffer);
276 GPasteBuffer = copyChar (cdktemplate->info);
277 cleanCDKTemplate (cdktemplate);
278 drawCDKTemplateField (cdktemplate);
279 }
280 else
281 {
282 Beep ();
283 }
284 break;
285
286 case CDK_COPY:
287 if ((int)strlen (cdktemplate->info) != 0)
288 {
289 freeChar (GPasteBuffer);
290 GPasteBuffer = copyChar (cdktemplate->info);
291 }
292 else
293 {
294 Beep ();
295 }
296 break;
297
298 case CDK_PASTE:
299 if (GPasteBuffer != 0)
300 {
301 cleanCDKTemplate (cdktemplate);
302
303 /* Start inserting each character one at a time. */
304 length = (int)strlen (GPasteBuffer);
305 for (x = 0; x < length; x++)
306 {
307 (cdktemplate->callbackfn) (cdktemplate, GPasteBuffer[x]);
308 }
309 drawCDKTemplateField (cdktemplate);
310 }
311 else
312 {
313 Beep ();
314 }
315 break;
316
317 case KEY_TAB:
318 case KEY_ENTER:
319 if ((int)strlen (cdktemplate->info) < (int)cdktemplate->min)
320 {
321 Beep ();
322 }
323 else
324 {
325 setExitType (cdktemplate, input);
326 ret = cdktemplate->info;
327 complete = TRUE;
328 }
329 break;
330
331 case KEY_ESC:
332 setExitType (cdktemplate, input);
333 complete = TRUE;
334 break;
335
336 case CDK_REFRESH:
337 eraseCDKScreen (ScreenOf (cdktemplate));
338 refreshCDKScreen (ScreenOf (cdktemplate));
339 break;
340
341 default:
342 (cdktemplate->callbackfn) (cdktemplate, input);
343 break;
344 }
345 }
346
347 /* Should we call a post-process? */
348 if (!complete && (PostProcessFuncOf (cdktemplate) != 0))
349 {
350 PostProcessFuncOf (cdktemplate) (vTEMPLATE,
351 cdktemplate,
352 PostProcessDataOf (cdktemplate),
353 input);
354 }
355 }
356
357 if (!complete)
358 {
359 setExitType (cdktemplate, 0);
360 }
361
362 ResultOf (cdktemplate).valueString = ret;
363 return (ret != unknownString);
364 }
365
366 /*
367 * Return true if the given string matches the template (may be incomplete).
368 */
369 static boolean validTemplate (CDKTEMPLATE *cdktemplate, char *input)
370 {
371 int pp, ip;
372 const char *plate = cdktemplate->plate;
373
374 for (pp = 0, ip = 0; input[ip] != '\0' && plate[pp] != '\0'; ++ip, ++pp)
375 {
376 int newchar = input[ip];
377
378 while (plate[pp] != '\0' && !isPlateChar (plate[pp]))
379 {
380 ++pp;
381 }
382 if (plate[pp] == 0)
383 {
384 return FALSE;
385 }
386
387 /* check if the input matches the plate */
388 if (isdigit (CharOf (newchar)) &&
389 (plate[pp] == 'A' ||
390 plate[pp] == 'C' ||
391 plate[pp] == 'c'))
392 {
393 return FALSE;
394 }
395 if (!isdigit (CharOf (newchar)) &&
396 plate[pp] == '#')
397 {
398 return FALSE;
399 }
400
401 /* Do we need to convert the case??? */
402 if (plate[pp] == 'C' ||
403 plate[pp] == 'X')
404 {
405 newchar = toupper (newchar);
406 }
407 else if (plate[pp] == 'c' ||
408 plate[pp] == 'x')
409 {
410 newchar = tolower (newchar);
411 }
412 input[ip] = (char)newchar;
413 }
414 return TRUE;
415 }
416
417 /*
418 * This is the standard callback proc for the cdktemplate.
419 */
420 static void CDKTemplateCallBack (CDKTEMPLATE *cdktemplate, chtype input)
421 {
422 boolean failed = FALSE;
423 boolean change = FALSE;
424 boolean moveby = FALSE;
425 int amount = 0;
426 unsigned mark = cdktemplate->infoPos;
427 unsigned have = strlen (cdktemplate->info);
428
429 if (input == KEY_LEFT)
430 {
431 if (mark != 0)
432 {
433 moveby = TRUE;
434 amount = -1;
435 }
436 else
437 {
438 failed = TRUE;
439 }
440 }
441 else if (input == KEY_RIGHT)
442 {
443 if (cdktemplate->info[mark] != '\0')
444 {
445 moveby = TRUE;
446 amount = 1;
447 }
448 else
449 {
450 failed = TRUE;
451 }
452 }
453 else
454 {
455 char *test = malloc (have + 2);
456
457 if (test != 0)
458 {
459 strcpy (test, cdktemplate->info);
460
461 if (input == KEY_BACKSPACE)
462 {
463 if (mark != 0)
464 {
465 strcpy (test + mark - 1, cdktemplate->info + mark);
466 change = TRUE;
467 amount = -1;
468 }
469 else
470 {
471 failed = TRUE;
472 }
473 }
474 else if (input == KEY_DC)
475 {
476 if (test[mark] != '\0')
477 {
478 strcpy (test + mark, cdktemplate->info + mark + 1);
479 change = TRUE;
480 amount = 0;
481 }
482 else
483 {
484 failed = TRUE;
485 }
486 }
487 else if (isChar (input) &&
488 cdktemplate->platePos < cdktemplate->fieldWidth)
489 {
490 test[mark] = CharOf (input);
491 strcpy (test + mark + 1, cdktemplate->info + mark);
492 change = TRUE;
493 amount = 1;
494 }
495 else
496 {
497 failed = TRUE;
498 }
499
500 if (change)
501 {
502 if (validTemplate (cdktemplate, test))
503 {
504 strcpy (cdktemplate->info, test);
505 drawCDKTemplateField (cdktemplate);
506 }
507 else
508 {
509 failed = TRUE;
510 }
511 }
512
513 free (test);
514 }
515 }
516
517 if (failed)
518 {
519 Beep ();
520 }
521 else if (change || moveby)
522 {
523 cdktemplate->infoPos += amount;
524 cdktemplate->platePos += amount;
525 cdktemplate->screenPos += amount;
526
527 adjustCDKTemplateCursor (cdktemplate, amount);
528 }
529 }
530
531 /*
532 * Return a mixture of the plate-overlay and field-info.
533 */
534 char *mixCDKTemplate (CDKTEMPLATE *cdktemplate)
535 {
536 char *mixedString = 0;
537 int platePos = 0;
538 int infoPos = 0;
539
540 if (cdktemplate->info != 0 && cdktemplate->info[0] != '\0')
541 {
542 mixedString = typeCallocN (char, cdktemplate->plateLen + 3);
543
544 if (mixedString != 0)
545 {
546 while (platePos < cdktemplate->plateLen)
547 {
548 mixedString[platePos] = (isPlateChar (cdktemplate->plate[platePos])
549 ? cdktemplate->info[infoPos++]
550 : cdktemplate->plate[platePos]);
551 platePos++;
552 }
553 }
554 }
555
556 return mixedString;
557 }
558
559 /*
560 * Return the field-info from the mixed string.
561 */
562 char *unmixCDKTemplate (CDKTEMPLATE *cdktemplate, char *info)
563 {
564 int x = 0;
565 int pos = 0;
566 int infolen = (int)strlen (info);
567 char *unmixedString = typeCallocN (char, infolen + 2);
568
569 if (unmixedString != 0)
570 {
571 while (pos < infolen)
572 {
573 if (isPlateChar (cdktemplate->plate[pos]))
574 {
575 unmixedString[x++] = info[pos++];
576 }
577 else
578 {
579 pos++;
580 }
581 }
582 }
583
584 return unmixedString;
585 }
586
587 /*
588 * Move the cdktemplate field to the given location.
589 */
590 static void _moveCDKTemplate (CDKOBJS *object,
591 int xplace,
592 int yplace,
593 boolean relative,
594 boolean refresh_flag)
595 {
596 CDKTEMPLATE *cdktemplate = (CDKTEMPLATE *)object;
597 int currentX = getbegx (cdktemplate->win);
598 int currentY = getbegy (cdktemplate->win);
599 int xpos = xplace;
600 int ypos = yplace;
601 int xdiff = 0;
602 int ydiff = 0;
603
604 /*
605 * If this is a relative move, then we will adjust where we want
606 * to move to.
607 */
608 if (relative)
609 {
610 xpos = getbegx (cdktemplate->win) + xplace;
611 ypos = getbegy (cdktemplate->win) + yplace;
612 }
613
614 /* Adjust the window if we need to. */
615 alignxy (WindowOf (cdktemplate), &xpos, &ypos, cdktemplate->boxWidth, cdktemplate->boxHeight);
616
617 /* Get the difference. */
618 xdiff = currentX - xpos;
619 ydiff = currentY - ypos;
620
621 /* Move the window to the new location. */
622 moveCursesWindow (cdktemplate->win, -xdiff, -ydiff);
623 moveCursesWindow (cdktemplate->labelWin, -xdiff, -ydiff);
624 moveCursesWindow (cdktemplate->fieldWin, -xdiff, -ydiff);
625 moveCursesWindow (cdktemplate->shadowWin, -xdiff, -ydiff);
626
627 /* Touch the windows so they 'move'. */
628 refreshCDKWindow (WindowOf (cdktemplate));
629
630 /* Redraw the window, if they asked for it. */
631 if (refresh_flag)
632 {
633 drawCDKTemplate (cdktemplate, ObjOf (cdktemplate)->box);
634 }
635 }
636
637 /*
638 * Draw the template widget.
639 */
640 static void _drawCDKTemplate (CDKOBJS *object, boolean Box)
641 {
642 CDKTEMPLATE *cdktemplate = (CDKTEMPLATE *)object;
643
644 /* Do we need to draw the shadow. */
645 if (cdktemplate->shadowWin != 0)
646 {
647 drawShadow (cdktemplate->shadowWin);
648 }
649
650 /* Box it if needed */
651 if (Box)
652 {
653 drawObjBox (cdktemplate->win, ObjOf (cdktemplate));
654 }
655
656 drawCdkTitle (cdktemplate->win, object);
657
658 wrefresh (cdktemplate->win);
659
660 drawCDKTemplateField (cdktemplate);
661 }
662
663 /*
664 * Draw the cdktemplate field.
665 */
666 static void drawCDKTemplateField (CDKTEMPLATE *cdktemplate)
667 {
668 chtype fieldColor = 0;
669 int infolen = (int)strlen (cdktemplate->info);
670 int x = 0;
671
672 /* Draw in the label and the cdktemplate object. */
673 if (cdktemplate->labelWin != 0)
674 {
675 writeChtype (cdktemplate->labelWin, 0, 0,
676 cdktemplate->label,
677 HORIZONTAL, 0,
678 cdktemplate->labelLen);
679 wrefresh (cdktemplate->labelWin);
680 }
681
682 /* Draw in the cdktemplate... */
683 if (cdktemplate->overlay != 0)
684 {
685 writeChtype (cdktemplate->fieldWin, 0, 0,
686 cdktemplate->overlay,
687 HORIZONTAL, 0,
688 cdktemplate->overlayLen);
689 }
690
691 /* Adjust the cursor. */
692 if (infolen != 0)
693 {
694 int pos = 0;
695 for (x = 0; x < cdktemplate->fieldWidth; x++)
696 {
697 if (isPlateChar (cdktemplate->plate[x]) && pos < infolen)
698 {
699 fieldColor = cdktemplate->overlay[x] & A_ATTRIBUTES;
700 mvwaddch (cdktemplate->fieldWin,
701 0, x,
702 CharOf (cdktemplate->info[pos++]) | fieldColor);
703 }
704 }
705 wmove (cdktemplate->fieldWin, 0, cdktemplate->screenPos);
706 }
707 else
708 {
709 adjustCDKTemplateCursor (cdktemplate, +1);
710 }
711 wrefresh (cdktemplate->fieldWin);
712 }
713
714 /*
715 * Adjust the cursor for the cdktemplate.
716 */
717 static void adjustCDKTemplateCursor (CDKTEMPLATE *cdktemplate, int direction)
718 {
719 while (!isPlateChar (cdktemplate->plate[cdktemplate->platePos])
720 && cdktemplate->platePos < cdktemplate->fieldWidth)
721 {
722 cdktemplate->platePos += direction;
723 cdktemplate->screenPos += direction;
724 }
725 wmove (cdktemplate->fieldWin, 0, cdktemplate->screenPos);
726 wrefresh (cdktemplate->fieldWin);
727 }
728
729 /*
730 * Set the background attribute of the widget.
731 */
732 static void _setBKattrTemplate (CDKOBJS *object, chtype attrib)
733 {
734 if (object != 0)
735 {
736 CDKTEMPLATE *widget = (CDKTEMPLATE *)object;
737
738 wbkgd (widget->win, attrib);
739 wbkgd (widget->fieldWin, attrib);
740 if (widget->labelWin != 0)
741 {
742 wbkgd (widget->labelWin, attrib);
743 }
744 }
745 }
746
747 /*
748 * Destroy this widget.
749 */
750 static void _destroyCDKTemplate (CDKOBJS *object)
751 {
752 if (object != 0)
753 {
754 CDKTEMPLATE *cdktemplate = (CDKTEMPLATE *)object;
755
756 cleanCdkTitle (object);
757 freeChtype (cdktemplate->label);
758 freeChtype (cdktemplate->overlay);
759 freeChar (cdktemplate->plate);
760 freeChar (cdktemplate->info);
761
762 /* Delete the windows. */
763 deleteCursesWindow (cdktemplate->fieldWin);
764 deleteCursesWindow (cdktemplate->labelWin);
765 deleteCursesWindow (cdktemplate->shadowWin);
766 deleteCursesWindow (cdktemplate->win);
767
768 /* Clean the key bindings. */
769 cleanCDKObjectBindings (vTEMPLATE, cdktemplate);
770
771 unregisterCDKObject (vTEMPLATE, cdktemplate);
772 }
773 }
774
775 /*
776 * Erase the widget.
777 */
778 static void _eraseCDKTemplate (CDKOBJS *object)
779 {
780 if (validCDKObject (object))
781 {
782 CDKTEMPLATE *cdktemplate = (CDKTEMPLATE *)object;
783
784 eraseCursesWindow (cdktemplate->fieldWin);
785 eraseCursesWindow (cdktemplate->labelWin);
786 eraseCursesWindow (cdktemplate->win);
787 eraseCursesWindow (cdktemplate->shadowWin);
788 }
789 }
790
791 /*
792 * Set the value given to the cdktemplate.
793 */
794 void setCDKTemplate (CDKTEMPLATE *cdktemplate, char *newValue, boolean Box)
795 {
796 setCDKTemplateValue (cdktemplate, newValue);
797 setCDKTemplateBox (cdktemplate, Box);
798 }
799
800 /*
801 * Set the value given to the cdktemplate.
802 */
803 void setCDKTemplateValue (CDKTEMPLATE *cdktemplate, char *newValue)
804 {
805 int len = 0;
806 int copychars = 0;
807 int x;
808
809 /* Just to be sure, if let's make sure the new value isn't null. */
810 if (newValue == 0)
811 {
812 cleanCDKTemplate (cdktemplate);
813 return;
814 }
815
816 /* Determine how many characters we need to copy. */
817 len = (int)strlen (newValue);
818 copychars = MINIMUM (len, cdktemplate->fieldWidth);
819
820 /* OK, erase the old value, and copy in the new value. */
821 cdktemplate->info[0] = '\0';
822 strncpy (cdktemplate->info, newValue, copychars);
823
824 /* Use the function which handles the input of the characters. */
825 for (x = 0; x < len; x++)
826 {
827 (cdktemplate->callbackfn) (cdktemplate, (chtype)newValue[x]);
828 }
829 }
830 char *getCDKTemplateValue (CDKTEMPLATE *cdktemplate)
831 {
832 return cdktemplate->info;
833 }
834
835 /*
836 * Set the minimum number of characters to enter into the widget.
837 */
838 void setCDKTemplateMin (CDKTEMPLATE *cdktemplate, int min)
839 {
840 if (min >= 0)
841 {
842 cdktemplate->min = min;
843 }
844 }
845 int getCDKTemplateMin (CDKTEMPLATE *cdktemplate)
846 {
847 return cdktemplate->min;
848 }
849
850 /*
851 * Set the box attribute of the cdktemplate widget.
852 */
853 void setCDKTemplateBox (CDKTEMPLATE *cdktemplate, boolean Box)
854 {
855 ObjOf (cdktemplate)->box = Box;
856 ObjOf (cdktemplate)->borderSize = Box ? 1 : 0;
857 }
858 boolean getCDKTemplateBox (CDKTEMPLATE *cdktemplate)
859 {
860 return ObjOf (cdktemplate)->box;
861 }
862
863 /*
864 * Erase the information in the cdktemplate widget.
865 */
866 void cleanCDKTemplate (CDKTEMPLATE *cdktemplate)
867 {
868 cdktemplate->info[0] = '\0';
869 cdktemplate->screenPos = 0;
870 cdktemplate->infoPos = 0;
871 cdktemplate->platePos = 0;
872 }
873
874 /*
875 * Set the callback function for the widget.
876 */
877 void setCDKTemplateCB (CDKTEMPLATE *cdktemplate, TEMPLATECB callback)
878 {
879 cdktemplate->callbackfn = callback;
880 }
881
882 static void _focusCDKTemplate (CDKOBJS *object)
883 {
884 CDKTEMPLATE *widget = (CDKTEMPLATE *)object;
885
886 drawCDKTemplate (widget, ObjOf (widget)->box);
887 }
888
889 static void _unfocusCDKTemplate (CDKOBJS *object)
890 {
891 CDKTEMPLATE *widget = (CDKTEMPLATE *)object;
892
893 drawCDKTemplate (widget, ObjOf (widget)->box);
894 }
895
896 dummyRefreshData (Template)
897
898 dummySaveData (Template)
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2005/12/30 01:32:53 $
5 * $Revision: 1.21 $
6 */
7
8 #define limitFocusIndex(screen, value) \
9 (((value) >= (screen)->objectCount || (value) < 0) \
10 ? 0 \
11 : (value))
12
13 static int getFocusIndex (CDKSCREEN *screen)
14 {
15 int result = limitFocusIndex (screen, screen->objectFocus);
16
17 return result;
18 }
19
20 static void setFocusIndex (CDKSCREEN *screen, int value)
21 {
22 screen->objectFocus = limitFocusIndex (screen, value);
23 }
24
25 static void unsetFocus (CDKOBJS *obj)
26 {
27 curs_set (0);
28 if (obj != 0)
29 {
30 HasFocusObj (obj) = FALSE;
31 UnfocusObj (obj);
32 }
33 }
34
35 static void setFocus (CDKOBJS *obj)
36 {
37 if (obj != 0)
38 {
39 HasFocusObj (obj) = TRUE;
40 FocusObj (obj);
41 }
42 curs_set (1);
43 }
44
45 static CDKOBJS *switchFocus (CDKOBJS *newobj, CDKOBJS *oldobj)
46 {
47 if (oldobj != newobj)
48 {
49 unsetFocus (oldobj);
50 setFocus (newobj);
51 }
52 return newobj;
53 }
54
55 static boolean checkMenuKey (int keyCode, int functionKey)
56 {
57 int result = FALSE;
58
59 result = (keyCode == KEY_ESC && !functionKey);
60
61 return result;
62 }
63
64 static CDKOBJS *handleMenu (CDKSCREEN *screen, CDKOBJS *menu, CDKOBJS *oldobj)
65 {
66 bool done = FALSE;
67 CDKOBJS *newobj;
68
69 switchFocus (menu, oldobj);
70 while (!done)
71 {
72 boolean functionKey;
73 int key = getchCDKObject (menu, &functionKey);
74
75 switch (key)
76 {
77 case KEY_TAB:
78 done = TRUE;
79 break;
80
81 case KEY_ESC:
82 /* cleanup the menu */
83 injectCDKMenu ((CDKMENU *)menu, key);
84 done = TRUE;
85 break;
86
87 default:
88 done = (injectCDKMenu ((CDKMENU *)menu, key) >= 0);
89 break;
90 }
91 }
92
93 if ((newobj = getCDKFocusCurrent (screen)) == 0)
94 newobj = setCDKFocusNext (screen);
95
96 return switchFocus (newobj, menu);
97 }
98
99 /*
100 * Save data in widgets on a screen
101 */
102 static void saveDataCDKScreen (CDKSCREEN *screen)
103 {
104 int i;
105
106 for (i = 0; i < screen->objectCount; ++i)
107 SaveDataObj (screen->object[i]);
108 }
109
110 /*
111 * Refresh data in widgets on a screen
112 */
113 static void refreshDataCDKScreen (CDKSCREEN *screen)
114 {
115 int i;
116
117 for (i = 0; i < screen->objectCount; ++i)
118 RefreshDataObj (screen->object[i]);
119 }
120
121
122 /*
123 * ======================================================================
124 * Public Interface
125 */
126
127 void resetCDKScreen (CDKSCREEN *screen)
128 {
129 refreshDataCDKScreen (screen);
130 }
131
132 void exitOKCDKScreen (CDKSCREEN *screen)
133 {
134 screen->exitStatus = CDKSCREEN_EXITOK;
135 }
136
137 void exitCancelCDKScreen (CDKSCREEN *screen)
138 {
139 screen->exitStatus = CDKSCREEN_EXITCANCEL;
140 }
141
142 void exitOKCDKScreenOf (CDKOBJS *obj)
143 {
144 exitOKCDKScreen (obj->screen);
145 }
146
147 void exitCancelCDKScreenOf (CDKOBJS *obj)
148 {
149 exitCancelCDKScreen (obj->screen);
150 }
151
152 void resetCDKScreenOf (CDKOBJS *obj)
153 {
154 resetCDKScreen (obj->screen);
155 }
156
157 /*
158 * Returns the object on which the focus lies.
159 */
160 CDKOBJS *getCDKFocusCurrent (CDKSCREEN *screen)
161 {
162 CDKOBJS *result = 0;
163 int n = screen->objectFocus;
164
165 if (n >= 0 && n < screen->objectCount)
166 result = screen->object[n];
167 return result;
168 }
169
170 /*
171 * Set focus to the next object, returning it.
172 */
173 CDKOBJS *setCDKFocusNext (CDKSCREEN *screen)
174 {
175 CDKOBJS *result = 0;
176 CDKOBJS *curobj;
177 int n = getFocusIndex (screen);
178 int first = n;
179
180 for (;;)
181 {
182 if (++n >= screen->objectCount)
183 n = 0;
184 curobj = screen->object[n];
185 if (curobj != 0 && AcceptsFocusObj (curobj))
186 {
187 result = curobj;
188 break;
189 }
190 else
191 {
192 if (n == first)
193 {
194 break;
195 }
196 }
197 }
198
199 setFocusIndex (screen, (result != 0) ? n : -1);
200 return result;
201 }
202
203 /*
204 * Set focus to the previous object, returning it.
205 */
206 CDKOBJS *setCDKFocusPrevious (CDKSCREEN *screen)
207 {
208 CDKOBJS *result = 0;
209 CDKOBJS *curobj;
210 int n = getFocusIndex (screen);
211 int first = n;
212
213 for (;;)
214 {
215 if (--n < 0)
216 n = screen->objectCount - 1;
217 curobj = screen->object[n];
218 if (curobj != 0 && AcceptsFocusObj (curobj))
219 {
220 result = curobj;
221 break;
222 }
223 else if (n == first)
224 {
225 break;
226 }
227 }
228
229 setFocusIndex (screen, (result != 0) ? n : -1);
230 return result;
231 }
232
233 /*
234 * Set focus to a specific object, returning it.
235 * If the object cannot be found, return null.
236 */
237 CDKOBJS *setCDKFocusCurrent (CDKSCREEN *screen, CDKOBJS *newobj)
238 {
239 CDKOBJS *result = 0;
240 CDKOBJS *curobj;
241 int n = getFocusIndex (screen);
242 int first = n;
243
244 for (;;)
245 {
246 if (++n >= screen->objectCount)
247 n = 0;
248
249 curobj = screen->object[n];
250 if (curobj == newobj)
251 {
252 result = curobj;
253 break;
254 }
255 else if (n == first)
256 {
257 break;
258 }
259 }
260
261 setFocusIndex (screen, (result != 0) ? n : -1);
262 return result;
263 }
264
265 /*
266 * Set focus to the first object in the screen.
267 */
268 CDKOBJS *setCDKFocusFirst (CDKSCREEN *screen)
269 {
270 setFocusIndex (screen, screen->objectCount - 1);
271 return switchFocus (setCDKFocusNext (screen), 0);
272 }
273
274 /*
275 * Set focus to the last object in the screen.
276 */
277 CDKOBJS *setCDKFocusLast (CDKSCREEN *screen)
278 {
279 setFocusIndex (screen, 0);
280 return switchFocus (setCDKFocusPrevious (screen), 0);
281 }
282
283 void traverseCDKOnce (CDKSCREEN *screen,
284 CDKOBJS *curobj,
285 int keyCode,
286 boolean functionKey,
287 CHECK_KEYCODE funcMenuKey)
288 {
289 switch (keyCode)
290 {
291 case KEY_BTAB:
292 switchFocus (setCDKFocusPrevious (screen), curobj);
293 break;
294
295 case KEY_TAB:
296 switchFocus (setCDKFocusNext (screen), curobj);
297 break;
298
299 case KEY_F (10):
300 /* save data and exit */
301 exitOKCDKScreen (screen);
302 break;
303
304 case CTRL ('X'):
305 exitCancelCDKScreen (screen);
306 break;
307
308 case CTRL ('R'):
309 /* reset data to defaults */
310 resetCDKScreen (screen);
311 setFocus (curobj);
312 break;
313
314 case CDK_REFRESH:
315 /* redraw screen */
316 refreshCDKScreen (screen);
317 setFocus (curobj);
318 break;
319
320 default:
321 /* not everyone wants menus, so we make them optional here */
322 if (funcMenuKey != 0 && funcMenuKey (keyCode, functionKey))
323 {
324 /* find and enable drop down menu */
325 int j;
326
327 for (j = 0; j < screen->objectCount; ++j)
328 if (ObjTypeOf (screen->object[j]) == vMENU)
329 {
330 handleMenu (screen, screen->object[j], curobj);
331 break;
332 }
333 }
334 else
335 {
336 InjectObj (curobj, keyCode);
337 }
338 break;
339 }
340 }
341
342 /*
343 * Traverse the widgets on a screen.
344 */
345 int traverseCDKScreen (CDKSCREEN *screen)
346 {
347 int result = 0;
348 CDKOBJS *curobj = setCDKFocusFirst (screen);
349
350 if (curobj != 0)
351 {
352 refreshDataCDKScreen (screen);
353
354 screen->exitStatus = CDKSCREEN_NOEXIT;
355
356 while (((curobj = getCDKFocusCurrent (screen)) != 0)
357 && (screen->exitStatus == CDKSCREEN_NOEXIT))
358 {
359 int key;
360 boolean function;
361
362 key = getchCDKObject (curobj, &function);
363
364 traverseCDKOnce (screen, curobj, key, function, checkMenuKey);
365 }
366
367 if (screen->exitStatus == CDKSCREEN_EXITOK)
368 {
369 saveDataCDKScreen (screen);
370 result = 1;
371 }
372 }
373 return result;
374 }
+0
-34
typemap less more
0 WINDOW * T_PTROBJ
1 CDKARRAY * T_PTROBJ
2 CDKSCREEN * T_PTROBJ
3 CDKLABEL * T_PTROBJ
4 CDKDIALOG * T_PTROBJ
5 CDKENTRY * T_PTROBJ
6 CDKSCROLL * T_PTROBJ
7 CDKSCALE * T_PTROBJ
8 CDKHISTOGRAM * T_PTROBJ
9 CDKMENU * T_PTROBJ
10 CDKMENTRY * T_PTROBJ
11 CDKMATRIX * T_PTROBJ
12 CDKMARQUEE * T_PTROBJ
13 CDKSELECTION * T_PTROBJ
14 CDKVIEWER * T_PTROBJ
15 CDKGRAPH * T_PTROBJ
16 CDKRADIO * T_PTROBJ
17 CDKTEMPLATE * T_PTROBJ
18 CDKSWINDOW * T_PTROBJ
19 CDKITEMLIST * T_PTROBJ
20 CDKFSELECT * T_PTROBJ
21 CDKSLIDER * T_PTROBJ
22 CDKALPHALIST * T_PTROBJ
23 CDKCALENDAR * T_PTROBJ
24 CDKBUTTONBOX * T_PTROBJ
25
26 chtype T_IV
27 boolean T_IV
28
29 EObjectType T_IV
30 EDisplayType T_IV
31 EHistogramDisplayType T_IV
32
33 INPUT
0 #include <cdk.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2002/07/20 00:30:51 $
5 * $Revision: 1.1 $
6 */
7 char * CDKVersion(void)
8 {
9 return CDK_VERSION_MAJOR "." CDK_VERSION_MINOR " - " CDK_VERSION_PATCH;
10 }
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2005/12/27 01:05:44 $
5 * $Revision: 1.3 $
6 */
7
8 /*
9 * This allows the user to view a file.
10 */
11 int viewFile (CDKSCREEN *screen, char *title, char *filename, char **buttons, int buttonCount)
12 {
13 int result;
14 int lines = 0;
15 char **info = 0;
16
17 /* Open the file and read the contents. */
18 lines = CDKreadFile (filename, &info);
19
20 /* If we couldn't read the file, return an error. */
21 if (lines == -1)
22 {
23 result = lines;
24 }
25 else
26 {
27
28 result = viewInfo(screen, title, info, lines, buttons, buttonCount, TRUE);
29 CDKfreeStrings (info);
30 }
31 return result;
32 }
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2003/11/27 22:05:27 $
5 * $Revision: 1.1 $
6 */
7
8 /*
9 * This allows the user to view information.
10 */
11 int viewInfo (CDKSCREEN *screen, char *title, char **info, int count, char **buttons, int buttonCount, boolean interpret)
12 {
13 CDKVIEWER *viewer = 0;
14 int selected = -1;
15
16 /* Create the file viewer to view the file selected.*/
17 viewer = newCDKViewer (screen, CENTER, CENTER, -6, -16,
18 buttons, buttonCount,
19 A_REVERSE, TRUE, TRUE);
20
21 /* Set up the viewer title, and the contents to the widget. */
22 setCDKViewer (viewer, title, info, count, A_REVERSE, interpret, TRUE, TRUE);
23
24 /* Activate the viewer widget. */
25 selected = activateCDKViewer (viewer, 0);
26
27 /* Make sure they exited normally. */
28 if (viewer->exitType != vNORMAL)
29 {
30 destroyCDKViewer (viewer);
31 return (-1);
32 }
33
34 /* Clean up and return the button index selected. */
35 destroyCDKViewer (viewer);
36 return selected;
37 }
0 #include <cdk_int.h>
1
2 /*
3 * $Author: tom $
4 * $Date: 2006/05/05 00:27:44 $
5 * $Revision: 1.156 $
6 */
7
8 /*
9 * Declare some local definitions.
10 */
11 #define DOWN 0
12 #define UP 1
13
14 /*
15 * Declare file local prototypes.
16 */
17 static int createList (CDKVIEWER *swindow, int listSize);
18 static int searchForWord (CDKVIEWER *viewer, char *pattern, int direction);
19 static int jumpToLine (CDKVIEWER *viewer);
20 static void popUpLabel (CDKVIEWER *viewer, char **mesg);
21 static void getAndStorePattern (CDKSCREEN *screen);
22 static void drawCDKViewerButtons (CDKVIEWER *viewer);
23 static void drawCDKViewerInfo (CDKVIEWER *viewer);
24
25 /*
26 * Declare file local variables.
27 */
28 static char * SearchPattern = 0;
29 static int SearchDirection = DOWN;
30
31 DeclareCDKObjects (VIEWER, Viewer, setCdk, Unknown);
32
33 /*
34 * This function creates a new viewer object.
35 */
36 CDKVIEWER *newCDKViewer (CDKSCREEN *cdkscreen,
37 int xplace,
38 int yplace,
39 int height,
40 int width,
41 char **buttons,
42 int buttonCount,
43 chtype buttonHighlight,
44 boolean Box,
45 boolean shadow)
46 {
47 CDKVIEWER *viewer = 0;
48 int parentWidth = getmaxx (cdkscreen->window);
49 int parentHeight = getmaxy (cdkscreen->window);
50 int boxWidth = width;
51 int boxHeight = height;
52 int xpos = xplace;
53 int ypos = yplace;
54 int buttonWidth = 0;
55 int buttonAdj = 0;
56 int buttonPos = 1;
57 int x = 0;
58
59 /* *INDENT-OFF* */
60 static const struct { int from; int to; } bindings[] = {
61 { CDK_BACKCHAR, KEY_PPAGE },
62 { 'b', KEY_PPAGE },
63 { 'B', KEY_PPAGE },
64 { CDK_FORCHAR, KEY_NPAGE },
65 { SPACE, KEY_NPAGE },
66 { 'f', KEY_NPAGE },
67 { 'F', KEY_NPAGE },
68 { '|', KEY_HOME },
69 { '$', KEY_END },
70 };
71 /* *INDENT-ON* */
72
73 if ((viewer = newCDKObject (CDKVIEWER, &my_funcs)) == 0)
74 return (0);
75
76 setCDKViewerBox (viewer, Box);
77
78 boxHeight = setWidgetDimension (parentHeight, height, 0);
79 boxWidth = setWidgetDimension (parentWidth, width, 0);
80
81 /* Rejustify the x and y positions if we need to. */
82 alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
83
84 /* Make the viewer window. */
85 viewer->win = newwin (boxHeight, boxWidth, ypos, xpos);
86 if (viewer->win == 0)
87 {
88 destroyCDKObject (viewer);
89 return (0);
90 }
91
92 /* Turn the keypad on for the viewer. */
93 keypad (viewer->win, TRUE);
94
95 /* Create the buttons. */
96 viewer->buttonCount = buttonCount;
97 if (buttonCount > 0)
98 {
99 if ((viewer->button = typeCallocN (chtype *, buttonCount + 1)) == 0
100 || (viewer->buttonLen = typeCallocN (int, buttonCount + 1)) == 0
101 || (viewer->buttonPos = typeCallocN (int, buttonCount + 1)) == 0)
102 {
103 destroyCDKObject (viewer);
104 return (0);
105 }
106 for (x=0; x < buttonCount; x++)
107 {
108 viewer->button[x] = char2Chtype (buttons[x], &viewer->buttonLen[x], &buttonAdj);
109 buttonWidth += viewer->buttonLen[x] + 1;
110 }
111 buttonAdj = (int)((boxWidth-buttonWidth)/ (buttonCount +1));
112 buttonPos = 1 + buttonAdj;
113 for (x=0; x < buttonCount; x++)
114 {
115 viewer->buttonPos[x] = buttonPos;
116 buttonPos += buttonAdj + viewer->buttonLen[x];
117 }
118 }
119
120 /* Set the rest of the variables */
121 ScreenOf (viewer) = cdkscreen;
122 viewer->parent = cdkscreen->window;
123 viewer->shadowWin = 0;
124 viewer->buttonHighlight = buttonHighlight;
125 viewer->boxHeight = boxHeight;
126 viewer->boxWidth = boxWidth - 2;
127 viewer->viewSize = height - 2;
128 ObjOf (viewer)->inputWindow = viewer->win;
129 initExitType (viewer);
130 viewer->shadow = shadow;
131 viewer->currentButton = 0;
132 viewer->currentTop = 0;
133 viewer->length = 0;
134 viewer->leftChar = 0;
135 viewer->maxLeftChar = 0;
136 viewer->maxTopLine = 0;
137 viewer->characters = 0;
138 viewer->listSize = -1;
139 viewer->showLineInfo = 1;
140 viewer->exitType = vEARLY_EXIT;
141
142 /* Do we need to create a shadow??? */
143 if (shadow)
144 {
145 viewer->shadowWin = newwin (boxHeight, boxWidth + 1, ypos + 1, xpos + 1);
146 if (viewer->shadowWin == 0)
147 {
148 destroyCDKObject (viewer);
149 return (0);
150 }
151 }
152
153 /* Setup the key bindings. */
154 for (x = 0; x < (int)SIZEOF (bindings); ++x)
155 bindCDKObject (vVIEWER, viewer, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to);
156
157 registerCDKObject (cdkscreen, vVIEWER, viewer);
158
159 return (viewer);
160 }
161
162 /*
163 * This function sets various attributes of the widget.
164 */
165 int setCDKViewer (CDKVIEWER *viewer,
166 char *title,
167 char **list,
168 int listSize,
169 chtype buttonHighlight,
170 boolean attrInterp,
171 boolean showLineInfo,
172 boolean Box)
173 {
174 setCDKViewerTitle (viewer, title);
175 setCDKViewerHighlight (viewer, buttonHighlight);
176 setCDKViewerInfoLine (viewer, showLineInfo);
177 setCDKViewerBox (viewer, Box);
178 return setCDKViewerInfo (viewer, list, listSize, attrInterp);
179 }
180
181 /*
182 * This sets the title of the viewer. (A null title is allowed.
183 * It just means that the viewer will not have a title when drawn.)
184 */
185 void setCDKViewerTitle (CDKVIEWER *viewer, char *title)
186 {
187 (void) setCdkTitle (ObjOf (viewer), title, - (viewer->boxWidth + 1));
188 viewer->titleAdj = TitleLinesOf (viewer);
189
190 /* Need to set viewer->viewSize. */
191 viewer->viewSize = viewer->boxHeight - (TitleLinesOf (viewer) + 1) - 2;
192 }
193 chtype **getCDKViewerTitle (CDKVIEWER *viewer)
194 {
195 return TitleOf (viewer);
196 }
197
198 static void setupLine (CDKVIEWER *viewer, boolean interpret, char *list, int x)
199 {
200 /* Did they ask for attribute interpretation? */
201 if (interpret)
202 {
203 viewer->list[x] = char2Chtype (list, &viewer->listLen[x], &viewer->listPos[x]);
204 viewer->listPos[x] = justifyString (viewer->boxWidth,
205 viewer->listLen[x],
206 viewer->listPos[x]);
207 }
208 else
209 {
210 int len = (int)strlen (list);
211 int pass;
212 int y;
213 chtype *t = 0;
214
215 /*
216 * We must convert tabs and other nonprinting characters. The curses
217 * library normally does this, but we are bypassing it by writing
218 * chtype's directly.
219 */
220 for (pass = 0; pass < 2; ++pass)
221 {
222 len = 0;
223 for (y = 0; list[y] != '\0'; ++y)
224 {
225 if (list[y] == '\t')
226 {
227 do
228 {
229 if (pass)
230 t[len] = ' ';
231 ++len;
232 }
233 while (len & 7);
234 }
235 else if (isprint (CharOf (list[y])))
236 {
237 if (pass)
238 t[len] = CharOf (list[y]);
239 ++len;
240 }
241 else
242 {
243 const char *s = unctrl (list[y]);
244 while (*s != 0)
245 {
246 if (pass)
247 t[len] = CharOf (*s);
248 ++len;
249 ++s;
250 }
251 }
252 }
253 if (!pass)
254 {
255 viewer->list[x] = t = typeCallocN (chtype, len + 3);
256 if (t == 0)
257 {
258 len = 0;
259 break;
260 }
261 }
262 }
263 viewer->listLen[x] = len;
264 viewer->listPos[x] = 0;
265 }
266 viewer->widestLine = MAXIMUM (viewer->widestLine, viewer->listLen[x]);
267 }
268
269 static void freeLine (CDKVIEWER *viewer, int x)
270 {
271 if (x < viewer->listSize)
272 {
273 freeChtype (viewer->list[x]);
274 viewer->list[x] = 0;
275 }
276 }
277
278 /*
279 * This function sets the contents of the viewer.
280 */
281 int setCDKViewerInfo (CDKVIEWER *viewer, char **list, int listSize, boolean interpret)
282 {
283 char filename[CDK_PATHMAX + 2];
284 int currentLine = 0;
285 int x = 0;
286 int viewerSize = listSize;
287
288 /*
289 * If the list-size is negative, count the length of the null-terminated
290 * list of strings.
291 */
292 if (listSize < 0)
293 {
294 listSize = CDKcountStrings (list);
295 }
296
297 /* compute the size of the resulting display */
298 viewerSize = listSize;
299 if (list != 0 && interpret)
300 {
301 for (x = 0; x < listSize; ++x)
302 {
303 if (list[x] == 0)
304 {
305 viewerSize = x; /* oops - caller gave the wrong length */
306 break;
307 }
308 if (checkForLink (list[x], filename) == 1)
309 {
310 char **fileContents = 0;
311 int fileLen = CDKreadFile (filename, &fileContents);
312
313 if (fileLen >= 0)
314 viewerSize += (fileLen - 1);
315 CDKfreeStrings (fileContents);
316 }
317 }
318 }
319
320 /* Clean out the old viewer info. (if there is any) */
321 viewer->inProgress = TRUE;
322 cleanCDKViewer (viewer);
323 createList (viewer, viewerSize);
324
325 /* Keep some semi-permanent info. */
326 viewer->interpret = interpret;
327
328 /* Copy the information given. */
329 for (x = currentLine = 0; x < listSize && currentLine < viewerSize; x++)
330 {
331 if (list[x] == 0)
332 {
333 viewer->list[currentLine] = 0;
334 viewer->listLen[currentLine] = 0;
335 viewer->listPos[currentLine] = 0;
336 currentLine++;
337 }
338 else
339 {
340 /* Check if we have a file link in this line. */
341 if (checkForLink (list[x], filename) == 1)
342 {
343 /* We have a link, open the file. */
344 char **fileContents = 0;
345 int fileLen = 0;
346 int fileLine = 0;
347
348 /* Open the file and put it into the viewer. */
349 fileLen = CDKreadFile (filename, &fileContents);
350 if (fileLen == -1)
351 {
352 #ifdef HAVE_START_COLOR
353 #define FOPEN_FMT "<C></16>Link Failed: Could not open the file %s"
354 #else
355 #define FOPEN_FMT "<C></K>Link Failed: Could not open the file %s"
356 #endif
357 char *temp = (char *)malloc (80 + strlen (filename));
358 sprintf (temp, FOPEN_FMT, filename);
359 setupLine (viewer, TRUE, temp, currentLine++);
360 free (temp);
361 }
362 else
363 {
364 /* For each line read, copy it into the viewer. */
365 fileLen = MINIMUM (fileLen, (viewerSize - currentLine));
366 for (fileLine = 0; fileLine < fileLen; fileLine++)
367 {
368 if (currentLine >= viewerSize)
369 break;
370 setupLine (viewer, FALSE, fileContents[fileLine], currentLine);
371 viewer->characters += viewer->listLen[currentLine];
372 currentLine++;
373 }
374 CDKfreeStrings (fileContents);
375 }
376 }
377 else if (currentLine < viewerSize)
378 {
379 setupLine (viewer, viewer->interpret, list[x], currentLine);
380 viewer->characters += viewer->listLen[currentLine];
381 currentLine++;
382 }
383 }
384 }
385
386 /*
387 * Determine how many characters we can shift to the right
388 * before all the items have been viewer off the screen.
389 */
390 if (viewer->widestLine > viewer->boxWidth)
391 {
392 viewer->maxLeftChar = (viewer->widestLine - viewer->boxWidth) + 1;
393 }
394 else
395 {
396 viewer->maxLeftChar = 0;
397 }
398
399 /* Set up the needed vars for the viewer list. */
400 viewer->inProgress = FALSE;
401 viewer->listSize = viewerSize;
402 if (viewer->listSize <= viewer->viewSize)
403 {
404 viewer->maxTopLine = 0;
405 }
406 else
407 {
408 viewer->maxTopLine = viewer->listSize - 1;
409 }
410 return viewer->listSize;
411 }
412 chtype **getCDKViewerInfo (CDKVIEWER *viewer, int *size)
413 {
414 (*size) = viewer->listSize;
415 return viewer->list;
416 }
417
418 /*
419 * This function sets the highlight type of the buttons.
420 */
421 void setCDKViewerHighlight (CDKVIEWER *viewer, chtype buttonHighlight)
422 {
423 viewer->buttonHighlight = buttonHighlight;
424 }
425 chtype getCDKViewerHighlight (CDKVIEWER *viewer)
426 {
427 return viewer->buttonHighlight;
428 }
429
430 /*
431 * This sets whether or not you want to set the viewer info line.
432 */
433 void setCDKViewerInfoLine (CDKVIEWER *viewer, boolean showLineInfo)
434 {
435 viewer->showLineInfo = showLineInfo;
436 }
437 boolean getCDKViewerInfoLine (CDKVIEWER *viewer)
438 {
439 return viewer->showLineInfo;
440 }
441
442 /*
443 * This sets the widgets box attribute.
444 */
445 void setCDKViewerBox (CDKVIEWER *viewer, boolean Box)
446 {
447 ObjOf (viewer)->box = Box;
448 ObjOf (viewer)->borderSize = Box ? 1 : 0;
449 }
450 boolean getCDKViewerBox (CDKVIEWER *viewer)
451 {
452 return ObjOf (viewer)->box;
453 }
454
455 /*
456 * This removes all the lines inside the scrolling window.
457 */
458 void cleanCDKViewer (CDKVIEWER *viewer)
459 {
460 int x;
461
462 /* Clean up the memory used ... */
463 for (x = 0; x < viewer->listSize; x++)
464 {
465 freeLine (viewer, x);
466 }
467
468 /* Reset some variables. */
469 viewer->listSize = 0;
470 viewer->maxLeftChar = 0;
471 viewer->widestLine = 0;
472 viewer->currentTop = 0;
473 viewer->maxTopLine = 0;
474
475 /* Redraw the window. */
476 drawCDKViewer (viewer, ObjOf (viewer)->box);
477 }
478
479 static void PatternNotFound (CDKVIEWER *viewer, char *pattern)
480 {
481 char *tempInfo[2];
482 char *temp = (char *)malloc (80 + strlen (pattern));
483 tempInfo[0] = temp;
484 tempInfo[1] = 0;
485 sprintf (temp, "</U/5>Pattern '%s' not found.<!U!5>", pattern);
486 popUpLabel (viewer, tempInfo);
487 free (temp);
488 }
489
490 /*
491 * This function actually controls the viewer...
492 */
493 int activateCDKViewer (CDKVIEWER *viewer, chtype *actions GCC_UNUSED)
494 {
495 char *fileInfo[10];
496 char *tempInfo[2], temp[500];
497 chtype input;
498 boolean functionKey;
499 int x, REFRESH;
500
501 /* Create the information about the file stats. */
502 sprintf (temp, "</5> </U>File Statistics<!U> <!5>");
503 fileInfo[0] = copyChar (temp);
504 sprintf (temp, "</5> <!5>");
505 fileInfo[1] = copyChar (temp);
506 sprintf (temp, "</5/R>Character Count:<!R> %-4ld <!5>", viewer->characters);
507 fileInfo[2] = copyChar (temp);
508 sprintf (temp, "</5/R>Line Count :<!R> %-4d <!5>", viewer->listSize);
509 fileInfo[3] = copyChar (temp);
510 sprintf (temp, "</5> <!5>");
511 fileInfo[4] = copyChar (temp);
512 sprintf (temp, "<C></5>Press Any Key To Continue.<!5>");
513 fileInfo[5] = copyChar (temp);
514 fileInfo[6] = 0;
515
516 tempInfo[0] = temp;
517 tempInfo[1] = 0;
518
519 /* Set the current button. */
520 viewer->currentButton = 0;
521
522 /* Draw the viewer list. */
523 drawCDKViewer (viewer, ObjOf (viewer)->box);
524
525 /* Do this until KEY_ENTER is hit. */
526 for (;;)
527 {
528 /* Reset the refresh flag. */
529 REFRESH = FALSE;
530
531 input = getchCDKObject (ObjOf (viewer), &functionKey);
532 if (!checkCDKObjectBind (vVIEWER, viewer, input))
533 {
534 switch (input)
535 {
536 case KEY_TAB:
537 if (viewer->buttonCount > 1)
538 {
539 if (viewer->currentButton == (viewer->buttonCount - 1))
540 {
541 viewer->currentButton = 0;
542 }
543 else
544 {
545 viewer->currentButton++;
546 }
547
548 /* Redraw the buttons. */
549 drawCDKViewerButtons (viewer);
550 }
551 break;
552
553 case CDK_PREV:
554 if (viewer->buttonCount > 1)
555 {
556 if (viewer->currentButton == 0)
557 {
558 viewer->currentButton = viewer->buttonCount - 1;
559 }
560 else
561 {
562 viewer->currentButton--;
563 }
564
565 /* Redraw the buttons. */
566 drawCDKViewerButtons (viewer);
567 }
568 break;
569
570 case KEY_UP:
571 if (viewer->currentTop > 0)
572 {
573 viewer->currentTop--;
574 REFRESH = TRUE;
575 }
576 else
577 {
578 Beep ();
579 }
580 break;
581
582 case KEY_DOWN:
583 if (viewer->currentTop < viewer->maxTopLine)
584 {
585 viewer->currentTop++;
586 REFRESH = TRUE;
587 }
588 else
589 {
590 Beep ();
591 }
592 break;
593
594 case KEY_RIGHT:
595 if (viewer->leftChar < viewer->maxLeftChar)
596 {
597 viewer->leftChar++;
598 REFRESH = TRUE;
599 }
600 else
601 {
602 Beep ();
603 }
604 break;
605
606 case KEY_LEFT:
607 if (viewer->leftChar > 0)
608 {
609 viewer->leftChar--;
610 REFRESH = TRUE;
611 }
612 else
613 {
614 Beep ();
615 }
616 break;
617
618 case KEY_PPAGE:
619 if (viewer->currentTop > 0)
620 {
621 if ((viewer->currentTop - (viewer->viewSize-1)) > 0)
622 {
623 viewer->currentTop = (viewer->currentTop
624 - (viewer->viewSize - 1));
625 }
626 else
627 {
628 viewer->currentTop = 0;
629 }
630 REFRESH = TRUE;
631 }
632 else
633 {
634 Beep ();
635 }
636 break;
637
638 case KEY_NPAGE:
639 if (viewer->currentTop < viewer->maxTopLine)
640 {
641 if ((viewer->currentTop + viewer->viewSize) < viewer->maxTopLine)
642 {
643 viewer->currentTop = viewer->currentTop + (viewer->viewSize - 1);
644 }
645 else
646 {
647 viewer->currentTop = viewer->maxTopLine;
648 }
649 REFRESH = TRUE;
650 }
651 else
652 {
653 Beep ();
654 }
655 break;
656
657 case KEY_HOME:
658 viewer->leftChar = 0;
659 REFRESH = TRUE;
660 break;
661
662 case KEY_END:
663 viewer->leftChar = viewer->maxLeftChar;
664 REFRESH = TRUE;
665 break;
666
667 case 'g':
668 case '1':
669 case '<':
670 viewer->currentTop = 0;
671 REFRESH = TRUE;
672 break;
673
674 case 'G':
675 case '>':
676 viewer->currentTop = viewer->maxTopLine;
677 REFRESH = TRUE;
678 break;
679
680 case 'L':
681 x = (int)((viewer->listSize + viewer->currentTop) / 2);
682 if (x < viewer->maxTopLine)
683 {
684 viewer->currentTop = x;
685 REFRESH = TRUE;
686 }
687 else
688 {
689 Beep ();
690 }
691 break;
692
693 case 'l':
694 x = (int)(viewer->currentTop / 2);
695 if (x >= 0)
696 {
697 viewer->currentTop = x;
698 REFRESH = TRUE;
699 }
700 else
701 {
702 Beep ();
703 }
704 break;
705
706 case '?':
707 SearchDirection = UP;
708 getAndStorePattern (ScreenOf (viewer));
709 if (!searchForWord (viewer, SearchPattern, SearchDirection))
710 {
711 PatternNotFound (viewer, SearchPattern);
712 }
713 REFRESH = TRUE;
714 break;
715
716 case '/':
717 SearchDirection = DOWN;
718 getAndStorePattern (ScreenOf (viewer));
719 if (! searchForWord (viewer, SearchPattern, SearchDirection))
720 {
721 PatternNotFound (viewer, SearchPattern);
722 }
723 REFRESH = TRUE;
724 break;
725
726 case 'N':
727 case 'n':
728 if (SearchPattern == 0)
729 {
730 sprintf (temp, "</5>There is no pattern in the buffer.<!5>");
731 popUpLabel (viewer, tempInfo);
732 }
733 else if (!searchForWord (viewer,
734 SearchPattern,
735 ((input == 'n')
736 ? SearchDirection
737 : !SearchDirection)))
738 {
739 PatternNotFound (viewer, SearchPattern);
740 }
741 REFRESH = TRUE;
742 break;
743
744 case ':':
745 viewer->currentTop = jumpToLine (viewer);
746 REFRESH = TRUE;
747 break;
748
749 case 'i':
750 case 's':
751 case 'S':
752 popUpLabel (viewer, fileInfo);
753 REFRESH = TRUE;
754 break;
755
756 case KEY_ESC:
757 freeCharList (fileInfo, 6);
758 setExitType (viewer, input);
759 return -1;
760
761 case KEY_ENTER:
762 freeCharList (fileInfo, 6);
763 setExitType (viewer, input);
764 return viewer->currentButton;
765
766 case CDK_REFRESH:
767 eraseCDKScreen (ScreenOf (viewer));
768 refreshCDKScreen (ScreenOf (viewer));
769 break;
770
771 default:
772 Beep ();
773 break;
774 }
775 }
776
777 /* Do we need to redraw the screen??? */
778 if (REFRESH)
779 {
780 drawCDKViewerInfo (viewer);
781 }
782 }
783 }
784
785 /*
786 * This searches the document looking for the given word.
787 */
788 static void getAndStorePattern (CDKSCREEN *screen)
789 {
790 CDKENTRY *getPattern = 0;
791 char *temp = 0;
792 char *list = 0;
793
794 /* Check the direction. */
795 if (SearchDirection == UP)
796 {
797 temp = "</5>Search Up : <!5>";
798 }
799 else
800 {
801 temp = "</5>Search Down: <!5>";
802 }
803
804 /* Pop up the entry field. */
805 getPattern = newCDKEntry (screen, CENTER, CENTER,
806 0, temp,
807 COLOR_PAIR (5)|A_BOLD,
808 '.'|COLOR_PAIR (5)|A_BOLD,
809 vMIXED, 10, 0, 256, TRUE, FALSE);
810
811 /* Is there an old search pattern? */
812 if (SearchPattern != 0)
813 {
814 setCDKEntry (getPattern, SearchPattern, getPattern->min, getPattern->max, ObjOf (getPattern)->box);
815 }
816 freeChar (SearchPattern);
817
818 /* Activate this baby. */
819 list = activateCDKEntry (getPattern, 0);
820
821 /* Save the list. */
822 if ((list != 0) || (strlen (list) != 0))
823 {
824 SearchPattern = copyChar (list);
825 }
826
827 /* Clean up. */
828 destroyCDKEntry (getPattern);
829 }
830
831 /*
832 * This searches for a line containing the word and realigns the value on the
833 * screen.
834 */
835 static int searchForWord (CDKVIEWER *viewer, char *pattern, int direction)
836 {
837 int x, y, pos, len, plen;
838 int found = 0;
839
840 /* If the pattern is empty then return. */
841 if (pattern != 0 && (plen = strlen (pattern)) != 0)
842 {
843 if (direction == DOWN)
844 {
845 /* Start looking from 'here' down. */
846 for (x = viewer->currentTop + 1; !found && (x < viewer->listSize); x++)
847 {
848 len = chlen (viewer->list[x]);
849 for (y = pos = 0; y < len; y++)
850 {
851 int plainChar = CharOf (viewer->list[x][y]);
852
853 if (CharOf (pattern[pos]) != plainChar)
854 {
855 y -= pos;
856 pos = 0;
857 }
858 else if (++pos == plen)
859 {
860 viewer->currentTop = (x < viewer->maxTopLine ? x : viewer->maxTopLine);
861 viewer->leftChar = (y < viewer->boxWidth ? 0 : viewer->maxLeftChar);
862 found = 1;
863 break;
864 }
865
866 }
867 }
868 }
869 else
870 {
871 /* Start looking from 'here' up. */
872 for (x = viewer->currentTop - 1; !found && (x >= 0); x--)
873 {
874 len = chlen (viewer->list[x]);
875 for (y = pos = 0; y < len; y++)
876 {
877 int plainChar = CharOf (viewer->list[x][y]);
878
879 if (CharOf (pattern[pos]) != plainChar)
880 {
881 y -= pos;
882 pos = 0;
883 }
884 else if (++pos == plen)
885 {
886 viewer->currentTop = x;
887 viewer->leftChar = (y < viewer->boxWidth ? 0 : viewer->maxLeftChar);
888 found = 1;
889 break;
890 }
891
892 }
893 }
894 }
895 }
896 return (found);
897 }
898
899 /*
900 * This allows us to 'jump' to a given line in the file.
901 */
902 static int jumpToLine (CDKVIEWER *viewer)
903 {
904 int line = 0;
905 CDKSCALE * newline = newCDKScale (ScreenOf (viewer), CENTER, CENTER,
906 "<C>Jump To Line", "</5>Line :", A_BOLD,
907 intlen (viewer->listSize) + 1,
908 viewer->currentTop + 1,
909 0, viewer->maxTopLine + 1,
910 1, 10, TRUE, TRUE);
911 line = activateCDKScale (newline, 0);
912 destroyCDKScale (newline);
913 return ((line-1));
914 }
915
916 /*
917 * This pops a little message up on the screen.
918 */
919 static void popUpLabel (CDKVIEWER *viewer, char **mesg)
920 {
921 CDKLABEL *label;
922 boolean functionKey;
923
924 /* Set up variables. */
925 label = newCDKLabel (ScreenOf (viewer), CENTER, CENTER, mesg, CDKcountStrings (mesg), TRUE, FALSE);
926
927 /* Draw the label and wait. */
928 drawCDKLabel (label, TRUE);
929 getchCDKObject (ObjOf (label), &functionKey);
930
931 /* Clean up. */
932 destroyCDKLabel (label);
933 }
934
935 /*
936 * This moves the viewer field to the given location.
937 */
938 static void _moveCDKViewer (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag)
939 {
940 CDKVIEWER *viewer = (CDKVIEWER *)object;
941 int currentX = getbegx (viewer->win);
942 int currentY = getbegy (viewer->win);
943 int xpos = xplace;
944 int ypos = yplace;
945 int xdiff = 0;
946 int ydiff = 0;
947
948 /*
949 * If this is a relative move, then we will adjust where we want
950 * to move to.
951 */
952 if (relative)
953 {
954 xpos = getbegx (viewer->win) + xplace;
955 ypos = getbegy (viewer->win) + yplace;
956 }
957
958 /* Adjust the window if we need to. */
959 alignxy (WindowOf (viewer), &xpos, &ypos, viewer->boxWidth, viewer->boxHeight);
960
961 /* Get the difference. */
962 xdiff = currentX - xpos;
963 ydiff = currentY - ypos;
964
965 /* Move the window to the new location. */
966 moveCursesWindow (viewer->win, -xdiff, -ydiff);
967 moveCursesWindow (viewer->shadowWin, -xdiff, -ydiff);
968
969 /* Touch the windows so they 'move'. */
970 refreshCDKWindow (WindowOf (viewer));
971
972 /* Redraw the window, if they asked for it. */
973 if (refresh_flag)
974 {
975 drawCDKViewer (viewer, ObjOf (viewer)->box);
976 }
977 }
978
979 /*
980 * This function draws the viewer widget.
981 */
982 static void _drawCDKViewer (CDKOBJS *object, boolean Box)
983 {
984 CDKVIEWER *viewer = (CDKVIEWER *)object;
985
986 /* Do we need to draw in the shadow??? */
987 if (viewer->shadowWin != 0)
988 {
989 drawShadow (viewer->shadowWin);
990 }
991
992 /* Box it if it was asked for. */
993 if (Box)
994 {
995 drawObjBox (viewer->win, ObjOf (viewer));
996 wrefresh (viewer->win);
997 }
998
999 /* Draw the info in the viewer. */
1000 drawCDKViewerInfo (viewer);
1001 }
1002
1003 /*
1004 * This redraws the viewer buttons.
1005 */
1006 static void drawCDKViewerButtons (CDKVIEWER *viewer)
1007 {
1008 chtype character;
1009 int x;
1010
1011 /* No buttons, no drawing. */
1012 if (viewer->buttonCount == 0)
1013 {
1014 return;
1015 }
1016
1017 /* Redraw the buttons. */
1018 for (x = 0; x < viewer->buttonCount; x++)
1019 {
1020 writeChtype (viewer->win,
1021 viewer->buttonPos[x],
1022 viewer->boxHeight - 2,
1023 viewer->button[x],
1024 HORIZONTAL,
1025 0,
1026 viewer->buttonLen[x]);
1027 }
1028
1029 /* Highlight the current button. */
1030 for (x=0; x < viewer->buttonLen[viewer->currentButton]; x++)
1031 {
1032 /* Strip the character of any extra attributes. */
1033 character = CharOf (viewer->button[viewer->currentButton][x]);
1034
1035 /* Add the character into the window. */
1036 mvwaddch (viewer->win,
1037 viewer->boxHeight - 2,
1038 viewer->buttonPos[viewer->currentButton] + x,
1039 character | viewer->buttonHighlight);
1040 }
1041
1042 /* Refresh the window. */
1043 wrefresh (viewer->win);
1044 }
1045
1046 /*
1047 * This sets the background attribute of the widget.
1048 */
1049 static void _setBKattrViewer (CDKOBJS *object, chtype attrib)
1050 {
1051 if (object != 0)
1052 {
1053 CDKVIEWER *widget = (CDKVIEWER *)object;
1054
1055 wbkgd (widget->win, attrib);
1056 }
1057 }
1058
1059 /*
1060 * Free any storage associated with the info-list.
1061 */
1062 static void destroyInfo (CDKVIEWER *viewer)
1063 {
1064 CDKfreeChtypes (viewer->list);
1065 freeChecked (viewer->listPos);
1066 freeChecked (viewer->listLen);
1067
1068 viewer->list = 0;
1069 viewer->listPos = 0;
1070 viewer->listLen = 0;
1071 }
1072
1073 /*
1074 * This function destroys the viewer widget.
1075 */
1076 static void _destroyCDKViewer (CDKOBJS *object)
1077 {
1078 if (object != 0)
1079 {
1080 CDKVIEWER *viewer = (CDKVIEWER *)object;
1081
1082 destroyInfo (viewer);
1083
1084 cleanCdkTitle (object);
1085 CDKfreeChtypes (viewer->button);
1086 freeChecked (viewer->buttonLen);
1087 freeChecked (viewer->buttonPos);
1088
1089 /* Clean up the windows. */
1090 deleteCursesWindow (viewer->shadowWin);
1091 deleteCursesWindow (viewer->win);
1092
1093 /* Clean the key bindings. */
1094 cleanCDKObjectBindings (vVIEWER, viewer);
1095
1096 /* Unregister this object. */
1097 unregisterCDKObject (vVIEWER, viewer);
1098 }
1099 }
1100
1101 /*
1102 * This function erases the viewer widget from the screen.
1103 */
1104 static void _eraseCDKViewer (CDKOBJS *object)
1105 {
1106 if (validCDKObject (object))
1107 {
1108 CDKVIEWER *viewer = (CDKVIEWER *)object;
1109
1110 eraseCursesWindow (viewer->win);
1111 eraseCursesWindow (viewer->shadowWin);
1112 }
1113 }
1114
1115 /*
1116 * This draws the viewer info lines.
1117 */
1118 static void drawCDKViewerInfo (CDKVIEWER *viewer)
1119 {
1120 int listAdjust = 0;
1121 int lastLine = 0;
1122 char temp[256];
1123 int x;
1124
1125 /* Clear the window. */
1126 werase (viewer->win);
1127
1128 drawCdkTitle (viewer->win, ObjOf (viewer));
1129
1130 /* Draw in the current line at the top. */
1131 if (viewer->showLineInfo == TRUE)
1132 {
1133 /* Set up the info line and draw it. */
1134 if (viewer->inProgress)
1135 {
1136 strcpy (temp, "processing...");
1137 }
1138 else if (viewer->listSize != 0)
1139 {
1140 sprintf (temp, "%d/%d %2.0f%%",
1141 (viewer->currentTop + 1),
1142 viewer->listSize,
1143 ((float)(viewer->currentTop + 1)
1144 / (float)viewer->listSize) * 100);
1145 }
1146 else
1147 {
1148 sprintf (temp, "%d/%d %2.0f%%", 0, 0, 0.0);
1149 }
1150
1151 /*
1152 * The listAdjust variable tells us if we have to shift down one line
1153 * because the person asked for the line X of Y line at the top of the
1154 * screen. We only want to set this to 1 if they asked for the info line
1155 * and there is no title, or if the two items overlap.
1156 */
1157 if (TitleLinesOf (viewer) == 0
1158 || TitlePosOf (viewer)[0] < ((int)strlen (temp) + 2))
1159 {
1160 listAdjust = 1;
1161 }
1162 writeChar (viewer->win, 1, (listAdjust ? TitleLinesOf (viewer) : 0) + 1,
1163 temp, HORIZONTAL, 0, (int)strlen (temp));
1164 }
1165
1166 /* Determine the last line to draw. */
1167 lastLine = ((viewer->listSize <= viewer->viewSize)
1168 ? viewer->listSize
1169 : viewer->viewSize);
1170 lastLine -= listAdjust;
1171
1172 /* Redraw the list. */
1173 for (x = 0; x < lastLine; x++)
1174 {
1175 if (viewer->currentTop + x < viewer->listSize)
1176 {
1177 int screenPos = viewer->listPos[viewer->currentTop + x] + 1 - viewer->leftChar;
1178
1179 writeChtype (viewer->win,
1180 ((screenPos >= 0)
1181 ? screenPos
1182 : 1),
1183 x + TitleLinesOf (viewer) + listAdjust + 1,
1184 viewer->list[x + viewer->currentTop],
1185 HORIZONTAL,
1186 ((screenPos >= 0)
1187 ? 0
1188 : (viewer->leftChar
1189 - viewer->listPos[viewer->currentTop + x])),
1190 viewer->listLen[x + viewer->currentTop]);
1191 }
1192 }
1193
1194 /* Box it if we have to. */
1195 if (ObjOf (viewer)->box)
1196 {
1197 drawObjBox (viewer->win, ObjOf (viewer));
1198 wrefresh (viewer->win);
1199 }
1200
1201 /* Draw the separation line. */
1202 if (viewer->buttonCount > 0)
1203 {
1204 chtype boxattr = BXAttrOf (viewer);
1205
1206 for (x=1; x <= viewer->boxWidth; x++)
1207 {
1208 mvwaddch (viewer->win, viewer->boxHeight-3, x,
1209 HZCharOf (viewer) | boxattr);
1210 }
1211 mvwaddch (viewer->win, viewer->boxHeight-3, 0,
1212 ACS_LTEE | boxattr);
1213 mvwaddch (viewer->win, viewer->boxHeight-3,
1214 getmaxx (viewer->win) - 1,
1215 ACS_RTEE | boxattr);
1216 }
1217
1218 /* Draw the buttons. This will call refresh on the viewer win. */
1219 drawCDKViewerButtons (viewer);
1220 }
1221
1222 /*
1223 * The listSize may be negative, to assign no definite limit.
1224 */
1225 static int createList (CDKVIEWER *swindow, int listSize)
1226 {
1227 int status = 0;
1228 if (listSize <= 0)
1229 {
1230 destroyInfo (swindow);
1231 }
1232 else
1233 {
1234 chtype **newList = typeCallocN (chtype *, listSize + 1);
1235 int *newPos = typeCallocN (int, listSize + 1);
1236 int *newLen = typeCallocN (int, listSize + 1);
1237
1238 if (newList != 0
1239 && newPos != 0
1240 && newLen != 0)
1241 {
1242 status = 1;
1243 destroyInfo (swindow);
1244
1245 swindow->list = newList;
1246 swindow->listPos = newPos;
1247 swindow->listLen = newLen;
1248 }
1249 if (!status)
1250 {
1251 CDKfreeChtypes (newList);
1252 freeChecked (newPos);
1253 freeChecked (newLen);
1254 }
1255 }
1256 return status;
1257 }
1258
1259 dummyInject (Viewer)
1260
1261 dummyFocus (Viewer)
1262
1263 dummyUnfocus (Viewer)
1264
1265 dummyRefreshData (Viewer)
1266
1267 dummySaveData (Viewer)