From e9057ab4e0257b4bdae607d34bac2b7f6392e6a8 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sun, 14 Oct 2012 20:36:34 +0200 Subject: [PATCH] Remove all X11 code by #ifdeffing it out With #ifdef TODO_GTK we disable all X11 code, in order to get a compiling X11-free version. The disabled sections can then be replaced by code for another widget set, the X11 version still showing what it was supposed to do. --- xboard.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- xboard.h | 15 +++-- xengineoutput.c | 41 ++++++-------- xgamelist.c | 34 +----------- xhistory.c | 26 ++------- xoptions.c | 122 ++++++++++++++++++++++++++++++++++-------- 6 files changed, 287 insertions(+), 109 deletions(-) diff --git a/xboard.c b/xboard.c index fd1e087..8270d52 100644 --- a/xboard.c +++ b/xboard.c @@ -271,13 +271,13 @@ int CopyMemoProc P(()); */ int xtVersion = XtSpecificationRelease; +#ifdef TODO_GTK 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; -Option *optList; // contains all widgets of main window #if ENABLE_NLS XFontSet fontSet, clockFontSet; #else @@ -287,6 +287,11 @@ XFontStruct *clockFontStruct; Font coordFontID, countFontID; XFontStruct *coordFontStruct, *countFontStruct; XtAppContext appContext; +#else +void *shellWidget, *formWidget, *boardWidget, *titleWidget, *dropMenu, *menuBarWidget; +void *appContext; +#endif +Option *optList; // contains all widgets of main window char *layoutName; char installDir[] = "."; // [HGM] UCI: needed for UCI; probably needs run-time initializtion @@ -355,6 +360,7 @@ DropMenuEnables dmEnables[] = { { 'Q', "Queen" } }; +#ifdef TODO_GTK Arg shellArgs[] = { { XtNwidth, 0 }, { XtNheight, 0 }, @@ -400,6 +406,7 @@ XtActionsRec boardActions[] = { { "WheelProc", WheelProc }, { "TabProc", TabProc }, }; +#endif char globalTranslations[] = ":F9: MenuItem(Actions.Resign) \n \ @@ -480,11 +487,12 @@ char ICSInputTranslations[] = // as the widget is destroyed before the up-click can call extend-end char commentTranslations[] = ": extend-end() select-start() CommentClick() \n"; +#ifdef TODO_GTK String xboardResources[] = { "*Error*translations: #override\\n Return: ErrorPopDown()", NULL }; - +#endif /* Max possible square size */ #define MAXSQSIZE 256 @@ -611,6 +619,7 @@ Warning: No DIR structure found on this system --\n\ #endif /* HAVE_DIR_STRUCT */ +#ifdef TODO_GTK /* Arrange to catch delete-window events */ Atom wm_delete_window; void @@ -621,15 +630,18 @@ CatchDeleteWindow (Widget w, String procname) snprintf(buf, sizeof(buf), "WM_PROTOCOLS: %s() \n", procname); XtAugmentTranslations(w, XtParseTranslationTable(buf)); } +#endif void BoardToTop () { +#ifdef TODO_GTK Arg args[16]; XtSetArg(args[0], XtNiconic, False); XtSetValues(shellWidget, args, 1); XtPopup(shellWidget, XtGrabNone); /* Raise if lowered */ +#endif } //--------------------------------------------------------------------------------------------------------- @@ -807,6 +819,7 @@ ParseCommPortSettings (char *s) int frameX, frameY; +#ifdef TODO_GTK void GetActualPlacement (Widget wg, WindowPlacement *wp) { @@ -825,11 +838,13 @@ GetActualPlacement (Widget wg, WindowPlacement *wp) wp->width = winAt.width; frameX = winAt.x; frameY = winAt.y; // remember to decide if windows touch } +#endif void GetWindowCoords () { // wrapper to shield use of window handles from back-end (make addressible by number?) // In XBoard this will have to wait until awareness of window parameters is implemented +#ifdef TODO_GTK GetActualPlacement(shellWidget, &wpMain); if(shellUp[EngOutDlg]) GetActualPlacement(shells[EngOutDlg], &wpEngineOutput); if(shellUp[HistoryDlg]) GetActualPlacement(shells[HistoryDlg], &wpMoveHistory); @@ -837,6 +852,7 @@ GetWindowCoords () if(shellUp[GameListDlg]) GetActualPlacement(shells[GameListDlg], &wpGameList); if(shellUp[CommentDlg]) GetActualPlacement(shells[CommentDlg], &wpComment); if(shellUp[TagsDlg]) GetActualPlacement(shells[TagsDlg], &wpTags); +#endif } void @@ -853,7 +869,11 @@ 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 0; +#endif } void @@ -887,6 +907,7 @@ ConvertToLine (int argc, char **argv) void ResizeBoardWindow (int w, int h, int inhibit) { +#ifdef TODO_GTK w += marginW + 1; // [HGM] not sure why the +1 is (sometimes) needed... h += marginH; shellArgs[0].value = w; @@ -896,8 +917,10 @@ ResizeBoardWindow (int w, int h, int inhibit) XtSetValues(shellWidget, &shellArgs[0], inhibit ? 6 : 2); XSync(xDisplay, False); +#endif } +#ifdef TODO_GTK static int MakeOneColor (char *name, Pixel *color) { @@ -915,16 +938,19 @@ MakeOneColor (char *name, Pixel *color) } 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; } @@ -932,6 +958,7 @@ MakeColors () void InitializeFonts (int clockFontPxlSize, int coordFontPxlSize, int fontPxlSize) { // detervtomine what fonts to use, and create them +#ifdef TODO_GTK XrmValue vTo; XrmDatabase xdb; @@ -982,6 +1009,7 @@ InitializeFonts (int clockFontPxlSize, int coordFontPxlSize, int fontPxlSize) #else XrmPutStringResource(&xdb, "*font", appData.font); #endif +#endif } char * @@ -1045,9 +1073,13 @@ 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 + int boardWidth, boardHeight, w, h; +#endif char *p; int forceMono = False; @@ -1138,6 +1170,7 @@ main (int argc, char **argv) gameInfo.variant = StringToVariant(appData.variant); InitPosition(FALSE); +#ifdef TODO_GTK shellWidget = XtAppInitialize(&appContext, "XBoard", shellOptions, XtNumber(shellOptions), @@ -1150,6 +1183,7 @@ main (int argc, char **argv) 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 @@ -1186,10 +1220,12 @@ 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++; } +#endif if (szd->name == NULL) szd--; appData.boardSize = strdup(szd->name); // [HGM] settings: remember name for saving settings } else { @@ -1221,14 +1257,18 @@ main (int argc, char **argv) /* * Determine what fonts to use. */ +#ifdef TODO_GTK InitializeFonts(clockFontPxlSize, coordFontPxlSize, fontPxlSize); +#endif /* * Detect if there are not enough colors available and adapt. */ +#ifdef TODO_GTK if (DefaultDepth(xDisplay, xScreen) <= 2) { appData.monoMode = True; } +#endif forceMono = MakeColors(); @@ -1239,14 +1279,18 @@ main (int argc, char **argv) } if (appData.monoMode && appData.debugMode) { +#ifdef TODO_GTK fprintf(stderr, _("white pixel = 0x%lx, black pixel = 0x%lx\n"), (unsigned long) XWhitePixel(xDisplay, xScreen), (unsigned long) XBlackPixel(xDisplay, xScreen)); +#endif } ParseIcsTextColors(); +#ifdef TODO_GTK XtAppAddActions(appContext, boardActions, XtNumber(boardActions)); +#endif /* * widget hierarchy @@ -1260,11 +1304,15 @@ main (int argc, char **argv) } optList = BoardPopUp(squareSize, lineGap, (void*) +#ifdef TODO_GTK #if ENABLE_NLS &clockFontSet); #else clockFontStruct); #endif +#else +0); +#endif InitDrawingHandle(optList + W_BOARD); currBoard = &optList[W_BOARD]; boardWidget = optList[W_BOARD].handle; @@ -1272,6 +1320,7 @@ main (int argc, char **argv) dropMenu = optList[W_DROP].handle; titleWidget = optList[optList[W_TITLE].type != -1 ? W_TITLE : W_SMALL].handle; formWidget = XtParent(boardWidget); +#ifdef TODO_GTK XtSetArg(args[0], XtNbackground, &timerBackgroundPixel); XtSetArg(args[1], XtNforeground, &timerForegroundPixel); XtGetValues(optList[W_WHITE].handle, args, 2); @@ -1280,9 +1329,12 @@ main (int argc, char **argv) XtSetArg(args[1], XtNforeground, &buttonForegroundPixel); XtGetValues(optList[W_PAUSE].handle, args, 2); } +#endif AppendEnginesToMenu(appData.recentEngineList); +#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(). @@ -1290,13 +1342,16 @@ main (int argc, char **argv) /* * Create X checkmark bitmap and initialize option menu checks. */ +#ifdef TODO_GTK ReadBitmap(&xMarkPixmap, "checkmark.bm", checkmark_bits, checkmark_width, checkmark_height); +#endif InitMenuMarkers(); /* * Create an icon. */ +#ifdef TODO_GTK ReadBitmap(&wIconPixmap, "icon_white.bm", icon_white_bits, icon_white_width, icon_white_height); ReadBitmap(&bIconPixmap, "icon_black.bm", @@ -1305,27 +1360,34 @@ main (int argc, char **argv) i = 0; XtSetArg(args[i], XtNiconPixmap, iconPixmap); i++; XtSetValues(shellWidget, args, i); +#endif /* * Create a cursor for the board widget. */ +#ifdef TODO_GTK window_attributes.cursor = XCreateFontCursor(xDisplay, XC_hand2); XChangeWindowAttributes(xDisplay, xBoardWindow, CWCursor, &window_attributes); +#endif /* * Inhibit shell resizing. */ +#ifdef TODO_GTK shellArgs[0].value = (XtArgVal) &w; shellArgs[1].value = (XtArgVal) &h; XtGetValues(shellWidget, shellArgs, 2); shellArgs[4].value = shellArgs[2].value = w; shellArgs[5].value = shellArgs[3].value = h; // XtSetValues(shellWidget, &shellArgs[2], 4); +#endif 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(); @@ -1340,6 +1402,7 @@ main (int argc, char **argv) if (appData.animate || appData.animateDragging) CreateAnimVars(); +#ifdef TODO_GTK XtAugmentTranslations(formWidget, XtParseTranslationTable(globalTranslations)); @@ -1347,6 +1410,7 @@ main (int argc, char **argv) (XtEventHandler) MoveTypeInProc, NULL); XtAddEventHandler(shellWidget, StructureNotifyMask, False, (XtEventHandler) EventProc, NULL); +#endif /* [AS] Restore layout */ if( wpMoveHistory.visible ) { @@ -1386,9 +1450,11 @@ main (int argc, char **argv) InitPosition(TRUE); UpdateLogos(TRUE); // XtSetKeyboardFocus(shellWidget, formWidget); +#ifdef TODO_GTK XSetInputFocus(xDisplay, XtWindow(formWidget), RevertToPointerRoot, CurrentTime); XtAppMainLoop(appContext); +#endif if (appData.debugMode) fclose(debugFP); // [DM] debug return 0; } @@ -1482,6 +1548,7 @@ InsertPxlSize (char *pattern, int targetPxlSize) return base_fnt_lst; } +#ifdef TODO_GTK XFontSet CreateFontSet (char *base_fnt_lst) { @@ -1516,6 +1583,7 @@ CreateFontSet (char *base_fnt_lst) } return fntSet; } +#endif #else // not ENABLE_NLS /* * Find a font that matches "pattern" that is as close as @@ -1532,6 +1600,7 @@ FindFont (char *pattern, int targetPxlSize) char **fonts, *p, *best, *scalable, *scalableTail; int i, j, nfonts, minerr, err, pxlSize; +#ifdef TODO_GTK fonts = XListFonts(xDisplay, pattern, 999999, &nfonts); if (nfonts < 1) { fprintf(stderr, _("%s: no fonts match pattern %s\n"), @@ -1580,6 +1649,7 @@ FindFont (char *pattern, int targetPxlSize) pattern, targetPxlSize, p); } XFreeFontNames(fonts); +#endif return p; } #endif @@ -1588,8 +1658,10 @@ void ReadBitmap (Pixmap *pm, String name, unsigned char bits[], u_int wreq, u_int hreq) { if (bits != NULL) { +#ifdef TODO_GTK *pm = XCreateBitmapFromData(xDisplay, xBoardWindow, (char *) bits, wreq, hreq); +#endif } } @@ -1598,13 +1670,17 @@ EnableNamedMenuItem (char *menuRef, int state) { MenuItem *item = MenuNameToItem(menuRef); +#ifdef TODO_GTK if(item) XtSetSensitive(item->handle, state); +#endif } void EnableButtonBar (int state) { +#ifdef TODO_GTK XtSetSensitive(optList[W_BUTTON].handle, state); +#endif } @@ -1617,6 +1693,7 @@ SetMenuEnables (Enables *enab) } } +#ifdef TODO_GTK void KeyBindingProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) { // [HGM] new method of key binding: specify MenuItem(FlipView) in stead of FlipViewProc in translation string @@ -1625,22 +1702,28 @@ KeyBindingProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) item = MenuNameToItem(prms[0]); if(item) ((MenuProc *) item->proc) (); } +#endif +#ifdef TODO_GTK static void MenuEngineSelect (Widget w, caddr_t addr, caddr_t index) { RecentEngineEvent((int) (intptr_t) addr); } +#endif void AppendMenuItem (char *msg, int n) { +#ifdef TODO_GTK CreateMenuItem((Widget) optList[W_ENGIN].textValue, msg, (XtCallbackProc) MenuEngineSelect, n); +#endif } void SetupDropMenu () { +#ifdef TODO_GTK int i, j, count; char label[32]; Arg args[16]; @@ -1661,6 +1744,7 @@ SetupDropMenu () XtSetArg(args[j], XtNlabel, label); j++; XtSetValues(entry, args, j); } +#endif } static void @@ -1672,8 +1756,10 @@ do_flash_delay (unsigned long msec) void FlashDelay (int flash_delay) { +#ifdef TODO_GTK XSync(xDisplay, False); if(flash_delay) do_flash_delay(flash_delay); +#endif } double @@ -1686,6 +1772,7 @@ Fraction (int x, int start, int stop) static WindowPlacement wpNew; +#ifdef TODO_GTK void CoDrag (Widget sh, WindowPlacement *wp) { @@ -1716,9 +1803,11 @@ CoDrag (Widget sh, WindowPlacement *wp) wp->y += wpNew.y - wpMain.y; if(touch == 1) wp->x += wpNew.width - wpMain.width; else if(touch == 3) wp->y += wpNew.height - wpMain.height; +#ifdef TODO_GTK XtSetArg(args[j], XtNx, wp->x); j++; XtSetArg(args[j], XtNy, wp->y); j++; XtSetValues(sh, args, j); +#endif } void @@ -1740,7 +1829,11 @@ ReSize (WindowPlacement *wp) if(optList[W_BOARD].value > h) optList[W_BOARD].value = h; } +#ifdef TODO_GTK static XtIntervalId delayedDragID = 0; +#else +static int delayedDragID = 0; +#endif void DragProc () @@ -1764,21 +1857,25 @@ DragProc () delayedDragID = 0; // now drag executed, make sure next DelayedDrag will not cancel timer event (which could now be used by other) busy = 0; } - +#endif void DelayedDrag () { +#ifdef TODO_GTK if(delayedDragID) XtRemoveTimeOut(delayedDragID); // cancel pending delayedDragID = XtAppAddTimeOut(appContext, 200, (XtTimerCallbackProc) DragProc, (XtPointer) 0); // and schedule new one 50 msec later +#endif } void EventProc (Widget widget, caddr_t unused, XEvent *event) { +#ifdef TODO_GTK if(XtIsRealized(widget) && event->type == ConfigureNotify || appData.useStickyWindows) DelayedDrag(); // as long as events keep coming in faster than 50 msec, they destroy each other +#endif } /* @@ -1791,17 +1888,20 @@ DrawPositionProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) } +#ifdef TODO_GTK void HandlePV (Widget w, XEvent * event, String * params, Cardinal * nParams) { // [HGM] pv: walk PV MovePV(event->xmotion.x, event->xmotion.y, lineGap + BOARD_HEIGHT * (squareSize + lineGap)); } +#endif static int savedIndex; /* gross that this is global */ void CommentClick (Widget w, XEvent * event, String * params, Cardinal * nParams) { +#ifdef TODO_GTK String val; XawTextPosition index, dummy; Arg arg; @@ -1812,6 +1912,7 @@ CommentClick (Widget w, XEvent * event, String * params, Cardinal * nParams) ReplaceComment(savedIndex, val); if(savedIndex != currentMove) ToNrEvent(savedIndex); LoadVariation( index, val ); // [HGM] also does the actual moving to it, now +#endif } void @@ -1853,17 +1954,20 @@ void ThawUI () { if (!frozen) return; +#ifdef TODO_GTK XtRemoveGrab(optList[W_MESSG].handle); +#endif frozen = 0; } void ModeHighlight () { - Arg args[16]; static int oldPausing = FALSE; static GameMode oldmode = (GameMode) -1; char *wname; +#ifdef TODO_GTK + Arg args[16]; if (!boardWidget || !XtIsRealized(boardWidget)) return; @@ -1887,6 +1991,7 @@ ModeHighlight () XtSetValues(optList[W_PAUSE].handle, args, 2); } } +#endif wname = ModeToWidgetName(oldmode); if (wname != NULL) { @@ -1910,6 +2015,7 @@ ModeHighlight () * Button/menu procedures */ +#ifdef TODO_GTK /* this variable is shared between CopyPositionProc and SendPositionSelection */ char *selected_fen_position=NULL; @@ -1976,6 +2082,7 @@ SendPositionSelection (Widget w, Atom *selection, Atom *target, return False; } } +#endif /* note: when called from menu all parameters are NULL, so no clue what the * Widget which was clicked on was, or what the click event was @@ -1983,6 +2090,7 @@ SendPositionSelection (Widget w, Atom *selection, Atom *target, void CopySomething (char *src) { +#ifdef TODO_GTK selected_fen_position = src; /* * Set both PRIMARY (the selection) and CLIPBOARD, since we don't @@ -1999,8 +2107,10 @@ CopySomething (char *src) SendPositionSelection, NULL/* lose_ownership_proc */ , NULL/* transfer_done_proc */); +#endif } +#ifdef TODO_GTK /* function called when the data to Paste is ready */ static void PastePositionCB (Widget w, XtPointer client_data, Atom *selection, @@ -2012,12 +2122,14 @@ PastePositionCB (Widget w, XtPointer client_data, Atom *selection, EditPositionPasteFEN(fenstr); XtFree(value); } +#endif /* called when Paste Position button is pressed, * all parameters will be NULL */ void PastePositionProc () { +#ifdef TODO_GTK XtGetSelectionValue(menuBarWidget, appData.pasteSelection ? XA_PRIMARY: XA_CLIPBOARD(xDisplay), XA_STRING, /* (XtSelectionCallbackProc) */ PastePositionCB, @@ -2029,8 +2141,10 @@ PastePositionProc () CurrentTime ); return; +#endif } +#ifdef TODO_GTK /* note: when called from menu all parameters are NULL, so no clue what the * Widget which was clicked on was, or what the click event was */ @@ -2053,12 +2167,14 @@ PasteGameCB (Widget w, XtPointer client_data, Atom *selection, XtFree(value); LoadGameFromFile(gamePasteFilename, 0, gamePasteFilename, TRUE); } +#endif /* called when Paste Game button is pressed, * all parameters will be NULL */ void PasteGameProc () { +#ifdef TODO_GTK XtGetSelectionValue(menuBarWidget, appData.pasteSelection ? XA_PRIMARY: XA_CLIPBOARD(xDisplay), XA_STRING, /* (XtSelectionCallbackProc) */ PasteGameCB, @@ -2070,6 +2186,7 @@ PasteGameProc () CurrentTime ); return; +#endif } @@ -2082,29 +2199,34 @@ QuitWrapper (Widget w, XEvent *event, String *prms, Cardinal *nprms) int ShiftKeys () { // bassic primitive for determining if modifier keys are pressed + int i,j, k=0; +#ifdef TODO_GTK long int codes[] = { XK_Meta_L, XK_Meta_R, XK_Control_L, XK_Control_R, XK_Shift_L, XK_Shift_R }; char keys[32]; - int i,j, k=0; XQueryKeymap(xDisplay,keys); for(i=0; i<6; i++) { k <<= 1; j = XKeysymToKeycode(xDisplay, codes[i]); k += ( (keys[j>>3]&1<<(j&7)) != 0 ); } +#endif return k; } static void MoveTypeInProc (Widget widget, caddr_t unused, XEvent *event) { +#ifdef TODO_GTK char buf[10]; KeySym sym; int n = XLookupString(&(event->xkey), buf, 10, &sym, NULL); if ( n == 1 && *buf >= 32 // printable && !(ShiftKeys() & 0x3C) // no Alt, Ctrl ) BoxAutoPopUp (buf); +#endif } +#ifdef TODO_GTK static void UpKeyProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) { // [HGM] input: let up-arrow recall previous line from history @@ -2123,6 +2245,7 @@ EnterKeyProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) IcsKey(0); } + void TempBackwardProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) { @@ -2160,16 +2283,20 @@ ManInner (Widget w, XEvent *event, String *prms, Cardinal *nprms) snprintf(buf, sizeof(buf), "xterm -e man %s &", name); system(buf); } +#endif void ManProc () { // called from menu +#ifdef TODO_GTK ManInner(NULL, NULL, NULL, NULL); +#endif } void SetWindowTitle (char *text, char *title, char *icon) { +#ifdef TODO_GTK Arg args[16]; int i; if (appData.titleInWindow) { @@ -2182,6 +2309,7 @@ SetWindowTitle (char *text, char *title, char *icon) XtSetArg(args[i], XtNtitle, (XtArgVal) title); i++; XtSetValues(shellWidget, args, i); XSync(xDisplay, False); +#endif } @@ -2194,6 +2322,7 @@ NullXErrorCheck (Display *dpy, XErrorEvent *error_event) void DisplayIcsInteractionTitle (String message) { +#ifdef TODO_GTK if (oldICSInteractionTitle == NULL) { /* Magic to find the old window title, adapted from vim */ char *wina = getenv("WINDOWID"); @@ -2218,12 +2347,14 @@ DisplayIcsInteractionTitle (String message) } printf("\033]0;%s\007", message); fflush(stdout); +#endif } void DisplayTimerLabel (Option *opt, char *color, long timer, int highlight) { +#ifdef TODO_GTK char buf[MSG_SIZ]; Arg args[16]; Widget w = (Widget) opt->handle; @@ -2254,13 +2385,17 @@ DisplayTimerLabel (Option *opt, char *color, long timer, int highlight) } XtSetValues(w, args, 3); +#endif } +#ifdef TODO_GTK static Pixmap *clockIcons[] = { &wIconPixmap, &bIconPixmap }; +#endif void SetClockIcon (int color) { +#ifdef TODO_GTK Arg args[16]; Pixmap pm = *clockIcons[color]; if (iconPixmap != pm) { @@ -2268,8 +2403,10 @@ SetClockIcon (int color) XtSetArg(args[0], XtNiconPixmap, iconPixmap); XtSetValues(shellWidget, args, 1); } +#endif } +#ifdef TODO_GTK void DoInputCallback (caddr_t closure, int *source, XtInputId *xid) { @@ -2308,10 +2445,12 @@ DoInputCallback (caddr_t closure, int *source, XtInputId *xid) (is->func)(is, is->closure, is->buf, count, error); } } +#endif InputSourceRef AddInputSource (ProcRef pr, int lineByLine, InputCallback func, VOIDSTAR closure) { +#ifdef TODO_GTK InputSource *is; ChildProc *cp = (ChildProc *) pr; @@ -2335,16 +2474,21 @@ AddInputSource (ProcRef pr, int lineByLine, InputCallback func, VOIDSTAR closure (XtPointer) is); is->closure = closure; return (InputSourceRef) is; +#else + return (InputSourceRef) 0; +#endif } void RemoveInputSource (InputSourceRef isr) { +#ifdef TODO_GTK InputSource *is = (InputSource *) isr; if (is->xid == 0) return; XtRemoveInput(is->xid); is->xid = 0; +#endif } #ifndef HAVE_USLEEP @@ -2362,6 +2506,7 @@ FrameAlarm (int sig) void FrameDelay (int time) { +#ifdef TODO_GTK struct itimerval delay; XSync(xDisplay, False); @@ -2379,6 +2524,7 @@ FrameDelay (int time) delay.it_interval.tv_usec = delay.it_value.tv_usec = 0; setitimer(ITIMER_REAL, &delay, NULL); } +#endif } #else @@ -2386,7 +2532,9 @@ FrameDelay (int time) void FrameDelay (int time) { +#ifdef TODO_GTK XSync(xDisplay, False); +#endif if (time > 0) usleep(time * 1000); } diff --git a/xboard.h b/xboard.h index ca2a705..5a7b25e 100644 --- a/xboard.h +++ b/xboard.h @@ -148,22 +148,25 @@ void StopPV P((Widget w, XEvent * event, String * params, Cardinal * nParams)); extern char memoTranslations[]; - +#if TODO_GTK extern Widget shells[]; -extern int dialogError; extern Widget formWidget, shellWidget, boardWidget, menuBarWidget; extern Display *xDisplay; extern Window xBoardWindow; -extern int squareSize; extern Pixmap xMarkPixmap, wIconPixmap, bIconPixmap; -extern char *layoutName; extern Pixel timerForegroundPixel, timerBackgroundPixel, dialogColor, buttonColor; extern Atom wm_delete_window; +extern GC coordGC; +extern Dimension textHeight; // of message widget in board window +#else +extern void *shells[]; +#endif +extern int dialogError; +extern int squareSize; +extern char *layoutName; extern int useImages, useImageSqs; extern char ICSInputTranslations[]; extern char *selected_fen_position; -extern GC coordGC; -extern Dimension textHeight; // of message widget in board window #define TOPLEVEL 1 /* preference item; 1 = make popup windows toplevel */ diff --git a/xengineoutput.c b/xengineoutput.c index 78269b8..f03b870 100644 --- a/xengineoutput.c +++ b/xengineoutput.c @@ -48,26 +48,6 @@ extern char *getenv(); # include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "common.h" #include "frontend.h" #include "backend.h" @@ -84,8 +64,6 @@ extern char *getenv(); # define N_(s) s #endif -#include - // [HGM] pixmaps of some ICONS used in the engine-outut window #include "pixmaps/WHITE_14.xpm" #include "pixmaps/BLACK_14.xpm" @@ -97,16 +75,18 @@ extern char *getenv(); /* Module variables */ +#ifdef TODO_GTK static int currentPV, highTextStart[2], highTextEnd[2]; static Pixmap icons[8]; // [HGM] this front-end array translates back-end icon indicator to handle static Widget memoWidget; - +#endif static void ReadIcon (char *pixData[], int iconNr, Widget w) { int r; +#ifdef TODO_GTK if ((r=XpmCreatePixmapFromData(xDisplay, XtWindow(w), pixData, &(icons[iconNr]), @@ -114,11 +94,13 @@ ReadIcon (char *pixData[], int iconNr, Widget w) fprintf(stderr, _("Error %d loading icon image\n"), r); exit(1); } +#endif } void InitEngineOutput (Option *opt, Option *memo2) { // front-end, because it must have access to the pixmaps +#ifdef TODO_GTK Widget w = opt->handle; memoWidget = memo2->handle; @@ -130,19 +112,23 @@ InitEngineOutput (Option *opt, Option *memo2) ReadIcon(PONDER_14, nPondering, w); ReadIcon(THINK_14, nThinking, w); ReadIcon(ANALYZE_14, nAnalyzing, w); +#endif } void DrawWidgetIcon (Option *opt, int nIcon) { // as we are already in X front-end, so do X-stuff here +#ifdef TODO_GTK Arg arg; XtSetArg(arg, XtNleftBitmap, (XtArgVal) icons[nIcon]); XtSetValues(opt->handle, &arg, 1); +#endif } void InsertIntoMemo (int which, char * text, int where) { +#ifdef TODO_GTK XawTextBlock t; Widget edit; @@ -158,6 +144,7 @@ InsertIntoMemo (int which, char * text, int where) highTextStart[which] += len; highTextEnd[which] += len; XawTextSetSelection( edit, highTextStart[which], highTextEnd[which] ); } +#endif } //--------------------------------- PV walking --------------------------------------- @@ -172,6 +159,7 @@ Any: select-start() extend-end() SelectPV(0) \n \ void SelectPV (Widget w, XEvent * event, String * params, Cardinal * nParams) { // [HGM] pv: translate click to PV line, and load it for display +#ifdef TODO_GTK String val; int start, end; XawTextPosition index, dummy; @@ -188,15 +176,18 @@ SelectPV (Widget w, XEvent * event, String * params, Cardinal * nParams) XawTextSetSelection( w, start, end ); highTextStart[currentPV] = start; highTextEnd[currentPV] = end; } +#endif } void StopPV (Widget w, XEvent * event, String * params, Cardinal * nParams) { // [HGM] pv: on right-button release, stop displaying PV +#ifdef TODO_GTK XawTextUnsetSelection( w ); highTextStart[currentPV] = highTextEnd[currentPV] = 0; UnLoadPV(); XtCallActionProc(w, "beginning-of-file", event, NULL, 0); +#endif } //------------------------- Ctrl-C copying of memo texts --------------------------- @@ -209,6 +200,7 @@ StopPV (Widget w, XEvent * event, String * params, Cardinal * nParams) // cloned from CopyPositionProc. Abuse selected_fen_position to hold selection +#ifdef TODO_GTK Boolean SendPositionSelection(Widget w, Atom *selection, Atom *target, Atom *type_return, XtPointer *value_return, unsigned long *length_return, int *format_return); // from xboard.c @@ -243,6 +235,7 @@ CopyMemoProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) CurrentTime ); } +#endif //------------------------------- pane switching ----------------------------------- @@ -250,6 +243,7 @@ void ResizeWindowControls (int mode) { // another hideous kludge: to have only a single pane, we resize the // second to 5 pixels (which makes it too small to display anything) +#ifdef TODO_GTK Widget form1, form2; Arg args[16]; int j; @@ -282,5 +276,6 @@ ResizeWindowControls (int mode) XtSetArg(args[j], XtNheight, (XtArgVal) (ew_height/2)); j++; XtSetValues(form2, args, j); } +#endif } diff --git a/xgamelist.c b/xgamelist.c index 50367b1..82e43bf 100644 --- a/xgamelist.c +++ b/xgamelist.c @@ -43,38 +43,6 @@ extern char *getenv(); # include #endif -#include -#include -#include -#include -#if USE_XAW3D -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#else -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif - #include "common.h" #include "backend.h" #include "xboard.h" @@ -102,6 +70,7 @@ char filterTranslations[] = "Return: SetFilterProc() \n"; +#ifdef TODO_GTK void LoadSelectedProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) { @@ -115,4 +84,5 @@ SetFilterProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) { SetFilter(); } +#endif diff --git a/xhistory.c b/xhistory.c index bf5a26d..ca26228 100644 --- a/xhistory.c +++ b/xhistory.c @@ -25,26 +25,6 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "common.h" #include "backend.h" #include "xhistory.h" @@ -70,13 +50,16 @@ extern Option historyOptions[]; void HighlightMove (int from, int to, Boolean highlight) { +#ifdef TODO_GTK if(highlight) XawTextSetSelection( historyOptions[0].handle, from, to ); // for lack of a better method, use selection for highighting +#endif } void ScrollToCurrent (int caretPos) { +#ifdef TODO_GTK Arg args[10]; char *s; int len; @@ -92,6 +75,7 @@ ScrollToCurrent (int caretPos) XtSetArg(args[0], XtNinsertPosition, caretPos); // this triggers scrolling in Xaw XtSetArg(args[1], XtNdisplayCaret, False); XtSetValues(historyOptions[0].handle, args, 2); +#endif } @@ -104,9 +88,11 @@ char historyTranslations[] = void SelectMove (Widget w, XEvent * event, String * params, Cardinal * nParams) { +#ifdef TODO_GTK XawTextPosition index, dummy; XawTextGetSelectionPos(w, &index, &dummy); FindMoveByCharIndex( index ); // [HGM] also does the actual moving to it, now +#endif } diff --git a/xoptions.c b/xoptions.c index b3bea5a..fb12fa3 100644 --- a/xoptions.c +++ b/xoptions.c @@ -47,27 +47,6 @@ extern char *getenv(); #endif #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include @@ -95,6 +74,7 @@ static Option *currentOption; void UnCaret () { +#ifdef TODO_GTK Arg args[2]; if(previous) { @@ -102,11 +82,13 @@ UnCaret () XtSetValues(previous, args, 1); } previous = NULL; +#endif } void SetFocus (Widget w, XtPointer data, XEvent *event, Boolean *b) { +#ifdef TODO_GTK Arg args[2]; char *s; int j; @@ -120,12 +102,15 @@ SetFocus (Widget w, XtPointer data, XEvent *event, Boolean *b) XtSetValues(w, args, j); XtSetKeyboardFocus((Widget) data, w); previous = w; +#endif } void BoardFocus () { +#ifdef TODO_GTK XtSetKeyboardFocus(shellWidget, formWidget); +#endif } //--------------------------- Engine-specific options menu ---------------------------------- @@ -133,6 +118,7 @@ BoardFocus () int dialogError; Option *dialogOptions[NrOfDialogs]; +#ifdef TODO_GTK static Arg layoutArgs[] = { { XtNborderWidth, 0 }, { XtNdefaultDistance, 0 }, @@ -142,79 +128,97 @@ static Arg formArgs[] = { { XtNborderWidth, 0 }, { XtNresizable, (XtArgVal) True }, }; +#endif void MarkMenuItem (char *menuRef, int state) { MenuItem *item = MenuNameToItem(menuRef); +#ifdef TODO_GTK if(item) { Arg args[2]; XtSetArg(args[0], XtNleftBitmap, state ? xMarkPixmap : None); XtSetValues(item->handle, args, 1); } +#endif } void GetWidgetText (Option *opt, char **buf) { +#ifdef TODO_GTK Arg arg; XtSetArg(arg, XtNstring, buf); XtGetValues(opt->handle, &arg, 1); +#endif } void SetWidgetText (Option *opt, char *buf, int n) { +#ifdef TODO_GTK Arg arg; XtSetArg(arg, XtNstring, buf); XtSetValues(opt->handle, &arg, 1); if(n >= 0) SetFocus(opt->handle, shells[n], NULL, False); +#endif } void GetWidgetState (Option *opt, int *state) { +#ifdef TODO_GTK Arg arg; XtSetArg(arg, XtNstate, state); XtGetValues(opt->handle, &arg, 1); +#endif } void SetWidgetState (Option *opt, int state) { +#ifdef TODO_GTK Arg arg; XtSetArg(arg, XtNstate, state); XtSetValues(opt->handle, &arg, 1); +#endif } void SetWidgetLabel (Option *opt, char *buf) { +#ifdef TODO_GTK Arg arg; XtSetArg(arg, XtNlabel, (XtArgVal) buf); XtSetValues(opt->handle, &arg, 1); +#endif } void SetDialogTitle (DialogClass dlg, char *title) { +#ifdef TODO_GTK Arg args[16]; XtSetArg(args[0], XtNtitle, title); XtSetValues(shells[dlg], args, 1); +#endif } void LoadListBox (Option *opt, char *emptyText) { +#ifdef TODO_GTK static char *dummyList[2]; dummyList[0] = emptyText; // empty listboxes tend to crash X, so display user-supplied warning string instead XawListChange(opt->handle, *(char*)opt->target ? opt->target : dummyList, 0, 0, True); +#endif } int ReadScroll (Option *opt, float *top, float *bottom) { // retreives fractions of top and bottom of thumb +#ifdef TODO_GTK Arg args[16]; Widget w = XtParent(opt->handle); // viewport Widget v = XtNameToWidget(w, "vertical"); @@ -225,12 +229,14 @@ ReadScroll (Option *opt, float *top, float *bottom) XtSetArg(args[j], XtNtopOfThumb, top); j++; XtGetValues(v, args, j); *bottom = *top + h; +#endif return TRUE; } void SetScroll (Option *opt, float f) { // sets top of thumb to given fraction +#ifdef TODO_GTK static char *params[3] = { "", "Continuous", "Proportional" }; static XEvent event; Widget w = XtParent(opt->handle); // viewport @@ -241,17 +247,21 @@ SetScroll (Option *opt, float f) XtCallActionProc(v, "NotifyThumb", &event, params, 0); // XtCallActionProc(v, "NotifyScroll", &event, params+2, 1); XtCallActionProc(v, "EndScroll", &event, params, 0); +#endif } void HighlightListBoxItem (Option *opt, int nr) { +#ifdef TODO_GTK XawListHighlight(opt->handle, nr); +#endif } void HighlightWithScroll (Option *opt, int sel, int max) { +#ifdef TODO_GTK float top, bottom, f, g; HighlightListBoxItem(opt, sel); if(!ReadScroll(opt, &top, &bottom)) return; // no scroll bar @@ -262,31 +272,40 @@ HighlightWithScroll (Option *opt, int sel, int max) if(sel < (3*top + bottom)/4) f = (sel - 0.25f*(bottom-top))/max; if(f < 0.f) f = 0.; if(f + 1.f/max > 1.f) f = 1. - 1./max; if(f != g) SetScroll(opt, f); +#endif } int SelectedListBoxItem (Option *opt) { +#ifdef TODO_GTK XawListReturnStruct *rs; rs = XawListShowCurrent(opt->handle); return rs->list_index; +#else + return 0; +#endif } void FocusOnWidget (Option *opt, DialogClass dlg) { UnCaret(); +#ifdef TODO_GTK XtSetKeyboardFocus(shells[dlg], opt->handle); +#endif } void SetIconName (DialogClass dlg, char *name) { +#ifdef TODO_GTK Arg args[16]; int j = 0; XtSetArg(args[j], XtNiconName, (XtArgVal) name); j++; // XtSetArg(args[j], XtNtitle, (XtArgVal) name); j++; XtSetValues(shells[dlg], args, j); +#endif } static void @@ -304,6 +323,7 @@ CheckCallback (Widget ww, XtPointer client_data, XEvent *event, Boolean *b) static void SpinCallback (Widget w, XtPointer client_data, XtPointer call_data) { +#ifdef TODO_GTK String name, val; Arg args[16]; char buf[MSG_SIZ], *p; @@ -332,11 +352,13 @@ SpinCallback (Widget w, XtPointer client_data, XtPointer call_data) } else return; snprintf(buf, MSG_SIZ, "%d", j); SetWidgetText(opt, buf, TransientDlg); +#endif } static void ComboSelect (Widget w, caddr_t addr, caddr_t index) // callback for all combo items { +#ifdef TODO_GTK Arg args[16]; Option *opt = dialogOptions[((intptr_t)addr)>>24]; // applicable option list int i = ((intptr_t)addr)>>16 & 255; // option number @@ -355,11 +377,13 @@ ComboSelect (Widget w, caddr_t addr, caddr_t index) // callback for all combo it XtSetArg(args[0], XtNlabel, _(((char**)opt[i].choice)[j])); XtSetValues(opt[i].handle, args, 1); +#endif } Widget CreateMenuItem (Widget menu, char *msg, XtCallbackProc CB, int n) { +#ifdef TODO_GTK int j=0; Widget entry; Arg args[16]; @@ -370,11 +394,15 @@ CreateMenuItem (Widget menu, char *msg, XtCallbackProc CB, int n) entry = XtCreateManagedWidget("item", smeBSBObjectClass, menu, args, j+1); XtAddCallback(entry, XtNcallback, CB, (caddr_t)(intptr_t) n); return entry; +#else + return NULL; +#endif } static Widget CreateComboPopup (Widget parent, Option *opt, int n, int fromList, int def) { // fromList determines if the item texts are taken from a list of strings, or from a menu table +#ifdef TODO_GTK int i; Widget menu, entry; Arg arg; @@ -396,6 +424,9 @@ CreateComboPopup (Widget parent, Option *opt, int n, int fromList, int def) } } return menu; +#else + return NULL; +#endif } char moveTypeInTranslations[] = @@ -411,17 +442,24 @@ char *translationTable[] = { // beware: order is essential! filterTranslations, gameListTranslations, memoTranslations }; -void +void * shells[NrOfDialogs]; + AddHandler (Option *opt, int nr) { +#ifdef TODO_GTK XtOverrideTranslations(opt->handle, XtParseTranslationTable(translationTable[nr])); +#endif } //----------------------------Generic dialog -------------------------------------------- // cloned from Engine Settings dialog (and later merged with it) +#ifdef TODO_GTK Widget shells[NrOfDialogs]; +#else +void *shells[NrOfDialogs]; +#endif DialogClass parents[NrOfDialogs]; WindowPlacement *wp[NrOfDialogs] = { // Beware! Order must correspond to DialogClass enum NULL, &wpComment, &wpTags, NULL, NULL, NULL, NULL, &wpMoveHistory, &wpGameList, &wpEngineOutput, &wpEvalGraph, @@ -437,6 +475,7 @@ DialogExists (DialogClass n) void RaiseWindow (DialogClass dlg) { +#ifdef TODO_GTK static XEvent xev; Window root = RootWindow(xDisplay, DefaultScreen(xDisplay)); Atom atom = XInternAtom (xDisplay, "_NET_ACTIVE_WINDOW", False); @@ -458,11 +497,13 @@ RaiseWindow (DialogClass dlg) XFlush(xDisplay); XSync(xDisplay, False); +#endif } int PopDown (DialogClass n) { // pops down any dialog created by GenericPopUp (or returns False if it wasn't up), unmarks any associated marked menu +#ifdef TODO_GTK int j; Arg args[10]; Dimension windowH, windowW; Position windowX, windowY; @@ -491,9 +532,11 @@ PopDown (DialogClass n) currentOption = dialogOptions[TransientDlg]; // just in case a transient dialog was up (to allow its check and combo callbacks to work) RaiseWindow(parents[n]); if(parents[n] == BoardWindow) XtSetKeyboardFocus(shellWidget, formWidget); +#endif return 1; } +#ifdef TODO_GTK void GenericPopDown (Widget w, XEvent *event, String *prms, Cardinal *nprms) { // to cause popdown through a translation (Delete Window button!) @@ -504,23 +547,27 @@ GenericPopDown (Widget w, XEvent *event, String *prms, Cardinal *nprms) PopDown(dlg); shells[dlg] = sh; // restore } +#endif int AppendText (Option *opt, char *s) { + int len; +#ifdef TODO_GTK XawTextBlock t; char *v; - int len; GetWidgetText(opt, &v); len = strlen(v); t.ptr = s; t.firstPos = 0; t.length = strlen(s); t.format = XawFmt8Bit; XawTextReplace(opt->handle, len, len, &t); +#endif return len; } void SetColor (char *colorName, Option *box) { // sets the color of a widget +#ifdef TODO_GTK Arg args[5]; Pixel buttonColor; XrmValue vFrom, vTo; @@ -536,19 +583,23 @@ SetColor (char *colorName, Option *box) } else buttonColor = timerBackgroundPixel; XtSetArg(args[0], XtNbackground, buttonColor);; XtSetValues(box->handle, args, 1); +#endif } void ColorChanged (Widget w, XtPointer data, XEvent *event, Boolean *b) { // for detecting a typed change in color char buf[10]; +#ifdef TODO_GTK if ( (XLookupString(&(event->xkey), buf, 2, NULL, NULL) == 1) && *buf == '\r' ) RefreshColor((int)(intptr_t) data, 0); +#endif } static void GraphEventProc(Widget widget, caddr_t client_data, XEvent *event) { // handle expose and mouse events on Graph widget +#ifdef TODO_GTK Dimension w, h; Arg args[16]; int j, button=10, f=1, sizing=0; @@ -613,20 +664,24 @@ GraphEventProc(Widget widget, caddr_t client_data, XEvent *event) XtPopupSpringLoaded(opt->handle); } XSync(xDisplay, False); +#endif } void GraphExpose (Option *opt, int x, int y, int w, int h) { +#ifdef TODO_GTK XExposeEvent e; if(!opt->handle) return; e.x = x; e.y = y; e.width = w; e.height = h; e.count = -1; e.type = Expose; // count = -1: kludge to suppress sizing GraphEventProc(opt->handle, (caddr_t) opt, (XEvent *) &e); // fake expose event +#endif } static void GenericCallback (Widget w, XtPointer client_data, XtPointer call_data) { // all Buttons in a dialog (including OK, cancel) invoke this +#ifdef TODO_GTK String name; Arg args[16]; char buf[MSG_SIZ]; @@ -652,11 +707,13 @@ GenericCallback (Widget w, XtPointer client_data, XtPointer call_data) } else ((ButtonCallback*) currentOption[data].target)(data); shells[dlg] = oldSh; // in case of multiple instances, restore previous (as this one could be popped down now) +#endif } void TabProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) { // for transfering focus to the next text-edit +#ifdef TODO_GTK Option *opt; for(opt = currentOption; opt->type != EndMark; opt++) { if(opt->handle == w) { @@ -670,11 +727,13 @@ TabProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) } } } +#endif } void WheelProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) { // for scrolling a widget seen through a viewport with the mouse wheel (ListBox!) +#ifdef TODO_GTK int j=0, n = atoi(prms[0]); static char *params[3] = { "", "Continuous", "Proportional" }; Arg args[16]; @@ -697,6 +756,7 @@ WheelProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) XtCallActionProc(v, "NotifyThumb", event, params, 0); // XtCallActionProc(w, "NotifyScroll", event, params+2, 1); XtCallActionProc(v, "EndScroll", event, params, 0); +#endif } static char *oneLiner = @@ -710,6 +770,7 @@ static char scrollTranslations[] = static void SqueezeIntoBox (Option *opt, int nr, int width) { // size buttons in bar to fit, clipping button names where necessary +#ifdef TODO_GTK int i, wtot = 0; Dimension widths[20], oldWidths[20]; Arg arg; @@ -731,12 +792,14 @@ SqueezeIntoBox (Option *opt, int nr, int width) XtSetValues(opt[i].handle, &arg, 1); } opt->min = wtot; +#endif } int SetPositionAndSize (Arg *args, Widget leftNeigbor, Widget topNeigbor, int b, int w, int h, int chaining) { // sizing and positioning most widgets have in common int j = 0; +#ifdef TODO_GTK // first position the widget w.r.t. earlier ones if(chaining & 1) { // same row: position w.r.t. last (on current row) and lastrow XtSetArg(args[j], XtNfromVert, topNeigbor); j++; @@ -763,12 +826,14 @@ SetPositionAndSize (Arg *args, Widget leftNeigbor, Widget topNeigbor, int b, int if(b == 3) b = 1; // border XtSetArg(args[j], XtNborderWidth, b); j++; +#endif return j; } int GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent, int modal, int top) { +#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; @@ -1163,11 +1228,13 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent XtSetValues(popup, args, j); } RaiseWindow(dlgNr); +#endif return 1; // tells caller he must do initialization (e.g. add specific event handlers) } /* function called when the data to Paste is ready */ +#ifdef TODO_GTK static void SendTextCB (Widget w, XtPointer client_data, Atom *selection, Atom *type, XtPointer value, unsigned long *len, int *format) @@ -1181,10 +1248,12 @@ SendTextCB (Widget w, XtPointer client_data, Atom *selection, SendString(buf); XtFree(value); } +#endif void SendText (int n) { +#ifdef TODO_GTK char *p = (char*) textOptions[n].choice; if(strstr(p, "$name")) { XtGetSelectionValue(menuBarWidget, @@ -1194,18 +1263,22 @@ SendText (int n) CurrentTime ); } else SendString(p); +#endif } void SetInsertPos (Option *opt, int pos) { +#ifdef TODO_GTK Arg args[16]; XtSetArg(args[0], XtNinsertPosition, pos); XtSetValues(opt->handle, args, 1); // SetFocus(opt->handle, shells[InputBoxDlg], NULL, False); // No idea why this does not work, and the following is needed: // XSetInputFocus(xDisplay, XtWindow(opt->handle), RevertToPointerRoot, CurrentTime); +#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) @@ -1218,11 +1291,14 @@ TypeInProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) GenericCallback (w, (XtPointer)(intptr_t) (30000 + n + (dlgNr<<16)), NULL); } } +#endif void HardSetFocus (Option *opt) { +#ifdef TODO_GTK XSetInputFocus(xDisplay, XtWindow(opt->handle), RevertToPointerRoot, CurrentTime); +#endif } -- 1.7.0.4