Skip to content

Commit 507bea3

Browse files
committed
Add setIconRaw to set window icon to void*
1 parent 2551c0a commit 507bea3

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

c-src/Fl_WindowC.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,9 @@ FL_EXPORT_C(fl_Window, Fl_OverriddenWindow_NewXY_WithLabel)(int x, int y, int w,
764764
Fl_RGB_Image* rgb = static_cast<Fl_RGB_Image*>(i);
765765
(static_cast<Fl_DerivedWindow*>(win))->icon(rgb);
766766
}
767+
FL_EXPORT_C(void,Fl_Window_set_icon_raw)(fl_Window win,const void * ic){
768+
(static_cast<Fl_DerivedWindow*>(win))->icon(ic);
769+
}
767770
FL_EXPORT_C(int,Fl_Window_shown)(fl_Window win){
768771
return (static_cast<Fl_DerivedWindow*>(win))->shown();
769772
}

c-src/Fl_WindowC.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ EXPORT {
247247
FL_EXPORT_C_HEADER(void,Fl_Window_set_xclass,(fl_Window win,const char* c));
248248
FL_EXPORT_C_HEADER(const void*,Fl_Window_icon,(fl_Window win));
249249
FL_EXPORT_C_HEADER(void,Fl_Window_set_icon,(fl_Window win,fl_RGB_Image ic));
250+
FL_EXPORT_C_HEADER(void,Fl_Window_set_icon_raw,(fl_Window win,const void* ic));
250251
FL_EXPORT_C_HEADER(int,Fl_Window_shown,(fl_Window win));
251252
FL_EXPORT_C_HEADER(void,Fl_Window_iconize,(fl_Window win));
252253
FL_EXPORT_C_HEADER(int,Fl_Window_x_root,(fl_Window win));

src/Graphics/UI/FLTK/LowLevel/Base/Window.chs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ instance (Parent a RGBImage, impl ~ (Maybe( Ref a ) -> IO ())) => Op (SetIcon (
332332
Just copyI -> withRef win $ \winPtr -> withRef copyI $ \iPtr -> setIcon' winPtr iPtr
333333
Nothing -> throwIO (userError "Could not make a copy of icon image")
334334

335+
{# fun Fl_Window_set_icon_raw as setIconRaw' { id `Ptr ()', id `Ptr ()' } -> `()' supressWarningAboutRes #}
336+
instance (impl ~ (Ptr a -> IO ())) => Op (SetIconRaw ()) WindowBase orig impl where
337+
runOp _ _ win bitmapPtr = withRef win $ \winPtr -> setIconRaw' winPtr (castPtr bitmapPtr)
338+
335339
{# fun Fl_Window_shown as shown' { id `Ptr ()' } -> `Bool' toBool #}
336340
instance (impl ~ ( IO (Bool))) => Op (Shown ()) WindowBase orig impl where
337341
runOp _ _ win = withRef win $ \winPtr -> shown' winPtr
@@ -559,7 +563,9 @@ instance (impl ~ ( IO ())) => Op (Flush ()) WindowBase orig impl where
559563
--
560564
-- setDefaultCursorWithFgBg :: 'Ref' 'WindowBase' -> 'CursorType' -> ('Maybe' 'Color', 'Maybe' 'Color') -> 'IO' ()
561565
--
562-
-- setIcon:: ('Parent' a 'RGBImage') => 'Ref' 'WindowBase' -> 'Maybe'( 'Ref' a ) -> 'IO' ()
566+
-- setIcon :: ('Parent' a 'RGBImage') => 'Ref' 'WindowBase' -> 'Maybe' ( 'Ref' a ) -> 'IO' ()
567+
--
568+
-- setIconRaw :: 'Ref' 'WindowBase' -> 'Ptr' a -> 'IO' ()
563569
--
564570
-- setIconlabel :: 'Ref' 'WindowBase' -> 'T.Text' -> 'IO' ()
565571
--

src/Graphics/UI/FLTK/LowLevel/Hierarchy.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ module Graphics.UI.FLTK.LowLevel.Hierarchy
327327
getIcon,
328328
SetIcon,
329329
setIcon,
330+
SetIconRaw,
331+
setIconRaw,
330332
Shown,
331333
shown,
332334
Iconize,
@@ -2036,6 +2038,7 @@ type WindowBaseFuncs =
20362038
(SetDefaultCursor
20372039
(SetDefaultCursorWithFgBg
20382040
(SetIcon
2041+
(SetIconRaw
20392042
(SetIconlabel
20402043
(SetLabel
20412044
(SetLabelWithIconlabel
@@ -2052,7 +2055,7 @@ type WindowBaseFuncs =
20522055
(SizeRangeWithArgs
20532056
(WaitForExpose
20542057
(Flush
2055-
())))))))))))))))))))))))))))))))))))))))))))))))))))))))
2058+
()))))))))))))))))))))))))))))))))))))))))))))))))))))))))
20562059
type instance Functions WindowBase = WindowBaseFuncs
20572060

20582061
data CWindow parent
@@ -2095,6 +2098,7 @@ MAKE_METHOD(GetXclass,getXclass)
20952098
MAKE_METHOD(SetXclass,setXclass)
20962099
MAKE_METHOD(GetIcon,getIcon)
20972100
MAKE_METHOD(SetIcon,setIcon)
2101+
MAKE_METHOD(SetIconRaw,setIconRaw)
20982102
MAKE_METHOD(Shown,shown)
20992103
MAKE_METHOD(Iconize,iconize)
21002104
MAKE_METHOD(GetXRoot,getXRoot)

0 commit comments

Comments
 (0)