That would need the FlexibleInstances extension though.

On 14-05-15 14:11, Kristof Bastiaensen wrote:
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



------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y


_______________________________________________
wxhaskell-devel mailing list
wxhaskell-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxhaskell-devel

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
wxhaskell-devel mailing list
wxhaskell-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxhaskell-devel

Reply via email to