Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add toolMenuFromBitmap function (requested by Bernd Holzmueller).

Ignore-this: 4554f704bc90617ce767e2cb51816857

darcs-hash:20090102051307-c1071-7e46b3f6be547a3e70d144901640df898a70b8e9.gz
  • Loading branch information...
commit d31a83f3b0014c76e456d4095c131c1d76d9b867 1 parent 1fd5a0c
@shelarcy shelarcy authored
Showing with 17 additions and 11 deletions.
  1. +16 −10 wx/src/Graphics/UI/WX/Menu.hs
  2. +1 −1  wxc/src/eljdc.cpp
View
26 wx/src/Graphics/UI/WX/Menu.hs
@@ -38,7 +38,7 @@ module Graphics.UI.WX.Menu
, menuItemOnCommandRes, menuLine, menuSub, menuRadioItem
-- * Tool bar
, ToolBar, toolBar, toolBarEx
- , ToolBarItem, toolMenu, toolItem, toolControl, tool
+ , ToolBarItem, toolMenu, toolMenuFromBitmap, toolItem, toolControl, tool
-- * Status bar
, StatusField, statusBar, statusField, statusWidth
-- * Deprecated
@@ -534,19 +534,25 @@ tool (ToolBarItem toolbar id isToggle)
-- corresponding menu item.
toolMenu :: ToolBar a -> MenuItem a -> String -> FilePath -> [Prop ToolBarItem] -> IO ToolBarItem
toolMenu toolbar menuitem label bitmapPath props
+ = withBitmapFromFile bitmapPath $ \bitmap ->
+ toolMenuFromBitmap toolbar menuitem label bitmap props
+
+-- | This is a generalized version of 'toolMenu' function. You can specify 'Bitmap' that is
+-- loaded from any other place instead of using 'FilePath' directly.
+toolMenuFromBitmap :: ToolBar a -> MenuItem a -> String -> Bitmap b -> [Prop ToolBarItem] -> IO ToolBarItem
+toolMenuFromBitmap toolbar menuitem label bitmap props
= do isToggle <- get menuitem checkable
id <- get menuitem identity
lhelp <- get menuitem help
shelp <- get menuitem help
- withBitmapFromFile bitmapPath $ \bitmap ->
- do toolBarAddTool2 toolbar id label bitmap nullBitmap
- (if isToggle then wxITEM_CHECK else wxITEM_NORMAL)
- shelp lhelp
- let t = ToolBarItem (downcastToolBar toolbar) id isToggle
- set t props
- toolBarRealize toolbar
- return t
-
+ toolBarAddTool2 toolbar id label bitmap nullBitmap
+ (if isToggle then wxITEM_CHECK else wxITEM_NORMAL)
+ shelp lhelp
+ let t = ToolBarItem (downcastToolBar toolbar) id isToggle
+ set t props
+ toolBarRealize toolbar
+ return t
+
-- | Create an /orphan/ toolbar item that is unassociated with a menu. Takes a
-- label, a flag that is 'True' when the item is 'checkable' and a path to an image
-- (bmp,png,gif,ico,etc.) as arguments.
View
2  wxc/src/eljdc.cpp
@@ -660,7 +660,7 @@ EWXWEXPORT(void, wxMetafile_Delete) (void* _obj)
#endif
}
-#if (wxVERSION_NUMBER >= 2800)
+#if wxCHECK_VERSION (2,8,0)
EWXWEXPORT(void, wxDC_DrawLabel)(void* _obj, void *str, int x, int y, int w, int h, int align, int indexAccel)
{
wxRect rect(x, y, w, h);
Please sign in to comment.
Something went wrong with that request. Please try again.