wxPaintEvent(3erl)

๐Ÿ“ฆ
version 25.3.2.8 ยท 5 versions
, in ubuntu noble

๐Ÿ’– NAME ๐Ÿ’–

wxPaintEvent(3erl) โ€” straight out of the Erlang Module Definition manual โ€” is literally Functions for wxPaintEvent class. Bestie, this is your paint-event bestie page. ๐ŸŽจโœจ


๐ŸŒˆ DESCRIPTION ๐ŸŒˆ

Okay so picture this: a paint event gets sent when a windowโ€™s contents need to be repainted. Thatโ€™s the whole vibe check. ๐Ÿ–Œ๏ธ

The handler of this event must create a wxPaintDC object and use it for painting the window contents. No cap, thatโ€™s mandatory. For example:

(the source page says โ€œFor example:โ€ right here, but thereโ€™s no actual snippet shown โ€” not me staring at an empty example block ๐Ÿ˜ญ)
Important bestie warning: you must not create other kinds of wxDC โ€” like wxClientDC or wxWindowDC โ€” in EVT_PAINT handlers. And also donโ€™t create wxPaintDC outside of these event handlers. Periodt. ๐Ÿšซ๐Ÿ’…

You can optimize painting by retrieving the rectangles that have been damaged and only repainting those. Iconic efficiency behavior. The rectangles are in terms of the client area, and theyโ€™re unscrolled, so youโ€™ll need to do some calculations using the current view position to obtain logical, scrolled units. Math era, unfortunately. ๐Ÿงฎโœจ

Here is an example of using the wxRegionIterator (not implemented in wx) class:

(again, the source page promises an example right here but shows no code โ€” the snippet is lowkey MIA ๐Ÿซ )
Remark: please notice that in general it is impossible to change the drawing of a standard control (such as wxButton), so you shouldnโ€™t attempt to handle paint events for them. Even if it might work on some platforms, this is inherently not portable and wonโ€™t work everywhere. So likeโ€ฆ donโ€™t do it. ๐Ÿ™ˆ

See: Overview events ๐Ÿ‘€

This class is derived (and can use functions) from: wxEvent. Family tree slay. ๐ŸŒณ๐Ÿ’–

wxWidgets docs: wxPaintEvent ๐Ÿ“š


โœจ EVENTS โœจ

Use wxEvtHandler:connect/3 with wxPaintEventType to subscribe to events of this type. Thatโ€™s the subscription link, bestie โ€” click subscribe and get your paint-event notifications. ๐Ÿ””๐ŸŽ€


๐ŸŽ€ DATA TYPES ๐ŸŽ€

wxPaintEvent() = wx:wx_object()

wxPaint() = #wxPaint{type = wxPaintEvent:wxPaintEventType()}

wxPaintEventType() = paint

Literal data-type royalty. paint is the only type in the wxPaintEventType() lineup here, and it ate. ๐Ÿ‘‘๐Ÿ’…


shoutout to the wxWidgets team โ€” source/version wx 2.2.2.1, manual page wxPaintEvent(3erl) โ€” for this whole paint-event situation. The footer doesnโ€™t give us a date, so no fake-date energy from me, bestie. ๐Ÿซถ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from