/***************************************************************************** # Copyright (C) 1994-2008 by David Gordon. # All rights reserved. # # This software is part of a beta-test version of the Consed/Autofinish # package. It should not be redistributed or # used for any commercial purpose, including commercially funded # sequencing, without written permission from the author and the # University of Washington. # # This software is provided ``AS IS'' and any express or implied # warranties, including, but not limited to, the implied warranties of # merchantability and fitness for a particular purpose, are disclaimed. # In no event shall the authors or the University of Washington be # liable for any direct, indirect, incidental, special, exemplary, or # consequential damages (including, but not limited to, procurement of # substitute goods or services; loss of use, data, or profits; or # business interruption) however caused and on any theory of liability, # whether in contract, strict liability, or tort (including negligence # or otherwise) arising in any way out of the use of this software, even # if advised of the possibility of such damage. # # Building Consed from source is error prone and not simple which is # why I provide executables. Due to time limitations I cannot # provide any assistance in building Consed. Even if you do not # modify the source, you may introduce errors due to using a # different version of the compiler, a different version of motif, # different versions of other libraries than I used, etc. For this # reason, if you discover Consed bugs, I can only offer help with # those bugs if you first reproduce those bugs with an executable # provided by me--not an executable you have built. # # Modifying Consed is also difficult. Although Consed is modular, # some modules are used by many other modules. Thus making a change # in one place can have unforeseen effects on many other features. # It may takes months for you to notice these other side-effects # which may not seen connected at all. It is not feasable for me to # provide help with modifying Consed sources because of the # potentially huge amount of time involved. # #*****************************************************************************/ #include "guiWhatToDoWithSelection.h" #include "whatToDoWithSelectionTypes.h" #include "guiapp.h" #include #include #include #include "assert.h" #include "handleWindowManagerDelete.h" #include #include guiWhatToDoWithSelection :: guiWhatToDoWithSelection() {} void guiWhatToDoWithSelection :: popupAndGetAnswer( etypeWhatToDoWithSelection& eWhatToDoWithSelection, RWCString& soTagComment ) { Arg aArg[100]; int nArgs; XmStringTable xmStringList; int n; widPopupShell_ = XtVaCreatePopupShell("What to Do with Selection", topLevelShellWidgetClass, GuiApp::pGetGuiApp()->widGetTopLevel(), XmNdeleteResponse, XmDO_NOTHING, XmNmwmDecorations, MWM_DECOR_ALL | MWM_DECOR_MENU | MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE, NULL ); handleWindowManagerDelete( widPopupShell_ ); // the immediate child of the application shell is a // main window Widget widMainWin = XtVaCreateManagedWidget("mainwin", xmMainWindowWidgetClass, widPopupShell_, XmNancestorSensitive, True, NULL ); // // create the form widget // nArgs = 0; XtSetArg(aArg[nArgs],XmNshadowThickness,0); nArgs++; XtSetArg(aArg[nArgs],XmNborderWidth,0); nArgs++; Widget widForm = XmCreateForm(widMainWin, "form", aArg, nArgs); XtManageChild(widForm); XmString xmsWarningMessage = XmStringCreateLtoR( "YOU MUST RESPOND TO THIS\nBEFORE DOING ANYTHING ELSE", XmFONTLIST_DEFAULT_TAG ); Widget widWarningLabel = XtVaCreateManagedWidget( "label", xmLabelWidgetClass, widForm, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNlabelString, xmsWarningMessage, XmNalignment, XmALIGNMENT_CENTER, NULL ); XmStringFree( xmsWarningMessage ); Widget widMakeHighQuality = XtVaCreateManagedWidget( "Make High Quality", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widWarningLabel, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 40, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNleftOffset, 40, XmNrightOffset, 40, NULL ); XtAddCallback(widMakeHighQuality, XmNactivateCallback, (XtCallbackProc )cbGuiWhatToDoWithSelection, this); Widget widMakeHighQualityAndChangeConsensus = XtVaCreateManagedWidget( "Change Consensus", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widMakeHighQuality, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 40, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNleftOffset, 40, XmNrightOffset, 40, NULL ); XtAddCallback(widMakeHighQualityAndChangeConsensus, XmNactivateCallback, (XtCallbackProc )cbGuiWhatToDoWithSelection, this); Widget widMakeLowQuality = XtVaCreateManagedWidget( "Make low quality", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widMakeHighQualityAndChangeConsensus, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 40, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNleftOffset, 40, XmNrightOffset, 40, NULL ); XtAddCallback(widMakeLowQuality, XmNactivateCallback, (XtCallbackProc )cbGuiWhatToDoWithSelection, this); Widget widMakeLowQualityToLeft = XtVaCreateManagedWidget( "Make Low Quality to Left End", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widMakeLowQuality, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 40, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNleftOffset, 40, XmNrightOffset, 40, NULL ); XtAddCallback(widMakeLowQualityToLeft, XmNactivateCallback, (XtCallbackProc )cbGuiWhatToDoWithSelection, this); Widget widMakeLowQualityToRight = XtVaCreateManagedWidget( "Make Low Quality To Right End", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widMakeLowQualityToLeft, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 40, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNleftOffset, 40, XmNrightOffset, 40, NULL ); XtAddCallback(widMakeLowQualityToRight, XmNactivateCallback, (XtCallbackProc )cbGuiWhatToDoWithSelection, this); Widget widChangeToNs = XtVaCreateManagedWidget( "Change to n's", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widMakeLowQualityToRight, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 40, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNleftOffset, 40, XmNrightOffset, 40, NULL ); XtAddCallback(widChangeToNs, XmNactivateCallback, (XtCallbackProc )cbGuiWhatToDoWithSelection, this); Widget widChangeToNsToLeft = XtVaCreateManagedWidget( "Change to n's to left", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widChangeToNs, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 40, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNleftOffset, 40, XmNrightOffset, 40, NULL ); XtAddCallback(widChangeToNsToLeft, XmNactivateCallback, (XtCallbackProc )cbGuiWhatToDoWithSelection, this); Widget widChangeToNsToRight = XtVaCreateManagedWidget( "Change to n's to right", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widChangeToNsToLeft, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 40, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNleftOffset, 40, XmNrightOffset, 40, NULL ); XtAddCallback(widChangeToNsToRight, XmNactivateCallback, (XtCallbackProc )cbGuiWhatToDoWithSelection, this); Widget widChangeToXsToLeft = XtVaCreateManagedWidget( "Change to x's to left", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widChangeToNsToRight, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 40, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 40, XmNtraversalOn, False, NULL ); XtAddCallback( widChangeToXsToLeft, XmNactivateCallback, (XtCallbackProc ) cbGuiWhatToDoWithSelection, this ); Widget widWidgetAbove = widChangeToXsToLeft; Widget widChangeToXsToRight = widWidgetAbove = XtVaCreateManagedWidget( "Change to x's to right", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widWidgetAbove, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 40, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 40, XmNtraversalOn, False, NULL ); XtAddCallback( widChangeToXsToRight, XmNactivateCallback, (XtCallbackProc ) cbGuiWhatToDoWithSelection, this ); Widget widAddTag = XtVaCreateManagedWidget( "Add Tag", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widWidgetAbove, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 40, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNleftOffset, 40, XmNrightOffset, 40, NULL ); XtAddCallback(widAddTag, XmNactivateCallback, (XtCallbackProc )cbGuiWhatToDoWithSelection, this); Widget widDismiss = XtVaCreateManagedWidget( "Dismiss", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widAddTag, XmNtopOffset, 50, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 40, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNleftOffset, 40, XmNrightOffset, 40, NULL ); XtAddCallback( widDismiss, XmNactivateCallback, (XtCallbackProc )cbGuiWhatToDoWithSelection, this ); // pop it all up // Note: if you do this any earlier, the bottom of the dialog will be // off the screen since it grows downward after being popped up. XtPopup( widPopupShell_, XtGrabExclusive ); // wait until user answers the question--don't let him do anything else! bBlockApplication_ = true; // xt callback must clear XEvent xevent; while( bBlockApplication_ ) { XtAppNextEvent( GuiApp::pGetGuiApp()->ctxGetAppContext(), &xevent); XtDispatchEvent( &xevent); } if (widWhichButtonGotPushed_ == widDismiss ) eWhatToDoWithSelection = eDismiss; else if (widWhichButtonGotPushed_ == widMakeHighQuality ) eWhatToDoWithSelection = eMakeHighQuality; else if (widWhichButtonGotPushed_ == widMakeHighQualityAndChangeConsensus ) eWhatToDoWithSelection = eMakeHighQualityAndChangeConsensus; else if (widWhichButtonGotPushed_ == widMakeLowQuality ) eWhatToDoWithSelection = eMakeLowQuality; else if (widWhichButtonGotPushed_ == widMakeLowQualityToLeft) eWhatToDoWithSelection = eMakeLowQualityToLeft; else if (widWhichButtonGotPushed_ == widMakeLowQualityToRight) eWhatToDoWithSelection = eMakeLowQualityToRight; else if (widWhichButtonGotPushed_ == widChangeToNs ) eWhatToDoWithSelection = eChangeToNs; else if (widWhichButtonGotPushed_ == widChangeToNsToLeft ) eWhatToDoWithSelection = eChangeToNsToLeft; else if (widWhichButtonGotPushed_ == widChangeToNsToRight ) eWhatToDoWithSelection = eChangeToNsToRight; else if (widWhichButtonGotPushed_ == widChangeToXsToLeft ) eWhatToDoWithSelection = eChangeToXsToLeft; else if (widWhichButtonGotPushed_ == widChangeToXsToRight ) eWhatToDoWithSelection = eChangeToXsToRight; else if (widWhichButtonGotPushed_ == widAddTag ) { eWhatToDoWithSelection = eAddTag; } else assert(false ); } void cbGuiWhatToDoWithSelection(Widget widButton, guiWhatToDoWithSelection *pGuiWhatToDoWithSelection, XmPushButtonCallbackStruct* pCbStruct) { // clear the flag pGuiWhatToDoWithSelection->bBlockApplication_ = false; pGuiWhatToDoWithSelection->widWhichButtonGotPushed_ = widButton; }