#include "frontend.h"
#include "backend.h"
-#include "xboard.h"
#include "xevalgraph.h"
#include "board.h"
#include "menus.h"
int x1, x2, y1, y2;
} gridSegments[BOARD_RANKS + BOARD_FILES + 2];
+static int dual = 0;
+
void
SwitchWindow ()
{
cairo_surface_t *cstmp = csBoardWindow;
csBoardWindow = csDualBoard;
- if(!csDualBoard && cstmp) {
- int boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap);
- int boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap);
- csBoardWindow = cairo_xlib_surface_create(xDisplay, xBoardWindow, DefaultVisual(xDisplay, 0), boardWidth, boardHeight);
+ dual = !dual;
+ if(!csDualBoard) {
+ csBoardWindow = GetOutputSurface(&dualOptions[3], 0, 0);
+ dual = 1;
}
+ csDualBoard = cstmp;
}
void
{ // [HGM] resize is functional now, but for board format changes only (nr of ranks, files)
int boardWidth, boardHeight;
int i;
- static Dimension oldWidth, oldHeight;
+ static int oldWidth, oldHeight;
static VariantClass oldVariant;
static int oldMono = -1, oldTwoBoards = 0;
+ extern Widget formWidget;
if(!formWidget) return;
}
}
-int
+void
CreateAnyPieces ()
{ // [HGM] taken out of main
if (appData.pngDirectory[0] != NULLCHAR) {
}
CreatePNGBoard(appData.liteBackTextureFile, 1);
CreatePNGBoard(appData.darkBackTextureFile, 0);
- cairoAnimate = *appData.pngDirectory && useTexture == 3
- && strstr(appData.liteBackTextureFile, ".png") && strstr(appData.darkBackTextureFile, ".png");
- return cairoAnimate;
}
void
int boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap);
int boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap);
if(!csBoardWindow) {
- csBoardWindow = cairo_xlib_surface_create(xDisplay, xBoardWindow, DefaultVisual(xDisplay, 0), boardWidth, boardHeight);
+ csBoardWindow = GetOutputSurface(&mainOptions[W_BOARD], 0, 0);
csBoardBackup = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, boardWidth, boardHeight);
}
}
DrawGrid()
{
DoDrawGrid(csBoardWindow);
- DoDrawGrid(csBoardBackup);
+ if(!dual) DoDrawGrid(csBoardBackup);
}
void
DrawBorder (int x, int y, int type)
{
DoDrawBorder(csBoardWindow, x, y, type);
- DoDrawBorder(csBoardBackup, x, y, type);
+ if(!dual) DoDrawBorder(csBoardBackup, x, y, type);
}
static int
int w, h;
if(!logo || !handle) return;
- cs = cairo_xlib_surface_create(xDisplay, XtWindow(handle), DefaultVisual(xDisplay, 0), appData.logoSize, appData.logoSize/2);
+ cs = GetOutputSurface(handle, appData.logoSize, appData.logoSize/2);
img = cairo_image_surface_create_from_png (logo);
w = cairo_image_surface_get_width (img);
h = cairo_image_surface_get_height (img);
{
DrawSeekOpen();
DoDrawOneSquare (csBoardWindow, x, y, piece, square_color, marker, string, align);
+ if(!dual)
DoDrawOneSquare (csBoardBackup, x, y, piece, square_color, marker, string, align);
}
DrawPolygon (Pnt arrow[], int nr)
{
DoDrawPolygon(csBoardWindow, arrow, nr);
- DoDrawPolygon(csBoardBackup, arrow, nr);
+ if(!dual) DoDrawPolygon(csBoardBackup, arrow, nr);
}
void DelayedDrag P((void));
void ReadBitmap P((Pixmap *pm, String name, unsigned char bits[],
u_int wreq, u_int hreq));
+cairo_surface_t *GetOutputSurface P((Option *opt, int w, int h));
extern XFontStruct *coordFontStruct, *countFontStruct;
extern Font coordFontID, countFontID;
extern int xScreen;
+extern int lineGap, squareSize;
extern Pixel lightSquareColor, darkSquareColor, whitePieceColor, blackPieceColor,
highlightSquareColor, premoveHighlightColor;
// defined in draw.c
void CreateGCs P((int redo));
void NewSurfaces P((void));
-int CreateAnyPieces P((void));
+void CreateAnyPieces P((void));
void CreatePNGPieces P((void));
void CreateGrid P((void));
XtGetValues(shellWidget, shellArgs, 2);
shellArgs[4].value = shellArgs[2].value = w;
shellArgs[5].value = shellArgs[3].value = h;
- if(!CreateAnyPieces()) XtSetValues(shellWidget, &shellArgs[2], 4);
+// XtSetValues(shellWidget, &shellArgs[2], 4);
marginW = w - boardWidth; // [HGM] needed to set new shellWidget size when we resize board
marginH = h - boardHeight;
CatchDeleteWindow(shellWidget, "QuitProc");
+ CreateAnyPieces();
CreateGrid();
if(appData.logoSize)
}
}
+cairo_surface_t *
+GetOutputSurface(Option *opt, int w, int h)
+{
+ if(w == 0) w = lineGap + BOARD_WIDTH * (squareSize + lineGap);
+ if(h == 0) h = lineGap + BOARD_HEIGHT * (squareSize + lineGap);
+ return cairo_xlib_surface_create(xDisplay, XtWindow(opt->handle), DefaultVisual(xDisplay, 0), w, h);
+}
static void
do_flash_delay (unsigned long msec)