chess
Volker Bartheld
dr_versaeg at freenet.de
Thu Oct 18 11:47:43 PDT 2007
Hi!
>> Create a frame, override the OnPaint() handler (EVT_PAINT,
>> http://www.wxwidgets.org/manuals/stable/wx_wxpaintevent.html#wxpaintevent).
>> You'll receive a wxPaintDC.
wxDC::GetSize() reports the size of the device context. Please read the
docu (http://www.wxwidgets.org/manuals/stable/wx_wxdc.html#wxdcgetsize) it
more or less says it all.
> ok, I write this one:
> http://dark-code.bulix.org/g85xr4-58309
And - what happens? Did you add jpeg-support? Did bmp show up? (Hint:
Prepending m_ to member variables add a great deal of readability to the
code). What is the problem?
>> 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.
> hm... where I have to put that?
Did you look at wxBombs? BombsCanvas::OnPaint() pretty much has everything
in there:
- A new bitmap is created with the correct size.
- It is selected into the memory DC.
- DrawField() draws the field on the memdc using wxDC::DrawLine(),
wxDC::DrawText(), wxPen, wxBrush, etc., etc.
- The memdc is blitted into the paintdc.
So I would strongly suggest understanding and than stripping down wxBombs
(or another sample prog) to your needs, adding sizers to contain further
controls (like MyTextCtrl) and implement event handlers to react to user
input.
Btw, what are you intending with MyTextCtrl? To-date it's not of very much
use, never added to any sizer. Should it log/accept the moves of the
player?
> How I can know the wxForm is resized?
I don't know of any class that is called wxForm. Anything that inherits
from wxWindow emits EVT_SIZE events after it has been sized. If you want
special behaviour _while_ the window is sizing, I think EVT_PAINT is the
right macro.
> what change this code?
My time is a bit limited and your question a bit vague. Please have a look
at the wxLife demo - it's paint handler LifeCanvas::OnPaint() is quite
advanced in that respect and redraws regions of the canvas when they are
damaged.
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