removed/commented out more X-stuff: xDisplay, shellWidget and some other small things
[xboard.git] / xhistory.c
index ee865fd..c220e9a 100644 (file)
@@ -44,31 +44,12 @@ extern char *getenv();
 # include <unistd.h>
 #endif
 
-#include <X11/Intrinsic.h>
-#include <X11/StringDefs.h>
-#include <X11/Shell.h>
-#include <X11/Xaw/Dialog.h>
-#include <X11/Xaw/Form.h>
-#include <X11/Xaw/List.h>
-#include <X11/Xaw/Label.h>
-#include <X11/Xaw/SimpleMenu.h>
-#include <X11/Xaw/SmeBSB.h>
-#include <X11/Xaw/SmeLine.h>
-#include <X11/Xaw/Box.h>
-#include <X11/Xaw/Paned.h>
-#include <X11/Xaw/MenuButton.h>
-#include <X11/cursorfont.h>
-#include <X11/Xaw/Text.h>
-#include <X11/Xaw/AsciiText.h>
-#include <X11/Xaw/Viewport.h>
-
 #include "common.h"
 #include "frontend.h"
 #include "backend.h"
 #include "xboard.h"
 #include "xhistory.h"
 #include "gettext.h"
-#include "gtk/gtk.h"
 
 #ifdef ENABLE_NLS
 # define  _(s) gettext (s)
@@ -78,28 +59,12 @@ extern char *getenv();
 # define N_(s)  s
 #endif
 
-#define _LL_ 100
-
-extern Widget formWidget, shellWidget, boardWidget, menuBarWidget;
-extern Display *xDisplay;
-extern int squareSize;
-extern Pixmap xMarkPixmap;
-extern char *layoutName;
-
 extern GtkWidget               *GUI_History;
 extern GtkListStore            *LIST_MoveHistory;
 
-
-struct History{
-  String *Nr,*white,*black;
-  int     aNr;  /* space actually alocated */
-  Widget mvn,mvw,mvb,vbox,viewport,sh;
-  char Up;
-};
-
-struct History *hist=0;
 String dots=" ... ";
 Position gameHistoryX, gameHistoryY;
+Dimension gameHistoryW, gameHistoryH;
 
 void
 HistoryPopDown(object, user_data)
@@ -113,6 +78,7 @@ HistoryPopDown(object, user_data)
 void HistoryMoveProc(Widget w, XtPointer closure, XtPointer call_data)
 {
     int to;
+    /*
     XawListReturnStruct *R = (XawListReturnStruct *) call_data;
     if (w == hist->mvn || w == hist->mvw) {
       to=2*R->list_index-1;
@@ -122,6 +88,7 @@ void HistoryMoveProc(Widget w, XtPointer closure, XtPointer call_data)
       to=2*R->list_index;
       ToNrEvent(to);
     }
+    */
 }
 
 
@@ -131,6 +98,9 @@ void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current)
   char movewhite[2*MOVE_LEN],moveblack[2*MOVE_LEN],move[2*MOVE_LEN];
   GtkTreeIter iter;
 
+  /* TODO need to add highlights for current move */
+  /* TODO need to add navigation by keyboard or mouse (double click on move) */
+
   /* first clear everything, do we need this? */
   gtk_list_store_clear(LIST_MoveHistory);
 
@@ -179,6 +149,7 @@ void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current)
          strcpy(moveblack,"");
        };
     }
+
   /* check if ther is a white move left */
   if(movewhite[0])
     {
@@ -192,25 +163,11 @@ void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current)
                          2, moveblack,
                          -1);
     };
+
+  //TODO
+  //  EvalGraphSet( first, last, current, pvInfoList ); // piggy-backed
   
   return;
-  
-  
-  if(current<0){
-    // XawListUnhighlight(hist->mvw);
-    // XawListUnhighlight(hist->mvb);
-  }
-  else if((current%2)==0){
-    // XawListHighlight(hist->mvw, current/2+1);
-    // XawListUnhighlight(hist->mvb);
-  }
-  else{
-    // XawListUnhighlight(hist->mvw);
-    // if(current) XawListHighlight(hist->mvb, current/2+1);
-    // else XawListUnhighlight(hist->mvb);
-  }
-
-return;
 }
 
 void HistoryCreate()
@@ -222,6 +179,143 @@ void HistoryCreate()
              <Key>Right: ForwardProc() \n";
 
     return;
+    /*-------- create the widgets ---------------*/
+//<<<<<<< HEAD
+//    j = 0;
+//    XtSetArg(args[j], XtNresizable, True);  j++;
+//    XtSetArg(args[j], XtNallowShellResize, True);  j++;
+//#if TOPLEVEL
+//    hist->sh = historyShell =
+//      XtCreatePopupShell(_("Move list"), topLevelShellWidgetClass,
+//                      shellWidget, args, j);
+//#else
+//    hist->sh = historyShell =
+//      XtCreatePopupShell(_("Move list"), transientShellWidgetClass,
+//                      shellWidget, args, j);
+//#endif
+//    j = 0;
+//    XtSetArg(args[j], XtNborderWidth, 0); j++;
+//    XtSetArg(args[j], XtNdefaultDistance, 0);  j++;
+//      layout =
+//      XtCreateManagedWidget(layoutName, formWidgetClass, hist->sh,
+//                         args, j);
+//
+//    j = 0;
+//    XtSetArg(args[j], XtNborderWidth, 0); j++;
+//    XtSetArg(args[j], XtNresizable, True);  j++;
+//
+//    form =
+//      XtCreateManagedWidget("form", formWidgetClass, layout, args, j);
+//
+//    j = 0;
+//    XtSetArg(args[j], XtNtop, XtChainTop);  j++;
+//    XtSetArg(args[j], XtNbottom, XtChainBottom);  j++;
+//    XtSetArg(args[j], XtNleft, XtChainLeft);  j++;
+//    XtSetArg(args[j], XtNright, XtChainRight);  j++;
+//
+//    XtSetArg(args[j], XtNborderWidth, 1); j++;
+//    XtSetArg(args[j], XtNresizable, False);  j++;
+//    XtSetArg(args[j], XtNallowVert, True); j++;
+//    XtSetArg(args[j], XtNallowHoriz, True);  j++;
+//    XtSetArg(args[j], XtNforceBars, False); j++;
+//    XtSetArg(args[j], XtNheight, 280); j++;
+//    hist->viewport =
+//      XtCreateManagedWidget("viewport", viewportWidgetClass,
+//                         form, args, j);
+//    j=0;
+//    XtSetArg(args[j], XtNborderWidth, 0); j++;
+//    XtSetArg(args[j], XtNorientation,XtorientHorizontal);j++;
+//    hist->vbox =
+//      XtCreateManagedWidget("vbox", formWidgetClass, hist->viewport, args, j);
+//
+//    j=0;
+//    XtSetArg(args[j], XtNtop, XtChainTop);  j++;
+//    XtSetArg(args[j], XtNbottom, XtChainTop);  j++;
+//    XtSetArg(args[j], XtNleft, XtChainLeft);  j++;
+//    XtSetArg(args[j], XtNright, XtChainLeft);  j++;
+//
+//    XtSetArg(args[j], XtNdefaultColumns, 1);  j++;
+//    XtSetArg(args[j], XtNforceColumns, True);  j++;
+//    XtSetArg(args[j], XtNverticalList, True);  j++;
+//    XtSetArg(args[j], XtNborderWidth, 0); j++;
+//    XtSetArg(args[j], XtNresizable,True);j++;
+//    XtSetArg(args[j], XtNleft, XtChainLeft);  j++;
+//    hist->mvn = XtCreateManagedWidget("movesn", listWidgetClass,
+//                                   hist->vbox, args, j);
+//    XtAddCallback(hist->mvn, XtNcallback, HistoryMoveProc, (XtPointer) hist);
+//
+//    j=0;
+//    XtSetArg(args[j], XtNtop, XtChainTop);  j++;
+//    XtSetArg(args[j], XtNbottom, XtChainTop);  j++;
+//    XtSetArg(args[j], XtNleft, XtChainLeft);  j++;
+//    XtSetArg(args[j], XtNright, XtRubber);  j++;
+//
+//    XtSetArg(args[j], XtNdefaultColumns, 1);  j++;
+//    XtSetArg(args[j], XtNforceColumns, True);  j++;
+//    XtSetArg(args[j], XtNverticalList, True);  j++;
+//    XtSetArg(args[j], XtNborderWidth, 0); j++;
+//    XtSetArg(args[j], XtNresizable,True);j++;
+//    XtSetArg(args[j], XtNfromHoriz, hist->mvn);  j++;
+//    hist->mvw = XtCreateManagedWidget("movesw", listWidgetClass,
+//                                   hist->vbox, args, j);
+//    XtAddCallback(hist->mvw, XtNcallback, HistoryMoveProc, (XtPointer) hist);
+//
+//    j=0;
+//    XtSetArg(args[j], XtNtop, XtChainTop);  j++;
+//    XtSetArg(args[j], XtNbottom, XtChainTop);  j++;
+//    XtSetArg(args[j], XtNleft, XtRubber);  j++;
+//    XtSetArg(args[j], XtNright,  XtRubber);  j++;
+//
+//    XtSetArg(args[j], XtNdefaultColumns, 1);  j++;
+//    XtSetArg(args[j], XtNforceColumns, True);  j++;
+//    XtSetArg(args[j], XtNverticalList, True);  j++;
+//    XtSetArg(args[j], XtNborderWidth, 0); j++;
+//    XtSetArg(args[j], XtNresizable,True);j++;
+//    XtSetArg(args[j], XtNfromHoriz, hist->mvw);  j++;
+//    hist->mvb = XtCreateManagedWidget("movesb", listWidgetClass,
+//                                   hist->vbox, args, j);
+//    XtAddCallback(hist->mvb, XtNcallback, HistoryMoveProc, (XtPointer) hist);
+//
+//    j=0;
+//    XtSetArg(args[j], XtNbottom, XtChainBottom);  j++;
+//    XtSetArg(args[j], XtNtop, XtChainBottom);  j++;
+//    XtSetArg(args[j], XtNleft, XtChainLeft);  j++;
+//    XtSetArg(args[j], XtNright, XtChainLeft);  j++;
+//    XtSetArg(args[j], XtNfromVert, hist->viewport);  j++;
+//    b_close= XtCreateManagedWidget(_("Close"), commandWidgetClass,
+//                                form, args, j);
+//    XtAddCallback(b_close, XtNcallback, HistoryPopDown, (XtPointer) 0);
+//
+//    XtAugmentTranslations(hist->sh,XtParseTranslationTable (trstr));
+//
+//    XtRealizeWidget(hist->sh);
+//    CatchDeleteWindow(hist->sh, "HistoryPopDown");
+//
+//    for(i=1;i<hist->aNr;i++){
+//      strcpy(hist->white[i],dots);
+//      strcpy(hist->black[i],"");
+//     }
+//
+//    if(wpMoveHistory.width > 0) {
+//      gameHistoryW = wpMoveHistory.width;
+//      gameHistoryH = wpMoveHistory.height;
+//      gameHistoryX = wpMoveHistory.x;
+//      gameHistoryY = wpMoveHistory.y;
+//    }
+//
+//  // [HGM] restore old position
+//  if(gameHistoryW > 0) {
+//  j = 0;
+//    XtSetArg(args[j], XtNx, gameHistoryX);  j++;
+//  XtSetArg(args[j], XtNy, gameHistoryY);  j++;
+//    XtSetArg(args[j], XtNwidth, gameHistoryW);  j++;
+//    XtSetArg(args[j], XtNheight, gameHistoryH);  j++;
+//  XtSetValues(hist->sh, args, j);
+//  }
+//    XtRealizeWidget(hist->sh);
+//
+//    return hist->sh;
+//
 }
 
 void
@@ -240,21 +334,17 @@ HistoryShowProc(object, user_data)
      GtkObject *object;
      gpointer user_data;
 {
-  if (!hist) 
-    {
-      HistoryCreate();
-      HistoryPopUp();
-    } 
-  else if (hist->Up) 
-    {
-      HistoryPopDown(NULL,NULL);
-    } 
-  else 
-    {
-      HistoryPopUp();
-    }
-  ToNrEvent(currentMove);
+  HistoryCreate();
+  HistoryPopUp();
+  //TODO:  ToNrEvent(currentMove);
 
   return;
 }
 
+Boolean
+MoveHistoryIsUp()
+{
+  // TODO
+  return 0;
+  //  return hist && hist->Up;
+}