void *userLogo;
void
-DisplayLogos (void *w1, void *w2)
+DisplayLogos (Option *w1, Option *w2)
{
void *whiteLogo = first.programLogo, *blackLogo = second.programLogo;
if(appData.autoLogo) {
Option *
LogoW (int n, int x, int y)
{
- if(n == 10) DisplayLogos(mainOptions[W_WHITE-1].handle, NULL);
+ if(n == 10) DisplayLogos(&mainOptions[W_WHITE-1], NULL);
return NULL;
}
Option *
LogoB (int n, int x, int y)
{
- if(n == 10) DisplayLogos(NULL, mainOptions[W_BLACK+1].handle);
+ if(n == 10) DisplayLogos(NULL, &mainOptions[W_BLACK+1]);
return NULL;
}
void SetScroll P((Option *opt, float f));
void AddHandler P((Option *opt, int nr));
void SendText P((int n));
-void DisplayLogos P((void *left, void *right));
+void DisplayLogos P((Option *left, Option *right));
void Browse P((DialogClass dlg, char *label, char *proposed, char *ext,
Boolean pathFlag, char *mode, char **name, FILE **fp));
void InitDrawingParams P((int reload)); // in draw.c
-void DrawLogo P((void *handle, void *logo));
+void DrawLogo P((Option *opt, void *logo));
void ErrorPopUp P((char *title, char *text, int modal));
int ShiftKeys P((void));
void SetClockIcon P((int color));
#define SOLID 0
#define OUTLINE 1
Boolean cairoAnimate;
-static cairo_surface_t *csBoardWindow, *csBoardBackup, *csDualBoard;
+static cairo_surface_t *csBoardWindow, *csDualBoard;
static cairo_surface_t *pngPieceImages[2][(int)BlackPawn+4]; // png 256 x 256 images
static cairo_surface_t *pngPieceBitmaps[2][(int)BlackPawn]; // scaled pieces as used
static cairo_surface_t *pngPieceBitmaps2[2][(int)BlackPawn+4]; // scaled pieces in store
csBoardWindow = csDualBoard;
dual = !dual;
if(!csDualBoard) {
- csBoardWindow = GetOutputSurface(&dualOptions[3], 0, 0);
+ csBoardWindow = DRAWABLE(dualOptions+3);
dual = 1;
}
csDualBoard = cstmp;
}
void
-DrawLogo (void *handle, void *logo)
+DrawLogo (Option *opt, void *logo)
{
- cairo_surface_t *img, *cs;
+ cairo_surface_t *img;
cairo_t *cr;
int w, h;
- if(!logo || !handle) return;
- cs = GetOutputSurface(handle, appData.logoSize, appData.logoSize/2);
+ if(!logo || !opt) return;
img = cairo_image_surface_create_from_png (logo);
w = cairo_image_surface_get_width (img);
h = cairo_image_surface_get_height (img);
- cr = cairo_create(cs);
+ cr = cairo_create(DRAWABLE(opt));
cairo_scale(cr, (float)appData.logoSize/w, appData.logoSize/(2.*h));
cairo_set_source_surface (cr, img, 0, 0);
cairo_paint (cr);
cairo_destroy (cr);
cairo_surface_destroy (img);
- cairo_surface_destroy (cs);
+ GraphExpose(opt, 0, 0, appData.logoSize, appData.logoSize/2);
}
static void
*------------------------------------------------------------------------
** See the file ChangeLog for a revision history. */
+#define DRAWABLE(X) ((cairo_surface_t *) ((X)->choice))
+
// defined in xboard.c
int MakeColors P((void));
void ResizeBoardWindow P((int w, int h, int inhibit));
}
}
-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)
{
/* Maybe all the enables should be handled here, not just this one */
EnableNamedMenuItem("Mode.Training", gameMode == Training || gameMode == PlayFromGameFile);
- DisplayLogos(optList[W_WHITE-1].handle, optList[W_BLACK+1].handle);
+ DisplayLogos(&optList[W_WHITE-1], &optList[W_BLACK+1]);
}
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);
+ if(displ) DisplayLogos(&optList[W_WHITE-1], &optList[W_BLACK+1]);
return;
}
sizing = ((w != graph->max || h != graph->value) && ((XExposeEvent*)event)->count >= 0);
graph->max = w; graph->value = h;
if(sizing && ((XExposeEvent*)event)->count > 0) { graph->max = 0; return; } // don't bother if further exposure is pending during resize
- if(!graph->textValue || sizing) {
- // create surfaces of new size for widget and buffer
+ if(!graph->textValue || sizing) { // create surfaces of new size for display widget
if(graph->textValue) cairo_surface_destroy((cairo_surface_t *)graph->textValue);
graph->textValue = (char*) cairo_xlib_surface_create(xDisplay, XtWindow(widget), DefaultVisual(xDisplay, 0), w, h);
+ }
+ if(sizing) { // the memory buffer was already created in GenericPopup(),
+ // to give drawing routines opportunity to use it befor first expose event
+ // (which are only processed when main gets to the event loop, so after all init!)
+ // so only change when size is no longer good
if(graph->choice) cairo_surface_destroy((cairo_surface_t *) graph->choice);
graph->choice = (char**) cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w, h);
}
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);