deech / fltkhs

Haskell bindings to FLTK GUI toolkit.
MIT License
190 stars 24 forks source link

Add setIconRaw to set window icon to void* #161

Closed mtolly closed 4 years ago

mtolly commented 4 years ago

I know you fixed setIcon to take an RGBImage in #154, but this readds (with correct type) the version that takes a void* as setIconRaw (feel free to change, wasn't sure what a good name would be).

This version takes a platform-specific icon format. The reason I'd like it is on Windows, I use this to pass the .ico from the executable itself to be the window icon, which produces a nicer 16x16 small icon than passing my normal large icon file and having FLTK scale it down (.ico on top, scaled larger .png on bottom):

icon-comparison

This is done like so (inside appropriate ifdefs):

foreign import ccall "&fl_display" fl_display :: Ptr HINSTANCE

... = do
  disp <- peek fl_display
  icon <- loadIcon (Just disp) $ intPtrToPtr 1
  FL.setIconRaw window icon

where HINSTANCE and loadIcon come from the Win32 package.

Also I wasn't sure if it makes sense to accept Ptr a or Ptr (). I went with the first but it doesn't really make a difference to me.

deech commented 4 years ago

Thanks for this PR, unfortunately this function is deprecated so it may go away ( although FLTK hasn't cut a release in long enough that I think you're ok for a year at least :) ). Ok if I merge this with a {-# DEPRECATED ... #-} pragma?

mtolly commented 4 years ago

Oh dang, I didn't notice that deprecation... Sure, that's fine by me, I'll keep an eye on if it goes away at some point.