1
/*===========================================================================
2
Copyright (C) 1995-2009 European Southern Observatory (ESO)
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public
15
License along with this program; if not, write to the Free
16
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
19
Correspondence concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
30
/*******************************************************************************
33
*******************************************************************************/
45
/*******************************************************************************
46
Includes, Defines, and Global variables from the Declarations Editor:
47
*******************************************************************************/
49
#include <ExternResources.h>
50
#include <alice_global.h>
52
/*******************************************************************************
53
The definition of the context structure:
54
If you create multiple instances of your interface, the context
55
structure ensures that your callbacks use the variables for the
58
For each swidget in the interface, each argument to the Interface
59
function, and each variable in the Instance Specific section of the
60
Declarations Editor, there is an entry in the context structure.
61
and a #define. The #define makes the variable name refer to the
62
corresponding entry in the context structure.
63
*******************************************************************************/
67
swidget UxLabelCursor;
70
swidget UxOkLabelCursor;
71
swidget UxCancelLabel;
72
swidget UxDefaultLabel;
82
swidget UxarrowButton13;
83
swidget UxarrowButton14;
86
#define LabelCursor UxLabelCursorContext->UxLabelCursor
87
#define form10 UxLabelCursorContext->Uxform10
88
#define form11 UxLabelCursorContext->Uxform11
89
#define OkLabelCursor UxLabelCursorContext->UxOkLabelCursor
90
#define CancelLabel UxLabelCursorContext->UxCancelLabel
91
#define DefaultLabel UxLabelCursorContext->UxDefaultLabel
92
#define separator2 UxLabelCursorContext->Uxseparator2
93
#define LabelText UxLabelCursorContext->UxLabelText
94
#define label13 UxLabelCursorContext->Uxlabel13
95
#define AngleText UxLabelCursorContext->UxAngleText
96
#define SizeText UxLabelCursorContext->UxSizeText
97
#define FontText UxLabelCursorContext->UxFontText
98
#define label14 UxLabelCursorContext->Uxlabel14
99
#define label15 UxLabelCursorContext->Uxlabel15
100
#define label16 UxLabelCursorContext->Uxlabel16
101
#define arrowButton13 UxLabelCursorContext->UxarrowButton13
102
#define arrowButton14 UxLabelCursorContext->UxarrowButton14
104
static _UxCLabelCursor *UxLabelCursorContext;
106
extern void labelCursor(), putFontText(), out_error();
109
/*******************************************************************************
110
The following are translation tables.
111
*******************************************************************************/
113
static char *CursorTab = "#override\n\
114
<Key>Delete:delete-previous-character()\n\
115
<Key>BackSpace:delete-previous-character()\n\
116
<Key>osfBackSpace:delete-previous-character()\n\
117
<Key>osfDelete:delete-previous-character()\n";
119
/*******************************************************************************
120
Forward declarations of functions that are defined later in this file.
121
*******************************************************************************/
123
swidget create_LabelCursor();
125
/*******************************************************************************
126
The following are callback functions.
127
*******************************************************************************/
129
static void activateCB_OkLabelCursor( UxWidget, UxClientData, UxCallbackArg )
131
XtPointer UxClientData, UxCallbackArg;
133
_UxCLabelCursor *UxSaveCtx, *UxContext;
134
swidget UxThisWidget;
136
UxThisWidget = UxWidgetToSwidget( UxWidget );
137
UxSaveCtx = UxLabelCursorContext;
138
UxLabelCursorContext = UxContext =
139
(_UxCLabelCursor *) UxGetContext( UxThisWidget );
142
strcpy(label, UxGetText(UxFindSwidget("LabelText")));
143
labelCursor(label,plotAngle,plotSize,plotFont);
149
UxLabelCursorContext = UxSaveCtx;
152
static void activateCB_CancelLabel( UxWidget, UxClientData, UxCallbackArg )
154
XtPointer UxClientData, UxCallbackArg;
156
_UxCLabelCursor *UxSaveCtx, *UxContext;
157
swidget UxThisWidget;
159
UxThisWidget = UxWidgetToSwidget( UxWidget );
160
UxSaveCtx = UxLabelCursorContext;
161
UxLabelCursorContext = UxContext =
162
(_UxCLabelCursor *) UxGetContext( UxThisWidget );
164
UxPopdownInterface(LabelCursor);
166
UxLabelCursorContext = UxSaveCtx;
169
static void activateCB_DefaultLabel( UxWidget, UxClientData, UxCallbackArg )
171
XtPointer UxClientData, UxCallbackArg;
173
_UxCLabelCursor *UxSaveCtx, *UxContext;
174
swidget UxThisWidget;
176
UxThisWidget = UxWidgetToSwidget( UxWidget );
177
UxSaveCtx = UxLabelCursorContext;
178
UxLabelCursorContext = UxContext =
179
(_UxCLabelCursor *) UxGetContext( UxThisWidget );
184
UxPutText(UxFindSwidget("AngleText"),"0");
185
UxPutText(UxFindSwidget("SizeText"),"1.5");
186
UxPutText(UxFindSwidget("FontText"),"Standard");
187
UxPutText(UxFindSwidget("LabelText"),"");
189
UxLabelCursorContext = UxSaveCtx;
192
static void modifyVerifyCB_AngleText( UxWidget, UxClientData, UxCallbackArg )
194
XtPointer UxClientData, UxCallbackArg;
196
_UxCLabelCursor *UxSaveCtx, *UxContext;
197
swidget UxThisWidget;
199
UxThisWidget = UxWidgetToSwidget( UxWidget );
200
UxSaveCtx = UxLabelCursorContext;
201
UxLabelCursorContext = UxContext =
202
(_UxCLabelCursor *) UxGetContext( UxThisWidget );
206
UxLabelCursorContext = UxSaveCtx;
209
static void losingFocusCB_AngleText( UxWidget, UxClientData, UxCallbackArg )
211
XtPointer UxClientData, UxCallbackArg;
213
_UxCLabelCursor *UxSaveCtx, *UxContext;
214
swidget UxThisWidget;
216
UxThisWidget = UxWidgetToSwidget( UxWidget );
217
UxSaveCtx = UxLabelCursorContext;
218
UxLabelCursorContext = UxContext =
219
(_UxCLabelCursor *) UxGetContext( UxThisWidget );
224
{ plotModAngle = FALSE;
225
if(sscanf(UxGetText( UxFindSwidget("AngleText") ) ,"%f",&aux_angle)==1)
226
plotAngle = aux_angle;
229
sprintf(out,"%g",plotAngle);
230
UxPutText( UxFindSwidget("AngleText") ,out);
231
out_error("Invalid angle input");
235
UxLabelCursorContext = UxSaveCtx;
238
static void modifyVerifyCB_SizeText( UxWidget, UxClientData, UxCallbackArg )
240
XtPointer UxClientData, UxCallbackArg;
242
_UxCLabelCursor *UxSaveCtx, *UxContext;
243
swidget UxThisWidget;
245
UxThisWidget = UxWidgetToSwidget( UxWidget );
246
UxSaveCtx = UxLabelCursorContext;
247
UxLabelCursorContext = UxContext =
248
(_UxCLabelCursor *) UxGetContext( UxThisWidget );
252
UxLabelCursorContext = UxSaveCtx;
255
static void losingFocusCB_SizeText( UxWidget, UxClientData, UxCallbackArg )
257
XtPointer UxClientData, UxCallbackArg;
259
_UxCLabelCursor *UxSaveCtx, *UxContext;
260
swidget UxThisWidget;
262
UxThisWidget = UxWidgetToSwidget( UxWidget );
263
UxSaveCtx = UxLabelCursorContext;
264
UxLabelCursorContext = UxContext =
265
(_UxCLabelCursor *) UxGetContext( UxThisWidget );
270
{ plotModSize = FALSE;
271
if(sscanf(UxGetText( UxFindSwidget("SizeText" )) ,"%f",&aux_size)==1)
275
sprintf(out,"%g",plotSize);
276
UxPutText(UxFindSwidget("SizeText") ,out);
277
out_error("Invalid size input");
281
UxLabelCursorContext = UxSaveCtx;
284
static void activateCB_arrowButton13( UxWidget, UxClientData, UxCallbackArg )
286
XtPointer UxClientData, UxCallbackArg;
288
_UxCLabelCursor *UxSaveCtx, *UxContext;
289
swidget UxThisWidget;
291
UxThisWidget = UxWidgetToSwidget( UxWidget );
292
UxSaveCtx = UxLabelCursorContext;
293
UxLabelCursorContext = UxContext =
294
(_UxCLabelCursor *) UxGetContext( UxThisWidget );
300
putFontText(plotFont);
302
UxLabelCursorContext = UxSaveCtx;
305
static void activateCB_arrowButton14( UxWidget, UxClientData, UxCallbackArg )
307
XtPointer UxClientData, UxCallbackArg;
309
_UxCLabelCursor *UxSaveCtx, *UxContext;
310
swidget UxThisWidget;
312
UxThisWidget = UxWidgetToSwidget( UxWidget );
313
UxSaveCtx = UxLabelCursorContext;
314
UxLabelCursorContext = UxContext =
315
(_UxCLabelCursor *) UxGetContext( UxThisWidget );
321
putFontText(plotFont);
323
UxLabelCursorContext = UxSaveCtx;
326
/*******************************************************************************
327
The 'init_' function sets the private properties for all the
328
swidgets to the values specified in the Property Table.
329
Some properties need to be set after the X widgets have been
330
created and the setting of these properties is done in the
331
'build_' function after the UxCreateWidget call.
332
*******************************************************************************/
334
static void _Uxinit_LabelCursor()
336
UxPutIconName( LabelCursor, "Label Cursor" );
337
UxPutKeyboardFocusPolicy( LabelCursor, "pointer" );
338
UxPutHeight( LabelCursor, 148 );
339
UxPutWidth( LabelCursor, 384 );
340
UxPutY( LabelCursor, 448 );
341
UxPutX( LabelCursor, 533 );
343
UxPutBackground( form10, WindowBackground );
344
UxPutHeight( form10, 98 );
345
UxPutWidth( form10, 182 );
346
UxPutY( form10, 16 );
347
UxPutX( form10, 52 );
348
UxPutUnitType( form10, "pixels" );
349
UxPutResizePolicy( form10, "resize_none" );
351
UxPutBackground( form11, ButtonBackground );
352
UxPutHeight( form11, 52 );
353
UxPutWidth( form11, 386 );
354
UxPutY( form11, 96 );
356
UxPutResizePolicy( form11, "resize_none" );
358
UxPutHighlightColor( OkLabelCursor, "Black" );
359
UxPutHighlightOnEnter( OkLabelCursor, "true" );
360
UxPutLabelString( OkLabelCursor, "Ok" );
361
UxPutForeground( OkLabelCursor, ButtonForeground );
362
UxPutFontList( OkLabelCursor, BoldTextFont );
363
UxPutBackground( OkLabelCursor, ButtonBackground );
364
UxPutHeight( OkLabelCursor, 30 );
365
UxPutWidth( OkLabelCursor, 90 );
366
UxPutY( OkLabelCursor, 12 );
367
UxPutX( OkLabelCursor, 132 );
369
UxPutHighlightColor( CancelLabel, "Black" );
370
UxPutHighlightOnEnter( CancelLabel, "true" );
371
UxPutLabelString( CancelLabel, "Cancel" );
372
UxPutForeground( CancelLabel, CancelForeground );
373
UxPutFontList( CancelLabel, BoldTextFont );
374
UxPutBackground( CancelLabel, ButtonBackground );
375
UxPutHeight( CancelLabel, 30 );
376
UxPutWidth( CancelLabel, 90 );
377
UxPutY( CancelLabel, 12 );
378
UxPutX( CancelLabel, 240 );
380
UxPutHighlightColor( DefaultLabel, "Black" );
381
UxPutHighlightOnEnter( DefaultLabel, "true" );
382
UxPutLabelString( DefaultLabel, "Default" );
383
UxPutForeground( DefaultLabel, ButtonForeground );
384
UxPutFontList( DefaultLabel, BoldTextFont );
385
UxPutBackground( DefaultLabel, ButtonBackground );
386
UxPutHeight( DefaultLabel, 30 );
387
UxPutWidth( DefaultLabel, 90 );
388
UxPutY( DefaultLabel, 12 );
389
UxPutX( DefaultLabel, 24 );
391
UxPutBackground( separator2, ButtonBackground );
392
UxPutHeight( separator2, 6 );
393
UxPutWidth( separator2, 386 );
394
UxPutY( separator2, 90 );
395
UxPutX( separator2, -2 );
397
UxPutMarginHeight( LabelText, 3 );
398
UxPutHighlightColor( LabelText, "Black" );
399
UxPutForeground( LabelText, TextForeground );
400
UxPutTranslations( LabelText, CursorTab );
401
UxPutFontList( LabelText, TextFont );
402
UxPutHighlightOnEnter( LabelText, "true" );
403
UxPutMaxLength( LabelText, 240 );
404
UxPutBackground( LabelText, TextBackground );
405
UxPutHeight( LabelText, 32 );
406
UxPutWidth( LabelText, 316 );
407
UxPutY( LabelText, 6 );
408
UxPutX( LabelText, 60 );
410
UxPutHighlightColor( label13, "Black" );
411
UxPutForeground( label13, TextForeground );
412
UxPutFontList( label13, TextFont );
413
UxPutLabelString( label13, "Text :" );
414
UxPutBackground( label13, LabelBackground );
415
UxPutHeight( label13, 30 );
416
UxPutWidth( label13, 52 );
417
UxPutY( label13, 8 );
418
UxPutX( label13, 6 );
420
UxPutMarginHeight( AngleText, 3 );
421
UxPutHighlightColor( AngleText, "Black" );
422
UxPutForeground( AngleText, TextForeground );
423
UxPutTranslations( AngleText, CursorTab );
424
UxPutFontList( AngleText, TextFont );
425
UxPutHighlightOnEnter( AngleText, "true" );
426
UxPutMaxLength( AngleText, 40 );
427
UxPutBackground( AngleText, TextBackground );
428
UxPutHeight( AngleText, 32 );
429
UxPutWidth( AngleText, 42 );
430
UxPutY( AngleText, 50 );
431
UxPutX( AngleText, 68 );
433
UxPutMarginHeight( SizeText, 3 );
434
UxPutHighlightColor( SizeText, "Black" );
435
UxPutForeground( SizeText, TextForeground );
436
UxPutTranslations( SizeText, CursorTab );
437
UxPutFontList( SizeText, TextFont );
438
UxPutHighlightOnEnter( SizeText, "true" );
439
UxPutMaxLength( SizeText, 40 );
440
UxPutBackground( SizeText, TextBackground );
441
UxPutHeight( SizeText, 32 );
442
UxPutWidth( SizeText, 42 );
443
UxPutY( SizeText, 50 );
444
UxPutX( SizeText, 170 );
446
UxPutMarginWidth( FontText, 3 );
447
UxPutMarginHeight( FontText, 3 );
448
UxPutHighlightColor( FontText, "Black" );
449
UxPutForeground( FontText, TextForeground );
450
UxPutCursorPositionVisible( FontText, "false" );
451
UxPutFontList( FontText, TextFont );
452
UxPutHighlightOnEnter( FontText, "true" );
453
UxPutColumns( FontText, 12 );
454
UxPutMaxLength( FontText, 20 );
455
UxPutEditable( FontText, "false" );
456
UxPutBackground( FontText, TextBackground );
457
UxPutHeight( FontText, 32 );
458
UxPutWidth( FontText, 94 );
459
UxPutY( FontText, 50 );
460
UxPutX( FontText, 254 );
462
UxPutHighlightColor( label14, "Black" );
463
UxPutForeground( label14, TextForeground );
464
UxPutFontList( label14, TextFont );
465
UxPutLabelString( label14, "Angle :" );
466
UxPutBackground( label14, LabelBackground );
467
UxPutHeight( label14, 30 );
468
UxPutWidth( label14, 58 );
469
UxPutY( label14, 50 );
470
UxPutX( label14, 10 );
472
UxPutHighlightColor( label15, "Black" );
473
UxPutForeground( label15, TextForeground );
474
UxPutFontList( label15, TextFont );
475
UxPutLabelString( label15, "Size :" );
476
UxPutBackground( label15, LabelBackground );
477
UxPutHeight( label15, 30 );
478
UxPutWidth( label15, 58 );
479
UxPutY( label15, 50 );
480
UxPutX( label15, 110 );
482
UxPutHighlightColor( label16, "Black" );
483
UxPutForeground( label16, TextForeground );
484
UxPutFontList( label16, TextFont );
485
UxPutLabelString( label16, "Font :" );
486
UxPutBackground( label16, LabelBackground );
487
UxPutHeight( label16, 30 );
488
UxPutWidth( label16, 40 );
489
UxPutY( label16, 50 );
490
UxPutX( label16, 214 );
492
UxPutBackground( arrowButton13, TextBackground );
493
UxPutHighlightOnEnter( arrowButton13, "true" );
494
UxPutForeground( arrowButton13, MenuBackground );
495
UxPutHeight( arrowButton13, 20 );
496
UxPutWidth( arrowButton13, 30 );
497
UxPutY( arrowButton13, 48 );
498
UxPutX( arrowButton13, 346 );
500
UxPutBackground( arrowButton14, TextBackground );
501
UxPutHighlightOnEnter( arrowButton14, "true" );
502
UxPutForeground( arrowButton14, MenuBackground );
503
UxPutArrowDirection( arrowButton14, "arrow_down" );
504
UxPutHeight( arrowButton14, 20 );
505
UxPutWidth( arrowButton14, 30 );
506
UxPutY( arrowButton14, 66 );
507
UxPutX( arrowButton14, 346 );
511
/*******************************************************************************
512
The 'build_' function creates all the swidgets and X widgets,
513
and sets their properties to the values specified in the
515
*******************************************************************************/
517
static swidget _Uxbuild_LabelCursor()
519
/* Create the swidgets */
521
LabelCursor = UxCreateTopLevelShell( "LabelCursor", NO_PARENT );
522
UxPutContext( LabelCursor, UxLabelCursorContext );
524
form10 = UxCreateForm( "form10", LabelCursor );
525
form11 = UxCreateForm( "form11", form10 );
526
OkLabelCursor = UxCreatePushButton( "OkLabelCursor", form11 );
527
CancelLabel = UxCreatePushButton( "CancelLabel", form11 );
528
DefaultLabel = UxCreatePushButton( "DefaultLabel", form11 );
529
separator2 = UxCreateSeparator( "separator2", form10 );
530
LabelText = UxCreateText( "LabelText", form10 );
531
label13 = UxCreateLabel( "label13", form10 );
532
AngleText = UxCreateText( "AngleText", form10 );
533
SizeText = UxCreateText( "SizeText", form10 );
534
FontText = UxCreateText( "FontText", form10 );
535
label14 = UxCreateLabel( "label14", form10 );
536
label15 = UxCreateLabel( "label15", form10 );
537
label16 = UxCreateLabel( "label16", form10 );
538
arrowButton13 = UxCreateArrowButton( "arrowButton13", form10 );
539
arrowButton14 = UxCreateArrowButton( "arrowButton14", form10 );
541
_Uxinit_LabelCursor();
543
/* Create the X widgets */
545
UxCreateWidget( LabelCursor );
546
UxCreateWidget( form10 );
547
UxCreateWidget( form11 );
548
UxCreateWidget( OkLabelCursor );
549
UxCreateWidget( CancelLabel );
550
UxCreateWidget( DefaultLabel );
551
UxCreateWidget( separator2 );
552
UxCreateWidget( LabelText );
553
UxCreateWidget( label13 );
554
UxCreateWidget( AngleText );
555
UxCreateWidget( SizeText );
556
UxCreateWidget( FontText );
557
UxCreateWidget( label14 );
558
UxCreateWidget( label15 );
559
UxCreateWidget( label16 );
560
UxCreateWidget( arrowButton13 );
561
UxCreateWidget( arrowButton14 );
563
UxAddCallback( OkLabelCursor, XmNactivateCallback,
564
activateCB_OkLabelCursor,
565
(XtPointer) UxLabelCursorContext );
567
UxAddCallback( CancelLabel, XmNactivateCallback,
568
activateCB_CancelLabel,
569
(XtPointer) UxLabelCursorContext );
571
UxAddCallback( DefaultLabel, XmNactivateCallback,
572
activateCB_DefaultLabel,
573
(XtPointer) UxLabelCursorContext );
575
UxAddCallback( AngleText, XmNmodifyVerifyCallback,
576
modifyVerifyCB_AngleText,
577
(XtPointer) UxLabelCursorContext );
578
UxAddCallback( AngleText, XmNlosingFocusCallback,
579
losingFocusCB_AngleText,
580
(XtPointer) UxLabelCursorContext );
582
UxAddCallback( SizeText, XmNmodifyVerifyCallback,
583
modifyVerifyCB_SizeText,
584
(XtPointer) UxLabelCursorContext );
585
UxAddCallback( SizeText, XmNlosingFocusCallback,
586
losingFocusCB_SizeText,
587
(XtPointer) UxLabelCursorContext );
589
UxAddCallback( arrowButton13, XmNactivateCallback,
590
activateCB_arrowButton13,
591
(XtPointer) UxLabelCursorContext );
593
UxAddCallback( arrowButton14, XmNactivateCallback,
594
activateCB_arrowButton14,
595
(XtPointer) UxLabelCursorContext );
598
/* Finally, call UxRealizeInterface to create the X windows
599
for the widgets created above. */
601
UxRealizeInterface( LabelCursor );
603
return ( LabelCursor );
606
/*******************************************************************************
607
The following function includes the code that was entered
608
in the 'Initial Code' and 'Final Code' sections of the
609
Declarations Editor. This function is called from the
610
'Interface function' below.
611
*******************************************************************************/
613
static swidget _Ux_create_LabelCursor()
616
_UxCLabelCursor *UxContext;
618
UxLabelCursorContext = UxContext =
619
(_UxCLabelCursor *) UxMalloc( sizeof(_UxCLabelCursor) );
621
rtrn = _Uxbuild_LabelCursor();
626
/*******************************************************************************
627
The following is the 'Interface function' which is the
628
external entry point for creating this interface.
629
This function should be called from your application or from
631
*******************************************************************************/
633
swidget create_LabelCursor()
637
_Uxrtrn = _Ux_create_LabelCursor();
642
/*******************************************************************************
644
*******************************************************************************/