1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
|
#ifndef lint
static char SccsId[] = "%W% %G%";
#endif
/*
* Module: menuctrl.c (Menu Control)
* Purpose: Manipulate the button panel under software control
* Subroutine: touch_submenu_button() returns: void
* Subroutine: set_submenu_toggle() returns: void
* Subroutine: enable_annuli_button() returns: void
* Subroutine: enable_ortho_button() returns: void
* Subroutine: init_buttonbox_settings() returns: void
* Xlib calls: none
* Copyright: 1989 Smithsonian Astrophysical Observatory
* You may do anything you like with this file except remove
* this copyright. The Smithsonian Astrophysical Observatory
* makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without
* express or implied warranty.
* Modified: {0} Michael VanHilst initial version 26 April 1989
* {n} <who> -- <does what> -- <when>
*/
#include <stdio.h> /* define stderr, NULL */
#include <X11/Xlib.h> /* X window stuff */
#include <X11/Xutil.h> /* X window manager stuff */
#include "btnlib/buttons.h"
#include "hfiles/constant.h"
#include "hfiles/struct.h" /* declare structure types */
#include "hfiles/extern.h" /* extern main parameter structures */
extern ButtonBox MainPanel[1];
extern ButtonBox ColorPanel[1];
extern ButtonBox CursorPanel[2];
extern ButtonBox ScalePanel[1];
extern ButtonBox PanPanel[1];
extern ButtonBox EtcPanel[1];
extern ButtonBox RegionPanel[1];
extern ButtonBox CmapPanel[1];
extern ButtonBox MonoPanel[1];
/*
* Subroutine: touch_submenu_button
* Purpose: Make the button panel respond (as if the given button had been
* clicked by the mouse) to set submenu button to agree with
* current internal status
*/
void touch_submenu_button ( mode, action )
int mode;
int action;
{
int button;
GC set_gc_with_background();
/* set the forground and background for drawing buttons */
(void)set_gc_with_background(&color.gcset.menu, color.gcset.menu.background);
switch( mode ) {
case COP:
if( (button = ButtonNumber(CursorPanel[0], 1, action)) >= 0 )
(void)TouchButton(CursorPanel[0], button, 0, 0);
break;
case ROP:
if( (button = ButtonNumber(RegionPanel[0], 1, action)) >= 0 )
(void)TouchButton(RegionPanel[0], button, 0, 0);
break;
case VOP:
if( (button = ButtonNumber(ColorPanel[0], 1, action)) >= 0 )
(void)TouchButton(ColorPanel[0], button, 0, 0);
break;
case MOP:
if( (button = ButtonNumber(CmapPanel[0], 1, action)) >= 0 )
(void)TouchButton(CmapPanel[0], button, 0, 0);
break;
case BOP:
if( (button = ButtonNumber(MonoPanel[0], 1, action)) >= 0 )
(void)TouchButton(MonoPanel[0], button, 0, 0);
break;
case SOP:
if( (button = ButtonNumber(ScalePanel[0], 1, action)) >= 0 )
(void)TouchButton(ScalePanel[0], button, 0, 0);
break;
case ZOP:
if( (button = ButtonNumber(PanPanel[0], 1, action)) >= 0 )
(void)TouchButton(PanPanel[0], button, 0, 0);
break;
case EOP:
if( (button = ButtonNumber(EtcPanel[0], 1, action)) >= 0 )
(void)TouchButton(EtcPanel[0], button, 0, 0);
break;
default:
break;
}
}
/*
* Subroutine: set_submenu_toggle
* Purpose: Set submenu toggle button to agree with current status
*/
void set_submenu_toggle ( mode, action, status )
int mode;
int action;
int status;
{
int button;
GC set_gc_with_background();
/* set the forground and background for drawing buttons */
(void)set_gc_with_background(&color.gcset.menu, color.gcset.menu.background);
switch( mode ) {
case COP:
if( (button = ButtonNumber(CursorPanel[0], 1, action)) >= 0 )
(void)SetToggleButton(CursorPanel[0], button, status);
break;
case ROP:
if( (button = ButtonNumber(RegionPanel[0], 1, action)) >= 0 )
(void)SetToggleButton(RegionPanel[0], button, status);
break;
case VOP:
if( (button = ButtonNumber(ColorPanel[0], 1, action)) >= 0 )
(void)SetToggleButton(ColorPanel[0], button, status);
break;
case MOP:
if( (button = ButtonNumber(CmapPanel[0], 1, action)) >= 0 )
(void)SetToggleButton(CmapPanel[0], button, status);
break;
case BOP:
if( (button = ButtonNumber(MonoPanel[0], 1, action)) >= 0 )
(void)SetToggleButton(MonoPanel[0], button, status);
break;
case SOP:
if( (button = ButtonNumber(ScalePanel[0], 1, action)) >= 0 )
(void)SetToggleButton(ScalePanel[0], button, status);
break;
case ZOP:
if( (button = ButtonNumber(PanPanel[0], 1, action)) >= 0 )
(void)SetToggleButton(PanPanel[0], status, button);
break;
case EOP:
if( (button = ButtonNumber(EtcPanel[0], 1, action)) >= 0 )
(void)SetToggleButton(EtcPanel[0], button, status);
break;
default:
break;
}
}
/*
* Subroutine: enable_annuli_button
* Purpose: Enable and disable anuulus button depending on current cursor
*/
void enable_annuli_button ( enable )
int enable; /* i: enable vs. disable */
{
int button;
static int disabled = 0;
GC set_gc_with_background();
if( (button = ButtonNumber(CursorPanel[0], 1, COP_Annuli)) >= 0 ) {
if( enable ) {
if( disabled ) {
(void)EnableButton(CursorPanel[0], button, BTNToggle);
disabled = 0;
}
} else {
if( disabled == 0 ) {
(void)set_gc_with_background(&color.gcset.menu,
color.gcset.menu.background);
(void)SetToggleButton(CursorPanel[0], button, 0);
(void)DisableButton(CursorPanel[0], button);
disabled = 1;
}
}
}
}
/*
* Subroutine: enable_ortho_button
* Purpose: Enable and disable ortho button depending on current cursor
*/
void enable_ortho_button ( enable )
int enable; /* i: enable vs. disable */
{
int button;
static int disabled = 0;
if( (button = ButtonNumber(CursorPanel[0], 1, COP_Orthogonal)) >= 0 ) {
if( enable ) {
if( disabled ) {
(void)EnableButton(CursorPanel[0], button, BTNFlash);
disabled = 0;
}
} else {
if( disabled == 0 ) {
(void)DisableButton(CursorPanel[0], button);
disabled = 1;
}
}
}
}
/*
* Subroutine: init_buttonbox_settings
* Purpose: Set buttons to states corresponding to initial defaults
* Note: region's buttons are set from init_region
*/
void init_buttonbox_settings ( )
{
int button;
/* cursor */
touch_submenu_button (COP, cursor.type);
if( (cursor.type == COP_Polygon) || (cursor.type == COP_Point) ) {
enable_annuli_button(0);
enable_ortho_button(0);
} else if( cursor.annuli ) {
set_submenu_toggle(COP, COP_Annuli, 1);
enable_ortho_button(0);
} else if( cursor.type == COP_Circle )
enable_ortho_button(0);
/* color */
if( color.inverse )
set_submenu_toggle(VOP, VOP_Invert, 1);
if( color.halftone.inverse )
set_submenu_toggle (BOP, BOP_Invert, 1);
/* set the modes */
button = ButtonNumber(ColorPanel[0], 1, VOP_Halftone);
if( ((color.screen_depth <= 1) || (color.colormap_mode == VOP_Halftone)) &&
(button >= 0) ) {
/* halftone only?, set mono and then freeze (disable) it */
(void)SetToggleButton (ColorPanel[0], button, 1);
(void)DisableButton(ColorPanel[0], button);
} else {
/* color possible? set control mode, then set mono if chosen */
touch_submenu_button(VOP, color.control_mode);
if( color.cells.overlay )
set_submenu_toggle(VOP, VOP_Overlay, 1);
}
if( color.halftone.mode == BOP_Diffuse ) {
touch_submenu_button(BOP, BOP_Diffuse);
} else if( color.halftone.matrixID == BOP_Matrix1 ) {
touch_submenu_button(BOP, BOP_Matrix1);
} else if( color.halftone.matrixID == BOP_Matrix2 ) {
touch_submenu_button(BOP, BOP_Matrix2);
}
/* scale */
touch_submenu_button (SOP, color.scale.mode);
/* control */
if( control.magni_track )
set_submenu_toggle(EOP, EOP_Track, 1);
if( control.coord_track )
set_submenu_toggle(EOP, EOP_TextTrack, 1);
if( control.verbose )
set_submenu_toggle(EOP, EOP_Verbose, 1);
/* main menu */
if( (button = ButtonNumber(MainPanel[0], 0, control.mode)) >= 0 )
(void)TouchButton(MainPanel[0], button, 0, 0);
}
|