chess

Volker Bartheld dr_versaeg at freenet.de
Wed Oct 17 02:45:48 PDT 2007


Hi!

>>> what I can make a chess board?
>>> scalable chess board and chess figures. anybody have idea/example?
> but WHAT I write the board?
> Do You have any idea / code?

Example: No.
Idea: Yes.

What about this:

Create a frame, override the OnPaint() handler (EVT_PAINT,
http://www.wxwidgets.org/manuals/stable/wx_wxpaintevent.html#wxpaintevent).
You'll receive a wxPaintDC. Then you'll use wxDC::DrawRectangle() to paint
black rectangles onto that DC, probably with a surrounding frame for the
whole board. Get or draw a set of bitmaps (see
http://www.wxwidgets.org/manuals/stable/wx_wxdc.html#wxdcdrawrectangle and
http://www.wxwidgets.org/manuals/stable/wx_wxbitmap.html#wxbitmap)
with wxDC::DrawBitmap() from .GIF/.PNG/.BMP/.TIF-sources with alpha
channel. You might want to rescale the bitmaps with wxImage::Resize()
(http://www.wxwidgets.org/manuals/stable/wx_wximage.html#wximageresize) to
the size you need or alternatively switch to a TTF-font with chess figures
using wxDC::DrawText() and rely on the OS's scaling functions. Another
solution would be a temporary wxMemoryDC and then wxDC::Blit()
(http://www.wxwidgets.org/manuals/stable/wx_wxdc.html#wxdcblit) which
usually is hardware-supportet and therefore pretty fast.

If you look at the "wxBombs" demo in the distribution, you should get a raw
idea of what drawing into the client area of a frame is all about.

Good luck!

Volker


-- 
mailto:  V B A R T H E L D at G M X dot D E






More information about the wx-users mailing list