From: H.G. Muller Date: Mon, 22 Oct 2012 15:40:08 +0000 (+0200) Subject: Delete emptied front-end files, and move rest to gtk directory X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=0d88b7c20af19de163b648898ec8d3ed4c31d796;p=xboard.git Delete emptied front-end files, and move rest to gtk directory Remove #ifdeffed-out Xt code that has GTK implementation. The xgamelist and xhistory have been completely cleared off content, and were removed. --- diff --git a/Makefile.am b/Makefile.am index 3cb4956..96aebba 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,10 +10,9 @@ endif ### define sources for the front-end and backend -GTKsources = xboard.c xtimer.c xgamelist.c \ - xhistory.c xoptions.c xboard.h \ - xengineoutput.c xgamelist.h \ - xhistory.h +GTKsources = gtk/xboard.c gtk/xboard.h \ + gtk/xoptions.c gtk/xtimer.c \ + gtk/xengineoutput.c Xsources = xaw/xboard.c xaw/xboard.h \ xaw/xengineoutput.c \ @@ -49,6 +48,7 @@ backendsources = backend.c backend.h backendz.h \ if withGTK xboard_SOURCES = $(backendsources) $(GTKsources) + headers = -I gtk endif if withXaw xboard_SOURCES = $(backendsources) $(Xsources) diff --git a/dialogs.h b/dialogs.h index 6c3c201..498feeb 100644 --- a/dialogs.h +++ b/dialogs.h @@ -152,6 +152,7 @@ void SetDialogTitle P((DialogClass dlg, char *title)); void LoadListBox P((Option *opt, char *emptyText, int n1, int n2)); void HighlightListBoxItem P((Option *opt, int nr)); void HighlightWithScroll P((Option *opt, int sel, int max)); +void ScrollToCursor P((Option *opt, int pos)); int SelectedListBoxItem P((Option *opt)); void BoardFocus P((void)); void FocusOnWidget P((Option *opt, DialogClass dlg)); @@ -191,4 +192,3 @@ void SendString P((char *p)); int GameListClicks P((int direction)); void SetFilter P((void)); - diff --git a/frontend.h b/frontend.h index 01d0da0..949bb18 100644 --- a/frontend.h +++ b/frontend.h @@ -237,5 +237,6 @@ void SlavePopUp P((void)); /* these are in xhistory.c */ Boolean MoveHistoryIsUp P((void)); void HistoryPopUp P((void)); +void FindMoveByCharIndex P(( int char_index )); #endif /* XB_FRONTEND */ diff --git a/gtk/.dirstamp b/gtk/.dirstamp new file mode 100644 index 0000000..e69de29 diff --git a/xboard.c b/gtk/xboard.c similarity index 87% rename from xboard.c rename to gtk/xboard.c index baa4c7f..44c9984 100644 --- a/xboard.c +++ b/gtk/xboard.c @@ -159,8 +159,6 @@ extern char *getenv(); #include "xboard.h" #include "xboard2.h" #include "childio.h" -#include "xgamelist.h" -#include "xhistory.h" #include "menus.h" #include "board.h" #include "dialogs.h" @@ -198,25 +196,6 @@ char *FindFont P((char *pattern, int targetPxlSize)); void DelayedDrag P((void)); void ICSInputBoxPopUp P((void)); gboolean KeyPressProc P((GtkWindow *window, GdkEventKey *eventkey, gpointer data)); -#ifdef TODO_GTK -static void MoveTypeInProc P((Widget widget, caddr_t unused, XEvent *event)); -void HandlePV P((Widget w, XEvent * event, - String * params, Cardinal * nParams)); -void DrawPositionProc P((Widget w, XEvent *event, - String *prms, Cardinal *nprms)); -void CommentClick P((Widget w, XEvent * event, - String * params, Cardinal * nParams)); -void SelectCommand P((Widget w, XtPointer client_data, XtPointer call_data)); -void KeyBindingProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); -void QuitWrapper P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); -static void EnterKeyProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); -static void UpKeyProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); -static void DownKeyProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); -void TempBackwardProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); -void TempForwardProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); -void ManInner P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); -void SelectMove P((Widget w, XEvent * event, String * params, Cardinal * nParams)); -#endif Boolean TempBackwardActive = False; void DisplayMove P((int moveNumber)); void ICSInitScript P((void)); @@ -225,17 +204,6 @@ int CopyMemoProc P(()); static gboolean EventProc P((GtkWidget *widget, GdkEvent *event, gpointer g)); #ifdef TODO_GTK -/* -* XBoard depends on Xt R4 or higher -*/ -int xtVersion = XtSpecificationRelease; - -int xScreen; -Display *xDisplay; -Window xBoardWindow; -Pixel lowTimeWarningColor, dialogColor, buttonColor; // used in widgets -Pixmap iconPixmap, wIconPixmap, bIconPixmap, xMarkPixmap; -Widget shellWidget, formWidget, boardWidget, titleWidget, dropMenu, menuBarWidget; #if ENABLE_NLS XFontSet fontSet, clockFontSet; #else @@ -244,10 +212,8 @@ XFontStruct *clockFontStruct; #endif Font coordFontID, countFontID; XFontStruct *coordFontStruct, *countFontStruct; -XtAppContext appContext; #else void *shellWidget, *formWidget, *boardWidget, *titleWidget, *dropMenu, *menuBarWidget; -void *appContext; GtkWidget *mainwindow; #endif Option *optList; // contains all widgets of main window @@ -271,8 +237,6 @@ int smallLayout = 0, tinyLayout = 0, errorExitStatus = -1, defaultLineGap; #ifdef TODO_GTK Dimension textHeight; -Pixel timerForegroundPixel, timerBackgroundPixel; -Pixel buttonForegroundPixel, buttonBackgroundPixel; #endif char *chessDir, *programName, *programVersion; Boolean alwaysOnTop = False; @@ -311,51 +275,11 @@ DropMenuEnables dmEnables[] = { }; #ifdef TODO_GTK -Arg shellArgs[] = { - { XtNwidth, 0 }, - { XtNheight, 0 }, - { XtNminWidth, 0 }, - { XtNminHeight, 0 }, - { XtNmaxWidth, 0 }, - { XtNmaxHeight, 0 } -}; - XtResource clientResources[] = { { "flashCount", "flashCount", XtRInt, sizeof(int), XtOffset(AppDataPtr, flashCount), XtRImmediate, (XtPointer) FLASH_COUNT }, }; - -XrmOptionDescRec shellOptions[] = { - { "-flashCount", "flashCount", XrmoptionSepArg, NULL }, - { "-flash", "flashCount", XrmoptionNoArg, "3" }, - { "-xflash", "flashCount", XrmoptionNoArg, "0" }, -}; - -XtActionsRec boardActions[] = { - { "DrawPosition", DrawPositionProc }, - { "HandlePV", HandlePV }, - { "SelectPV", SelectPV }, - { "StopPV", StopPV }, - { "MenuItem", KeyBindingProc }, // [HGM] generic handler for key bindings - { "QuitProc", QuitWrapper }, - { "ManProc", ManInner }, - { "TempBackwardProc", TempBackwardProc }, - { "TempForwardProc", TempForwardProc }, - { "CommentClick", (XtActionProc) CommentClick }, - { "GenericPopDown", (XtActionProc) GenericPopDown }, - { "ErrorPopDown", (XtActionProc) ErrorPopDown }, - { "CopyMemoProc", (XtActionProc) CopyMemoProc }, - { "SelectMove", (XtActionProc) SelectMove }, - { "LoadSelectedProc", LoadSelectedProc }, - { "SetFilterProc", SetFilterProc }, - { "TypeInProc", TypeInProc }, - { "EnterKeyProc", EnterKeyProc }, - { "UpKeyProc", UpKeyProc }, - { "DownKeyProc", DownKeyProc }, - { "WheelProc", WheelProc }, - { "TabProc", TabProc }, -}; #endif char globalTranslations[] = @@ -449,138 +373,6 @@ String xboardResources[] = { static int xpm_avail[MAXSQSIZE]; -#ifdef HAVE_DIR_STRUCT - -/* Extract piece size from filename */ -static int -xpm_getsize (char *name, int len, char *ext) -{ - char *p, *d; - char buf[10]; - - if (len < 4) - return 0; - - if ((p=strchr(name, '.')) == NULL || - StrCaseCmp(p+1, ext) != 0) - return 0; - - p = name + 3; - d = buf; - - while (*p && isdigit(*p)) - *(d++) = *(p++); - - *d = 0; - return atoi(buf); -} - -/* Setup xpm_avail */ -static int -xpm_getavail (char *dirname, char *ext) -{ - DIR *dir; - struct dirent *ent; - int i; - - for (i=0; id_name, NAMLEN(ent), ext); - if (i > 0 && i < MAXSQSIZE) - xpm_avail[i] = 1; - } - - closedir(dir); - - return 0; -} - -void -xpm_print_avail (FILE *fp, char *ext) -{ - int i; - - fprintf(fp, _("Available `%s' sizes:\n"), ext); - for (i=1; iWM_PROTOCOLS: %s() \n", procname); - XtAugmentTranslations(w, XtParseTranslationTable(buf)); -} -#endif void BoardToTop () @@ -824,11 +616,7 @@ EnsureOnScreen (int *x, int *y, int minX, int minY) int MainWindowUp () { // [HGM] args: allows testing if main window is realized from back-end -#ifdef TODO_GTK - return xBoardWindow != 0; -#else return DialogExists(BoardWindow); -#endif } void @@ -878,44 +666,15 @@ ResizeBoardWindow (int w, int h, int inhibit) #endif } -#ifdef TODO_GTK -static int -MakeOneColor (char *name, Pixel *color) -{ - XrmValue vFrom, vTo; - if (!appData.monoMode) { - vFrom.addr = (caddr_t) name; - vFrom.size = strlen(name); - XtConvert(shellWidget, XtRString, &vFrom, XtRPixel, &vTo); - if (vTo.addr == NULL) { - appData.monoMode = True; - return True; - } else { - *color = *(Pixel *) vTo.addr; - } - } - return False; -} -#endif - int MakeColors () -{ // [HGM] taken out of main(), so it can be called from BoardOptions dialog - int forceMono = False; - -#ifdef TODO_GTK - if (appData.lowTimeWarning) - forceMono |= MakeOneColor(appData.lowTimeWarningColor, &lowTimeWarningColor); - if(appData.dialogColor[0]) MakeOneColor(appData.dialogColor, &dialogColor); - if(appData.buttonColor[0]) MakeOneColor(appData.buttonColor, &buttonColor); -#endif - - return forceMono; +{ // dummy, as the GTK code does not make colors in advance + return FALSE; } void InitializeFonts (int clockFontPxlSize, int coordFontPxlSize, int fontPxlSize) -{ // detervtomine what fonts to use, and create them +{ // determine what fonts to use, and create them #ifdef TODO_GTK XrmValue vTo; XrmDatabase xdb; @@ -1031,12 +790,6 @@ int main (int argc, char **argv) { int i, clockFontPxlSize, coordFontPxlSize, fontPxlSize; -#ifdef TODO_GTK - XSetWindowAttributes window_attributes; - Arg args[16]; - Dimension boardWidth, boardHeight, w, h; -#else -#endif int boardWidth, boardHeight, w, h; char *p; int forceMono = False; @@ -1137,31 +890,6 @@ main (int argc, char **argv) gameInfo.variant = StringToVariant(appData.variant); InitPosition(FALSE); -#ifdef TODO_GTK - /* GTK */ - builder = gtk_builder_new(); - filename = get_glade_filename ("mainboard.glade"); - if(! gtk_builder_add_from_file (builder, filename, >kerror) ) - { - if(gtkerror) - printf ("Error: %d %s\n",gtkerror->code,gtkerror->message); - } - mainwindow = GTK_WIDGET(gtk_builder_get_object (builder, "mainwindow")); - - shellWidget = - XtAppInitialize(&appContext, "XBoard", shellOptions, - XtNumber(shellOptions), - &argc, argv, xboardResources, NULL, 0); - - XtGetApplicationResources(shellWidget, (XtPointer) &appData, - clientResources, XtNumber(clientResources), - NULL, 0); - - xDisplay = XtDisplay(shellWidget); - xScreen = DefaultScreen(xDisplay); - wm_delete_window = XInternAtom(xDisplay, "WM_DELETE_WINDOW", True); -#endif - /* * determine size, based on supplied or remembered -size, or screen size */ @@ -1197,12 +925,6 @@ main (int argc, char **argv) } else { SizeDefaults *szd = sizeDefaults; if (*appData.boardSize == NULLCHAR) { -#ifdef TODO_GTK - while (DisplayWidth(xDisplay, xScreen) < szd->minScreenSize || - DisplayHeight(xDisplay, xScreen) < szd->minScreenSize) { - szd++; - } -#else GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(mainwindow)); guint screenwidth = gdk_screen_get_width(screen); guint screenheight = gdk_screen_get_height(screen); @@ -1210,7 +932,6 @@ main (int argc, char **argv) screenheight < szd->minScreenSize) { szd++; } -#endif if (szd->name == NULL) szd--; appData.boardSize = strdup(szd->name); // [HGM] settings: remember name for saving settings } else { @@ -1265,10 +986,6 @@ main (int argc, char **argv) ParseIcsTextColors(); -#ifdef TODO_GTK - XtAppAddActions(appContext, boardActions, XtNumber(boardActions)); -#endif - /* * widget hierarchy */ @@ -1309,10 +1026,6 @@ main (int argc, char **argv) } #endif -#ifdef TODO_GTK - xBoardWindow = XtWindow(boardWidget); -#endif - // [HGM] it seems the layout code ends here, but perhaps the color stuff is size independent and would // not need to go into InitDrawingSizes(). @@ -1356,10 +1069,6 @@ printf("start size (%d,%d), %dx%d\n", a.x, a.y, w, h); marginW = w - boardWidth; // [HGM] needed to set new shellWidget size when we resize board marginH = h - boardHeight; -#ifdef TODO_GTK - CatchDeleteWindow(shellWidget, "QuitProc"); -#endif - CreateAnyPieces(); CreateGrid(); @@ -1373,15 +1082,6 @@ printf("start size (%d,%d), %dx%d\n", a.x, a.y, w, h); if (appData.animate || appData.animateDragging) CreateAnimVars(); -#ifdef TODO_GTK - XtAugmentTranslations(formWidget, - XtParseTranslationTable(globalTranslations)); - - XtAddEventHandler(formWidget, KeyPressMask, False, - (XtEventHandler) MoveTypeInProc, NULL); - XtAddEventHandler(shellWidget, StructureNotifyMask, False, - (XtEventHandler) EventProc, NULL); -#endif g_signal_connect(shells[BoardWindow], "key-press-event", G_CALLBACK(KeyPressProc), NULL); g_signal_connect(shells[BoardWindow], "configure-event", G_CALLBACK(EventProc), NULL); @@ -1797,11 +1497,7 @@ ReSize (WindowPlacement *wp) if(optList[W_BOARD].value > h) optList[W_BOARD].value = h; } -#ifdef TODO_GTK -static XtIntervalId delayedDragID = 0; -#else static guint delayedDragTag = 0; -#endif void DragProc () @@ -1851,17 +1547,6 @@ printf("event proc (%d,%d) %dx%d\n", event->configure.x, event->configure.y, eve return FALSE; } -/* - * event handler for redrawing the board - */ -#ifdef TODO_GTK -void -DrawPositionProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) -{ - DrawPosition(True, NULL); -} -#endif - /* Disable all user input other than deleting the window */ diff --git a/xboard.h b/gtk/xboard.h similarity index 100% rename from xboard.h rename to gtk/xboard.h diff --git a/xengineoutput.c b/gtk/xengineoutput.c similarity index 100% rename from xengineoutput.c rename to gtk/xengineoutput.c diff --git a/xoptions.c b/gtk/xoptions.c similarity index 71% rename from xoptions.c rename to gtk/xoptions.c index a2f749f..f5d223c 100644 --- a/xoptions.c +++ b/gtk/xoptions.c @@ -314,6 +314,14 @@ HighlightWithScroll (Option *opt, int index, int max) HighlightItem (opt, index, TRUE); // ignore max } +void +ScrollToCursor (Option *opt, int caretPos) +{ + static GtkTextIter iter; + gtk_text_buffer_get_iter_at_offset((GtkTextBuffer *) opt->handle, &iter, caretPos); + gtk_text_view_scroll_to_iter((GtkTextView *) opt->textValue, &iter, 0.0, 0, 0.5, 0.5); +} + int SelectedListBoxItem (Option *opt) { @@ -434,19 +442,6 @@ CreateMenuPopup (Option *opt, int n, int def) return menu; } -char moveTypeInTranslations[] = - "Return: TypeInProc(1) \n" - "Escape: TypeInProc(0) \n"; -extern char filterTranslations[]; -extern char gameListTranslations[]; -extern char memoTranslations[]; - - -char *translationTable[] = { // beware: order is essential! - historyTranslations, commentTranslations, moveTypeInTranslations, ICSInputTranslations, - filterTranslations, gameListTranslations, memoTranslations -}; - Option *typeIn; // kludge to distinguish type-in callback from input-box callback void @@ -1425,37 +1420,14 @@ printf("option =%2d, top =%2d\n", i, top); g_signal_connect (graph, "motion-notify-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]); #ifdef TODO_GTK - XtAddEventHandler(last, ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask, False, - (XtEventHandler) GraphEventProc, &option[i]); // mandatory user-supplied expose handler if(option[i].min & SAME_ROW) last = forelast, forelast = lastrow; #endif option[i].choice = (char**) cairo_image_surface_create (CAIRO_FORMAT_ARGB32, option[i].max, option[i].value); // image buffer break; #ifdef TODO_GTK - case Graph: - j = SetPositionAndSize(args, last, lastrow, 0 /* border */, - option[i].max /* w */, option[i].value /* h */, option[i].min /* chain */); - option[i].handle = (void*) - (last = XtCreateManagedWidget("graph", widgetClass, form, args, j)); - XtAddEventHandler(last, ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask, False, - (XtEventHandler) GraphEventProc, &option[i]); // mandatory user-supplied expose handler - if(option[i].min & SAME_ROW) last = forelast, forelast = lastrow; - option[i].choice = (char**) cairo_image_surface_create (CAIRO_FORMAT_ARGB32, option[i].max, option[i].value); // image buffer - break; case PopUp: // note: used only after Graph, so 'last' refers to the Graph widget option[i].handle = (void*) CreateComboPopup(last, option + i, i + 256*dlgNr, TRUE, option[i].value); break; - case BoxBegin: - if(option[i].min & SAME_ROW) forelast = lastrow; - j = SetPositionAndSize(args, last, lastrow, 0 /* border */, - 0 /* w */, 0 /* h */, option[i].min /* chain */); - XtSetArg(args[j], XtNorientation, XtorientHorizontal); j++; - XtSetArg(args[j], XtNvSpace, 0); j++; - option[box=i].handle = (void*) - (last = XtCreateWidget("box", boxWidgetClass, form, args, j)); - oldForm = form; form = last; oldLastRow = lastrow; oldForeLast = forelast; - lastrow = NULL; last = NULL; - break; #endif case DropDown: top--; @@ -1534,402 +1506,6 @@ printf("option =%2d, top =%2d\n", i, top); (gpointer)(intptr_t) dlgNr); shellUp[dlgNr]++; -#ifdef TODO_GTK - Arg args[24]; - Widget popup, layout, dialog=NULL, edit=NULL, form, last, b_ok, b_cancel, previousPane = NULL, textField = NULL, oldForm, oldLastRow, oldForeLast; - Window root, child; - int x, y, i, j, height=999, width=1, h, c, w, shrink=FALSE, stack = 0, box, chain; - int win_x, win_y, maxWidth, maxTextWidth; - unsigned int mask; - char def[MSG_SIZ], *msg, engineDlg = (currentCps != NULL && dlgNr != BrowserDlg); - static char pane[6] = "paneX"; - Widget texts[100], forelast = NULL, anchor, widest, lastrow = NULL, browse = NULL; - Dimension bWidth = 50; - - if(dlgNr < PromoDlg && shellUp[dlgNr]) return 0; // already up - if(dlgNr && dlgNr < PromoDlg && shells[dlgNr]) { // reusable, and used before (but popped down) - XtPopup(shells[dlgNr], XtGrabNone); - shellUp[dlgNr] = True; - return 0; - } - - dialogOptions[dlgNr] = option; // make available to callback - // post currentOption globally, so Spin and Combo callbacks can already use it - // WARNING: this kludge does not work for persistent dialogs, so that these cannot have spin or combo controls! - currentOption = option; - - if(engineDlg) { // Settings popup for engine: format through heuristic - int n = currentCps->nrOptions; - if(n > 50) width = 4; else if(n>24) width = 2; else width = 1; - height = n / width + 1; - if(n && (currentOption[n-1].type == Button || currentOption[n-1].type == SaveButton)) currentOption[n].min = SAME_ROW; // OK on same line - currentOption[n].type = EndMark; currentOption[n].target = NULL; // delimit list by callback-less end mark - } - i = 0; - XtSetArg(args[i], XtNresizable, True); i++; - shells[BoardWindow] = shellWidget; parents[dlgNr] = parent; - - if(dlgNr == BoardWindow) popup = shellWidget; else - popup = shells[dlgNr] = - XtCreatePopupShell(title, !top || !appData.topLevel ? transientShellWidgetClass : topLevelShellWidgetClass, - shells[parent], args, i); - - layout = - XtCreateManagedWidget(layoutName, formWidgetClass, popup, - layoutArgs, XtNumber(layoutArgs)); - if(!appData.monoMode && appData.dialogColor[0]) XtSetArg(args[0], XtNbackground, dialogColor); - XtSetValues(layout, args, 1); - - for(c=0; c and - - if(option[i].type == TextBox || option[i].type == Fractional) break; - - // add increment and decrement controls for spin - if(option[i].type == FileName || option[i].type == PathName) { - msg = _("browse"); w = 0; // automatically scale to width of text - j = textHeight ? textHeight : 0; - } else { - w = 20; msg = "+"; j = textHeight/2; // spin button - } - j = SetPositionAndSize(args, last, edit, 3 /* border */, - w /* w */, j /* h */, 0x31 /* chain to right edge */); - edit = XtCreateManagedWidget(msg, commandWidgetClass, form, args, j); - XtAddCallback(edit, XtNcallback, SpinCallback, (XtPointer)(intptr_t) i + 256*dlgNr); - if(w == 0) browse = edit; - - if(option[i].type != Spin) break; - - j = SetPositionAndSize(args, last, edit, 3 /* border */, - 20 /* w */, textHeight/2 /* h */, 0x31 /* chain to right edge */); - XtSetArg(args[j], XtNvertDistance, -1); j++; - last = XtCreateManagedWidget("-", commandWidgetClass, form, args, j); - XtAddCallback(last, XtNcallback, SpinCallback, (XtPointer)(intptr_t) i + 256*dlgNr); - break; - case CheckBox: - if(!engineDlg) option[i].value = *(Boolean*)option[i].target; // where checkbox callback uses it - j = SetPositionAndSize(args, last, lastrow, 1 /* border */, - textHeight/2 /* w */, textHeight/2 /* h */, 0xC0 /* chain both to left edge */); - XtSetArg(args[j], XtNvertDistance, (textHeight+2)/4 + 3); j++; - XtSetArg(args[j], XtNstate, option[i].value); j++; - lastrow = last; - option[i].handle = (void*) - (last = XtCreateManagedWidget(" ", toggleWidgetClass, form, args, j)); - j = SetPositionAndSize(args, last, lastrow, 0 /* border */, - option[i].max /* w */, textHeight /* h */, 0xC1 /* chain */); - XtSetArg(args[j], XtNjustify, XtJustifyLeft); j++; - XtSetArg(args[j], XtNlabel, _(option[i].name)); j++; - last = XtCreateManagedWidget("label", commandWidgetClass, form, args, j); - // make clicking the text toggle checkbox - XtAddEventHandler(last, ButtonPressMask, False, CheckCallback, (XtPointer)(intptr_t) i + 256*dlgNr); - shrink = TRUE; // following buttons must get text height - break; - case Label: - msg = option[i].name; - if(!msg) break; - chain = option[i].min; - if(chain & SAME_ROW) forelast = lastrow; else shrink = FALSE; - j = SetPositionAndSize(args, last, lastrow, (chain & 2) != 0 /* border */, - option[i].max /* w */, shrink ? textHeight : 0 /* h */, chain | 2 /* chain */); -#if ENABLE_NLS - if(option[i].choice) XtSetArg(args[j], XtNfontSet, *(XFontSet*)option[i].choice), j++; -#else - if(option[i].choice) XtSetArg(args[j], XtNfont, (XFontStruct*)option[i].choice), j++; -#endif - XtSetArg(args[j], XtNresizable, False); j++; - XtSetArg(args[j], XtNjustify, XtJustifyLeft); j++; - XtSetArg(args[j], XtNlabel, _(msg)); j++; - option[i].handle = (void*) (last = XtCreateManagedWidget("label", labelWidgetClass, form, args, j)); - if(option[i].target) // allow user to specify event handler for button presses - XtAddEventHandler(last, ButtonPressMask, False, CheckCallback, (XtPointer)(intptr_t) i + 256*dlgNr); - break; - case SaveButton: - case Button: - if(option[i].min & SAME_ROW) { - chain = 0x31; // 0011.0001 = both left and right side to right edge - forelast = lastrow; - } else chain = 0, shrink = FALSE; - j = SetPositionAndSize(args, last, lastrow, 3 /* border */, - option[i].max /* w */, shrink ? textHeight : 0 /* h */, option[i].min & 0xE | chain /* chain */); - XtSetArg(args[j], XtNlabel, _(option[i].name)); j++; - if(option[i].textValue) { // special for buttons of New Variant dialog - XtSetArg(args[j], XtNsensitive, appData.noChessProgram || option[i].value < 0 - || strstr(first.variants, VariantName(option[i].value))); j++; - XtSetArg(args[j], XtNborderWidth, (gameInfo.variant == option[i].value)+1); j++; - } - option[i].handle = (void*) - (dialog = last = XtCreateManagedWidget(option[i].name, commandWidgetClass, form, args, j)); - if(option[i].choice && ((char*)option[i].choice)[0] == '#' && !engineDlg) { // for the color picker default-reset - SetColor( *(char**) option[i-1].target, &option[i]); - XtAddEventHandler(option[i-1].handle, KeyReleaseMask, False, ColorChanged, (XtPointer)(intptr_t) i-1); - } - XtAddCallback(last, XtNcallback, GenericCallback, (XtPointer)(intptr_t) i + (dlgNr<<16)); // invokes user callback - if(option[i].textValue) SetColor( option[i].textValue, &option[i]); // for new-variant buttons - break; - case ComboBox: - j = SetPositionAndSize(args, last, lastrow, 0 /* border */, - 0 /* w */, textHeight /* h */, 0xC0 /* chain both sides to left edge */); - XtSetArg(args[j], XtNjustify, XtJustifyLeft); j++; - XtSetArg(args[j], XtNlabel, _(option[i].name)); j++; - texts[h] = dialog = XtCreateManagedWidget(option[i].name, labelWidgetClass, form, args, j); - - if(option[i].min & COMBO_CALLBACK) msg = _(option[i].name); else { - if(!engineDlg) SetCurrentComboSelection(option+i); - msg=_(((char**)option[i].choice)[option[i].value]); - } - - j = SetPositionAndSize(args, dialog, last, (option[i].min & 2) == 0 /* border */, - option[i].max && !engineDlg ? option[i].max : 100 /* w */, - textHeight /* h */, 0x91 /* chain */); // same row as its label! - XtSetArg(args[j], XtNmenuName, XtNewString(option[i].name)); j++; - XtSetArg(args[j], XtNlabel, msg); j++; - shrink = TRUE; - option[i].handle = (void*) - (last = XtCreateManagedWidget(" ", menuButtonWidgetClass, form, args, j)); - CreateComboPopup(last, option + i, i + 256*dlgNr, TRUE, -1); - values[i] = option[i].value; - break; - case ListBox: - // Listbox goes in viewport, as needed for game list - if(option[i].min & SAME_ROW) forelast = lastrow; - j = SetPositionAndSize(args, last, lastrow, 1 /* border */, - option[i].max /* w */, option[i].value /* h */, option[i].min /* chain */); - XtSetArg(args[j], XtNresizable, False); j++; - XtSetArg(args[j], XtNallowVert, True); j++; // scoll direction - last = - XtCreateManagedWidget("viewport", viewportWidgetClass, form, args, j); - j = 0; // now list itself - XtSetArg(args[j], XtNdefaultColumns, 1); j++; - XtSetArg(args[j], XtNforceColumns, True); j++; - XtSetArg(args[j], XtNverticalList, True); j++; - option[i].handle = (void*) - (edit = XtCreateManagedWidget("list", listWidgetClass, last, args, j)); - XawListChange(option[i].handle, option[i].target, 0, 0, True); - XawListHighlight(option[i].handle, 0); - scrollTranslations[25] = '0' + i; - scrollTranslations[27] = 'A' + dlgNr; - XtOverrideTranslations(edit, XtParseTranslationTable(scrollTranslations)); // for mouse-wheel - break; - case Graph: - j = SetPositionAndSize(args, last, lastrow, 0 /* border */, - option[i].max /* w */, option[i].value /* h */, option[i].min /* chain */); - option[i].handle = (void*) - (last = XtCreateManagedWidget("graph", widgetClass, form, args, j)); - XtAddEventHandler(last, ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask, False, - (XtEventHandler) GraphEventProc, &option[i]); // mandatory user-supplied expose handler - if(option[i].min & SAME_ROW) last = forelast, forelast = lastrow; - option[i].choice = (char**) cairo_image_surface_create (CAIRO_FORMAT_ARGB32, option[i].max, option[i].value); // image buffer - break; - case PopUp: // note: used only after Graph, so 'last' refers to the Graph widget - option[i].handle = (void*) CreateComboPopup(last, option + i, i + 256*dlgNr, TRUE, option[i].value); - break; - case BoxBegin: - if(option[i].min & SAME_ROW) forelast = lastrow; - j = SetPositionAndSize(args, last, lastrow, 0 /* border */, - 0 /* w */, 0 /* h */, option[i].min /* chain */); - XtSetArg(args[j], XtNorientation, XtorientHorizontal); j++; - XtSetArg(args[j], XtNvSpace, 0); j++; - option[box=i].handle = (void*) - (last = XtCreateWidget("box", boxWidgetClass, form, args, j)); - oldForm = form; form = last; oldLastRow = lastrow; oldForeLast = forelast; - lastrow = NULL; last = NULL; - break; - case DropDown: - j = SetPositionAndSize(args, last, lastrow, 0 /* border */, - 0 /* w */, 0 /* h */, 1 /* chain (always on same row) */); - forelast = lastrow; - msg = _(option[i].name); // write name on the menu button - XtSetArg(args[j], XtNmenuName, XtNewString(option[i].name)); j++; - XtSetArg(args[j], XtNlabel, msg); j++; - option[i].handle = (void*) - (last = XtCreateManagedWidget(option[i].name, menuButtonWidgetClass, form, args, j)); - option[i].textValue = (char*) CreateComboPopup(last, option + i, i + 256*dlgNr, FALSE, -1); - break; - case BoxEnd: - XtManageChildren(&form, 1); - SqueezeIntoBox(&option[box], i-box, option[box].max); - if(option[i].target) ((ButtonCallback*)option[i].target)(box); // callback that can make sizing decisions - last = form; lastrow = oldLastRow; form = oldForm; forelast = oldForeLast; - break; - case Break: - width++; - height = i+1; - stack = !(option[i].min & SAME_ROW); - break; - default: - printf("GenericPopUp: unexpected case in switch.\n"); - break; - } - } - - // make an attempt to align all spins and textbox controls - maxWidth = maxTextWidth = 0; - if(browse != NULL) { - j=0; - XtSetArg(args[j], XtNwidth, &bWidth); j++; - XtGetValues(browse, args, j); - } - for(h=0; h maxWidth) maxWidth = w; - widest = texts[h]; - } else { - if(w > maxTextWidth) maxTextWidth = w; - if(!widest) widest = texts[h]; - } - } - } - if(maxTextWidth + 110 < maxWidth) - maxTextWidth = maxWidth - 110; - else maxWidth = maxTextWidth + 110; - for(h=0; hWM_PROTOCOLS: GenericPopDown(\"%d\") \n", dlgNr); - XtAugmentTranslations(popup, XtParseTranslationTable(def)); - XQueryPointer(xDisplay, xBoardWindow, &root, &child, - &x, &y, &win_x, &win_y, &mask); - - XtSetArg(args[0], XtNx, x - 10); - XtSetArg(args[1], XtNy, y - 30); - XtSetValues(popup, args, 2); - } - XtPopup(popup, modal ? XtGrabExclusive : XtGrabNone); - shellUp[dlgNr]++; // count rather than flag - previous = NULL; - if(textField) SetFocus(textField, popup, (XEvent*) NULL, False); - if(dlgNr && wp[dlgNr] && wp[dlgNr]->width > 0) { // if persistent window-info available, reposition - j = 0; - XtSetArg(args[j], XtNheight, (Dimension) (wp[dlgNr]->height)); j++; - XtSetArg(args[j], XtNwidth, (Dimension) (wp[dlgNr]->width)); j++; - XtSetArg(args[j], XtNx, (Position) (wp[dlgNr]->x)); j++; - XtSetArg(args[j], XtNy, (Position) (wp[dlgNr]->y)); j++; - XtSetValues(popup, args, j); - } - RaiseWindow(dlgNr); -#endif return 1; // tells caller he must do initialization (e.g. add specific event handlers) } @@ -1978,21 +1554,6 @@ SetInsertPos (Option *opt, int pos) #endif } -#ifdef TODO_GTK -void -TypeInProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) -{ // can be used as handler for any text edit in any dialog (from GenericPopUp, that is) - int n = prms[0][0] - '0'; - Widget sh = XtParent(XtParent(XtParent(w))); // popup shell - - if(n<2) { // Enter or Esc typed from primed text widget: treat as if dialog OK or cancel button hit. - int dlgNr; // figure out what the dialog number is by comparing shells (because we must pass it :( ) - for(dlgNr=0; dlgNr #include "common.h" +#include "frontend.h" #include "backend.h" -#include "xhistory.h" #include "dialogs.h" #include "gettext.h" @@ -83,6 +83,12 @@ Option historyOptions[] = { { 0, NO_OK, 0, NULL, (void*) NULL, "", NULL, EndMark , "" } }; +void +ScrollToCurrent (int caretPos) +{ + ScrollToCursor(&historyOptions[0], caretPos); +} + // ------------ standard entry points into MoveHistory code ----------- Boolean diff --git a/xaw/xhistory.c b/xaw/xhistory.c index d46206d..805c1f3 100644 --- a/xaw/xhistory.c +++ b/xaw/xhistory.c @@ -74,23 +74,23 @@ extern Option historyOptions[]; // the bold argument says 0 = normal, 1 = bold typeface // the colorNr argument says 0 = font-default, 1 = gray void -ScrollToCurrent (int caretPos) +ScrollToCursor (Option *opt, int caretPos) { Arg args[10]; char *s; int len; - GetWidgetText(&historyOptions[0], &s); + GetWidgetText(opt, &s); len = strlen(s); if(caretPos < 0 || caretPos > len) caretPos = len; if(caretPos > len-30) { // scroll to end, which causes no flicker static XEvent event; - XtCallActionProc(historyOptions[0].handle, "end-of-file", &event, NULL, 0); + XtCallActionProc(opt->handle, "end-of-file", &event, NULL, 0); return; } // the following leads to a very annoying flicker, even when no scrolling is done at all. XtSetArg(args[0], XtNinsertPosition, caretPos); // this triggers scrolling in Xaw XtSetArg(args[1], XtNdisplayCaret, False); - XtSetValues(historyOptions[0].handle, args, 2); + XtSetValues(opt->handle, args, 2); } diff --git a/xgamelist.c b/xgamelist.c deleted file mode 100644 index b2f5ade..0000000 --- a/xgamelist.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * xgamelist.c -- Game list window, part of X front end for XBoard - * - * Copyright 1995, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. - * ------------------------------------------------------------------------ - * - * GNU XBoard is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * GNU XBoard is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. * - * - *------------------------------------------------------------------------ - ** See the file ChangeLog for a revision history. */ - -#include "config.h" - -#include -#include -#include -#include - -#if STDC_HEADERS -# include -# include -#else /* not STDC_HEADERS */ -extern char *getenv(); -# if HAVE_STRING_H -# include -# else /* not HAVE_STRING_H */ -# include -# endif /* not HAVE_STRING_H */ -#endif /* not STDC_HEADERS */ - -#if HAVE_UNISTD_H -# include -#endif - -#include - -#include "common.h" -#include "backend.h" -#include "xboard.h" -#include "xgamelist.h" -#include "dialogs.h" - - -char gameListTranslations[] = - ": WheelProc(-3) \n \ - : WheelProc(3) \n \ - : LoadSelectedProc(100) Set() \n \ - (2): LoadSelectedProc(0) \n \ - Home: LoadSelectedProc(-2) \n \ - End: LoadSelectedProc(2) \n \ - CtrlUp: LoadSelectedProc(-3) \n \ - CtrlDown: LoadSelectedProc(3) \n \ - Up: LoadSelectedProc(-1) \n \ - Down: LoadSelectedProc(1) \n \ - Left: LoadSelectedProc(-1) \n \ - Right: LoadSelectedProc(1) \n \ - Prior: LoadSelectedProc(-4) \n \ - Next: LoadSelectedProc(4) \n \ - Return: LoadSelectedProc(0) \n"; -char filterTranslations[] = - "Return: SetFilterProc() \n"; - - -#ifdef TODO_GTK -void -LoadSelectedProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) -{ - if(GameListClicks(atoi(prms[0]))) return; // if no game loaded, no focus transfer - XSync(xDisplay, False); - XSetInputFocus(xDisplay, XtWindow(boardWidget), RevertToPointerRoot, CurrentTime); -} - -void -SetFilterProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) -{ - SetFilter(); -} -#endif - diff --git a/xgamelist.h b/xgamelist.h deleted file mode 100644 index c78e736..0000000 --- a/xgamelist.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * xgamelist.h -- Game list window, part of X front end for XBoard - * - * Copyright 1995, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. - * ------------------------------------------------------------------------ - * - * GNU XBoard is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * GNU XBoard is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. * - * - *------------------------------------------------------------------------ - ** See the file ChangeLog for a revision history. */ - -#ifndef XB_XGAMELIST -#define XB_XGAMELIST - -#ifdef TODO_GTK -void LoadSelectedProc P((Widget w, XEvent *event, - String *prms, Cardinal *nprms)); -void SetFilterProc P((Widget w, XEvent *event, - String *prms, Cardinal *nprms)); -#endif - -#endif /* XB_XGAMELIST */ diff --git a/xhistory.c b/xhistory.c deleted file mode 100644 index 0551ce1..0000000 --- a/xhistory.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * New (WinBoard-style) Move history for XBoard - * - * Copyright 2009, 2010, 2011, 2012 Free Software Foundation, Inc. - * ------------------------------------------------------------------------ - * - * GNU XBoard is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * GNU XBoard is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - * - * ------------------------------------------------------------------------ - ** See the file ChangeLog for a revision history. */ - -#include "config.h" - -#include -#include -#include - -#include "common.h" -#include "backend.h" -#include "xhistory.h" -#include "dialogs.h" -#include "gettext.h" - -#ifdef ENABLE_NLS -# define _(s) gettext (s) -# define N_(s) gettext_noop (s) -#else -# define _(s) (s) -# define N_(s) s -#endif - -// templates for calls into back-end (= history.c; should be moved to history.h header shared with it!) -void FindMoveByCharIndex P(( int char_index )); - -// variables in nhistory.c -extern Option historyOptions[]; - -// ------------- low-level front-end actions called by MoveHistory back-end ----------------- - -void -ScrollToCurrent (int caretPos) -{ - static GtkTextIter iter; - gtk_text_buffer_get_iter_at_offset((GtkTextBuffer *) historyOptions[0].handle, &iter, caretPos); - gtk_text_view_scroll_to_iter((GtkTextView *) historyOptions[0].textValue, &iter, 0.0, 0, 0.5, 0.5); -} - - -// ------------------------------ callbacks -------------------------- - -char historyTranslations[] = -": select-start() \n \ -: extend-end() SelectMove() \n"; - diff --git a/xhistory.h b/xhistory.h deleted file mode 100644 index 90f0c9b..0000000 --- a/xhistory.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * xhistory.h -- Eval graph window, part of X front end for XBoard - * - * Copyright 1995, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. - * ------------------------------------------------------------------------ - * - * GNU XBoard is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * GNU XBoard is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. * - * - *------------------------------------------------------------------------ - ** See the file ChangeLog for a revision history. */ - -#ifndef XB_XHISTLIST -#define XB_XHISTLIST - -void HistoryShowProc P((void)); -Boolean MoveHistoryIsUp P((void)); - -#endif /* XB_XHISTLIST */