From: Kristof B. <kr...@re...> - 2015-05-14 12:11:59
|
Hi, Looking at the source code, it seems that virtual member functions are not supported yet by wxHaskell. I've been thinking about several solutions, and I have come up with a solution that seems reasonable: For example to subclass wxGridCellRenderer, define a typeclass gridCellRenderer and a newGridCellRenderer contructor: class WxGridCellRenderer where wxGridCellRendererDraw :: wxGrid a -> wxGridCellAttr <http://docs.wxwidgets.org/3.0/classwx_grid_cell_attr.html> -> wxDC <http://docs.wxwidgets.org/3.0/classwx_d_c.html> Rect <http://docs.wxwidgets.org/3.0/classwx_rect.html> -> Int -> Int -> Bool -> IO () wxGridCellRendererDraw = wxGridCellRenderDrawDefault wxGridCellRendererGetBestSize :: (..) wxGridCellRendererGetBestSize = wxGridCellRendererGetBestSizeDefault (...) newGridCellRenderer :: (WxGridCellRenderer a) => IO a This creates a new gridCellRenderer, were the virtual functions call the functions in the instance. On the C side, create a subclass, with a constructor that takes the function definitions for all the virtual functions. The default definitions are simply the base class functions WxGridCellRenderer::Draw(), etc... It does need a lot of boilerplate, that may be automated via wxdirect. -- Kristof Bastiaensen |