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 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
|
# include "appFrameConfig.h"
# include <stdlib.h>
# include <stdio.h>
# include "appFrame.h"
# include "appSystem.h"
# include <appGeoString.h>
# ifdef USE_MOTIF
# include <Xm/DrawingA.h>
# include <appDebugon.h>
/************************************************************************/
/* */
/* Send an expose after a resize. */
/* */
/************************************************************************/
static void appGuiSendExposeForResize( APP_WIDGET w,
void * through,
void * voidcbs )
{
if ( XtIsRealized( w ) )
{
XClearArea( XtDisplay( w ), XtWindow( w ), 0, 0, 0, 0, True );
}
}
/************************************************************************/
/* */
/* Display the popup that belongs to this drawn popdown. */
/* */
/************************************************************************/
static APP_EVENT_HANDLER_H( appDrawnPulldownPulldown, w, voidadp, mouseEvent )
{
AppDrawnPulldown * adp= (AppDrawnPulldown *)voidadp;
Position inplaceX= 0;
Position inplaceY= 0;
Position screenX;
Position screenY;
int mouseX;
int mouseY;
int button;
int upDown;
int seq;
unsigned int keyState= 0;
Arg al[20];
int ac= 0;
if ( mouseEvent->xbutton.button != Button1 )
{ return; }
/******/
if ( appGetCoordinatesFromMouseButtonEvent( &mouseX, &mouseY,
&button, &upDown, &seq, &keyState,
w, mouseEvent ) )
{ XtPopdown( w ); return; }
XtTranslateCoords( adp->adpInplaceDrawing,
mouseX, mouseY,
&screenX, &screenY );
adp->adpFirstDownTime= mouseEvent->xbutton.time;
adp->adpMouseX= screenX;
adp->adpMouseY= screenY;
/******/
XtTranslateCoords( adp->adpInplaceDrawing,
inplaceX, inplaceY,
&screenX, &screenY );
ac= 0;
XtSetArg( al[ac], XmNx, screenX ); ac++;
XtSetArg( al[ac], XmNy, screenY ); ac++;
XtSetValues( adp->adpPulldownShell, al, ac );
XtPopupSpringLoaded( adp->adpPulldownShell );
return;
}
static APP_EVENT_HANDLER_H( appDrawnPulldownMouseUpDown, w, voidadp, mouseEvent )
{
AppDrawnPulldown * adp= (AppDrawnPulldown *)voidadp;
Position screenX;
Position screenY;
Dimension wide;
Dimension high;
int mouseX;
int mouseY;
int button;
int upDown;
int seq;
unsigned int keyState= 0;
/**/
if ( appGetCoordinatesFromMouseButtonEvent( &mouseX, &mouseY,
&button, &upDown, &seq, &keyState,
w, mouseEvent ) )
{ XtPopdown( w ); return; }
XtTranslateCoords( adp->adpInplaceDrawing,
mouseX, mouseY,
&screenX, &screenY );
if ( mouseEvent->xbutton.time == adp->adpFirstDownTime )
{ return; }
if ( upDown < 0 &&
adp->adpMouseX == screenX &&
adp->adpMouseY == screenY )
{ return; }
XtVaGetValues( w,
XmNwidth, &wide,
XmNheight, &high,
NULL );
/**/
XtPopdown( w );
if ( mouseX < 0 ||
mouseY < 0 ||
mouseX >= wide ||
mouseY >= high )
{ return; }
if ( adp->adpClickHandler )
{
(*adp->adpClickHandler)( w, adp->adpThrough, mouseEvent, pRefused );
}
return;
}
/************************************************************************/
/* */
/* Finish the drawn pulldown. Attach the pulldown to the in place */
/* widget and do administration. */
/* */
/************************************************************************/
static void appFinishDrawnPulldown( AppDrawnPulldown * adp,
APP_EVENT_HANDLER_T redrawInplace,
APP_EVENT_HANDLER_T redrawPulldown,
APP_EVENT_HANDLER_T clickedPulldown,
void * through )
{
Arg al[20];
int ac= 0;
adp->adpClickHandler= clickedPulldown;
adp->adpThrough= through;
/******/
if ( redrawInplace )
{
XtAddEventHandler( adp->adpInplaceDrawing, ExposureMask,
False, redrawInplace, through );
}
XtAddCallback( adp->adpInplaceDrawing, XmNresizeCallback,
appGuiSendExposeForResize, (void *)0 );
/******/
ac= 0;
XtSetArg( al[ac], XmNmwmDecorations, 0 ); ac++;
XtSetArg( al[ac], XmNmwmFunctions, 0 ); ac++;
XtSetArg( al[ac], XmNoverrideRedirect, True ); ac++;
XtSetArg( al[ac], XmNallowShellResize, True ); ac++;
adp->adpPulldownShell= XtCreatePopupShell( WIDGET_NAME,
transientShellWidgetClass,
adp->adpInplaceDrawing, al, ac );
ac= 0;
XtSetArg( al[ac], XmNwidth, 100 ); ac++;
XtSetArg( al[ac], XmNheight, 100 ); ac++;
adp->adpPulldownDrawing= XmCreateDrawingArea(
adp->adpPulldownShell, WIDGET_NAME, al, ac );
if ( redrawPulldown )
{
XtAddEventHandler( adp->adpPulldownDrawing, ExposureMask,
False, redrawPulldown, through );
}
XtAddCallback( adp->adpPulldownDrawing, XmNresizeCallback,
appGuiSendExposeForResize, (void *)0 );
/******/
XtAddEventHandler( adp->adpPulldownShell,
ButtonReleaseMask|ButtonPressMask,
False, appDrawnPulldownMouseUpDown, (void *)adp );
XtAddEventHandler( adp->adpInplaceDrawing, ButtonPressMask,
False, appDrawnPulldownPulldown, (void *)adp );
/******/
XtManageChild( adp->adpPulldownDrawing );
return;
}
/************************************************************************/
/* */
/* Make a pulldown where the values are drawings.. Not Text. */
/* */
/************************************************************************/
void appMakeDrawnPulldownInColumn( AppDrawnPulldown * adp,
APP_EVENT_HANDLER_T redrawInplace,
APP_EVENT_HANDLER_T redrawPulldown,
APP_EVENT_HANDLER_T clickedPulldown,
APP_WIDGET column,
void * through )
{
Arg al[20];
int ac= 0;
ac= 0;
XtSetArg( al[ac], XmNtraversalOn, False ); ac++;
XtSetArg( al[ac], XmNnavigationType, XmNONE ); ac++;
XtSetArg( al[ac], XmNmarginWidth, 0 ); ac++;
XtSetArg( al[ac], XmNmarginHeight, 0 ); ac++;
adp->adpInplaceDrawing= XmCreateDrawingArea( column, WIDGET_NAME, al, ac );
XtManageChild( adp->adpInplaceDrawing );
appMotifTurnOfSashTraversal( column );
appFinishDrawnPulldown( adp,
redrawInplace, redrawPulldown, clickedPulldown, through );
return;
}
void appMakeDrawnPulldownInRow( AppDrawnPulldown * adp,
APP_EVENT_HANDLER_T redrawInplace,
APP_EVENT_HANDLER_T redrawPulldown,
APP_EVENT_HANDLER_T clickedPulldown,
APP_WIDGET row,
int column,
int colspan,
void * through )
{
Arg al[20];
int ac= 0;
ac= 0;
XtSetArg( al[ac], XmNtopAttachment, XmATTACH_FORM ); ac++;
XtSetArg( al[ac], XmNtopOffset, 0 ); ac++;
XtSetArg( al[ac], XmNbottomAttachment, XmATTACH_FORM ); ac++;
XtSetArg( al[ac], XmNbottomOffset, 0 ); ac++;
XtSetArg( al[ac], XmNleftAttachment, XmATTACH_POSITION ); ac++;
XtSetArg( al[ac], XmNleftPosition, column ); ac++;
XtSetArg( al[ac], XmNrightAttachment, XmATTACH_POSITION ); ac++;
XtSetArg( al[ac], XmNrightPosition, column+ colspan ); ac++;
XtSetArg( al[ac], XmNmarginHeight, 0 ); ac++;
XtSetArg( al[ac], XmNmarginWidth, 0 ); ac++;
XtSetArg( al[ac], XmNspacing, 0 ); ac++;
XtSetArg( al[ac], XmNentryBorder, 0 ); ac++;
XtSetArg( al[ac], XmNtraversalOn, False ); ac++;
XtSetArg( al[ac], XmNnavigationType, XmNONE ); ac++;
adp->adpInplaceDrawing= XmCreateDrawingArea( row, WIDGET_NAME, al, ac );
XtManageChild( adp->adpInplaceDrawing );
appFinishDrawnPulldown( adp,
redrawInplace, redrawPulldown, clickedPulldown, through );
return;
}
void appGuiEnableDrawnPulldown( AppDrawnPulldown * adp,
int sensitive )
{
XtSetSensitive( adp->adpInplaceDrawing, sensitive != 0 );
}
void appInitDrawnPulldown( AppDrawnPulldown * adp )
{
adp->adpPulldownShell= (APP_WIDGET)0;
adp->adpPulldownDrawing= (APP_WIDGET)0;
adp->adpInplaceDrawing= (APP_WIDGET)0;
adp->adpClickHandler= (APP_EVENT_HANDLER_T)0;
adp->adpThrough= (void *)0;
}
void appGuiSetDrawnPulldownHeight( AppDrawnPulldown * adp,
int height )
{
XtVaSetValues( adp->adpPulldownShell,
XmNheight, height,
NULL );
return;
}
void appGuiSetDrawnPulldownStrips( AppDrawnPulldown * adp,
int strips )
{
Dimension inplaceHeight;
Dimension inplaceWidth;
XtVaGetValues( adp->adpInplaceDrawing,
XmNwidth, &inplaceWidth,
XmNheight, &inplaceHeight,
NULL );
XtVaSetValues( adp->adpPulldownShell,
XmNwidth, inplaceWidth,
XmNheight, strips* inplaceHeight,
NULL );
return;
}
int appGuiDrawnPulldownGetStrip(
int * pStrip,
const AppDrawnPulldown * adp,
const APP_WIDGET w,
const APP_EVENT * mouseEvent )
{
int mouseX;
int mouseY;
int button;
int upDown;
int seq;
unsigned int keyState= 0;
Dimension inplaceHeight;
Dimension inplaceWidth;
XtVaGetValues( adp->adpInplaceDrawing,
XmNheight, &inplaceHeight,
XmNwidth, &inplaceWidth,
NULL );
if ( appGetCoordinatesFromMouseButtonEvent( &mouseX, &mouseY,
&button, &upDown, &seq, &keyState,
w, mouseEvent ) )
{ return -1; }
*pStrip= mouseY/ inplaceHeight;
return 0;
}
# endif
|