/* options.c * Handles the options window popup * This handles the meat of the optiosn popup stuff */ #include #include #include #include #include #include #include #include #include #include "defs.h" #include "externs.h" #include "game.h" #include "grades.h" #include "search.h" #include "searchwidgets.h" #include "learn.h" #include "widgets.h" #include "utils.h" #include "log.h" #include "multikanji.h" #include "init.h" #include "timeout.h" Widget orderbutton,usefilebutton; Widget kanjimode,englishmode,kanamode; int buttonswidth=BUTTONSWIDTH; Widget options_popup; Widget optionsform; Widget frequencyForm,gradelevelForm, timeoutForm; /* Assume "True" == 1 !! */ char * orderlabel[2] = { "Showing randomly", "Showing in order", }; char * romajilabel[2] = { "Kana/Romaji ", "Romaji/Kana ", }; char * usefilelabel[2] = { "No Usefile", "Using Usefile", }; void ordercallback(Widget w,XtPointer data,XtPointer calldata) { showinorder = !showinorder; XtVaSetValues(w,XtNlabel,orderlabel[(int) showinorder],NULL); switch(showinorder){ case 0: setstatus("Will now select kanji randomly"); SetXtrmBoolean("showinorder", False); break; case 1: setstatus("Will now go through kanji in order of #"); SetXtrmBoolean("showinorder", True); break; } return; } /* update the LABEL of the "using usefile" button in options window, * according to global useUsefile */ void UpdateUsefileL() { XtVaSetValues(usefilebutton,XtNlabel,usefilelabel[(int) useUsefile],NULL); } /* Handle togglebutton in Options window, for "Use Usefile" */ void UsefileCallback(Widget w,XtPointer data,XtPointer calldata) { char statbuff[300]; switch(useUsefile){ case True: useUsefile = False; setstatus("No longer restricting by usefile"); CountKanji(); break; case False: if(NumInUsefile() max_bounds; buttonswidth=12*(deffontsize.ascent+deffontsize.descent); } options_popup = XtVaCreatePopupShell("kdrill_options", transientShellWidgetClass, toplevel, NULL); optionsform = XtVaCreateManagedWidget("optionsform", formWidgetClass, options_popup, NULL); Opshowform = XtVaCreateManagedWidget("Opshowform", formWidgetClass, optionsform, NULL); q[0] = XtVaCreateManagedWidget( "q0",commandWidgetClass, Opshowform, XtNlabel,"Show kanji", XtNvertDistance,8, XtNshapeStyle,XawShapeOval, NULL); q[1] = XtVaCreateManagedWidget( "q1",commandWidgetClass, Opshowform, XtNlabel,"Show English", XtNshapeStyle,XawShapeOval, XtNfromVert,q[0], NULL); q[2] = XtVaCreateManagedWidget( "q2",commandWidgetClass, Opshowform, XtNlabel,"Show meaning", XtNshapeStyle,XawShapeOval, XtNfromVert,q[1], NULL); Opguessform = XtVaCreateManagedWidget("Opguessform", formWidgetClass, optionsform, XtNfromVert, Opshowform, NULL); kanjimode = XtVaCreateManagedWidget( "kanjimode",commandWidgetClass, Opguessform, XtNlabel,"Guess kanji", XtNvertDistance,8, XtNshapeStyle,XawShapeOval, NULL); englishmode = XtVaCreateManagedWidget( "englishmode",commandWidgetClass, Opguessform, XtNlabel,"Guess English", XtNfromVert,kanjimode, XtNshapeStyle,XawShapeOval, NULL); kanamode = XtVaCreateManagedWidget( "kana",commandWidgetClass, Opguessform, XtNlabel,"Guess meaning", XtNshapeStyle,XawShapeOval, XtNfromVert,englishmode, NULL); orderbutton = XtVaCreateManagedWidget("order",commandWidgetClass, optionsform, XtNlabel,orderlabel[(int) showinorder], XtNfromHoriz,Opshowform, NULL); romajibutton = XtVaCreateManagedWidget("romaji",commandWidgetClass, optionsform, XtNlabel,romajilabel[(int) romajiswitch], XtNfromVert,orderbutton, XtNfromHoriz,Opshowform, NULL); usefilebutton = XtVaCreateManagedWidget("usefile",commandWidgetClass, optionsform, XtNlabel,usefilelabel[(int) useUsefile], XtNfromVert,romajibutton, XtNfromHoriz,Opshowform, NULL); gradelevelForm = XtVaCreateManagedWidget( "gradeForm",formWidgetClass,optionsform, XtNhorizDistance,GRADEDISTANCE, XtNvertDistance,10, XtNfromHoriz,orderbutton, NULL); MakeGradeSelect(gradelevelForm); frequencyForm = XtVaCreateManagedWidget( "freqForm",formWidgetClass,optionsform, XtNvertDistance,10, XtNfromHoriz,Opguessform, XtNfromVert, Opshowform, NULL); MakeFrequency(frequencyForm); timeoutForm = XtVaCreateManagedWidget( "timeoutForm",formWidgetClass,optionsform, XtNvertDistance,10, XtNfromHoriz,frequencyForm, XtNfromVert, Opshowform, NULL); MakeTimeoutOptions(timeoutForm); XtAddCallback(q[0],XtNcallback,ChangeQuestion,(XtPointer) GUESS_KANJI); XtAddCallback(q[1],XtNcallback,ChangeQuestion,(XtPointer) GUESS_ENGLISH); XtAddCallback(q[2],XtNcallback,ChangeQuestion,(XtPointer) GUESS_KANA); XtAddCallback(kanjimode,XtNcallback,ChangeMode,(XtPointer) GUESS_KANJI); XtAddCallback(englishmode,XtNcallback,ChangeMode,(XtPointer) GUESS_ENGLISH); XtAddCallback(kanamode,XtNcallback,ChangeMode,(XtPointer) GUESS_KANA); XtAddCallback(orderbutton,XtNcallback,ordercallback,NULL); XtAddCallback(usefilebutton,XtNcallback,UsefileCallback,NULL); XtAddCallback(romajibutton,XtNcallback,romajicallback,NULL); XtSetKeyboardFocus(options_popup,toplevel); }