void CommentClick P((Widget w, XEvent * event,
String * params, Cardinal * nParams));
void ICSInputBoxPopUp P((void));
-void FileNamePopUp P((char *label, char *def, char *filter,
- FileProc proc, char *openMode));
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));
void ICSInitScript P((void));
void SelectMove P((Widget w, XEvent * event, String * params, Cardinal * nParams));
void update_ics_width P(());
-int get_term_width P(());
int CopyMemoProc P(());
-void SetupDropMenu P((void));
/*
* XBoard depends on Xt R4 or higher
XtAppContext appContext;
char *layoutName;
-FileProc fileProc;
-char *fileOpenMode;
char installDir[] = "."; // [HGM] UCI: needed for UCI; probably needs run-time initializtion
Position commentX = -1, commentY = -1;
return xBoardWindow != 0;
}
-void SwitchWindow()
+void
+SwitchWindow ()
{
extern Option dualOptions[];
static Window dual;
CreateGrid();
CreateAnyPieces();
+ if(appData.logoSize)
+ { // locate and read user logo
+ char buf[MSG_SIZ];
+ snprintf(buf, MSG_SIZ, "%s/%s.xpm", appData.logoDir, UserName());
+ XpmReadFileToPixmap(xDisplay, xBoardWindow, buf, (Pixmap *) &userLogo, NULL, NULL);
+ }
+
if (appData.animate || appData.animateDragging)
CreateAnimVars();
gameInfo.boardWidth = 0; // [HGM] pieces: kludge to ensure InitPosition() calls InitDrawingSizes()
InitPosition(TRUE);
+ UpdateLogos(TRUE);
// XtSetKeyboardFocus(shellWidget, formWidget);
XSetInputFocus(xDisplay, XtWindow(formWidget), RevertToPointerRoot, CurrentTime);
}
void
-EnableMenuItem (char *menuRef, int state)
+EnableNamedMenuItem (char *menuRef, int state)
{
MenuItem *item = MenuNameToItem(menuRef);
SetMenuEnables (Enables *enab)
{
while (enab->name != NULL) {
- EnableMenuItem(enab->name, enab->value);
+ EnableNamedMenuItem(enab->name, enab->value);
enab++;
}
}
return 1;
}
+void
+DrawLogo (void *handle, void *logo)
+{
+ if(!logo || !handle) return;
+ XCopyArea(xDisplay, (Pixmap) logo, XtWindow((Widget) handle), wlPieceGC,
+ 0, 0, appData.logoSize, appData.logoSize/2, 0, 0);
+}
+
static void
BlankSquare (int x, int y, int color, ChessSquare piece, Drawable dest, int fac)
{ // [HGM] extra param 'fac' for forcing destination to (0,0) for copying to animation buffer
PopDown(CommentDlg);
}
-static char *openName;
-FILE *openFP;
-
-void
-DelayedLoad ()
-{
- (void) (*fileProc)(openFP, 0, openName);
-}
-
-void
-FileNamePopUp (char *label, char *def, char *filter, FileProc proc, char *openMode)
-{
- fileProc = proc; /* I can't see a way not */
- fileOpenMode = openMode; /* to use globals here */
- { // [HGM] use file-selector dialog stolen from Ghostview
- // int index; // this is not supported yet
- Browse(BoardWindow, label, (def[0] ? def : NULL), filter, False, openMode, &openName, &openFP);
- }
-}
-
/* Disable all user input other than deleting the window */
static int frozen = 0;
MarkMenuItem("Mode.MachineMatch", matchMode && matchGame < appData.matchGames);
/* Maybe all the enables should be handled here, not just this one */
- EnableMenuItem("Mode.Training", gameMode == Training || gameMode == PlayFromGameFile);
+ EnableNamedMenuItem("Mode.Training", gameMode == Training || gameMode == PlayFromGameFile);
+
+ DisplayLogos(optList[W_WHITE-1].handle, optList[W_BLACK+1].handle);
}
}
void
+ManProc ()
+{ // called from menu
+ ManInner(NULL, NULL, NULL, NULL);
+}
+
+void
SetWindowTitle (char *text, char *title, char *icon)
{
Arg args[16];
foregroundOrWarningColor = lowTimeWarningColor;
if (appData.clockMode) {
- snprintf(buf, MSG_SIZ, "%s: %s", color, TimeString(timer));
+ snprintf(buf, MSG_SIZ, "%s:%s%s", color, appData.logoSize && !partnerUp ? "\n" : " ", TimeString(timer));
XtSetArg(args[0], XtNlabel, buf);
} else {
snprintf(buf, MSG_SIZ, "%s ", color);
if(appData.monoMode) arrow[nr] = arrow[0], XDrawLines(xDisplay, xBoardWindow, darkSquareGC, pts, nr+1, CoordModeOrigin);
}
+static void
+LoadLogo (ChessProgramState *cps, int n, Boolean ics)
+{
+ char buf[MSG_SIZ], *logoName = buf;
+ if(appData.logo[n][0]) {
+ logoName = appData.logo[n];
+ } else if(appData.autoLogo) {
+ if(ics) { // [HGM] logo: in ICS mode second can be used for ICS
+ sprintf(buf, "%s/%s.xpm", appData.logoDir, appData.icsHost);
+ } else if(appData.directory[n] && appData.directory[n][0]) {
+ sprintf(buf, "%s/%s.xpm", appData.logoDir, cps->tidy);
+ }
+ }
+ if(logoName[0])
+ XpmReadFileToPixmap(xDisplay, xBoardWindow, logoName, (Pixmap *) &(cps->programLogo), NULL, NULL);
+}
+
void
UpdateLogos (int displ)
{
- return; // no logos in XBoard yet
+ if(optList[W_WHITE-1].handle == NULL) return;
+ LoadLogo(&first, 0, 0);
+ LoadLogo(&second, 1, appData.icsActive);
+ if(displ) DisplayLogos(optList[W_WHITE-1].handle, optList[W_BLACK+1].handle);
+ return;
}