From: Stefan Csomor Date: Sun, 3 Aug 2008 17:34:59 +0000 (+0000) Subject: moving osx files (rename will follow) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/96dabe431382e288fc1ccc561f62c400895ac0fa moving osx files (rename will follow) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54962 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/Makefile.in b/Makefile.in index 4136201748..db86f1645e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4631,14 +4631,22 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___GUI_SRC_OBJECTS = \ monodll_treeentry_gtk.o @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@__GUI_SRC_OBJECTS = $(COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___GUI_SRC_OBJECTS) COND_TOOLKIT_MAC___GUI_SRC_OBJECTS = \ + monodll_accel.o \ + monodll_artmac.o \ monodll_brush.o \ + monodll_fontutil.o \ + monodll_imaglist.o \ + monodll_minifram.o \ + monodll_palette.o \ monodll_pen.o \ + monodll_bitmap.o \ monodll_colour.o \ + monodll_dcmemory.o \ + monodll_display.o \ + monodll_fontenum.o \ + monodll_printmac.o \ monodll_timer.o \ - monodll_accel.o \ monodll_app.o \ - monodll_artmac.o \ - monodll_bitmap.o \ monodll_bmpbuttn.o \ monodll_button.o \ monodll_checkbox.o \ @@ -4651,40 +4659,32 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS = \ monodll_cursor.o \ monodll_dataobj.o \ monodll_dcclient.o \ - monodll_dcmemory.o \ monodll_dcprint.o \ monodll_dcscreen.o \ monodll_dialog.o \ monodll_dirdlg.o \ - monodll_display.o \ monodll_dnd.o \ monodll_evtloop.o \ monodll_filedlg.o \ monodll_font.o \ monodll_fontdlg.o \ - monodll_fontenum.o \ - monodll_fontutil.o \ monodll_frame.o \ monodll_gauge.o \ monodll_gdiobj.o \ monodll_graphics.o \ monodll_icon.o \ - monodll_imaglist.o \ monodll_listbox.o \ monodll_listctrl_mac.o \ monodll_mdi.o \ monodll_menu.o \ monodll_menuitem.o \ monodll_metafile.o \ - monodll_minifram.o \ monodll_msgdlg.o \ monodll_nonownedwnd.o \ monodll_notebmac.o \ monodll_overlay.o \ - monodll_palette.o \ monodll_popupwin.o \ monodll_printdlg.o \ - monodll_printmac.o \ monodll_radiobox.o \ monodll_radiobut.o \ monodll_region.o \ @@ -6532,14 +6532,22 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___GUI_SRC_OBJECTS_1 = \ monolib_treeentry_gtk.o @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@__GUI_SRC_OBJECTS_1 = $(COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___GUI_SRC_OBJECTS_1) COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_1 = \ + monolib_accel.o \ + monolib_artmac.o \ monolib_brush.o \ + monolib_fontutil.o \ + monolib_imaglist.o \ + monolib_minifram.o \ + monolib_palette.o \ monolib_pen.o \ + monolib_bitmap.o \ monolib_colour.o \ + monolib_dcmemory.o \ + monolib_display.o \ + monolib_fontenum.o \ + monolib_printmac.o \ monolib_timer.o \ - monolib_accel.o \ monolib_app.o \ - monolib_artmac.o \ - monolib_bitmap.o \ monolib_bmpbuttn.o \ monolib_button.o \ monolib_checkbox.o \ @@ -6552,40 +6560,32 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_1 = \ monolib_cursor.o \ monolib_dataobj.o \ monolib_dcclient.o \ - monolib_dcmemory.o \ monolib_dcprint.o \ monolib_dcscreen.o \ monolib_dialog.o \ monolib_dirdlg.o \ - monolib_display.o \ monolib_dnd.o \ monolib_evtloop.o \ monolib_filedlg.o \ monolib_font.o \ monolib_fontdlg.o \ - monolib_fontenum.o \ - monolib_fontutil.o \ monolib_frame.o \ monolib_gauge.o \ monolib_gdiobj.o \ monolib_graphics.o \ monolib_icon.o \ - monolib_imaglist.o \ monolib_listbox.o \ monolib_listctrl_mac.o \ monolib_mdi.o \ monolib_menu.o \ monolib_menuitem.o \ monolib_metafile.o \ - monolib_minifram.o \ monolib_msgdlg.o \ monolib_nonownedwnd.o \ monolib_notebmac.o \ monolib_overlay.o \ - monolib_palette.o \ monolib_popupwin.o \ monolib_printdlg.o \ - monolib_printmac.o \ monolib_radiobox.o \ monolib_radiobut.o \ monolib_region.o \ @@ -8694,14 +8694,22 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___GUI_SRC_OBJECTS_2 = \ coredll_treeentry_gtk.o @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@__GUI_SRC_OBJECTS_2 = $(COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___GUI_SRC_OBJECTS_2) COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_2 = \ + coredll_accel.o \ + coredll_artmac.o \ coredll_brush.o \ + coredll_fontutil.o \ + coredll_imaglist.o \ + coredll_minifram.o \ + coredll_palette.o \ coredll_pen.o \ + coredll_bitmap.o \ coredll_colour.o \ + coredll_dcmemory.o \ + coredll_display.o \ + coredll_fontenum.o \ + coredll_printmac.o \ coredll_timer.o \ - coredll_accel.o \ coredll_app.o \ - coredll_artmac.o \ - coredll_bitmap.o \ coredll_bmpbuttn.o \ coredll_button.o \ coredll_checkbox.o \ @@ -8714,40 +8722,32 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_2 = \ coredll_cursor.o \ coredll_dataobj.o \ coredll_dcclient.o \ - coredll_dcmemory.o \ coredll_dcprint.o \ coredll_dcscreen.o \ coredll_dialog.o \ coredll_dirdlg.o \ - coredll_display.o \ coredll_dnd.o \ coredll_evtloop.o \ coredll_filedlg.o \ coredll_font.o \ coredll_fontdlg.o \ - coredll_fontenum.o \ - coredll_fontutil.o \ coredll_frame.o \ coredll_gauge.o \ coredll_gdiobj.o \ coredll_graphics.o \ coredll_icon.o \ - coredll_imaglist.o \ coredll_listbox.o \ coredll_listctrl_mac.o \ coredll_mdi.o \ coredll_menu.o \ coredll_menuitem.o \ coredll_metafile.o \ - coredll_minifram.o \ coredll_msgdlg.o \ coredll_nonownedwnd.o \ coredll_notebmac.o \ coredll_overlay.o \ - coredll_palette.o \ coredll_popupwin.o \ coredll_printdlg.o \ - coredll_printmac.o \ coredll_radiobox.o \ coredll_radiobut.o \ coredll_region.o \ @@ -10193,14 +10193,22 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___GUI_SRC_OBJECTS_3 = \ corelib_treeentry_gtk.o @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@__GUI_SRC_OBJECTS_3 = $(COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___GUI_SRC_OBJECTS_3) COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_3 = \ + corelib_accel.o \ + corelib_artmac.o \ corelib_brush.o \ + corelib_fontutil.o \ + corelib_imaglist.o \ + corelib_minifram.o \ + corelib_palette.o \ corelib_pen.o \ + corelib_bitmap.o \ corelib_colour.o \ + corelib_dcmemory.o \ + corelib_display.o \ + corelib_fontenum.o \ + corelib_printmac.o \ corelib_timer.o \ - corelib_accel.o \ corelib_app.o \ - corelib_artmac.o \ - corelib_bitmap.o \ corelib_bmpbuttn.o \ corelib_button.o \ corelib_checkbox.o \ @@ -10213,40 +10221,32 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_3 = \ corelib_cursor.o \ corelib_dataobj.o \ corelib_dcclient.o \ - corelib_dcmemory.o \ corelib_dcprint.o \ corelib_dcscreen.o \ corelib_dialog.o \ corelib_dirdlg.o \ - corelib_display.o \ corelib_dnd.o \ corelib_evtloop.o \ corelib_filedlg.o \ corelib_font.o \ corelib_fontdlg.o \ - corelib_fontenum.o \ - corelib_fontutil.o \ corelib_frame.o \ corelib_gauge.o \ corelib_gdiobj.o \ corelib_graphics.o \ corelib_icon.o \ - corelib_imaglist.o \ corelib_listbox.o \ corelib_listctrl_mac.o \ corelib_mdi.o \ corelib_menu.o \ corelib_menuitem.o \ corelib_metafile.o \ - corelib_minifram.o \ corelib_msgdlg.o \ corelib_nonownedwnd.o \ corelib_notebmac.o \ corelib_overlay.o \ - corelib_palette.o \ corelib_popupwin.o \ corelib_printdlg.o \ - corelib_printmac.o \ corelib_radiobox.o \ corelib_radiobut.o \ corelib_region.o \ @@ -13951,8 +13951,11 @@ monodll_tbarwce.o: $(srcdir)/src/msw/wince/tbarwce.cpp $(MONODLL_ODEP) monodll_textctrlce.o: $(srcdir)/src/msw/wince/textctrlce.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/wince/textctrlce.cpp -monodll_artmac.o: $(srcdir)/src/osx/carbon/artmac.cpp $(MONODLL_ODEP) - $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/artmac.cpp +monodll_artmac.o: $(srcdir)/src/osx/artmac.cpp $(MONODLL_ODEP) + $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/artmac.cpp + +monodll_printmac.o: $(srcdir)/src/osx/core/printmac.cpp $(MONODLL_ODEP) + $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/printmac.cpp monodll_listctrl_mac.o: $(srcdir)/src/osx/carbon/listctrl_mac.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/listctrl_mac.cpp @@ -13960,9 +13963,6 @@ monodll_listctrl_mac.o: $(srcdir)/src/osx/carbon/listctrl_mac.cpp $(MONODLL_ODEP monodll_notebmac.o: $(srcdir)/src/osx/carbon/notebmac.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/notebmac.cpp -monodll_printmac.o: $(srcdir)/src/osx/carbon/printmac.cpp $(MONODLL_ODEP) - $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/printmac.cpp - monodll_srchctrl.o: $(srcdir)/src/osx/carbon/srchctrl.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/srchctrl.cpp @@ -15022,8 +15022,8 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@monodll_imaglist.o: $(srcdir)/src/msw/imaglist.cpp $(MONODLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/imaglist.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_imaglist.o: $(srcdir)/src/osx/carbon/imaglist.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/imaglist.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_imaglist.o: $(srcdir)/src/osx/imaglist.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/imaglist.cpp @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monodll_dialup.o: $(srcdir)/src/unix/dialup.cpp $(MONODLL_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/unix/dialup.cpp @@ -15067,8 +15067,8 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@monodll_fontenum.o: $(srcdir)/src/dfb/fontenum.cpp $(MONODLL_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/dfb/fontenum.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_fontenum.o: $(srcdir)/src/osx/carbon/fontenum.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/fontenum.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_fontenum.o: $(srcdir)/src/osx/core/fontenum.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/fontenum.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monodll_fontenum.o: $(srcdir)/src/cocoa/fontenum.mm $(MONODLL_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/cocoa/fontenum.mm @@ -15097,8 +15097,8 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@monodll_fontutil.o: $(srcdir)/src/mgl/fontutil.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/mgl/fontutil.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_fontutil.o: $(srcdir)/src/osx/carbon/fontutil.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/fontutil.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_fontutil.o: $(srcdir)/src/osx/fontutil.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/fontutil.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monodll_fontutil.o: $(srcdir)/src/cocoa/fontutil.cpp $(MONODLL_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/cocoa/fontutil.cpp @@ -15232,8 +15232,8 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@monodll_bitmap.o: $(srcdir)/src/dfb/bitmap.cpp $(MONODLL_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/dfb/bitmap.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_bitmap.o: $(srcdir)/src/osx/carbon/bitmap.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/bitmap.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_bitmap.o: $(srcdir)/src/osx/core/bitmap.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/bitmap.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monodll_bitmap.o: $(srcdir)/src/cocoa/bitmap.mm $(MONODLL_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/cocoa/bitmap.mm @@ -15484,8 +15484,8 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@monodll_dcmemory.o: $(srcdir)/src/motif/dcmemory.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/motif/dcmemory.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_dcmemory.o: $(srcdir)/src/osx/carbon/dcmemory.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/dcmemory.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_dcmemory.o: $(srcdir)/src/osx/core/dcmemory.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/dcmemory.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monodll_dcmemory.o: $(srcdir)/src/cocoa/dcmemory.mm $(MONODLL_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/cocoa/dcmemory.mm @@ -15598,8 +15598,8 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@monodll_minifram.o: $(srcdir)/src/motif/minifram.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/motif/minifram.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_minifram.o: $(srcdir)/src/osx/carbon/minifram.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/minifram.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_minifram.o: $(srcdir)/src/osx/minifram.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/minifram.cpp @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monodll_minifram.o: $(srcdir)/src/os2/minifram.cpp $(MONODLL_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/os2/minifram.cpp @@ -15883,8 +15883,8 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@monodll_palette.o: $(srcdir)/src/mgl/palette.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/mgl/palette.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_palette.o: $(srcdir)/src/osx/carbon/palette.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/palette.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_palette.o: $(srcdir)/src/osx/palette.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/palette.cpp @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monodll_palette.o: $(srcdir)/src/os2/palette.cpp $(MONODLL_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/os2/palette.cpp @@ -15919,8 +15919,8 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@monodll_display.o: $(srcdir)/src/msw/display.cpp $(MONODLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/display.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_display.o: $(srcdir)/src/osx/carbon/display.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/display.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_display.o: $(srcdir)/src/osx/core/display.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monodll_display.o: $(srcdir)/src/cocoa/display.mm $(MONODLL_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/cocoa/display.mm @@ -16108,8 +16108,8 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monodll_accel.o: $(srcdir)/src/msw/accel.cpp $(MONODLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/accel.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_accel.o: $(srcdir)/src/osx/carbon/accel.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/accel.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_accel.o: $(srcdir)/src/osx/accel.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/accel.cpp @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monodll_accel.o: $(srcdir)/src/os2/accel.cpp $(MONODLL_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/os2/accel.cpp @@ -18442,8 +18442,11 @@ monolib_tbarwce.o: $(srcdir)/src/msw/wince/tbarwce.cpp $(MONOLIB_ODEP) monolib_textctrlce.o: $(srcdir)/src/msw/wince/textctrlce.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/wince/textctrlce.cpp -monolib_artmac.o: $(srcdir)/src/osx/carbon/artmac.cpp $(MONOLIB_ODEP) - $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/artmac.cpp +monolib_artmac.o: $(srcdir)/src/osx/artmac.cpp $(MONOLIB_ODEP) + $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/artmac.cpp + +monolib_printmac.o: $(srcdir)/src/osx/core/printmac.cpp $(MONOLIB_ODEP) + $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/printmac.cpp monolib_listctrl_mac.o: $(srcdir)/src/osx/carbon/listctrl_mac.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/listctrl_mac.cpp @@ -18451,9 +18454,6 @@ monolib_listctrl_mac.o: $(srcdir)/src/osx/carbon/listctrl_mac.cpp $(MONOLIB_ODEP monolib_notebmac.o: $(srcdir)/src/osx/carbon/notebmac.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/notebmac.cpp -monolib_printmac.o: $(srcdir)/src/osx/carbon/printmac.cpp $(MONOLIB_ODEP) - $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/printmac.cpp - monolib_srchctrl.o: $(srcdir)/src/osx/carbon/srchctrl.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/srchctrl.cpp @@ -19513,8 +19513,8 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@monolib_imaglist.o: $(srcdir)/src/msw/imaglist.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/imaglist.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_imaglist.o: $(srcdir)/src/osx/carbon/imaglist.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/imaglist.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_imaglist.o: $(srcdir)/src/osx/imaglist.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/imaglist.cpp @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monolib_dialup.o: $(srcdir)/src/unix/dialup.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/unix/dialup.cpp @@ -19558,8 +19558,8 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@monolib_fontenum.o: $(srcdir)/src/dfb/fontenum.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/dfb/fontenum.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_fontenum.o: $(srcdir)/src/osx/carbon/fontenum.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/fontenum.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_fontenum.o: $(srcdir)/src/osx/core/fontenum.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/fontenum.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monolib_fontenum.o: $(srcdir)/src/cocoa/fontenum.mm $(MONOLIB_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/cocoa/fontenum.mm @@ -19588,8 +19588,8 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@monolib_fontutil.o: $(srcdir)/src/mgl/fontutil.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/mgl/fontutil.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_fontutil.o: $(srcdir)/src/osx/carbon/fontutil.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/fontutil.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_fontutil.o: $(srcdir)/src/osx/fontutil.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/fontutil.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monolib_fontutil.o: $(srcdir)/src/cocoa/fontutil.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/cocoa/fontutil.cpp @@ -19723,8 +19723,8 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@monolib_bitmap.o: $(srcdir)/src/dfb/bitmap.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/dfb/bitmap.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_bitmap.o: $(srcdir)/src/osx/carbon/bitmap.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/bitmap.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_bitmap.o: $(srcdir)/src/osx/core/bitmap.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/bitmap.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monolib_bitmap.o: $(srcdir)/src/cocoa/bitmap.mm $(MONOLIB_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/cocoa/bitmap.mm @@ -19975,8 +19975,8 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@monolib_dcmemory.o: $(srcdir)/src/motif/dcmemory.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/motif/dcmemory.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_dcmemory.o: $(srcdir)/src/osx/carbon/dcmemory.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/dcmemory.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_dcmemory.o: $(srcdir)/src/osx/core/dcmemory.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/dcmemory.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monolib_dcmemory.o: $(srcdir)/src/cocoa/dcmemory.mm $(MONOLIB_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/cocoa/dcmemory.mm @@ -20089,8 +20089,8 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@monolib_minifram.o: $(srcdir)/src/motif/minifram.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/motif/minifram.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_minifram.o: $(srcdir)/src/osx/carbon/minifram.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/minifram.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_minifram.o: $(srcdir)/src/osx/minifram.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/minifram.cpp @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monolib_minifram.o: $(srcdir)/src/os2/minifram.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/os2/minifram.cpp @@ -20374,8 +20374,8 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@monolib_palette.o: $(srcdir)/src/mgl/palette.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/mgl/palette.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_palette.o: $(srcdir)/src/osx/carbon/palette.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/palette.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_palette.o: $(srcdir)/src/osx/palette.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/palette.cpp @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monolib_palette.o: $(srcdir)/src/os2/palette.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/os2/palette.cpp @@ -20410,8 +20410,8 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@monolib_display.o: $(srcdir)/src/msw/display.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/display.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_display.o: $(srcdir)/src/osx/carbon/display.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/display.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_display.o: $(srcdir)/src/osx/core/display.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monolib_display.o: $(srcdir)/src/cocoa/display.mm $(MONOLIB_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/cocoa/display.mm @@ -20599,8 +20599,8 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monolib_accel.o: $(srcdir)/src/msw/accel.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/accel.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_accel.o: $(srcdir)/src/osx/carbon/accel.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/accel.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_accel.o: $(srcdir)/src/osx/accel.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/accel.cpp @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monolib_accel.o: $(srcdir)/src/os2/accel.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/os2/accel.cpp @@ -24232,8 +24232,11 @@ coredll_tbarwce.o: $(srcdir)/src/msw/wince/tbarwce.cpp $(COREDLL_ODEP) coredll_textctrlce.o: $(srcdir)/src/msw/wince/textctrlce.cpp $(COREDLL_ODEP) $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/wince/textctrlce.cpp -coredll_artmac.o: $(srcdir)/src/osx/carbon/artmac.cpp $(COREDLL_ODEP) - $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/artmac.cpp +coredll_artmac.o: $(srcdir)/src/osx/artmac.cpp $(COREDLL_ODEP) + $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/artmac.cpp + +coredll_printmac.o: $(srcdir)/src/osx/core/printmac.cpp $(COREDLL_ODEP) + $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/core/printmac.cpp coredll_listctrl_mac.o: $(srcdir)/src/osx/carbon/listctrl_mac.cpp $(COREDLL_ODEP) $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/listctrl_mac.cpp @@ -24241,9 +24244,6 @@ coredll_listctrl_mac.o: $(srcdir)/src/osx/carbon/listctrl_mac.cpp $(COREDLL_ODEP coredll_notebmac.o: $(srcdir)/src/osx/carbon/notebmac.cpp $(COREDLL_ODEP) $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/notebmac.cpp -coredll_printmac.o: $(srcdir)/src/osx/carbon/printmac.cpp $(COREDLL_ODEP) - $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/printmac.cpp - coredll_srchctrl.o: $(srcdir)/src/osx/carbon/srchctrl.cpp $(COREDLL_ODEP) $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/srchctrl.cpp @@ -24496,8 +24496,8 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@coredll_imaglist.o: $(srcdir)/src/msw/imaglist.cpp $(COREDLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/imaglist.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_imaglist.o: $(srcdir)/src/osx/carbon/imaglist.cpp $(COREDLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/imaglist.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_imaglist.o: $(srcdir)/src/osx/imaglist.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/imaglist.cpp @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@coredll_dialup.o: $(srcdir)/src/unix/dialup.cpp $(COREDLL_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/unix/dialup.cpp @@ -24541,8 +24541,8 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@coredll_fontenum.o: $(srcdir)/src/dfb/fontenum.cpp $(COREDLL_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/dfb/fontenum.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_fontenum.o: $(srcdir)/src/osx/carbon/fontenum.cpp $(COREDLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/fontenum.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_fontenum.o: $(srcdir)/src/osx/core/fontenum.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/core/fontenum.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@coredll_fontenum.o: $(srcdir)/src/cocoa/fontenum.mm $(COREDLL_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/cocoa/fontenum.mm @@ -24571,8 +24571,8 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@coredll_fontutil.o: $(srcdir)/src/mgl/fontutil.cpp $(COREDLL_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/mgl/fontutil.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_fontutil.o: $(srcdir)/src/osx/carbon/fontutil.cpp $(COREDLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/fontutil.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_fontutil.o: $(srcdir)/src/osx/fontutil.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/fontutil.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@coredll_fontutil.o: $(srcdir)/src/cocoa/fontutil.cpp $(COREDLL_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/cocoa/fontutil.cpp @@ -24706,8 +24706,8 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@coredll_bitmap.o: $(srcdir)/src/dfb/bitmap.cpp $(COREDLL_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/dfb/bitmap.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_bitmap.o: $(srcdir)/src/osx/carbon/bitmap.cpp $(COREDLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/bitmap.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_bitmap.o: $(srcdir)/src/osx/core/bitmap.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/core/bitmap.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@coredll_bitmap.o: $(srcdir)/src/cocoa/bitmap.mm $(COREDLL_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/cocoa/bitmap.mm @@ -24958,8 +24958,8 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@coredll_dcmemory.o: $(srcdir)/src/motif/dcmemory.cpp $(COREDLL_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/motif/dcmemory.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_dcmemory.o: $(srcdir)/src/osx/carbon/dcmemory.cpp $(COREDLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/dcmemory.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_dcmemory.o: $(srcdir)/src/osx/core/dcmemory.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/core/dcmemory.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@coredll_dcmemory.o: $(srcdir)/src/cocoa/dcmemory.mm $(COREDLL_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/cocoa/dcmemory.mm @@ -25072,8 +25072,8 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@coredll_minifram.o: $(srcdir)/src/motif/minifram.cpp $(COREDLL_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/motif/minifram.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_minifram.o: $(srcdir)/src/osx/carbon/minifram.cpp $(COREDLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/minifram.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_minifram.o: $(srcdir)/src/osx/minifram.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/minifram.cpp @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@coredll_minifram.o: $(srcdir)/src/os2/minifram.cpp $(COREDLL_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/os2/minifram.cpp @@ -25384,8 +25384,8 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@coredll_palette.o: $(srcdir)/src/mgl/palette.cpp $(COREDLL_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/mgl/palette.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_palette.o: $(srcdir)/src/osx/carbon/palette.cpp $(COREDLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/palette.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_palette.o: $(srcdir)/src/osx/palette.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/palette.cpp @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@coredll_palette.o: $(srcdir)/src/os2/palette.cpp $(COREDLL_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/os2/palette.cpp @@ -25420,8 +25420,8 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@coredll_display.o: $(srcdir)/src/msw/display.cpp $(COREDLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/display.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_display.o: $(srcdir)/src/osx/carbon/display.cpp $(COREDLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/display.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_display.o: $(srcdir)/src/osx/core/display.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@coredll_display.o: $(srcdir)/src/cocoa/display.mm $(COREDLL_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/cocoa/display.mm @@ -25609,8 +25609,8 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@coredll_accel.o: $(srcdir)/src/msw/accel.cpp $(COREDLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/accel.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_accel.o: $(srcdir)/src/osx/carbon/accel.cpp $(COREDLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/accel.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_accel.o: $(srcdir)/src/osx/accel.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/accel.cpp @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@coredll_accel.o: $(srcdir)/src/os2/accel.cpp $(COREDLL_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/os2/accel.cpp @@ -27307,8 +27307,11 @@ corelib_tbarwce.o: $(srcdir)/src/msw/wince/tbarwce.cpp $(CORELIB_ODEP) corelib_textctrlce.o: $(srcdir)/src/msw/wince/textctrlce.cpp $(CORELIB_ODEP) $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/wince/textctrlce.cpp -corelib_artmac.o: $(srcdir)/src/osx/carbon/artmac.cpp $(CORELIB_ODEP) - $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/artmac.cpp +corelib_artmac.o: $(srcdir)/src/osx/artmac.cpp $(CORELIB_ODEP) + $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/artmac.cpp + +corelib_printmac.o: $(srcdir)/src/osx/core/printmac.cpp $(CORELIB_ODEP) + $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/core/printmac.cpp corelib_listctrl_mac.o: $(srcdir)/src/osx/carbon/listctrl_mac.cpp $(CORELIB_ODEP) $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/listctrl_mac.cpp @@ -27316,9 +27319,6 @@ corelib_listctrl_mac.o: $(srcdir)/src/osx/carbon/listctrl_mac.cpp $(CORELIB_ODEP corelib_notebmac.o: $(srcdir)/src/osx/carbon/notebmac.cpp $(CORELIB_ODEP) $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/notebmac.cpp -corelib_printmac.o: $(srcdir)/src/osx/carbon/printmac.cpp $(CORELIB_ODEP) - $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/printmac.cpp - corelib_srchctrl.o: $(srcdir)/src/osx/carbon/srchctrl.cpp $(CORELIB_ODEP) $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/srchctrl.cpp @@ -27571,8 +27571,8 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@corelib_imaglist.o: $(srcdir)/src/msw/imaglist.cpp $(CORELIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/imaglist.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_imaglist.o: $(srcdir)/src/osx/carbon/imaglist.cpp $(CORELIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/imaglist.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_imaglist.o: $(srcdir)/src/osx/imaglist.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/imaglist.cpp @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@corelib_dialup.o: $(srcdir)/src/unix/dialup.cpp $(CORELIB_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/unix/dialup.cpp @@ -27616,8 +27616,8 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@corelib_fontenum.o: $(srcdir)/src/dfb/fontenum.cpp $(CORELIB_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/dfb/fontenum.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_fontenum.o: $(srcdir)/src/osx/carbon/fontenum.cpp $(CORELIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/fontenum.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_fontenum.o: $(srcdir)/src/osx/core/fontenum.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/core/fontenum.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@corelib_fontenum.o: $(srcdir)/src/cocoa/fontenum.mm $(CORELIB_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/cocoa/fontenum.mm @@ -27646,8 +27646,8 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@corelib_fontutil.o: $(srcdir)/src/mgl/fontutil.cpp $(CORELIB_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/mgl/fontutil.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_fontutil.o: $(srcdir)/src/osx/carbon/fontutil.cpp $(CORELIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/fontutil.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_fontutil.o: $(srcdir)/src/osx/fontutil.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/fontutil.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@corelib_fontutil.o: $(srcdir)/src/cocoa/fontutil.cpp $(CORELIB_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/cocoa/fontutil.cpp @@ -27781,8 +27781,8 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@corelib_bitmap.o: $(srcdir)/src/dfb/bitmap.cpp $(CORELIB_ODEP) @COND_TOOLKIT_DFB_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/dfb/bitmap.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_bitmap.o: $(srcdir)/src/osx/carbon/bitmap.cpp $(CORELIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/bitmap.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_bitmap.o: $(srcdir)/src/osx/core/bitmap.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/core/bitmap.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@corelib_bitmap.o: $(srcdir)/src/cocoa/bitmap.mm $(CORELIB_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/cocoa/bitmap.mm @@ -28033,8 +28033,8 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@corelib_dcmemory.o: $(srcdir)/src/motif/dcmemory.cpp $(CORELIB_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/motif/dcmemory.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_dcmemory.o: $(srcdir)/src/osx/carbon/dcmemory.cpp $(CORELIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/dcmemory.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_dcmemory.o: $(srcdir)/src/osx/core/dcmemory.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/core/dcmemory.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@corelib_dcmemory.o: $(srcdir)/src/cocoa/dcmemory.mm $(CORELIB_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/cocoa/dcmemory.mm @@ -28147,8 +28147,8 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@corelib_minifram.o: $(srcdir)/src/motif/minifram.cpp $(CORELIB_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/motif/minifram.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_minifram.o: $(srcdir)/src/osx/carbon/minifram.cpp $(CORELIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/minifram.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_minifram.o: $(srcdir)/src/osx/minifram.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/minifram.cpp @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@corelib_minifram.o: $(srcdir)/src/os2/minifram.cpp $(CORELIB_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/os2/minifram.cpp @@ -28459,8 +28459,8 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@corelib_palette.o: $(srcdir)/src/mgl/palette.cpp $(CORELIB_ODEP) @COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/mgl/palette.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_palette.o: $(srcdir)/src/osx/carbon/palette.cpp $(CORELIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/palette.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_palette.o: $(srcdir)/src/osx/palette.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/palette.cpp @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@corelib_palette.o: $(srcdir)/src/os2/palette.cpp $(CORELIB_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/os2/palette.cpp @@ -28495,8 +28495,8 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@corelib_display.o: $(srcdir)/src/msw/display.cpp $(CORELIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/display.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_display.o: $(srcdir)/src/osx/carbon/display.cpp $(CORELIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/display.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_display.o: $(srcdir)/src/osx/core/display.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@corelib_display.o: $(srcdir)/src/cocoa/display.mm $(CORELIB_ODEP) @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/cocoa/display.mm @@ -28684,8 +28684,8 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@corelib_accel.o: $(srcdir)/src/msw/accel.cpp $(CORELIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/accel.cpp -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_accel.o: $(srcdir)/src/osx/carbon/accel.cpp $(CORELIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/accel.cpp +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_accel.o: $(srcdir)/src/osx/accel.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/accel.cpp @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@corelib_accel.o: $(srcdir)/src/os2/accel.cpp $(CORELIB_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/os2/accel.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index a5e9e1a6b2..89c037a8a0 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -2182,16 +2182,24 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! + src/osx/accel.cpp + src/osx/artmac.cpp src/osx/brush.cpp + src/osx/fontutil.cpp + src/osx/imaglist.cpp + src/osx/minifram.cpp + src/osx/palette.cpp src/osx/pen.cpp + src/osx/core/bitmap.cpp src/osx/core/colour.cpp + src/osx/core/dcmemory.cpp + src/osx/core/display.cpp + src/osx/core/fontenum.cpp + src/osx/core/printmac.cpp src/osx/core/timer.cpp - src/osx/carbon/accel.cpp src/osx/carbon/app.cpp - src/osx/carbon/artmac.cpp - src/osx/carbon/bitmap.cpp src/osx/carbon/bmpbuttn.cpp src/osx/carbon/button.cpp src/osx/carbon/checkbox.cpp @@ -2204,40 +2212,32 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/osx/carbon/cursor.cpp src/osx/carbon/dataobj.cpp src/osx/carbon/dcclient.cpp - src/osx/carbon/dcmemory.cpp src/osx/carbon/dcprint.cpp src/osx/carbon/dcscreen.cpp src/osx/carbon/dialog.cpp src/osx/carbon/dirdlg.cpp - src/osx/carbon/display.cpp src/osx/carbon/dnd.cpp src/osx/carbon/evtloop.cpp src/osx/carbon/filedlg.cpp src/osx/carbon/font.cpp src/osx/carbon/fontdlg.cpp - src/osx/carbon/fontenum.cpp - src/osx/carbon/fontutil.cpp src/osx/carbon/frame.cpp src/osx/carbon/gauge.cpp src/osx/carbon/gdiobj.cpp src/osx/carbon/graphics.cpp src/osx/carbon/icon.cpp - src/osx/carbon/imaglist.cpp src/osx/carbon/listbox.cpp src/osx/carbon/listctrl_mac.cpp src/osx/carbon/mdi.cpp src/osx/carbon/menu.cpp src/osx/carbon/menuitem.cpp src/osx/carbon/metafile.cpp - src/osx/carbon/minifram.cpp src/osx/carbon/msgdlg.cpp src/osx/carbon/nonownedwnd.cpp src/osx/carbon/notebmac.cpp src/osx/carbon/overlay.cpp - src/osx/carbon/palette.cpp src/osx/carbon/popupwin.cpp src/osx/carbon/printdlg.cpp - src/osx/carbon/printmac.cpp src/osx/carbon/radiobox.cpp src/osx/carbon/radiobut.cpp src/osx/carbon/region.cpp diff --git a/src/osx/accel.cpp b/src/osx/accel.cpp new file mode 100644 index 0000000000..d1d535207d --- /dev/null +++ b/src/osx/accel.cpp @@ -0,0 +1,109 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/osx/accel.cpp +// Purpose: wxAcceleratorTable +// Author: Stefan Csomor +// Modified by: +// Created: 1998-01-01 +// RCS-ID: $Id$ +// Copyright: (c) Stefan Csomor +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/wxprec.h" + +#include "wx/accel.h" + +#ifndef WX_PRECOMP + #include "wx/string.h" +#endif + +#ifndef __WXUNIVERSAL__ + +IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject) + +// ---------------------------------------------------------------------------- +// wxAccelList: a list of wxAcceleratorEntries +// ---------------------------------------------------------------------------- + +WX_DECLARE_LIST(wxAcceleratorEntry, wxAccelList); +#include "wx/listimpl.cpp" +WX_DEFINE_LIST(wxAccelList) + +// ---------------------------------------------------------------------------- +// wxAccelRefData: the data used by wxAcceleratorTable +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData +{ + friend class wxAcceleratorTable; +public: + wxAcceleratorRefData(); + virtual ~wxAcceleratorRefData(); + + wxAccelList m_accels; +}; + +#define M_ACCELDATA ((wxAcceleratorRefData *)m_refData) + +wxAcceleratorRefData::wxAcceleratorRefData() + : m_accels() +{ +} + +wxAcceleratorRefData::~wxAcceleratorRefData() +{ + WX_CLEAR_LIST( wxAccelList, m_accels ); +} + +wxAcceleratorTable::wxAcceleratorTable() +{ + m_refData = NULL; +} + +wxAcceleratorTable::~wxAcceleratorTable() +{ +} + +// Create from an array +wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]) +{ + m_refData = new wxAcceleratorRefData; + + for (int i = 0; i < n; i++) + { + int flag = entries[i].GetFlags(); + int keycode = entries[i].GetKeyCode(); + int command = entries[i].GetCommand(); + if ((keycode >= (int)'a') && (keycode <= (int)'z')) keycode = (int)toupper( (char)keycode ); + M_ACCELDATA->m_accels.Append( new wxAcceleratorEntry( flag, keycode, command ) ); + } +} + +bool wxAcceleratorTable::IsOk() const +{ + return (m_refData != NULL); +} + +int wxAcceleratorTable::GetCommand( wxKeyEvent &event ) +{ + if (!Ok()) return -1; + + wxAccelList::compatibility_iterator node = M_ACCELDATA->m_accels.GetFirst(); + while (node) + { + wxAcceleratorEntry *entry = node->GetData(); + if ((event.m_keyCode == entry->GetKeyCode()) && + (((entry->GetFlags() & wxACCEL_CTRL) != 0) == event.ControlDown()) && + (((entry->GetFlags() & wxACCEL_SHIFT) != 0) == event.ShiftDown()) && + (((entry->GetFlags() & wxACCEL_ALT) != 0) == event.AltDown()) && + (((entry->GetFlags() & wxACCEL_CMD) != 0) == event.CmdDown())) + { + return entry->GetCommand(); + } + node = node->GetNext(); + } + + return -1; +} + +#endif \ No newline at end of file diff --git a/src/osx/artmac.cpp b/src/osx/artmac.cpp new file mode 100644 index 0000000000..548eb2ce97 --- /dev/null +++ b/src/osx/artmac.cpp @@ -0,0 +1,114 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/osx/artmac.cpp +// Purpose: wxArtProvider instance with native Mac stock icons +// Author: Alan Shouls +// Created: 2006-10-30 +// RCS-ID: $Id$ +// Copyright: (c) wxWindows team +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// --------------------------------------------------------------------------- +// headers +// --------------------------------------------------------------------------- + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#if defined(__BORLANDC__) + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/image.h" +#endif + +#if !defined(__WXUNIVERSAL__) + +#include "wx/artprov.h" +#include "wx/image.h" + +// ---------------------------------------------------------------------------- +// wxMacArtProvider +// ---------------------------------------------------------------------------- + +class wxMacArtProvider : public wxArtProvider +{ +protected: + virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client, + const wxSize& size); + virtual wxIconBundle CreateIconBundle(const wxArtID& id, + const wxArtClient& client); +}; + +/* static */ void wxArtProvider::InitNativeProvider() +{ + wxArtProvider::Push(new wxMacArtProvider); +} + +// ---------------------------------------------------------------------------- +// helper macros +// ---------------------------------------------------------------------------- + +#define CREATE_STD_ICON(iconId, xpmRc) \ + { \ + wxIconBundle icon(_T(iconId), wxBITMAP_TYPE_ICON_RESOURCE); \ + return icon; \ + } + +// Macro used in CreateBitmap to get wxICON_FOO icons: +#define ART_MSGBOX(artId, iconId, xpmRc) \ + if ( id == artId ) \ + { \ + CREATE_STD_ICON(#iconId, xpmRc) \ + } + +static wxIconBundle wxMacArtProvider_CreateIconBundle(const wxArtID& id) +{ + ART_MSGBOX(wxART_ERROR, wxICON_ERROR, error) + ART_MSGBOX(wxART_INFORMATION, wxICON_INFORMATION, info) + ART_MSGBOX(wxART_WARNING, wxICON_WARNING, warning) + ART_MSGBOX(wxART_QUESTION, wxICON_QUESTION, question) + + ART_MSGBOX(wxART_FOLDER, wxICON_FOLDER, folder) + ART_MSGBOX(wxART_FOLDER_OPEN, wxICON_FOLDER_OPEN, folder_open) + ART_MSGBOX(wxART_NORMAL_FILE, wxICON_NORMAL_FILE, deffile) + + return wxNullIconBundle; +} + +// ---------------------------------------------------------------------------- +// CreateIconBundle +// ---------------------------------------------------------------------------- + +wxIconBundle wxMacArtProvider::CreateIconBundle(const wxArtID& id, const wxArtClient& client) +{ + // On the Mac folders in lists are always drawn closed, so if an open + // folder icon is asked for we will ask for a closed one in its place + if ( client == wxART_LIST && id == wxART_FOLDER_OPEN ) + return wxMacArtProvider_CreateIconBundle(wxART_FOLDER); + + return wxMacArtProvider_CreateIconBundle(id); +} + +// ---------------------------------------------------------------------------- +// CreateBitmap +// ---------------------------------------------------------------------------- + +wxBitmap wxMacArtProvider::CreateBitmap(const wxArtID& id, + const wxArtClient& client, + const wxSize& reqSize) +{ + wxIconBundle ic(CreateIconBundle(id, client)); + if (ic.IsOk()) + { + wxIcon theIcon(ic.GetIcon(reqSize)); + return wxBitmap(theIcon); + } + + return wxNullBitmap; +} + +#endif // !defined(__WXUNIVERSAL__) + + diff --git a/src/osx/brush.cpp b/src/osx/brush.cpp index d7ec6a3369..aa05b6bd90 100644 --- a/src/osx/brush.cpp +++ b/src/osx/brush.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/brush.cpp +// Name: src/osx/brush.cpp // Purpose: wxBrush // Author: Stefan Csomor // Modified by: diff --git a/src/osx/carbon/accel.cpp b/src/osx/carbon/accel.cpp deleted file mode 100644 index f33bbe28e0..0000000000 --- a/src/osx/carbon/accel.cpp +++ /dev/null @@ -1,109 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/accel.cpp -// Purpose: wxAcceleratorTable -// Author: Stefan Csomor -// Modified by: -// Created: 1998-01-01 -// RCS-ID: $Id$ -// Copyright: (c) Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#include "wx/accel.h" - -#ifndef WX_PRECOMP - #include "wx/string.h" -#endif - -#ifndef __WXUNIVERSAL__ - -IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject) - -// ---------------------------------------------------------------------------- -// wxAccelList: a list of wxAcceleratorEntries -// ---------------------------------------------------------------------------- - -WX_DECLARE_LIST(wxAcceleratorEntry, wxAccelList); -#include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxAccelList) - -// ---------------------------------------------------------------------------- -// wxAccelRefData: the data used by wxAcceleratorTable -// ---------------------------------------------------------------------------- - -class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData -{ - friend class wxAcceleratorTable; -public: - wxAcceleratorRefData(); - virtual ~wxAcceleratorRefData(); - - wxAccelList m_accels; -}; - -#define M_ACCELDATA ((wxAcceleratorRefData *)m_refData) - -wxAcceleratorRefData::wxAcceleratorRefData() - : m_accels() -{ -} - -wxAcceleratorRefData::~wxAcceleratorRefData() -{ - WX_CLEAR_LIST( wxAccelList, m_accels ); -} - -wxAcceleratorTable::wxAcceleratorTable() -{ - m_refData = NULL; -} - -wxAcceleratorTable::~wxAcceleratorTable() -{ -} - -// Create from an array -wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]) -{ - m_refData = new wxAcceleratorRefData; - - for (int i = 0; i < n; i++) - { - int flag = entries[i].GetFlags(); - int keycode = entries[i].GetKeyCode(); - int command = entries[i].GetCommand(); - if ((keycode >= (int)'a') && (keycode <= (int)'z')) keycode = (int)toupper( (char)keycode ); - M_ACCELDATA->m_accels.Append( new wxAcceleratorEntry( flag, keycode, command ) ); - } -} - -bool wxAcceleratorTable::IsOk() const -{ - return (m_refData != NULL); -} - -int wxAcceleratorTable::GetCommand( wxKeyEvent &event ) -{ - if (!Ok()) return -1; - - wxAccelList::compatibility_iterator node = M_ACCELDATA->m_accels.GetFirst(); - while (node) - { - wxAcceleratorEntry *entry = node->GetData(); - if ((event.m_keyCode == entry->GetKeyCode()) && - (((entry->GetFlags() & wxACCEL_CTRL) != 0) == event.ControlDown()) && - (((entry->GetFlags() & wxACCEL_SHIFT) != 0) == event.ShiftDown()) && - (((entry->GetFlags() & wxACCEL_ALT) != 0) == event.AltDown()) && - (((entry->GetFlags() & wxACCEL_CMD) != 0) == event.CmdDown())) - { - return entry->GetCommand(); - } - node = node->GetNext(); - } - - return -1; -} - -#endif \ No newline at end of file diff --git a/src/osx/carbon/artmac.cpp b/src/osx/carbon/artmac.cpp deleted file mode 100644 index 5b08841635..0000000000 --- a/src/osx/carbon/artmac.cpp +++ /dev/null @@ -1,114 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/artmac.cpp -// Purpose: wxArtProvider instance with native Mac stock icons -// Author: Alan Shouls -// Created: 2006-10-30 -// RCS-ID: $Id$ -// Copyright: (c) wxWindows team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// --------------------------------------------------------------------------- -// headers -// --------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#if defined(__BORLANDC__) - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/image.h" -#endif - -#if !defined(__WXUNIVERSAL__) - -#include "wx/artprov.h" -#include "wx/image.h" - -// ---------------------------------------------------------------------------- -// wxMacArtProvider -// ---------------------------------------------------------------------------- - -class wxMacArtProvider : public wxArtProvider -{ -protected: - virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client, - const wxSize& size); - virtual wxIconBundle CreateIconBundle(const wxArtID& id, - const wxArtClient& client); -}; - -/* static */ void wxArtProvider::InitNativeProvider() -{ - wxArtProvider::Push(new wxMacArtProvider); -} - -// ---------------------------------------------------------------------------- -// helper macros -// ---------------------------------------------------------------------------- - -#define CREATE_STD_ICON(iconId, xpmRc) \ - { \ - wxIconBundle icon(_T(iconId), wxBITMAP_TYPE_ICON_RESOURCE); \ - return icon; \ - } - -// Macro used in CreateBitmap to get wxICON_FOO icons: -#define ART_MSGBOX(artId, iconId, xpmRc) \ - if ( id == artId ) \ - { \ - CREATE_STD_ICON(#iconId, xpmRc) \ - } - -static wxIconBundle wxMacArtProvider_CreateIconBundle(const wxArtID& id) -{ - ART_MSGBOX(wxART_ERROR, wxICON_ERROR, error) - ART_MSGBOX(wxART_INFORMATION, wxICON_INFORMATION, info) - ART_MSGBOX(wxART_WARNING, wxICON_WARNING, warning) - ART_MSGBOX(wxART_QUESTION, wxICON_QUESTION, question) - - ART_MSGBOX(wxART_FOLDER, wxICON_FOLDER, folder) - ART_MSGBOX(wxART_FOLDER_OPEN, wxICON_FOLDER_OPEN, folder_open) - ART_MSGBOX(wxART_NORMAL_FILE, wxICON_NORMAL_FILE, deffile) - - return wxNullIconBundle; -} - -// ---------------------------------------------------------------------------- -// CreateIconBundle -// ---------------------------------------------------------------------------- - -wxIconBundle wxMacArtProvider::CreateIconBundle(const wxArtID& id, const wxArtClient& client) -{ - // On the Mac folders in lists are always drawn closed, so if an open - // folder icon is asked for we will ask for a closed one in its place - if ( client == wxART_LIST && id == wxART_FOLDER_OPEN ) - return wxMacArtProvider_CreateIconBundle(wxART_FOLDER); - - return wxMacArtProvider_CreateIconBundle(id); -} - -// ---------------------------------------------------------------------------- -// CreateBitmap -// ---------------------------------------------------------------------------- - -wxBitmap wxMacArtProvider::CreateBitmap(const wxArtID& id, - const wxArtClient& client, - const wxSize& reqSize) -{ - wxIconBundle ic(CreateIconBundle(id, client)); - if (ic.IsOk()) - { - wxIcon theIcon(ic.GetIcon(reqSize)); - return wxBitmap(theIcon); - } - - return wxNullBitmap; -} - -#endif // !defined(__WXUNIVERSAL__) - - diff --git a/src/osx/carbon/bitmap.cpp b/src/osx/carbon/bitmap.cpp deleted file mode 100644 index 00e0709ae7..0000000000 --- a/src/osx/carbon/bitmap.cpp +++ /dev/null @@ -1,1728 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/bitmap.cpp -// Purpose: wxBitmap -// Author: Stefan Csomor -// Modified by: -// Created: 1998-01-01 -// RCS-ID: $Id$ -// Copyright: (c) Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#include "wx/bitmap.h" - -#ifndef WX_PRECOMP - #include "wx/log.h" - #include "wx/dcmemory.h" - #include "wx/icon.h" - #include "wx/image.h" -#endif - -#include "wx/metafile.h" -#include "wx/xpmdecod.h" - -#include "wx/rawbmp.h" - -IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject) -IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) - -#if wxOSX_USE_CARBON -#include "wx/osx/uma.h" -#else -#include "wx/osx/private.h" -#endif - -#ifndef __WXOSX_IPHONE__ -#include -#endif - -CGColorSpaceRef wxMacGetGenericRGBColorSpace(); -CGDataProviderRef wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer& buf ); - -// Implementation Notes -// -------------------- -// -// we are always working with a 32 bit deep pixel buffer -// under QuickDraw its alpha parts are going to be ignored in the GWorld, -// therefore we have a separate GWorld there for blitting the mask in - -// under Quartz then content is transformed into a CGImageRef representing the same data -// which can be transferred to the GPU by the OS for fast rendering - -class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData -{ - friend class WXDLLIMPEXP_FWD_CORE wxIcon; - friend class WXDLLIMPEXP_FWD_CORE wxCursor; -public: - wxBitmapRefData(int width , int height , int depth); - wxBitmapRefData(); - wxBitmapRefData(const wxBitmapRefData &tocopy); - - virtual ~wxBitmapRefData(); - - virtual bool IsOk() const { return m_ok; } - - void Free(); - void SetOk( bool isOk) { m_ok = isOk; } - - void SetWidth( int width ) { m_width = width; } - void SetHeight( int height ) { m_height = height; } - void SetDepth( int depth ) { m_depth = depth; } - - int GetWidth() const { return m_width; } - int GetHeight() const { return m_height; } - int GetDepth() const { return m_depth; } - - void *GetRawAccess() const; - void *BeginRawAccess(); - void EndRawAccess(); - - bool HasAlpha() const { return m_hasAlpha; } - void UseAlpha( bool useAlpha ); - -public: -#if wxUSE_PALETTE - wxPalette m_bitmapPalette; -#endif // wxUSE_PALETTE - - wxMask * m_bitmapMask; // Optional mask - CGImageRef CreateCGImage() const; - - // returns true if the bitmap has a size that - // can be natively transferred into a true icon - // if no is returned GetIconRef will still produce - // an icon but it will be generated via a PICT and - // rescaled to 16 x 16 - bool HasNativeSize(); - - // caller should increase ref count if needed longer - // than the bitmap exists - IconRef GetIconRef(); - -#ifndef __WXOSX_IPHONE__ - // returns a Pict from the bitmap content - PicHandle GetPictHandle(); -#endif - - CGContextRef GetBitmapContext() const; - - int GetBytesPerRow() const { return m_bytesPerRow; } - private : - bool Create(int width , int height , int depth); - void Init(); - - int m_width; - int m_height; - int m_bytesPerRow; - int m_depth; - bool m_hasAlpha; - wxMemoryBuffer m_memBuf; - int m_rawAccessCount; - bool m_ok; - mutable CGImageRef m_cgImageRef; - - IconRef m_iconRef; -#ifndef __WXOSX_IPHONE__ - PicHandle m_pictHandle; -#endif - CGContextRef m_hBitmap; -}; - - -#define wxOSX_USE_PREMULTIPLIED_ALPHA 1 -static const int kBestByteAlignement = 16; -static const int kMaskBytesPerPixel = 1; - -static int GetBestBytesPerRow( int rawBytes ) -{ - return (((rawBytes)+kBestByteAlignement-1) & ~(kBestByteAlignement-1) ); -} - -#if wxUSE_GUI && !defined(__WXOSX_IPHONE__) - -// this is used for more controls than just the wxBitmap button, also for notebooks etc - -void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType ) -{ - memset( info , 0 , sizeof(ControlButtonContentInfo) ) ; - if ( bitmap.Ok() ) - { - wxBitmapRefData * bmap = bitmap.GetBitmapData() ; - if ( bmap == NULL ) - return ; - - if ( forceType == 0 ) - { - forceType = kControlContentCGImageRef; - } - - if ( forceType == kControlContentIconRef ) - { - wxBitmap scaleBmp ; - wxBitmapRefData* bmp = bmap ; - - if ( !bmap->HasNativeSize() ) - { - // as PICT conversion will only result in a 16x16 icon, let's attempt - // a few scales for better results - - int w = bitmap.GetWidth() ; - int h = bitmap.GetHeight() ; - int sz = wxMax( w , h ) ; - if ( sz == 24 || sz == 64 ) - { - scaleBmp = wxBitmap( bitmap.ConvertToImage().Scale( w * 2 , h * 2 ) ) ; - bmp = scaleBmp.GetBitmapData() ; - } - } - - info->contentType = kControlContentIconRef ; - info->u.iconRef = bmp->GetIconRef() ; - AcquireIconRef( info->u.iconRef ) ; - } - else if ( forceType == kControlContentCGImageRef ) - { - info->contentType = kControlContentCGImageRef ; - info->u.imageRef = (CGImageRef) bmap->CreateCGImage() ; - } - else - { -#ifndef __LP64__ - info->contentType = kControlContentPictHandle ; - info->u.picture = bmap->GetPictHandle() ; -#endif - } - } -} - -CGImageRef wxMacCreateCGImageFromBitmap( const wxBitmap& bitmap ) -{ - wxBitmapRefData * bmap = bitmap.GetBitmapData() ; - if ( bmap == NULL ) - return NULL ; - return (CGImageRef) bmap->CreateCGImage(); -} - -void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ) -{ - if ( info->contentType == kControlContentIconRef ) - { - ReleaseIconRef( info->u.iconRef ) ; - } - else if ( info->contentType == kControlNoContent ) - { - // there's no bitmap at all, fall through silently - } - else if ( info->contentType == kControlContentPictHandle ) - { - // owned by the bitmap, no release here - } - else if ( info->contentType == kControlContentCGImageRef ) - { - CGImageRelease( info->u.imageRef ) ; - } - else - { - wxFAIL_MSG(wxT("Unexpected bitmap type") ) ; - } -} - -#endif //wxUSE_BMPBUTTON - -#define M_BITMAPDATA ((wxBitmapRefData *)m_refData) - -void wxBitmapRefData::Init() -{ - m_width = 0 ; - m_height = 0 ; - m_depth = 0 ; - m_bytesPerRow = 0; - m_ok = false ; - m_bitmapMask = NULL ; - m_cgImageRef = NULL ; - -#ifndef __WXOSX_IPHONE__ - m_iconRef = NULL ; - m_pictHandle = NULL ; -#endif - m_hBitmap = NULL ; - - m_rawAccessCount = 0 ; - m_hasAlpha = false; -} - -wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData &tocopy) -{ - Init(); - Create(tocopy.m_width, tocopy.m_height, tocopy.m_depth); - - if (tocopy.m_bitmapMask) - m_bitmapMask = new wxMask(*tocopy.m_bitmapMask); - else if (tocopy.m_hasAlpha) - UseAlpha(true); - - unsigned char* dest = (unsigned char*)GetRawAccess(); - unsigned char* source = (unsigned char*)tocopy.GetRawAccess(); - size_t numbytes = m_bytesPerRow * m_height; - memcpy( dest, source, numbytes ); -} - -wxBitmapRefData::wxBitmapRefData() -{ - Init() ; -} - -wxBitmapRefData::wxBitmapRefData( int w , int h , int d ) -{ - Init() ; - Create( w , h , d ) ; -} - -bool wxBitmapRefData::Create( int w , int h , int d ) -{ - m_width = wxMax(1, w); - m_height = wxMax(1, h); - m_depth = d ; - m_hBitmap = NULL ; - - m_bytesPerRow = GetBestBytesPerRow( w * 4 ) ; - size_t size = m_bytesPerRow * h ; - void* data = m_memBuf.GetWriteBuf( size ) ; - if ( data != NULL ) - { - memset( data , 0 , size ) ; - m_memBuf.UngetWriteBuf( size ) ; - - m_hBitmap = CGBitmapContextCreate((char*) data, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaNoneSkipFirst ); - wxASSERT_MSG( m_hBitmap , wxT("Unable to create CGBitmapContext context") ) ; - CGContextTranslateCTM( m_hBitmap, 0, m_height ); - CGContextScaleCTM( m_hBitmap, 1, -1 ); - } /* data != NULL */ - m_ok = ( m_hBitmap != NULL ) ; - - return m_ok ; -} - -void wxBitmapRefData::UseAlpha( bool use ) -{ - if ( m_hasAlpha == use ) - return ; - - m_hasAlpha = use ; - - CGContextRelease( m_hBitmap ); - m_hBitmap = CGBitmapContextCreate((char*) m_memBuf.GetData(), m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), m_hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst ); - wxASSERT_MSG( m_hBitmap , wxT("Unable to create CGBitmapContext context") ) ; - CGContextTranslateCTM( m_hBitmap, 0, m_height ); - CGContextScaleCTM( m_hBitmap, 1, -1 ); -} - -void *wxBitmapRefData::GetRawAccess() const -{ - wxCHECK_MSG( IsOk(), NULL , wxT("invalid bitmap") ) ; - return m_memBuf.GetData() ; -} - -void *wxBitmapRefData::BeginRawAccess() -{ - wxCHECK_MSG( IsOk(), NULL, wxT("invalid bitmap") ) ; - wxASSERT( m_rawAccessCount == 0 ) ; -#ifndef __WXOSX_IPHONE__ - wxASSERT_MSG( m_pictHandle == NULL && m_iconRef == NULL , - wxT("Currently, modifing bitmaps that are used in controls already is not supported") ) ; -#endif - ++m_rawAccessCount ; - - // we must destroy an existing cached image, as - // the bitmap data may change now - if ( m_cgImageRef ) - { - CGImageRelease( m_cgImageRef ) ; - m_cgImageRef = NULL ; - } - - return m_memBuf.GetData() ; -} - -void wxBitmapRefData::EndRawAccess() -{ - wxCHECK_RET( IsOk() , wxT("invalid bitmap") ) ; - wxASSERT( m_rawAccessCount == 1 ) ; - - --m_rawAccessCount ; -} - -bool wxBitmapRefData::HasNativeSize() -{ - int w = GetWidth() ; - int h = GetHeight() ; - int sz = wxMax( w , h ) ; - - return ( sz == 128 || sz == 48 || sz == 32 || sz == 16 ); -} - -#ifndef __WXOSX_IPHONE__ -IconRef wxBitmapRefData::GetIconRef() -{ - if ( m_iconRef == NULL ) - { - // Create Icon Family Handle - - IconFamilyHandle iconFamily = (IconFamilyHandle) NewHandle( 0 ); - - int w = GetWidth() ; - int h = GetHeight() ; - int sz = wxMax( w , h ) ; - - OSType dataType = 0 ; - OSType maskType = 0 ; - - switch (sz) - { - case 128: -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if ( UMAGetSystemVersion() >= 0x1050 ) - { - dataType = kIconServices128PixelDataARGB ; - } - else -#endif - { - dataType = kThumbnail32BitData ; - maskType = kThumbnail8BitMask ; - } - break; - - case 48: -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if ( UMAGetSystemVersion() >= 0x1050 ) - { - dataType = kIconServices48PixelDataARGB ; - } - else -#endif - { - dataType = kHuge32BitData ; - maskType = kHuge8BitMask ; - } - break; - - case 32: -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if ( UMAGetSystemVersion() >= 0x1050 ) - { - dataType = kIconServices32PixelDataARGB ; - } - else -#endif - { - dataType = kLarge32BitData ; - maskType = kLarge8BitMask ; - } - break; - - case 16: -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if ( UMAGetSystemVersion() >= 0x1050 ) - { - dataType = kIconServices16PixelDataARGB ; - } - else -#endif - { - dataType = kSmall32BitData ; - maskType = kSmall8BitMask ; - } - break; - - default: - break; - } - - if ( dataType != 0 ) - { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if ( maskType == 0 && UMAGetSystemVersion() >= 0x1050 ) - { - size_t datasize = sz * sz * 4 ; - Handle data = NewHandle( datasize ) ; - HLock( data ) ; - unsigned char* ptr = (unsigned char*) *data ; - memset( ptr, 0, datasize ); - bool hasAlpha = HasAlpha() ; - wxMask *mask = m_bitmapMask ; - unsigned char * sourcePtr = (unsigned char*) GetRawAccess() ; - unsigned char * masksourcePtr = mask ? (unsigned char*) mask->GetRawAccess() : NULL ; - - for ( int y = 0 ; y < h ; ++y, sourcePtr += m_bytesPerRow , masksourcePtr += mask ? mask->GetBytesPerRow() : 0 ) - { - unsigned char * source = sourcePtr; - unsigned char * masksource = masksourcePtr; - unsigned char * dest = ptr + y * sz * 4 ; - unsigned char a, r, g, b; - - for ( int x = 0 ; x < w ; ++x ) - { - a = *source ++ ; - r = *source ++ ; - g = *source ++ ; - b = *source ++ ; - - if ( mask ) - { - a = 0xFF - *masksource++ ; - } - else if ( !hasAlpha ) - a = 0xFF ; - else - { -#if wxOSX_USE_PREMULTIPLIED_ALPHA - // this must be non-premultiplied data - if ( a != 0xFF && a!= 0 ) - { - r = r * 255 / a; - g = g * 255 / a; - b = b * 255 / a; - } -#endif - } - *dest++ = a ; - *dest++ = r ; - *dest++ = g ; - *dest++ = b ; - - } - } - HUnlock( data ); - OSStatus err = SetIconFamilyData( iconFamily, dataType , data ); - wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ); - DisposeHandle( data ); - } - else -#endif - { - // setup the header properly - - Handle data = NULL ; - Handle maskdata = NULL ; - unsigned char * maskptr = NULL ; - unsigned char * ptr = NULL ; - size_t datasize, masksize ; - - datasize = sz * sz * 4 ; - data = NewHandle( datasize ) ; - HLock( data ) ; - ptr = (unsigned char*) *data ; - memset( ptr , 0, datasize ) ; - - masksize = sz * sz ; - maskdata = NewHandle( masksize ) ; - HLock( maskdata ) ; - maskptr = (unsigned char*) *maskdata ; - memset( maskptr , 0 , masksize ) ; - - bool hasAlpha = HasAlpha() ; - wxMask *mask = m_bitmapMask ; - unsigned char * sourcePtr = (unsigned char*) GetRawAccess() ; - unsigned char * masksourcePtr = mask ? (unsigned char*) mask->GetRawAccess() : NULL ; - - for ( int y = 0 ; y < h ; ++y, sourcePtr += m_bytesPerRow , masksourcePtr += mask ? mask->GetBytesPerRow() : 0 ) - { - unsigned char * source = sourcePtr; - unsigned char * masksource = masksourcePtr; - unsigned char * dest = ptr + y * sz * 4 ; - unsigned char * maskdest = maskptr + y * sz ; - unsigned char a, r, g, b; - - for ( int x = 0 ; x < w ; ++x ) - { - a = *source ++ ; - r = *source ++ ; - g = *source ++ ; - b = *source ++ ; - - *dest++ = 0 ; - *dest++ = r ; - *dest++ = g ; - *dest++ = b ; - - if ( mask ) - *maskdest++ = 0xFF - *masksource++ ; - else if ( hasAlpha ) - *maskdest++ = a ; - else - *maskdest++ = 0xFF ; - } - } - - OSStatus err = SetIconFamilyData( iconFamily, dataType , data ) ; - wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ; - - err = SetIconFamilyData( iconFamily, maskType , maskdata ) ; - wxASSERT_MSG( err == noErr , wxT("Error when adding mask") ) ; - - HUnlock( data ) ; - HUnlock( maskdata ) ; - DisposeHandle( data ) ; - DisposeHandle( maskdata ) ; - } - } - else - { - PicHandle pic = GetPictHandle() ; - SetIconFamilyData( iconFamily, 'PICT' , (Handle) pic ) ; - } - // transform into IconRef - - // cleaner version existing from 10.3 upwards - HLock((Handle) iconFamily); - OSStatus err = GetIconRefFromIconFamilyPtr( *iconFamily, GetHandleSize((Handle) iconFamily), &m_iconRef ); - HUnlock((Handle) iconFamily); - DisposeHandle( (Handle) iconFamily ) ; - - wxCHECK_MSG( err == noErr, NULL, wxT("Error when constructing icon ref") ); - } - - return m_iconRef ; -} - -PicHandle wxBitmapRefData::GetPictHandle() -{ - if ( m_pictHandle == NULL ) - { -#ifndef __LP64__ - GraphicsExportComponent exporter = 0; - OSStatus err = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypePicture, &exporter); - if (noErr == err) - { - m_pictHandle = (PicHandle) NewHandle(0); - if ( m_pictHandle ) - { - // QT does not correctly export the mask - // TODO if we get around to it create a synthetic PICT with the CopyBits and Mask commands - CGImageRef imageRef = CreateCGImage(); - err = GraphicsExportSetInputCGImage( exporter, imageRef ); - err = GraphicsExportSetOutputHandle(exporter, (Handle)m_pictHandle); - err = GraphicsExportDoExport(exporter, NULL); - CGImageRelease( imageRef ); - - size_t handleSize = GetHandleSize( (Handle) m_pictHandle ); - // the 512 bytes header is only needed for pict files, but not in memory - if ( handleSize >= 512 ) - { - memmove( *m_pictHandle , (char*)(*m_pictHandle)+512, handleSize - 512 ); - SetHandleSize( (Handle) m_pictHandle, handleSize - 512 ); - } - } - CloseComponent( exporter ); - } -#endif - } - - return m_pictHandle ; -} -#endif - -CGImageRef wxBitmapRefData::CreateCGImage() const -{ - wxASSERT( m_ok ) ; - wxASSERT( m_rawAccessCount >= 0 ) ; - CGImageRef image ; - if ( m_rawAccessCount > 0 || m_cgImageRef == NULL ) - { - if ( m_depth != 1 && m_bitmapMask == NULL ) - { - if ( m_bitmapMask ) - { - CGImageRef tempImage = CGBitmapContextCreateImage( m_hBitmap ); - CGImageRef tempMask = CGBitmapContextCreateImage((CGContextRef) m_bitmapMask->GetHBITMAP() ); - image = CGImageCreateWithMask( tempImage, tempMask ); - CGImageRelease(tempMask); - CGImageRelease(tempImage); - } - else - image = CGBitmapContextCreateImage( m_hBitmap ); - } - else - { - size_t imageSize = m_height * m_bytesPerRow ; - void * dataBuffer = m_memBuf.GetData() ; - int w = m_width ; - int h = m_height ; - CGImageAlphaInfo alphaInfo = kCGImageAlphaNoneSkipFirst ; - wxMemoryBuffer membuf; - - if ( m_bitmapMask ) - { - alphaInfo = kCGImageAlphaFirst ; - unsigned char *destalphastart = (unsigned char*) membuf.GetWriteBuf( imageSize ) ; - memcpy( destalphastart , dataBuffer , imageSize ) ; - unsigned char *sourcemaskstart = (unsigned char *) m_bitmapMask->GetRawAccess() ; - int maskrowbytes = m_bitmapMask->GetBytesPerRow() ; - for ( int y = 0 ; y < h ; ++y , destalphastart += m_bytesPerRow, sourcemaskstart += maskrowbytes) - { - unsigned char *sourcemask = sourcemaskstart ; - unsigned char *destalpha = destalphastart ; - for ( int x = 0 ; x < w ; ++x , sourcemask += kMaskBytesPerPixel , destalpha += 4 ) - { - *destalpha = 0xFF - *sourcemask ; - } - } - membuf.UngetWriteBuf( imageSize ); - } - else - { - if ( m_hasAlpha ) - { -#if wxOSX_USE_PREMULTIPLIED_ALPHA - alphaInfo = kCGImageAlphaPremultipliedFirst ; -#else - alphaInfo = kCGImageAlphaFirst ; -#endif - } - - membuf = m_memBuf; - } - - CGDataProviderRef dataProvider = NULL ; - if ( m_depth == 1 ) - { - // TODO CHECK ALIGNMENT - wxMemoryBuffer maskBuf; - unsigned char * maskBufData = (unsigned char*) maskBuf.GetWriteBuf( m_width * m_height ); - unsigned char * bufData = (unsigned char *) membuf.GetData() ; - // copy one color component - size_t i = 0; - for( int y = 0 ; y < m_height ; bufData+= m_bytesPerRow, ++y ) - { - unsigned char *bufDataIter = bufData+3; - for ( int x = 0 ; x < m_width ; bufDataIter += 4, ++x, ++i ) - { - maskBufData[i] = *bufDataIter; - } - } - maskBuf.UngetWriteBuf( m_width * m_height ); - - dataProvider = - wxMacCGDataProviderCreateWithMemoryBuffer( maskBuf ); - - image = ::CGImageMaskCreate( w, h, 8, 8, m_width , dataProvider, NULL, false ); - } - else - { - CGColorSpaceRef colorSpace = wxMacGetGenericRGBColorSpace(); - dataProvider = wxMacCGDataProviderCreateWithMemoryBuffer( membuf ); - image = - ::CGImageCreate( - w, h, 8 , 32 , m_bytesPerRow , colorSpace, alphaInfo , - dataProvider, NULL , false , kCGRenderingIntentDefault ); - } - CGDataProviderRelease( dataProvider); - } - } - else - { - image = m_cgImageRef ; - CGImageRetain( image ) ; - } - - if ( m_rawAccessCount == 0 && m_cgImageRef == NULL) - { - // we keep it for later use - m_cgImageRef = image ; - CGImageRetain( image ) ; - } - - return image ; -} - -CGContextRef wxBitmapRefData::GetBitmapContext() const -{ - return m_hBitmap; -} - -void wxBitmapRefData::Free() -{ - wxASSERT_MSG( m_rawAccessCount == 0 , wxT("Bitmap still selected when destroyed") ) ; - - if ( m_cgImageRef ) - { - CGImageRelease( m_cgImageRef ) ; - m_cgImageRef = NULL ; - } -#ifndef __WXOSX_IPHONE__ - if ( m_iconRef ) - { - ReleaseIconRef( m_iconRef ) ; - m_iconRef = NULL ; - } - -#ifndef __LP64__ - if ( m_pictHandle ) - { - KillPicture( m_pictHandle ) ; - m_pictHandle = NULL ; - } -#endif -#endif - if ( m_hBitmap ) - { - CGContextRelease(m_hBitmap); - m_hBitmap = NULL ; - } - - if (m_bitmapMask) - { - delete m_bitmapMask; - m_bitmapMask = NULL; - } -} - -wxBitmapRefData::~wxBitmapRefData() -{ - Free() ; -} - -bool wxBitmap::CopyFromIcon(const wxIcon& icon) -{ - bool created = false ; - int w = icon.GetWidth() ; - int h = icon.GetHeight() ; - - Create( icon.GetWidth() , icon.GetHeight() ) ; -#ifndef __WXOSX_IPHONE__ - if ( w == h && ( w == 16 || w == 32 || w == 48 || w == 128 ) ) - { - IconFamilyHandle iconFamily = NULL ; - Handle imagehandle = NewHandle( 0 ) ; - Handle maskhandle = NewHandle( 0 ) ; - - OSType maskType = 0; - OSType dataType = 0; - IconSelectorValue selector = 0 ; - - switch (w) - { - case 128: - dataType = kThumbnail32BitData ; - maskType = kThumbnail8BitMask ; - selector = kSelectorAllAvailableData ; - break; - - case 48: - dataType = kHuge32BitData ; - maskType = kHuge8BitMask ; - selector = kSelectorHuge32Bit | kSelectorHuge8BitMask ; - break; - - case 32: - dataType = kLarge32BitData ; - maskType = kLarge8BitMask ; - selector = kSelectorLarge32Bit | kSelectorLarge8BitMask ; - break; - - case 16: - dataType = kSmall32BitData ; - maskType = kSmall8BitMask ; - selector = kSelectorSmall32Bit | kSelectorSmall8BitMask ; - break; - - default: - break; - } - - OSStatus err = IconRefToIconFamily( MAC_WXHICON(icon.GetHICON()) , selector , &iconFamily ) ; - - err = GetIconFamilyData( iconFamily , dataType , imagehandle ) ; - err = GetIconFamilyData( iconFamily , maskType , maskhandle ) ; - size_t imagehandlesize = GetHandleSize( imagehandle ) ; - size_t maskhandlesize = GetHandleSize( maskhandle ) ; - - if ( imagehandlesize != 0 && maskhandlesize != 0 ) - { - wxASSERT( GetHandleSize( imagehandle ) == w * 4 * h ) ; - wxASSERT( GetHandleSize( maskhandle ) == w * h ) ; - - UseAlpha() ; - - unsigned char *source = (unsigned char *) *imagehandle ; - unsigned char *sourcemask = (unsigned char *) *maskhandle ; - unsigned char* destination = (unsigned char*) BeginRawAccess() ; - - for ( int y = 0 ; y < h ; ++y ) - { - for ( int x = 0 ; x < w ; ++x ) - { - unsigned char a = *sourcemask++; - *destination++ = a; - source++ ; -#if wxOSX_USE_PREMULTIPLIED_ALPHA - *destination++ = ( (*source++) * a + 127 ) / 255; - *destination++ = ( (*source++) * a + 127 ) / 255; - *destination++ = ( (*source++) * a + 127 ) / 255; -#else - *destination++ = *source++ ; - *destination++ = *source++ ; - *destination++ = *source++ ; -#endif - } - } - - EndRawAccess() ; - DisposeHandle( imagehandle ) ; - DisposeHandle( maskhandle ) ; - created = true ; - } - - DisposeHandle( (Handle) iconFamily ) ; - } -#endif - if ( !created ) - { - wxMemoryDC dc ; - dc.SelectObject( *this ) ; - dc.DrawIcon( icon , 0 , 0 ) ; - dc.SelectObject( wxNullBitmap ) ; - } - - return true; -} - -wxBitmap::wxBitmap() -{ -} - -wxBitmap::~wxBitmap() -{ -} - -wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits) -{ - wxBitmapRefData* bitmapRefData; - - m_refData = bitmapRefData = new wxBitmapRefData( the_width , the_height , no_bits ) ; - - if (bitmapRefData->IsOk()) - { - if ( no_bits == 1 ) - { - int linesize = ( the_width / (sizeof(unsigned char) * 8)) ; - if ( the_width % (sizeof(unsigned char) * 8) ) - linesize += sizeof(unsigned char); - - unsigned char* linestart = (unsigned char*) bits ; - unsigned char* destptr = (unsigned char*) BeginRawAccess() ; - - for ( int y = 0 ; y < the_height ; ++y , linestart += linesize, destptr += M_BITMAPDATA->GetBytesPerRow() ) - { - unsigned char* destination = destptr; - int index, bit, mask; - - for ( int x = 0 ; x < the_width ; ++x ) - { - index = x / 8 ; - bit = x % 8 ; - mask = 1 << bit ; - - if ( linestart[index] & mask ) - { - *destination++ = 0xFF ; - *destination++ = 0 ; - *destination++ = 0 ; - *destination++ = 0 ; - } - else - { - *destination++ = 0xFF ; - *destination++ = 0xFF ; - *destination++ = 0xFF ; - *destination++ = 0xFF ; - } - } - } - - EndRawAccess() ; - } - else - { - wxFAIL_MSG(wxT("multicolor BITMAPs not yet implemented")); - } - } /* bitmapRefData->IsOk() */ -} - -wxBitmap::wxBitmap(int w, int h, int d) -{ - (void)Create(w, h, d); -} - -wxBitmap::wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth) -{ - (void) Create(data, type, width, height, depth); -} - -wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type) -{ - LoadFile(filename, type); -} - -wxGDIRefData* wxBitmap::CreateGDIRefData() const -{ - return new wxBitmapRefData; -} - -wxGDIRefData* wxBitmap::CloneGDIRefData(const wxGDIRefData* data) const -{ - return new wxBitmapRefData(*wx_static_cast(const wxBitmapRefData *, data)); -} - -void * wxBitmap::GetRawAccess() const -{ - wxCHECK_MSG( Ok() , NULL , wxT("invalid bitmap") ) ; - - return M_BITMAPDATA->GetRawAccess() ; -} - -void * wxBitmap::BeginRawAccess() -{ - wxCHECK_MSG( Ok() , NULL , wxT("invalid bitmap") ) ; - - return M_BITMAPDATA->BeginRawAccess() ; -} - -void wxBitmap::EndRawAccess() -{ - wxCHECK_RET( Ok() , wxT("invalid bitmap") ) ; - - M_BITMAPDATA->EndRawAccess() ; -} - -CGImageRef wxBitmap::CreateCGImage() const -{ - wxCHECK_MSG( Ok(), NULL , wxT("invalid bitmap") ) ; - - return M_BITMAPDATA->CreateCGImage() ; -} - -#ifndef __WXOSX_IPHONE__ -IconRef wxBitmap::GetIconRef() const -{ - wxCHECK_MSG( Ok(), NULL , wxT("invalid bitmap") ) ; - - return M_BITMAPDATA->GetIconRef() ; -} - -IconRef wxBitmap::CreateIconRef() const -{ - IconRef icon = GetIconRef(); - verify_noerr( AcquireIconRef(icon) ); - return icon; -} -#endif - -wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const -{ - wxCHECK_MSG( Ok() && - (rect.x >= 0) && (rect.y >= 0) && - (rect.x+rect.width <= GetWidth()) && - (rect.y+rect.height <= GetHeight()), - wxNullBitmap, wxT("invalid bitmap or bitmap region") ); - - wxBitmap ret( rect.width, rect.height, GetDepth() ); - wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") ); - - int destwidth = rect.width ; - int destheight = rect.height ; - - { - unsigned char *sourcedata = (unsigned char*) GetRawAccess() ; - unsigned char *destdata = (unsigned char*) ret.BeginRawAccess() ; - wxASSERT( (sourcedata != NULL) && (destdata != NULL) ) ; - - int sourcelinesize = GetBitmapData()->GetBytesPerRow() ; - int destlinesize = ret.GetBitmapData()->GetBytesPerRow() ; - unsigned char *source = sourcedata + rect.x * 4 + rect.y * sourcelinesize ; - unsigned char *dest = destdata ; - - for (int yy = 0; yy < destheight; ++yy, source += sourcelinesize , dest += destlinesize) - { - memcpy( dest , source , destlinesize ) ; - } - } - - ret.EndRawAccess() ; - - if ( M_BITMAPDATA->m_bitmapMask ) - { - wxMemoryBuffer maskbuf ; - int rowBytes = GetBestBytesPerRow( destwidth * kMaskBytesPerPixel ); - size_t maskbufsize = rowBytes * destheight ; - - int sourcelinesize = M_BITMAPDATA->m_bitmapMask->GetBytesPerRow() ; - int destlinesize = rowBytes ; - - unsigned char *source = (unsigned char *) M_BITMAPDATA->m_bitmapMask->GetRawAccess() ; - unsigned char *destdata = (unsigned char * ) maskbuf.GetWriteBuf( maskbufsize ) ; - wxASSERT( (source != NULL) && (destdata != NULL) ) ; - - source += rect.x * kMaskBytesPerPixel + rect.y * sourcelinesize ; - unsigned char *dest = destdata ; - - for (int yy = 0; yy < destheight; ++yy, source += sourcelinesize , dest += destlinesize) - { - memcpy( dest , source , destlinesize ) ; - } - - maskbuf.UngetWriteBuf( maskbufsize ) ; - ret.SetMask( new wxMask( maskbuf , destwidth , destheight , rowBytes ) ) ; - } - else if ( HasAlpha() ) - ret.UseAlpha() ; - - return ret; -} - -bool wxBitmap::Create(int w, int h, int d) -{ - UnRef(); - - if ( d < 0 ) - d = wxDisplayDepth() ; - - m_refData = new wxBitmapRefData( w , h , d ); - - return M_BITMAPDATA->IsOk() ; -} - -bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) -{ - UnRef(); - - wxBitmapHandler *handler = FindHandler(type); - - if ( handler ) - { - m_refData = new wxBitmapRefData; - - return handler->LoadFile(this, filename, type, -1, -1); - } - else - { -#if wxUSE_IMAGE - wxImage loadimage(filename, type); - if (loadimage.Ok()) - { - *this = loadimage; - - return true; - } -#endif - } - - wxLogWarning(wxT("no bitmap handler for type %d defined."), type); - - return false; -} - -bool wxBitmap::Create(const void* data, wxBitmapType type, int width, int height, int depth) -{ - UnRef(); - - m_refData = new wxBitmapRefData; - - wxBitmapHandler *handler = FindHandler(type); - - if ( handler == NULL ) - { - wxLogWarning(wxT("no bitmap handler for type %d defined."), type); - - return false; - } - - return handler->Create(this, data, type, width, height, depth); -} - -#if wxUSE_IMAGE - -wxBitmap::wxBitmap(const wxImage& image, int depth) -{ - wxCHECK_RET( image.Ok(), wxT("invalid image") ); - - // width and height of the device-dependent bitmap - int width = image.GetWidth(); - int height = image.GetHeight(); - - wxBitmapRefData* bitmapRefData; - - m_refData = bitmapRefData = new wxBitmapRefData( width , height , depth ) ; - - if ( bitmapRefData->IsOk()) - { - // Create picture - - bool hasAlpha = false ; - - if ( image.HasMask() ) - { - // takes precedence, don't mix with alpha info - } - else - { - hasAlpha = image.HasAlpha() ; - } - - if ( hasAlpha ) - UseAlpha() ; - - unsigned char* destinationstart = (unsigned char*) BeginRawAccess() ; - register unsigned char* data = image.GetData(); - if ( destinationstart != NULL && data != NULL ) - { - const unsigned char *alpha = hasAlpha ? image.GetAlpha() : NULL ; - for (int y = 0; y < height; destinationstart += M_BITMAPDATA->GetBytesPerRow(), y++) - { - unsigned char * destination = destinationstart; - for (int x = 0; x < width; x++) - { - if ( hasAlpha ) - { - const unsigned char a = *alpha++; - *destination++ = a ; - - #if wxOSX_USE_PREMULTIPLIED_ALPHA - *destination++ = ((*data++) * a + 127) / 255 ; - *destination++ = ((*data++) * a + 127) / 255 ; - *destination++ = ((*data++) * a + 127) / 255 ; - #else - *destination++ = *data++ ; - *destination++ = *data++ ; - *destination++ = *data++ ; - #endif - } - else - { - *destination++ = 0xFF ; - *destination++ = *data++ ; - *destination++ = *data++ ; - *destination++ = *data++ ; - } - } - } - - EndRawAccess() ; - } - if ( image.HasMask() ) - SetMask( new wxMask( *this , wxColour( image.GetMaskRed() , image.GetMaskGreen() , image.GetMaskBlue() ) ) ) ; - } /* bitmapRefData->IsOk() */ -} - -wxImage wxBitmap::ConvertToImage() const -{ - wxImage image; - - wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") ); - - // create an wxImage object - int width = GetWidth(); - int height = GetHeight(); - image.Create( width, height ); - - unsigned char *data = image.GetData(); - wxCHECK_MSG( data, wxNullImage, wxT("Could not allocate data for image") ); - - unsigned char* sourcestart = (unsigned char*) GetRawAccess() ; - - bool hasAlpha = false ; - bool hasMask = false ; - int maskBytesPerRow = 0 ; - unsigned char *alpha = NULL ; - unsigned char *mask = NULL ; - - if ( HasAlpha() ) - hasAlpha = true ; - - if ( GetMask() ) - { - hasMask = true ; - mask = (unsigned char*) GetMask()->GetRawAccess() ; - maskBytesPerRow = GetMask()->GetBytesPerRow() ; - } - - if ( hasAlpha ) - { - image.SetAlpha() ; - alpha = image.GetAlpha() ; - } - - int index = 0; - - // The following masking algorithm is the same as well in msw/gtk: - // the colour used as transparent one in wxImage and the one it is - // replaced with when it actually occurs in the bitmap - static const int MASK_RED = 1; - static const int MASK_GREEN = 2; - static const int MASK_BLUE = 3; - static const int MASK_BLUE_REPLACEMENT = 2; - - for (int yy = 0; yy < height; yy++ , sourcestart += M_BITMAPDATA->GetBytesPerRow() , mask += maskBytesPerRow ) - { - unsigned char * maskp = mask ; - unsigned char * source = sourcestart; - unsigned char a, r, g, b; - long color; - - for (int xx = 0; xx < width; xx++) - { - color = *((long*) source) ; -#ifdef WORDS_BIGENDIAN - a = ((color&0xFF000000) >> 24) ; - r = ((color&0x00FF0000) >> 16) ; - g = ((color&0x0000FF00) >> 8) ; - b = (color&0x000000FF); -#else - b = ((color&0xFF000000) >> 24) ; - g = ((color&0x00FF0000) >> 16) ; - r = ((color&0x0000FF00) >> 8) ; - a = (color&0x000000FF); -#endif - if ( hasMask ) - { - if ( *maskp++ == 0xFF ) - { - r = MASK_RED ; - g = MASK_GREEN ; - b = MASK_BLUE ; - } - else if ( r == MASK_RED && g == MASK_GREEN && b == MASK_BLUE ) - b = MASK_BLUE_REPLACEMENT ; - } - else if ( hasAlpha ) - { - *alpha++ = a ; -#if wxOSX_USE_PREMULTIPLIED_ALPHA - // this must be non-premultiplied data - if ( a != 0xFF && a!= 0 ) - { - r = r * 255 / a; - g = g * 255 / a; - b = b * 255 / a; - } -#endif - } - - data[index ] = r ; - data[index + 1] = g ; - data[index + 2] = b ; - - index += 3; - source += 4 ; - } - } - - if ( hasMask ) - image.SetMaskColour( MASK_RED, MASK_GREEN, MASK_BLUE ); - - return image; -} - -#endif //wxUSE_IMAGE - -bool wxBitmap::SaveFile( const wxString& filename, - wxBitmapType type, const wxPalette *palette ) const -{ - bool success = false; - wxBitmapHandler *handler = FindHandler(type); - - if ( handler ) - { - success = handler->SaveFile(this, filename, type, palette); - } - else - { -#if wxUSE_IMAGE - wxImage image = ConvertToImage(); - success = image.SaveFile(filename, type); -#else - wxLogWarning(wxT("no bitmap handler for type %d defined."), type); -#endif - } - - return success; -} - -int wxBitmap::GetHeight() const -{ - wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") ); - - return M_BITMAPDATA->GetHeight(); -} - -int wxBitmap::GetWidth() const -{ - wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") ); - - return M_BITMAPDATA->GetWidth() ; -} - -int wxBitmap::GetDepth() const -{ - wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") ); - - return M_BITMAPDATA->GetDepth(); -} - -wxMask *wxBitmap::GetMask() const -{ - wxCHECK_MSG( Ok(), (wxMask *) NULL, wxT("invalid bitmap") ); - - return M_BITMAPDATA->m_bitmapMask; -} - -bool wxBitmap::HasAlpha() const -{ - wxCHECK_MSG( Ok(), false , wxT("invalid bitmap") ); - - return M_BITMAPDATA->HasAlpha() ; -} - -void wxBitmap::SetWidth(int w) -{ - AllocExclusive(); - M_BITMAPDATA->SetWidth(w); -} - -void wxBitmap::SetHeight(int h) -{ - AllocExclusive(); - M_BITMAPDATA->SetHeight(h); -} - -void wxBitmap::SetDepth(int d) -{ - AllocExclusive(); - M_BITMAPDATA->SetDepth(d); -} - -void wxBitmap::SetOk(bool isOk) -{ - AllocExclusive(); - M_BITMAPDATA->SetOk(isOk); -} - -#if wxUSE_PALETTE -wxPalette *wxBitmap::GetPalette() const -{ - wxCHECK_MSG( Ok(), NULL, wxT("Invalid bitmap GetPalette()") ); - - return &M_BITMAPDATA->m_bitmapPalette; -} - -void wxBitmap::SetPalette(const wxPalette& palette) -{ - AllocExclusive(); - M_BITMAPDATA->m_bitmapPalette = palette ; -} -#endif // wxUSE_PALETTE - -void wxBitmap::SetMask(wxMask *mask) -{ - AllocExclusive(); - // Remove existing mask if there is one. - delete M_BITMAPDATA->m_bitmapMask; - - M_BITMAPDATA->m_bitmapMask = mask ; -} - -WXHBITMAP wxBitmap::GetHBITMAP(WXHBITMAP* mask) const -{ - wxUnusedVar(mask); - - return WXHBITMAP(M_BITMAPDATA->GetBitmapContext()); -} - -// ---------------------------------------------------------------------------- -// wxMask -// ---------------------------------------------------------------------------- - -wxMask::wxMask() -{ - Init() ; -} - -wxMask::wxMask(const wxMask &tocopy) -{ - Init(); - - m_bytesPerRow = tocopy.m_bytesPerRow; - m_width = tocopy.m_width; - m_height = tocopy.m_height; - - size_t size = m_bytesPerRow * m_height; - unsigned char* dest = (unsigned char*)m_memBuf.GetWriteBuf( size ); - unsigned char* source = (unsigned char*)tocopy.m_memBuf.GetData(); - memcpy( dest, source, size ); - m_memBuf.UngetWriteBuf( size ) ; - RealizeNative() ; -} - -// Construct a mask from a bitmap and a colour indicating -// the transparent area -wxMask::wxMask( const wxBitmap& bitmap, const wxColour& colour ) -{ - Init() ; - Create( bitmap, colour ); -} - -// Construct a mask from a mono bitmap (copies the bitmap). -wxMask::wxMask( const wxBitmap& bitmap ) -{ - Init() ; - Create( bitmap ); -} - -// Construct a mask from a mono bitmap (copies the bitmap). - -wxMask::wxMask( const wxMemoryBuffer& data, int width , int height , int bytesPerRow ) -{ - Init() ; - Create( data, width , height , bytesPerRow ); -} - -wxMask::~wxMask() -{ - if ( m_maskBitmap ) - { - CGContextRelease( (CGContextRef) m_maskBitmap ); - m_maskBitmap = NULL ; - } -} - -void wxMask::Init() -{ - m_width = m_height = m_bytesPerRow = 0 ; - m_maskBitmap = NULL ; -} - -void *wxMask::GetRawAccess() const -{ - return m_memBuf.GetData() ; -} - -// The default ColorTable for k8IndexedGrayPixelFormat in Intel appears to be broken, so we'll use an non-indexed -// bitmap mask instead; in order to keep the code simple, the change applies to PowerPC implementations as well - -void wxMask::RealizeNative() -{ - if ( m_maskBitmap ) - { - CGContextRelease( (CGContextRef) m_maskBitmap ); - m_maskBitmap = NULL ; - } - - CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray(); - // from MouseTracking sample : - // Ironically, due to a bug in CGImageCreateWithMask, you cannot use - // CGColorSpaceCreateWithName(kCGColorSpaceGenericGray) at this point! - - m_maskBitmap = CGBitmapContextCreate((char*) m_memBuf.GetData(), m_width, m_height, 8, m_bytesPerRow, colorspace, - kCGImageAlphaNone ); - CGColorSpaceRelease( colorspace ); - wxASSERT_MSG( m_maskBitmap , wxT("Unable to create CGBitmapContext context") ) ; -} - -// Create a mask from a mono bitmap (copies the bitmap). - -bool wxMask::Create(const wxMemoryBuffer& data,int width , int height , int bytesPerRow) -{ - m_memBuf = data ; - m_width = width ; - m_height = height ; - m_bytesPerRow = bytesPerRow ; - - wxASSERT( data.GetDataLen() == (size_t)(height * bytesPerRow) ) ; - - RealizeNative() ; - - return true ; -} - -// Create a mask from a mono bitmap (copies the bitmap). -bool wxMask::Create(const wxBitmap& bitmap) -{ - m_width = bitmap.GetWidth() ; - m_height = bitmap.GetHeight() ; - m_bytesPerRow = GetBestBytesPerRow( m_width * kMaskBytesPerPixel ) ; - - size_t size = m_bytesPerRow * m_height ; - unsigned char * destdatabase = (unsigned char*) m_memBuf.GetWriteBuf( size ) ; - wxASSERT( destdatabase != NULL ) ; - - memset( destdatabase , 0 , size ) ; - unsigned char * srcdata = (unsigned char*) bitmap.GetRawAccess() ; - - for ( int y = 0 ; y < m_height ; ++y , destdatabase += m_bytesPerRow ) - { - unsigned char *destdata = destdatabase ; - unsigned char r, g, b; - - for ( int x = 0 ; x < m_width ; ++x ) - { - srcdata++ ; - r = *srcdata++ ; - g = *srcdata++ ; - b = *srcdata++ ; - - if ( ( r + g + b ) > 0x10 ) - *destdata++ = 0xFF ; - else - *destdata++ = 0x00 ; - } - } - - m_memBuf.UngetWriteBuf( size ) ; - RealizeNative() ; - - return true; -} - -// Create a mask from a bitmap and a colour indicating -// the transparent area -bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) -{ - m_width = bitmap.GetWidth() ; - m_height = bitmap.GetHeight() ; - m_bytesPerRow = GetBestBytesPerRow( m_width * kMaskBytesPerPixel ) ; - - size_t size = m_bytesPerRow * m_height ; - unsigned char * destdatabase = (unsigned char*) m_memBuf.GetWriteBuf( size ) ; - wxASSERT( destdatabase != NULL ) ; - - memset( destdatabase , 0 , size ) ; - unsigned char * srcdatabase = (unsigned char*) bitmap.GetRawAccess() ; - size_t sourceBytesRow = bitmap.GetBitmapData()->GetBytesPerRow(); - - for ( int y = 0 ; y < m_height ; ++y , srcdatabase+= sourceBytesRow, destdatabase += m_bytesPerRow) - { - unsigned char *srcdata = srcdatabase ; - unsigned char *destdata = destdatabase ; - unsigned char r, g, b; - - for ( int x = 0 ; x < m_width ; ++x ) - { - srcdata++ ; - r = *srcdata++ ; - g = *srcdata++ ; - b = *srcdata++ ; - - if ( colour == wxColour( r , g , b ) ) - *destdata++ = 0xFF ; - else - *destdata++ = 0x00 ; - } - } - - m_memBuf.UngetWriteBuf( size ) ; - RealizeNative() ; - - return true; -} - -WXHBITMAP wxMask::GetHBITMAP() const -{ - return m_maskBitmap ; -} - -// ---------------------------------------------------------------------------- -// Standard Handlers -// ---------------------------------------------------------------------------- - -#if !defined( __LP64__ ) && !defined(__WXOSX_IPHONE__) - -class WXDLLEXPORT wxPICTResourceHandler: public wxBitmapHandler -{ - DECLARE_DYNAMIC_CLASS(wxPICTResourceHandler) - -public: - inline wxPICTResourceHandler() - { - SetName(wxT("Macintosh Pict resource")); - SetExtension(wxEmptyString); - SetType(wxBITMAP_TYPE_PICT_RESOURCE); - }; - - virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight); -}; - -IMPLEMENT_DYNAMIC_CLASS(wxPICTResourceHandler, wxBitmapHandler) - - -bool wxPICTResourceHandler::LoadFile(wxBitmap *bitmap, - const wxString& name, - long WXUNUSED(flags), - int WXUNUSED(desiredWidth), - int WXUNUSED(desiredHeight)) -{ -#if wxUSE_METAFILE - Str255 theName ; - wxMacStringToPascal( name , theName ) ; - - PicHandle thePict = (PicHandle ) GetNamedResource( 'PICT' , theName ) ; - if ( thePict ) - { - wxMetafile mf ; - - mf.SetPICT( thePict ) ; - bitmap->Create( mf.GetWidth() , mf.GetHeight() ) ; - wxMemoryDC dc ; - dc.SelectObject( *bitmap ) ; - mf.Play( &dc ) ; - dc.SelectObject( wxNullBitmap ) ; - - return true ; - } -#endif - - return false ; -} -#endif - -void wxBitmap::InitStandardHandlers() -{ -#if !defined( __LP64__ ) && !defined(__WXOSX_IPHONE__) - AddHandler( new wxPICTResourceHandler ) ; -#endif -#if wxOSX_USE_COCOA_OR_CARBON - AddHandler( new wxICONResourceHandler ) ; -#endif -} - -// ---------------------------------------------------------------------------- -// raw bitmap access support -// ---------------------------------------------------------------------------- - -void *wxBitmap::GetRawData(wxPixelDataBase& data, int WXUNUSED(bpp)) -{ - if ( !Ok() ) - // no bitmap, no data (raw or otherwise) - return NULL; - - data.m_width = GetWidth() ; - data.m_height = GetHeight() ; - data.m_stride = GetBitmapData()->GetBytesPerRow() ; - - return BeginRawAccess() ; -} - -void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(dataBase)) -{ - EndRawAccess() ; -} - -void wxBitmap::UseAlpha() -{ - // remember that we are using alpha channel: - // we'll need to create a proper mask in UngetRawData() - M_BITMAPDATA->UseAlpha( true ); -} diff --git a/src/osx/carbon/dcmemory.cpp b/src/osx/carbon/dcmemory.cpp deleted file mode 100644 index e75442fb9c..0000000000 --- a/src/osx/carbon/dcmemory.cpp +++ /dev/null @@ -1,116 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/dcmemory.cpp -// Purpose: wxMemoryDC class -// Author: Stefan Csomor -// Modified by: -// Created: 01/02/97 -// RCS-ID: $Id$ -// Copyright: (c) Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#include "wx/dcmemory.h" -#include "wx/graphics.h" -#include "wx/osx/dcmemory.h" - -#include "wx/osx/private.h" - -//----------------------------------------------------------------------------- -// wxMemoryDCImpl -//----------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl,wxPaintDCImpl) - - -wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner ) - : wxPaintDCImpl( owner ) -{ - Init(); -} - -wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap ) - : wxPaintDCImpl( owner ) -{ - Init(); - DoSelect(bitmap); -} - -wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxDC * WXUNUSED(dc) ) - : wxPaintDCImpl( owner ) -{ - Init(); -} - -void wxMemoryDCImpl::Init() -{ - m_ok = true; - SetBackground(*wxWHITE_BRUSH); - SetBrush(*wxWHITE_BRUSH); - SetPen(*wxBLACK_PEN); - SetFont(*wxNORMAL_FONT); - m_ok = false; -} - -wxMemoryDCImpl::~wxMemoryDCImpl() -{ - if ( m_selected.Ok() ) - { - m_selected.EndRawAccess() ; - delete m_graphicContext ; - m_graphicContext = NULL ; - } -} - -void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) -{ - if ( m_selected.Ok() ) - { - m_selected.EndRawAccess() ; - delete m_graphicContext ; - m_graphicContext = NULL ; - } - - m_selected = bitmap; - if (m_selected.Ok()) - { - if ( m_selected.GetDepth() != 1 ) - m_selected.UseAlpha() ; - m_selected.BeginRawAccess() ; - m_width = bitmap.GetWidth(); - m_height = bitmap.GetHeight(); - CGColorSpaceRef genericColorSpace = wxMacGetGenericRGBColorSpace(); - CGContextRef bmCtx = (CGContextRef) m_selected.GetHBITMAP(); - - if ( bmCtx ) - { - CGContextSetFillColorSpace( bmCtx, genericColorSpace ); - CGContextSetStrokeColorSpace( bmCtx, genericColorSpace ); - SetGraphicsContext( wxGraphicsContext::CreateFromNative( bmCtx ) ); - } - m_ok = (m_graphicContext != NULL) ; - } - else - { - m_ok = false; - } -} - -void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const -{ - if (m_selected.Ok()) - { - if (width) - (*width) = m_selected.GetWidth(); - if (height) - (*height) = m_selected.GetHeight(); - } - else - { - if (width) - (*width) = 0; - if (height) - (*height) = 0; - } -} diff --git a/src/osx/carbon/display.cpp b/src/osx/carbon/display.cpp deleted file mode 100644 index 6743a09f6d..0000000000 --- a/src/osx/carbon/display.cpp +++ /dev/null @@ -1,265 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/display.cpp -// Purpose: Mac implementation of wxDisplay class -// Author: Ryan Norton & Brian Victor -// Modified by: Royce Mitchell III, Vadim Zeitlin -// Created: 06/21/02 -// RCS-ID: $Id$ -// Copyright: (c) wxWidgets team -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_DISPLAY - -#include "wx/display.h" - -#ifndef WX_PRECOMP - #include "wx/dynarray.h" - #include "wx/log.h" - #include "wx/string.h" - #include "wx/gdicmn.h" -#endif - -#include "wx/display_impl.h" -#include "wx/osx/private.h" - -#if wxOSX_USE_COCOA_OR_CARBON - -// ---------------------------------------------------------------------------- -// display classes implementation -// ---------------------------------------------------------------------------- - -class wxDisplayImplMacOSX : public wxDisplayImpl -{ -public: - wxDisplayImplMacOSX(unsigned n, CGDirectDisplayID id) - : wxDisplayImpl(n), - m_id(id) - { - } - - virtual wxRect GetGeometry() const; - virtual wxRect GetClientArea() const; - virtual wxString GetName() const { return wxString(); } - - virtual wxArrayVideoModes GetModes(const wxVideoMode& mode) const; - virtual wxVideoMode GetCurrentMode() const; - virtual bool ChangeMode(const wxVideoMode& mode); - -private: - CGDirectDisplayID m_id; - - DECLARE_NO_COPY_CLASS(wxDisplayImplMacOSX) -}; - -class wxDisplayFactoryMacOSX : public wxDisplayFactory -{ -public: - wxDisplayFactoryMacOSX() {} - - virtual wxDisplayImpl *CreateDisplay(unsigned n); - virtual unsigned GetCount(); - virtual int GetFromPoint(const wxPoint& pt); - -protected: - DECLARE_NO_COPY_CLASS(wxDisplayFactoryMacOSX) -}; - -// ============================================================================ -// wxDisplayFactoryMacOSX implementation -// ============================================================================ - -unsigned wxDisplayFactoryMacOSX::GetCount() -{ - CGDisplayCount count; -#ifdef __WXDEBUG__ - CGDisplayErr err = -#endif - CGGetActiveDisplayList(0, NULL, &count); - - wxASSERT(err == CGDisplayNoErr); - - return count; -} - -int wxDisplayFactoryMacOSX::GetFromPoint(const wxPoint& p) -{ - CGPoint thePoint = {(float)p.x, (float)p.y}; - CGDirectDisplayID theID; - CGDisplayCount theCount; - CGDisplayErr err = CGGetDisplaysWithPoint(thePoint, 1, &theID, &theCount); - wxASSERT(err == CGDisplayNoErr); - - int nWhich = wxNOT_FOUND; - - if (theCount) - { - theCount = GetCount(); - CGDirectDisplayID* theIDs = new CGDirectDisplayID[theCount]; - err = CGGetActiveDisplayList(theCount, theIDs, &theCount); - wxASSERT(err == CGDisplayNoErr); - - for (nWhich = 0; nWhich < (int) theCount; ++nWhich) - { - if (theIDs[nWhich] == theID) - break; - } - - delete [] theIDs; - - if (nWhich == (int) theCount) - { - wxFAIL_MSG(wxT("Failed to find display in display list")); - nWhich = wxNOT_FOUND; - } - } - - return nWhich; -} - -wxDisplayImpl *wxDisplayFactoryMacOSX::CreateDisplay(unsigned n) -{ - CGDisplayCount theCount = GetCount(); - CGDirectDisplayID* theIDs = new CGDirectDisplayID[theCount]; - -#ifdef __WXDEBUG__ - CGDisplayErr err = -#endif - CGGetActiveDisplayList(theCount, theIDs, &theCount); - - wxASSERT( err == CGDisplayNoErr ); - wxASSERT( n < theCount ); - - wxDisplayImplMacOSX *display = new wxDisplayImplMacOSX(n, theIDs[n]); - - delete [] theIDs; - - return display; -} - -// ============================================================================ -// wxDisplayImplMacOSX implementation -// ============================================================================ - -wxRect wxDisplayImplMacOSX::GetGeometry() const -{ - CGRect theRect = CGDisplayBounds(m_id); - return wxRect( (int)theRect.origin.x, - (int)theRect.origin.y, - (int)theRect.size.width, - (int)theRect.size.height ); //floats -} - -wxRect wxDisplayImplMacOSX::GetClientArea() const -{ - // VZ: I don't know how to get client area for arbitrary display but - // wxGetClientDisplayRect() does work correctly for at least the main - // one (TODO: do it correctly for the other displays too) - if ( IsPrimary() ) - return wxGetClientDisplayRect(); - - return wxDisplayImpl::GetClientArea(); -} - -static int wxCFDictKeyToInt( CFDictionaryRef desc, CFStringRef key ) -{ - CFNumberRef value = (CFNumberRef) CFDictionaryGetValue( desc, key ); - if (value == NULL) - return 0; - - int num = 0; - CFNumberGetValue( value, kCFNumberIntType, &num ); - - return num; -} - -wxArrayVideoModes wxDisplayImplMacOSX::GetModes(const wxVideoMode& mode) const -{ - wxArrayVideoModes resultModes; - - CFArrayRef theArray = CGDisplayAvailableModes( m_id ); - - for (CFIndex i = 0; i < CFArrayGetCount(theArray); ++i) - { - CFDictionaryRef theValue = (CFDictionaryRef) CFArrayGetValueAtIndex( theArray, i ); - - wxVideoMode theMode( - wxCFDictKeyToInt( theValue, kCGDisplayWidth ), - wxCFDictKeyToInt( theValue, kCGDisplayHeight ), - wxCFDictKeyToInt( theValue, kCGDisplayBitsPerPixel ), - wxCFDictKeyToInt( theValue, kCGDisplayRefreshRate )); - - if (theMode.Matches( mode )) - resultModes.Add( theMode ); - } - - return resultModes; -} - -wxVideoMode wxDisplayImplMacOSX::GetCurrentMode() const -{ - CFDictionaryRef theValue = CGDisplayCurrentMode( m_id ); - - return wxVideoMode( - wxCFDictKeyToInt( theValue, kCGDisplayWidth ), - wxCFDictKeyToInt( theValue, kCGDisplayHeight ), - wxCFDictKeyToInt( theValue, kCGDisplayBitsPerPixel ), - wxCFDictKeyToInt( theValue, kCGDisplayRefreshRate )); -} - -bool wxDisplayImplMacOSX::ChangeMode( const wxVideoMode& mode ) -{ - // Changing to default mode (wxDefaultVideoMode) doesn't - // work because we don't have access to the system's 'scrn' - // resource which holds the user's mode which the system - // will return to after this app is done - boolean_t bExactMatch; - CFDictionaryRef theCGMode = CGDisplayBestModeForParametersAndRefreshRate( - m_id, - (size_t)mode.GetDepth(), - (size_t)mode.GetWidth(), - (size_t)mode.GetHeight(), - (double)mode.GetRefresh(), - &bExactMatch ); - - bool bOK = bExactMatch; - - if (bOK) - bOK = CGDisplaySwitchToMode( m_id, theCGMode ) == CGDisplayNoErr; - - return bOK; -} - -// ============================================================================ -// wxDisplay::CreateFactory() -// ============================================================================ - -/* static */ wxDisplayFactory *wxDisplay::CreateFactory() -{ - return new wxDisplayFactoryMacOSX; -} - -#else - -/* static */ wxDisplayFactory *wxDisplay::CreateFactory() -{ - return new wxDisplayFactorySingle; -} - -#endif - -#endif // wxUSE_DISPLAY diff --git a/src/osx/carbon/fontenum.cpp b/src/osx/carbon/fontenum.cpp deleted file mode 100644 index 38f933e597..0000000000 --- a/src/osx/carbon/fontenum.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/fontenum.cpp -// Purpose: wxFontEnumerator class for MacOS -// Author: Stefan Csomor -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Stefan Csomor -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#if wxUSE_FONTENUM - -#include "wx/fontenum.h" - -#ifndef WX_PRECOMP - #include "wx/font.h" - #include "wx/intl.h" -#endif - -#include "wx/fontutil.h" -#include "wx/fontmap.h" -#include "wx/encinfo.h" - -#include "wx/osx/private.h" - -// ---------------------------------------------------------------------------- -// wxFontEnumerator -// ---------------------------------------------------------------------------- - -bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding, - bool fixedWidthOnly) -{ - if ( fixedWidthOnly ) - { - wxFAIL_MSG( "enumerating only fixed width fonts not supported" ); - return false; - } - - wxArrayString fontFamilies ; - -#if wxOSX_USE_ATSU_TEXT || wxOSX_USE_CORE_TEXT - - // - // From Apple's QA 1471 http://developer.apple.com/qa/qa2006/qa1471.html - // - - ATSFontFamilyIterator theFontFamilyIterator = NULL; - ATSFontFamilyRef theATSFontFamilyRef = 0; - OSStatus status = noErr; - - // Create the iterator - status = ATSFontFamilyIteratorCreate(kATSFontContextLocal, nil,nil, - kATSOptionFlagsUnRestrictedScope, - &theFontFamilyIterator ); - - wxUint32 macEncoding = wxMacGetSystemEncFromFontEnc(encoding) ; - - while (status == noErr) - { - // Get the next font in the iteration. - status = ATSFontFamilyIteratorNext( theFontFamilyIterator, &theATSFontFamilyRef ); - if(status == noErr) - { - #ifndef __LP64__ - // TODO CS : Find replacement - // added CS : avoid showing fonts that won't be displayable - FMFontStyle intrinsicStyle = 0 ; - FMFont fontInstance ; - FMFontFamily fmFamily = FMGetFontFamilyFromATSFontFamilyRef( theATSFontFamilyRef ); - status = FMGetFontFromFontFamilyInstance( fmFamily , 0 , &fontInstance , &intrinsicStyle); - if ( status != noErr ) - { - status = noErr; - continue ; - } -#endif - if ( encoding != wxFONTENCODING_SYSTEM ) - { - TextEncoding fontFamiliyEncoding = ATSFontFamilyGetEncoding(theATSFontFamilyRef) ; - if ( fontFamiliyEncoding != macEncoding ) - continue ; - } - - // TODO: determine fixed widths ... - - CFStringRef theName = NULL; - ATSFontFamilyGetName(theATSFontFamilyRef, kATSOptionFlagsDefault, &theName); - wxCFStringRef cfName(theName) ; - fontFamilies.Add(cfName.AsString(wxLocale::GetSystemEncoding())); - } - else if (status == kATSIterationScopeModified) // Make sure the font database hasnÕt changed. - { - // reset the iterator - status = ATSFontFamilyIteratorReset (kATSFontContextLocal, nil, nil, - kATSOptionFlagsUnRestrictedScope, - &theFontFamilyIterator); - fontFamilies.Clear() ; - } - } - ATSFontFamilyIteratorRelease(&theFontFamilyIterator); -#endif - - for ( size_t i = 0 ; i < fontFamilies.Count() ; ++i ) - { - if ( OnFacename( fontFamilies[i] ) == false ) - break ; - } - - return true; -} - -bool wxFontEnumerator::EnumerateEncodings(const wxString& WXUNUSED(family)) -{ - wxFAIL_MSG(wxT("wxFontEnumerator::EnumerateEncodings() not yet implemented")); - - return true; -} - -#endif // wxUSE_FONTENUM diff --git a/src/osx/carbon/fontutil.cpp b/src/osx/carbon/fontutil.cpp deleted file mode 100644 index 5fc4804433..0000000000 --- a/src/osx/carbon/fontutil.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: msw/fontutil.cpp -// Purpose: font-related helper functions for wxMSW -// Author: Vadim Zeitlin -// Modified by: -// Created: 05.11.99 -// RCS-ID: $Id$ -// Copyright: (c) 1999 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/string.h" - #include "wx/wxcrtvararg.h" - #include "wx/log.h" - #include "wx/intl.h" -#endif - -#include "wx/fontutil.h" -#include "wx/fontmap.h" -#include "wx/encinfo.h" -#include "wx/tokenzr.h" - - -// convert to/from the string representation: -// format is facename[;charset] -// -bool wxNativeEncodingInfo::FromString( const wxString& s ) -{ - wxStringTokenizer tokenizer(s, wxT(";")); - - facename = tokenizer.GetNextToken(); - if ( !facename ) - return false; - - wxString tmp = tokenizer.GetNextToken(); - if ( !tmp ) - { - // default charset (don't use DEFAULT_CHARSET though because of subtle - // Windows 9x/NT differences in handling it) - charset = 0; - } - else - { - if ( wxSscanf( tmp, wxT("%u"), &charset ) != 1 ) - // should be a number! - return false; - } - - return true; -} - -wxString wxNativeEncodingInfo::ToString() const -{ - wxString s(facename); - if ( charset != 0 ) - s << wxT(';') << charset; - - return s; -} - -// ---------------------------------------------------------------------------- -// helper functions -// ---------------------------------------------------------------------------- - -bool wxGetNativeFontEncoding( wxFontEncoding encoding, wxNativeEncodingInfo *info ) -{ - wxCHECK_MSG( info, false, wxT("bad pointer in wxGetNativeFontEncoding") ); - - if ( encoding == wxFONTENCODING_DEFAULT ) - encoding = wxFont::GetDefaultEncoding(); - - info->encoding = encoding; - - return true; -} - -bool wxTestFontEncoding( const wxNativeEncodingInfo& WXUNUSED(info) ) -{ - // basically we should be able to support every encoding via the OS - return true; -} diff --git a/src/osx/carbon/imaglist.cpp b/src/osx/carbon/imaglist.cpp deleted file mode 100644 index 054cdeb734..0000000000 --- a/src/osx/carbon/imaglist.cpp +++ /dev/null @@ -1,309 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/imaglist.cpp -// Purpose: -// Author: Robert Roebling -// RCS_ID: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_IMAGLIST - -#include "wx/imaglist.h" - -#ifndef WX_PRECOMP - #include "wx/dc.h" - #include "wx/icon.h" - #include "wx/image.h" -#endif - -IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject) - - -wxImageList::wxImageList( int width, int height, bool mask, int initialCount ) -{ - (void)Create(width, height, mask, initialCount); -} - -wxImageList::~wxImageList() -{ - (void)RemoveAll(); -} - -int wxImageList::GetImageCount() const -{ - return m_images.GetCount(); -} - -bool wxImageList::Create( int width, int height, bool WXUNUSED(mask), int WXUNUSED(initialCount) ) -{ - m_width = width; - m_height = height; - - return Create(); -} - -bool wxImageList::Create() -{ - return true; -} - -int wxImageList::Add( const wxIcon &bitmap ) -{ - wxASSERT_MSG( (bitmap.GetWidth() == m_width && bitmap.GetHeight() == m_height) - || (m_width == 0 && m_height == 0), - _T("invalid bitmap size in wxImageList: this might work ") - _T("on this platform but definitely won't under Windows.") ); - - m_images.Append( new wxIcon( bitmap ) ); - - if (m_width == 0 && m_height == 0) - { - m_width = bitmap.GetWidth(); - m_height = bitmap.GetHeight(); - } - - return m_images.GetCount() - 1; -} - -int wxImageList::Add( const wxBitmap &bitmap ) -{ - wxASSERT_MSG( (bitmap.GetWidth() >= m_width && bitmap.GetHeight() == m_height) - || (m_width == 0 && m_height == 0), - _T("invalid bitmap size in wxImageList: this might work ") - _T("on this platform but definitely won't under Windows.") ); - - // Mimic behavior of Windows ImageList_Add that automatically breaks up the added - // bitmap into sub-images of the correct size - if (m_width > 0 && bitmap.GetWidth() > m_width && bitmap.GetHeight() >= m_height) - { - int numImages = bitmap.GetWidth() / m_width; - for (int subIndex = 0; subIndex < numImages; subIndex++) - { - wxRect rect(m_width * subIndex, 0, m_width, m_height); - wxBitmap tmpBmp = bitmap.GetSubBitmap(rect); - m_images.Append( new wxBitmap(tmpBmp) ); - } - } - else - { - m_images.Append( new wxBitmap(bitmap) ); - } - - if (m_width == 0 && m_height == 0) - { - m_width = bitmap.GetWidth(); - m_height = bitmap.GetHeight(); - } - - return m_images.GetCount() - 1; -} - -int wxImageList::Add( const wxBitmap& bitmap, const wxBitmap& mask ) -{ - wxBitmap bmp( bitmap ); - if (mask.Ok()) - bmp.SetMask( new wxMask( mask ) ); - - return Add( bmp ); -} - -int wxImageList::Add( const wxBitmap& bitmap, const wxColour& maskColour ) -{ - wxImage img = bitmap.ConvertToImage(); - img.SetMaskColour( maskColour.Red(), maskColour.Green(), maskColour.Blue() ); - - return Add( wxBitmap( img ) ); -} - -// Get the bitmap -wxBitmap wxImageList::GetBitmap(int index) const -{ - wxList::compatibility_iterator node = m_images.Item( index ); - - wxCHECK_MSG( node, wxNullBitmap , wxT("wrong index in image list") ); - - wxObject* obj = (wxObject*) node->GetData(); - if ( obj == NULL ) - return wxNullBitmap ; - else if ( obj->IsKindOf(CLASSINFO(wxIcon)) ) - return wxBitmap( *(wx_static_cast(wxIcon*, obj)) ) ; - else - return *(wx_static_cast(wxBitmap*, obj)) ; -} - -// Get the icon -wxIcon wxImageList::GetIcon(int index) const -{ - wxList::compatibility_iterator node = m_images.Item( index ); - - wxCHECK_MSG( node, wxNullIcon , wxT("wrong index in image list") ); - - wxObject* obj = (wxObject*) node->GetData(); - if ( obj == NULL ) - return wxNullIcon ; - else if ( obj->IsKindOf(CLASSINFO(wxBitmap)) ) - { - wxFAIL_MSG( wxT("cannot convert from bitmap to icon") ) ; - return wxNullIcon ; - } - else - return *(wx_static_cast(wxIcon*, obj)) ; -} - -bool wxImageList::Replace( int index, const wxBitmap &bitmap ) -{ - wxList::compatibility_iterator node = m_images.Item( index ); - - wxCHECK_MSG( node, false, wxT("wrong index in image list") ); - - wxBitmap* newBitmap = new wxBitmap( bitmap ); - - if (index == (int) m_images.GetCount() - 1) - { - delete node->GetData(); - - m_images.Erase( node ); - m_images.Append( newBitmap ); - } - else - { - wxList::compatibility_iterator next = node->GetNext(); - delete node->GetData(); - - m_images.Erase( node ); - m_images.Insert( next, newBitmap ); - } - - return true; -} - -bool wxImageList::Replace( int index, const wxIcon &bitmap ) -{ - wxList::compatibility_iterator node = m_images.Item( index ); - - wxCHECK_MSG( node, false, wxT("wrong index in image list") ); - - wxIcon* newBitmap = new wxIcon( bitmap ); - - if (index == (int) m_images.GetCount() - 1) - { - delete node->GetData(); - m_images.Erase( node ); - m_images.Append( newBitmap ); - } - else - { - wxList::compatibility_iterator next = node->GetNext(); - delete node->GetData(); - m_images.Erase( node ); - m_images.Insert( next, newBitmap ); - } - - return true; -} - -bool wxImageList::Replace( int index, const wxBitmap &bitmap, const wxBitmap &mask ) -{ - wxList::compatibility_iterator node = m_images.Item( index ); - - wxCHECK_MSG( node, false, wxT("wrong index in image list") ); - - wxBitmap* newBitmap = new wxBitmap(bitmap); - - if (index == (int) m_images.GetCount() - 1) - { - delete node->GetData(); - m_images.Erase( node ); - m_images.Append( newBitmap ); - } - else - { - wxList::compatibility_iterator next = node->GetNext(); - delete node->GetData(); - m_images.Erase( node ); - m_images.Insert( next, newBitmap ); - } - - if (mask.Ok()) - newBitmap->SetMask(new wxMask(mask)); - - return true; -} - -bool wxImageList::Remove( int index ) -{ - wxList::compatibility_iterator node = m_images.Item( index ); - - wxCHECK_MSG( node, false, wxT("wrong index in image list") ); - - delete node->GetData(); - m_images.Erase( node ); - - return true; -} - -bool wxImageList::RemoveAll() -{ - WX_CLEAR_LIST(wxList, m_images); - m_images.Clear(); - - return true; -} - -bool wxImageList::GetSize( int index, int &width, int &height ) const -{ - width = 0; - height = 0; - - wxList::compatibility_iterator node = m_images.Item( index ); - - wxCHECK_MSG( node, false, wxT("wrong index in image list") ); - - wxObject *obj = (wxObject*)node->GetData(); - if (obj->IsKindOf(CLASSINFO(wxIcon))) - { - wxIcon *bm = wx_static_cast( wxIcon* , obj ) ; - width = bm->GetWidth(); - height = bm->GetHeight(); - } - else - { - wxBitmap *bm = wx_static_cast( wxBitmap* , obj ) ; - width = bm->GetWidth(); - height = bm->GetHeight(); - } - - return true; -} - -bool wxImageList::Draw( - int index, wxDC &dc, int x, int y, - int flags, bool WXUNUSED(solidBackground) ) -{ - wxList::compatibility_iterator node = m_images.Item( index ); - - wxCHECK_MSG( node, false, wxT("wrong index in image list") ); - - wxObject *obj = (wxObject*)node->GetData(); - if (obj->IsKindOf(CLASSINFO(wxIcon))) - { - wxIcon *bm = wx_static_cast( wxIcon* , obj ) ; - dc.DrawIcon( *bm , x, y ); - } - else - { - wxBitmap *bm = wx_static_cast( wxBitmap* , obj ) ; - dc.DrawBitmap( *bm, x, y, (flags & wxIMAGELIST_DRAW_TRANSPARENT) > 0 ); - } - - return true; -} - -#endif // wxUSE_IMAGLIST diff --git a/src/osx/carbon/minifram.cpp b/src/osx/carbon/minifram.cpp deleted file mode 100644 index f7266d529e..0000000000 --- a/src/osx/carbon/minifram.cpp +++ /dev/null @@ -1,20 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: minifram.cpp -// Purpose: wxMiniFrame. Optional; identical to wxFrame if not supported. -// Author: Stefan Csomor -// Modified by: -// Created: 1998-01-01 -// RCS-ID: $Id$ -// Copyright: (c) Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#if wxUSE_MINIFRAME - -#include "wx/minifram.h" - -IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame, wxFrame) - -#endif // wxUSE_MINIFRAME diff --git a/src/osx/carbon/palette.cpp b/src/osx/carbon/palette.cpp deleted file mode 100644 index 37b1826a80..0000000000 --- a/src/osx/carbon/palette.cpp +++ /dev/null @@ -1,155 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/palette.cpp -// Purpose: wxPalette -// Author: Stefan Csomor -// Modified by: -// Created: 1998-01-01 -// RCS-ID: $Id$ -// Copyright: (c) Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/wxprec.h" - -#if wxUSE_PALETTE - -#include "wx/palette.h" -#include "wx/colour.h" - -IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject) - -// ============================================================================ -// wxPaletteRefData -// ============================================================================ - -class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData -{ -public: - wxPaletteRefData(); - wxPaletteRefData(const wxPaletteRefData& data); - virtual ~wxPaletteRefData(); - - virtual bool IsOk() const { return m_count > 0; } - -protected: - wxColour* m_palette; - wxInt32 m_count; - - friend class WXDLLIMPEXP_FWD_CORE wxPalette; - - DECLARE_NO_ASSIGN_CLASS(wxPaletteRefData) -}; - -wxPaletteRefData::wxPaletteRefData() -{ - m_palette = NULL; - m_count = 0; -} - -wxPaletteRefData::wxPaletteRefData(const wxPaletteRefData& data) -{ - m_count = data.m_count; - m_palette = new wxColour[m_count]; - for ( wxInt32 i = 0; i < m_count; i++ ) - m_palette[i] = data.m_palette[i]; -} - -wxPaletteRefData::~wxPaletteRefData() -{ - delete[] m_palette; -} - -// ============================================================================ -// wxPalette -// ============================================================================ - -wxPalette::wxPalette() -{ -} - -wxPalette::wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) -{ - Create(n, red, green, blue); -} - -wxPalette::~wxPalette() -{ -} - -bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) -{ - UnRef(); - - m_refData = new wxPaletteRefData; - - M_PALETTEDATA->m_count = n ; - M_PALETTEDATA->m_palette = new wxColour[n] ; - - for ( int i = 0 ; i < n ; ++i) - { - M_PALETTEDATA->m_palette[i].Set( red[i] , green[i] , blue[i] ) ; - } - - return false; -} - -int wxPalette::GetPixel(unsigned char red, unsigned char green, unsigned char blue) const -{ - if ( !m_refData ) - return wxNOT_FOUND; - - long bestdiff = 3 * 256 ; - long bestpos = 0 ; - long currentdiff ; - - for ( int i = 0 ; i < M_PALETTEDATA->m_count ; ++i ) - { - const wxColour& col = M_PALETTEDATA->m_palette[i] ; - currentdiff = abs ( col.Red() - red ) + abs( col.Green() - green ) + abs ( col.Blue() - blue ) ; - if ( currentdiff < bestdiff ) - { - bestdiff = currentdiff ; - bestpos = i ; - if ( bestdiff == 0 ) - break ; - } - } - - return bestpos; -} - -bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const -{ - if ( !m_refData ) - return false; - - if (index < 0 || index >= M_PALETTEDATA->m_count) - return false; - - const wxColour& col = M_PALETTEDATA->m_palette[index] ; - *red = col.Red() ; - *green = col.Green() ; - *blue = col.Blue() ; - - return true; -} - -int wxPalette::GetColoursCount() const -{ - if (m_refData) - return M_PALETTEDATA->m_count; - - return 0; -} - -wxGDIRefData *wxPalette::CreateGDIRefData() const -{ - return new wxPaletteRefData; -} - -wxGDIRefData *wxPalette::CloneGDIRefData(const wxGDIRefData *data) const -{ - return new wxPaletteRefData(*wx_static_cast(const wxPaletteRefData *, data)); -} - -#endif // wxUSE_PALETTE diff --git a/src/osx/carbon/printmac.cpp b/src/osx/carbon/printmac.cpp deleted file mode 100644 index af3bd2a17f..0000000000 --- a/src/osx/carbon/printmac.cpp +++ /dev/null @@ -1,621 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/printwin.cpp -// Purpose: wxMacPrinter framework -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#if wxUSE_PRINTING_ARCHITECTURE - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/utils.h" - #include "wx/dc.h" - #include "wx/app.h" - #include "wx/msgdlg.h" - #include "wx/dcprint.h" - #include "wx/math.h" -#endif - -#include "wx/osx/uma.h" - -#include "wx/osx/printmac.h" -#include "wx/osx/private/print.h" - -#include "wx/printdlg.h" -#include "wx/paper.h" -#include "wx/osx/printdlg.h" - -#include - -IMPLEMENT_DYNAMIC_CLASS(wxMacCarbonPrintData, wxPrintNativeDataBase) -IMPLEMENT_DYNAMIC_CLASS(wxMacPrinter, wxPrinterBase) -IMPLEMENT_CLASS(wxMacPrintPreview, wxPrintPreviewBase) - -bool wxMacCarbonPrintData::IsOk() const -{ - return (m_macPageFormat != kPMNoPageFormat) && (m_macPrintSettings != kPMNoPrintSettings) && (m_macPrintSession != kPMNoReference); -} -wxMacCarbonPrintData::wxMacCarbonPrintData() -{ - m_macPageFormat = kPMNoPageFormat; - m_macPrintSettings = kPMNoPrintSettings; - m_macPrintSession = kPMNoReference ; - ValidateOrCreate() ; -} - -wxMacCarbonPrintData::~wxMacCarbonPrintData() -{ - if (m_macPageFormat != kPMNoPageFormat) - { - (void)PMRelease(m_macPageFormat); - m_macPageFormat = kPMNoPageFormat; - } - - if (m_macPrintSettings != kPMNoPrintSettings) - { - (void)PMRelease(m_macPrintSettings); - m_macPrintSettings = kPMNoPrintSettings; - } - - if ( m_macPrintSession != kPMNoReference ) - { - (void)PMRelease(m_macPrintSession); - m_macPrintSession = kPMNoReference; - } -} - -void wxMacCarbonPrintData::ValidateOrCreate() -{ - OSStatus err = noErr ; - if ( m_macPrintSession == kPMNoReference ) - { - err = PMCreateSession( &m_macPrintSession ) ; - } - // Set up a valid PageFormat object. - if ( m_macPageFormat == kPMNoPageFormat) - { - err = PMCreatePageFormat(&m_macPageFormat); - - // Note that PMPageFormat is not session-specific, but calling - // PMSessionDefaultPageFormat assigns values specific to the printer - // associated with the current printing session. - if ((err == noErr) && - ( m_macPageFormat != kPMNoPageFormat)) - { - err = PMSessionDefaultPageFormat(m_macPrintSession, - m_macPageFormat); - } - } - else - { - err = PMSessionValidatePageFormat(m_macPrintSession, - m_macPageFormat, - kPMDontWantBoolean); - } - - // Set up a valid PrintSettings object. - if ( m_macPrintSettings == kPMNoPrintSettings) - { - err = PMCreatePrintSettings( &m_macPrintSettings); - - // Note that PMPrintSettings is not session-specific, but calling - // PMSessionDefaultPrintSettings assigns values specific to the printer - // associated with the current printing session. - if ((err == noErr) && - ( m_macPrintSettings != kPMNoPrintSettings)) - { - err = PMSessionDefaultPrintSettings(m_macPrintSession, - m_macPrintSettings); - } - } - else - { - err = PMSessionValidatePrintSettings( m_macPrintSession, - m_macPrintSettings, - kPMDontWantBoolean); - } -} - -bool wxMacCarbonPrintData::TransferFrom( const wxPrintData &data ) -{ - ValidateOrCreate() ; - PMSetCopies( (PMPrintSettings) m_macPrintSettings , data.GetNoCopies() , false ) ; - if ( data.IsOrientationReversed() ) - PMSetOrientation( (PMPageFormat) m_macPageFormat , ( data.GetOrientation() == wxLANDSCAPE ) ? - kPMReverseLandscape : kPMReversePortrait , false ) ; - else - PMSetOrientation( (PMPageFormat) m_macPageFormat , ( data.GetOrientation() == wxLANDSCAPE ) ? - kPMLandscape : kPMPortrait , false ) ; - // collate cannot be set -#if 0 // not yet tested - if ( !m_printerName.empty() ) - PMSessionSetCurrentPrinter( (PMPrintSession) m_macPrintSession , wxCFStringRef( m_printerName , wxFont::GetDefaultEncoding() ) ) ; -#endif -#if wxOSX_USE_CARBON - PMColorMode color ; - PMGetColorMode( (PMPrintSettings) m_macPrintSettings, &color ) ; - if ( data.GetColour() ) - { - if ( color == kPMBlackAndWhite ) - PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMColor ) ; - } - else - PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMBlackAndWhite ) ; -#endif - - PMDuplexMode mode = 0 ; - switch( data.GetDuplex() ) - { - case wxDUPLEX_HORIZONTAL : - mode = kPMDuplexNoTumble ; - break ; - case wxDUPLEX_VERTICAL : - mode = kPMDuplexTumble ; - break ; - case wxDUPLEX_SIMPLEX : - default : - mode = kPMDuplexNone ; - break ; - } - PMSetDuplex( (PMPrintSettings) m_macPrintSettings, mode ) ; - - // PMQualityMode not yet accessible via API - // todo paperSize - - PMResolution res; - PMPrinter printer; - PMSessionGetCurrentPrinter(m_macPrintSession, &printer); - -#if wxOSX_USE_CARBON - PMTag tag = kPMMaxSquareResolution; - PMPrinterGetPrinterResolution(printer, tag, &res); - PMSetResolution((PMPageFormat) m_macPageFormat, &res); -#else - PMPrinterGetOutputResolution( printer, - (PMPrintSettings) m_macPrintSettings, &res) ; - // TODO transfer ? into page format ? - // may fail ! -#endif - // after setting the new resolution the format has to be updated, otherwise the page rect remains - // at the 'old' scaling - PMSessionValidatePageFormat((PMPrintSession) m_macPrintSession, - (PMPageFormat) m_macPageFormat, - kPMDontWantBoolean) ; - - return true ; -} - -bool wxMacCarbonPrintData::TransferTo( wxPrintData &data ) -{ - OSStatus err = noErr ; - - UInt32 copies ; - err = PMGetCopies( m_macPrintSettings , &copies ) ; - if ( err == noErr ) - data.SetNoCopies( copies ) ; - - PMOrientation orientation ; - err = PMGetOrientation( m_macPageFormat , &orientation ) ; - if ( err == noErr ) - { - if ( orientation == kPMPortrait || orientation == kPMReversePortrait ) - { - data.SetOrientation( wxPORTRAIT ); - data.SetOrientationReversed( orientation == kPMReversePortrait ); - } - else - { - data.SetOrientation( wxLANDSCAPE ); - data.SetOrientationReversed( orientation == kPMReverseLandscape ); - } - } - - // collate cannot be set -#if 0 - { - wxCFStringRef name ; - PMPrinter printer ; - PMSessionGetCurrentPrinter( m_macPrintSession , - &printer ) ; - m_printerName = name.AsString() ; - } -#endif - -#ifndef __LP64__ - PMColorMode color ; - err = PMGetColorMode( m_macPrintSettings, &color ) ; - if ( err == noErr ) - data.SetColour( !(color == kPMBlackAndWhite) ) ; -#endif - PMDuplexMode mode = 0 ; - PMGetDuplex( (PMPrintSettings) m_macPrintSettings, &mode ) ; - switch( mode ) - { - case kPMDuplexNoTumble : - data.SetDuplex(wxDUPLEX_HORIZONTAL); - break ; - case kPMDuplexTumble : - data.SetDuplex(wxDUPLEX_VERTICAL); - break ; - case kPMDuplexNone : - default : - data.SetDuplex(wxDUPLEX_SIMPLEX); - break ; - } - // PMQualityMode not yet accessible via API - - PMPaper paper ; - PMGetPageFormatPaper( m_macPageFormat, &paper ); - - PMRect rPaper; - err = PMGetUnadjustedPaperRect( m_macPageFormat, &rPaper); - if ( err == noErr ) - { - wxSize sz((int)(( rPaper.right - rPaper.left ) * pt2mm + 0.5 ) , - (int)(( rPaper.bottom - rPaper.top ) * pt2mm + 0.5 )); - data.SetPaperSize(sz); - wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10)); - if (id != wxPAPER_NONE) - { - data.SetPaperId(id); - } - } - return true ; -} - -void wxMacCarbonPrintData::TransferFrom( wxPageSetupData *WXUNUSED(data) ) -{ - // should we setup the page rect here ? - // since MacOS sometimes has two same paper rects with different - // page rects we could make it roundtrip safe perhaps -} - -void wxMacCarbonPrintData::TransferTo( wxPageSetupData* data ) -{ - PMRect rPaper; - OSStatus err = PMGetUnadjustedPaperRect(m_macPageFormat, &rPaper); - if ( err == noErr ) - { - wxSize sz((int)(( rPaper.right - rPaper.left ) * pt2mm + 0.5 ) , - (int)(( rPaper.bottom - rPaper.top ) * pt2mm + 0.5 )); - data->SetPaperSize(sz); - - PMRect rPage ; - err = PMGetUnadjustedPageRect(m_macPageFormat , &rPage ) ; - if ( err == noErr ) - { - data->SetMinMarginTopLeft( wxPoint ( - (int)(((double) rPage.left - rPaper.left ) * pt2mm) , - (int)(((double) rPage.top - rPaper.top ) * pt2mm) ) ) ; - - data->SetMinMarginBottomRight( wxPoint ( - (wxCoord)(((double) rPaper.right - rPage.right ) * pt2mm), - (wxCoord)(((double) rPaper.bottom - rPage.bottom ) * pt2mm)) ) ; - - if ( data->GetMarginTopLeft().x < data->GetMinMarginTopLeft().x ) - data->SetMarginTopLeft( wxPoint( data->GetMinMarginTopLeft().x , - data->GetMarginTopLeft().y ) ) ; - - if ( data->GetMarginBottomRight().x < data->GetMinMarginBottomRight().x ) - data->SetMarginBottomRight( wxPoint( data->GetMinMarginBottomRight().x , - data->GetMarginBottomRight().y ) ); - - if ( data->GetMarginTopLeft().y < data->GetMinMarginTopLeft().y ) - data->SetMarginTopLeft( wxPoint( data->GetMarginTopLeft().x , data->GetMinMarginTopLeft().y ) ); - - if ( data->GetMarginBottomRight().y < data->GetMinMarginBottomRight().y ) - data->SetMarginBottomRight( wxPoint( data->GetMarginBottomRight().x , - data->GetMinMarginBottomRight().y) ); - } - } -} - -void wxMacCarbonPrintData::TransferTo( wxPrintDialogData* data ) -{ - UInt32 minPage , maxPage ; - PMGetPageRange( m_macPrintSettings , &minPage , &maxPage ) ; - data->SetMinPage( minPage ) ; - data->SetMaxPage( maxPage ) ; - UInt32 copies ; - PMGetCopies( m_macPrintSettings , &copies ) ; - data->SetNoCopies( copies ) ; - UInt32 from , to ; - PMGetFirstPage( m_macPrintSettings , &from ) ; - PMGetLastPage( m_macPrintSettings , &to ) ; - if ( to >= 0x7FFFFFFF ) // due to an OS Bug we don't get back kPMPrintAllPages - { - data->SetAllPages( true ) ; - // This means all pages, more or less - data->SetFromPage(1); - data->SetToPage(32000); - } - else - { - data->SetFromPage( from ) ; - data->SetToPage( to ) ; - data->SetAllPages( false ); - } -} - -void wxMacCarbonPrintData::TransferFrom( wxPrintDialogData* data ) -{ - // Respect the value of m_printAllPages - if ( data->GetAllPages() ) - PMSetPageRange( m_macPrintSettings , data->GetMinPage() , (UInt32) kPMPrintAllPages ) ; - else - PMSetPageRange( m_macPrintSettings , data->GetMinPage() , data->GetMaxPage() ) ; - PMSetCopies( m_macPrintSettings , data->GetNoCopies() , false ) ; - PMSetFirstPage( m_macPrintSettings , data->GetFromPage() , false ) ; - - if (data->GetAllPages() || data->GetFromPage() == 0) - PMSetLastPage( m_macPrintSettings , (UInt32) kPMPrintAllPages, true ) ; - else - PMSetLastPage( m_macPrintSettings , (UInt32) data->GetToPage() , false ) ; -} - -/* -* Printer -*/ - -wxMacPrinter::wxMacPrinter(wxPrintDialogData *data): -wxPrinterBase(data) -{ -} - -wxMacPrinter::~wxMacPrinter(void) -{ -} - -bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) -{ - sm_abortIt = false; - sm_abortWindow = NULL; - - if (!printout) - return false; - - printout->SetIsPreview(false); - if (m_printDialogData.GetMinPage() < 1) - m_printDialogData.SetMinPage(1); - if (m_printDialogData.GetMaxPage() < 1) - m_printDialogData.SetMaxPage(9999); - - // Create a suitable device context - wxPrinterDC *dc = NULL; - if (prompt) - { - wxMacPrintDialog dialog(parent, & m_printDialogData); - if (dialog.ShowModal() == wxID_OK) - { - dc = wxDynamicCast(dialog.GetPrintDC(), wxPrinterDC); - wxASSERT(dc); - m_printDialogData = dialog.GetPrintDialogData(); - } - } - else - { - dc = new wxPrinterDC( m_printDialogData.GetPrintData() ) ; - } - - // May have pressed cancel. - if (!dc || !dc->IsOk()) - { - if (dc) - delete dc; - return false; - } - - // on the mac we have always pixels as addressing mode with 72 dpi - printout->SetPPIScreen(72, 72); - PMResolution res; - wxMacCarbonPrintData* nativeData = (wxMacCarbonPrintData*) - (m_printDialogData.GetPrintData().GetNativeData()); -#if wxOSX_USE_CARBON - PMGetResolution((PMPageFormat) (nativeData->m_macPageFormat), &res); -#else - PMPrinter printer; - PMSessionGetCurrentPrinter(nativeData->m_macPrintSession, &printer); - PMPrinterGetOutputResolution( printer, nativeData->m_macPrintSettings, &res) ; -#endif - printout->SetPPIPrinter(int(res.hRes), int(res.vRes)); - - // Set printout parameters - printout->SetDC(dc); - - int w, h; - dc->GetSize(&w, &h); - printout->SetPageSizePixels((int)w, (int)h); - printout->SetPaperRectPixels(dc->GetPaperRect()); - wxCoord mw, mh; - dc->GetSizeMM(&mw, &mh); - printout->SetPageSizeMM((int)mw, (int)mh); - - // Create an abort window - wxBeginBusyCursor(); - - printout->OnPreparePrinting(); - - // Get some parameters from the printout, if defined - int fromPage, toPage; - int minPage, maxPage; - printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); - - if (maxPage == 0) - { - wxEndBusyCursor(); - return false; - } - - // Only set min and max, because from and to have been - // set by the user - m_printDialogData.SetMinPage(minPage); - m_printDialogData.SetMaxPage(maxPage); - - printout->OnBeginPrinting(); - - bool keepGoing = true; - - if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage())) - { - wxEndBusyCursor(); - wxMessageBox(wxT("Could not start printing."), wxT("Print Error"), wxOK, parent); - } - - int pn; - for (pn = m_printDialogData.GetFromPage(); - keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn); - pn++) - { - if (sm_abortIt) - { - keepGoing = false; - break; - } - else - { - dc->StartPage(); - keepGoing = printout->OnPrintPage(pn); - dc->EndPage(); - } - } - printout->OnEndDocument(); - - printout->OnEndPrinting(); - - if (sm_abortWindow) - { - sm_abortWindow->Show(false); - delete sm_abortWindow; - sm_abortWindow = NULL; - } - - wxEndBusyCursor(); - - delete dc; - - return true; -} - -wxDC* wxMacPrinter::PrintDialog(wxWindow *parent) -{ - wxDC* dc = (wxDC*) NULL; - - wxPrintDialog dialog(parent, & m_printDialogData); - int ret = dialog.ShowModal(); - - if (ret == wxID_OK) - { - dc = dialog.GetPrintDC(); - m_printDialogData = dialog.GetPrintDialogData(); - } - - return dc; -} - -bool wxMacPrinter::Setup(wxWindow *WXUNUSED(parent)) -{ -#if 0 - wxPrintDialog dialog(parent, & m_printDialogData); - dialog.GetPrintDialogData().SetSetupDialog(true); - - int ret = dialog.ShowModal(); - - if (ret == wxID_OK) - m_printDialogData = dialog.GetPrintDialogData(); - - return (ret == wxID_OK); -#endif - - return wxID_CANCEL; -} - -/* -* Print preview -*/ - -wxMacPrintPreview::wxMacPrintPreview(wxPrintout *printout, - wxPrintout *printoutForPrinting, - wxPrintDialogData *data) - : wxPrintPreviewBase(printout, printoutForPrinting, data) -{ - DetermineScaling(); -} - -wxMacPrintPreview::wxMacPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data): -wxPrintPreviewBase(printout, printoutForPrinting, data) -{ - DetermineScaling(); -} - -wxMacPrintPreview::~wxMacPrintPreview(void) -{ -} - -bool wxMacPrintPreview::Print(bool interactive) -{ - if (!m_printPrintout) - return false; - - wxMacPrinter printer(&m_printDialogData); - return printer.Print(m_previewFrame, m_printPrintout, interactive); -} - -void wxMacPrintPreview::DetermineScaling(void) -{ - int screenWidth , screenHeight ; - wxDisplaySize( &screenWidth , &screenHeight ) ; - - wxSize ppiScreen( 72 , 72 ) ; - wxSize ppiPrinter( 72 , 72 ) ; - - // Note that with Leopard, screen dpi=72 is no longer a given - m_previewPrintout->SetPPIScreen( ppiScreen.x , ppiScreen.y ) ; - - wxCoord w , h ; - wxCoord ww, hh; - wxRect paperRect; - - // Get a device context for the currently selected printer - wxPrinterDC printerDC(m_printDialogData.GetPrintData()); - if (printerDC.IsOk()) - { - printerDC.GetSizeMM(&ww, &hh); - printerDC.GetSize( &w , &h ) ; - ppiPrinter = printerDC.GetPPI() ; - paperRect = printerDC.GetPaperRect(); - m_isOk = true ; - } - else - { - // use some defaults - w = 8 * 72 ; - h = 11 * 72 ; - ww = (wxCoord) (w * 25.4 / ppiPrinter.x) ; - hh = (wxCoord) (h * 25.4 / ppiPrinter.y) ; - paperRect = wxRect(0, 0, w, h); - m_isOk = false ; - } - m_pageWidth = w; - m_pageHeight = h; - - m_previewPrintout->SetPageSizePixels(w , h) ; - m_previewPrintout->SetPageSizeMM(ww, hh); - m_previewPrintout->SetPaperRectPixels(paperRect); - m_previewPrintout->SetPPIPrinter( ppiPrinter.x , ppiPrinter.y ) ; - - m_previewScaleX = float(ppiScreen.x) / ppiPrinter.x; - m_previewScaleY = float(ppiScreen.y) / ppiPrinter.y; -} - -#endif diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp new file mode 100644 index 0000000000..0b4dfcf11a --- /dev/null +++ b/src/osx/core/bitmap.cpp @@ -0,0 +1,1728 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/osx/core/bitmap.cpp +// Purpose: wxBitmap +// Author: Stefan Csomor +// Modified by: +// Created: 1998-01-01 +// RCS-ID: $Id$ +// Copyright: (c) Stefan Csomor +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/wxprec.h" + +#include "wx/bitmap.h" + +#ifndef WX_PRECOMP + #include "wx/log.h" + #include "wx/dcmemory.h" + #include "wx/icon.h" + #include "wx/image.h" +#endif + +#include "wx/metafile.h" +#include "wx/xpmdecod.h" + +#include "wx/rawbmp.h" + +IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject) +IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) + +#if wxOSX_USE_CARBON +#include "wx/osx/uma.h" +#else +#include "wx/osx/private.h" +#endif + +#ifndef __WXOSX_IPHONE__ +#include +#endif + +CGColorSpaceRef wxMacGetGenericRGBColorSpace(); +CGDataProviderRef wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer& buf ); + +// Implementation Notes +// -------------------- +// +// we are always working with a 32 bit deep pixel buffer +// under QuickDraw its alpha parts are going to be ignored in the GWorld, +// therefore we have a separate GWorld there for blitting the mask in + +// under Quartz then content is transformed into a CGImageRef representing the same data +// which can be transferred to the GPU by the OS for fast rendering + +class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData +{ + friend class WXDLLIMPEXP_FWD_CORE wxIcon; + friend class WXDLLIMPEXP_FWD_CORE wxCursor; +public: + wxBitmapRefData(int width , int height , int depth); + wxBitmapRefData(); + wxBitmapRefData(const wxBitmapRefData &tocopy); + + virtual ~wxBitmapRefData(); + + virtual bool IsOk() const { return m_ok; } + + void Free(); + void SetOk( bool isOk) { m_ok = isOk; } + + void SetWidth( int width ) { m_width = width; } + void SetHeight( int height ) { m_height = height; } + void SetDepth( int depth ) { m_depth = depth; } + + int GetWidth() const { return m_width; } + int GetHeight() const { return m_height; } + int GetDepth() const { return m_depth; } + + void *GetRawAccess() const; + void *BeginRawAccess(); + void EndRawAccess(); + + bool HasAlpha() const { return m_hasAlpha; } + void UseAlpha( bool useAlpha ); + +public: +#if wxUSE_PALETTE + wxPalette m_bitmapPalette; +#endif // wxUSE_PALETTE + + wxMask * m_bitmapMask; // Optional mask + CGImageRef CreateCGImage() const; + + // returns true if the bitmap has a size that + // can be natively transferred into a true icon + // if no is returned GetIconRef will still produce + // an icon but it will be generated via a PICT and + // rescaled to 16 x 16 + bool HasNativeSize(); + + // caller should increase ref count if needed longer + // than the bitmap exists + IconRef GetIconRef(); + +#ifndef __WXOSX_IPHONE__ + // returns a Pict from the bitmap content + PicHandle GetPictHandle(); +#endif + + CGContextRef GetBitmapContext() const; + + int GetBytesPerRow() const { return m_bytesPerRow; } + private : + bool Create(int width , int height , int depth); + void Init(); + + int m_width; + int m_height; + int m_bytesPerRow; + int m_depth; + bool m_hasAlpha; + wxMemoryBuffer m_memBuf; + int m_rawAccessCount; + bool m_ok; + mutable CGImageRef m_cgImageRef; + + IconRef m_iconRef; +#ifndef __WXOSX_IPHONE__ + PicHandle m_pictHandle; +#endif + CGContextRef m_hBitmap; +}; + + +#define wxOSX_USE_PREMULTIPLIED_ALPHA 1 +static const int kBestByteAlignement = 16; +static const int kMaskBytesPerPixel = 1; + +static int GetBestBytesPerRow( int rawBytes ) +{ + return (((rawBytes)+kBestByteAlignement-1) & ~(kBestByteAlignement-1) ); +} + +#if wxUSE_GUI && !defined(__WXOSX_IPHONE__) + +// this is used for more controls than just the wxBitmap button, also for notebooks etc + +void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType ) +{ + memset( info , 0 , sizeof(ControlButtonContentInfo) ) ; + if ( bitmap.Ok() ) + { + wxBitmapRefData * bmap = bitmap.GetBitmapData() ; + if ( bmap == NULL ) + return ; + + if ( forceType == 0 ) + { + forceType = kControlContentCGImageRef; + } + + if ( forceType == kControlContentIconRef ) + { + wxBitmap scaleBmp ; + wxBitmapRefData* bmp = bmap ; + + if ( !bmap->HasNativeSize() ) + { + // as PICT conversion will only result in a 16x16 icon, let's attempt + // a few scales for better results + + int w = bitmap.GetWidth() ; + int h = bitmap.GetHeight() ; + int sz = wxMax( w , h ) ; + if ( sz == 24 || sz == 64 ) + { + scaleBmp = wxBitmap( bitmap.ConvertToImage().Scale( w * 2 , h * 2 ) ) ; + bmp = scaleBmp.GetBitmapData() ; + } + } + + info->contentType = kControlContentIconRef ; + info->u.iconRef = bmp->GetIconRef() ; + AcquireIconRef( info->u.iconRef ) ; + } + else if ( forceType == kControlContentCGImageRef ) + { + info->contentType = kControlContentCGImageRef ; + info->u.imageRef = (CGImageRef) bmap->CreateCGImage() ; + } + else + { +#ifndef __LP64__ + info->contentType = kControlContentPictHandle ; + info->u.picture = bmap->GetPictHandle() ; +#endif + } + } +} + +CGImageRef wxMacCreateCGImageFromBitmap( const wxBitmap& bitmap ) +{ + wxBitmapRefData * bmap = bitmap.GetBitmapData() ; + if ( bmap == NULL ) + return NULL ; + return (CGImageRef) bmap->CreateCGImage(); +} + +void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ) +{ + if ( info->contentType == kControlContentIconRef ) + { + ReleaseIconRef( info->u.iconRef ) ; + } + else if ( info->contentType == kControlNoContent ) + { + // there's no bitmap at all, fall through silently + } + else if ( info->contentType == kControlContentPictHandle ) + { + // owned by the bitmap, no release here + } + else if ( info->contentType == kControlContentCGImageRef ) + { + CGImageRelease( info->u.imageRef ) ; + } + else + { + wxFAIL_MSG(wxT("Unexpected bitmap type") ) ; + } +} + +#endif //wxUSE_BMPBUTTON + +#define M_BITMAPDATA ((wxBitmapRefData *)m_refData) + +void wxBitmapRefData::Init() +{ + m_width = 0 ; + m_height = 0 ; + m_depth = 0 ; + m_bytesPerRow = 0; + m_ok = false ; + m_bitmapMask = NULL ; + m_cgImageRef = NULL ; + +#ifndef __WXOSX_IPHONE__ + m_iconRef = NULL ; + m_pictHandle = NULL ; +#endif + m_hBitmap = NULL ; + + m_rawAccessCount = 0 ; + m_hasAlpha = false; +} + +wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData &tocopy) +{ + Init(); + Create(tocopy.m_width, tocopy.m_height, tocopy.m_depth); + + if (tocopy.m_bitmapMask) + m_bitmapMask = new wxMask(*tocopy.m_bitmapMask); + else if (tocopy.m_hasAlpha) + UseAlpha(true); + + unsigned char* dest = (unsigned char*)GetRawAccess(); + unsigned char* source = (unsigned char*)tocopy.GetRawAccess(); + size_t numbytes = m_bytesPerRow * m_height; + memcpy( dest, source, numbytes ); +} + +wxBitmapRefData::wxBitmapRefData() +{ + Init() ; +} + +wxBitmapRefData::wxBitmapRefData( int w , int h , int d ) +{ + Init() ; + Create( w , h , d ) ; +} + +bool wxBitmapRefData::Create( int w , int h , int d ) +{ + m_width = wxMax(1, w); + m_height = wxMax(1, h); + m_depth = d ; + m_hBitmap = NULL ; + + m_bytesPerRow = GetBestBytesPerRow( w * 4 ) ; + size_t size = m_bytesPerRow * h ; + void* data = m_memBuf.GetWriteBuf( size ) ; + if ( data != NULL ) + { + memset( data , 0 , size ) ; + m_memBuf.UngetWriteBuf( size ) ; + + m_hBitmap = CGBitmapContextCreate((char*) data, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaNoneSkipFirst ); + wxASSERT_MSG( m_hBitmap , wxT("Unable to create CGBitmapContext context") ) ; + CGContextTranslateCTM( m_hBitmap, 0, m_height ); + CGContextScaleCTM( m_hBitmap, 1, -1 ); + } /* data != NULL */ + m_ok = ( m_hBitmap != NULL ) ; + + return m_ok ; +} + +void wxBitmapRefData::UseAlpha( bool use ) +{ + if ( m_hasAlpha == use ) + return ; + + m_hasAlpha = use ; + + CGContextRelease( m_hBitmap ); + m_hBitmap = CGBitmapContextCreate((char*) m_memBuf.GetData(), m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), m_hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst ); + wxASSERT_MSG( m_hBitmap , wxT("Unable to create CGBitmapContext context") ) ; + CGContextTranslateCTM( m_hBitmap, 0, m_height ); + CGContextScaleCTM( m_hBitmap, 1, -1 ); +} + +void *wxBitmapRefData::GetRawAccess() const +{ + wxCHECK_MSG( IsOk(), NULL , wxT("invalid bitmap") ) ; + return m_memBuf.GetData() ; +} + +void *wxBitmapRefData::BeginRawAccess() +{ + wxCHECK_MSG( IsOk(), NULL, wxT("invalid bitmap") ) ; + wxASSERT( m_rawAccessCount == 0 ) ; +#ifndef __WXOSX_IPHONE__ + wxASSERT_MSG( m_pictHandle == NULL && m_iconRef == NULL , + wxT("Currently, modifing bitmaps that are used in controls already is not supported") ) ; +#endif + ++m_rawAccessCount ; + + // we must destroy an existing cached image, as + // the bitmap data may change now + if ( m_cgImageRef ) + { + CGImageRelease( m_cgImageRef ) ; + m_cgImageRef = NULL ; + } + + return m_memBuf.GetData() ; +} + +void wxBitmapRefData::EndRawAccess() +{ + wxCHECK_RET( IsOk() , wxT("invalid bitmap") ) ; + wxASSERT( m_rawAccessCount == 1 ) ; + + --m_rawAccessCount ; +} + +bool wxBitmapRefData::HasNativeSize() +{ + int w = GetWidth() ; + int h = GetHeight() ; + int sz = wxMax( w , h ) ; + + return ( sz == 128 || sz == 48 || sz == 32 || sz == 16 ); +} + +#ifndef __WXOSX_IPHONE__ +IconRef wxBitmapRefData::GetIconRef() +{ + if ( m_iconRef == NULL ) + { + // Create Icon Family Handle + + IconFamilyHandle iconFamily = (IconFamilyHandle) NewHandle( 0 ); + + int w = GetWidth() ; + int h = GetHeight() ; + int sz = wxMax( w , h ) ; + + OSType dataType = 0 ; + OSType maskType = 0 ; + + switch (sz) + { + case 128: +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + if ( UMAGetSystemVersion() >= 0x1050 ) + { + dataType = kIconServices128PixelDataARGB ; + } + else +#endif + { + dataType = kThumbnail32BitData ; + maskType = kThumbnail8BitMask ; + } + break; + + case 48: +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + if ( UMAGetSystemVersion() >= 0x1050 ) + { + dataType = kIconServices48PixelDataARGB ; + } + else +#endif + { + dataType = kHuge32BitData ; + maskType = kHuge8BitMask ; + } + break; + + case 32: +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + if ( UMAGetSystemVersion() >= 0x1050 ) + { + dataType = kIconServices32PixelDataARGB ; + } + else +#endif + { + dataType = kLarge32BitData ; + maskType = kLarge8BitMask ; + } + break; + + case 16: +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + if ( UMAGetSystemVersion() >= 0x1050 ) + { + dataType = kIconServices16PixelDataARGB ; + } + else +#endif + { + dataType = kSmall32BitData ; + maskType = kSmall8BitMask ; + } + break; + + default: + break; + } + + if ( dataType != 0 ) + { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + if ( maskType == 0 && UMAGetSystemVersion() >= 0x1050 ) + { + size_t datasize = sz * sz * 4 ; + Handle data = NewHandle( datasize ) ; + HLock( data ) ; + unsigned char* ptr = (unsigned char*) *data ; + memset( ptr, 0, datasize ); + bool hasAlpha = HasAlpha() ; + wxMask *mask = m_bitmapMask ; + unsigned char * sourcePtr = (unsigned char*) GetRawAccess() ; + unsigned char * masksourcePtr = mask ? (unsigned char*) mask->GetRawAccess() : NULL ; + + for ( int y = 0 ; y < h ; ++y, sourcePtr += m_bytesPerRow , masksourcePtr += mask ? mask->GetBytesPerRow() : 0 ) + { + unsigned char * source = sourcePtr; + unsigned char * masksource = masksourcePtr; + unsigned char * dest = ptr + y * sz * 4 ; + unsigned char a, r, g, b; + + for ( int x = 0 ; x < w ; ++x ) + { + a = *source ++ ; + r = *source ++ ; + g = *source ++ ; + b = *source ++ ; + + if ( mask ) + { + a = 0xFF - *masksource++ ; + } + else if ( !hasAlpha ) + a = 0xFF ; + else + { +#if wxOSX_USE_PREMULTIPLIED_ALPHA + // this must be non-premultiplied data + if ( a != 0xFF && a!= 0 ) + { + r = r * 255 / a; + g = g * 255 / a; + b = b * 255 / a; + } +#endif + } + *dest++ = a ; + *dest++ = r ; + *dest++ = g ; + *dest++ = b ; + + } + } + HUnlock( data ); + OSStatus err = SetIconFamilyData( iconFamily, dataType , data ); + wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ); + DisposeHandle( data ); + } + else +#endif + { + // setup the header properly + + Handle data = NULL ; + Handle maskdata = NULL ; + unsigned char * maskptr = NULL ; + unsigned char * ptr = NULL ; + size_t datasize, masksize ; + + datasize = sz * sz * 4 ; + data = NewHandle( datasize ) ; + HLock( data ) ; + ptr = (unsigned char*) *data ; + memset( ptr , 0, datasize ) ; + + masksize = sz * sz ; + maskdata = NewHandle( masksize ) ; + HLock( maskdata ) ; + maskptr = (unsigned char*) *maskdata ; + memset( maskptr , 0 , masksize ) ; + + bool hasAlpha = HasAlpha() ; + wxMask *mask = m_bitmapMask ; + unsigned char * sourcePtr = (unsigned char*) GetRawAccess() ; + unsigned char * masksourcePtr = mask ? (unsigned char*) mask->GetRawAccess() : NULL ; + + for ( int y = 0 ; y < h ; ++y, sourcePtr += m_bytesPerRow , masksourcePtr += mask ? mask->GetBytesPerRow() : 0 ) + { + unsigned char * source = sourcePtr; + unsigned char * masksource = masksourcePtr; + unsigned char * dest = ptr + y * sz * 4 ; + unsigned char * maskdest = maskptr + y * sz ; + unsigned char a, r, g, b; + + for ( int x = 0 ; x < w ; ++x ) + { + a = *source ++ ; + r = *source ++ ; + g = *source ++ ; + b = *source ++ ; + + *dest++ = 0 ; + *dest++ = r ; + *dest++ = g ; + *dest++ = b ; + + if ( mask ) + *maskdest++ = 0xFF - *masksource++ ; + else if ( hasAlpha ) + *maskdest++ = a ; + else + *maskdest++ = 0xFF ; + } + } + + OSStatus err = SetIconFamilyData( iconFamily, dataType , data ) ; + wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ; + + err = SetIconFamilyData( iconFamily, maskType , maskdata ) ; + wxASSERT_MSG( err == noErr , wxT("Error when adding mask") ) ; + + HUnlock( data ) ; + HUnlock( maskdata ) ; + DisposeHandle( data ) ; + DisposeHandle( maskdata ) ; + } + } + else + { + PicHandle pic = GetPictHandle() ; + SetIconFamilyData( iconFamily, 'PICT' , (Handle) pic ) ; + } + // transform into IconRef + + // cleaner version existing from 10.3 upwards + HLock((Handle) iconFamily); + OSStatus err = GetIconRefFromIconFamilyPtr( *iconFamily, GetHandleSize((Handle) iconFamily), &m_iconRef ); + HUnlock((Handle) iconFamily); + DisposeHandle( (Handle) iconFamily ) ; + + wxCHECK_MSG( err == noErr, NULL, wxT("Error when constructing icon ref") ); + } + + return m_iconRef ; +} + +PicHandle wxBitmapRefData::GetPictHandle() +{ + if ( m_pictHandle == NULL ) + { +#ifndef __LP64__ + GraphicsExportComponent exporter = 0; + OSStatus err = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypePicture, &exporter); + if (noErr == err) + { + m_pictHandle = (PicHandle) NewHandle(0); + if ( m_pictHandle ) + { + // QT does not correctly export the mask + // TODO if we get around to it create a synthetic PICT with the CopyBits and Mask commands + CGImageRef imageRef = CreateCGImage(); + err = GraphicsExportSetInputCGImage( exporter, imageRef ); + err = GraphicsExportSetOutputHandle(exporter, (Handle)m_pictHandle); + err = GraphicsExportDoExport(exporter, NULL); + CGImageRelease( imageRef ); + + size_t handleSize = GetHandleSize( (Handle) m_pictHandle ); + // the 512 bytes header is only needed for pict files, but not in memory + if ( handleSize >= 512 ) + { + memmove( *m_pictHandle , (char*)(*m_pictHandle)+512, handleSize - 512 ); + SetHandleSize( (Handle) m_pictHandle, handleSize - 512 ); + } + } + CloseComponent( exporter ); + } +#endif + } + + return m_pictHandle ; +} +#endif + +CGImageRef wxBitmapRefData::CreateCGImage() const +{ + wxASSERT( m_ok ) ; + wxASSERT( m_rawAccessCount >= 0 ) ; + CGImageRef image ; + if ( m_rawAccessCount > 0 || m_cgImageRef == NULL ) + { + if ( m_depth != 1 && m_bitmapMask == NULL ) + { + if ( m_bitmapMask ) + { + CGImageRef tempImage = CGBitmapContextCreateImage( m_hBitmap ); + CGImageRef tempMask = CGBitmapContextCreateImage((CGContextRef) m_bitmapMask->GetHBITMAP() ); + image = CGImageCreateWithMask( tempImage, tempMask ); + CGImageRelease(tempMask); + CGImageRelease(tempImage); + } + else + image = CGBitmapContextCreateImage( m_hBitmap ); + } + else + { + size_t imageSize = m_height * m_bytesPerRow ; + void * dataBuffer = m_memBuf.GetData() ; + int w = m_width ; + int h = m_height ; + CGImageAlphaInfo alphaInfo = kCGImageAlphaNoneSkipFirst ; + wxMemoryBuffer membuf; + + if ( m_bitmapMask ) + { + alphaInfo = kCGImageAlphaFirst ; + unsigned char *destalphastart = (unsigned char*) membuf.GetWriteBuf( imageSize ) ; + memcpy( destalphastart , dataBuffer , imageSize ) ; + unsigned char *sourcemaskstart = (unsigned char *) m_bitmapMask->GetRawAccess() ; + int maskrowbytes = m_bitmapMask->GetBytesPerRow() ; + for ( int y = 0 ; y < h ; ++y , destalphastart += m_bytesPerRow, sourcemaskstart += maskrowbytes) + { + unsigned char *sourcemask = sourcemaskstart ; + unsigned char *destalpha = destalphastart ; + for ( int x = 0 ; x < w ; ++x , sourcemask += kMaskBytesPerPixel , destalpha += 4 ) + { + *destalpha = 0xFF - *sourcemask ; + } + } + membuf.UngetWriteBuf( imageSize ); + } + else + { + if ( m_hasAlpha ) + { +#if wxOSX_USE_PREMULTIPLIED_ALPHA + alphaInfo = kCGImageAlphaPremultipliedFirst ; +#else + alphaInfo = kCGImageAlphaFirst ; +#endif + } + + membuf = m_memBuf; + } + + CGDataProviderRef dataProvider = NULL ; + if ( m_depth == 1 ) + { + // TODO CHECK ALIGNMENT + wxMemoryBuffer maskBuf; + unsigned char * maskBufData = (unsigned char*) maskBuf.GetWriteBuf( m_width * m_height ); + unsigned char * bufData = (unsigned char *) membuf.GetData() ; + // copy one color component + size_t i = 0; + for( int y = 0 ; y < m_height ; bufData+= m_bytesPerRow, ++y ) + { + unsigned char *bufDataIter = bufData+3; + for ( int x = 0 ; x < m_width ; bufDataIter += 4, ++x, ++i ) + { + maskBufData[i] = *bufDataIter; + } + } + maskBuf.UngetWriteBuf( m_width * m_height ); + + dataProvider = + wxMacCGDataProviderCreateWithMemoryBuffer( maskBuf ); + + image = ::CGImageMaskCreate( w, h, 8, 8, m_width , dataProvider, NULL, false ); + } + else + { + CGColorSpaceRef colorSpace = wxMacGetGenericRGBColorSpace(); + dataProvider = wxMacCGDataProviderCreateWithMemoryBuffer( membuf ); + image = + ::CGImageCreate( + w, h, 8 , 32 , m_bytesPerRow , colorSpace, alphaInfo , + dataProvider, NULL , false , kCGRenderingIntentDefault ); + } + CGDataProviderRelease( dataProvider); + } + } + else + { + image = m_cgImageRef ; + CGImageRetain( image ) ; + } + + if ( m_rawAccessCount == 0 && m_cgImageRef == NULL) + { + // we keep it for later use + m_cgImageRef = image ; + CGImageRetain( image ) ; + } + + return image ; +} + +CGContextRef wxBitmapRefData::GetBitmapContext() const +{ + return m_hBitmap; +} + +void wxBitmapRefData::Free() +{ + wxASSERT_MSG( m_rawAccessCount == 0 , wxT("Bitmap still selected when destroyed") ) ; + + if ( m_cgImageRef ) + { + CGImageRelease( m_cgImageRef ) ; + m_cgImageRef = NULL ; + } +#ifndef __WXOSX_IPHONE__ + if ( m_iconRef ) + { + ReleaseIconRef( m_iconRef ) ; + m_iconRef = NULL ; + } + +#ifndef __LP64__ + if ( m_pictHandle ) + { + KillPicture( m_pictHandle ) ; + m_pictHandle = NULL ; + } +#endif +#endif + if ( m_hBitmap ) + { + CGContextRelease(m_hBitmap); + m_hBitmap = NULL ; + } + + if (m_bitmapMask) + { + delete m_bitmapMask; + m_bitmapMask = NULL; + } +} + +wxBitmapRefData::~wxBitmapRefData() +{ + Free() ; +} + +bool wxBitmap::CopyFromIcon(const wxIcon& icon) +{ + bool created = false ; + int w = icon.GetWidth() ; + int h = icon.GetHeight() ; + + Create( icon.GetWidth() , icon.GetHeight() ) ; +#ifndef __WXOSX_IPHONE__ + if ( w == h && ( w == 16 || w == 32 || w == 48 || w == 128 ) ) + { + IconFamilyHandle iconFamily = NULL ; + Handle imagehandle = NewHandle( 0 ) ; + Handle maskhandle = NewHandle( 0 ) ; + + OSType maskType = 0; + OSType dataType = 0; + IconSelectorValue selector = 0 ; + + switch (w) + { + case 128: + dataType = kThumbnail32BitData ; + maskType = kThumbnail8BitMask ; + selector = kSelectorAllAvailableData ; + break; + + case 48: + dataType = kHuge32BitData ; + maskType = kHuge8BitMask ; + selector = kSelectorHuge32Bit | kSelectorHuge8BitMask ; + break; + + case 32: + dataType = kLarge32BitData ; + maskType = kLarge8BitMask ; + selector = kSelectorLarge32Bit | kSelectorLarge8BitMask ; + break; + + case 16: + dataType = kSmall32BitData ; + maskType = kSmall8BitMask ; + selector = kSelectorSmall32Bit | kSelectorSmall8BitMask ; + break; + + default: + break; + } + + OSStatus err = IconRefToIconFamily( MAC_WXHICON(icon.GetHICON()) , selector , &iconFamily ) ; + + err = GetIconFamilyData( iconFamily , dataType , imagehandle ) ; + err = GetIconFamilyData( iconFamily , maskType , maskhandle ) ; + size_t imagehandlesize = GetHandleSize( imagehandle ) ; + size_t maskhandlesize = GetHandleSize( maskhandle ) ; + + if ( imagehandlesize != 0 && maskhandlesize != 0 ) + { + wxASSERT( GetHandleSize( imagehandle ) == w * 4 * h ) ; + wxASSERT( GetHandleSize( maskhandle ) == w * h ) ; + + UseAlpha() ; + + unsigned char *source = (unsigned char *) *imagehandle ; + unsigned char *sourcemask = (unsigned char *) *maskhandle ; + unsigned char* destination = (unsigned char*) BeginRawAccess() ; + + for ( int y = 0 ; y < h ; ++y ) + { + for ( int x = 0 ; x < w ; ++x ) + { + unsigned char a = *sourcemask++; + *destination++ = a; + source++ ; +#if wxOSX_USE_PREMULTIPLIED_ALPHA + *destination++ = ( (*source++) * a + 127 ) / 255; + *destination++ = ( (*source++) * a + 127 ) / 255; + *destination++ = ( (*source++) * a + 127 ) / 255; +#else + *destination++ = *source++ ; + *destination++ = *source++ ; + *destination++ = *source++ ; +#endif + } + } + + EndRawAccess() ; + DisposeHandle( imagehandle ) ; + DisposeHandle( maskhandle ) ; + created = true ; + } + + DisposeHandle( (Handle) iconFamily ) ; + } +#endif + if ( !created ) + { + wxMemoryDC dc ; + dc.SelectObject( *this ) ; + dc.DrawIcon( icon , 0 , 0 ) ; + dc.SelectObject( wxNullBitmap ) ; + } + + return true; +} + +wxBitmap::wxBitmap() +{ +} + +wxBitmap::~wxBitmap() +{ +} + +wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits) +{ + wxBitmapRefData* bitmapRefData; + + m_refData = bitmapRefData = new wxBitmapRefData( the_width , the_height , no_bits ) ; + + if (bitmapRefData->IsOk()) + { + if ( no_bits == 1 ) + { + int linesize = ( the_width / (sizeof(unsigned char) * 8)) ; + if ( the_width % (sizeof(unsigned char) * 8) ) + linesize += sizeof(unsigned char); + + unsigned char* linestart = (unsigned char*) bits ; + unsigned char* destptr = (unsigned char*) BeginRawAccess() ; + + for ( int y = 0 ; y < the_height ; ++y , linestart += linesize, destptr += M_BITMAPDATA->GetBytesPerRow() ) + { + unsigned char* destination = destptr; + int index, bit, mask; + + for ( int x = 0 ; x < the_width ; ++x ) + { + index = x / 8 ; + bit = x % 8 ; + mask = 1 << bit ; + + if ( linestart[index] & mask ) + { + *destination++ = 0xFF ; + *destination++ = 0 ; + *destination++ = 0 ; + *destination++ = 0 ; + } + else + { + *destination++ = 0xFF ; + *destination++ = 0xFF ; + *destination++ = 0xFF ; + *destination++ = 0xFF ; + } + } + } + + EndRawAccess() ; + } + else + { + wxFAIL_MSG(wxT("multicolor BITMAPs not yet implemented")); + } + } /* bitmapRefData->IsOk() */ +} + +wxBitmap::wxBitmap(int w, int h, int d) +{ + (void)Create(w, h, d); +} + +wxBitmap::wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth) +{ + (void) Create(data, type, width, height, depth); +} + +wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type) +{ + LoadFile(filename, type); +} + +wxGDIRefData* wxBitmap::CreateGDIRefData() const +{ + return new wxBitmapRefData; +} + +wxGDIRefData* wxBitmap::CloneGDIRefData(const wxGDIRefData* data) const +{ + return new wxBitmapRefData(*wx_static_cast(const wxBitmapRefData *, data)); +} + +void * wxBitmap::GetRawAccess() const +{ + wxCHECK_MSG( Ok() , NULL , wxT("invalid bitmap") ) ; + + return M_BITMAPDATA->GetRawAccess() ; +} + +void * wxBitmap::BeginRawAccess() +{ + wxCHECK_MSG( Ok() , NULL , wxT("invalid bitmap") ) ; + + return M_BITMAPDATA->BeginRawAccess() ; +} + +void wxBitmap::EndRawAccess() +{ + wxCHECK_RET( Ok() , wxT("invalid bitmap") ) ; + + M_BITMAPDATA->EndRawAccess() ; +} + +CGImageRef wxBitmap::CreateCGImage() const +{ + wxCHECK_MSG( Ok(), NULL , wxT("invalid bitmap") ) ; + + return M_BITMAPDATA->CreateCGImage() ; +} + +#ifndef __WXOSX_IPHONE__ +IconRef wxBitmap::GetIconRef() const +{ + wxCHECK_MSG( Ok(), NULL , wxT("invalid bitmap") ) ; + + return M_BITMAPDATA->GetIconRef() ; +} + +IconRef wxBitmap::CreateIconRef() const +{ + IconRef icon = GetIconRef(); + verify_noerr( AcquireIconRef(icon) ); + return icon; +} +#endif + +wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const +{ + wxCHECK_MSG( Ok() && + (rect.x >= 0) && (rect.y >= 0) && + (rect.x+rect.width <= GetWidth()) && + (rect.y+rect.height <= GetHeight()), + wxNullBitmap, wxT("invalid bitmap or bitmap region") ); + + wxBitmap ret( rect.width, rect.height, GetDepth() ); + wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") ); + + int destwidth = rect.width ; + int destheight = rect.height ; + + { + unsigned char *sourcedata = (unsigned char*) GetRawAccess() ; + unsigned char *destdata = (unsigned char*) ret.BeginRawAccess() ; + wxASSERT( (sourcedata != NULL) && (destdata != NULL) ) ; + + int sourcelinesize = GetBitmapData()->GetBytesPerRow() ; + int destlinesize = ret.GetBitmapData()->GetBytesPerRow() ; + unsigned char *source = sourcedata + rect.x * 4 + rect.y * sourcelinesize ; + unsigned char *dest = destdata ; + + for (int yy = 0; yy < destheight; ++yy, source += sourcelinesize , dest += destlinesize) + { + memcpy( dest , source , destlinesize ) ; + } + } + + ret.EndRawAccess() ; + + if ( M_BITMAPDATA->m_bitmapMask ) + { + wxMemoryBuffer maskbuf ; + int rowBytes = GetBestBytesPerRow( destwidth * kMaskBytesPerPixel ); + size_t maskbufsize = rowBytes * destheight ; + + int sourcelinesize = M_BITMAPDATA->m_bitmapMask->GetBytesPerRow() ; + int destlinesize = rowBytes ; + + unsigned char *source = (unsigned char *) M_BITMAPDATA->m_bitmapMask->GetRawAccess() ; + unsigned char *destdata = (unsigned char * ) maskbuf.GetWriteBuf( maskbufsize ) ; + wxASSERT( (source != NULL) && (destdata != NULL) ) ; + + source += rect.x * kMaskBytesPerPixel + rect.y * sourcelinesize ; + unsigned char *dest = destdata ; + + for (int yy = 0; yy < destheight; ++yy, source += sourcelinesize , dest += destlinesize) + { + memcpy( dest , source , destlinesize ) ; + } + + maskbuf.UngetWriteBuf( maskbufsize ) ; + ret.SetMask( new wxMask( maskbuf , destwidth , destheight , rowBytes ) ) ; + } + else if ( HasAlpha() ) + ret.UseAlpha() ; + + return ret; +} + +bool wxBitmap::Create(int w, int h, int d) +{ + UnRef(); + + if ( d < 0 ) + d = wxDisplayDepth() ; + + m_refData = new wxBitmapRefData( w , h , d ); + + return M_BITMAPDATA->IsOk() ; +} + +bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) +{ + UnRef(); + + wxBitmapHandler *handler = FindHandler(type); + + if ( handler ) + { + m_refData = new wxBitmapRefData; + + return handler->LoadFile(this, filename, type, -1, -1); + } + else + { +#if wxUSE_IMAGE + wxImage loadimage(filename, type); + if (loadimage.Ok()) + { + *this = loadimage; + + return true; + } +#endif + } + + wxLogWarning(wxT("no bitmap handler for type %d defined."), type); + + return false; +} + +bool wxBitmap::Create(const void* data, wxBitmapType type, int width, int height, int depth) +{ + UnRef(); + + m_refData = new wxBitmapRefData; + + wxBitmapHandler *handler = FindHandler(type); + + if ( handler == NULL ) + { + wxLogWarning(wxT("no bitmap handler for type %d defined."), type); + + return false; + } + + return handler->Create(this, data, type, width, height, depth); +} + +#if wxUSE_IMAGE + +wxBitmap::wxBitmap(const wxImage& image, int depth) +{ + wxCHECK_RET( image.Ok(), wxT("invalid image") ); + + // width and height of the device-dependent bitmap + int width = image.GetWidth(); + int height = image.GetHeight(); + + wxBitmapRefData* bitmapRefData; + + m_refData = bitmapRefData = new wxBitmapRefData( width , height , depth ) ; + + if ( bitmapRefData->IsOk()) + { + // Create picture + + bool hasAlpha = false ; + + if ( image.HasMask() ) + { + // takes precedence, don't mix with alpha info + } + else + { + hasAlpha = image.HasAlpha() ; + } + + if ( hasAlpha ) + UseAlpha() ; + + unsigned char* destinationstart = (unsigned char*) BeginRawAccess() ; + register unsigned char* data = image.GetData(); + if ( destinationstart != NULL && data != NULL ) + { + const unsigned char *alpha = hasAlpha ? image.GetAlpha() : NULL ; + for (int y = 0; y < height; destinationstart += M_BITMAPDATA->GetBytesPerRow(), y++) + { + unsigned char * destination = destinationstart; + for (int x = 0; x < width; x++) + { + if ( hasAlpha ) + { + const unsigned char a = *alpha++; + *destination++ = a ; + + #if wxOSX_USE_PREMULTIPLIED_ALPHA + *destination++ = ((*data++) * a + 127) / 255 ; + *destination++ = ((*data++) * a + 127) / 255 ; + *destination++ = ((*data++) * a + 127) / 255 ; + #else + *destination++ = *data++ ; + *destination++ = *data++ ; + *destination++ = *data++ ; + #endif + } + else + { + *destination++ = 0xFF ; + *destination++ = *data++ ; + *destination++ = *data++ ; + *destination++ = *data++ ; + } + } + } + + EndRawAccess() ; + } + if ( image.HasMask() ) + SetMask( new wxMask( *this , wxColour( image.GetMaskRed() , image.GetMaskGreen() , image.GetMaskBlue() ) ) ) ; + } /* bitmapRefData->IsOk() */ +} + +wxImage wxBitmap::ConvertToImage() const +{ + wxImage image; + + wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") ); + + // create an wxImage object + int width = GetWidth(); + int height = GetHeight(); + image.Create( width, height ); + + unsigned char *data = image.GetData(); + wxCHECK_MSG( data, wxNullImage, wxT("Could not allocate data for image") ); + + unsigned char* sourcestart = (unsigned char*) GetRawAccess() ; + + bool hasAlpha = false ; + bool hasMask = false ; + int maskBytesPerRow = 0 ; + unsigned char *alpha = NULL ; + unsigned char *mask = NULL ; + + if ( HasAlpha() ) + hasAlpha = true ; + + if ( GetMask() ) + { + hasMask = true ; + mask = (unsigned char*) GetMask()->GetRawAccess() ; + maskBytesPerRow = GetMask()->GetBytesPerRow() ; + } + + if ( hasAlpha ) + { + image.SetAlpha() ; + alpha = image.GetAlpha() ; + } + + int index = 0; + + // The following masking algorithm is the same as well in msw/gtk: + // the colour used as transparent one in wxImage and the one it is + // replaced with when it actually occurs in the bitmap + static const int MASK_RED = 1; + static const int MASK_GREEN = 2; + static const int MASK_BLUE = 3; + static const int MASK_BLUE_REPLACEMENT = 2; + + for (int yy = 0; yy < height; yy++ , sourcestart += M_BITMAPDATA->GetBytesPerRow() , mask += maskBytesPerRow ) + { + unsigned char * maskp = mask ; + unsigned char * source = sourcestart; + unsigned char a, r, g, b; + long color; + + for (int xx = 0; xx < width; xx++) + { + color = *((long*) source) ; +#ifdef WORDS_BIGENDIAN + a = ((color&0xFF000000) >> 24) ; + r = ((color&0x00FF0000) >> 16) ; + g = ((color&0x0000FF00) >> 8) ; + b = (color&0x000000FF); +#else + b = ((color&0xFF000000) >> 24) ; + g = ((color&0x00FF0000) >> 16) ; + r = ((color&0x0000FF00) >> 8) ; + a = (color&0x000000FF); +#endif + if ( hasMask ) + { + if ( *maskp++ == 0xFF ) + { + r = MASK_RED ; + g = MASK_GREEN ; + b = MASK_BLUE ; + } + else if ( r == MASK_RED && g == MASK_GREEN && b == MASK_BLUE ) + b = MASK_BLUE_REPLACEMENT ; + } + else if ( hasAlpha ) + { + *alpha++ = a ; +#if wxOSX_USE_PREMULTIPLIED_ALPHA + // this must be non-premultiplied data + if ( a != 0xFF && a!= 0 ) + { + r = r * 255 / a; + g = g * 255 / a; + b = b * 255 / a; + } +#endif + } + + data[index ] = r ; + data[index + 1] = g ; + data[index + 2] = b ; + + index += 3; + source += 4 ; + } + } + + if ( hasMask ) + image.SetMaskColour( MASK_RED, MASK_GREEN, MASK_BLUE ); + + return image; +} + +#endif //wxUSE_IMAGE + +bool wxBitmap::SaveFile( const wxString& filename, + wxBitmapType type, const wxPalette *palette ) const +{ + bool success = false; + wxBitmapHandler *handler = FindHandler(type); + + if ( handler ) + { + success = handler->SaveFile(this, filename, type, palette); + } + else + { +#if wxUSE_IMAGE + wxImage image = ConvertToImage(); + success = image.SaveFile(filename, type); +#else + wxLogWarning(wxT("no bitmap handler for type %d defined."), type); +#endif + } + + return success; +} + +int wxBitmap::GetHeight() const +{ + wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") ); + + return M_BITMAPDATA->GetHeight(); +} + +int wxBitmap::GetWidth() const +{ + wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") ); + + return M_BITMAPDATA->GetWidth() ; +} + +int wxBitmap::GetDepth() const +{ + wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") ); + + return M_BITMAPDATA->GetDepth(); +} + +wxMask *wxBitmap::GetMask() const +{ + wxCHECK_MSG( Ok(), (wxMask *) NULL, wxT("invalid bitmap") ); + + return M_BITMAPDATA->m_bitmapMask; +} + +bool wxBitmap::HasAlpha() const +{ + wxCHECK_MSG( Ok(), false , wxT("invalid bitmap") ); + + return M_BITMAPDATA->HasAlpha() ; +} + +void wxBitmap::SetWidth(int w) +{ + AllocExclusive(); + M_BITMAPDATA->SetWidth(w); +} + +void wxBitmap::SetHeight(int h) +{ + AllocExclusive(); + M_BITMAPDATA->SetHeight(h); +} + +void wxBitmap::SetDepth(int d) +{ + AllocExclusive(); + M_BITMAPDATA->SetDepth(d); +} + +void wxBitmap::SetOk(bool isOk) +{ + AllocExclusive(); + M_BITMAPDATA->SetOk(isOk); +} + +#if wxUSE_PALETTE +wxPalette *wxBitmap::GetPalette() const +{ + wxCHECK_MSG( Ok(), NULL, wxT("Invalid bitmap GetPalette()") ); + + return &M_BITMAPDATA->m_bitmapPalette; +} + +void wxBitmap::SetPalette(const wxPalette& palette) +{ + AllocExclusive(); + M_BITMAPDATA->m_bitmapPalette = palette ; +} +#endif // wxUSE_PALETTE + +void wxBitmap::SetMask(wxMask *mask) +{ + AllocExclusive(); + // Remove existing mask if there is one. + delete M_BITMAPDATA->m_bitmapMask; + + M_BITMAPDATA->m_bitmapMask = mask ; +} + +WXHBITMAP wxBitmap::GetHBITMAP(WXHBITMAP* mask) const +{ + wxUnusedVar(mask); + + return WXHBITMAP(M_BITMAPDATA->GetBitmapContext()); +} + +// ---------------------------------------------------------------------------- +// wxMask +// ---------------------------------------------------------------------------- + +wxMask::wxMask() +{ + Init() ; +} + +wxMask::wxMask(const wxMask &tocopy) +{ + Init(); + + m_bytesPerRow = tocopy.m_bytesPerRow; + m_width = tocopy.m_width; + m_height = tocopy.m_height; + + size_t size = m_bytesPerRow * m_height; + unsigned char* dest = (unsigned char*)m_memBuf.GetWriteBuf( size ); + unsigned char* source = (unsigned char*)tocopy.m_memBuf.GetData(); + memcpy( dest, source, size ); + m_memBuf.UngetWriteBuf( size ) ; + RealizeNative() ; +} + +// Construct a mask from a bitmap and a colour indicating +// the transparent area +wxMask::wxMask( const wxBitmap& bitmap, const wxColour& colour ) +{ + Init() ; + Create( bitmap, colour ); +} + +// Construct a mask from a mono bitmap (copies the bitmap). +wxMask::wxMask( const wxBitmap& bitmap ) +{ + Init() ; + Create( bitmap ); +} + +// Construct a mask from a mono bitmap (copies the bitmap). + +wxMask::wxMask( const wxMemoryBuffer& data, int width , int height , int bytesPerRow ) +{ + Init() ; + Create( data, width , height , bytesPerRow ); +} + +wxMask::~wxMask() +{ + if ( m_maskBitmap ) + { + CGContextRelease( (CGContextRef) m_maskBitmap ); + m_maskBitmap = NULL ; + } +} + +void wxMask::Init() +{ + m_width = m_height = m_bytesPerRow = 0 ; + m_maskBitmap = NULL ; +} + +void *wxMask::GetRawAccess() const +{ + return m_memBuf.GetData() ; +} + +// The default ColorTable for k8IndexedGrayPixelFormat in Intel appears to be broken, so we'll use an non-indexed +// bitmap mask instead; in order to keep the code simple, the change applies to PowerPC implementations as well + +void wxMask::RealizeNative() +{ + if ( m_maskBitmap ) + { + CGContextRelease( (CGContextRef) m_maskBitmap ); + m_maskBitmap = NULL ; + } + + CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray(); + // from MouseTracking sample : + // Ironically, due to a bug in CGImageCreateWithMask, you cannot use + // CGColorSpaceCreateWithName(kCGColorSpaceGenericGray) at this point! + + m_maskBitmap = CGBitmapContextCreate((char*) m_memBuf.GetData(), m_width, m_height, 8, m_bytesPerRow, colorspace, + kCGImageAlphaNone ); + CGColorSpaceRelease( colorspace ); + wxASSERT_MSG( m_maskBitmap , wxT("Unable to create CGBitmapContext context") ) ; +} + +// Create a mask from a mono bitmap (copies the bitmap). + +bool wxMask::Create(const wxMemoryBuffer& data,int width , int height , int bytesPerRow) +{ + m_memBuf = data ; + m_width = width ; + m_height = height ; + m_bytesPerRow = bytesPerRow ; + + wxASSERT( data.GetDataLen() == (size_t)(height * bytesPerRow) ) ; + + RealizeNative() ; + + return true ; +} + +// Create a mask from a mono bitmap (copies the bitmap). +bool wxMask::Create(const wxBitmap& bitmap) +{ + m_width = bitmap.GetWidth() ; + m_height = bitmap.GetHeight() ; + m_bytesPerRow = GetBestBytesPerRow( m_width * kMaskBytesPerPixel ) ; + + size_t size = m_bytesPerRow * m_height ; + unsigned char * destdatabase = (unsigned char*) m_memBuf.GetWriteBuf( size ) ; + wxASSERT( destdatabase != NULL ) ; + + memset( destdatabase , 0 , size ) ; + unsigned char * srcdata = (unsigned char*) bitmap.GetRawAccess() ; + + for ( int y = 0 ; y < m_height ; ++y , destdatabase += m_bytesPerRow ) + { + unsigned char *destdata = destdatabase ; + unsigned char r, g, b; + + for ( int x = 0 ; x < m_width ; ++x ) + { + srcdata++ ; + r = *srcdata++ ; + g = *srcdata++ ; + b = *srcdata++ ; + + if ( ( r + g + b ) > 0x10 ) + *destdata++ = 0xFF ; + else + *destdata++ = 0x00 ; + } + } + + m_memBuf.UngetWriteBuf( size ) ; + RealizeNative() ; + + return true; +} + +// Create a mask from a bitmap and a colour indicating +// the transparent area +bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) +{ + m_width = bitmap.GetWidth() ; + m_height = bitmap.GetHeight() ; + m_bytesPerRow = GetBestBytesPerRow( m_width * kMaskBytesPerPixel ) ; + + size_t size = m_bytesPerRow * m_height ; + unsigned char * destdatabase = (unsigned char*) m_memBuf.GetWriteBuf( size ) ; + wxASSERT( destdatabase != NULL ) ; + + memset( destdatabase , 0 , size ) ; + unsigned char * srcdatabase = (unsigned char*) bitmap.GetRawAccess() ; + size_t sourceBytesRow = bitmap.GetBitmapData()->GetBytesPerRow(); + + for ( int y = 0 ; y < m_height ; ++y , srcdatabase+= sourceBytesRow, destdatabase += m_bytesPerRow) + { + unsigned char *srcdata = srcdatabase ; + unsigned char *destdata = destdatabase ; + unsigned char r, g, b; + + for ( int x = 0 ; x < m_width ; ++x ) + { + srcdata++ ; + r = *srcdata++ ; + g = *srcdata++ ; + b = *srcdata++ ; + + if ( colour == wxColour( r , g , b ) ) + *destdata++ = 0xFF ; + else + *destdata++ = 0x00 ; + } + } + + m_memBuf.UngetWriteBuf( size ) ; + RealizeNative() ; + + return true; +} + +WXHBITMAP wxMask::GetHBITMAP() const +{ + return m_maskBitmap ; +} + +// ---------------------------------------------------------------------------- +// Standard Handlers +// ---------------------------------------------------------------------------- + +#if !defined( __LP64__ ) && !defined(__WXOSX_IPHONE__) + +class WXDLLEXPORT wxPICTResourceHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxPICTResourceHandler) + +public: + inline wxPICTResourceHandler() + { + SetName(wxT("Macintosh Pict resource")); + SetExtension(wxEmptyString); + SetType(wxBITMAP_TYPE_PICT_RESOURCE); + }; + + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight); +}; + +IMPLEMENT_DYNAMIC_CLASS(wxPICTResourceHandler, wxBitmapHandler) + + +bool wxPICTResourceHandler::LoadFile(wxBitmap *bitmap, + const wxString& name, + long WXUNUSED(flags), + int WXUNUSED(desiredWidth), + int WXUNUSED(desiredHeight)) +{ +#if wxUSE_METAFILE + Str255 theName ; + wxMacStringToPascal( name , theName ) ; + + PicHandle thePict = (PicHandle ) GetNamedResource( 'PICT' , theName ) ; + if ( thePict ) + { + wxMetafile mf ; + + mf.SetPICT( thePict ) ; + bitmap->Create( mf.GetWidth() , mf.GetHeight() ) ; + wxMemoryDC dc ; + dc.SelectObject( *bitmap ) ; + mf.Play( &dc ) ; + dc.SelectObject( wxNullBitmap ) ; + + return true ; + } +#endif + + return false ; +} +#endif + +void wxBitmap::InitStandardHandlers() +{ +#if !defined( __LP64__ ) && !defined(__WXOSX_IPHONE__) + AddHandler( new wxPICTResourceHandler ) ; +#endif +#if wxOSX_USE_COCOA_OR_CARBON + AddHandler( new wxICONResourceHandler ) ; +#endif +} + +// ---------------------------------------------------------------------------- +// raw bitmap access support +// ---------------------------------------------------------------------------- + +void *wxBitmap::GetRawData(wxPixelDataBase& data, int WXUNUSED(bpp)) +{ + if ( !Ok() ) + // no bitmap, no data (raw or otherwise) + return NULL; + + data.m_width = GetWidth() ; + data.m_height = GetHeight() ; + data.m_stride = GetBitmapData()->GetBytesPerRow() ; + + return BeginRawAccess() ; +} + +void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(dataBase)) +{ + EndRawAccess() ; +} + +void wxBitmap::UseAlpha() +{ + // remember that we are using alpha channel: + // we'll need to create a proper mask in UngetRawData() + M_BITMAPDATA->UseAlpha( true ); +} diff --git a/src/osx/core/dcmemory.cpp b/src/osx/core/dcmemory.cpp new file mode 100644 index 0000000000..a21782eaae --- /dev/null +++ b/src/osx/core/dcmemory.cpp @@ -0,0 +1,116 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/osx/core/dcmemory.cpp +// Purpose: wxMemoryDC class +// Author: Stefan Csomor +// Modified by: +// Created: 01/02/97 +// RCS-ID: $Id$ +// Copyright: (c) Stefan Csomor +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/wxprec.h" + +#include "wx/dcmemory.h" +#include "wx/graphics.h" +#include "wx/osx/dcmemory.h" + +#include "wx/osx/private.h" + +//----------------------------------------------------------------------------- +// wxMemoryDCImpl +//----------------------------------------------------------------------------- + +IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl,wxPaintDCImpl) + + +wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner ) + : wxPaintDCImpl( owner ) +{ + Init(); +} + +wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap ) + : wxPaintDCImpl( owner ) +{ + Init(); + DoSelect(bitmap); +} + +wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxDC * WXUNUSED(dc) ) + : wxPaintDCImpl( owner ) +{ + Init(); +} + +void wxMemoryDCImpl::Init() +{ + m_ok = true; + SetBackground(*wxWHITE_BRUSH); + SetBrush(*wxWHITE_BRUSH); + SetPen(*wxBLACK_PEN); + SetFont(*wxNORMAL_FONT); + m_ok = false; +} + +wxMemoryDCImpl::~wxMemoryDCImpl() +{ + if ( m_selected.Ok() ) + { + m_selected.EndRawAccess() ; + delete m_graphicContext ; + m_graphicContext = NULL ; + } +} + +void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) +{ + if ( m_selected.Ok() ) + { + m_selected.EndRawAccess() ; + delete m_graphicContext ; + m_graphicContext = NULL ; + } + + m_selected = bitmap; + if (m_selected.Ok()) + { + if ( m_selected.GetDepth() != 1 ) + m_selected.UseAlpha() ; + m_selected.BeginRawAccess() ; + m_width = bitmap.GetWidth(); + m_height = bitmap.GetHeight(); + CGColorSpaceRef genericColorSpace = wxMacGetGenericRGBColorSpace(); + CGContextRef bmCtx = (CGContextRef) m_selected.GetHBITMAP(); + + if ( bmCtx ) + { + CGContextSetFillColorSpace( bmCtx, genericColorSpace ); + CGContextSetStrokeColorSpace( bmCtx, genericColorSpace ); + SetGraphicsContext( wxGraphicsContext::CreateFromNative( bmCtx ) ); + } + m_ok = (m_graphicContext != NULL) ; + } + else + { + m_ok = false; + } +} + +void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const +{ + if (m_selected.Ok()) + { + if (width) + (*width) = m_selected.GetWidth(); + if (height) + (*height) = m_selected.GetHeight(); + } + else + { + if (width) + (*width) = 0; + if (height) + (*height) = 0; + } +} diff --git a/src/osx/core/display.cpp b/src/osx/core/display.cpp new file mode 100644 index 0000000000..45dcdd802f --- /dev/null +++ b/src/osx/core/display.cpp @@ -0,0 +1,265 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/osx/core/display.cpp +// Purpose: Mac implementation of wxDisplay class +// Author: Ryan Norton & Brian Victor +// Modified by: Royce Mitchell III, Vadim Zeitlin +// Created: 06/21/02 +// RCS-ID: $Id$ +// Copyright: (c) wxWidgets team +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#if wxUSE_DISPLAY + +#include "wx/display.h" + +#ifndef WX_PRECOMP + #include "wx/dynarray.h" + #include "wx/log.h" + #include "wx/string.h" + #include "wx/gdicmn.h" +#endif + +#include "wx/display_impl.h" +#include "wx/osx/private.h" + +#if wxOSX_USE_COCOA_OR_CARBON + +// ---------------------------------------------------------------------------- +// display classes implementation +// ---------------------------------------------------------------------------- + +class wxDisplayImplMacOSX : public wxDisplayImpl +{ +public: + wxDisplayImplMacOSX(unsigned n, CGDirectDisplayID id) + : wxDisplayImpl(n), + m_id(id) + { + } + + virtual wxRect GetGeometry() const; + virtual wxRect GetClientArea() const; + virtual wxString GetName() const { return wxString(); } + + virtual wxArrayVideoModes GetModes(const wxVideoMode& mode) const; + virtual wxVideoMode GetCurrentMode() const; + virtual bool ChangeMode(const wxVideoMode& mode); + +private: + CGDirectDisplayID m_id; + + DECLARE_NO_COPY_CLASS(wxDisplayImplMacOSX) +}; + +class wxDisplayFactoryMacOSX : public wxDisplayFactory +{ +public: + wxDisplayFactoryMacOSX() {} + + virtual wxDisplayImpl *CreateDisplay(unsigned n); + virtual unsigned GetCount(); + virtual int GetFromPoint(const wxPoint& pt); + +protected: + DECLARE_NO_COPY_CLASS(wxDisplayFactoryMacOSX) +}; + +// ============================================================================ +// wxDisplayFactoryMacOSX implementation +// ============================================================================ + +unsigned wxDisplayFactoryMacOSX::GetCount() +{ + CGDisplayCount count; +#ifdef __WXDEBUG__ + CGDisplayErr err = +#endif + CGGetActiveDisplayList(0, NULL, &count); + + wxASSERT(err == CGDisplayNoErr); + + return count; +} + +int wxDisplayFactoryMacOSX::GetFromPoint(const wxPoint& p) +{ + CGPoint thePoint = {(float)p.x, (float)p.y}; + CGDirectDisplayID theID; + CGDisplayCount theCount; + CGDisplayErr err = CGGetDisplaysWithPoint(thePoint, 1, &theID, &theCount); + wxASSERT(err == CGDisplayNoErr); + + int nWhich = wxNOT_FOUND; + + if (theCount) + { + theCount = GetCount(); + CGDirectDisplayID* theIDs = new CGDirectDisplayID[theCount]; + err = CGGetActiveDisplayList(theCount, theIDs, &theCount); + wxASSERT(err == CGDisplayNoErr); + + for (nWhich = 0; nWhich < (int) theCount; ++nWhich) + { + if (theIDs[nWhich] == theID) + break; + } + + delete [] theIDs; + + if (nWhich == (int) theCount) + { + wxFAIL_MSG(wxT("Failed to find display in display list")); + nWhich = wxNOT_FOUND; + } + } + + return nWhich; +} + +wxDisplayImpl *wxDisplayFactoryMacOSX::CreateDisplay(unsigned n) +{ + CGDisplayCount theCount = GetCount(); + CGDirectDisplayID* theIDs = new CGDirectDisplayID[theCount]; + +#ifdef __WXDEBUG__ + CGDisplayErr err = +#endif + CGGetActiveDisplayList(theCount, theIDs, &theCount); + + wxASSERT( err == CGDisplayNoErr ); + wxASSERT( n < theCount ); + + wxDisplayImplMacOSX *display = new wxDisplayImplMacOSX(n, theIDs[n]); + + delete [] theIDs; + + return display; +} + +// ============================================================================ +// wxDisplayImplMacOSX implementation +// ============================================================================ + +wxRect wxDisplayImplMacOSX::GetGeometry() const +{ + CGRect theRect = CGDisplayBounds(m_id); + return wxRect( (int)theRect.origin.x, + (int)theRect.origin.y, + (int)theRect.size.width, + (int)theRect.size.height ); //floats +} + +wxRect wxDisplayImplMacOSX::GetClientArea() const +{ + // VZ: I don't know how to get client area for arbitrary display but + // wxGetClientDisplayRect() does work correctly for at least the main + // one (TODO: do it correctly for the other displays too) + if ( IsPrimary() ) + return wxGetClientDisplayRect(); + + return wxDisplayImpl::GetClientArea(); +} + +static int wxCFDictKeyToInt( CFDictionaryRef desc, CFStringRef key ) +{ + CFNumberRef value = (CFNumberRef) CFDictionaryGetValue( desc, key ); + if (value == NULL) + return 0; + + int num = 0; + CFNumberGetValue( value, kCFNumberIntType, &num ); + + return num; +} + +wxArrayVideoModes wxDisplayImplMacOSX::GetModes(const wxVideoMode& mode) const +{ + wxArrayVideoModes resultModes; + + CFArrayRef theArray = CGDisplayAvailableModes( m_id ); + + for (CFIndex i = 0; i < CFArrayGetCount(theArray); ++i) + { + CFDictionaryRef theValue = (CFDictionaryRef) CFArrayGetValueAtIndex( theArray, i ); + + wxVideoMode theMode( + wxCFDictKeyToInt( theValue, kCGDisplayWidth ), + wxCFDictKeyToInt( theValue, kCGDisplayHeight ), + wxCFDictKeyToInt( theValue, kCGDisplayBitsPerPixel ), + wxCFDictKeyToInt( theValue, kCGDisplayRefreshRate )); + + if (theMode.Matches( mode )) + resultModes.Add( theMode ); + } + + return resultModes; +} + +wxVideoMode wxDisplayImplMacOSX::GetCurrentMode() const +{ + CFDictionaryRef theValue = CGDisplayCurrentMode( m_id ); + + return wxVideoMode( + wxCFDictKeyToInt( theValue, kCGDisplayWidth ), + wxCFDictKeyToInt( theValue, kCGDisplayHeight ), + wxCFDictKeyToInt( theValue, kCGDisplayBitsPerPixel ), + wxCFDictKeyToInt( theValue, kCGDisplayRefreshRate )); +} + +bool wxDisplayImplMacOSX::ChangeMode( const wxVideoMode& mode ) +{ + // Changing to default mode (wxDefaultVideoMode) doesn't + // work because we don't have access to the system's 'scrn' + // resource which holds the user's mode which the system + // will return to after this app is done + boolean_t bExactMatch; + CFDictionaryRef theCGMode = CGDisplayBestModeForParametersAndRefreshRate( + m_id, + (size_t)mode.GetDepth(), + (size_t)mode.GetWidth(), + (size_t)mode.GetHeight(), + (double)mode.GetRefresh(), + &bExactMatch ); + + bool bOK = bExactMatch; + + if (bOK) + bOK = CGDisplaySwitchToMode( m_id, theCGMode ) == CGDisplayNoErr; + + return bOK; +} + +// ============================================================================ +// wxDisplay::CreateFactory() +// ============================================================================ + +/* static */ wxDisplayFactory *wxDisplay::CreateFactory() +{ + return new wxDisplayFactoryMacOSX; +} + +#else + +/* static */ wxDisplayFactory *wxDisplay::CreateFactory() +{ + return new wxDisplayFactorySingle; +} + +#endif + +#endif // wxUSE_DISPLAY diff --git a/src/osx/core/fontenum.cpp b/src/osx/core/fontenum.cpp new file mode 100644 index 0000000000..c7e7376ff2 --- /dev/null +++ b/src/osx/core/fontenum.cpp @@ -0,0 +1,123 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/osx/core/fontenum.cpp +// Purpose: wxFontEnumerator class for MacOS +// Author: Stefan Csomor +// Modified by: +// Created: 04/01/98 +// RCS-ID: $Id$ +// Copyright: (c) Stefan Csomor +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#if wxUSE_FONTENUM + +#include "wx/fontenum.h" + +#ifndef WX_PRECOMP + #include "wx/font.h" + #include "wx/intl.h" +#endif + +#include "wx/fontutil.h" +#include "wx/fontmap.h" +#include "wx/encinfo.h" + +#include "wx/osx/private.h" + +// ---------------------------------------------------------------------------- +// wxFontEnumerator +// ---------------------------------------------------------------------------- + +bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding, + bool fixedWidthOnly) +{ + if ( fixedWidthOnly ) + { + wxFAIL_MSG( "enumerating only fixed width fonts not supported" ); + return false; + } + + wxArrayString fontFamilies ; + +#if wxOSX_USE_ATSU_TEXT || wxOSX_USE_CORE_TEXT + + // + // From Apple's QA 1471 http://developer.apple.com/qa/qa2006/qa1471.html + // + + ATSFontFamilyIterator theFontFamilyIterator = NULL; + ATSFontFamilyRef theATSFontFamilyRef = 0; + OSStatus status = noErr; + + // Create the iterator + status = ATSFontFamilyIteratorCreate(kATSFontContextLocal, nil,nil, + kATSOptionFlagsUnRestrictedScope, + &theFontFamilyIterator ); + + wxUint32 macEncoding = wxMacGetSystemEncFromFontEnc(encoding) ; + + while (status == noErr) + { + // Get the next font in the iteration. + status = ATSFontFamilyIteratorNext( theFontFamilyIterator, &theATSFontFamilyRef ); + if(status == noErr) + { + #ifndef __LP64__ + // TODO CS : Find replacement + // added CS : avoid showing fonts that won't be displayable + FMFontStyle intrinsicStyle = 0 ; + FMFont fontInstance ; + FMFontFamily fmFamily = FMGetFontFamilyFromATSFontFamilyRef( theATSFontFamilyRef ); + status = FMGetFontFromFontFamilyInstance( fmFamily , 0 , &fontInstance , &intrinsicStyle); + if ( status != noErr ) + { + status = noErr; + continue ; + } +#endif + if ( encoding != wxFONTENCODING_SYSTEM ) + { + TextEncoding fontFamiliyEncoding = ATSFontFamilyGetEncoding(theATSFontFamilyRef) ; + if ( fontFamiliyEncoding != macEncoding ) + continue ; + } + + // TODO: determine fixed widths ... + + CFStringRef theName = NULL; + ATSFontFamilyGetName(theATSFontFamilyRef, kATSOptionFlagsDefault, &theName); + wxCFStringRef cfName(theName) ; + fontFamilies.Add(cfName.AsString(wxLocale::GetSystemEncoding())); + } + else if (status == kATSIterationScopeModified) // Make sure the font database hasnÕt changed. + { + // reset the iterator + status = ATSFontFamilyIteratorReset (kATSFontContextLocal, nil, nil, + kATSOptionFlagsUnRestrictedScope, + &theFontFamilyIterator); + fontFamilies.Clear() ; + } + } + ATSFontFamilyIteratorRelease(&theFontFamilyIterator); +#endif + + for ( size_t i = 0 ; i < fontFamilies.Count() ; ++i ) + { + if ( OnFacename( fontFamilies[i] ) == false ) + break ; + } + + return true; +} + +bool wxFontEnumerator::EnumerateEncodings(const wxString& WXUNUSED(family)) +{ + wxFAIL_MSG(wxT("wxFontEnumerator::EnumerateEncodings() not yet implemented")); + + return true; +} + +#endif // wxUSE_FONTENUM diff --git a/src/osx/core/printmac.cpp b/src/osx/core/printmac.cpp new file mode 100644 index 0000000000..d7aae24967 --- /dev/null +++ b/src/osx/core/printmac.cpp @@ -0,0 +1,621 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/osx/core/printmac.cpp +// Purpose: wxMacPrinter framework +// Author: Julian Smart, Stefan Csomor +// Modified by: +// Created: 04/01/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart, Stefan Csomor +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#if wxUSE_PRINTING_ARCHITECTURE + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/utils.h" + #include "wx/dc.h" + #include "wx/app.h" + #include "wx/msgdlg.h" + #include "wx/dcprint.h" + #include "wx/math.h" +#endif + +#include "wx/osx/uma.h" + +#include "wx/osx/printmac.h" +#include "wx/osx/private/print.h" + +#include "wx/printdlg.h" +#include "wx/paper.h" +#include "wx/osx/printdlg.h" + +#include + +IMPLEMENT_DYNAMIC_CLASS(wxMacCarbonPrintData, wxPrintNativeDataBase) +IMPLEMENT_DYNAMIC_CLASS(wxMacPrinter, wxPrinterBase) +IMPLEMENT_CLASS(wxMacPrintPreview, wxPrintPreviewBase) + +bool wxMacCarbonPrintData::IsOk() const +{ + return (m_macPageFormat != kPMNoPageFormat) && (m_macPrintSettings != kPMNoPrintSettings) && (m_macPrintSession != kPMNoReference); +} +wxMacCarbonPrintData::wxMacCarbonPrintData() +{ + m_macPageFormat = kPMNoPageFormat; + m_macPrintSettings = kPMNoPrintSettings; + m_macPrintSession = kPMNoReference ; + ValidateOrCreate() ; +} + +wxMacCarbonPrintData::~wxMacCarbonPrintData() +{ + if (m_macPageFormat != kPMNoPageFormat) + { + (void)PMRelease(m_macPageFormat); + m_macPageFormat = kPMNoPageFormat; + } + + if (m_macPrintSettings != kPMNoPrintSettings) + { + (void)PMRelease(m_macPrintSettings); + m_macPrintSettings = kPMNoPrintSettings; + } + + if ( m_macPrintSession != kPMNoReference ) + { + (void)PMRelease(m_macPrintSession); + m_macPrintSession = kPMNoReference; + } +} + +void wxMacCarbonPrintData::ValidateOrCreate() +{ + OSStatus err = noErr ; + if ( m_macPrintSession == kPMNoReference ) + { + err = PMCreateSession( &m_macPrintSession ) ; + } + // Set up a valid PageFormat object. + if ( m_macPageFormat == kPMNoPageFormat) + { + err = PMCreatePageFormat(&m_macPageFormat); + + // Note that PMPageFormat is not session-specific, but calling + // PMSessionDefaultPageFormat assigns values specific to the printer + // associated with the current printing session. + if ((err == noErr) && + ( m_macPageFormat != kPMNoPageFormat)) + { + err = PMSessionDefaultPageFormat(m_macPrintSession, + m_macPageFormat); + } + } + else + { + err = PMSessionValidatePageFormat(m_macPrintSession, + m_macPageFormat, + kPMDontWantBoolean); + } + + // Set up a valid PrintSettings object. + if ( m_macPrintSettings == kPMNoPrintSettings) + { + err = PMCreatePrintSettings( &m_macPrintSettings); + + // Note that PMPrintSettings is not session-specific, but calling + // PMSessionDefaultPrintSettings assigns values specific to the printer + // associated with the current printing session. + if ((err == noErr) && + ( m_macPrintSettings != kPMNoPrintSettings)) + { + err = PMSessionDefaultPrintSettings(m_macPrintSession, + m_macPrintSettings); + } + } + else + { + err = PMSessionValidatePrintSettings( m_macPrintSession, + m_macPrintSettings, + kPMDontWantBoolean); + } +} + +bool wxMacCarbonPrintData::TransferFrom( const wxPrintData &data ) +{ + ValidateOrCreate() ; + PMSetCopies( (PMPrintSettings) m_macPrintSettings , data.GetNoCopies() , false ) ; + if ( data.IsOrientationReversed() ) + PMSetOrientation( (PMPageFormat) m_macPageFormat , ( data.GetOrientation() == wxLANDSCAPE ) ? + kPMReverseLandscape : kPMReversePortrait , false ) ; + else + PMSetOrientation( (PMPageFormat) m_macPageFormat , ( data.GetOrientation() == wxLANDSCAPE ) ? + kPMLandscape : kPMPortrait , false ) ; + // collate cannot be set +#if 0 // not yet tested + if ( !m_printerName.empty() ) + PMSessionSetCurrentPrinter( (PMPrintSession) m_macPrintSession , wxCFStringRef( m_printerName , wxFont::GetDefaultEncoding() ) ) ; +#endif +#if wxOSX_USE_CARBON + PMColorMode color ; + PMGetColorMode( (PMPrintSettings) m_macPrintSettings, &color ) ; + if ( data.GetColour() ) + { + if ( color == kPMBlackAndWhite ) + PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMColor ) ; + } + else + PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMBlackAndWhite ) ; +#endif + + PMDuplexMode mode = 0 ; + switch( data.GetDuplex() ) + { + case wxDUPLEX_HORIZONTAL : + mode = kPMDuplexNoTumble ; + break ; + case wxDUPLEX_VERTICAL : + mode = kPMDuplexTumble ; + break ; + case wxDUPLEX_SIMPLEX : + default : + mode = kPMDuplexNone ; + break ; + } + PMSetDuplex( (PMPrintSettings) m_macPrintSettings, mode ) ; + + // PMQualityMode not yet accessible via API + // todo paperSize + + PMResolution res; + PMPrinter printer; + PMSessionGetCurrentPrinter(m_macPrintSession, &printer); + +#if wxOSX_USE_CARBON + PMTag tag = kPMMaxSquareResolution; + PMPrinterGetPrinterResolution(printer, tag, &res); + PMSetResolution((PMPageFormat) m_macPageFormat, &res); +#else + PMPrinterGetOutputResolution( printer, + (PMPrintSettings) m_macPrintSettings, &res) ; + // TODO transfer ? into page format ? + // may fail ! +#endif + // after setting the new resolution the format has to be updated, otherwise the page rect remains + // at the 'old' scaling + PMSessionValidatePageFormat((PMPrintSession) m_macPrintSession, + (PMPageFormat) m_macPageFormat, + kPMDontWantBoolean) ; + + return true ; +} + +bool wxMacCarbonPrintData::TransferTo( wxPrintData &data ) +{ + OSStatus err = noErr ; + + UInt32 copies ; + err = PMGetCopies( m_macPrintSettings , &copies ) ; + if ( err == noErr ) + data.SetNoCopies( copies ) ; + + PMOrientation orientation ; + err = PMGetOrientation( m_macPageFormat , &orientation ) ; + if ( err == noErr ) + { + if ( orientation == kPMPortrait || orientation == kPMReversePortrait ) + { + data.SetOrientation( wxPORTRAIT ); + data.SetOrientationReversed( orientation == kPMReversePortrait ); + } + else + { + data.SetOrientation( wxLANDSCAPE ); + data.SetOrientationReversed( orientation == kPMReverseLandscape ); + } + } + + // collate cannot be set +#if 0 + { + wxCFStringRef name ; + PMPrinter printer ; + PMSessionGetCurrentPrinter( m_macPrintSession , + &printer ) ; + m_printerName = name.AsString() ; + } +#endif + +#ifndef __LP64__ + PMColorMode color ; + err = PMGetColorMode( m_macPrintSettings, &color ) ; + if ( err == noErr ) + data.SetColour( !(color == kPMBlackAndWhite) ) ; +#endif + PMDuplexMode mode = 0 ; + PMGetDuplex( (PMPrintSettings) m_macPrintSettings, &mode ) ; + switch( mode ) + { + case kPMDuplexNoTumble : + data.SetDuplex(wxDUPLEX_HORIZONTAL); + break ; + case kPMDuplexTumble : + data.SetDuplex(wxDUPLEX_VERTICAL); + break ; + case kPMDuplexNone : + default : + data.SetDuplex(wxDUPLEX_SIMPLEX); + break ; + } + // PMQualityMode not yet accessible via API + + PMPaper paper ; + PMGetPageFormatPaper( m_macPageFormat, &paper ); + + PMRect rPaper; + err = PMGetUnadjustedPaperRect( m_macPageFormat, &rPaper); + if ( err == noErr ) + { + wxSize sz((int)(( rPaper.right - rPaper.left ) * pt2mm + 0.5 ) , + (int)(( rPaper.bottom - rPaper.top ) * pt2mm + 0.5 )); + data.SetPaperSize(sz); + wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10)); + if (id != wxPAPER_NONE) + { + data.SetPaperId(id); + } + } + return true ; +} + +void wxMacCarbonPrintData::TransferFrom( wxPageSetupData *WXUNUSED(data) ) +{ + // should we setup the page rect here ? + // since MacOS sometimes has two same paper rects with different + // page rects we could make it roundtrip safe perhaps +} + +void wxMacCarbonPrintData::TransferTo( wxPageSetupData* data ) +{ + PMRect rPaper; + OSStatus err = PMGetUnadjustedPaperRect(m_macPageFormat, &rPaper); + if ( err == noErr ) + { + wxSize sz((int)(( rPaper.right - rPaper.left ) * pt2mm + 0.5 ) , + (int)(( rPaper.bottom - rPaper.top ) * pt2mm + 0.5 )); + data->SetPaperSize(sz); + + PMRect rPage ; + err = PMGetUnadjustedPageRect(m_macPageFormat , &rPage ) ; + if ( err == noErr ) + { + data->SetMinMarginTopLeft( wxPoint ( + (int)(((double) rPage.left - rPaper.left ) * pt2mm) , + (int)(((double) rPage.top - rPaper.top ) * pt2mm) ) ) ; + + data->SetMinMarginBottomRight( wxPoint ( + (wxCoord)(((double) rPaper.right - rPage.right ) * pt2mm), + (wxCoord)(((double) rPaper.bottom - rPage.bottom ) * pt2mm)) ) ; + + if ( data->GetMarginTopLeft().x < data->GetMinMarginTopLeft().x ) + data->SetMarginTopLeft( wxPoint( data->GetMinMarginTopLeft().x , + data->GetMarginTopLeft().y ) ) ; + + if ( data->GetMarginBottomRight().x < data->GetMinMarginBottomRight().x ) + data->SetMarginBottomRight( wxPoint( data->GetMinMarginBottomRight().x , + data->GetMarginBottomRight().y ) ); + + if ( data->GetMarginTopLeft().y < data->GetMinMarginTopLeft().y ) + data->SetMarginTopLeft( wxPoint( data->GetMarginTopLeft().x , data->GetMinMarginTopLeft().y ) ); + + if ( data->GetMarginBottomRight().y < data->GetMinMarginBottomRight().y ) + data->SetMarginBottomRight( wxPoint( data->GetMarginBottomRight().x , + data->GetMinMarginBottomRight().y) ); + } + } +} + +void wxMacCarbonPrintData::TransferTo( wxPrintDialogData* data ) +{ + UInt32 minPage , maxPage ; + PMGetPageRange( m_macPrintSettings , &minPage , &maxPage ) ; + data->SetMinPage( minPage ) ; + data->SetMaxPage( maxPage ) ; + UInt32 copies ; + PMGetCopies( m_macPrintSettings , &copies ) ; + data->SetNoCopies( copies ) ; + UInt32 from , to ; + PMGetFirstPage( m_macPrintSettings , &from ) ; + PMGetLastPage( m_macPrintSettings , &to ) ; + if ( to >= 0x7FFFFFFF ) // due to an OS Bug we don't get back kPMPrintAllPages + { + data->SetAllPages( true ) ; + // This means all pages, more or less + data->SetFromPage(1); + data->SetToPage(32000); + } + else + { + data->SetFromPage( from ) ; + data->SetToPage( to ) ; + data->SetAllPages( false ); + } +} + +void wxMacCarbonPrintData::TransferFrom( wxPrintDialogData* data ) +{ + // Respect the value of m_printAllPages + if ( data->GetAllPages() ) + PMSetPageRange( m_macPrintSettings , data->GetMinPage() , (UInt32) kPMPrintAllPages ) ; + else + PMSetPageRange( m_macPrintSettings , data->GetMinPage() , data->GetMaxPage() ) ; + PMSetCopies( m_macPrintSettings , data->GetNoCopies() , false ) ; + PMSetFirstPage( m_macPrintSettings , data->GetFromPage() , false ) ; + + if (data->GetAllPages() || data->GetFromPage() == 0) + PMSetLastPage( m_macPrintSettings , (UInt32) kPMPrintAllPages, true ) ; + else + PMSetLastPage( m_macPrintSettings , (UInt32) data->GetToPage() , false ) ; +} + +/* +* Printer +*/ + +wxMacPrinter::wxMacPrinter(wxPrintDialogData *data): +wxPrinterBase(data) +{ +} + +wxMacPrinter::~wxMacPrinter(void) +{ +} + +bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) +{ + sm_abortIt = false; + sm_abortWindow = NULL; + + if (!printout) + return false; + + printout->SetIsPreview(false); + if (m_printDialogData.GetMinPage() < 1) + m_printDialogData.SetMinPage(1); + if (m_printDialogData.GetMaxPage() < 1) + m_printDialogData.SetMaxPage(9999); + + // Create a suitable device context + wxPrinterDC *dc = NULL; + if (prompt) + { + wxMacPrintDialog dialog(parent, & m_printDialogData); + if (dialog.ShowModal() == wxID_OK) + { + dc = wxDynamicCast(dialog.GetPrintDC(), wxPrinterDC); + wxASSERT(dc); + m_printDialogData = dialog.GetPrintDialogData(); + } + } + else + { + dc = new wxPrinterDC( m_printDialogData.GetPrintData() ) ; + } + + // May have pressed cancel. + if (!dc || !dc->IsOk()) + { + if (dc) + delete dc; + return false; + } + + // on the mac we have always pixels as addressing mode with 72 dpi + printout->SetPPIScreen(72, 72); + PMResolution res; + wxMacCarbonPrintData* nativeData = (wxMacCarbonPrintData*) + (m_printDialogData.GetPrintData().GetNativeData()); +#if wxOSX_USE_CARBON + PMGetResolution((PMPageFormat) (nativeData->m_macPageFormat), &res); +#else + PMPrinter printer; + PMSessionGetCurrentPrinter(nativeData->m_macPrintSession, &printer); + PMPrinterGetOutputResolution( printer, nativeData->m_macPrintSettings, &res) ; +#endif + printout->SetPPIPrinter(int(res.hRes), int(res.vRes)); + + // Set printout parameters + printout->SetDC(dc); + + int w, h; + dc->GetSize(&w, &h); + printout->SetPageSizePixels((int)w, (int)h); + printout->SetPaperRectPixels(dc->GetPaperRect()); + wxCoord mw, mh; + dc->GetSizeMM(&mw, &mh); + printout->SetPageSizeMM((int)mw, (int)mh); + + // Create an abort window + wxBeginBusyCursor(); + + printout->OnPreparePrinting(); + + // Get some parameters from the printout, if defined + int fromPage, toPage; + int minPage, maxPage; + printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); + + if (maxPage == 0) + { + wxEndBusyCursor(); + return false; + } + + // Only set min and max, because from and to have been + // set by the user + m_printDialogData.SetMinPage(minPage); + m_printDialogData.SetMaxPage(maxPage); + + printout->OnBeginPrinting(); + + bool keepGoing = true; + + if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage())) + { + wxEndBusyCursor(); + wxMessageBox(wxT("Could not start printing."), wxT("Print Error"), wxOK, parent); + } + + int pn; + for (pn = m_printDialogData.GetFromPage(); + keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn); + pn++) + { + if (sm_abortIt) + { + keepGoing = false; + break; + } + else + { + dc->StartPage(); + keepGoing = printout->OnPrintPage(pn); + dc->EndPage(); + } + } + printout->OnEndDocument(); + + printout->OnEndPrinting(); + + if (sm_abortWindow) + { + sm_abortWindow->Show(false); + delete sm_abortWindow; + sm_abortWindow = NULL; + } + + wxEndBusyCursor(); + + delete dc; + + return true; +} + +wxDC* wxMacPrinter::PrintDialog(wxWindow *parent) +{ + wxDC* dc = (wxDC*) NULL; + + wxPrintDialog dialog(parent, & m_printDialogData); + int ret = dialog.ShowModal(); + + if (ret == wxID_OK) + { + dc = dialog.GetPrintDC(); + m_printDialogData = dialog.GetPrintDialogData(); + } + + return dc; +} + +bool wxMacPrinter::Setup(wxWindow *WXUNUSED(parent)) +{ +#if 0 + wxPrintDialog dialog(parent, & m_printDialogData); + dialog.GetPrintDialogData().SetSetupDialog(true); + + int ret = dialog.ShowModal(); + + if (ret == wxID_OK) + m_printDialogData = dialog.GetPrintDialogData(); + + return (ret == wxID_OK); +#endif + + return wxID_CANCEL; +} + +/* +* Print preview +*/ + +wxMacPrintPreview::wxMacPrintPreview(wxPrintout *printout, + wxPrintout *printoutForPrinting, + wxPrintDialogData *data) + : wxPrintPreviewBase(printout, printoutForPrinting, data) +{ + DetermineScaling(); +} + +wxMacPrintPreview::wxMacPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data): +wxPrintPreviewBase(printout, printoutForPrinting, data) +{ + DetermineScaling(); +} + +wxMacPrintPreview::~wxMacPrintPreview(void) +{ +} + +bool wxMacPrintPreview::Print(bool interactive) +{ + if (!m_printPrintout) + return false; + + wxMacPrinter printer(&m_printDialogData); + return printer.Print(m_previewFrame, m_printPrintout, interactive); +} + +void wxMacPrintPreview::DetermineScaling(void) +{ + int screenWidth , screenHeight ; + wxDisplaySize( &screenWidth , &screenHeight ) ; + + wxSize ppiScreen( 72 , 72 ) ; + wxSize ppiPrinter( 72 , 72 ) ; + + // Note that with Leopard, screen dpi=72 is no longer a given + m_previewPrintout->SetPPIScreen( ppiScreen.x , ppiScreen.y ) ; + + wxCoord w , h ; + wxCoord ww, hh; + wxRect paperRect; + + // Get a device context for the currently selected printer + wxPrinterDC printerDC(m_printDialogData.GetPrintData()); + if (printerDC.IsOk()) + { + printerDC.GetSizeMM(&ww, &hh); + printerDC.GetSize( &w , &h ) ; + ppiPrinter = printerDC.GetPPI() ; + paperRect = printerDC.GetPaperRect(); + m_isOk = true ; + } + else + { + // use some defaults + w = 8 * 72 ; + h = 11 * 72 ; + ww = (wxCoord) (w * 25.4 / ppiPrinter.x) ; + hh = (wxCoord) (h * 25.4 / ppiPrinter.y) ; + paperRect = wxRect(0, 0, w, h); + m_isOk = false ; + } + m_pageWidth = w; + m_pageHeight = h; + + m_previewPrintout->SetPageSizePixels(w , h) ; + m_previewPrintout->SetPageSizeMM(ww, hh); + m_previewPrintout->SetPaperRectPixels(paperRect); + m_previewPrintout->SetPPIPrinter( ppiPrinter.x , ppiPrinter.y ) ; + + m_previewScaleX = float(ppiScreen.x) / ppiPrinter.x; + m_previewScaleY = float(ppiScreen.y) / ppiPrinter.y; +} + +#endif diff --git a/src/osx/fontutil.cpp b/src/osx/fontutil.cpp new file mode 100644 index 0000000000..6e21a539dd --- /dev/null +++ b/src/osx/fontutil.cpp @@ -0,0 +1,88 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/osx/fontutil.cpp +// Purpose: font-related helper functions for OS X +// Author: Vadim Zeitlin, Stefan Csomor +// Modified by: +// Created: 05.11.99 +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/string.h" + #include "wx/wxcrtvararg.h" + #include "wx/log.h" + #include "wx/intl.h" +#endif + +#include "wx/fontutil.h" +#include "wx/fontmap.h" +#include "wx/encinfo.h" +#include "wx/tokenzr.h" + + +// convert to/from the string representation: +// format is facename[;charset] +// +bool wxNativeEncodingInfo::FromString( const wxString& s ) +{ + wxStringTokenizer tokenizer(s, wxT(";")); + + facename = tokenizer.GetNextToken(); + if ( !facename ) + return false; + + wxString tmp = tokenizer.GetNextToken(); + if ( !tmp ) + { + // default charset (don't use DEFAULT_CHARSET though because of subtle + // Windows 9x/NT differences in handling it) + charset = 0; + } + else + { + if ( wxSscanf( tmp, wxT("%u"), &charset ) != 1 ) + // should be a number! + return false; + } + + return true; +} + +wxString wxNativeEncodingInfo::ToString() const +{ + wxString s(facename); + if ( charset != 0 ) + s << wxT(';') << charset; + + return s; +} + +// ---------------------------------------------------------------------------- +// helper functions +// ---------------------------------------------------------------------------- + +bool wxGetNativeFontEncoding( wxFontEncoding encoding, wxNativeEncodingInfo *info ) +{ + wxCHECK_MSG( info, false, wxT("bad pointer in wxGetNativeFontEncoding") ); + + if ( encoding == wxFONTENCODING_DEFAULT ) + encoding = wxFont::GetDefaultEncoding(); + + info->encoding = encoding; + + return true; +} + +bool wxTestFontEncoding( const wxNativeEncodingInfo& WXUNUSED(info) ) +{ + // basically we should be able to support every encoding via the OS + return true; +} diff --git a/src/osx/imagelist.cpp b/src/osx/imagelist.cpp new file mode 100644 index 0000000000..9bd77204a4 --- /dev/null +++ b/src/osx/imagelist.cpp @@ -0,0 +1,309 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/osx/imaglist.cpp +// Purpose: +// Author: Robert Roebling +// RCS_ID: $Id$ +// Copyright: (c) 1998 Robert Roebling +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#if wxUSE_IMAGLIST + +#include "wx/imaglist.h" + +#ifndef WX_PRECOMP + #include "wx/dc.h" + #include "wx/icon.h" + #include "wx/image.h" +#endif + +IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject) + + +wxImageList::wxImageList( int width, int height, bool mask, int initialCount ) +{ + (void)Create(width, height, mask, initialCount); +} + +wxImageList::~wxImageList() +{ + (void)RemoveAll(); +} + +int wxImageList::GetImageCount() const +{ + return m_images.GetCount(); +} + +bool wxImageList::Create( int width, int height, bool WXUNUSED(mask), int WXUNUSED(initialCount) ) +{ + m_width = width; + m_height = height; + + return Create(); +} + +bool wxImageList::Create() +{ + return true; +} + +int wxImageList::Add( const wxIcon &bitmap ) +{ + wxASSERT_MSG( (bitmap.GetWidth() == m_width && bitmap.GetHeight() == m_height) + || (m_width == 0 && m_height == 0), + _T("invalid bitmap size in wxImageList: this might work ") + _T("on this platform but definitely won't under Windows.") ); + + m_images.Append( new wxIcon( bitmap ) ); + + if (m_width == 0 && m_height == 0) + { + m_width = bitmap.GetWidth(); + m_height = bitmap.GetHeight(); + } + + return m_images.GetCount() - 1; +} + +int wxImageList::Add( const wxBitmap &bitmap ) +{ + wxASSERT_MSG( (bitmap.GetWidth() >= m_width && bitmap.GetHeight() == m_height) + || (m_width == 0 && m_height == 0), + _T("invalid bitmap size in wxImageList: this might work ") + _T("on this platform but definitely won't under Windows.") ); + + // Mimic behavior of Windows ImageList_Add that automatically breaks up the added + // bitmap into sub-images of the correct size + if (m_width > 0 && bitmap.GetWidth() > m_width && bitmap.GetHeight() >= m_height) + { + int numImages = bitmap.GetWidth() / m_width; + for (int subIndex = 0; subIndex < numImages; subIndex++) + { + wxRect rect(m_width * subIndex, 0, m_width, m_height); + wxBitmap tmpBmp = bitmap.GetSubBitmap(rect); + m_images.Append( new wxBitmap(tmpBmp) ); + } + } + else + { + m_images.Append( new wxBitmap(bitmap) ); + } + + if (m_width == 0 && m_height == 0) + { + m_width = bitmap.GetWidth(); + m_height = bitmap.GetHeight(); + } + + return m_images.GetCount() - 1; +} + +int wxImageList::Add( const wxBitmap& bitmap, const wxBitmap& mask ) +{ + wxBitmap bmp( bitmap ); + if (mask.Ok()) + bmp.SetMask( new wxMask( mask ) ); + + return Add( bmp ); +} + +int wxImageList::Add( const wxBitmap& bitmap, const wxColour& maskColour ) +{ + wxImage img = bitmap.ConvertToImage(); + img.SetMaskColour( maskColour.Red(), maskColour.Green(), maskColour.Blue() ); + + return Add( wxBitmap( img ) ); +} + +// Get the bitmap +wxBitmap wxImageList::GetBitmap(int index) const +{ + wxList::compatibility_iterator node = m_images.Item( index ); + + wxCHECK_MSG( node, wxNullBitmap , wxT("wrong index in image list") ); + + wxObject* obj = (wxObject*) node->GetData(); + if ( obj == NULL ) + return wxNullBitmap ; + else if ( obj->IsKindOf(CLASSINFO(wxIcon)) ) + return wxBitmap( *(wx_static_cast(wxIcon*, obj)) ) ; + else + return *(wx_static_cast(wxBitmap*, obj)) ; +} + +// Get the icon +wxIcon wxImageList::GetIcon(int index) const +{ + wxList::compatibility_iterator node = m_images.Item( index ); + + wxCHECK_MSG( node, wxNullIcon , wxT("wrong index in image list") ); + + wxObject* obj = (wxObject*) node->GetData(); + if ( obj == NULL ) + return wxNullIcon ; + else if ( obj->IsKindOf(CLASSINFO(wxBitmap)) ) + { + wxFAIL_MSG( wxT("cannot convert from bitmap to icon") ) ; + return wxNullIcon ; + } + else + return *(wx_static_cast(wxIcon*, obj)) ; +} + +bool wxImageList::Replace( int index, const wxBitmap &bitmap ) +{ + wxList::compatibility_iterator node = m_images.Item( index ); + + wxCHECK_MSG( node, false, wxT("wrong index in image list") ); + + wxBitmap* newBitmap = new wxBitmap( bitmap ); + + if (index == (int) m_images.GetCount() - 1) + { + delete node->GetData(); + + m_images.Erase( node ); + m_images.Append( newBitmap ); + } + else + { + wxList::compatibility_iterator next = node->GetNext(); + delete node->GetData(); + + m_images.Erase( node ); + m_images.Insert( next, newBitmap ); + } + + return true; +} + +bool wxImageList::Replace( int index, const wxIcon &bitmap ) +{ + wxList::compatibility_iterator node = m_images.Item( index ); + + wxCHECK_MSG( node, false, wxT("wrong index in image list") ); + + wxIcon* newBitmap = new wxIcon( bitmap ); + + if (index == (int) m_images.GetCount() - 1) + { + delete node->GetData(); + m_images.Erase( node ); + m_images.Append( newBitmap ); + } + else + { + wxList::compatibility_iterator next = node->GetNext(); + delete node->GetData(); + m_images.Erase( node ); + m_images.Insert( next, newBitmap ); + } + + return true; +} + +bool wxImageList::Replace( int index, const wxBitmap &bitmap, const wxBitmap &mask ) +{ + wxList::compatibility_iterator node = m_images.Item( index ); + + wxCHECK_MSG( node, false, wxT("wrong index in image list") ); + + wxBitmap* newBitmap = new wxBitmap(bitmap); + + if (index == (int) m_images.GetCount() - 1) + { + delete node->GetData(); + m_images.Erase( node ); + m_images.Append( newBitmap ); + } + else + { + wxList::compatibility_iterator next = node->GetNext(); + delete node->GetData(); + m_images.Erase( node ); + m_images.Insert( next, newBitmap ); + } + + if (mask.Ok()) + newBitmap->SetMask(new wxMask(mask)); + + return true; +} + +bool wxImageList::Remove( int index ) +{ + wxList::compatibility_iterator node = m_images.Item( index ); + + wxCHECK_MSG( node, false, wxT("wrong index in image list") ); + + delete node->GetData(); + m_images.Erase( node ); + + return true; +} + +bool wxImageList::RemoveAll() +{ + WX_CLEAR_LIST(wxList, m_images); + m_images.Clear(); + + return true; +} + +bool wxImageList::GetSize( int index, int &width, int &height ) const +{ + width = 0; + height = 0; + + wxList::compatibility_iterator node = m_images.Item( index ); + + wxCHECK_MSG( node, false, wxT("wrong index in image list") ); + + wxObject *obj = (wxObject*)node->GetData(); + if (obj->IsKindOf(CLASSINFO(wxIcon))) + { + wxIcon *bm = wx_static_cast( wxIcon* , obj ) ; + width = bm->GetWidth(); + height = bm->GetHeight(); + } + else + { + wxBitmap *bm = wx_static_cast( wxBitmap* , obj ) ; + width = bm->GetWidth(); + height = bm->GetHeight(); + } + + return true; +} + +bool wxImageList::Draw( + int index, wxDC &dc, int x, int y, + int flags, bool WXUNUSED(solidBackground) ) +{ + wxList::compatibility_iterator node = m_images.Item( index ); + + wxCHECK_MSG( node, false, wxT("wrong index in image list") ); + + wxObject *obj = (wxObject*)node->GetData(); + if (obj->IsKindOf(CLASSINFO(wxIcon))) + { + wxIcon *bm = wx_static_cast( wxIcon* , obj ) ; + dc.DrawIcon( *bm , x, y ); + } + else + { + wxBitmap *bm = wx_static_cast( wxBitmap* , obj ) ; + dc.DrawBitmap( *bm, x, y, (flags & wxIMAGELIST_DRAW_TRANSPARENT) > 0 ); + } + + return true; +} + +#endif // wxUSE_IMAGLIST diff --git a/src/osx/minifram.cpp b/src/osx/minifram.cpp new file mode 100644 index 0000000000..a798d3ea9a --- /dev/null +++ b/src/osx/minifram.cpp @@ -0,0 +1,20 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/osx/minifram.cpp +// Purpose: wxMiniFrame. Optional; identical to wxFrame if not supported. +// Author: Stefan Csomor +// Modified by: +// Created: 1998-01-01 +// RCS-ID: $Id$ +// Copyright: (c) Stefan Csomor +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/wxprec.h" + +#if wxUSE_MINIFRAME + +#include "wx/minifram.h" + +IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame, wxFrame) + +#endif // wxUSE_MINIFRAME diff --git a/src/osx/palette.cpp b/src/osx/palette.cpp new file mode 100644 index 0000000000..c92d1da1ea --- /dev/null +++ b/src/osx/palette.cpp @@ -0,0 +1,155 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/osx/palette.cpp +// Purpose: wxPalette +// Author: Stefan Csomor +// Modified by: +// Created: 1998-01-01 +// RCS-ID: $Id$ +// Copyright: (c) Stefan Csomor +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/wxprec.h" + +#if wxUSE_PALETTE + +#include "wx/palette.h" +#include "wx/colour.h" + +IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject) + +// ============================================================================ +// wxPaletteRefData +// ============================================================================ + +class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData +{ +public: + wxPaletteRefData(); + wxPaletteRefData(const wxPaletteRefData& data); + virtual ~wxPaletteRefData(); + + virtual bool IsOk() const { return m_count > 0; } + +protected: + wxColour* m_palette; + wxInt32 m_count; + + friend class WXDLLIMPEXP_FWD_CORE wxPalette; + + DECLARE_NO_ASSIGN_CLASS(wxPaletteRefData) +}; + +wxPaletteRefData::wxPaletteRefData() +{ + m_palette = NULL; + m_count = 0; +} + +wxPaletteRefData::wxPaletteRefData(const wxPaletteRefData& data) +{ + m_count = data.m_count; + m_palette = new wxColour[m_count]; + for ( wxInt32 i = 0; i < m_count; i++ ) + m_palette[i] = data.m_palette[i]; +} + +wxPaletteRefData::~wxPaletteRefData() +{ + delete[] m_palette; +} + +// ============================================================================ +// wxPalette +// ============================================================================ + +wxPalette::wxPalette() +{ +} + +wxPalette::wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) +{ + Create(n, red, green, blue); +} + +wxPalette::~wxPalette() +{ +} + +bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) +{ + UnRef(); + + m_refData = new wxPaletteRefData; + + M_PALETTEDATA->m_count = n ; + M_PALETTEDATA->m_palette = new wxColour[n] ; + + for ( int i = 0 ; i < n ; ++i) + { + M_PALETTEDATA->m_palette[i].Set( red[i] , green[i] , blue[i] ) ; + } + + return false; +} + +int wxPalette::GetPixel(unsigned char red, unsigned char green, unsigned char blue) const +{ + if ( !m_refData ) + return wxNOT_FOUND; + + long bestdiff = 3 * 256 ; + long bestpos = 0 ; + long currentdiff ; + + for ( int i = 0 ; i < M_PALETTEDATA->m_count ; ++i ) + { + const wxColour& col = M_PALETTEDATA->m_palette[i] ; + currentdiff = abs ( col.Red() - red ) + abs( col.Green() - green ) + abs ( col.Blue() - blue ) ; + if ( currentdiff < bestdiff ) + { + bestdiff = currentdiff ; + bestpos = i ; + if ( bestdiff == 0 ) + break ; + } + } + + return bestpos; +} + +bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const +{ + if ( !m_refData ) + return false; + + if (index < 0 || index >= M_PALETTEDATA->m_count) + return false; + + const wxColour& col = M_PALETTEDATA->m_palette[index] ; + *red = col.Red() ; + *green = col.Green() ; + *blue = col.Blue() ; + + return true; +} + +int wxPalette::GetColoursCount() const +{ + if (m_refData) + return M_PALETTEDATA->m_count; + + return 0; +} + +wxGDIRefData *wxPalette::CreateGDIRefData() const +{ + return new wxPaletteRefData; +} + +wxGDIRefData *wxPalette::CloneGDIRefData(const wxGDIRefData *data) const +{ + return new wxPaletteRefData(*wx_static_cast(const wxPaletteRefData *, data)); +} + +#endif // wxUSE_PALETTE diff --git a/src/osx/pen.cpp b/src/osx/pen.cpp index 260f1abc82..e902ada8c6 100644 --- a/src/osx/pen.cpp +++ b/src/osx/pen.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/pen.cpp +// Name: src/osx/pen.cpp // Purpose: wxPen // Author: Stefan Csomor // Modified by: